-
Notifications
You must be signed in to change notification settings - Fork 117
Description
Is your feature request related to a problem? Please describe.
I get that .NET Framework is reaching a decade old in age, however the projects I work on require that I target a built-in runtime. Further to this, my main project is used in Windows PowerShell/PowerShell 7, so considering options like NativeAOT is not possible. What I'm finding is that setups like the below don't work on .NET Framework and are appropriately unavailable for me:
internal unsafe readonly ReadOnlySpan<winmdroot.System.Diagnostics.Debug.IMAGE_DATA_DIRECTORY> AsReadOnlySpan() => MemoryMarshal.CreateReadOnlySpan(ref Unsafe.AsRef(in _0), SpanLength);Describe the solution you'd like
Something like the following should achieve the same result and would work equally on .NET Framework with System.Memory, or .NET 8/9/10:
internal unsafe readonly ReadOnlySpan<winmdroot.System.Diagnostics.Debug.IMAGE_DATA_DIRECTORY> AsReadOnlySpan() => new(Unsafe.AsPointer(ref _0), SpanLength);I am yet to test this within my own code as an extension method, but will do so soon.
Describe alternatives you've considered
My own extension method as mentioned above, however it'd be good to have this as a first class available option.