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

Class with IList<Uri> throws AmbiguousComparerOverrideResolutionException #40

Closed
DCourtel opened this issue Apr 11, 2022 · 2 comments
Closed
Labels
Milestone

Comments

@DCourtel
Copy link

A class like this:

public class TestClass
{
    public IList<Uri> Urls { get; } = new List<Uri>();
}

Throws an AmbiguousComparerOverrideResolutionException when compared with this code:

public void CompareTestClass()
{
    var obj1 = new TestClass();
    obj1.Urls.Add(new Uri("https://Test.com"));
    var obj2 = new TestClass();
    obj2.Urls.Add(new Uri("https://Test.com"));

    var comparer = new ObjectsComparer.Comparer<TestClass>();
    //  comparer.AddComparerOverride<IList<Uri>>(new ListOfUriComparer());
    IEnumerable<Difference> differences = new List<Difference>();
    comparer.Compare(obj1, obj2, out differences);
}

Uncommenting the line with the AddComparerOverride method solves the issue but the comparer should be able to compare list of Uri natively.
Also, the error message is misleading:

Unable to resolve comparer for type System.Uri. More than one value comparer meet criteria for this type.

It should reference IList of Uri.
Thanks.

@ValeraT1982 ValeraT1982 pinned this issue Apr 11, 2022
@ValeraT1982 ValeraT1982 added this to the 2.0 milestone May 4, 2022
@ValeraT1982 ValeraT1982 added the bug label May 4, 2022
@ValeraT1982
Copy link
Owner

Fix submitted. Will be available in the next version.

@DCourtel
Copy link
Author

DCourtel commented May 4, 2022

Thanks.

@DCourtel DCourtel closed this as completed May 4, 2022
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