-
-
Notifications
You must be signed in to change notification settings - Fork 108
Closed as not planned
Closed as not planned
Copy link
Labels
Description
Description
We are encountering a likely false positive for warning TUnit0046 when returning an array of Func<IConstraint> from a [MethodDataSource]-annotated method. The intention of this rule—to ensure lazy evaluation of test cases—is already fulfilled by the use of Func<T>. However, the analyzer still raises the warning.
Reproduction Example
[Test]
[MethodDataSource(nameof(ChainedInvalidOperationsData))]
public void Value_ChainedInvalidOperations_ShouldThrowInvalidOperationException(Func<IConstraint> funcConstraint) =>
_ = Assert.Throws<InvalidOperationException>(() =>
{
var _ = funcConstraint.Invoke();
});
public static Func<IConstraint>[] ChainedInvalidOperationsData() =>
[
() => Value.Not.Not,
() => Value.Null.And.And,
() => Value.Null.And.Or,
() => Value.Null.And.Xor,
() => Value.Null.Or.And,
() => Value.Null.Or.Or,
() => Value.Null.Or.Xor,
() => Value.Null.Xor.And,
() => Value.Null.Xor.Or,
() => Value.Null.Xor.Xor,
];Expected Behavior
No warning should be emitted, as the method correctly returns an array of deferred Func<IConstraint> instances, not evaluated values.
Related repository: dailydevops/fluentvalue#126