Back to Xunit

xUnit9001

site/xunit.analyzers/rules/xUnit9001.md

latest878 B
Original Source

Cause

A violation of this rule occurs when a type is missing a required interface implementation.

Reason for rule

In order for the type to be used by the system (and correctly consumed by the source generator), it must implement a specific interface.

How to fix violations

Implement the required interface.

Examples

Violates

csharp
using Xunit;
using Xunit.v3;

[assembly: CollectionBehavior(typeof(MyTestCollectionFactory))]

class MyTestCollectionFactory
{ }
shell
error xUnit9001: Type 'MyTestCollectionFactory' must implement interface 'Xunit.v3.ICodeGenTestCollectionFactory'

Does not violate

csharp
using Xunit;
using Xunit.v3;

[assembly: CollectionBehavior(typeof(MyTestCollectionFactory))]

class MyTestCollectionFactory : ICodeGenTestCollectionFactory
{
    // ...implementation of ICodeGenTestCollectionFactory...
}