Skip to content
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

[API Proposal]: Add GetDeclaredSymbol overload for LocalFunctionStatementSyntax #71028

Closed
CollinAlpert opened this issue Nov 30, 2023 · 6 comments · Fixed by #71169
Closed

[API Proposal]: Add GetDeclaredSymbol overload for LocalFunctionStatementSyntax #71028

CollinAlpert opened this issue Nov 30, 2023 · 6 comments · Fixed by #71169
Assignees
Labels
api-approved API was approved in API review, it can be implemented Area-IDE Concept-API This issue involves adding, removing, clarification, or modification of an API. Feature Request

Comments

@CollinAlpert
Copy link
Contributor

CollinAlpert commented Nov 30, 2023

Background and Motivation

For the sake of completeness, an extension method on SemanticModel should exist for LocalFunctionStatementSyntax. Note that such an overload already exists on the CSharpSemanticModel.

Proposed API

namespace Microsoft.CodeAnalysis.CSharp
{
     public static class CSharpExtensions
     {
+        public static IMethodSymbol? GetDeclaredSymbol(this SemanticModel? semanticModel, LocalFunctionStatementSyntax node, CancellationToken cancellationToken = default(CancellationToken));
     }

Usage Examples

using Microsoft.CodeAnalysis.CSharp;

void M(SemanticModel m, LocalFunctionStatementSyntax s)
{
    IMethodSymbol symbol = m.GetDeclaredSymbol(s);
}

Related to dotnet/roslyn-analyzers#7061

@CollinAlpert CollinAlpert added Concept-API This issue involves adding, removing, clarification, or modification of an API. Feature Request labels Nov 30, 2023
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Nov 30, 2023
@CyrusNajmabadi
Copy link
Member

Should likely be typed to return an IMethodSymbol

@CollinAlpert
Copy link
Contributor Author

CollinAlpert commented Nov 30, 2023

That was my initial thought as well, however it seems the method in CSharpSemanticModel returns an ISymbol.

@CyrusNajmabadi
Copy link
Member

@CollinAlpert tweak here: #71034

@CollinAlpert
Copy link
Contributor Author

Cool! I've tweaked the proposal.

@CyrusNajmabadi
Copy link
Member

Awesome. Thanks. I'll drive this!

@CyrusNajmabadi CyrusNajmabadi self-assigned this Nov 30, 2023
@CyrusNajmabadi CyrusNajmabadi added api-ready-for-review API is ready for review, it is NOT ready for implementation and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Nov 30, 2023
@333fred
Copy link
Member

333fred commented Dec 7, 2023

API Review

  • Ship it.

Conclusion: Approved.

@333fred 333fred added api-approved API was approved in API review, it can be implemented and removed api-ready-for-review API is ready for review, it is NOT ready for implementation labels Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-approved API was approved in API review, it can be implemented Area-IDE Concept-API This issue involves adding, removing, clarification, or modification of an API. Feature Request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants