Skip to content

ResolveTypeNameDifference does not handle generic types well #2289

@mikkelbu

Description

@mikkelbu

Given two different classes that gives the same result via ToString(), e.g.

class Dummy
{
    internal readonly int value;

    public Dummy(int value)
    {
        this.value = value;
    }

    public override string ToString()
    {
        return "Dummy " + value;
    }
}

class Dummy1
{
    internal readonly int value;

    public Dummy1(int value)
    {
        this.value = value;
    }

    public override string ToString()
    {
        return "Dummy " + value;
    }
}

Then the following tests fails correctly with a message from ResolveTypeNameDifference that describes the type difference.

[Test]
public void SomeTest()
{
    var d1 = new Dummy(12);
    var d2 = new Dummy1(12);
    var tuple1 = new KeyValuePair<Dummy>("", d1);
    var tuple2 = new KeyValuePair<Dummy1>("", d2);

    Assert.That(tuple1, Is.EqualTo(tuple2));
}

The error message, however, does not handle the generic class very well

  Expected: (Dummy 12) (ValueTupleEqualityTests+Dummy1])
  But was:  (Dummy 12) (ValueTupleEqualityTests+Dummy])

I would have expected something like

  Expected: (Dummy 12) (KeyValuePair`2[String,ValueTupleEqualityTests+Dummy1])
  But was:  (Dummy 12) (KeyValuePair`2[String,ValueTupleEqualityTests+Dummy])

At the moment the code just splits on "." and there is no special handling of generic types.

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions