Skip to content

.NET 6 RC 1: changes to overload resolution? Breaks NUnit? #56167

@jonathanpeppers

Description

@jonathanpeppers

Version Used:

> dotnet --version
6.0.100-rc.1.21452.4

Steps to Reproduce:

  1. Unzip this somewhere: repro.zip
  2. dotnet build fails with:
Program.cs(3,8): error CS0121: The call is ambiguous between the following methods or properties: 'Assert.That(TestDelegate, IResolveConstraint)' and 'Assert.That<TActual>(TActual, IResolveConstraint)'
  1. If you uncomment <LangVersion>9.0</LangVersion> it works.

The problematic method is NUnit:

Assert.That(() => { }, Throws.Nothing);

We hit this in .NET MAUI here:

dotnet/maui#2369

The breaking change might be expected. The part that is concerning, is we had some unit tests fail at runtime due to a similar issue, where changing LangVersion=9.0 fixed the test failure:

https://github.com/dotnet/maui/blob/f22a61ac027bb115a115a0f493c97ba0c98fa3e8/src/Core/tests/UnitTests/LifecycleEvents/LifecycleEventsTests.cs#L119-L136

I thought it might be worth checking into, thanks!

Expected Behavior:

NUnit Assert.That(() => { }, Throws.Nothing); compiles in C# 10?

Actual Behavior:

NUnit Assert.That(() => { }, Throws.Nothing); doesn't compile under C# 10.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions