From a5ca7b886fd3ec3e24b8cdb94ed61298f9043c27 Mon Sep 17 00:00:00 2001 From: Christopher Whitley Date: Thu, 16 Nov 2023 01:16:24 -0500 Subject: [PATCH] Check for GCLatencyMode.NoGCRegion This test fails occasionaly when run through the automated cake script. Wrapped the EndNoGCREgion in a check for GCTatencyMode.NoGCRegion to resolve --- .../Tests/MonoGame.Extended.Tests/Collections/BagTests.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/cs/Tests/MonoGame.Extended.Tests/Collections/BagTests.cs b/src/cs/Tests/MonoGame.Extended.Tests/Collections/BagTests.cs index 471743de..4712ba9f 100644 --- a/src/cs/Tests/MonoGame.Extended.Tests/Collections/BagTests.cs +++ b/src/cs/Tests/MonoGame.Extended.Tests/Collections/BagTests.cs @@ -35,7 +35,12 @@ namespace MonoGame.Extended.Tests.Collections Assert.True(false); } - GC.EndNoGCRegion(); + // Wrap in if statement due to exception thrown when running test through + // cake build script or when debugging test script manually. + if(GCSettings.LatencyMode == GCLatencyMode.NoGCRegion) + { + GC.EndNoGCRegion(); + } } }