Table of Contents

Class CSharpUnionDataModel

Namespace
PolyType.Roslyn
Assembly
PolyType.Roslyn.dll

Describes a type following the C# union member pattern.

public sealed class CSharpUnionDataModel : TypeDataModel
Inheritance
CSharpUnionDataModel
Inherited Members

Properties

Kind

Determines the type of TypeDataModel being used.

public override TypeDataKind Kind { get; }

Property Value

TypeDataKind

UnionCases

Gets the creation members and their case types in declaration-context compiler enumeration order.

public required ImmutableArray<UnionCaseDataModel> UnionCases { get; init; }

Property Value

ImmutableArray<UnionCaseDataModel>

Remarks

Distinct creation members are retained even when generic substitution gives them the same case type. Inherited factory hiding is resolved in the original union declaration's generic context. This order is independent of the order needed to match overlapping case types.

UnionMemberProvider

Gets the nested IUnionMembers interface, or null when constructors define the cases.

public INamedTypeSymbol? UnionMemberProvider { get; init; }

Property Value

INamedTypeSymbol

ValueProperty

Gets the instance property used to access the union payload, either on the union type or its member provider interface.

public required IPropertySymbol ValueProperty { get; init; }

Property Value

IPropertySymbol