Can you post more example code and the warning in full? It’s hard to say with little context.
The serialisation depth warning only really comes up with recursive or cyclical references are in play. One class having an instance to another class, where no cyclical references are present shouldn’t be throwing this warning.