Table of Contents

Analyzers 2.0.0-pre.40 2026 April 11

Today, we're shipping three new prereleases:

  • xUnit.net Core Framework v3 4.0.0-pre.81 (release notes)
  • xUnit.net Analyzers 2.0.0-pre.40
  • xUnit.net Visual Studio adapter 4.0.0-pre.4 (release notes)

This is the second prerelease build for the 2.0 release. This is shipping alongside Core Framework v3 4.0.0-pre.81, and the primary feature of this release is adding diagnostics that were previously emitted by the source generators in Native AOT.

As always, we'd like to thank all the users who contributed to the success of xUnit.net through usage, feedback, and code. 🎉

Release Notes

These release notes are a list of changes from 2.0.0-pre.9 to 2.0.0-pre.40.

Usage Analyzers

  • We have updated xUnit1007 to stop triggering when the [ClassData] source implements either IEnumerable or IEnumerable<object>. Although these signatures are not ideal, they do permit returning data that otherwise implements one of the required contracts (object[] for v2 and v3, as well as ITheoryDataRow and ITuple for v3). xunit/xunit#3507

  • We have updated xUnit1019 to stop triggering when the [MemberData] source implements either IEnumerable or IEnumerable<object>. Although these signatures are not ideal, they do permit returning data that otherwise implements one of the required contracts (object[] for v2 and v3, as well as ITheoryDataRow and ITuple for v3). xunit/xunit#3508

  • We have added xUnit1054 ("Properties used for conditional skipping must be public, static, and return bool"). This diagnostic is raised when either SkipUnless or SkipWhen properties don't point to an appropriate property.

  • We have added xUnit1055 ("Conditional skipping cannot set both SkipUnless and SkipWhen"). This diagnostic is raised when both SkipUnless and SkipWhen are set.

  • We have added xUnit1056 ("Type must have a single public non-static constructor"). This diagnostic is raised when a given type is required to have a single public constructor. This includes test classes and test fixtures.

  • We have added xUnit1057 ("Type must be public or internal"). This diagnostic is raised when a given type must have either public or internal visibility so that the Native AOT source generators can reference the type. This is only raised in Native AOT mode, and does not affect reflection mode.

  • We have added xUnit1058 ("Generic collection definitions are not supported in Native AOT"). This diagnostic is raised when a collection definition class is defined as a generic class. Closing open generics is not available in Native AOT.

  • We have added xUnit1059 ("Test classes may not be decorated with ICollectionFixture<>"). This diagnostic is raised when a test class was decorated with ICollectionFixture, as test classes cannot specify collection fixtures (only collection definitions can).

  • We have added xUnit1060 ("Cultured test methods must have at least one culture"). This diagnostic is raised when a cultured tests (using CulturedFact or CulturedTheory) specifies zero cultures, which would result in zero tests.

  • We have added xUnit1061 ("Fact methods cannot be generic"). This diagnostic is raised when a test method decorated with [Fact] or [CulturedFact] is an open generic. Since there is no data around which to close the open generic, this is not legal.

  • We have added xUnit1062 ("Theory methods cannot be generic in Native AOT"). This diagnostic is raised when a test method decorated with [Theory] or [CulturedTheory] is an open generic. Closing open generics is not available in Native AOT.

  • We have added xUnit1063 ("Test class cannot be an open generic type"). This diagnostic is raised when a test class is an open generic type. Since there is no data around which to close the open generic, this is not legal.

  • We have added xUnit1064 ("Theory parameter cannot use params modifier in Native AOT"). This diagnostic is raised when a test method parameter is marked with the params modifier. Support for params parameters is not available in Native AOT.

  • We have added xUnit1065 ("MemberData member may not be overloaded in Native AOT"). This diagnostic is raised when [MemberData] points to an overloaded method in Native AOT mode. Support for resolving the method ambiguity is not available in Native AOT mode.

  • We have added xUnit1066 ("MemberData parameter cannot use params modifier in Native AOT"). This diagnostic is raised when a method referenced by [MemberData] has a parameter with the params modifier. Support for params parameters is not available in Native AOT.

  • We have added xUnit1067 ("There is no matching MemberData method argument"). This diagnostic is raised when the [MemberData] attribute does not provide enough arguments for the method.

Extensibility Analyzers

  • We have added xUnit3004 ("Type does not implement interface"). This diagnostic is raised when the analyzer determines that a given type needs to implement an interface that it does not. The interfaces currently supported here are:

    • ICodeGenTestCollectionFactory (for CollectionBehaviorAttribute in Native AOT mode)
    • IConsoleResultWriter (for RegisterConsoleResultWriterAttribute and RegisterResultWriterAttribute)
    • IMicrosoftTestingPlatformResultWriter (for RegisterMicrosoftTestingPlatformResultWriterAttribute and RegisterResultWriterAttribute)
    • IRunnerReporter (for RegisterRunnerReporterAttribute)
    • ITestCaseOrderer (for test case orderers)
    • ITestClassOrderer (for test class orderers)
    • ITestCollectionOrderer (for test collection orderers)
    • ITestFramework (for TestFrameworkAttribute)
    • ITestMethodOrderer (for test method orderers)
    • ITestPipelineStartup (for TestPipelineStartupAttribute)
    • IXunitSerializer (for RegisterXunitSerializerAttribute)
    • IXunitTestCollectionFactory (for CollectionBehaviorAttribute in reflection mode)
  • We have added xUnit3005 ("Type must have an appropriate non-obsolete public constructor"). This diagnostic is raised when an appropriate constructor cannot be found for the given extensibility type; the constructor must be public, non-static, and non-[Obsolete]. Those types include:

    • Assembly fixtures (no parameters)
    • ICodeGenTestCollectionFactory implementations (single parameter ICodeGenTestAssembly testAssembly)
    • IConsoleResultWriter implementations (no parameters)
    • IMicrosoftTestingPlatformResultWriter implementations (no parameters)
    • IRunnerReporter implementations (no parameters)
    • ITestCaseOrderer implementations (no parameters)
    • ITestClassOrderer implementations (no parameters)
    • ITestCollectionOrderer implementations (no parameters)
    • ITestFramework (single parameter string? configFileName, or no parameters)
    • ITestMethodOrderer implementations (no parameters)
    • ITestPipelineStartup implementations (no parameters)
    • IXunitSerializer implementations (no parameters)
    • IXunitTestCollectionFactory implementations (single parameter IXunitTestAssembly testAssembly)