site/xunit.analyzers/rules/xUnit1046.md
A violation of this rule occurs when a value passed to the TheoryDataRow constructor is known to
not be serializable.
Non-serializable data makes it impossible for the developer to run individual data rows inside of Visual Studio's Test Explorer.
To fix a violation of this rule, use data that is known to be serializable. This includes all the
supported built-in types (listed below) or any type which implements IXunitSerializable, as well as
arrays of any supported type and nullable versions of any supported value type.
Supported built-in types (as of v3 0.1.1-pre.392) include:
BigIntegerboolbyte and sbytecharDateTime, DateTimeOffset, and TimeSpanDateOnly and TimeOnly (.NET 8+ only)decimalfloat and doubleint and uintlong and ulongshort and ushortstringTypeAdditional built-in types supported for v3 (as of 0.5.0) include:
GuidIndex and Range (.NET 8+ only)UriVersionusing Xunit;
public sealed class TestData { }
public class MyClass
{
public TheoryDataRow GetDataRow()
{
return new TheoryDataRow(new TestData());
}
}
using Xunit;
public sealed class TestData { }
public class MyClass
{
public TheoryDataRow GetDataRow()
{
return new TheoryDataRow(42, "Hello World!");
}
}
using Xunit;
using Xunit.Sdk;
public sealed class TestData : IXunitSerializable { }
public class MyClass
{
public TheoryDataRow GetDataRow()
{
return new TheoryDataRow(new TestData());
}
}