From c33d94bd43331c6c79a2ec144c1902430c1dddc5 Mon Sep 17 00:00:00 2001 From: ahsonkhan Date: Fri, 22 Dec 2017 23:50:23 -0800 Subject: [PATCH 1/2] Remove leftover uses of DangerousGetPinnableReference --- .../src/Interop/Windows/advapi32/Interop.CryptGetProvParam.cs | 2 +- src/System.IO.FileSystem/src/System/IO/PathHelpers.cs | 4 ++-- .../src/Internal/Cryptography/Pal/Windows/HelpersWindows.cs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Common/src/Interop/Windows/advapi32/Interop.CryptGetProvParam.cs b/src/Common/src/Interop/Windows/advapi32/Interop.CryptGetProvParam.cs index be3d4df2de2f..2ad575297e5f 100644 --- a/src/Common/src/Interop/Windows/advapi32/Interop.CryptGetProvParam.cs +++ b/src/Common/src/Interop/Windows/advapi32/Interop.CryptGetProvParam.cs @@ -57,7 +57,7 @@ public static bool CryptGetProvParam( unsafe { - fixed (byte* bytePtr = &pbData.DangerousGetPinnableReference()) + fixed (byte* bytePtr = &MemoryMarshal.GetReference(pbData)) { return CryptGetProvParam(safeProvHandle, dwParam, (IntPtr)bytePtr, ref dwDataLen, 0); } diff --git a/src/System.IO.FileSystem/src/System/IO/PathHelpers.cs b/src/System.IO.FileSystem/src/System/IO/PathHelpers.cs index aa54d434febe..dc574c783396 100644 --- a/src/System.IO.FileSystem/src/System/IO/PathHelpers.cs +++ b/src/System.IO.FileSystem/src/System/IO/PathHelpers.cs @@ -118,7 +118,7 @@ private unsafe static string CombineNoChecksInternal(ReadOnlySpan first, R bool hasSeparator = PathInternal.IsDirectorySeparator(first[first.Length - 1]) || PathInternal.IsDirectorySeparator(second[0]); - fixed (char* f = &first.DangerousGetPinnableReference(), s = &second.DangerousGetPinnableReference()) + fixed (char* f = &MemoryMarshal.GetReference(first), s = &MemoryMarshal.GetReference(second)) { return string.Create( first.Length + second.Length + (hasSeparator ? 0 : 1), @@ -143,7 +143,7 @@ private unsafe static string CombineNoChecksInternal(ReadOnlySpan first, R bool thirdHasSeparator = PathInternal.IsDirectorySeparator(second[second.Length - 1]) || PathInternal.IsDirectorySeparator(third[0]); - fixed (char* f = &first.DangerousGetPinnableReference(), s = &second.DangerousGetPinnableReference(), t = &third.DangerousGetPinnableReference()) + fixed (char* f = &MemoryMarshal.GetReference(first), s = &MemoryMarshal.GetReference(second), t = &MemoryMarshal.GetReference(third)) { return string.Create( first.Length + second.Length + third.Length + (firstHasSeparator ? 0 : 1) + (thirdHasSeparator ? 0 : 1), diff --git a/src/System.Security.Cryptography.Pkcs/src/Internal/Cryptography/Pal/Windows/HelpersWindows.cs b/src/System.Security.Cryptography.Pkcs/src/Internal/Cryptography/Pal/Windows/HelpersWindows.cs index 0a8dd5e31e65..4dc1252a8f84 100644 --- a/src/System.Security.Cryptography.Pkcs/src/Internal/Cryptography/Pal/Windows/HelpersWindows.cs +++ b/src/System.Security.Cryptography.Pkcs/src/Internal/Cryptography/Pal/Windows/HelpersWindows.cs @@ -440,7 +440,7 @@ private static string GetStringProvParam( unsafe { - fixed (byte* asciiPtr = &buf.DangerousGetPinnableReference()) + fixed (byte* asciiPtr = &MemoryMarshal.GetReference(buf)) { return Marshal.PtrToStringAnsi((IntPtr)asciiPtr, len); } From 12224288575a5634d2849e68da34682ca39caadc Mon Sep 17 00:00:00 2001 From: ahsonkhan Date: Sat, 23 Dec 2017 00:24:07 -0800 Subject: [PATCH 2/2] Add reference to system.memory --- .../src/System.Security.Cryptography.Csp.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/src/System.Security.Cryptography.Csp/src/System.Security.Cryptography.Csp.csproj b/src/System.Security.Cryptography.Csp/src/System.Security.Cryptography.Csp.csproj index 097079ca3ec5..e0943bbe3761 100644 --- a/src/System.Security.Cryptography.Csp/src/System.Security.Cryptography.Csp.csproj +++ b/src/System.Security.Cryptography.Csp/src/System.Security.Cryptography.Csp.csproj @@ -93,6 +93,7 @@ +