Class Contract
- Namespace
- MarymoorStudios.Core
- Assembly
- MarymoorStudios.Core.dll
Used to check contract invariants in either Debug-only (Assert) or Debug and Release (Requires, Invariant, etc.). Contract failures will attempt to break into the debugger, will trace the error, and will throw a ContractViolationException.
public static class Contract
- Inheritance
-
Contract
- Inherited Members
Methods
Assert(bool)
[Conditional("DEBUG")]
public static void Assert(bool condition)
Parameters
conditionbool
Assert(bool, string)
[Conditional("DEBUG")]
public static void Assert(bool condition, string message)
Parameters
Assert<T>(T, bool)
public static T Assert<T>(T retval, bool condition) where T : allows ref struct
Parameters
retvalTconditionbool
Returns
- T
Type Parameters
T
Assert<T>(T, bool, string)
public static T Assert<T>(T retval, bool condition, string message) where T : allows ref struct
Parameters
Returns
- T
Type Parameters
T
Fail()
public static void Fail()
Fail(string)
public static void Fail(string message)
Parameters
messagestring
FailThrow(string)
public static Exception FailThrow(string message)
Parameters
messagestring
Returns
Invariant(bool)
public static void Invariant(bool condition)
Parameters
conditionbool
Invariant(bool, string)
public static void Invariant(bool condition, string message)
Parameters
Requires(bool)
public static void Requires(bool condition)
Parameters
conditionbool
Requires(bool, string)
public static void Requires(bool condition, string message)
Parameters
Unused<T>(T)
Used to annotate unused parameters to indicate that they are required for method signature contractual reasons even if they are unused in the current implementation.
[Conditional("DEBUG")]
public static void Unused<T>(T unused) where T : allows ref struct
Parameters
unusedTThe unused parameter.
Type Parameters
TAny type.