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 |
|---|---|
| HasNullForgivingOperator | Gets a value indicating whether the null-forgiving operator ( |
| IsArray | |
| IsInitialized | Gets a value indicating whether the Value has been specified (including when it is set to |
| IsNullOrDefault | Gets a value indicating whether the value is |
| RawValue | Gets the raw value of the TypedConstant. If IsArray is |
| 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. |
| Values |
Methods
| Name | Description |
|---|---|
| Create(IField) | Creates a TypedConstant that references a constant field. When rendered to code,
this produces a reference to the field (e.g., |
| Create(object?) | |
| Create(object?, IType?) | |
| Create(object?, Type?) | |
| CreateUnchecked(object?, IType) | |
| Default(IType, bool) | Creates a TypedConstant representing the default value for the specified type.
When rendered to code, this produces |
| Default(Type, bool) | Creates a TypedConstant representing the default value for the specified type.
When rendered to code, this produces |
| Equals(TypedConstant) | |
| Equals(object?) | |
| ForCompilation(ICompilation) | |
| GetHashCode() | |
| ToString() | |
| TryConvertFromExpression(IExpression, out TypedConstant?) | |
| TryConvertFromExpression(string, out TypedConstant?) |
Operators
| Name | Description |
|---|---|
| operator ==(TypedConstant, TypedConstant) | |
| operator !=(TypedConstant, TypedConstant) |