You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add support for the new System.Runtime.InteropServices.ExtendedLayoutAttribute #19190
The interop team has decided to add a new mechanism to specify type layouts. 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 the System.Runtime.InteropServices.ExtendedLayoutAttribute to 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.LayoutKind enumeration in the StructLayout pseudo-attribute as the compiler can't map it to a valid TypeAttributes value. I do not know if F# does the same today.
The System.Runtime.InteropServices.ExtendedLayoutAttribute type 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 F# should be either:
Allow the user to specify the ExtendedLayoutAttribute on 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 F# to specify that value is to put this attribute on the type.
Disallow the FieldOffset attribute for extended layout types.
Block user usage of ExtendedLayoutAttribute.
There is a PR to add support to Roslyn for C# and VB.NET at dotnet/roslyn#78741
Could you please help with crafting prompts for testing this properly?
Also w.r.t to what it should be doing at runtime in an interop-relevant scenario.
Activity
T-Gro commentedon Jan 6, 2026
@jkoritzinsky :
Could you please help with crafting prompts for testing this properly?
Also w.r.t to what it should be doing at runtime in an interop-relevant scenario.
jkoritzinsky commentedon Jan 6, 2026
We've only implemented CStruct so far in .NET 11, which has identical behavior to LayoutKind.Sequential.
It looks like you've got a good set of tests already in the PR. Left one comment.