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]: Expose SymbolAnnotation.Create #65041

Open
Youssef1313 opened this issue Oct 27, 2022 · 0 comments
Open

[API Proposal]: Expose SymbolAnnotation.Create #65041

Youssef1313 opened this issue Oct 27, 2022 · 0 comments
Assignees
Labels
Area-Compilers Concept-API This issue involves adding, removing, clarification, or modification of an API. Feature Request
Milestone

Comments

@Youssef1313
Copy link
Member

Background and Motivation

Codefixes can usually annotate a TypeSyntax with AddImportsAnnotation so that the using directive is added automatically if not present. However, when the codefix suggests using an extension method, AddImportsAnnotation alone cannot work.

Proposed API

namespace Microsoft.CodeAnalysis.Simplification
{
-    internal class SymbolAnnotation
+    public class SymbolAnnotation
     {
         // Make everything internal except Create(ISymbol symbol) method
     }
}

Usage Examples

var annotation = SymbolAnnotation.Create(compilation.GetTypeByMetadataName("MyNamespace.Extensions"));
return document.WithSyntaxRoot(
    root.ReplaceNode(nodetoReplace, extensionInvocation.WithAdditionalAnnotations(Simplifier.AddImportsAnnotation, annotation)));

Alternative Designs

Risks

@Youssef1313 Youssef1313 added Concept-API This issue involves adding, removing, clarification, or modification of an API. Feature Request labels Oct 27, 2022
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Oct 27, 2022
@jaredpar jaredpar removed the untriaged Issues and PRs which have not yet been triaged by a lead label Nov 7, 2022
@jaredpar jaredpar added this to the 17.5 milestone Nov 7, 2022
@jaredpar jaredpar modified the milestones: 17.5, 17.6 Jan 5, 2023
@jaredpar jaredpar modified the milestones: 17.6, C# 12.0 Feb 15, 2023
@jaredpar jaredpar modified the milestones: C# 12.0, Backlog Sep 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers Concept-API This issue involves adding, removing, clarification, or modification of an API. Feature Request
Projects
None yet
Development

No branches or pull requests

3 participants