Closed
Description
Using C# 12 collection literals with .NET 8 can cause xUnit1026 false positives.
For example:
public class FalsePositive
{
[Theory]
[InlineData("hello")]
public void XUnit1026_False_Positive(string greeting)
{
string[] values = [greeting, "world"];
string actual = string.Join(' ', values);
Assert.Equal("hello world", actual);
}
}
Produces this warning:
Theory method 'XUnit1026_False_Positive' on test class 'FalsePositive' does not use parameter 'greeting'. Use the parameter, or remove the parameter and associated data.