Table of Contents

Class EzrWrapper<TMemberInfo>

Namespace
EzrSquared.Runtime.Types.Wrappers
Assembly
ezrSquared-lib.dll

Parent class for all automatic wrappers which wrap existing C# objects and members so that they can be used in ezr².

public abstract class EzrWrapper<TMemberInfo> : EzrObject, IEzrObject where TMemberInfo : MemberInfo

Type Parameters

TMemberInfo

The System.Reflection.MemberInfo type for the C# member being wrapped.

Inheritance
object
EzrWrapper<TMemberInfo>
Implements
Derived
Inherited Members

Constructors

EzrWrapper(TMemberInfo, object?, Context, Position, Position)

Creates a new EzrWrapper<TMemberInfo>.

public EzrWrapper(TMemberInfo wrappedMember, object? instance, Context parentContext, Position startPosition, Position endPosition)

Parameters

wrappedMember TMemberInfo

Reflection info on the wrapped C# member.

instance object

The object which contains the wrapped member, null if static.

parentContext Context

The context in which this object was created.

startPosition Position

The starting position of the object.

endPosition Position

The ending position of the object.

Fields

AutoWrapperAttribute

The WrapMemberAttribute of the wrapped object, if defined.

public readonly WrapMemberAttribute? AutoWrapperAttribute

Field Value

WrapMemberAttribute

Instance

The object which contains the wrapped member, null if static.

public readonly object? Instance

Field Value

object

SharpMember

Reflection info for the current object being wrapped.

public readonly TMemberInfo SharpMember

Field Value

TMemberInfo

SharpMemberName

The name of the wrapped member in snake_case.

public readonly string SharpMemberName

Field Value

string

s_alphaNumericUnderscoreOnlyFilterRegex

Regex for matching non-alphanumeric + underscore characters.

private static readonly Regex s_alphaNumericUnderscoreOnlyFilterRegex

Field Value

Regex

s_caseConverterRegex

Regex for converting PascalCase/camelCase to snake_case.

private static readonly Regex s_caseConverterRegex

Field Value

Regex

Remarks

Regex explanation:

  1. (?<!^)(?=[A-Z][a-z]) - Add underscore before capital letter followed by a lowercase letter, except at the start.
  2. (?<=[a-z0-9])(?=[A-Z]) - Add underscore when transitioning from lowercase or number to uppercase.
  3. (?<=[A-Z])(?=[A-Z][a-z]) - Add underscore between uppercase sequences followed by lowercase (e.g., "TCProtocol").

s_taskFromResultMethod

Reflection info for System.Threading.Tasks.Task.FromResult<TResult>(TResult)/

private static readonly MethodInfo s_taskFromResultMethod

Field Value

MethodInfo

Properties

Tag

The tag of the type of this object, similar to C# namespace naming conventions.

public override string Tag { get; protected internal set; }

Property Value

string

TypeName

The name of the type of this object, in plain text, all lowercase. Spaces are allowed.

public override string TypeName { get; protected internal set; }

Property Value

string

Methods

CSharpToEzrObject(object?, Type, RuntimeResult)

Converts a C# object to an ezr² object.

protected internal void CSharpToEzrObject(object? value, Type valueType, RuntimeResult result)

Parameters

value object

The C# object to convert.

valueType Type

The type of value.

result RuntimeResult

Runtime result for carrying the result and any errors.

ComparisonEqual(IEzrObject, RuntimeResult)

Compares the object to another, checks equality.

public override void ComparisonEqual(IEzrObject other, RuntimeResult result)

Parameters

other IEzrObject

The other object in the operation.

result RuntimeResult

Runtime result for carrying the result and any errors.

ComparisonNotEqual(IEzrObject, RuntimeResult)

Compares the object to another, checks unequality.

public override void ComparisonNotEqual(IEzrObject other, RuntimeResult result)

Parameters

other IEzrObject

The other object in the operation.

result RuntimeResult

Runtime result for carrying the result and any errors.

ComputeHashCode(RuntimeResult)

