dotnet-api-docs icon indicating copy to clipboard operation
dotnet-api-docs copied to clipboard

Document `ref` return as required for field accessors in UnsafeAccessorAttribute

Open xparadoxical opened this issue 1 year ago • 1 comments

Summary

The documentation of UnsafeAccessorAttribute incorrectly suggests the ref return is optional for field accessors. Without ref you get System.BadImageFormatException: 'Invalid usage of UnsafeAccessorAttribute.'

Example accessor throwing the above exception when invoked:

[UnsafeAccessor(UnsafeAccessorKind.Field, Name = "_charBuffer")]
static extern char[] GetCharBuffer(StreamReader sr);

xparadoxical avatar Aug 17 '24 04:08 xparadoxical

Learn Build status updates of commit 3f91840:

:white_check_mark: Validation status: passed

File Status Preview URL Details
xml/System.Runtime.CompilerServices/UnsafeAccessorAttribute.xml :white_check_mark:Succeeded View

For more details, please refer to the build report.

For any questions, please: