Add FixAll support of UseRecursivePattern refactoring#61915
Merged
mavasani merged 1 commit intodotnet:mainfrom Jun 15, 2022
Merged
Add FixAll support of UseRecursivePattern refactoring#61915mavasani merged 1 commit intodotnet:mainfrom
mavasani merged 1 commit intodotnet:mainfrom
Conversation
This was identified as a high value refactoring for FixAll support as it promotes a new language feature (C# recursive patterns)
Contributor
Author
|
Tagging @mikadumont |
Comment on lines
+84
to
+94
| private static bool IsFixableNode(SyntaxNode node) | ||
| => node switch | ||
| { | ||
| BinaryExpressionSyntax(LogicalAndExpression) => true, | ||
| CasePatternSwitchLabelSyntax { WhenClause: { } whenClause } => true, | ||
| SwitchExpressionArmSyntax { WhenClause: { } whenClause } => true, | ||
| WhenClauseSyntax { Parent: CasePatternSwitchLabelSyntax } => true, | ||
| WhenClauseSyntax { Parent: SwitchExpressionArmSyntax } => true, | ||
| _ => false | ||
| }; | ||
|
|
Contributor
There was a problem hiding this comment.
Suggested change
| private static bool IsFixableNode(SyntaxNode node) | |
| => node switch | |
| { | |
| BinaryExpressionSyntax(LogicalAndExpression) => true, | |
| CasePatternSwitchLabelSyntax { WhenClause: { } whenClause } => true, | |
| SwitchExpressionArmSyntax { WhenClause: { } whenClause } => true, | |
| WhenClauseSyntax { Parent: CasePatternSwitchLabelSyntax } => true, | |
| WhenClauseSyntax { Parent: SwitchExpressionArmSyntax } => true, | |
| _ => false | |
| }; | |
| private static bool IsFixableNode(SyntaxNode node) | |
| => node switch | |
| { | |
| BinaryExpressionSyntax(LogicalAndExpression) => true, | |
| CasePatternSwitchLabelSyntax { WhenClause: not null } => true, | |
| SwitchExpressionArmSyntax { WhenClause: not null } => true, | |
| WhenClauseSyntax { Parent: CasePatternSwitchLabelSyntax } => true, | |
| WhenClauseSyntax { Parent: SwitchExpressionArmSyntax } => true, | |
| _ => false | |
| }; | |
Contributor
Author
There was a problem hiding this comment.
I'll fold this suggestion into the next PR and avoid re-running tests on this PR.
|
|
||
| // Get current root, current node to refactor and semantic model. | ||
| var root = await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false); | ||
| var currentNode = root.GetCurrentNodes(originalNode).SingleOrDefault(); |
Contributor
There was a problem hiding this comment.
you're using SingleOrDefault, but not checking the result? should we check this for null? or does GetReplacementFunc already do this?
Contributor
Author
There was a problem hiding this comment.
Yes, GetReplacementFunc handles null input.
CyrusNajmabadi
approved these changes
Jun 15, 2022
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.
This was identified as a high value refactoring for FixAll support as it promotes a new language feature (C# recursive patterns)