Skip to content

Commit ba463e1

Browse files
BillWagnerCopilot
andauthored
Add docs on ExtendedLayout (#51762)
* Add docs on ExtendedLayout Fixes #51746 Add description of the `ExtendedLayoutAttribute` in the language attributes section. * Update docs/csharp/language-reference/attributes/general.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Apply suggestion from @BillWagner --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent dad6c78 commit ba463e1

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

docs/csharp/language-reference/attributes/general.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "Attributes interpreted by the compiler: Miscellaneous"
3-
ms.date: 01/14/2026
3+
ms.date: 02/17/2026
44
description: "Learn about attributes that affect code generated by the compiler: the Conditional, Obsolete, AttributeUsage, ModuleInitializer, and SkipLocalsInit attributes."
55
---
66
# Miscellaneous attributes interpreted by the C# compiler
@@ -26,6 +26,7 @@ You can apply several attributes to elements in your code to add semantic meanin
2626
- [`InlineArray`](#inlinearray-attribute): Specify that a `struct` type is an *inline array*.
2727
- [`IUnknownConstant`](#iunknownconstant-and-idispatchconstant-attributes): Specifies how a missing argument should be supplied for a default parameter.
2828
- [`IDispatchConstant`](#iunknownconstant-and-idispatchconstant-attributes): Specifies how a missing argument should be supplied for a default parameter.
29+
- [`ExtendedLayoutAttribute`](#extendedlayout-attribute): Instructs the compiler to set the `ExtendedLayout` flag in the type's metadata.
2930

3031
The compiler uses those semantic meanings to alter its output and report possible mistakes by developers using your code.
3132

@@ -273,6 +274,16 @@ The <xref:System.Runtime.CompilerServices.CollectionBuilderAttribute?displayProp
273274

274275
The <xref:System.Runtime.CompilerServices.InlineArrayAttribute?displayProperty=nameWithType> attribute marks a type as an [inline array](../builtin-types/struct.md#inline-arrays). You can learn more about this feature in the article on `structs`, in the section on [inline arrays](../builtin-types/struct.md#inline-arrays).
275276

277+
> [!IMPORTANT]
278+
> This attribute can't be combined with the [`ExtendedLayout`](#extendedlayout-attribute) attribute.
279+
280+
## ExtendedLayout attribute
281+
282+
The <xref:System.Runtime.InteropServices.ExtendedLayoutAttribute?displayProperty=nameWithType> instructs the compiler to set the <xref:System.Reflection.TypeAttributes.ExtendedLayout?displayProperty=nameWithType> flag in the type's <xref:System.Type.Attributes?displayProperty=nameWithType> flags.
283+
284+
> [!IMPORTANT]
285+
> This attribute can't be combined with the [`StructLayoutAttribute`](pseudo-attributes.md) or the [`InlineArray`](#inlinearray-attribute) attribute.
286+
276287
## IUnknownConstant and IDispatchConstant attributes
277288

278289
The <xref:System.Runtime.CompilerServices.IUnknownConstantAttribute?displayProperty=nameWithType> and <xref:System.Runtime.CompilerServices.IDispatchConstantAttribute?displayProperty=nameWithType> attributes can be added to default parameters to indicate that a missing argument should be supplied as `new UnknownWrapper(null)` or `new DispatchWrapper(null)`.

docs/csharp/language-reference/attributes/pseudo-attributes.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "Attributes interpreted by the compiler: Pseudo-attributes"
3-
ms.date: 01/14/2026
3+
ms.date: 02/17/2026
44
description: "Learn about attributes you can add to code that are written to IL as modifiers. These custom attributes aren't emitted as attributes in the compiled output."
55
---
66
# Custom attributes that generate flags or options in the Intermediate Language (IL) output
@@ -23,6 +23,9 @@ Add these attributes to your code for the compiler to emit a specified Intermedi
2323
| <xref:System.Runtime.InteropServices.StructLayoutAttribute?displayProperty=fullName> | `auto`, `sequential`, or `explicit` | Layout options can be set using the parameters. |
2424
| <xref:System.Runtime.CompilerServices.IndexerNameAttribute?displayProperty=fullName> | | Add this attribute to an indexer to set a different method name. By default, indexers are compiled to a property named `Item`. You can specify a different name using this attribute. |
2525

26+
> [!IMPORTANT]
27+
> The [`StructLayoutAttribute`] can't be combined with the [`ExtendedLayout`](general.md#extendedlayout-attribute) attribute.
28+
2629
Some of these custom attributes are applied by using other C# syntax rather than adding the attribute to your source code.
2730

2831
| Attribute | Comments |

0 commit comments

Comments
 (0)