You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With xunit 2.6.1 when using C# 12 collection expressions, CS0121 compiler errors occur when using code similar to the following:
[Fact]publicstaticvoidCS0121(){int[]actual=[1,2,3];// Assume this value would come from the code being tested
Assert.Equal([1,2,3], actual);}
CS0121 The call is ambiguous between the following methods or properties: 'Assert.Equal<T>(T[], T[])' and 'Assert.Equal<T>(ReadOnlySpan<T>, Span<T>)'
This can be worked around by using the previous syntax to create a literal array, but this generates an IDE0300 analyser suggestion in Visual Studio to change it back to a collection expression.
This issue is similar to #2811, so this might be a duplicate of that, but I only ran into this after updating existing tests to use C# 12 and adopting collection expressions.
The text was updated successfully, but these errors were encountered:
martincostello
added a commit
to martincostello/lambda-test-server
that referenced
this issue
Nov 5, 2023
Unfortunately there will always be cases of compiler ambiguity given the number of overloads the Assert.Equal has. Removing some of those overloads is not really an option.
With xunit 2.6.1 when using C# 12 collection expressions, CS0121 compiler errors occur when using code similar to the following:
This can be worked around by using the previous syntax to create a literal array, but this generates an IDE0300 analyser suggestion in Visual Studio to change it back to a collection expression.
Otherwise, the workaround is to assign the expected value to a variable:
This issue is similar to #2811, so this might be a duplicate of that, but I only ran into this after updating existing tests to use C# 12 and adopting collection expressions.
The text was updated successfully, but these errors were encountered: