Open sandboxFocus

Struct TypedConstant

Represents a typed value that can be defined, defined to null, or undefined. Used to represent default values, for instance DefaultValue, or attribute arguments.

Namespace: Metalama.Framework.Code
Assembly: Metalama.Framework.dll
Syntax
[CompileTime]
public readonly struct TypedConstant : IExpression, IHasType, IEquatable<TypedConstant>

Properties

Name Description
IsArray
IsInitialized

Gets a value indicating whether the Value has been specified (including when it is set to null).

IsNullOrDefault

Gets a value indicating whether the value is null or default. Not to be confused with IsInitialized.

RawValue

Gets the raw value of the TypedConstant. If IsArray is true, this property returns an ImmutableArray<TypedConstant>.

Type

Gets the type of the value. This is important if the type is an enum, because in this case, if the enum type is not compile-time, Value is set to the underlying integer value.

Value

Gets the Value for non-array types. For array types, get an array of a primitive type (e.g. int[]) instead of an array of TypedConstant.

Values

Methods

Name Description
Create(object?)
Create(object?, IType?)
Create(object?, Type?)
CreateUnchecked(object?, IType)
Default(IType)
Default(Type)
Equals(TypedConstant)
Equals(object?)
ForCompilation(ICompilation)
GetHashCode()
ToString()

Operators

Name Description
operator ==(TypedConstant, TypedConstant)
operator !=(TypedConstant, TypedConstant)

Extension Methods