diff --git a/src/thirtytwo_tests/Win32/Foundation/HRESULTTests.cs b/src/thirtytwo_tests/Win32/Foundation/HRESULTTests.cs index b2d08a0..0dbad61 100644 --- a/src/thirtytwo_tests/Win32/Foundation/HRESULTTests.cs +++ b/src/thirtytwo_tests/Win32/Foundation/HRESULTTests.cs @@ -7,9 +7,12 @@ namespace Windows.Win32.Foundation; public class HRESULTTests { - [Fact] + [RetryFact(MaxRetries = 5)] public void HRESULT_ToStringWithDescription() { + // The Marshal.GetExceptionForHR method is not thread safe for CLR (COR_E*) HRESULTs. + // We don't control all threads in the process, so we have to retry a few times. + // .NET exception messages aren't localized. (Only .NET Framework) string message = HRESULT.COR_E_OBJECTDISPOSED.ToStringWithDescription(); message.Should().Be("HRESULT 0x80131622 [-2146232798]: Cannot access a disposed object.");