Table of Contents

Class ObjectTypeGraphBuilder

Namespace
MuLang.Core.Types
Assembly
MuLang.Core.dll

Builds immutable object-type graphs, including recursive graphs.

public sealed class ObjectTypeGraphBuilder
Inheritance
ObjectTypeGraphBuilder
Inherited Members

Constructors

ObjectTypeGraphBuilder()

public ObjectTypeGraphBuilder()

Methods

AddProperty(ObjectTypeGraphReference, string, ObjectTypeGraphReference, bool, bool)

Adds a property to a declared object type.

public ObjectTypeGraphBuilder AddProperty(ObjectTypeGraphReference objectType, string name, ObjectTypeGraphReference propertyType, bool isOptional = false, bool isReadOnly = false)

Parameters

objectType ObjectTypeGraphReference

The declared object type.

name string

The property name.

propertyType ObjectTypeGraphReference

The property type expression.

isOptional bool

Whether the property may be omitted.

isReadOnly bool

Whether the property value and presence are read-only.

Returns

ObjectTypeGraphBuilder

The same ObjectTypeGraphBuilder instance, for chaining.

Exceptions

ArgumentException

Thrown when a reference is invalid or the property is duplicated.

ArgumentNullException

Thrown when an argument is null.

InvalidOperationException

Thrown after the builder has been finalized.

Array(ObjectTypeGraphReference)

Creates a mutable-array type expression.

public ObjectTypeGraphReference Array(ObjectTypeGraphReference elementType)

Parameters

elementType ObjectTypeGraphReference

The element type expression.

Returns

ObjectTypeGraphReference

An opaque reference to the mutable-array type.

Exceptions

ArgumentException

Thrown when the reference belongs to another builder.

ArgumentNullException

Thrown when elementType is null.

InvalidOperationException

Thrown after the builder has been finalized.

Build()

Finalizes the complete type graph.

public IReadOnlyDictionary<ObjectTypeGraphReference, TypeSymbol> Build()

Returns

IReadOnlyDictionary<ObjectTypeGraphReference, TypeSymbol>

An immutable mapping from graph references to completed types.

Exceptions

ArgumentException

Thrown when a type expression is invalid.

InvalidOperationException

Thrown when the builder was already finalized.

DeclareAnonymous(string, bool)

Declares an anonymous object type.

public ObjectTypeGraphReference DeclareAnonymous(string key, bool isOpen)

Parameters

key string

The builder-local key.

isOpen bool

Whether undeclared properties are permitted.

Returns

ObjectTypeGraphReference

An opaque reference to the declared type.

Exceptions

ArgumentException

Thrown when key is invalid or duplicated.

InvalidOperationException

Thrown after the builder has been finalized.

DeclareNamed(string, string, string, bool)

Declares a named object type.

public ObjectTypeGraphReference DeclareNamed(string key, string id, string name, bool isOpen)

Parameters

key string

The builder-local key.

id string

The provider type identifier.

name string

The language-facing name.

isOpen bool

Whether undeclared properties are permitted.

Returns

ObjectTypeGraphReference

An opaque reference to the declared type.

Exceptions

ArgumentException

Thrown when a value is invalid or duplicated.

InvalidOperationException

Thrown after the builder has been finalized.

From(TypeSymbol)

Creates a reference to an existing type.

public ObjectTypeGraphReference From(TypeSymbol type)

Parameters

type TypeSymbol

The existing type.

Returns

ObjectTypeGraphReference

An opaque reference to the type.

Exceptions

ArgumentNullException

Thrown when type is null.

InvalidOperationException

Thrown after the builder has been finalized.

Nullable(ObjectTypeGraphReference)

Creates a nullable type expression.

public ObjectTypeGraphReference Nullable(ObjectTypeGraphReference underlyingType)

Parameters

underlyingType ObjectTypeGraphReference

The underlying type expression.

Returns

ObjectTypeGraphReference

An opaque reference to the nullable type.

Exceptions

ArgumentException

Thrown when the reference belongs to another builder.

ArgumentNullException

Thrown when underlyingType is null.

InvalidOperationException

Thrown after the builder has been finalized.

ReadOnlyArray(ObjectTypeGraphReference)

Creates a read-only-array type expression.

public ObjectTypeGraphReference ReadOnlyArray(ObjectTypeGraphReference elementType)

Parameters

elementType ObjectTypeGraphReference

The element type expression.

Returns

ObjectTypeGraphReference

An opaque reference to the read-only-array type.

Exceptions

ArgumentException

Thrown when the reference belongs to another builder.

ArgumentNullException

Thrown when elementType is null.

InvalidOperationException

Thrown after the builder has been finalized.