Skip to content

New ExtendedLayoutAttribute recognized by the compiler #51746

@jnm2

Description

@jnm2

Type of issue

Missing information

Description

There is a new compiler-recognized attribute, ExtendedLayoutAttribute, intended for a user to write in source code. When this attribute is used, the type it is applied to may not have a StructLayout attribute, and IL metadata is emitted equivalent to [StructLayout(LayoutKind.Extended, Size=0, Pack=0)] for that type. LayoutKind.Extended is a new flag that causes TypeAttributes.ExtendedLayout to be specified in the numeric value of the emitted type flags.

This is of interest because [StructLayout(LayoutKind.Extended)] is not allowed to be written in code. To set that flag, you must use the ExtendedLayoutAttribute parameter.

Description of the general feature:

How the C# compiler behaves:

Page URL

https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/attributes/pseudo-attributes

Content source URL

https://github.com/dotnet/docs/blob/main/docs/csharp/language-reference/attributes/pseudo-attributes.md

Document Version Independent Id

e27e1497-736f-0bb3-abea-1bb11f6e8560

Platform Id

26b706b9-46d1-8f15-bfce-3b0e594eb5ff

Article author

@BillWagner

Metadata

  • ID: a7957a0a-90d6-51d4-8ed6-876b0c451f03
  • PlatformId: 26b706b9-46d1-8f15-bfce-3b0e594eb5ff
  • Service: dotnet-csharp
  • Sub-service: lang-reference

Related Issues

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions