diff options
author | EgorBo <egorbo@gmail.com> | 2018-05-31 18:09:44 +0300 |
---|---|---|
committer | Marek Safar <marek.safar@gmail.com> | 2018-05-31 18:12:52 +0300 |
commit | 324334fdaa57aaaf9f09c840a51ba7ed51ec7c7e (patch) | |
tree | 5664e0ab856015cd8b2410553556045b4d210920 | |
parent | d52ca23291ea6c40ec7d3f30160c261350256f70 (diff) |
Fix Guid TryFormat for mono
-rw-r--r-- | src/Common/src/CoreLib/System/Guid.cs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/Common/src/CoreLib/System/Guid.cs b/src/Common/src/CoreLib/System/Guid.cs index 185b9bc56d..3a39253376 100644 --- a/src/Common/src/CoreLib/System/Guid.cs +++ b/src/Common/src/CoreLib/System/Guid.cs @@ -1303,12 +1303,17 @@ namespace System string guidString = string.FastAllocateString(guidSize); int bytesWritten; + bool result; #if MONO // Span.Portable doesn't have Span(ref T[], int) constructor // Remove it once Mono switches to Span.Fast - bool result = TryFormat(new Span<char>(guidString.ToCharArray()), out bytesWritten, format); + unsafe + { + fixed (char* guidStringPtr = guidString) + result = TryFormat(new Span<char>(guidStringPtr, guidString.Length), out bytesWritten, format); + } #else - bool result = TryFormat(new Span<char>(ref guidString.GetRawStringData(), guidString.Length), out bytesWritten, format); + result = TryFormat(new Span<char>(ref guidString.GetRawStringData(), guidString.Length), out bytesWritten, format); #endif Debug.Assert(result && bytesWritten == guidString.Length, "Formatting guid should have succeeded."); |