-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
MemoryMarshal.{Try}Read/{Try}Write/AsRef should allow ref struct #113132
Comments
Tagging subscribers to this area: @dotnet/interop-contrib |
All of these are blocking |
Yeah. But note that
You don't have control to types coming from other libs. Some libs just define all their value types as We can already do |
Tagging subscribers to this area: @dotnet/interop-contrib |
Using pointer should be sufficient in these cases. |
That's why we need it to take a ref struct so that it can help block invalid usage because it checks gc pointer for you. Without the support, people will just copy whatever the code from its implementation and make their code even more unsafe.
This doesn't hold as you can replace almost all Unsafe.* API usage by using pointers, so it should have been so sufficient that Unsafe.* API shouldn't even have existed in the first place. |
We are missing
where T : allows ref struct
on:MemoryMarshal.Read
MemoryMarshal.TryRead
MemoryMarshal.Write
MemoryMarshal.TryWrite
MemoryMarshal.AsRef
MemoryMarshal.AsRef
(readonly ref)The text was updated successfully, but these errors were encountered: