Skip to content

Commit

Permalink
Correct error messages for CoreCLR Win32 PAL uses in CoreLib (#76768)
Browse files Browse the repository at this point in the history
Contributes to #76736
  • Loading branch information
jkotas committed Oct 10, 2022
1 parent a04f75c commit 6893524
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/libraries/Common/src/System/IO/Win32Marshal.cs
Expand Up @@ -68,7 +68,9 @@ internal static Exception GetExceptionForWin32Error(int errorCode, string? path

static string GetPInvokeErrorMessage(int errorCode)
{
#if NET7_0_OR_GREATER
// Call Kernel32.GetMessage directly in CoreLib. It eliminates one level of indirection and it is necessary to
// produce correct error messages for CoreCLR Win32 PAL.
#if NET7_0_OR_GREATER && !SYSTEM_PRIVATE_CORELIB
return Marshal.GetPInvokeErrorMessage(errorCode);
#else
return Interop.Kernel32.GetMessage(errorCode);
Expand Down
Expand Up @@ -1795,6 +1795,12 @@
<Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.WIN32_FIND_DATA.cs">
<Link>Common\Interop\Windows\Kernel32\Interop.WIN32_FIND_DATA.cs</Link>
</Compile>
<Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.WriteFile_IntPtr.cs">
<Link>Common\Interop\Windows\Kernel32\Interop.WriteFile_IntPtr.cs</Link>
</Compile>
<Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.WriteFile_SafeHandle_IntPtr.cs">
<Link>Common\Interop\Windows\Kernel32\Interop.WriteFile_SafeHandle_IntPtr.cs</Link>
</Compile>
<Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.WriteFile_SafeHandle_NativeOverlapped.cs">
<Link>Common\Interop\Windows\Kernel32\Interop.WriteFile_SafeHandle_NativeOverlapped.cs</Link>
</Compile>
Expand Down Expand Up @@ -1974,12 +1980,6 @@
<Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.SetEnvironmentVariable.cs">
<Link>Common\Interop\Windows\Kernel32\Interop.SetEnvironmentVariable.cs</Link>
</Compile>
<Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.WriteFile_SafeHandle_IntPtr.cs">
<Link>Common\Interop\Windows\Kernel32\Interop.WriteFile_SafeHandle_IntPtr.cs</Link>
</Compile>
<Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.WriteFile_IntPtr.cs">
<Link>Common\Interop\Windows\Kernel32\Interop.WriteFile_SafeHandle_IntPtr.cs</Link>
</Compile>
<Compile Include="$(CommonPath)System\IO\Win32Marshal.cs">
<Link>Common\System\IO\Win32Marshal.cs</Link>
</Compile>
Expand Down

0 comments on commit 6893524

Please sign in to comment.