Skip to content

Some existing 3rd party Roslyn analyzers are broken by C# 8 NRTs #33199

Open
@CornedBee

Description

Version Used:

VS preview 2.2, .Net preview 3.0.100-preview-010184, C# 8 with nullable reference types enabled.

Steps to Reproduce:

  1. Use xUnit with Roslyn Analyzer integration
  2. 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);
        }
    }
  1. 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions