Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to handle circular references #43

Open
mr-at0s opened this issue Aug 21, 2018 · 9 comments
Open

How to handle circular references #43

mr-at0s opened this issue Aug 21, 2018 · 9 comments
Assignees
Labels

Comments

@mr-at0s
Copy link

mr-at0s commented Aug 21, 2018

Some objects may have circular references. How should we handle this? Maybe, throwing an exception if someone is registering such an object? Or any idea on this?

@mfidemraizer mfidemraizer self-assigned this Aug 22, 2018
@mfidemraizer
Copy link
Owner

Hey!

I'm not sure what could be the best solution here. Ignoring them, throwing that exception...

Anyway, is this throwing exceptions? Probably I'm mistaken, but TrackerDog independently handles each property change.

@mr-at0s
Copy link
Author

mr-at0s commented Aug 22, 2018

Currently, it does not throw an exception. It just runs into that cycle and never returns (until program is out of memory).

Potential solution: The user could provide an error callback that is called when a circular references is detected. But in each case a continuous check for circular references could be time consuming, wouldn't it?

Maybe, it is just a bad design in client's code (my) to allow potential circular references, e.g., tracking changes in a doubly linked list.

@mfidemraizer
Copy link
Owner

mfidemraizer commented Aug 22, 2018

@mr-at0s It shouldn't be a bad design per se, because usually when you implement an 1-n association, you may want a reference of both side in both sides:

public class Foo
{
      public IList<Bar> Bars { get; set; }
}

public class Bar
{
      public Foo Foo { get; set; }
}

Maybe a possible solution could be ignoring them with some attribute:

public class Foo
{
      public IList<Bar> Bars { get; set; }
}

public class Bar
{
      [IgnoreDataMember]
      public Foo Foo { get; set; }
}

Actually

What do you think about this?

@mfidemraizer
Copy link
Owner

Also, maybe the whole TrackerDog's configuration API could provide something like track this but (some given properties).

@mr-at0s
Copy link
Author

mr-at0s commented Aug 22, 2018

Yes, Ignore might be a solution for such scenarios.

@mr-at0s mr-at0s closed this as completed Aug 22, 2018
@mr-at0s mr-at0s reopened this Aug 22, 2018
@mfidemraizer
Copy link
Owner

Do you need this feature already?

@mr-at0s
Copy link
Author

mr-at0s commented Aug 23, 2018

Yes, but the performance issue (see #45) has got higher priority for us.

@mfidemraizer
Copy link
Owner

I see. Are you woking in a .NET Core app?

@mr-at0s
Copy link
Author

mr-at0s commented Aug 23, 2018

No, these are standard Windows .Net Framework projects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants