Ensure equivalence key is not null#52111
Conversation
| // Make a SolutionChangeAction. This way we can let it generate the diff | ||
| // preview appropriately. | ||
| var solutionChangeAction = new SolutionChangeAction("", c => GetUpdatedSolutionAsync(c)); | ||
| var solutionChangeAction = new SolutionChangeAction("", c => GetUpdatedSolutionAsync(c), ""); |
There was a problem hiding this comment.
Not sure why the title is empty string here. Is this code action (for some reason) non user-facing?
There was a problem hiding this comment.
yes. it is only used to get the operations out.
| string title, | ||
| Func<CancellationToken, Task<Solution>> createChangedSolution, | ||
| string? equivalenceKey = null, | ||
| string? equivalenceKey, |
There was a problem hiding this comment.
I didn't change this to non-nullable because it's called by a public API:
I'll have to either add a suppression or change the public API nullability. I thought it's good enough for this to not be optional.
| { | ||
| public MoveMisplacedUsingsCodeAction(Func<CancellationToken, Task<Document>> createChangedDocument) | ||
| : base(CSharpAnalyzersResources.Move_misplaced_using_directives, createChangedDocument) | ||
| : base(CSharpAnalyzersResources.Move_misplaced_using_directives, createChangedDocument, nameof(CSharpAnalyzersResources.Move_misplaced_using_directives)) |
There was a problem hiding this comment.
This change causing cleanup tests to fail. I still didn't figure out why, would be helpful if someone knows.
There was a problem hiding this comment.
In:
fixAllContext.CodeActionEquivalenceKey is null, causing the following condition to be false:
Hence, no code actions are executed:
There was a problem hiding this comment.
I fixed that in e6b3238 and 4e54b71.
I used the first fix as similar thing is done in:
roslyn/src/Features/Core/Portable/CodeFixes/CodeFixService.cs
Lines 245 to 247 in f3462ac
|
@sharwell @CyrusNajmabadi Can you review please? Thanks. |
|
Also pinging @mavasani specifically for the last two commits. |
|
@sharwell @mavasani @CyrusNajmabadi Can someone review? Thanks! |
| if (diagnostics.IsDefaultOrEmpty) | ||
| return null; | ||
|
|
||
| var title = FixAllContextHelper.GetDefaultFixAllTitle(fixAllContext); |
There was a problem hiding this comment.
why?
Possibly I was using it as equivalence key so I extracted to a variable, and changed that in a later commit to only use it as title.
|
Thank you :) |
Fixes #52074