Skip to content

Commit acb9841

Browse files
Copilotjkotas
andauthored
Clarify FixedAddressValueTypeAttribute applicability and static field storage wording (#12770)
* Update FixedAddressValueTypeAttribute docs per feedback * Apply suggestion from @jkotas * Fix remarks wording: replace 'may' with 'might', add 'the' before 'GC heap', use 'field' consistently --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Jan Kotas <jkotas@microsoft.com>
1 parent cc11708 commit acb9841

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

xml/System.Runtime.CompilerServices/FixedAddressValueTypeAttribute.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@
5454
<format type="text/markdown"><![CDATA[
5555
5656
## Remarks
57-
Use the <xref:System.Runtime.CompilerServices.FixedAddressValueTypeAttribute> attribute to mark static value types as pinned upon creation.
57+
Use the <xref:System.Runtime.CompilerServices.FixedAddressValueTypeAttribute> attribute to mark static value type fields as pinned upon creation. This attribute does not apply to primitive value type and enum fields.
5858
5959
This attribute is used by the Microsoft Visual C++ compiler.
6060
61-
Static value type fields are created as boxed objects. This means that their address can change as garbage collection is performed. When you apply this attribute to a static value type, its address remains constant during its lifetime.
61+
The storage for static value type fields might be allocated on the GC heap. This means that their address can change as garbage collection is performed. When you apply this attribute to a static value type field, its address remains constant during its lifetime.
6262
6363
## Examples
6464
The following example illustrates the use of the <xref:System.Runtime.CompilerServices.FixedAddressValueTypeAttribute> attribute to pin a static field in memory. It defines an `Age` structure and initializes two classes that have static fields of type `Age`. The second class applies <xref:System.Runtime.CompilerServices.FixedAddressValueTypeAttribute> to pin the field's address. A number of memory allocations are made before and after these two objects are instantiated and the garbage collector is invoked. The output from the example shows that although the address of the first `Age` field has changed after garbage collection, the address of the field to which <xref:System.Runtime.CompilerServices.FixedAddressValueTypeAttribute> is applied has not.

0 commit comments

Comments
 (0)