site/xunit.analyzers/rules/xUnit1012.md
This rule is trigged by having a null value in your [InlineData] for a value type parameter.
Value types are incompatible with null values.
To fix a violation of this rule, you may:
null value with a non-null valueusing Xunit;
public class xUnit1012
{
[Theory]
[InlineData(null)]
public void TestMethod(int _) { }
}
If nullable reference types are enabled, this also violates:
using Xunit;
public class xUnit1012
{
[Theory]
[InlineData(null)]
public void TestMethod(object _) { }
}
using Xunit;
public class xUnit1012
{
[Theory]
[InlineData(42)]
public void TestMethod(int _) { }
}
using Xunit;
public class xUnit1012
{
[Theory]
[InlineData(null)]
public void TestMethod(int? _) { }
}
If nullable reference types are enabled, parameters must be decorated to receive null values:
using Xunit;
public class xUnit1012
{
[Theory]
[InlineData(null)]
public void TestMethod(object? _) { }
}