-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Add SafeBuffer Span<T> methods #40842
Conversation
Note regarding the This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change. |
Tagging subscribers to this area: @eiriktsarpalis |
src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/SafeBuffer.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/SafeBuffer.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/SafeBuffer.cs
Outdated
Show resolved
Hide resolved
...aries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/SafeBufferTests.cs
Show resolved
Hide resolved
Yes, AllocHGlobal/FreeHGlobal works. SafeBuffer construction is unsafe. The caller is responsible for passing in the correct size. |
new TestStruct { I = 77, L = 88, D = 99 }, | ||
new TestStruct { I = 100, L = 200, D = 300 }, | ||
}; | ||
Span<TestStruct> structSpan = stackalloc TestStruct[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, modulo nit about redundant test. Could you please delete it?
You mean that |
...aries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/SafeBufferTests.cs
Outdated
Show resolved
Hide resolved
...aries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/SafeBufferTests.cs
Outdated
Show resolved
Hide resolved
Yes, you got it. One of my comments did not show up on github for some reason. |
@huoyaoyuan Thank you! |
@huoyaoyuan Thanks a lot! |
Closes #27831
I can't find tests for
SafeBuffer
class, so I didn't add tests for newly added methods.