Show / Hide Table of Contents

Class Diagnostic

Helper class for performing scaffolding operations.
Use Diagnose(DiagnoseMethod) to perform scaffolding operations.

Inheritance
object
Diagnostic
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
Namespace: SuperOffice.Diagnostics
Assembly: SoCore.dll
Syntax
public class Diagnostic
Examples

The following example illustrates the verifications of two strings being equal.
If they are different, an exception is thrown.

Diagnostic.Diagnose(delegate(Diagnostic s)
{
    string tmp = "hello";
    if (tmp != "world")
        s.Error("The strings are not equal");
});

Methods

Assert(bool, string)

Report error message if the provided condition is not true.

Declaration
public void Assert(bool condition, string errorMessage)
Parameters
Type Name Description
bool condition

condition to verify.

string errorMessage

Error message if the condition is false.

AssertEmpty<T>(T, string)

Report error message if the value is not empty. This means null for object types and '0' for value types.

Declaration
public void AssertEmpty<T>(T value, string errorMessage)
Parameters
Type Name Description
T value

Value to check if it is empty.

string errorMessage

Error message to pass on if the value is empty.

Type Parameters
Name Description
T

The type of value to check.

AssertEqual(object, object, string)

report error message if the actual value is different from the expected value.

Declaration
public void AssertEqual(object expected, object actual, string errorMessage)
Parameters
Type Name Description
object expected

The value expected.

object actual

The actual value recieved.

string errorMessage

Error message to pass on if the values are not equal.

AssertEqual<T>(T, T, string)

Report error message if the actual value is not equal to the expected value using the IEquatable interface.

Declaration
public void AssertEqual<T>(T expected, T actual, string errorMessage) where T : IEquatable<T>
Parameters
Type Name Description
T expected

The expected value

T actual

The actual value.

string errorMessage

Error message reported if the values are not equal.

Type Parameters
Name Description
T

Type of object to compare.

AssertNotEmpty<T>(T, string)

Report error message if the value is empty. This means null for object types and '0' for value types.

Declaration
public void AssertNotEmpty<T>(T value, string errorMessage)
Parameters
Type Name Description
T value

Value to check if it is not empty.

string errorMessage

Error message to pass on if the value is not empty.

Type Parameters
Name Description
T

The type of value to check.

AssertNotEqual(object, object, string)

Report error message if the actual value is equal to the expected value using the IEquatable interface.

Declaration
public void AssertNotEqual(object expected, object actual, string errorMessage)
Parameters
Type Name Description
object expected

The expected value

object actual

The actual value.

string errorMessage

Error message reported if the values are equal.

AssertNotEqual<T>(T, T, string)

Report error message if the actual value is equal to the expected value using the IEquatable interface.

Declaration
public void AssertNotEqual<T>(T expected, T actual, string errorMessage) where T : IEquatable<T>
Parameters
Type Name Description
T expected

The expected value

T actual

The actual value.

string errorMessage

Error message reported if the values are equal.

Type Parameters
Name Description
T

Type of object to compare.

AssertNotNull(object, string)

Report error message if the value is null.

Declaration
public void AssertNotNull(object value, string errorMessage)
Parameters
Type Name Description
object value

Value to check if is null.

string errorMessage

Error message to pass on if the value is null

AssertNotSame<T>(T, T, string)

Report error message if the actual value is the same as the expected value using the IComparable interface.

Declaration
public void AssertNotSame<T>(T expected, T actual, string errorMessage) where T : IComparable
Parameters
Type Name Description
T expected

The expected value

T actual

The actual value.

string errorMessage

Error message reported if the values are equal.

Type Parameters
Name Description
T

Type of object to compare.

AssertNull(object, string)

Report error message if the value is not null.

Declaration
public void AssertNull(object value, string errorMessage)
Parameters
Type Name Description
object value

Value to check if is null.

string errorMessage

Error message to pass on if the value is not null

AssertSame<T>(T, T, string)

Report errormessage if the actual value is not the same as the expected value using the IComparable interface.

Declaration
public void AssertSame<T>(T expected, T actual, string errorMessage) where T : IComparable
Parameters
Type Name Description
T expected

The expected value

T actual

The actual value.

string errorMessage

Error message reported if the values are not equal.

Type Parameters
Name Description
T

Type of object to compare.

Diagnose(DiagnoseMethod)

Carry out the diagnostic method in debug code and in "EnableScaffolding" is turned on in the configuration file.

Declaration
public static void Diagnose(DiagnoseMethod diagnoseMethod)
Parameters
Type Name Description
DiagnoseMethod diagnoseMethod

Method to execute.

Examples

The following example illustrates the verifications of two strings being equal.
If they are different, an exception is thrown.

Diagnostic.Diagnose(delegate(Diagnostic s)
{
    string tmp = "hello";
    if (tmp != "world")
        s.Error("The strings are not equal");
});
Exceptions
Type Condition
DiagnoseException

Thrown if errors occurs in hte executed code.

DiagnoseAsync(DiagnoseMethodAsync, CancellationToken)

Carry out the diagnostic method in debug code and in "EnableScaffolding" is turned on in the configuration file.

Declaration
[CreateSyncVersion(OmitNullableDirective = true)]
public static Task DiagnoseAsync(DiagnoseMethodAsync diagnoseMethod, CancellationToken cancellationToken = default)
Parameters
Type Name Description
DiagnoseMethodAsync diagnoseMethod

Method to execute.

CancellationToken cancellationToken
Returns
Type Description
Task
Examples

The following example illustrates the verifications of two strings being equal.
If they are different, an exception is thrown.

Diagnostic.Diagnose(delegate(Diagnostic s)
{
    string tmp = "hello";
    if (tmp != "world")
        s.Error("The strings are not equal");
});
Exceptions
Type Condition
DiagnoseException

Thrown if errors occurs in hte executed code.

Error(string)

Throw an exception with the message.

Declaration
public void Error(string message)
Parameters
Type Name Description
string message

Error message to report

Information(string)

Report some information.

Declaration
public void Information(string message)
Parameters
Type Name Description
string message

ToString()

Obtain information about the scaffolding results.

Declaration
public override string ToString()
Returns
Type Description
string

String containing the scaffolding results.

Overrides
object.ToString()

Warning(string)

Report a warning

Declaration
public void Warning(string message)
Parameters
Type Name Description
string message

warning message

Extension Methods

EnumUtil.MapEnums<From, To>(From)
Converters.MapEnums<From, To>(From)
© SuperOffice. All rights reserved.
SuperOffice |  Community |  Release Notes |  Privacy |  Site feedback |  Search Docs |  About Docs |  Contribute |  Back to top