Table of Contents

Class SourceGenUnionCaseShape<TUnionCase, TUnion>

Namespace
PolyType.SourceGenModel
Assembly
PolyType.dll

Source generator model for union case shapes.

public sealed class SourceGenUnionCaseShape<TUnionCase, TUnion> : IUnionCaseShape<TUnionCase, TUnion>, IUnionCaseShape

Type Parameters

TUnionCase

The type of the current union case.

TUnion

The type of the base union type.

Inheritance
SourceGenUnionCaseShape<TUnionCase, TUnion>
Implements
IUnionCaseShape<TUnionCase, TUnion>
Inherited Members

Properties

Index

Gets the unique index corresponding to the current union case.

public required int Index { get; init; }

Property Value

int

Remarks

Corresponds to the index of this instance in the parent UnionCases list. While similar to Tag, the value of the index is distinct and is not part of the data contract.

IsTagSpecified

Gets a value indicating whether Tag has been explicitly specified or inferred in a less stable way.

public required bool IsTagSpecified { get; init; }

Property Value

bool

Marshaler

Gets a bidirectional mapper between TUnionCase and TUnion.

public required IMarshaler<TUnionCase, TUnion> Marshaler { get; init; }

Property Value

IMarshaler<TUnionCase, TUnion>

Remarks

Converting from TUnionCase to TUnion is a reversible operation, however mapping from TUnion to TUnionCase can fail if the value is not a member of the current union case.

Name

Gets the unique string identifier for the current union case.

public required string Name { get; init; }

Property Value

string

Remarks

The value is usually the name of the derived type but can be overridden via the Name property.

Tag

Gets the unique integer identifier for the current union case.

public required int Tag { get; init; }

Property Value

int

Remarks

The value typically corresponds to the order of DerivedTypeShapeAttribute declarations but can be overridden via the Tag property.

Type

Gets the underlying type shape of the union case.

public required ITypeShape<TUnionCase> Type { get; init; }

Property Value

ITypeShape<TUnionCase>