Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document ref return as required for field accessors in UnsafeAccessorAttribute #10268

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

xparadoxical
Copy link
Contributor

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 xparadoxical requested a review from a team as a code owner August 17, 2024 04:34
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Aug 17, 2024
Copy link

Learn Build status updates of commit 3f91840:

✅ Validation status: passed

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

For more details, please refer to the build report.

For any questions, please:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-System.Runtime.CompilerServices community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant