-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Implement compiler support for System.Runtime.InteropServices.ExtendedLayoutAttribute #78741
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
base: main
Are you sure you want to change the base?
Conversation
…tribute Some error handling is still missing. NoPia tests are still TBD
|
@jkoritzinsky think we'll need a small specification document for this contribution. |
|
I'll put one together. Where is the best place for it to go? |
dotnet/csharplang. @333fred can you think of a good example that would be similar to this? |
|
I considered doing a proposal in csharplang, but there's zero specifications of |
|
I would agree with Jeremy, C# the language doesn't care about those attributes, just Roslyn the compiler. Perhaps under docs/features? Also, what support does VB have for these attributes, and what will we need to update in its support? |
|
Hmm ... for some reason I thought the spec discussed |
|
I'll drop a spec in docs/features and add VB support. |
…ther layout or layout-like attributes.
|
I've added a spec and added VB support |
…Kind to be defined in InternalSpecialType to enforce the "defined in CoreLib" requirement.
The interop team has decided to add a new mechanism to specify type layouts, designed similarly to how the
UnmanagedCallersOnlyfeature was designed. In particular, the team has decided to use the last remaining value in the "Layout Kind" mask of a type def's attributes to represent "extended layout". When this value it set, the runtime will look for theSystem.Runtime.InteropServices.ExtendedLayoutAttributeto provide all layout information.As part of the design process, we noticed that Roslyn blocks emitting a type with the last remaining value of the
System.Runtime.InteropServices.LayoutKindenumeration in theStructLayoutpseudo-attribute as the compiler can't map it to a validTypeAttributesvalue.The
System.Runtime.InteropServices.ExtendedLayoutAttributetype was approved in dotnet/runtime#100896 and has the first part of runtime implementation (the TypeAttributes bit and the LayoutKind value) in dotnet/runtime#116082.The support in C# is to allow the user to specify the
ExtendedLayoutAttributeon a type. When they do so, the correct layout bit will be set. The user cannot manually specify the new "extended layout" value. The only way in C# to specify that value is to put this attribute on the type.The
ExtendedLayoutAttributewill be embedded in NoPia scenarios as the layout bits are embedded in NoPia scenarios.This should go into .NET 11