-
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
Add EmbeddedAttribute API for source generators #76583
base: main
Are you sure you want to change the base?
Conversation
API review proposal: #76584. |
This PR modifies public API files. Please follow the instructions at https://github.com/dotnet/roslyn/blob/main/docs/contributing/API%20Review%20Process.md for ensuring all public APIs are reviewed before merging. |
5a6dca9
to
b33d913
Compare
Adds a new API to ensure that Microsoft.CodeAnalysis.EmbeddedAttribute is available in the compilation, and updates the cookbook to include information about using the attribute.
b33d913
to
5eed5e2
Compare
@@ -76,6 +76,15 @@ internal override SyntaxTree ParseGeneratedSourceText(GeneratedSourceText input, | |||
|
|||
internal override string SourceExtension => ".cs"; | |||
|
|||
internal override string EmbeddedAttributeDefinition => """ | |||
namespace Microsoft.CodeAnalysis |
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.
Nit. File scoped namespace
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.
I intentionally did not do this to maximize language version compat.
internal override string EmbeddedAttributeDefinition => """ | ||
namespace Microsoft.CodeAnalysis | ||
{ | ||
internal sealed partial class EmbeddedAttribute : global::System.Attribute |
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: semi colon body
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.
Same comment.
} | ||
|
||
[Fact] | ||
public void IncrementalGenerator_PostInit_AddEmbeddedAttributeSource_DoubleAdd_Throws() |
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.
What if two separate generators both call this. Is it ok? Can there be a test for this
Adds a new API to ensure that Microsoft.CodeAnalysis.EmbeddedAttribute is available in the compilation, and updates the cookbook to include information about using the attribute.