You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In .NET Core 3.0 we introduced the method string.GetPinnableReference, which retrieves a readonly char& pointing to the first character of the string's data. (If the string is empty, it returns a reference to the null terminator.)
It is preferred for compilers to use this method instead of RuntimeHelpers.GetOffsetToStringData when pinning string instances. The GetOffsetToStringData method assumes that the character data is inline with the string object itself. We want to experiment with breaking this assumption in future versions of .NET, and we need to get compilers off of this API and onto the preferred GetPinnableReference method instead.
If the application is targeting a previous version of .NET - one that doesn't include string.GetPinnableReference - then the compiler should continue to fall back to GetOffsetToStringData.
In .NET Core 3.0 we introduced the method
string.GetPinnableReference
, which retrieves a readonly char& pointing to the first character of the string's data. (If the string is empty, it returns a reference to the null terminator.)It is preferred for compilers to use this method instead of
RuntimeHelpers.GetOffsetToStringData
when pinning string instances. TheGetOffsetToStringData
method assumes that the character data is inline with the string object itself. We want to experiment with breaking this assumption in future versions of .NET, and we need to get compilers off of this API and onto the preferredGetPinnableReference
method instead.If the application is targeting a previous version of .NET - one that doesn't include
string.GetPinnableReference
- then the compiler should continue to fall back toGetOffsetToStringData
.Repro steps
Expected IL
Actual IL
The text was updated successfully, but these errors were encountered: