site/xunit.analyzers/rules/xUnit9014.md
A violation of this rule occurs when a parameter of a [MemberData] method uses the params modifier.
When using the reflection-based version of xUnit.net, it will attempt to examine your [MemberData] arguments values at runtime and dynamically construct the params array on your behalf. This requires reflection features that are not available in Native AOT.
To fix a violation of this rule, remove the params modifier on the parameter, and update the [MemberData] to create the array yourself.
using System.Linq;
using Xunit;
public class xUnit9014
{
public static TheoryData<int> DataSource(params int[] multipliers) =>
[multipliers.Aggregate(42, (left, right) => left * right)];
[Theory]
[MemberData(nameof(DataSource), 2)]
public void TestMethod(int _)
{ }
}
using System.Linq;
using Xunit;
public class xUnit9014
{
public static TheoryData<int> DataSource(int[] multipliers) =>
[multipliers.Aggregate(42, (left, right) => left * right)];
[Theory]
[MemberData(nameof(DataSource), new[] { 2 })]
public void TestMethod(int _)
{ }
}