Open
Description
There are a number of unnecessary uses of Unsafe.AsPointer
in this repository (e.g.
Most of the uses can be broken in to 2 categories:
- Aligning or detecting alignment of a reference (we can introduce helper APIs for this, e.g. )
- Getting a pointer to something that is known to be pinned (many of these cases could be converted to ref fields instead, using refs/spans directly, or passing by pointer, e.g. )
The idea was mentioned by @tannergooding on the discord, and one of the suggested solutions was to create an internal API bool IsOpportunisticallyAligned(ref T address, nuint aligment)
or similar for the alignment uses.
I am happy to make PRs for these. @tannergooding suggested that I make one for each area separately. Just making this issue to track it and get support for the general idea from people.