Open sandboxFocus

Class Invariant

A utility class that checks runtime invariant and throws AssertionFailedException in case of failure.

Inheritance
Invariant
Namespace: Metalama.Framework.Engine
Assembly: Metalama.Framework.Sdk.dll
Syntax
[ExcludeFromCodeCoverage]
public static class Invariant

Methods

Name Description
Assert(bool, string?)

Checks that a given condition is true and throws an AssertionFailedException in case it is not.

AssertCast<T>(object?)
AssertDistinct<T>(IEnumerable<T>)
AssertEach<T>(IEnumerable<T>, Predicate<T>)
AssertNoneNull<T>(IEnumerable<T?>?)
AssertNoneNull<T>(ImmutableArray<T?>)
AssertNoneNull<T>(T?[]?)
AssertNot(bool, string?)

Checks that a given condition is false and throws an AssertionFailedException in case it is not.

AssertNotNullAsync<T>(Task<T?>?, string?)

Checks that a Task and its result are non-null and throws an AssertionFailedException if it is not.

AssertNotNullAsync<T>(ValueTask<T?>, string?)
AssertNotNull<T>(T?, string?)

Checks that a nullable value is non-null and throws an AssertionFailedException if it is not.

AssertNotNull<T>(Task<T?>?, string?)
AssertNotNull<T>(ValueTask<T?>, string?)
AssertNotNull<T>(T?, string?)

Checks that a reference is non-null and throws an AssertionFailedException if it is not.

AssertSorted<TItem>(IReadOnlyList<TItem>)
AssertSorted<TItem, TComparable>(IReadOnlyList<TItem>, Comparison<TItem>)
AssertSorted<TItem, TComparable>(IReadOnlyList<TItem>, Func<TItem, TComparable>)
AssertSorted<TItem, TComparable>(IReadOnlyList<TItem>, Func<TItem, TComparable>, Comparison<TComparable>)
AssertSymbolNotNull<TSymbol>(TSymbol?, string?)
AssertSymbolNullNotImplemented<TSymbol>(TSymbol?, string?)
Assert<T>(T, Predicate<T>)
CanBeNull<T>(T, string?)

Checks that a nullable value is non-null and throws an AssertionFailedException if it is not.

Implies(bool, bool)