-
Notifications
You must be signed in to change notification settings - Fork 245
Fix S1144 FN: Unused local functions #9071
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -167,23 +167,15 @@ public static bool ContainsMethodInvocation(this BaseMethodDeclarationSyntax met | |
| .Any(symbolPredicate); | ||
| } | ||
|
|
||
| public static SyntaxToken? GetIdentifierOrDefault(this BaseMethodDeclarationSyntax methodDeclaration) | ||
| { | ||
| switch (methodDeclaration?.Kind()) | ||
| public static SyntaxToken? GetIdentifierOrDefault(this BaseMethodDeclarationSyntax methodDeclaration) => | ||
| methodDeclaration?.Kind() switch | ||
| { | ||
| case SyntaxKind.ConstructorDeclaration: | ||
| return ((ConstructorDeclarationSyntax)methodDeclaration).Identifier; | ||
|
|
||
| case SyntaxKind.DestructorDeclaration: | ||
| return ((DestructorDeclarationSyntax)methodDeclaration).Identifier; | ||
|
|
||
| case SyntaxKind.MethodDeclaration: | ||
| return ((MethodDeclarationSyntax)methodDeclaration).Identifier; | ||
|
|
||
| default: | ||
| return null; | ||
| } | ||
| } | ||
| SyntaxKind.ConstructorDeclaration => ((ConstructorDeclarationSyntax)methodDeclaration)?.Identifier, | ||
| SyntaxKind.DestructorDeclaration => ((DestructorDeclarationSyntax)methodDeclaration)?.Identifier, | ||
| SyntaxKind.MethodDeclaration => ((MethodDeclarationSyntax)methodDeclaration)?.Identifier, | ||
|
Tim-Pohlmann marked this conversation as resolved.
Outdated
|
||
| _ when LocalFunctionStatementSyntaxWrapper.IsInstance(methodDeclaration) => ((LocalFunctionStatementSyntaxWrapper)methodDeclaration).Identifier, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should follow the same pattern as the cases above using
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We cannot cast to LocalFunctionStatementSyntax because we don't have it, so it would be something like:
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But it's the same assumption as in the three cases above. |
||
| _ => null, | ||
| }; | ||
|
|
||
| public static bool IsMethodInvocation(this InvocationExpressionSyntax invocation, KnownType type, string methodName, SemanticModel semanticModel) => | ||
| invocation.Expression.NameIs(methodName) && | ||
|
|
||
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.
Not strictly related to unused local functions, but requested in the same ticket.