Some existing 3rd party Roslyn analyzers are broken by C# 8 NRTs #33199
Open
Description
opened on Feb 7, 2019
Version Used:
VS preview 2.2, .Net preview 3.0.100-preview-010184, C# 8 with nullable reference types enabled.
Steps to Reproduce:
- Use xUnit with Roslyn Analyzer integration
- Add a test class like this, which uses the
MemberData
attribute:
public class UnitTest1
{
public static readonly object[][] Data =
{
new object[] { "1" },
new object[] { "2" },
};
[Theory, MemberData(nameof(Data))]
public void Test1(string value)
{
Assert.NotNull(value);
}
}
- Enable nullable reference types.
Expected Behavior:
There are no errors or warnings.
Actual Behavior:
If you add #nullable enable
at the top, you get the following error:
error xUnit1019: MemberData must reference a data type assignable to 'System.Collections.Generic.IEnumerable<object[]>'. The referenced type 'object[][]' is not valid.
I reported this to the xUnit project here: xunit/xunit#1897
They asked me to report this to Roslyn instead. Basically, this appears to be a breaking API change for Roslyn analyzers.
Activity