Edit on GitHub

xUnit1019 Error

MemberData must reference a member providing a valid data type

Cause

This rule is triggered when your [MemberData] attribute points to a member does not have a valid return type (IEnumerable<object[]> or something compatible with it, like TheoryData<>).

Reason for rule

[MemberData] attributes which do not point to valid data sources will fail at runtime.

How to fix violations

To fix a violation of this rule, update the data member to have an appropriate return type.

Examples

Violates

using System.Collections.Generic;
using Xunit;

public class xUnit1019
{
    public static IEnumerable<object> TestData;

    [Theory]
    [MemberData(nameof(TestData))]
    public void TestMethod(string greeting, int age) { }
}

Does not violate

using System.Collections.Generic;
using Xunit;

public class xUnit1019
{
    public static IEnumerable<object[]> TestData;

    [Theory]
    [MemberData(nameof(TestData))]
    public void TestMethod(string greeting, int age) { }
}
Copyright © .NET Foundation. Contributions welcomed at https://github.com/xunit/xunit/tree/gh-pages.