Evaluates the current object as its hash.

public override int ComputeHashCode(RuntimeResult result)

Parameters

result RuntimeResult

Runtime result for carrying any errors.

Returns

int

The evaluated value.

EvaluateBoolean(RuntimeResult)

Evaluates the current object as a boolean value.

public override bool EvaluateBoolean(RuntimeResult result)

Parameters

result RuntimeResult

Runtime result for carrying any errors.

Returns

bool

The evaluated value.

EzrObjectToCSharp(IEzrObject, Type, RuntimeResult)

Converts an ezr² object to a C# object.

protected internal object? EzrObjectToCSharp(IEzrObject value, Type targetType, RuntimeResult result)

Parameters

value IEzrObject

The IEzrObject to convert.

targetType Type

The type to convert it to.

result RuntimeResult

Runtime result for carrying any errors.

Returns

object

The converted object.

GetAlphaNumericUnderscoreOnlyFilterRegex()

[GeneratedRegex("[^a-zA-Z0-9_]", RegexOptions.Compiled|RegexOptions.CultureInvariant)]
private static Regex GetAlphaNumericUnderscoreOnlyFilterRegex()

Returns

Regex

Remarks

Pattern:

[^a-zA-Z0-9_]

Options:
RegexOptions.Compiled | RegexOptions.CultureInvariant

Explanation:
○ Match a character in the set [^0-9A-Z_a-z].

GetCaseConverterRegex()

[GeneratedRegex("(?<!^)(?=[A-Z][a-z])|(?<=[a-z0-9])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])", RegexOptions.Compiled|RegexOptions.CultureInvariant)]
private static Regex GetCaseConverterRegex()

Returns

Regex

Remarks

Pattern:

(?<!^)(?=[A-Z][a-z])|(?<=[a-z0-9])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])

Options:
RegexOptions.Compiled | RegexOptions.CultureInvariant

Explanation:
○ Match with 3 alternative expressions, atomically.
○ Match a sequence of expressions.
○ Zero-width negative lookbehind.
○ Match if at the beginning of the string.
○ Zero-width positive lookahead.
○ Match a character in the set [A-Z].
○ Match a character in the set [a-z].
○ Match a sequence of expressions.
○ Zero-width positive lookbehind.
○ Match a character in the set [0-9a-z] right-to-left.
○ Zero-width positive lookahead.
○ Match a character in the set [A-Z].
○ Match a sequence of expressions.
○ Zero-width positive lookbehind.
○ Match a character in the set [A-Z] right-to-left.
○ Zero-width positive lookahead.
○ Match a character in the set [A-Z].
○ Match a character in the set [a-z].

HandleCSharpArrayToEzrObject(Array, Type, RuntimeResult)

Converts a C# array to an ezr² array-like object.

protected internal void HandleCSharpArrayToEzrObject(Array value, Type valueType, RuntimeResult result)

Parameters

value Array

The value to convert.

valueType Type

The type to convert from.

result RuntimeResult

Runtime result for carrying the result and any errors.

HandleEzrArrayLikeToCSharp(IEzrObject, Type, RuntimeResult)

Converts an ezr² array-like object to a C# array.

protected internal object? HandleEzrArrayLikeToCSharp(IEzrObject value, Type targetType, RuntimeResult result)

Parameters

value IEzrObject

The value to convert.

targetType Type

The type to convert to.

result RuntimeResult

Runtime result for carrying any errors.

Returns

object

PascalToSnakeCase(string?)

Converts a string from PascalCase to snake_case.

protected internal static string? PascalToSnakeCase(string? text)

Parameters

text string

The text to convert in PascalCase.

Returns

string

The converted text in snake_case.

StrictEquals(IEzrObject, RuntimeResult)

Strictly compares the current object to another, taking into account inheritance.

public override bool StrictEquals(IEzrObject other, RuntimeResult result)

Parameters

other IEzrObject

The other object in the operation.

result RuntimeResult

Runtime result for carrying any errors.

Returns

bool