Fix MakeLocalFunctionStatic for top-level local function#56473
Merged
jcouv merged 4 commits intodotnet:mainfrom Sep 17, 2021
Merged
Fix MakeLocalFunctionStatic for top-level local function#56473jcouv merged 4 commits intodotnet:mainfrom
jcouv merged 4 commits intodotnet:mainfrom
Conversation
Comment on lines
+526
to
+528
|
|
||
| //await TestAsync(initialMarkup, expectedMarkup, WithRegularOptions(parameters)); | ||
|
|
Contributor
There was a problem hiding this comment.
Suggested change
| //await TestAsync(initialMarkup, expectedMarkup, WithRegularOptions(parameters)); |
|
|
||
| return Task.CompletedTask; | ||
|
|
||
| static SyntaxNode unwrapGlobalStatement(SyntaxNode node) |
Contributor
There was a problem hiding this comment.
Suggested change
| static SyntaxNode unwrapGlobalStatement(SyntaxNode node) | |
| static SyntaxNode UnwrapGlobalStatement(SyntaxNode node) |
| SyntaxEditor editor, CancellationToken cancellationToken) | ||
| { | ||
| var localFunctions = diagnostics.SelectAsArray(d => d.AdditionalLocations[0].FindNode(cancellationToken)); | ||
| var localFunctions = diagnostics.SelectAsArray(d => unwrapGlobalStatement(d.AdditionalLocations[0].FindNode(cancellationToken))); |
Contributor
There was a problem hiding this comment.
Suggested change
| var localFunctions = diagnostics.SelectAsArray(d => unwrapGlobalStatement(d.AdditionalLocations[0].FindNode(cancellationToken))); | |
| var localFunctions = diagnostics.SelectAsArray(d => d.AdditionalLocations[0].FindNode(getInnermostNodeForTie: true, cancellationToken)); |
Comment on lines
+59
to
+62
| static SyntaxNode unwrapGlobalStatement(SyntaxNode node) | ||
| { | ||
| return node is GlobalStatementSyntax globalStatement ? globalStatement.Statement : node; | ||
| } |
Contributor
There was a problem hiding this comment.
Suggested change
| static SyntaxNode unwrapGlobalStatement(SyntaxNode node) | |
| { | |
| return node is GlobalStatementSyntax globalStatement ? globalStatement.Statement : node; | |
| } |
Youssef1313
reviewed
Sep 17, 2021
| } | ||
|
|
||
| [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsMakeLocalFunctionStatic)] | ||
| [WorkItem(53179, "https://github.com/dotnet/roslyn/issues/53179")] |
Member
There was a problem hiding this comment.
This issue is about about the CodeRefactoringProvider, not the CodeFixProvider.
Might be good to add a test to the coderefactoring if it already works (or fix it if it doesn't).
Member
Author
There was a problem hiding this comment.
Thanks, added a test. They do share the code so worked fine :-)
| using System.Threading.Tasks; | ||
| using Microsoft.CodeAnalysis.CodeActions; | ||
| using Microsoft.CodeAnalysis.CodeFixes; | ||
| using Microsoft.CodeAnalysis.CSharp.Syntax; |
CyrusNajmabadi
approved these changes
Sep 17, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #53179