Semantica.Lib.Checks
8.1.0
dotnet add package Semantica.Lib.Checks --version 8.1.0
NuGet\Install-Package Semantica.Lib.Checks -Version 8.1.0
<PackageReference Include="Semantica.Lib.Checks" Version="8.1.0" />
<PackageVersion Include="Semantica.Lib.Checks" Version="8.1.0" />
<PackageReference Include="Semantica.Lib.Checks" />
paket add Semantica.Lib.Checks --version 8.1.0
#r "nuget: Semantica.Lib.Checks, 8.1.0"
#:package Semantica.Lib.Checks@8.1.0
#addin nuget:?package=Semantica.Lib.Checks&version=8.1.0
#tool nuget:?package=Semantica.Lib.Checks&version=8.1.0
Semantica.Lib.Checks
This package is part of the core packages of Semantica.Lib.
Summary
A library that provides types and statics to streamline guards and validations. The Chk
and Chk<T>
value types provide
boolean-like behaviour but can be combined with a reason and/or a payload. Guard
static methods throws exceptions when
checks fail.
Contents
type Chk
Contains the Chk
and Chk<T>
types. These types can be thought of and manipulated as boolean types, but can also contain
a (string) Reason, and in the case of the generic version, a Payload. Chk is used to streamline sequential checks by leveraging
short-circuiting of boolean operators. This results in more elegant and consistently structured validation methods. The Reason
can be used for either feedback or debugging purposes to make apparent why validation fails when there are multiple checks done.
Payload can be used to return other types of additional information such as associated keys. There is also a non-determined
outcome of Chk that is only a reason (Chk.Rsn
) and/or a payload (Chk.Pld
) associated with either a pass or a fail, that
can be &&-ed or ||-ed onto a determined Pass/Fail. Through that mechanism reason and payload-creation can also be skipped using
short-circuiting when not applicable.
Chk
and Chk<T>
can be implicitly cast to each other, although obviously payload will be lost when casting to the
non-generic version. This can be done explicitly with the Simplify()
method, or Simplify(out T)
if you want to use the
payload locally. There are operator overloads for and/or where the left operand is Chk
and the right operand and result are
Chk<T>
, but short-circuiting is only possible in C# when both operands are of the same type, so can only be used as the
bitwise, non short-circuit operators.
Using a non-determined (IsDetermined=false
) instance with reason or payloads as the right hand side of and/or operators will
result in an exception when the wrong operator is used for the wrong Pass-value. i.e. Fail reasons can only be or-ed, Pass
reasons can only be and-ed.
As an optional safety feature, HasPassed()
and HasFailed()
can be used when evaluating the validation. The boolean value
of an undetermined reason for pass will still be true (as will the Pass
property), but HasPassed()
will only return
true when Pass
and IsDetermined
are true. HasFailed()
will also return true when IsDetermined
is false. This is
for safety concerns, so a check will not pass when a non-determined instance is accidentally returned.
static Guard & Check
Provide more elegant method of implementing guards in your methods. The Guard
static methods throws exceptions if a guard is
not satisfied. By using the Check
static methods that return Chk<CheckKind>
values, a more comprehensive error message
is generated than with the standard if/throw ArgumentException.
Examples
Chk
Most basic validation with short circuiting - condition 2 is only evaluated if condition 1 is true.
Chk validation = Chk.If(condition1) && Chk.If(condition2)
if (validation.HasPassed())
{
//do work
}
Validation with basic reason.
Chk validation = Chk.If(condition1).Fails("condition 1 was not satisfied.")
if (validation.HasPassed())
{
//do work
}
else return Conflict(validation.Reason);
Validation with reason short-cicuiting.
Chk validation = Chk.If(condition1) || Chk.Rsn.ForFail($"condition 1 on entity {(await GetEntity(key)).Name} was not satisfied.")
if (validation.HasPassed())
{
//do work
}
else return Conflict(validation.Reason);
Name validation that returns the matching key.
public Chk<Key> ValidateName(string name)
{
var entity = await GetEntityByName(name);
Chk validation = Chk.If(entity != null).Fails($"No entity with name '{name}' not found.")
&& Chk.If(entity.IsActive).Fails($"Entity with key {entity.Key} that matches name '{name}' is not active.");
return Chk.WithPld(entity.Key);
}
Same name validation, but where the payload is only retrieved if previous validations passed.
public Chk<Key> ValidateName(string name)
{
var entity = await GetEntityByName(name);
Chk<Key> validation = Chk.If(entity != null).Fails($"No entity with name '{name}' not found.");
return validation && Chk.Pld.ForPass(await GetAssociatedEntityKey(entity));
}
Subsequent validation chaining with payload reuse
var validation = ValidateName(name).Simplify(out Key key) && ValidateSystemState(key);
if (validation.HasFailed())
return Conflict(validation.Reason);
//do work
Documentation generated from the XMLDoc:
<a name='assembly'></a>
Lib.Checks
Contents
- Check
- None
- AreEqual``1(left,right,leftExpression,rightExpression)
- Fails(description)
- IsDefined(value,name)
- IsDefined(value,name)
- IsDefined``1(value,name)
- IsDefined``1(value,name)
- IsDetermined``1(value,name)
- IsDetermined``1(value,name)
- MaxLength(value,maxLength,name)
- MinLength(value,minLength,name)
- NonZero(value,name)
- NonZero(value,name)
- NonZero(value,name)
- NonZero(value,name)
- NonZero(value,name)
- NonZero(value,name)
- Not(condition,expression)
- NotDefault``1(value,name)
- NotEmpty(value,name)
- NotEmpty(value,name)
- NotEmpty(value,name)
- NotEmpty``1(collection,name)
- NotEmpty``1(collection,name)
- NotEmpty``1(value,name)
- NotEmpty``1(value,name)
- NotNegative(value,name)
- NotNegative(value,name)
- NotNegative(value,name)
- NotNegative(value,name)
- NotNegative(value,name)
- NotNegative(value,name)
- NotNullOrDefault``1(value,name)
- NotNull``1(value,name)
- NotNull``1(value,name)
- StrictPositive(value,name)
- StrictPositive(value,name)
- StrictPositive(value,name)
- StrictPositive(value,name)
- StrictPositive(value,name)
- StrictPositive(value,name)
- That(condition,expression)
- WhenNotEmpty``1(value,check)
- WhenNotEmpty``1(value,check)
- WhenNotNull``1(value,check)
- WhenNotNull``1(value,check)
- CheckExtensions
- Chk
- Fail
- IsDetermined
- Pass
- Fails(failReason)
- Fails``1(payload)
- Fails``1(failReason,payload)
- If(result)
- If``1(result)
- Passes(passReason)
- Passes``1(payload)
- Passes``1(passReason,payload)
- SplitReasons()
- ToString()
- WithPld``1(payload)
- WithRsn(reason)
- op_BitwiseAnd(left,right)
- op_BitwiseOr(left,right)
- op_False()
- op_LogicalNot()
- op_True()
- Chk`1
- Fail
- Pass
- Payload
- Fails(failReason)
- Fails(payload)
- Fails(failReason,payload)
- Passes(passReason)
- Passes(payload)
- Passes(passReason,payload)
- Simplify()
- Simplify(payload)
- SplitReasons()
- ToString()
- op_BitwiseAnd(left,right)
- op_BitwiseAnd(left,right)
- op_BitwiseOr(left,right)
- op_BitwiseOr(left,right)
- op_False()
- op_LogicalNot()
- op_True()
- ContractArgumentException
- ContractArgumentNullException
- ContractArgumentOutOfRangeException
- ContractException
- Guard
- Contract(check,expression)
- Contract(check,description,argumentName)
- Contract(check)
- Contract(check,description)
- For(check,expression)
- For(check,description,argumentName)
- For(check)
- For(check,description)
- For``1(check)
- Index(index,end)
- Index(index,start,end)
- State(check,expression)
- State(check,description,fieldName)
- State(check)
- State(check,description)
- GuardArgumentException
- GuardArgumentNullException
- GuardArgumentOutOfRangeException
- GuardException
- IChk
- Pld
- Rsn
- Rsn
- StateException
- Throw
<a name='T-Semantica-Checks-Check'></a>
Check type
Namespace
Semantica.Checks
Summary
Provides a number of standard checks that can be used for guards. The CheckKindPayload indicates the type of check that has failed, so a proper exception(-message) can be constructed. The Reason will contain the expression passed on failure.
<a name='F-Semantica-Checks-Check-None'></a>
None constants
Summary
<a name='M-Semantica-Checks-Check-AreEqual1-
0,``0,System-String,System-String-'></a>
AreEqual``1(left,right,leftExpression,rightExpression) method
Summary
Makes a check that passes if the left
and the right
are equal; and fails otherwise.
Returns
A new Chk`1 of CheckKind that is Passed when conditions are met.
Parameters
Name | Type | Description |
---|---|---|
left | ``0 | The bool result of a condition. |
right | ``0 | The bool result of a condition. |
leftExpression | System.String | The left expression to be added as reason on fail. |
rightExpression | System.String | The right expression to be added as reason on fail. |
<a name='M-Semantica-Checks-Check-Fails-System-String-'></a>
Fails(description) method
Summary
Creates a failed check reason that can be ||
'd onto an actual check in order to make the evaluation of the
reason only evaluated if the check fails using short-circuit mechanisms.
Returns
A Chk`1 of CheckKind with the provided description
.
Parameters
Name | Type | Description |
---|---|---|
description | System.String | Description of the failed check. |
<a name='M-Semantica-Checks-Check-IsDefined-System-Double,System-String-'></a>
IsDefined(value,name) method
Summary
Makes a check of kind Defined that passes if value
is a valid value for
double; and fails if the value is double.NaN
or double.Infinity
.
Returns
A new Chk`1 of CheckKind that is Passed when conditions are met.
Parameters
Name | Type | Description |
---|---|---|
value | System.Double | The value to check. |
name | System.String | Name/expression of the value field, argument or property to check. Added as Reason on failure. |
<a name='M-Semantica-Checks-Check-IsDefined-System-Nullable{System-Double},System-String-'></a>
IsDefined(value,name) method
Summary
Makes a check of kind Defined that passes if value
is a valid value for
double; and fails if the value is double.NaN
or double.Infinity
.
Returns
A new Chk`1 of CheckKind that is Passed when conditions are met.
Parameters
Name | Type | Description |
---|---|---|
value | System.Nullable{System.Double} | The value to check. |
name | System.String | Name/expression of the value field, argument or property to check. Added as Reason on failure. |
<a name='M-Semantica-Checks-Check-IsDefined1-
0,System-String-'></a>
IsDefined``1(value,name) method
Summary
Makes a check of kind Defined that passes if value
is a valid value for enum
T
; and fails otherwise.
Returns
A new Chk`1 of CheckKind that is Passed when conditions are met.
Parameters
Name | Type | Description |
---|---|---|
value | ``0 | The value to check. |
name | System.String | Name/expression of the value field, argument or property to check. Added as Reason on failure. |
Generic Types
Name | Description |
---|---|
T | Type of the enum value to check. |
<a name='M-Semantica-Checks-Check-IsDefined1-System-Nullable{
0},System-String-'></a>
IsDefined``1(value,name) method
Summary
Makes a check of kind Defined that passes if value
is a valid value for enum
T
; and fails otherwise.
Returns
A new Chk`1 of CheckKind that is Passed when conditions are met.
Parameters
Name | Type | Description |
---|---|---|
value | System.Nullable{``0} | The value to check. |
name | System.String | Name/expression of the value field, argument or property to check. Added as Reason on failure. |
Generic Types
Name | Description |
---|---|
T | Type of the enum value to check. |
<a name='M-Semantica-Checks-Check-IsDetermined1-
0,System-String-'></a>
IsDetermined``1(value,name) method
Summary
Makes a check of kind Defined that passes if value
is determined;
and fails otherwise.
Returns
A new Chk`1 of CheckKind that is Passed when conditions are met.
Parameters
Name | Type | Description |
---|---|---|
value | ``0 | The instance to check. |
name | System.String | Name/expression of the value field, argument or property to check. Added as Reason on failure. |
Generic Types
Name | Description |
---|---|
T | The IDeterminable type of instance to check. |
<a name='M-Semantica-Checks-Check-IsDetermined1-System-Nullable{
0},System-String-'></a>
IsDetermined``1(value,name) method
Summary
Makes a check of kind Defined that passes if value
is determined;
and fails otherwise.
Returns
A new Chk`1 of CheckKind that is Passed when conditions are met.
Parameters
Name | Type | Description |
---|---|---|
value | System.Nullable{``0} | The instance to check. |
name | System.String | Name/expression of the value field, argument or property to check. Added as Reason on failure. |
Generic Types
Name | Description |
---|---|
T | The IDeterminable type of instance to check. |
<a name='M-Semantica-Checks-Check-MaxLength-System-String,System-Int32,System-String-'></a>
MaxLength(value,maxLength,name) method
Summary
Makes a check that passes if value
is at most maxLength
characters in length; and
fails otherwise.
Returns
A new Chk`1 of CheckKind that is Passed when conditions are met.
Parameters
Name | Type | Description |
---|---|---|
value | System.String | The String instance to check. |
maxLength | System.Int32 | The maximal valid length for the input. |
name | System.String | Name/expression of the value field, argument or property to check. Added as Reason on failure. |
<a name='M-Semantica-Checks-Check-MinLength-System-String,System-Int32,System-String-'></a>
MinLength(value,minLength,name) method
Summary
Makes a check that passes if value
is not null
and at least
minLength
characters in length; and fails otherwise.
Returns
A new Chk`1 of CheckKind that is Passed when conditions are met.
Parameters
Name | Type | Description |
---|---|---|
value | System.String | The String instance to check. |
minLength | System.Int32 | The minimal valid length for the input. |
name | System.String | Name/expression of the value field, argument or property to check. Added as Reason on failure. |
<a name='M-Semantica-Checks-Check-NonZero-System-Int32,System-String-'></a>
NonZero(value,name) method
Summary
Makes a check of kind NonZero that passes if value
is not zero; and fails
otherwise.
Returns
A new Chk`1 of CheckKind that is Passed when conditions are met.
Parameters
Name | Type | Description |
---|---|---|
value | System.Int32 | The int value to check. |
name | System.String | Name/expression of the value field, argument or property to check. Added as Reason on failure. |
<a name='M-Semantica-Checks-Check-NonZero-System-Int16,System-String-'></a>
NonZero(value,name) method
Summary
Makes a check of kind NonZero that passes if value
is not zero; and fails
otherwise.
Returns
A new Chk`1 of CheckKind that is Passed when conditions are met.
Parameters
Name | Type | Description |
---|---|---|
value | System.Int16 | The short value to check. |
name | System.String | Name/expression of the value field, argument or property to check. Added as Reason on failure. |
<a name='M-Semantica-Checks-Check-NonZero-System-Int64,System-String-'></a>
NonZero(value,name) method
Summary
Makes a check of kind NonZero that passes if value
is not zero; and fails
otherwise.
Returns
A new Chk`1 of CheckKind that is Passed when conditions are met.
Parameters
Name | Type | Description |
---|---|---|
value | System.Int64 | The long value to check. |
name | System.String | Name/expression of the value field, argument or property to check. Added as Reason on failure. |
<a name='M-Semantica-Checks-Check-NonZero-System-Single,System-String-'></a>
NonZero(value,name) method
Summary
Makes a check of kind NonZero that passes if value
is not zero; and fails
otherwise.
Returns
A new Chk`1 of CheckKind that is Passed when conditions are met.
Parameters
Name | Type | Description |
---|---|---|
value | System.Single | The float value to check. |
name | System.String | Name/expression of the value field, argument or property to check. Added as Reason on failure. |
<a name='M-Semantica-Checks-Check-NonZero-System-Double,System-String-'></a>
NonZero(value,name) method
Summary
Makes a check of kind NonZero that passes if value
is not zero; and fails
otherwise.
Returns
A new Chk`1 of CheckKind that is Passed when conditions are met.
Parameters
Name | Type | Description |
---|---|---|
value | System.Double | The double value to check. |
name | System.String | Name/expression of the value field, argument or property to check. Added as Reason on failure. |
<a name='M-Semantica-Checks-Check-NonZero-System-Decimal,System-String-'></a>
NonZero(value,name) method
Summary
Makes a check of kind NonZero that passes if value
is not zero; and fails
otherwise.
Returns
A new Chk`1 of CheckKind that is Passed when conditions are met.
Parameters
Name | Type | Description |
---|---|---|
value | System.Decimal | The decimal value to check. |
name | System.String | Name/expression of the value field, argument or property to check. Added as Reason on failure. |
<a name='M-Semantica-Checks-Check-Not-System-Boolean,System-String-'></a>
Not(condition,expression) method
Summary
Makes a check that passes if condition
is false
; and fails otherwise.
Returns
A new Chk`1 of CheckKind that is Passed when conditions are met.
Parameters
Name | Type | Description |
---|---|---|
condition | System.Boolean | The bool result of a condition. |
expression | System.String | The expression to be added as reason on fail. |
<a name='M-Semantica-Checks-Check-NotDefault1-
0,System-String-'></a>
NotDefault``1(value,name) method
Summary
Makes a check of kind NotNull that passes if value
is not equal to
default
; and fails otherwise.
Returns
A new Chk`1 of CheckKind that is Passed when conditions are met.
Parameters
Name | Type | Description |
---|---|---|
value | ``0 | The instance to check. |
name | System.String | Name/expression of the value field, argument or property to check. Added as Reason on failure. |
Generic Types
Name | Description |
---|---|
T | The IEquatable`1 type of instance to check. |
<a name='M-Semantica-Checks-Check-NotEmpty-System-Guid,System-String-'></a>
NotEmpty(value,name) method
Summary
Makes a check of kind NotEmpty that passes if value
is not
Guid.Empty
; and fails otherwise.
Returns
A new Chk`1 of CheckKind that is Passed when conditions are met.
Parameters
Name | Type | Description |
---|---|---|
value | System.Guid | The Guid instance to check. |
name | System.String | Name/expression of the value field, argument or property to check. Added as Reason on failure. |
<a name='M-Semantica-Checks-Check-NotEmpty-System-Nullable{System-Guid},System-String-'></a>
NotEmpty(value,name) method
Summary
Makes a check of kind NotEmpty that passes if value
is not
Guid.Empty
; and fails otherwise.
Returns
A new Chk`1 of CheckKind that is Passed when conditions are met.
Parameters
Name | Type | Description |
---|---|---|
value | System.Nullable{System.Guid} | The Guid instance to check. |
name | System.String | Name/expression of the value field, argument or property to check. Added as Reason on failure. |
<a name='M-Semantica-Checks-Check-NotEmpty-System-String,System-String-'></a>
NotEmpty(value,name) method
Summary
Makes a check of kind NotEmpty that passes if value
is not
null
or an empty string; and fails otherwise.
Returns
A new Chk`1 of CheckKind that is Passed when conditions are met.
Parameters
Name | Type | Description |
---|---|---|
value | System.String | The String instance to check. |
name | System.String | Name/expression of the value field, argument or property to check. Added as Reason on failure. |
<a name='M-Semantica-Checks-Check-NotEmpty1-System-Collections-Generic-IReadOnlyCollection{
0},System-String-'></a>
NotEmpty``1(collection,name) method
Summary
Makes a check of kind NotEmpty that passes if collection
is not
null
and has at least one element; and fails otherwise.
Returns
A new Chk`1 of CheckKind that is Passed when conditions are met.
Parameters
Name | Type | Description |
---|---|---|
collection | System.Collections.Generic.IReadOnlyCollection{``0} | The collection instance to check. |
name | System.String | Name/expression of the collection field, argument or property to check. Added as Reason on failure. |
Generic Types
Name | Description |
---|---|
T | The IReadOnlyCollection`1 type of instance to check. |
<a name='M-Semantica-Checks-Check-NotEmpty1-System-Collections-Generic-IReadOnlyList{
0},System-String-'></a>
NotEmpty``1(collection,name) method
Summary
Makes a check of kind NotEmpty that passes if collection
is not
null
and has at least one element; and fails otherwise.
Returns
A new Chk`1 of CheckKind that is Passed when conditions are met.
Parameters
Name | Type | Description |
---|---|---|
collection | System.Collections.Generic.IReadOnlyList{``0} | The collection instance to check. |
name | System.String | Name/expression of the collection field, argument or property to check. Added as Reason on failure. |
Generic Types
Name | Description |
---|---|
T | The IReadOnlyList`1 type of instance to check. |
<a name='M-Semantica-Checks-Check-NotEmpty1-
0,System-String-'></a>
NotEmpty``1(value,name) method
Summary
Makes a check of kind NotEmpty that passes if value
is not empty; and fails
otherwise.
Returns
A new Chk`1 of CheckKind that is Passed when conditions are met.
Parameters
Name | Type | Description |
---|---|---|
value | ``0 | The instance to check. |
name | System.String | Name/expression of the value field, argument or property to check. Added as Reason on failure. |
Generic Types
Name | Description |
---|---|
T | The ICanBeEmpty type of instance to check. |
<a name='M-Semantica-Checks-Check-NotEmpty1-System-Nullable{
0},System-String-'></a>
NotEmpty``1(value,name) method
Summary
Makes a check of kind NotEmpty that passes if value
is not empty; and fails
otherwise.
Returns
A new Chk`1 of CheckKind that is Passed when conditions are met.
Parameters
Name | Type | Description |
---|---|---|
value | System.Nullable{``0} | The instance to check. |
name | System.String | Name/expression of the value field, argument or property to check. Added as Reason on failure. |
Generic Types
Name | Description |
---|---|
T | The ICanBeEmpty type of instance to check. |
<a name='M-Semantica-Checks-Check-NotNegative-System-Int32,System-String-'></a>
NotNegative(value,name) method
Summary
Makes a check of kind NonNegative that passes if value
is not negative;
and fails otherwise.
Returns
A new Chk`1 of CheckKind that is Passed when conditions are met.
Parameters
Name | Type | Description |
---|---|---|
value | System.Int32 | The int value to check. |
name | System.String | Name/expression of the value field, argument or property to check. Added as Reason on failure. |
<a name='M-Semantica-Checks-Check-NotNegative-System-Int16,System-String-'></a>
NotNegative(value,name) method
Summary
Makes a check of kind NonNegative that passes if value
is not negative;
and fails otherwise.
Returns
A new Chk`1 of CheckKind that is Passed when conditions are met.
Parameters
Name | Type | Description |
---|---|---|
value | System.Int16 | The short value to check. |
name | System.String | Name/expression of the value field, argument or property to check. Added as Reason on failure. |
<a name='M-Semantica-Checks-Check-NotNegative-System-Int64,System-String-'></a>
NotNegative(value,name) method
Summary
Makes a check of kind NonNegative that passes if value
is not negative;
and fails otherwise.
Returns
A new Chk`1 of CheckKind that is Passed when conditions are met.
Parameters
Name | Type | Description |
---|---|---|
value | System.Int64 | The long value to check. |
name | System.String | Name/expression of the value field, argument or property to check. Added as Reason on failure. |
<a name='M-Semantica-Checks-Check-NotNegative-System-Single,System-String-'></a>
NotNegative(value,name) method
Summary
Makes a check of kind NonNegative that passes if value
is not negative;
and fails otherwise.
Returns
A new Chk`1 of CheckKind that is Passed when conditions are met.
Parameters
Name | Type | Description |
---|---|---|
value | System.Single | The float value to check. |
name | System.String | Name/expression of the value field, argument or property to check. Added as Reason on failure. |
<a name='M-Semantica-Checks-Check-NotNegative-System-Double,System-String-'></a>
NotNegative(value,name) method
Summary
Makes a check of kind NonNegative that passes if value
is not negative;
and fails otherwise.
Returns
A new Chk`1 of CheckKind that is Passed when conditions are met.
Parameters
Name | Type | Description |
---|---|---|
value | System.Double | The double value to check. |
name | System.String | Name/expression of the value field, argument or property to check. Added as Reason on failure. |
<a name='M-Semantica-Checks-Check-NotNegative-System-Decimal,System-String-'></a>
NotNegative(value,name) method
Summary
Makes a check of kind NonNegative that passes if value
is not negative;
and fails otherwise.
Returns
A new Chk`1 of CheckKind that is Passed when conditions are met.
Parameters
Name | Type | Description |
---|---|---|
value | System.Decimal | The decimal value to check. |
name | System.String | Name/expression of the value field, argument or property to check. Added as Reason on failure. |
<a name='M-Semantica-Checks-Check-NotNullOrDefault1-
0,System-String-'></a>
NotNullOrDefault``1(value,name) method
Summary
Makes a check of kind NotNull that passes if value
is not
default
, using de default EqualityComparer`1; and fails otherwise.
Returns
A new Chk`1 of CheckKind that is Passed when conditions are met.
Parameters
Name | Type | Description |
---|---|---|
value | ``0 | The instance to check. |
name | System.String | Name/expression of the value field, argument or property to check. Added as Reason on failure. |
Generic Types
Name | Description |
---|---|
T | The reference type of instance to check. |
<a name='M-Semantica-Checks-Check-NotNull1-
0,System-String-'></a>
NotNull``1(value,name) method
Summary
Makes a check of kind NotNull that passes if value
is not
null
; and fails otherwise.
Returns
A new Chk`1 of CheckKind that is Passed when conditions are met.
Parameters
Name | Type | Description |
---|---|---|
value | ``0 | The instance to check. |
name | System.String | Name/expression of the value field, argument or property to check. Added as Reason on failure. |
Generic Types
Name | Description |
---|---|
T | The reference type of instance to check. |
<a name='M-Semantica-Checks-Check-NotNull1-System-Nullable{
0},System-String-'></a>
NotNull``1(value,name) method
Summary
Makes a check of kind NotNull that passes if value
is not
null
; and fails otherwise.
Returns
A new Chk`1 of CheckKind that is Passed when conditions are met.
Parameters
Name | Type | Description |
---|---|---|
value | System.Nullable{``0} | The instance to check. |
name | System.String | Name/expression of the value field, argument or property to check. Added as Reason on failure. |
Generic Types
Name | Description |
---|---|
T | The Nullable`1 value type of instance to check. |
<a name='M-Semantica-Checks-Check-StrictPositive-System-Int32,System-String-'></a>
StrictPositive(value,name) method
Summary
Makes a check of kind StrictPositive that passes if value
is greater than
zero; and fails otherwise.
Returns
A new Chk`1 of CheckKind that is Passed when conditions are met.
Parameters
Name | Type | Description |
---|---|---|
value | System.Int32 | The int value to check. |
name | System.String | Name/expression of the value field, argument or property to check. Added as Reason on failure. |
<a name='M-Semantica-Checks-Check-StrictPositive-System-Int16,System-String-'></a>
StrictPositive(value,name) method
Summary
Makes a check of kind StrictPositive that passes if value
is greater than
zero; and fails otherwise.
Returns
A new Chk`1 of CheckKind that is Passed when conditions are met.
Parameters
Name | Type | Description |
---|---|---|
value | System.Int16 | The short value to check. |
name | System.String | Name/expression of the value field, argument or property to check. Added as Reason on failure. |
<a name='M-Semantica-Checks-Check-StrictPositive-System-Int64,System-String-'></a>
StrictPositive(value,name) method
Summary
Makes a check of kind StrictPositive that passes if value
is greater than
zero; and fails otherwise.
Returns
A new Chk`1 of CheckKind that is Passed when conditions are met.
Parameters
Name | Type | Description |
---|---|---|
value | System.Int64 | The long value to check. |
name | System.String | Name/expression of the value field, argument or property to check. Added as Reason on failure. |
<a name='M-Semantica-Checks-Check-StrictPositive-System-Single,System-String-'></a>
StrictPositive(value,name) method
Summary
Makes a check of kind StrictPositive that passes if value
is greater than
zero; and fails otherwise.
Returns
A new Chk`1 of CheckKind that is Passed when conditions are met.
Parameters
Name | Type | Description |
---|---|---|
value | System.Single | The float value to check. |
name | System.String | Name/expression of the value field, argument or property to check. Added as Reason on failure. |
<a name='M-Semantica-Checks-Check-StrictPositive-System-Double,System-String-'></a>
StrictPositive(value,name) method
Summary
Makes a check of kind StrictPositive that passes if value
is greater than
zero; and fails otherwise.
Returns
A new Chk`1 of CheckKind that is Passed when conditions are met.
Parameters
Name | Type | Description |
---|---|---|
value | System.Double | The double value to check. |
name | System.String | Name/expression of the value field, argument or property to check. Added as Reason on failure. |
<a name='M-Semantica-Checks-Check-StrictPositive-System-Decimal,System-String-'></a>
StrictPositive(value,name) method
Summary
Makes a check of kind StrictPositive that passes if value
is greater than
zero; and fails otherwise.
Returns
A new Chk`1 of CheckKind that is Passed when conditions are met.
Parameters
Name | Type | Description |
---|---|---|
value | System.Decimal | The decimal value to check. |
name | System.String | Name/expression of the value field, argument or property to check. Added as Reason on failure. |
<a name='M-Semantica-Checks-Check-That-System-Boolean,System-String-'></a>
That(condition,expression) method
Summary
Makes a check that passes if condition
is true
; and fails otherwise.
Returns
A new Chk`1 of CheckKind that is Passed when conditions are met.
Parameters
Name | Type | Description |
---|---|---|
condition | System.Boolean | The bool result of a condition. |
expression | System.String | The expression to be added as reason on fail. |
<a name='M-Semantica-Checks-Check-WhenNotEmpty1-
0,Semantica-Checks-Chk{Semantica-Checks-CheckKind}-'></a>
WhenNotEmpty``1(value,check) method
Summary
Checks if value
is not empty and only then returns check
;
returns a passed test otherwise.
Returns
A new Chk`1 of CheckKind that is Passed when conditions are met.
Parameters
Name | Type | Description |
---|---|---|
value | ``0 | The ICanBeEmpty instance to check. |
check | Semantica.Checks.Chk{Semantica.Checks.CheckKind} | The check to return if value is not empty. |
Generic Types
Name | Description |
---|---|
T | The ICanBeEmpty type of instance to check. |
<a name='M-Semantica-Checks-Check-WhenNotEmpty1-System-Nullable{
0},Semantica-Checks-Chk{Semantica-Checks-CheckKind}-'></a>
WhenNotEmpty``1(value,check) method
Summary
Checks if value
is not null
or empty and only then returns check
;
returns a passed test otherwise.
Returns
A new Chk`1 of CheckKind that is Passed when conditions are met.
Parameters
Name | Type | Description |
---|---|---|
value | System.Nullable{``0} | The nullable ICanBeEmpty instance to check. |
check | Semantica.Checks.Chk{Semantica.Checks.CheckKind} | The check to return if value is not empty. |
Generic Types
Name | Description |
---|---|
T | The ICanBeEmpty type of instance to check. |
<a name='M-Semantica-Checks-Check-WhenNotNull1-System-Nullable{
0},Semantica-Checks-Chk{Semantica-Checks-CheckKind}-'></a>
WhenNotNull``1(value,check) method
Summary
Checks if value
is not null
and only then returns check
;
returns a passed test otherwise.
Returns
A new Chk`1 of CheckKind that is Passed when conditions are met.
Parameters
Name | Type | Description |
---|---|---|
value | System.Nullable{``0} | The Nullable`1 instance to check. |
check | Semantica.Checks.Chk{Semantica.Checks.CheckKind} | The check to return if value is not null. |
Generic Types
Name | Description |
---|---|
T | The Nullable`1 type of instance to check. |
<a name='M-Semantica-Checks-Check-WhenNotNull1-
0,Semantica-Checks-Chk{Semantica-Checks-CheckKind}-'></a>
WhenNotNull``1(value,check) method
Summary
Checks if value
is not null
and only then returns check
;
returns a passed test otherwise.
Returns
A new Chk`1 of CheckKind that is Passed when conditions are met.
Parameters
Name | Type | Description |
---|---|---|
value | ``0 | The instance to check. |
check | Semantica.Checks.Chk{Semantica.Checks.CheckKind} | The check to return if value is not null. |
Generic Types
Name | Description |
---|---|
T | The reference type of instance to check. |
<a name='T-Semantica-Checks-CheckExtensions'></a>
CheckExtensions type
Namespace
Semantica.Checks
Summary
Provides extension methods on Chk of CheckKind that can be used for guarding of all three types ContractException, GuardException and StateException.
<a name='M-Semantica-Checks-CheckExtensions-Contract-Semantica-Checks-Chk{Semantica-Checks-CheckKind}-'></a>
Contract(check) method
Summary
Throws if the check failed.
Parameters
Name | Type | Description |
---|---|---|
check | Semantica.Checks.Chk{Semantica.Checks.CheckKind} | Check result, optionally containing the kind of check and/or description. |
Exceptions
Name | Description |
---|---|
System.ArgumentException | Depending on the kind of check, throws one of the contract-subtypes when it's failed. |
<a name='M-Semantica-Checks-CheckExtensions-Contract-Semantica-Checks-Chk{Semantica-Checks-CheckKind},System-String-'></a>
Contract(check,description) method
Summary
Throws if the check failed.
Parameters
Name | Type | Description |
---|---|---|
check | Semantica.Checks.Chk{Semantica.Checks.CheckKind} | Check result, optionally containing the kind of check. |
description | System.String | Description added to the thrown exception. |
Exceptions
Name | Description |
---|---|
System.ArgumentException | Depending on the kind of check, throws one of the contract-subtypes when it's failed. |
<a name='M-Semantica-Checks-CheckExtensions-Guard-Semantica-Checks-Chk{Semantica-Checks-CheckKind}-'></a>
Guard(check) method
Summary
Throws if the check failed.
Parameters
Name | Type | Description |
---|---|---|
check | Semantica.Checks.Chk{Semantica.Checks.CheckKind} | Check result, optionally containing the kind of check and/or description. |
Exceptions
Name | Description |
---|---|
System.ArgumentException | Depending on the kind of check, throws one of the guard-subtypes when it's failed. |
<a name='M-Semantica-Checks-CheckExtensions-Guard-Semantica-Checks-Chk{Semantica-Checks-CheckKind},System-String-'></a>
Guard(check,description) method
Summary
Throws if the check failed.
Parameters
Name | Type | Description |
---|---|---|
check | Semantica.Checks.Chk{Semantica.Checks.CheckKind} | Check result, optionally containing the kind of check. |
description | System.String | Description added to the thrown exception. |
Exceptions
Name | Description |
---|---|
System.ArgumentException | Depending on the kind of check, throws one of the guard-subtypes when it's failed. |
<a name='M-Semantica-Checks-CheckExtensions-Out-Semantica-Checks-Chk{Semantica-Checks-CheckKind},Semantica-Checks-Chk{Semantica-Checks-CheckKind}@-'></a>
Out(check,chk) method
Summary
Assigns the input check
to the out parameter chk
, and also returns it.
Returns
The input.
Parameters
Name | Type | Description |
---|---|---|
check | Semantica.Checks.Chk{Semantica.Checks.CheckKind} | Input Chk`1 of CheckKind. |
chk | Semantica.Checks.Chk{Semantica.Checks.CheckKind}@ | Out parameter that will contain a copy of check . |
Remarks
This method can be used to assign the result of a check to a variable an in-line, making it more compact to use it in an if and it's then-statement.
<a name='M-Semantica-Checks-CheckExtensions-State-Semantica-Checks-Chk{Semantica-Checks-CheckKind}-'></a>
State(check) method
Summary
Throws if the check failed.
Parameters
Name | Type | Description |
---|---|---|
check | Semantica.Checks.Chk{Semantica.Checks.CheckKind} | Check result, optionally containing the kind of check and/or description. |
Exceptions
Name | Description |
---|---|
Semantica.Checks.Exceptions.StateException | Throws when check failed. |
<a name='M-Semantica-Checks-CheckExtensions-State-Semantica-Checks-Chk{Semantica-Checks-CheckKind},System-String-'></a>
State(check,description) method
Summary
Throws if the check failed.
Parameters
Name | Type | Description |
---|---|---|
check | Semantica.Checks.Chk{Semantica.Checks.CheckKind} | Check result, optionally containing the kind of check. |
description | System.String | Description added to the thrown exception. |
Exceptions
Name | Description |
---|---|
Semantica.Checks.Exceptions.StateException | Throws when check failed. |
<a name='T-Semantica-Checks-Chk'></a>
Chk type
Namespace
Semantica.Checks
Summary
Represents the result of a (bool
) check, with an optional Reason.
Remarks
Instances of Chk can be used just as booleans. Short-circuiting is supported for operators &&
and ||
. The Reason is always associated with a certain outcome (Passed or
Failed). When two instances are combined with an operator, only the reasons that are associated with the
outcome will be present in the result. Multiple applicable reasons are concatenated. Chk is
IDeterminable. An undetermined instance has the meaning of only being a reason associated to a specific
outcome, and it's value will never influence a binary operator's outcome.
<a name='P-Semantica-Checks-Chk-Fail'></a>
Fail property
Summary
A Failed instance.
<a name='P-Semantica-Checks-Chk-IsDetermined'></a>
IsDetermined property
Summary
true
for an actual check outcome. false
if the instance is only a reason associated
to a specific outcome. The value will never influence a binary operator's outcome.
<a name='P-Semantica-Checks-Chk-Pass'></a>
Pass property
Summary
A Passed instance.
<a name='M-Semantica-Checks-Chk-Fails-System-String-'></a>
Fails(failReason) method
Summary
Makes an instance with a new value for Reason, but only if the check already Failed.
Returns
A new instance of Chk containing failReason
if Failed, otherwise
Reason is retained.
Parameters
Name | Type | Description |
---|---|---|
failReason | System.String | The new value of Reason if Failed |
<a name='M-Semantica-Checks-Chk-Fails1-
0-'></a>
Fails``1(payload) method
Summary
Makes an instance with a new value for Payload, but only if the check already Failed.
Returns
A new instance of Chk`1 containing payload
if Failed, otherwise the
Payload is default
.
Parameters
Name | Type | Description |
---|---|---|
payload | ``0 | The value of Payload if Failed. |
Generic Types
Name | Description |
---|---|
TPayload | The type of the payload. |
<a name='M-Semantica-Checks-Chk-Fails1-System-String,
0-'></a>
Fails``1(failReason,payload) method
Summary
Makes an instance with new values for Payload and Reason, but only if the check already Failed.
Returns
A new instance of Chk`1 containing failReason
and payload
if
Failed, otherwise the Payload is default
, and
Reason is retained.
Parameters
Name | Type | Description |
---|---|---|
failReason | System.String | The new value of Reason if Failed. |
payload | ``0 | The value of Payload if Failed. |
Generic Types
Name | Description |
---|---|
TPayload | The type of the payload. |
<a name='M-Semantica-Checks-Chk-If-System-Boolean-'></a>
If(result) method
Summary
A new instance of Chk that Passed if result
is true
.
Returns
A new instance of Chk with no specified reason.
Parameters
Name | Type | Description |
---|---|---|
result | System.Boolean | bool result of some check. |
<a name='M-Semantica-Checks-Chk-If``1-System-Boolean-'></a>
If``1(result) method
Summary
A new instance of Chk`1 that Passed if result
is
true
.
Returns
A new instance of Chk`1 with no specified reason or payload.
Parameters
Name | Type | Description |
---|---|---|
result | System.Boolean | bool result of some check. |
<a name='M-Semantica-Checks-Chk-Passes-System-String-'></a>
Passes(passReason) method
Summary
Makes an instance with a new value for Reason, but only if the check already Passed.
Returns
A new instance of Chk`1 containing passReason
if Passed, otherwise
Reason is retained.
Parameters
Name | Type | Description |
---|---|---|
passReason | System.String | The new value of Reason if Passed. |
<a name='M-Semantica-Checks-Chk-Passes1-
0-'></a>
Passes``1(payload) method
Summary
Makes an instance with a value for Payload, but only if the check already Passed.
Returns
A new instance of Chk`1 containing payload
if Passed, otherwise the
Payload is default
.
Parameters
Name | Type | Description |
---|---|---|
payload | ``0 | The value of Payload if Passed. |
Generic Types
Name | Description |
---|---|
TPayload | The type of the payload. |
<a name='M-Semantica-Checks-Chk-Passes1-System-String,
0-'></a>
Passes``1(passReason,payload) method
Summary
Makes an instance with new values for Payload and Reason, but only if the check already Passed.
Returns
A new instance of Chk`1 containing passReason
and payload
if
Passed, otherwise the Payload is default
, and
Reason is retained.
Parameters
Name | Type | Description |
---|---|---|
passReason | System.String | The new value of Reason if Passed. |
payload | ``0 | The value of Payload if Passed. |
Generic Types
Name | Description |
---|---|
TPayload | The type of the payload. |
<a name='M-Semantica-Checks-Chk-SplitReasons'></a>
SplitReasons() method
Summary
If multiple reasons were previously combined, this method can split up these reasons.
Returns
A string[]
containing all the reasons associated with the outcome.
Parameters
This method has no parameters.
<a name='M-Semantica-Checks-Chk-ToString'></a>
ToString() method
Summary
Returns a descriptive version of the value of the instance.
Parameters
This method has no parameters.
<a name='M-Semantica-Checks-Chk-WithPld1-
0-'></a>
WithPld``1(payload) method
Summary
Makes an instance with new values for Payload, regardless if the check Failed or Passed.
Returns
A new instance of Chk`1 containing payload
.
Parameters
Name | Type | Description |
---|---|---|
payload | ``0 | The value of Payload. |
Generic Types
Name | Description |
---|---|
TPayload | The type of the payload. |
<a name='M-Semantica-Checks-Chk-WithRsn-System-String-'></a>
WithRsn(reason) method
Summary
Makes an instance with a new value for Reason, regardless if the check Failed or Passed.
Returns
A new instance of Chk containing reason
.
Parameters
Name | Type | Description |
---|---|---|
reason | System.String | The new value of Reason. |
<a name='M-Semantica-Checks-Chk-op_BitwiseAnd-Semantica-Checks-Chk,Semantica-Checks-Chk-'></a>
op_BitwiseAnd(left,right) method
Summary
And-operator for two Chk instances.
Returns
Passed if left
and right
both Passed, otherwise
Failed.
Parameters
Name | Type | Description |
---|---|---|
left | Semantica.Checks.Chk | The left operand. |
right | Semantica.Checks.Chk | The right operand. |
Exceptions
Name | Description |
---|---|
System.InvalidOperationException | When a fail reason Fail is used as right operand (IsDetermined is |
false ) |
Remarks
If the outcome is Failed, only reasons of Failed inputs are retained in the output. If the outcome is Passed, only reasons of Passed inputs are retained in the output.
<a name='M-Semantica-Checks-Chk-op_BitwiseOr-Semantica-Checks-Chk,Semantica-Checks-Chk-'></a>
op_BitwiseOr(left,right) method
Summary
Or-operator for two Chk instances.
Returns
Passed if left
or right
have Passed, otherwise
Failed.
Parameters
Name | Type | Description |
---|---|---|
left | Semantica.Checks.Chk | The left operand. |
right | Semantica.Checks.Chk | The right operand. |
Exceptions
Name | Description |
---|---|
System.InvalidOperationException | When a pass reason Pass is used as right operand (IsDetermined is |
false ). |
Remarks
If the outcome is Failed, only reasons of Failed inputs are retained in the output. If the outcome is Passed, only reasons of Passed inputs are retained in the output.
<a name='M-Semantica-Checks-Chk-op_False-Semantica-Checks-Chk-'></a>
op_False() method
Summary
Determines false-value of Chk instance.
Parameters
This method has no parameters.
Remarks
Required for short-circuiting.
<a name='M-Semantica-Checks-Chk-op_LogicalNot-Semantica-Checks-Chk-'></a>
op_LogicalNot() method
Summary
Not-operator.
Parameters
This method has no parameters.
Remarks
Required for short-circuiting.
<a name='M-Semantica-Checks-Chk-op_True-Semantica-Checks-Chk-'></a>
op_True() method
Summary
Determines true-value of Chk instance.
Parameters
This method has no parameters.
Remarks
Required for short-circuiting.
<a name='T-Semantica-Checks-Chk`1'></a>
Chk`1 type
Namespace
Semantica.Checks
Summary
Represents the result of a (bool
) check, with an optional Reason and Payload
of type T
.
Remarks
Instances of Chk can be used just as booleans. Short-circuiting is supported for operators &&
and ||
. The Reason and Payload are always associated with a certain outcome
(Passed or Failed). When two instances are combined with an operator, only the reasons that are
associated with the outcome will be present in the result. Multiple applicable reasons are concatenated.
Chk`1 is IDeterminable. An undetermined instance has the meaning of only
being a reason or payload associated to a specific outcome, and it's value will never influence a binary operator's outcome.
<a name='F-Semantica-Checks-Chk`1-Fail'></a>
Fail constants
Summary
A Failed instance.
<a name='F-Semantica-Checks-Chk`1-Pass'></a>
Pass constants
Summary
A Passed instance.
<a name='P-Semantica-Checks-Chk`1-Payload'></a>
Payload property
Summary
A payload of type T
associated with this check's Passed or Failed
value.
<a name='M-Semantica-Checks-Chk`1-Fails-System-String-'></a>
Fails(failReason) method
Summary
Makes an instance with a new value for Reason, but only if the check already Failed.
Returns
A new instance of Chk`1 containing failReason
if Failed, otherwise
Reason is retained.
Parameters
Name | Type | Description |
---|---|---|
failReason | System.String | The new value of Reason if Failed. |
<a name='M-Semantica-Checks-Chk1-Fails-
0-'></a>
Fails(payload) method
Summary
Makes an instance with a new value for Payload, but only if the check already Failed.
Returns
A new instance of Chk`1 containing payload
if Failed, otherwise the
Payload is default
.
Parameters
Name | Type | Description |
---|---|---|
payload | `0 | The value of Payload if Failed. |
<a name='M-Semantica-Checks-Chk1-Fails-System-String,
0-'></a>
Fails(failReason,payload) method
Summary
Makes an instance with new values for Payload and Reason, but only if the check already Failed.
Returns
A new instance of Chk`1 containing failReason
and payload
if
Failed, otherwise the Payload is default
, and Reason is
retained.
Parameters
Name | Type | Description |
---|---|---|
failReason | System.String | The new value of Reason if Failed. |
payload | `0 | The value of Payload if Failed. |
<a name='M-Semantica-Checks-Chk`1-Passes-System-String-'></a>
Passes(passReason) method
Summary
Makes an instance with a new value for Reason, but only if the check already Passed.
Returns
A new instance of Chk`1 containing passReason
if Passed, otherwise
Reason is retained.
Parameters
Name | Type | Description |
---|---|---|
passReason | System.String | The new value of Reason if Passed. |
<a name='M-Semantica-Checks-Chk1-Passes-
0-'></a>
Passes(payload) method
Summary
Makes an instance with a value for Payload, but only if the check already Passed.
Returns
A new instance of Chk`1 containing payload
if Passed, otherwise the
Payload is default
.
Parameters
Name | Type | Description |
---|---|---|
payload | `0 | The value of Payload if Passed. |
<a name='M-Semantica-Checks-Chk1-Passes-System-String,
0-'></a>
Passes(passReason,payload) method
Summary
Makes an instance with new values for Payload and Reason, but only if the check already Passed.
Returns
A new instance of Chk`1 containing passReason
and payload
if
Passed, otherwise the Payload is default
, and Reason is
retained.
Parameters
Name | Type | Description |
---|---|---|
passReason | System.String | The new value of Reason if Passed. |
payload | `0 | The value of Payload if Passed. |
<a name='M-Semantica-Checks-Chk`1-Simplify'></a>
Simplify() method
Summary
Drops the payload and returns the non-generic Chk.
Returns
Chk with only value and reason retained.
Parameters
This method has no parameters.
<a name='M-Semantica-Checks-Chk1-Simplify-
0@-'></a>
Simplify(payload) method
Summary
Drops the payload and returns the non-generic Chk, and Payload as out-parameter.
Returns
Chk with only value and reason retained.
Parameters
Name | Type | Description |
---|---|---|
payload | `0@ | Out-parameter contains the value of Payload. |
<a name='M-Semantica-Checks-Chk`1-SplitReasons'></a>
SplitReasons() method
Summary
If multiple reasons were previously combined, this method can split up these reasons.
Returns
A string[]
containing all the reasons associated with the outcome.
Parameters
This method has no parameters.
<a name='M-Semantica-Checks-Chk`1-ToString'></a>
ToString() method
Summary
Inherit from parent.
Parameters
This method has no parameters.
<a name='M-Semantica-Checks-Chk1-op_BitwiseAnd-Semantica-Checks-Chk{
0},Semantica-Checks-Chk{`0}-'></a>
op_BitwiseAnd(left,right) method
Summary
And-operator for two Chk`1 instances.
Returns
Passed if left
and right
both Passed, otherwise
Failed.
Parameters
Name | Type | Description |
---|---|---|
left | Semantica.Checks.Chk{`0} | The left operand. |
right | Semantica.Checks.Chk{`0} | The right operand. |
Exceptions
Name | Description |
---|---|
System.InvalidOperationException | When a fail reason or payloads Fail is used as right operand (IsDetermined |
is false ). |
Remarks
If the outcome is Failed, only reasons or payloads of Failed inputs are retained in the output. If the outcome is Passed, only reasons or payloads of Passed inputs are retained in the output.
<a name='M-Semantica-Checks-Chk1-op_BitwiseAnd-Semantica-Checks-Chk{
0},Semantica-Checks-Chk-'></a>
op_BitwiseAnd(left,right) method
Summary
And-operator for two Chk`1 instances.
Returns
Passed if left
and right
both Passed, otherwise
Failed.
Parameters
Name | Type | Description |
---|---|---|
left | Semantica.Checks.Chk{`0} | The left operand. |
right | Semantica.Checks.Chk | The right operand. |
Exceptions
Name | Description |
---|---|
System.InvalidOperationException | When a fail reason or payloads Fail is used as right operand (IsDetermined is |
false ). |
Remarks
If the outcome is Failed, only reasons or payloads of Failed inputs are retained in the
output. If the outcome is Passed, only reasons or payloads of Passed inputs are retained in
the output. Cannot be used as short-circuiting operator (&&
).
<a name='M-Semantica-Checks-Chk1-op_BitwiseOr-Semantica-Checks-Chk{
0},Semantica-Checks-Chk{`0}-'></a>
op_BitwiseOr(left,right) method
Summary
Or-operator for two Chk`1 instances.
Returns
Passed if left
or right
have Passed, otherwise
Failed
Parameters
Name | Type | Description |
---|---|---|
left | Semantica.Checks.Chk{`0} | The left operand. |
right | Semantica.Checks.Chk{`0} | The right operand. |
Exceptions
Name | Description |
---|---|
System.InvalidOperationException | When a pass reason or payloads Pass is used as right operand (IsDetermined |
is false ) |
Remarks
If the outcome is Failed, only reasons or payloads of Failed inputs are retained in the output. If the outcome is Passed, only reasons or payloads of Passed inputs are retained in the output.
<a name='M-Semantica-Checks-Chk1-op_BitwiseOr-Semantica-Checks-Chk{
0},Semantica-Checks-Chk-'></a>
op_BitwiseOr(left,right) method
Summary
Or-operator for two Chk`1 instances.
Returns
Passed if left
or right
have Passed, otherwise
Failed
Parameters
Name | Type | Description |
---|---|---|
left | Semantica.Checks.Chk{`0} | The left operand. |
right | Semantica.Checks.Chk | The right operand. |
Exceptions
Name | Description |
---|---|
System.InvalidOperationException | When a pass reason or payloads Pass is used as right operand (IsDetermined |
is false ) |
Remarks
If the outcome is Failed, only reasons or payloads of Failed inputs are retained in the
output. If the outcome is Passed, only reasons or payloads of Passed inputs are retained in
the output. Cannot be used as short-circuiing operator (||
).
<a name='M-Semantica-Checks-Chk1-op_False-Semantica-Checks-Chk{
0}-'></a>
op_False() method
Summary
Inherit from parent.
Parameters
This method has no parameters.
<a name='M-Semantica-Checks-Chk1-op_LogicalNot-Semantica-Checks-Chk{
0}-'></a>
op_LogicalNot() method
Summary
Inherit from parent.
Parameters
This method has no parameters.
<a name='M-Semantica-Checks-Chk1-op_True-Semantica-Checks-Chk{
0}-'></a>
op_True() method
Summary
Inherit from parent.
Parameters
This method has no parameters.
<a name='T-Semantica-Checks-Exceptions-ContractArgumentException'></a>
ContractArgumentException type
Namespace
Semantica.Checks.Exceptions
Summary
A subtype of ArgumentException, meant to be thrown when a contract guard on the arguments of a method fails.
<a name='M-Semantica-Checks-Exceptions-ContractArgumentException-#ctor-System-String-'></a>
#ctor() constructor
Summary
Inherit from parent.
Parameters
This constructor has no parameters.
<a name='M-Semantica-Checks-Exceptions-ContractArgumentException-#ctor-System-String,System-String-'></a>
#ctor() constructor
Summary
Inherit from parent.
Parameters
This constructor has no parameters.
<a name='T-Semantica-Checks-Exceptions-ContractArgumentNullException'></a>
ContractArgumentNullException type
Namespace
Semantica.Checks.Exceptions
Summary
A subtype of ArgumentNullException, meant to be thrown when a contract guard on the arguments of a method fails.
<a name='M-Semantica-Checks-Exceptions-ContractArgumentNullException-#ctor-System-String,System-String-'></a>
#ctor() constructor
Summary
Inherit from parent.
Parameters
This constructor has no parameters.
<a name='T-Semantica-Checks-Exceptions-ContractArgumentOutOfRangeException'></a>
ContractArgumentOutOfRangeException type
Namespace
Semantica.Checks.Exceptions
Summary
A subtype of ArgumentOutOfRangeException, meant to be thrown when a contract guard on the arguments of a method fails.
<a name='M-Semantica-Checks-Exceptions-ContractArgumentOutOfRangeException-#ctor-System-String,System-String-'></a>
#ctor() constructor
Summary
Inherit from parent.
Parameters
This constructor has no parameters.
<a name='T-Semantica-Checks-Exceptions-ContractException'></a>
ContractException type
Namespace
Semantica.Checks.Exceptions
Summary
Provides a number of static methods that create exception instances to be thrown when contract guards fail.
<a name='M-Semantica-Checks-Exceptions-ContractException-Make-System-String-'></a>
Make() method
Summary
Makes a new ContractArgumentException.
Parameters
This method has no parameters.
<a name='M-Semantica-Checks-Exceptions-ContractException-Make-System-String,System-String-'></a>
Make() method
Summary
Makes a new ContractArgumentException.
Parameters
This method has no parameters.
<a name='M-Semantica-Checks-Exceptions-ContractException-MakeEmpty-System-String-'></a>
MakeEmpty() method
Summary
Makes a new ContractArgumentNullException.
Parameters
This method has no parameters.
<a name='M-Semantica-Checks-Exceptions-ContractException-MakeEmpty-System-String,System-String-'></a>
MakeEmpty() method
Summary
Makes a new ContractArgumentNullException.
Parameters
This method has no parameters.
<a name='M-Semantica-Checks-Exceptions-ContractException-MakeFor-Semantica-Checks-Chk{Semantica-Checks-CheckKind}-'></a>
MakeFor() method
Summary
Makes a new ContractArgumentException, ContractArgumentNullException or
ContractArgumentOutOfRangeException, depending on the check
's CheckKind.
Parameters
This method has no parameters.
<a name='M-Semantica-Checks-Exceptions-ContractException-MakeFor-Semantica-Checks-Chk{Semantica-Checks-CheckKind},System-String-'></a>
MakeFor() method
Summary
Makes a new ContractArgumentException, ContractArgumentNullException or
ContractArgumentOutOfRangeException, depending on the check
's CheckKind.
Parameters
This method has no parameters.
<a name='M-Semantica-Checks-Exceptions-ContractException-MakeNonNegative-System-String-'></a>
MakeNonNegative() method
Summary
Makes a new ContractArgumentOutOfRangeException.
Parameters
This method has no parameters.
<a name='M-Semantica-Checks-Exceptions-ContractException-MakeNonNegative-System-String,System-String-'></a>
MakeNonNegative() method
Summary
Makes a new ContractArgumentOutOfRangeException.
Parameters
This method has no parameters.
<a name='M-Semantica-Checks-Exceptions-ContractException-MakeNonZero-System-String-'></a>
MakeNonZero() method
Summary
Makes a new ContractArgumentOutOfRangeException.
Parameters
This method has no parameters.
<a name='M-Semantica-Checks-Exceptions-ContractException-MakeNonZero-System-String,System-String-'></a>
MakeNonZero() method
Summary
Makes a new ContractArgumentOutOfRangeException.
Parameters
This method has no parameters.
<a name='M-Semantica-Checks-Exceptions-ContractException-MakeNull-System-String-'></a>
MakeNull() method
Summary
Makes a new ContractArgumentNullException.
Parameters
This method has no parameters.
<a name='M-Semantica-Checks-Exceptions-ContractException-MakeNull-System-String,System-String-'></a>
MakeNull() method
Summary
Makes a new ContractArgumentNullException.
Parameters
This method has no parameters.
<a name='M-Semantica-Checks-Exceptions-ContractException-MakeStrictPositive-System-String-'></a>
MakeStrictPositive() method
Summary
Makes a new ContractArgumentOutOfRangeException.
Parameters
This method has no parameters.
<a name='M-Semantica-Checks-Exceptions-ContractException-MakeStrictPositive-System-String,System-String-'></a>
MakeStrictPositive() method
Summary
Makes a new ContractArgumentOutOfRangeException.
Parameters
This method has no parameters.
<a name='M-Semantica-Checks-Exceptions-ContractException-MakeUndefined-System-String-'></a>
MakeUndefined() method
Summary
Makes a new ContractArgumentException.
Parameters
This method has no parameters.
<a name='M-Semantica-Checks-Exceptions-ContractException-MakeUndefined-System-String,System-String-'></a>
MakeUndefined() method
Summary
Makes a new ContractArgumentException.
Parameters
This method has no parameters.
<a name='T-Semantica-Checks-Guard'></a>
Guard type
Namespace
Semantica.Checks
Summary
Provides static functions for guarding of all three types ContractException, GuardException and StateException.
<a name='M-Semantica-Checks-Guard-Contract-System-Boolean,System-String-'></a>
Contract(check,expression) method
Summary
Throws if the argument check failed.
Parameters
Name | Type | Description |
---|---|---|
check | System.Boolean | bool result of a check. |
expression | System.String | The expression to be added as description of failure. |
Exceptions
Name | Description |
---|---|
Semantica.Checks.Exceptions.ContractArgumentException | Throws if check is false . |
<a name='M-Semantica-Checks-Guard-Contract-System-Boolean,System-String,System-String-'></a>
Contract(check,description,argumentName) method
Summary
Throws if the argument check failed.
Parameters
Name | Type | Description |
---|---|---|
check | System.Boolean | bool result of a check. |
description | System.String | Description added to the thrown exception. |
argumentName | System.String | Name of the argument that violates the code contract. |
Exceptions
Name | Description |
---|---|
Semantica.Checks.Exceptions.ContractArgumentException | Throws if check is false . |
<a name='M-Semantica-Checks-Guard-Contract-Semantica-Checks-Chk{Semantica-Checks-CheckKind}-'></a>
Contract(check) method
Summary
Throws if the argument check failed.
Parameters
Name | Type | Description |
---|---|---|
check | Semantica.Checks.Chk{Semantica.Checks.CheckKind} | Check result, optionally containing the kind of check and/or description. |
Exceptions
Name | Description |
---|---|
System.ArgumentException | Depending on the kind of check, throws one of the contract-subtypes when it's failed. |
<a name='M-Semantica-Checks-Guard-Contract-Semantica-Checks-Chk{Semantica-Checks-CheckKind},System-String-'></a>
Contract(check,description) method
Summary
Throws if the argument check failed.
Parameters
Name | Type | Description |
---|---|---|
check | Semantica.Checks.Chk{Semantica.Checks.CheckKind} | Check result, optionally containing the kind of check and/or description. |
description | System.String | Description added to the thrown exception. |
Exceptions
Name | Description |
---|---|
System.ArgumentException | Depending on the kind of check, throws one of the contract-subtypes when it's failed. |
<a name='M-Semantica-Checks-Guard-For-System-Boolean,System-String-'></a>
For(check,expression) method
Summary
Throws if the argument check failed.
Parameters
Name | Type | Description |
---|---|---|
check | System.Boolean | bool result of a check. |
expression | System.String | The expression to be added as description of failure. |
Exceptions
Name | Description |
---|---|
Semantica.Checks.Exceptions.GuardArgumentException | Throws if check is false . |
<a name='M-Semantica-Checks-Guard-For-System-Boolean,System-String,System-String-'></a>
For(check,description,argumentName) method
Summary
Throws if the argument check failed.
Parameters
Name | Type | Description |
---|---|---|
check | System.Boolean | bool result of a check. |
description | System.String | Description added to the thrown exception. |
argumentName | System.String | Name of the argument that violates the code contract. |
Exceptions
Name | Description |
---|---|
Semantica.Checks.Exceptions.GuardArgumentException | Throws if check is false . |
<a name='M-Semantica-Checks-Guard-For-Semantica-Checks-Chk{Semantica-Checks-CheckKind}-'></a>
For(check) method
Summary
Throws if the argument check failed.
Parameters
Name | Type | Description |
---|---|---|
check | Semantica.Checks.Chk{Semantica.Checks.CheckKind} | Check result, optionally containing the kind of check and/or description. |
Exceptions
Name | Description |
---|---|
System.ArgumentException | Depending on the kind of check, throws one of the guard-subtypes when it's failed. |
<a name='M-Semantica-Checks-Guard-For-Semantica-Checks-Chk{Semantica-Checks-CheckKind},System-String-'></a>
For(check,description) method
Summary
Throws if the argument check failed.
Parameters
Name | Type | Description |
---|---|---|
check | Semantica.Checks.Chk{Semantica.Checks.CheckKind} | Check result, optionally containing the kind of check and/or description. |
description | System.String | Description added to the thrown exception. |
Exceptions
Name | Description |
---|---|
System.ArgumentException | Depending on the kind of check, throws one of the guard-subtypes when it's failed. |
<a name='M-Semantica-Checks-Guard-For``1-System-Boolean-'></a>
For``1(check) method
Summary
Throws if the state check failed.
Parameters
Name | Type | Description |
---|---|---|
check | System.Boolean | bool result of a check. |
Exceptions
Name | Description |
---|---|
System.Exception | Throws if check is false . |
<a name='M-Semantica-Checks-Guard-Index-System-Int32,System-Int32-'></a>
Index(index,end) method
Summary
Throws if the index is not in range.
Parameters
Name | Type | Description |
---|---|---|
index | System.Int32 | Value of the index to check. |
end | System.Int32 | The exclusive end of the valid range. |
Exceptions
Name | Description |
---|---|
System.IndexOutOfRangeException | Throws when index is less than 0 , or greater than or equal to end . |
<a name='M-Semantica-Checks-Guard-Index-System-Int32,System-Int32,System-Int32-'></a>
Index(index,start,end) method
Summary
Throws if the index is not in range.
Parameters
Name | Type | Description |
---|---|---|
index | System.Int32 | Value of the index to check. |
start | System.Int32 | The inclusive start of the valid range. |
end | System.Int32 | The exclusive end of the valid range. |
Exceptions
Name | Description |
---|---|
System.IndexOutOfRangeException | Throws when index is less than start , or greater than or equal to |
end . |
<a name='M-Semantica-Checks-Guard-State-System-Boolean,System-String-'></a>
State(check,expression) method
Summary
Throws if the state check failed.
Parameters
Name | Type | Description |
---|---|---|
check | System.Boolean | bool result of a check. |
expression | System.String | The expression to be added as description of failure. |
Exceptions
Name | Description |
---|---|
Semantica.Checks.Exceptions.StateException | Throws if check is false . |
<a name='M-Semantica-Checks-Guard-State-System-Boolean,System-String,System-String-'></a>
State(check,description,fieldName) method
Summary
Throws if the state check failed.
Parameters
Name | Type | Description |
---|---|---|
check | System.Boolean | bool result of a check. |
description | System.String | Description added to the thrown exception. |
fieldName | System.String | Name of the field that indicates the unexpected state. |
Exceptions
Name | Description |
---|---|
Semantica.Checks.Exceptions.StateException | Throws if check is false . |
<a name='M-Semantica-Checks-Guard-State-Semantica-Checks-Chk{Semantica-Checks-CheckKind}-'></a>
State(check) method
Summary
Throws if the state check failed.
Parameters
Name | Type | Description |
---|---|---|
check | Semantica.Checks.Chk{Semantica.Checks.CheckKind} | Check result, optionally containing the kind of check and/or description. |
Exceptions
Name | Description |
---|---|
Semantica.Checks.Exceptions.StateException | Throws if check has failed. |
<a name='M-Semantica-Checks-Guard-State-Semantica-Checks-Chk{Semantica-Checks-CheckKind},System-String-'></a>
State(check,description) method
Summary
Throws if the state check failed.
Parameters
Name | Type | Description |
---|---|---|
check | Semantica.Checks.Chk{Semantica.Checks.CheckKind} | Check result, optionally containing the kind of check and/or description. |
description | System.String | Description added to the thrown exception. |
Exceptions
Name | Description |
---|---|
Semantica.Checks.Exceptions.StateException | Throws if check has failed. |
<a name='T-Semantica-Checks-Exceptions-GuardArgumentException'></a>
GuardArgumentException type
Namespace
Semantica.Checks.Exceptions
Summary
A subtype of ArgumentException, meant to be thrown when a guard on the arguments of a method fails.
<a name='M-Semantica-Checks-Exceptions-GuardArgumentException-#ctor-System-String-'></a>
#ctor() constructor
Summary
Inherit from parent.
Parameters
This constructor has no parameters.
<a name='M-Semantica-Checks-Exceptions-GuardArgumentException-#ctor-System-String,System-String-'></a>
#ctor() constructor
Summary
Inherit from parent.
Parameters
This constructor has no parameters.
<a name='T-Semantica-Checks-Exceptions-GuardArgumentNullException'></a>
GuardArgumentNullException type
Namespace
Semantica.Checks.Exceptions
Summary
A subtype of ArgumentNullException, meant to be thrown when a guard on the arguments of a method fails.
<a name='M-Semantica-Checks-Exceptions-GuardArgumentNullException-#ctor-System-String,System-String-'></a>
#ctor() constructor
Summary
Inherit from parent.
Parameters
This constructor has no parameters.
<a name='T-Semantica-Checks-Exceptions-GuardArgumentOutOfRangeException'></a>
GuardArgumentOutOfRangeException type
Namespace
Semantica.Checks.Exceptions
Summary
A subtype of ArgumentOutOfRangeException, meant to be thrown when a guard on the arguments of a method fails.
<a name='M-Semantica-Checks-Exceptions-GuardArgumentOutOfRangeException-#ctor-System-String,System-String-'></a>
#ctor() constructor
Summary
Inherit from parent.
Parameters
This constructor has no parameters.
<a name='T-Semantica-Checks-Exceptions-GuardException'></a>
GuardException type
Namespace
Semantica.Checks.Exceptions
Summary
Provides a number of static methods that create exception instances to be thrown when argument guards fail.
<a name='M-Semantica-Checks-Exceptions-GuardException-Make-System-String-'></a>
Make() method
Summary
Makes a new GuardArgumentException.
Parameters
This method has no parameters.
<a name='M-Semantica-Checks-Exceptions-GuardException-Make-System-String,System-String-'></a>
Make() method
Summary
Makes a new GuardArgumentException.
Parameters
This method has no parameters.
<a name='M-Semantica-Checks-Exceptions-GuardException-MakeEmpty-System-String-'></a>
MakeEmpty() method
Summary
Makes a new GuardArgumentNullException.
Parameters
This method has no parameters.
<a name='M-Semantica-Checks-Exceptions-GuardException-MakeEmpty-System-String,System-String-'></a>
MakeEmpty() method
Summary
Makes a new GuardArgumentNullException.
Parameters
This method has no parameters.
<a name='M-Semantica-Checks-Exceptions-GuardException-MakeFor-Semantica-Checks-Chk{Semantica-Checks-CheckKind}-'></a>
MakeFor() method
Summary
Makes a new GuardArgumentException, GuardArgumentNullException or
GuardArgumentOutOfRangeException, depending on the check
's CheckKind.
Parameters
This method has no parameters.
<a name='M-Semantica-Checks-Exceptions-GuardException-MakeFor-Semantica-Checks-Chk{Semantica-Checks-CheckKind},System-String-'></a>
MakeFor() method
Summary
Makes a new GuardArgumentException, GuardArgumentNullException or
GuardArgumentOutOfRangeException, depending on the check
's CheckKind.
Parameters
This method has no parameters.
<a name='M-Semantica-Checks-Exceptions-GuardException-MakeIndex-System-Int32,System-Int32-'></a>
MakeIndex() method
Summary
Makes a new IndexOutOfRangeException
Parameters
This method has no parameters.
<a name='M-Semantica-Checks-Exceptions-GuardException-MakeMaxValue-System-String-'></a>
MakeMaxValue() method
Summary
Makes a new GuardArgumentOutOfRangeException.
Parameters
This method has no parameters.
<a name='M-Semantica-Checks-Exceptions-GuardException-MakeMaxValue-System-String,System-String-'></a>
MakeMaxValue() method
Summary
Makes a new GuardArgumentOutOfRangeException.
Parameters
This method has no parameters.
<a name='M-Semantica-Checks-Exceptions-GuardException-MakeNonNegative-System-String-'></a>
MakeNonNegative() method
Summary
Makes a new GuardArgumentOutOfRangeException.
Parameters
This method has no parameters.
<a name='M-Semantica-Checks-Exceptions-GuardException-MakeNonNegative-System-String,System-String-'></a>
MakeNonNegative() method
Summary
Makes a new GuardArgumentOutOfRangeException.
Parameters
This method has no parameters.
<a name='M-Semantica-Checks-Exceptions-GuardException-MakeNonZero-System-String-'></a>
MakeNonZero() method
Summary
Makes a new GuardArgumentOutOfRangeException.
Parameters
This method has no parameters.
<a name='M-Semantica-Checks-Exceptions-GuardException-MakeNonZero-System-String,System-String-'></a>
MakeNonZero() method
Summary
Makes a new GuardArgumentOutOfRangeException.
Parameters
This method has no parameters.
<a name='M-Semantica-Checks-Exceptions-GuardException-MakeNull-System-String-'></a>
MakeNull() method
Summary
Makes a new GuardArgumentNullException.
Parameters
This method has no parameters.
<a name='M-Semantica-Checks-Exceptions-GuardException-MakeNull-System-String,System-String-'></a>
MakeNull() method
Summary
Makes a new GuardArgumentNullException.
Parameters
This method has no parameters.
<a name='M-Semantica-Checks-Exceptions-GuardException-MakeStrictPositive-System-String-'></a>
MakeStrictPositive() method
Summary
Makes a new GuardArgumentOutOfRangeException.
Parameters
This method has no parameters.
<a name='M-Semantica-Checks-Exceptions-GuardException-MakeStrictPositive-System-String,System-String-'></a>
MakeStrictPositive() method
Summary
Makes a new GuardArgumentOutOfRangeException.
Parameters
This method has no parameters.
<a name='M-Semantica-Checks-Exceptions-GuardException-MakeUndefined-System-String-'></a>
MakeUndefined() method
Summary
Makes a new GuardArgumentException.
Parameters
This method has no parameters.
<a name='M-Semantica-Checks-Exceptions-GuardException-MakeUndefined-System-String,System-String-'></a>
MakeUndefined() method
Summary
Makes a new GuardArgumentException.
Parameters
This method has no parameters.
<a name='T-Semantica-Checks-IChk'></a>
IChk type
Namespace
Semantica.Checks
Summary
Represents the result of a (bool
) check, with an optional Reason.
<a name='P-Semantica-Checks-IChk-Failed'></a>
Failed property
Summary
Not Passed. Always use HasFailed for control flow.
<a name='P-Semantica-Checks-IChk-Passed'></a>
Passed property
Summary
Indicates if the Chk has passed or failed, or if the Reason is associated with passing or failing. Always use HasPassed for control flow.
<a name='P-Semantica-Checks-IChk-Reason'></a>
Reason property
Summary
The string
reason associated with this check's Passed or Failed value.
<a name='M-Semantica-Checks-IChk-HasFailed'></a>
HasFailed() method
Summary
Has the check Failed or is it not IsDetermined. Use to check the outcome in control flow for safety.
Returns
true
if either Passed or IsDetermined are false
.
Parameters
This method has no parameters.
<a name='M-Semantica-Checks-IChk-HasPassed'></a>
HasPassed() method
Summary
Has the check Passed and IsDetermined. Use to check the outcome in control flow for safety.
Returns
true
only if Passed and IsDetermined are both true
.
Parameters
This method has no parameters.
<a name='T-Semantica-Checks-Chk-Pld'></a>
Pld type
Namespace
Semantica.Checks.Chk
Summary
Provides static functionality to create Chk instances with undetermined outcome. These instances are only a Payload and possibly a Reason associated with a specific eventual outcome.
<a name='M-Semantica-Checks-Chk-Pld-ForFail1-
0-'></a>
ForFail``1(payload) method
Summary
An undetermined value with a fail reason that can be ||
-attached to a determined check, so this expression
will only be evaluated if needed.
Returns
Undetermined Failed Chk Payload.
Parameters
Name | Type | Description |
---|---|---|
payload | ``0 | The payload for failing. |
<a name='M-Semantica-Checks-Chk-Pld-ForFail1-
0,System-String-'></a>
ForFail``1(payload,reason) method
Summary
An undetermined value with a payload and a fail reason that can be ||
-attached to a determined check, so
this expression will only be evaluated if needed.
Returns
Undetermined Failed Chk Payload.
Parameters
Name | Type | Description |
---|---|---|
payload | ``0 | The payload for failing. |
reason | System.String | The reason for failing. |
<a name='M-Semantica-Checks-Chk-Pld-ForPass1-
0-'></a>
ForPass``1(payload) method
Summary
An undetermined value with a pass reason that can be &&
-attached to a determined check, so this
expression will only be evaluated if needed.
Returns
Undetermined Passed Chk Payload.
Parameters
Name | Type | Description |
---|---|---|
payload | ``0 | The payload for passing. |
<a name='M-Semantica-Checks-Chk-Pld-ForPass1-
0,System-String-'></a>
ForPass``1(payload,reason) method
Summary
An undetermined value with a payload and a pass reason that can be &&
-attached to a determined check,
so this expression will only be evaluated if needed
Returns
Undetermined Passed Chk Payload.
Parameters
Name | Type | Description |
---|---|---|
payload | ``0 | The payload for passing. |
reason | System.String | The reason for passing. |
<a name='T-Semantica-Checks-Chk-Rsn'></a>
Rsn type
Namespace
Semantica.Checks.Chk
Summary
Provides static functionality to create Chk instances with undetermined outcome. These instances are only a Reason associated with a specific eventual outcome.
<a name='T-Semantica-Checks-Chk`1-Rsn'></a>
Rsn type
Namespace
Semantica.Checks.Chk`1
Summary
Inherit from parent.
<a name='P-Semantica-Checks-Chk-Rsn-Fail'></a>
Fail property
Summary
An undetermined Failed instance.
<a name='P-Semantica-Checks-Chk-Rsn-Pass'></a>
Pass property
Summary
An undetermined Passed instance.
<a name='P-Semantica-Checks-Chk`1-Rsn-Fail'></a>
Fail property
Summary
An undetermined Failed instance.
<a name='P-Semantica-Checks-Chk`1-Rsn-Pass'></a>
Pass property
Summary
An undetermined Passed instance.
<a name='M-Semantica-Checks-Chk-Rsn-ForFail-System-String-'></a>
ForFail(reason) method
Summary
An undetermined value with a failure reason that can be ||
-attached to a determined check, so this
expression will only be evaluated if needed, and short-circuited if not.
Returns
Undetermined Failed instance.
Parameters
Name | Type | Description |
---|---|---|
reason | System.String | The Reason for failure. |
<a name='M-Semantica-Checks-Chk-Rsn-ForFail``1-System-String-'></a>
ForFail``1(reason) method
Summary
An undetermined value with a failure reason that can be ||
-attached to a determined check, so this
expression will only be evaluated if needed, and short-circuited if not.
Returns
Undetermined Failed instance.
Parameters
Name | Type | Description |
---|---|---|
reason | System.String | The Reason for failure |
<a name='M-Semantica-Checks-Chk-Rsn-ForPass-System-String-'></a>
ForPass(reason) method
Summary
An undetermined value with a pass reason that can be &&
-attached to a determined check, so this
expression will only be evaluated if needed, and short-circuited if not.
Returns
Undetermined Passed instance.
Parameters
Name | Type | Description |
---|---|---|
reason | System.String | The Reason for passing. |
<a name='M-Semantica-Checks-Chk-Rsn-ForPass``1-System-String-'></a>
ForPass``1(reason) method
Summary
An undetermined value with a pass reason that can be &&
-attached to a determined check, so this
expression will only be evaluated if needed, and short-circuited if not.
Returns
Undetermined Passed instance.
Parameters
Name | Type | Description |
---|---|---|
reason | System.String | The Reason for passing. |
<a name='T-Semantica-Checks-Exceptions-StateException'></a>
StateException type
Namespace
Semantica.Checks.Exceptions
Summary
A subtype of InvalidOperationException, meant to be thrown when a guard on the state when calling an instance method fails.
Also provides a number of static methods that create exception instances.
<a name='M-Semantica-Checks-Exceptions-StateException-#ctor-System-String-'></a>
#ctor() constructor
Summary
Inherit from parent.
Parameters
This constructor has no parameters.
<a name='M-Semantica-Checks-Exceptions-StateException-Make-System-String-'></a>
Make() method
Summary
Makes a new StateException.
Parameters
This method has no parameters.
<a name='M-Semantica-Checks-Exceptions-StateException-Make-System-String,System-String-'></a>
Make() method
Summary
Makes a new StateException.
Parameters
This method has no parameters.
<a name='M-Semantica-Checks-Exceptions-StateException-MakeEmpty-System-String,System-String-'></a>
MakeEmpty() method
Summary
Makes a new StateException.
Parameters
This method has no parameters.
<a name='M-Semantica-Checks-Exceptions-StateException-MakeFor-Semantica-Checks-Chk{Semantica-Checks-CheckKind}-'></a>
MakeFor() method
Summary
Makes a new StateException.
Parameters
This method has no parameters.
<a name='M-Semantica-Checks-Exceptions-StateException-MakeFor-Semantica-Checks-Chk{Semantica-Checks-CheckKind},System-String-'></a>
MakeFor() method
Summary
Makes a new StateException.
Parameters
This method has no parameters.
<a name='M-Semantica-Checks-Exceptions-StateException-MakeNonNegative-System-String,System-String-'></a>
MakeNonNegative() method
Summary
Makes a new StateException.
Parameters
This method has no parameters.
<a name='M-Semantica-Checks-Exceptions-StateException-MakeNonZero-System-String,System-String-'></a>
MakeNonZero() method
Summary
Makes a new StateException.
Parameters
This method has no parameters.
<a name='M-Semantica-Checks-Exceptions-StateException-MakeNull-System-String,System-String-'></a>
MakeNull() method
Summary
Makes a new StateException.
Parameters
This method has no parameters.
<a name='M-Semantica-Checks-Exceptions-StateException-MakeStrictPositive-System-String,System-String-'></a>
MakeStrictPositive() method
Summary
Makes a new StateException.
Parameters
This method has no parameters.
<a name='M-Semantica-Checks-Exceptions-StateException-MakeUndefined-System-String,System-String-'></a>
MakeUndefined() method
Summary
Makes a new StateException.
Parameters
This method has no parameters.
<a name='T-Semantica-Checks-Throw'></a>
Throw type
Namespace
Semantica.Checks
Summary
Static helper methods that always throw an exception
<a name='M-Semantica-Checks-Throw-Contract-System-String-'></a>
Contract(expression) method
Parameters
Name | Type | Description |
---|---|---|
expression | System.String | Expression that violated the code contract. |
Exceptions
Name | Description |
---|---|
Semantica.Checks.Exceptions.ContractArgumentException | Throws always. |
<a name='M-Semantica-Checks-Throw-Contract-System-String,System-String-'></a>
Contract(description,argumentName) method
Parameters
Name | Type | Description |
---|---|---|
description | System.String | Description added to the thrown exception. |
argumentName | System.String | Name of the argument that violates the code contract. |
Exceptions
Name | Description |
---|---|
Semantica.Checks.Exceptions.ContractArgumentException | Throws always. |
<a name='M-Semantica-Checks-Throw-ContractFor-Semantica-Checks-Chk{Semantica-Checks-CheckKind}-'></a>
ContractFor(check) method
Parameters
Name | Type | Description |
---|---|---|
check | Semantica.Checks.Chk{Semantica.Checks.CheckKind} | Check result, optionally containing the kind of check and/or description. |
Exceptions
Name | Description |
---|---|
System.ArgumentException | Depending on the kind of check, throws one of the contract-subtypes. |
<a name='M-Semantica-Checks-Throw-ContractFor-Semantica-Checks-Chk{Semantica-Checks-CheckKind},System-String-'></a>
ContractFor(description,check) method
Parameters
Name | Type | Description |
---|---|---|
description | Semantica.Checks.Chk{Semantica.Checks.CheckKind} | Description added to the thrown exception. |
check | System.String | Check result, optionally containing the kind of check. |
Exceptions
Name | Description |
---|---|
System.ArgumentException | Depending on the kind of check, throws one of the contract-subtypes. |
<a name='M-Semantica-Checks-Throw-Guard-System-String-'></a>
Guard(expression) method
Parameters
Name | Type | Description |
---|---|---|
expression | System.String | Expression that violated the code contract. |
Exceptions
Name | Description |
---|---|
Semantica.Checks.Exceptions.GuardArgumentException | Throws always. |
<a name='M-Semantica-Checks-Throw-Guard-System-String,System-String-'></a>
Guard(description,argumentName) method
Parameters
Name | Type | Description |
---|---|---|
description | System.String | Description added to the thrown exception. |
argumentName | System.String | Name of the argument that violates the code contract. |
Exceptions
Name | Description |
---|---|
Semantica.Checks.Exceptions.GuardArgumentException | Throws always. |
<a name='M-Semantica-Checks-Throw-GuardFor-Semantica-Checks-Chk{Semantica-Checks-CheckKind}-'></a>
GuardFor(check) method
Parameters
Name | Type | Description |
---|---|---|
check | Semantica.Checks.Chk{Semantica.Checks.CheckKind} | Check result, optionally containing the kind of check and/or description. |
Exceptions
Name | Description |
---|---|
System.ArgumentException | Depending on the kind of check, throws one of the guard-subtypes. |
<a name='M-Semantica-Checks-Throw-GuardFor-Semantica-Checks-Chk{Semantica-Checks-CheckKind},System-String-'></a>
GuardFor(description,check) method
Parameters
Name | Type | Description |
---|---|---|
description | Semantica.Checks.Chk{Semantica.Checks.CheckKind} | Description added to the thrown exception. |
check | System.String | Check result, optionally containing the kind of check. |
Exceptions
Name | Description |
---|---|
System.ArgumentException | Depending on the kind of check, throws one of the guard-subtypes. |
<a name='M-Semantica-Checks-Throw-State-System-String-'></a>
State(expression) method
Parameters
Name | Type | Description |
---|---|---|
expression | System.String | Expression that failed the state guard. |
Exceptions
Name | Description |
---|---|
Semantica.Checks.Exceptions.StateException | Throws always. |
<a name='M-Semantica-Checks-Throw-State-System-String,System-String-'></a>
State(description,fieldName) method
Parameters
Name | Type | Description |
---|---|---|
description | System.String | Description added to the thrown exception. |
fieldName | System.String | Name of the field that indicates the unexpected state. |
Exceptions
Name | Description |
---|---|
Semantica.Checks.Exceptions.StateException | Throws always. |
<a name='M-Semantica-Checks-Throw-StateFor-Semantica-Checks-Chk{Semantica-Checks-CheckKind},System-String-'></a>
StateFor(check,fieldName) method
Parameters
Name | Type | Description |
---|---|---|
check | Semantica.Checks.Chk{Semantica.Checks.CheckKind} | Check result, optionally containing the kind of check and/or description. |
fieldName | System.String | Name of the field that indicates the unexpected state. |
Exceptions
Name | Description |
---|---|
Semantica.Checks.Exceptions.StateException | Throws always. |
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net6.0
- Semantica.Lib.Patterns (>= 8.1.0)
-
net7.0
- Semantica.Lib.Patterns (>= 8.1.0)
-
net8.0
- Semantica.Lib.Patterns (>= 8.1.0)
NuGet packages (14)
Showing the top 5 NuGet packages that depend on Semantica.Lib.Checks:
Package | Downloads |
---|---|
Semantica.Lib.Linq
A library that provides extensions that expand on the standard System.Linq functionality on IEnumerable<T> and IQueryable<T>, as well as provide optimized extensions/overloads for the IReadOnlyList<T>, IReadOnlyCollection<T> and IReadOnlyDictionary<TKey,T> interfaces. |
|
Semantica.Lib.Order
A library that provides types and extensions that represent and help with ordering of collections. |
|
Semantica.Lib.Collections
A library that provides a number of collection types that can help with either more readable/elegant syntax, or improved performance compared to native collection types. |
|
Semantica.Lib.Patterns.CanSerialize
Provides typeconverters and (System.Text.Json) jsonconverters for types that implement ICanSerialize (one-way) or ICanSerialize<T> (two-way). |
|
Semantica.Lib.Package.Core
Combines all primary Semantica.Lib.Core packages in a single package. Check the ReadMe of each package for further elaboration on package contents. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
8.1.0 | 177 | 5/30/2025 |
8.0.7 | 280 | 9/6/2024 |
8.0.6-beta | 850 | 7/10/2024 |
8.0.5-beta | 906 | 7/4/2024 |
8.0.4-beta | 235 | 7/2/2024 |
8.0.3-beta | 231 | 6/14/2024 |
8.0.2-beta | 308 | 6/4/2024 |
8.0.1-beta | 236 | 6/4/2024 |
8.0.0-beta | 246 | 6/4/2024 |
6.6.1-beta | 349 | 4/5/2024 |
6.6.0-beta | 387 | 3/5/2024 |
6.5.5-alpha2 | 135 | 3/4/2024 |
6.5.5-alpha | 133 | 3/4/2024 |
6.5.4-beta | 161 | 2/29/2024 |
6.5.3-beta | 895 | 10/5/2023 |
6.5.2-beta | 172 | 10/5/2023 |
6.5.1-beta | 227 | 9/29/2023 |
6.5.0-beta | 183 | 9/22/2023 |
6.4.0-beta | 487 | 7/11/2023 |
6.3.0-beta | 193 | 6/15/2023 |
6.2.5-beta | 277 | 3/14/2023 |
6.2.4-beta | 637 | 10/12/2022 |
6.2.3-beta | 332 | 9/1/2022 |
6.2.1-beta | 237 | 8/25/2022 |