Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NUnit2024 triggers invalidly on Has.Property() #673

Open
Sebazzz opened this issue Jan 5, 2024 · 0 comments
Open

NUnit2024 triggers invalidly on Has.Property() #673

Sebazzz opened this issue Jan 5, 2024 · 0 comments
Labels

Comments

@Sebazzz
Copy link

Sebazzz commented Jan 5, 2024

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)
@mikkelbu mikkelbu added the bug label Jan 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants