-
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
Allow users to define EmbeddedAttribute #76523
Conversation
…ser-defined-embedded * origin/source-gen-warning: Additional testing Add tests
@dotnet/roslyn-compiler for review. I'll propose a source-generation API to allow authors to create this API easily, but this change can go in separately. |
src/Compilers/CSharp/Portable/Symbols/Source/SourceNamedTypeSymbol.cs
Outdated
Show resolved
Hide resolved
src/Compilers/CSharp/Test/Emit3/Attributes/AttributeTests_Embedded.cs
Outdated
Show resolved
Hide resolved
src/Compilers/CSharp/Test/Emit3/Attributes/AttributeTests_Embedded.cs
Outdated
Show resolved
Hide resolved
src/Compilers/CSharp/Portable/Symbols/Source/SourceNamedTypeSymbol.cs
Outdated
Show resolved
Hide resolved
Done with review pass (commit 8) #Closed |
…tself didn't have one applied to it.
@AlekseyTs I believe I've address your feedback, thanks! |
|
||
***Introduced in Visual Studio 2022 version 17.13*** | ||
|
||
The compiler now validates the shape of `Microsoft.CodeAnalysis.EmbeddedAttribute` when declared in source. Previously, the compiler |
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.
Unrelated to the PR: it's not clear to me what the Microsoft.CodeAnalysis.EmbeddedAttribute
does. Is that documented somewhere?
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 documented afaik, though we will when we add the SG API. It prevents the compiler from resolving the type outside the current compilation. It's how the compiler itself gets around the "type defined in multiple assemblies" issues when it needs to synthesize an attribute.
docs/compilers/Visual Basic/Compiler Breaking Changes - DotNet 10.md
Outdated
Show resolved
Hide resolved
docs/compilers/Visual Basic/Compiler Breaking Changes - DotNet 10.md
Outdated
Show resolved
Hide resolved
src/Compilers/CSharp/Portable/Symbols/Source/SourceNamedTypeSymbol.cs
Outdated
Show resolved
Hide resolved
src/Compilers/CSharp/Test/Emit3/Attributes/AttributeTests_Embedded.cs
Outdated
Show resolved
Hide resolved
src/Compilers/VisualBasic/Portable/Symbols/Source/SourceMemberContainerTypeSymbol.vb
Outdated
Show resolved
Hide resolved
@AlekseyTs addressed feedback, thanks! |
docs/compilers/Visual Basic/Compiler Breaking Changes - DotNet 10.md
Outdated
Show resolved
Hide resolved
docs/compilers/Visual Basic/Compiler Breaking Changes - DotNet 10.md
Outdated
Show resolved
Hide resolved
src/Compilers/VisualBasic/Portable/Symbols/Source/SourceMemberContainerTypeSymbol.vb
Outdated
Show resolved
Hide resolved
src/Compilers/VisualBasic/Portable/Symbols/Source/SourceNamedTypeSymbol.vb
Outdated
Show resolved
Hide resolved
src/Compilers/VisualBasic/Test/Emit/Attributes/AttributeTests.vb
Outdated
Show resolved
Hide resolved
Done with review pass (commit 11) #Closed |
@AlekseyTs @cston for another review pass |
docs/compilers/Visual Basic/Compiler Breaking Changes - DotNet 10.md
Outdated
Show resolved
Hide resolved
src/Compilers/VisualBasic/Test/Emit/Attributes/AttributeTests.vb
Outdated
Show resolved
Hide resolved
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 (commit 12)
Alternative approach to #71546. Today, our enforcement of whether to allow users to define
Microsoft.CodeAnalysis.EmbeddedAttribute
is inconsistent; if we need to generate it, we error if the user defines one. But if the we don't need to generate it (as we increasingly do not since .NET 6), we allow the user to define their own version. This PR standardizes our enforcement, and enables the compiler to use the user-declared attribute instead generating one. We also document the breaking change from the standardized enforcement.