Skip to content

Commit

Permalink
Use FailFast instead of throwing in DebugEx.Assert under .NET Framewo…
Browse files Browse the repository at this point in the history
…rk (#4625)
  • Loading branch information
Youssef1313 authored Jan 13, 2025
1 parent ca46a44 commit 63ec778
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/TestFramework/TestFramework/Internal/DebugEx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ public static void Assert([DoesNotReturnIf(false)] bool b, string message)
if (!b)
{
// In CI scenarios, we don't want Debug.Assert to show a dialog that
// ends up causing the job to timeout. Instead, we want to throw an Exception
throw new Exception($"Debug.Assert failed: {message}");
// ends up causing the job to timeout. We use FailFast instead.
// FailFast is better than throwing an exception to avoid anyone
// catching an exception and masking an assert failure.
var ex = new Exception($"Debug.Assert failed: {message}");
Environment.FailFast(ex.Message, ex);
}
}
#else
Expand Down

0 comments on commit 63ec778

Please sign in to comment.