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

Infinite loop when object contains a reference to Net Type. #21

Open
eriksimonic opened this issue Apr 24, 2023 · 1 comment
Open

Infinite loop when object contains a reference to Net Type. #21

eriksimonic opened this issue Apr 24, 2023 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@eriksimonic
Copy link

This example will course a endless loop on private properties of Type.
Is this intended behavior? How do I fix this.

class TypeReference
{
private Type   _type;
public  string AssemblyQualifiedName { get; set; }

public Type GetTypeInt() => _type;
public TypeReference(Type type)
{
    _type   = type;
    AssemblyQualifiedName = type.AssemblyQualifiedName;
}
}

class StaticValueProvider
{
public TypeReference Source { get; set; }
public object       Value  { get; set; }
}

var staticValueProvider = new StaticValueProvider()
{
Source = new TypeReference(typeof(string)),
Value  = "wa"
};


var staticValueProvider2 = new StaticValueProvider()
{
Source = new TypeReference(typeof(string)),
Value  = "wa"
};

var differences1 = staticValueProvider.Diff(staticValueProvider2);

If I do this comparison it works, but fields can be public.

  var differences1 = staticValueProvider.Diff(staticValueProvider2,
                                              ComparisonOptions.ExcludeList |
                                              ComparisonOptions.CompareCollections |
  //                                            ComparisonOptions.CompareFields |
                                              ComparisonOptions.CompareProperties);
@replaysMike
Copy link
Owner

I'm not sure at the moment! I will investigate this in the morning and see if it's somehow getting around the reference tracker. Will follow up tomorrow

@replaysMike replaysMike self-assigned this Apr 24, 2023
@replaysMike replaysMike added the bug Something isn't working label Apr 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants