site/xunit.analyzers/rules/xUnit9012.md
A violation of this rule occurs when [MemberData] points at an ambiguous member.
The source generator must determine unambiguously which member a [MemberData] is referring to. When the named member is overloaded, it cannot determine this.
To fix a violation of this rule, either remove the additional overloads or given them a different name.
using Xunit;
public class xUnit9012
{
public static TheoryData<int> DataSource() => DataSource(1);
public static TheoryData<int> DataSource(int multiplier) => [42 * multiplier];
[Theory]
[MemberData(nameof(DataSource))]
[MemberData(nameof(DataSource), 4)]
public void TestMethod(int _)
{ }
}
using Xunit;
public class xUnit9012
{
public static TheoryData<int> DataSource(int multiplier = 1) => [42 * multiplier];
[Theory]
[MemberData(nameof(DataSource))]
[MemberData(nameof(DataSource), 4)]
public void TestMethod(int _)
{ }
}