Fixed #467 where IErrorHandler types threw error on ToString method after 4.0.1.

master
David Hall 2024-05-25 21:36:16 -06:00
parent 949f6bb8d2
commit 4b398b3f73
2 changed files with 7 additions and 1 deletions

View File

@ -27,7 +27,7 @@ public static class ErrorHelper
{
if (!lookupHelpers.TryGetValue(typeof(TType), out var lookupFunc))
lookupFunc = FormatMessage;
return lookupFunc(id.ToUInt32(null), lib ?? StaticFieldValueHash.GetFieldLib<TType, TFieldType>(id));
return lookupFunc(unchecked((uint)id.ToInt64(null)), lib ?? StaticFieldValueHash.GetFieldLib<TType, TFieldType>(id));
}
/// <summary>Formats the message.</summary>

View File

@ -121,6 +121,12 @@ public class Win32ErrorTests
[TestCase(0x00990003U, "0x00990003")]
public void ToStringTest(uint c, string val) => Assert.That(new Win32Error(c).ToString(), Does.StartWith(val));
[Test]
public void ToStringHRESULTTest()
{
Assert.That(new Win32Error(Win32Error.ERROR_CLOUD_FILE_NOT_UNDER_SYNC_ROOT).ToHRESULT().ToString(), Does.StartWith("HRESULT_FROM_WIN32(ERROR_CLOUD_FILE_NOT_UNDER_SYNC_ROOT"));
}
[Test]
public void TypeConverterTest()
{