CSharpHttpServer/SimpleHttpServer/GlobalUsings.cs

22 lines
726 B
C#

global using static SimpleHttpServer.GlobalUsings;
using SimpleHttpServer.Types.Exceptions;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
namespace SimpleHttpServer;
internal static class GlobalUsings {
[DebuggerHidden]
internal static void Assert([DoesNotReturnIf(false)] bool b, string? message = null) {
if (!b) {
if (message == null)
throw new AssertionFailedException("An assertion has failed!");
else
throw new AssertionFailedException($"An assertion has failed: {message}");
}
}
[DebuggerHidden]
internal static void AssertImplies(bool x, bool y, string? message = null) => Assert(!x || y, message);
}