nunit.analyzers
nunit.analyzers copied to clipboard
NUnit2024 triggers invalidly on Has.Property()
Code:
public static class ConstraintExtensions {
public static RegexConstraint EqualToANiceName(this ResolvableConstraintExpression expression, string entityType) {
return expression.Matches($@"John");
}
}
class Person { public string Name { get;set; } }
Person p = new();
Assert.That(p, Has.Property(nameof(Person.Name)).EqualToANiceName());
Result:
Error NUnit2024 : The 'RegexConstraint' constraint cannot be used with actual argument of type 'Person' (https://github.com/nunit/nunit.analyzers/tree/master/documentation/NUnit2024.md)