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
API Proposal: SafeBuffer Span<T> methods #27831
Comments
Seems reasonable to me. These are just direct span-based equivalents of the existing array methods: public void ReadArray<T>(ulong byteOffset, T[] array, int index, int count) where T : struct;
public void WriteArray<T>(ulong byteOffset, T[] array, int index, int count) where T : struct; |
Not necessarily against these, but if I recall the Other than perhaps placement, this seems like a good idea. |
Interesting. What does it mean for SafeBuffer to be obsolete but SafeMemoryMappedViewHandle derived from it to not be? |
@stephentoub That is a great question. This has been marked this way for a long time if I recall - well before I came on the scene. Can you think of anyone who might know why this class was officially marked as obsolete? |
Looks like this is happening because of something from netstandard 1.2 😮 Perhaps a mistake? |
People were pretty liberal in early days of .NET Core with marking things obsolete. Most/all of it was rolled back. I am not able to find the history for this particular one, but here are a few related PRs: |
I think it's possible to implement the proposal directly on We have access to the handle and length via Does it make more sense to do that or try and undeprecate |
|
@vcsjones Now that the |
Happy to do a PR for this when it gets through API review. |
We didn't discuss the parameter names in the review. Should they both be called public void ReadSpan<T>(ulong byteOffset, Span<T> buffer) where T : struct => throw null;
public void WriteSpan<T>(ulong byteOffset, ReadOnlySpan<T> data) where T : struct => throw null; |
Hm. Probably just a poor decision on my part when writing this up.
I think I avoided |
Looks like this is unassigned. @vcsjones did you want to take this or should we mark it up for grabs? |
@GrabYourPitchforks I'm happy to pick it up; wanted to know how we should resolve @ahsonkhan's feedback post API Review process. |
It's fine to call the parameter name span IMO. We do this for other APIs which accept |
Granted, that's an extension method. I think either |
@vcsjones Where did we land on this? Did I miss the PR? |
This is marked as api-approved. Presumably what's next is just for someone to implement it 😄 |
Hm, I guess that can be me. I see I offered a little while ago but failed to follow through. Apologies. |
No need to apologize :) Thanks for the offer. |
Proposal:
The purpose of this is to be a Span-based equivalent of
ReadArray
. The motivation for this is for a later API proposal to add the same methods toUnmanagedMemoryAccessor
which will work for memory mapped views.This would make it possible to work efficiently and safely with stackalloc'ed data.
The text was updated successfully, but these errors were encountered: