question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ambiguous invocation when using BeEquivalentTo with Excluding with <6.0

See original GitHub issue

This code brings compiler exception “ambiguous invocation” when using 6.0.0 version, but works with lower versions.

private class Test1
{
    public string Name { get; set; }
}

private class Test2
{
    public string Name { get; set; }
}

[Fact]
public async Task Test_Case()
{
    var test1 = new Test1();
    var test2 = new Test2();

    //Work around
    //Expression<Func<IMemberInfo, bool>> expression = info => info.Name == "Level.Level.Text";
    //test1.Should().BeEquivalentTo(test2, opts => opts.Excluding(expression));

    test1.Should().BeEquivalentTo(test2,
        opts => opts.Excluding(ctx => ctx.SelectedMemberPath == "Level.Level.Text"));
}

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
ajeckmanscommented, Aug 16, 2021

SelectedMemberPath was renamed to Path. So test1.Should().BeEquivalentTo(test2, opts => opts.Excluding(ctx => ctx.Path == "Level.Level.Text")); should work.

The docs unfortunately do not reflect this yet. Nor was it mentioned as a breaking change in the release notes.

0reactions
ajeckmanscommented, Aug 17, 2021

@dennisdoomen There is also the issue of the docs all mentioning the “old” way and not the new. Is there a guideline on how to write the documentation? (I think only https://github.com/fluentassertions/fluentassertions/blob/master/docs/_pages/objectgraphs.md mentions it)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ambiguous Call when using Should().NotBeNull() on As item
This started happening when I upgraded from fluent assertions 5 to 6. Any Idea as to how I can go about resolving this...
Read more >
Upgrading to version 6.0 - Fluent Assertions
With Fluent Assertion 5.0 we redefined equivalency to let the expectation drive the comparison. If your expectation is an interface we will by...
Read more >
Fluent Assertions 6.0, the biggest release ever
In the past, we would invoke asynchronous code by wrapping it in a synchronously blocking call. ... using the same engine as BeEquivalentTo...
Read more >
Classes - C# language specification
In this case, the invocation creates an instance of the parameter array type with a length corresponding to the number of arguments, initializes ......
Read more >
Red Hat JBoss Enterprise Application Platform 7.4
your deployments, invocations between deployments using different security ... Due to the changes in JBoss EAP 6 to use modular class loading, you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found