Skip to content

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

@eriksimonic

Description

@eriksimonic

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions