Leonard Hecker ddae2a1d49
Remove UTF-8 BOM from all files (#11821)
As VS 2022 doesn't seem to store files with UTF-8 BOM as often anymore, we've
been getting more and more pull requests which seemingly randomly change files.
This cleans the situation up by removing the BOM from all files that have one.
Additionally, `Host.Tests.Feature.rc` was converted from UTF-16 to UTF-8.
2021-11-29 12:54:35 -06:00

31 lines
879 B
C#

using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace Samples.Terminal
{
internal static class NativeMethods
{
private static int MakeHRFromErrorCode(int errorCode)
{
// Don't convert it if it is already an HRESULT
if ((0xFFFF0000 & errorCode) != 0)
{
Debug.Assert(false, "errorCode is already HRESULT");
return errorCode;
}
return unchecked(((int)0x80070000) | errorCode);
}
internal static Exception GetExceptionForWin32Error(int errorCode)
{
return Marshal.GetExceptionForHR(MakeHRFromErrorCode(errorCode));
}
internal static Exception GetExceptionForLastWin32Error()
{
return GetExceptionForWin32Error(Marshal.GetLastWin32Error());
}
}
}