Table of Contents

Interface IPropertyShape

Namespace
PolyType.Abstractions
Assembly
PolyType.dll

Provides a strongly typed shape model for a given .NET instance property or field.

public interface IPropertyShape

Properties

AttributeProvider

Gets the provider used for property-level attribute resolution.

IGenericCustomAttributeProvider AttributeProvider { get; }

Property Value

IGenericCustomAttributeProvider

Remarks

Provides fast attribute resolution when using the source generator, otherwise this is wrapping standard reflection-based attribute resolution.

When using the source generator, the following categories of attributes are excluded to reduce trimmed application size:

  • System.Runtime.CompilerServices.* - Compiler-generated attributes
  • System.Runtime.InteropServices.* - COM interop attributes
  • System.Diagnostics.* - Diagnostic attributes
  • System.Reflection.DefaultMemberAttribute - Default member metadata
  • System.CLSCompliantAttribute - CLS compliance marker
  • Microsoft.FSharp.Core.* - F# compiler generated attributes
  • Attributes marked with unmet ConditionalAttribute annotations
Users requiring complete attribute resolution can use the MemberInfo property to access standard reflection-based attribute APIs, though this will be slower.

DeclaringType

Gets the shape of the declaring type.

IObjectTypeShape DeclaringType { get; }

Property Value

IObjectTypeShape

HasGetter

Gets a value indicating whether the property has an accessible getter.

bool HasGetter { get; }

Property Value

bool

HasSetter

Gets a value indicating whether the property has an accessible setter.

bool HasSetter { get; }

Property Value

bool

IsField

Gets a value indicating whether the shape represents a .NET field.

bool IsField { get; }

Property Value

bool

IsGetterNonNullable

Gets a value indicating whether the getter returns non-null values.

bool IsGetterNonNullable { get; }

Property Value

bool

Remarks

Returns true if the property type is a non-nullable struct, a non-nullable reference type or the property has been annotated with the NotNullAttribute.

Conversely, it could return false if a non-nullable property has been annotated with MaybeNullAttribute.

IsGetterPublic

Gets a value indicating whether the property getter is declared public.

bool IsGetterPublic { get; }

Property Value

bool

IsSetterNonNullable

Gets a value indicating whether the setter requires non-null values.

bool IsSetterNonNullable { get; }

Property Value

bool

Remarks

Returns true if the property type is a non-nullable struct, a non-nullable reference type or the property has been annotated with the DisallowNullAttribute.

Conversely, it could return false if a non-nullable property has been annotated with AllowNullAttribute.

IsSetterPublic

Gets a value indicating whether the property setter is declared public.

bool IsSetterPublic { get; }

Property Value

bool

MemberInfo

Gets the underlying MemberInfo representing the property or field, if available.

MemberInfo? MemberInfo { get; }

Property Value

MemberInfo

Remarks

Typically returns either FieldInfo or PropertyInfo depending on the underlying member.

Name

Gets the name of the property.

string Name { get; }

Property Value

string

Position

Gets the 0-indexed position of the current property.

int Position { get; }

Property Value

int

PropertyType

Gets the shape of the property type.

ITypeShape PropertyType { get; }

Property Value

ITypeShape

Methods

Accept(TypeShapeVisitor, object?)

Accepts an TypeShapeVisitor for strongly typed traversal.

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.