Table of Contents

Class SourceGenEnumerableTypeShape<TEnumerable, TElement>

Namespace
PolyType.SourceGenModel
Assembly
PolyType.dll

Source generator model for enumerable shapes.

public sealed class SourceGenEnumerableTypeShape<TEnumerable, TElement> : SourceGenTypeShape<TEnumerable>, IEnumerableTypeShape<TEnumerable, TElement>, ITypeShape<TEnumerable>, IEnumerableTypeShape, ITypeShape

Type Parameters

TEnumerable

The type of the enumerable collection.

TElement

The element type of the collection.

Inheritance
SourceGenTypeShape<TEnumerable>
SourceGenEnumerableTypeShape<TEnumerable, TElement>
Implements
IEnumerableTypeShape<TEnumerable, TElement>
ITypeShape<TEnumerable>
Inherited Members

Properties

AppenderFunc

Gets the function that appends an element to the collection.

public EnumerableAppender<TEnumerable, TElement>? AppenderFunc { get; init; }

Property Value

EnumerableAppender<TEnumerable, TElement>

ConstructionStrategy

Gets the construction strategy for the collection.

public required CollectionConstructionStrategy ConstructionStrategy { get; init; }

Property Value

CollectionConstructionStrategy

DefaultConstructorFunc

Gets the function that constructs an empty instance of the collection.

public MutableCollectionConstructor<TElement, TEnumerable>? DefaultConstructorFunc { get; init; }

Property Value

MutableCollectionConstructor<TElement, TEnumerable>

ElementType

Gets the shape of the underlying element type.

public required ITypeShape<TElement> ElementType { get; init; }

Property Value

ITypeShape<TElement>

Remarks

For non-generic IEnumerable this returns the shape for object.

GetEnumerableFunc

Gets the function that retrieves an enumerable from an instance of the collection.

public required Func<TEnumerable, IEnumerable<TElement>> GetEnumerableFunc { get; init; }

Property Value

Func<TEnumerable, IEnumerable<TElement>>

IsAsyncEnumerable

Indicates whether the underlying type is an IAsyncEnumerable.

public required bool IsAsyncEnumerable { get; init; }

Property Value

bool

Remarks

Calling GetGetEnumerable() on async enumerable instances will result in an exception being thrown to prevent accidental sync-over-async. Users should manually cast instances to IAsyncEnumerable and enumerate elements asynchronously.

IsSetType

Indicates whether the enumerable is one of the recognized set collection types.

public required bool IsSetType { get; init; }

Property Value

bool

Kind

Gets determines the TypeShapeKind that the current shape supports.

public override TypeShapeKind Kind { get; }

Property Value

TypeShapeKind

ParameterizedConstructorFunc

Gets the function that constructs a collection from a span.

public ParameterizedCollectionConstructor<TElement, TElement, TEnumerable>? ParameterizedConstructorFunc { get; init; }

Property Value

ParameterizedCollectionConstructor<TElement, TElement, TEnumerable>

Rank

Gets the dimensionality of the collection type.

public required int Rank { get; init; }

Property Value

int

IEnumerable<T>, most collections and most arrays have a rank of 1.

Remarks

Test for arrays by using IsArray on Type.

SupportedComparer

Gets the kind of custom comparer (if any) that this collection may be initialized with.

public required CollectionComparerOptions SupportedComparer { get; init; }

Property Value

CollectionComparerOptions

Methods

Accept(TypeShapeVisitor, object?)

Accepts an TypeShapeVisitor for strongly-typed traversal.

public override object? Accept(TypeShapeVisitor visitor, object? state = null)

Parameters

visitor TypeShapeVisitor

The visitor to accept.

state object

The state parameter to pass to the underlying visitor.

Returns

object

The object result returned by the visitor.