Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Implement CodeFix for CA2246 #3694
base: main
Are you sure you want to change the base?
Implement CodeFix for CA2246 #3694
Changes from 9 commits
f7df990
2db806b
29f3918
17c641a
3768e90
8e62dcd
f7fc00a
9d14a22
9b01d9d
b97a38c
111abcc
9de938a
ebf37bd
56f180d
f82374a
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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 am not sure which change to suggest (maybe the method name) but when reviewing it feels weird because we loop on
members.Count
and it's not really clear there is a change to this variable. At first I thought there was a "silly" bug.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.
Could you please use a meaningful name instead of XXX1 and XXX2? Maybe something like
finalAssignmentToLeft
andfinalAssignmentToRight
.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.
Instead of having this pragma, could we bump the version of the analyzer we are using to rely on one where I have fixed this issue?
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.
@Evangelink Sure. Do you know which version got the fix?
We will also need to remove the suppression in:
roslyn-analyzers/src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/ApiDesignGuidelines/MarkAttributesWithAttributeUsage.Fixer.cs
Line 56 in 91b109f
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.
Just made a test and it seems that the latest available pre-release (i.e. 3.3.1-beta1.20505.3) does not contain the fix so let's move on as-is and we will do a separate PR to get rid of both pragmas.
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.
Same name suggestion here. We will currently see something like:
in the lightbulb, that's not really helpful.
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.
@Evangelink If I used the same wording you suggested in #3694 (comment) as titles (e.g.
Split assignments with final assignment to the left variable
), do you think it's good to the end-user?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 think so. @mavasani any opinion?
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.
What about
SplitAssignments
?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.
@Evangelink To me, I'd interpret
SplitAssignments
such that it returns a collection of the new assignment statements. While it returns a collection of each member in the assignment.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.
You are right. I think I am a bit bothered by
Members
because it's moreExpressions
but it probably doesn't matter much.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'm okay with renaming to
GetAssignmentExpressions
if you think it's clearer.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 am not sure but maybe using the
DocumentEditor
would help with solving the issue you are facing.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.
@Evangelink Can you elaborate more on how I should use
DocumentEditor
to fix this?