AnyDiff icon indicating copy to clipboard operation
AnyDiff copied to clipboard

Infinite loop when object contains a reference to Net Type.

Open eriksimonic opened this issue 2 years ago • 1 comments

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);

eriksimonic avatar Apr 24 '23 07:04 eriksimonic

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 avatar Apr 24 '23 07:04 replaysMike