Class SourceGenObjectTypeShape<TObject>
- Namespace
- PolyType.SourceGenModel
- Assembly
- PolyType.dll
Source generator model for object type shapes.
public sealed class SourceGenObjectTypeShape<TObject> : SourceGenTypeShape<TObject>, IObjectTypeShape<TObject>, ITypeShape<TObject>, IObjectTypeShape, ITypeShape
Type Parameters
TObject
The type whose shape is described.
- Inheritance
-
SourceGenTypeShape<TObject>SourceGenObjectTypeShape<TObject>
- Implements
-
IObjectTypeShape<TObject>ITypeShape<TObject>
- Inherited Members
- Extension Methods
Properties
AssociatedTypeShapes
Gets the shape of an associated type, by its name.
public Func<string, ITypeShape?>? AssociatedTypeShapes { get; init; }
Property Value
CreateConstructorFunc
Gets the factory method for creating constructor shapes.
public Func<IConstructorShape>? CreateConstructorFunc { get; init; }
Property Value
CreatePropertiesFunc
Gets the factory method for creating property shapes.
public Func<IEnumerable<IPropertyShape>>? CreatePropertiesFunc { get; init; }
Property Value
IsRecordType
Gets a value indicating whether the type represents a record.
public required bool IsRecordType { get; init; }
Property Value
IsTupleType
Gets a value indicating whether the type represents a tuple.
public required bool IsTupleType { get; init; }
Property Value
Kind
Gets the TypeShapeKind that the current shape supports.
public override TypeShapeKind Kind { get; }
Property Value
Methods
Accept(TypeShapeVisitor, object?)
Accepts an TypeShapeVisitor for strongly-typed traversal.
public override object? Accept(TypeShapeVisitor visitor, object? state = null)
Parameters
visitor
TypeShapeVisitorThe visitor to accept.
state
objectThe state parameter to pass to the underlying visitor.
Returns
GetAssociatedTypeShape(Type)
Gets the shape for a type associated to this property's declared Type, as captured in AssociatedTypes or AssociatedTypes.
public override ITypeShape? GetAssociatedTypeShape(Type associatedType)
Parameters
associatedType
TypeThe associated type (which must be one found in the AssociatedTypes property). If the associated type is a generic type definition, the type arguments used on this shape's Type will be used to close the associated generic type.
Returns
- ITypeShape
The shape for the associated type, or null if no shape for the associated type is available.
Remarks
ReflectionTypeShapeProvider can produce the shape on demand without any AssociatedTypes, while SourceGenTypeShapeProvider is expected to only produce the shape that was explicitly requested via attribute.
Exceptions
- InvalidOperationException
Thrown when this method is called on an instance that does not represent a generic type.