From: simplejackcoder <40817635+simplejackcoder@users.noreply.github.com> Date: Thu, 28 Mar 2019 15:20:15 +0000 (-0700) Subject: GetPinnableReference on String.cs (#23428) X-Git-Tag: accepted/tizen/unified/20190813.215958~54^2~61 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7c4717e01baf2cc5f4f6a73fc56109b527311c2d;p=platform%2Fupstream%2Fcoreclr.git GetPinnableReference on String.cs (#23428) * GetPinnableReference on String.cs * Add attributes for debugger and performance --- diff --git a/src/System.Private.CoreLib/shared/System/String.cs b/src/System.Private.CoreLib/shared/System/String.cs index 1a1b80c..3ae88bb 100644 --- a/src/System.Private.CoreLib/shared/System/String.cs +++ b/src/System.Private.CoreLib/shared/System/String.cs @@ -473,6 +473,13 @@ namespace System return true; } + /// + /// Returns a reference to the first element of the String. If the string is null, an access will throw a NullReferenceException. + /// + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + [NonVersionable] + public ref readonly char GetPinnableReference() => ref _firstChar; + internal ref char GetRawStringData() => ref _firstChar; // Helper for encodings so they can talk to our buffer directly