Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 281ef75

Browse files
MichalStrehovskyjkotas
authored andcommitted
Work around MCG bug around ref char marshalling (dotnet/corert#5481)
The change in the P/invoke signature that came from CoreCLR triggers a bug in MCG on the TFS side. Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com> Signed-off-by: dotnet-bot-corefx-mirror <dotnet-bot@microsoft.com>
1 parent 15f0dbe commit 281ef75

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/Common/src/CoreLib/Interop/Windows/Kernel32/Interop.GetFullPathNameW.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,17 @@ internal partial class Kernel32
1313
/// WARNING: This method does not implicitly handle long paths. Use GetFullPathName or PathHelper.
1414
/// </summary>
1515
[DllImport(Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Unicode, BestFitMapping = false, ExactSpelling = true)]
16+
#if PROJECTN
17+
internal static extern unsafe uint GetFullPathNameW(string path, uint numBufferChars, char* buffer, IntPtr mustBeZero);
18+
19+
// Works around https://devdiv.visualstudio.com/web/wi.aspx?pcguid=011b8bdf-6d56-4f87-be0d-0092136884d9&id=575202
20+
internal static unsafe uint GetFullPathNameW(string path, uint numBufferChars, ref char buffer, IntPtr mustBeZero)
21+
{
22+
fixed (char* pBuffer = &buffer)
23+
return GetFullPathNameW(path, numBufferChars, pBuffer, mustBeZero);
24+
}
25+
#else
1626
internal static extern uint GetFullPathNameW(string path, uint numBufferChars, ref char buffer, IntPtr mustBeZero);
27+
#endif
1728
}
1829
}

src/Common/src/CoreLib/Interop/Windows/Kernel32/Interop.GetLongPathNameW.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,17 @@ internal partial class Kernel32
1313
/// WARNING: This method does not implicitly handle long paths. Use GetFullPath/PathHelper.
1414
/// </summary>
1515
[DllImport(Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Unicode, BestFitMapping = false, ExactSpelling = true)]
16+
#if PROJECTN
17+
internal static extern unsafe uint GetLongPathNameW(ref char lpszShortPath, char* lpszLongPath, uint cchBuffer);
18+
19+
// Works around https://devdiv.visualstudio.com/web/wi.aspx?pcguid=011b8bdf-6d56-4f87-be0d-0092136884d9&id=575202
20+
internal static unsafe uint GetLongPathNameW(ref char lpszShortPath, ref char lpszLongPath, uint cchBuffer)
21+
{
22+
fixed (char* plpszLongPath = &lpszLongPath)
23+
return GetLongPathNameW(ref lpszShortPath, plpszLongPath, cchBuffer);
24+
}
25+
#else
1626
internal static extern uint GetLongPathNameW(ref char lpszShortPath, ref char lpszLongPath, uint cchBuffer);
27+
#endif
1728
}
1829
}

0 commit comments

Comments
 (0)