-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Make GetDeclaredSymbol more strongly typed for LocalFunctionDeclarationSyntax #71034
Conversation
@333fred @jcouv @RikkiGibson trivial type safety PR. |
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.
lgtm, seems to make things consistent with the CompilationUnitSyntax overload below.
@RikkiGibson Yup. These should always be strongly typed. The only times they shouldn't be is if you can genuinely get different symbol types back. For example, an IPropertySymbol and an IMethodSymbol (which share no common base interface except ISymbol) :) |
@@ -2960,7 +2960,7 @@ internal Conversion ClassifyConversionForCast(int position, ExpressionSyntax exp | |||
/// <param name="declarationSyntax">The syntax node that declares a member.</param> | |||
/// <param name="cancellationToken">The cancellation token.</param> | |||
/// <returns>The symbol that was declared.</returns> | |||
public abstract ISymbol GetDeclaredSymbol(LocalFunctionStatementSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken)); | |||
public abstract IMethodSymbol GetDeclaredSymbol(LocalFunctionStatementSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken)); |
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.
Huh. I was going to suggest that we should update the public API for this as well, but we apparently don't have a GetDeclaredSymbol
extension for local functions. That seems like a bug in itself, as it means that dotnet/roslyn-analyzers#6779 is going to warn when calling GetDeclaredSymbol
on a local function syntax node.
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.
And now I see that you're driving this because of a request for just such an API in #71028 😆.
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.
yup :D
No description provided.