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.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 @@ + 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); }