Skip to content

https://andrewlock.net/exploring-dotnet-10-preview-features-4-solving-the-source-generator-marker-attribute-problem-in-dotnet-10/Β #423

@ignatandrei

Description

@ignatandrei
netstandard2.0
<IsRoslynComponent>true</IsRoslynComponent>
[Generator] #pragma warning disable RS1036 // Specify analyzer banned API enforcement setting public class HelloWorldGenerator : IIncrementalGenerator #pragma warning restore RS1036 // Specify analyzer banned API enforcement setting { public void Initialize(IncrementalGeneratorInitializationContext context) { context .RegisterPostInitializationOutput(i => { i.AddEmbeddedAttributeDefinition();// πŸ‘ˆ Add the definition i.AddSource("MyExampleAttribute.g.cs", @" namespace HelloWorld { // πŸ‘‡ Use the attribute [global::Microsoft.CodeAnalysis.EmbeddedAttribute] internal class MyExampleAttribute: global::System.Attribute {} }"); });
    // ... generator implementaation
}

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions