-
Notifications
You must be signed in to change notification settings - Fork 253
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
Avoid conditionals inside assertions analyzer #2848
Conversation
...itTests/MSTest.Analyzers.UnitTests/AssertionArgsShouldAvoidConditionalAccessAnalyzerTests.cs
Show resolved
Hide resolved
...itTests/MSTest.Analyzers.UnitTests/AssertionArgsShouldAvoidConditionalAccessAnalyzerTests.cs
Show resolved
Hide resolved
src/Analyzers/MSTest.Analyzers/AssertionArgsShouldAvoidConditionalAccessAnalyzer.cs
Outdated
Show resolved
Hide resolved
...itTests/MSTest.Analyzers.UnitTests/AssertionArgsShouldAvoidConditionalAccessAnalyzerTests.cs
Outdated
Show resolved
Hide resolved
...itTests/MSTest.Analyzers.UnitTests/AssertionArgsShouldAvoidConditionalAccessAnalyzerTests.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be good to validate that no diagnostic is raised when using conditional access within Assert.IsNull
or Assert.IsNotNull
.
src/Analyzers/MSTest.Analyzers/AssertionArgsShouldAvoidConditionalAccessAnalyzer.cs
Outdated
Show resolved
Hide resolved
src/Analyzers/MSTest.Analyzers/AssertionArgsShouldAvoidConditionalAccessAnalyzer.cs
Outdated
Show resolved
Hide resolved
...itTests/MSTest.Analyzers.UnitTests/AssertionArgsShouldAvoidConditionalAccessAnalyzerTests.cs
Show resolved
Hide resolved
...itTests/MSTest.Analyzers.UnitTests/AssertionArgsShouldAvoidConditionalAccessAnalyzerTests.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM thank you for the nice implementation and the fast updates @fhnaseer
Could you please do a follow-up PR to dotnet/docs
for this rule? Here is an example PR: dotnet/docs#40785
Fixes #2751
Example:
// Warning
Assert.AreEqual(a?.b, "something");
// Fix
Assert.IsNotNull(a);
Assert.AreEqual(a.b, "something");