Skip to content

Commit

Permalink
Remove leftover uses of DangerousGetPinnableReference (dotnet#26037)
Browse files Browse the repository at this point in the history
* Remove leftover uses of DangerousGetPinnableReference

* Add reference to system.memory
  • Loading branch information
ahsonkhan authored Dec 23, 2017
1 parent 6cb23ac commit f965141
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions src/System.IO.FileSystem/src/System/IO/PathHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ private unsafe static string CombineNoChecksInternal(ReadOnlySpan<char> 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),
Expand All @@ -143,7 +143,7 @@ private unsafe static string CombineNoChecksInternal(ReadOnlySpan<char> 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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
<Reference Include="System.Diagnostics.Contracts" />
<Reference Include="System.Diagnostics.Debug" />
<Reference Include="System.Diagnostics.Tools" />
<Reference Include="System.Memory" />
<Reference Include="System.Resources.ResourceManager" />
<Reference Include="System.Runtime" />
<Reference Include="System.Runtime.Extensions" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit f965141

Please sign in to comment.