-
Notifications
You must be signed in to change notification settings - Fork 33
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
Fix logic around out-of-order arguments for classic assertions (#712) #716
Conversation
@dotnet-policy-service agree |
@Bartleby2718 You are right that most code fixes don't take named parameters into account and I rather not have 24 separate updates for each of the classic code fixes. The code already makes assumptions before getting to the
Can I suggest to do this differently? Actually the whole The method could then do something like: |
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.
Once named
arguments are in play, none of the code using an index is valid.
See comment above to change approach to replace underlying design.
src/nunit.analyzers/ClassicModelAssertUsage/AreEqualClassicModelAssertUsageCodeFix.cs
Outdated
Show resolved
Hide resolved
src/nunit.analyzers/ClassicModelAssertUsage/AreEqualClassicModelAssertUsageCodeFix.cs
Outdated
Show resolved
Hide resolved
@manfred-brands I think there's a little more room for improvement, but I've pushed what I did today. Given the time difference, requesting a re-review now. |
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.
@Bartleby2718 Thanks for making the changed.
The actual codefix now uses parameter names iso indices is a good approach.
I put some remarks for changes in the PR.
src/nunit.analyzers/ClassicModelAssertUsage/AreEqualClassicModelAssertUsageCodeFix.cs
Outdated
Show resolved
Hide resolved
src/nunit.analyzers/ClassicModelAssertUsage/ClassicModelAssertUsageCodeFix.cs
Outdated
Show resolved
Hide resolved
I'll need some refactoring to make sure the code follows the conventions of this repository, is maintainable, and is readable. In terms of correctness, however, I think the code is alright. Hence, re-requesting review from @manfred-brands! |
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.
@Bartleby2718 I think you are on the correct path.
Change how to treat the message parameter form List to Dictionary.
Some cleanups.
And then doing the other Classic Code Fixes ...
src/nunit.analyzers/ClassicModelAssertUsage/AreEqualClassicModelAssertUsageCodeFix.cs
Outdated
Show resolved
Hide resolved
src/nunit.analyzers/ClassicModelAssertUsage/ClassicModelAssertUsageCodeFix.cs
Outdated
Show resolved
Hide resolved
src/nunit.analyzers/ClassicModelAssertUsage/ClassicModelAssertUsageCodeFix.cs
Outdated
Show resolved
Hide resolved
src/nunit.analyzers/ClassicModelAssertUsage/ClassicModelAssertUsageCodeFix.cs
Outdated
Show resolved
Hide resolved
src/nunit.analyzers/ClassicModelAssertUsage/ClassicModelAssertUsageCodeFix.cs
Outdated
Show resolved
Hide resolved
src/nunit.analyzers/ClassicModelAssertUsage/ClassicModelAssertUsageCodeFix.cs
Outdated
Show resolved
Hide resolved
src/nunit.analyzers/ClassicModelAssertUsage/ClassicModelAssertUsageCodeFix.cs
Outdated
Show resolved
Hide resolved
The exisiting tests should ensure that nothing gets broken. Then I suggest one new test per Codefix using named out of order parameters. |
@dotnet-policy-service agree |
Still working on the tests; there's a lot to add 😅 |
...nunit.analyzers.tests/ClassicModelAssertUsage/AreEqualClassicModelAssertUsageCodeFixTests.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.
Nice work!
A few changes to make "more standard" named parameters work.
I'm not convinced we should introduce named parameters for the constraint model, regardless if they were used in the classic model.
I rather drop all names (.WithNameColon(null)
) than replace arg1
with actual
.
...nunit.analyzers.tests/ClassicModelAssertUsage/AreEqualClassicModelAssertUsageCodeFixTests.cs
Show resolved
Hide resolved
...nit.analyzers.tests/ClassicModelAssertUsage/AreNotSameClassicModelAssertUsageCodeFixTests.cs
Show resolved
Hide resolved
src/nunit.analyzers.tests/ClassicModelAssertUsage/ClassicModelAssertUsageCodeFixTests.cs
Outdated
Show resolved
Hide resolved
src/nunit.analyzers/ClassicModelAssertUsage/ClassicModelAssertUsageCodeFix.cs
Outdated
Show resolved
Hide resolved
src/nunit.analyzers/ClassicModelAssertUsage/ClassicModelAssertUsageCodeFix.cs
Show resolved
Hide resolved
src/nunit.analyzers/ClassicModelAssertUsage/ClassicModelAssertUsageCodeFix.cs
Outdated
Show resolved
Hide resolved
src/nunit.analyzers/ClassicModelAssertUsage/GreaterClassicModelAssertUsageCodeFix.cs
Outdated
Show resolved
Hide resolved
src/nunit.analyzers/ClassicModelAssertUsage/GreaterClassicModelAssertUsageCodeFix.cs
Outdated
Show resolved
Hide resolved
@Bartleby2718 I pushed up a commit addressing some of what I commented on in the PR. |
@manfred-brands Could you assign the PR to me? |
I noticed that not all 'named parameters' where removed in the classic code fixes. |
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.
Thanks for the cooperation.
I think we are there and the actual code fixes have become more straight forward.
@manfred-brands Thank you for all the guidance and explanations! I feel like I've learned a lot about both NUnit and Roslyn analyzers. I have a couple more questions about this repo:
|
Normally a PR targets master. If PRs are for different areas there should normally not be a merge conflict. PRs are merged when approved. In this case I want to see if @mikkelbu has any comments before merging.
I didn't know there was a NUnit release schedule. I thought they are released when enough changes justify one. NUnit and the NUnit.Analyzers don't have to be in sync and are released independently at the moment. |
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.
I've only reviewed half the files, but so far it looks great. I won't have time to review the rest of the files before the end of the week as I've very little spare time currently - hopefully Thursday evening CET or perhaps Friday evening CET.
I've left a couple of comments, but nothing major.
And Manfred is correct about the release cadency of NUnit vs NUnit.Analyzers. We could release the Analyzers when this PR is done and all the current active PRs have been merged.
src/nunit.analyzers.tests/StringAssertUsage/StringAssertUsageCodeFixTests.cs
Outdated
Show resolved
Hide resolved
src/nunit.analyzers/ClassicModelAssertUsage/LessOrEqualClassicModelAssertUsageCodeFix.cs
Outdated
Show resolved
Hide resolved
...s.tests/ClassicModelAssertUsage/IsTrueAndTrueClassicModelAssertUsageCondensedCodeFixTests.cs
Outdated
Show resolved
Hide resolved
…es that the first argument is expected and the second argument is actual
Update Tests to remove named parameters
@mikkelbu Fixed your reported issues and found two items we forgot to clean up. I left them in as separate commits. |
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.
Looks great @Bartleby2718 and @manfred-brands. I only noticed one little nit-pick otherwise I think we should merge.
I especially like how it simplified several of the existing analyzers/fixes.
@mikkelbu @manfred-brands Addressed the last feedback. Thanks both for the feedback and answers and guidance! |
I found another bug while fixing the code, but in the interest of making the PR more targeted and reviewable, I'll file another issue and another PR to fix that.
Closes #712.