Skip to content

Interface IPropertyDescriptor

Definition

Namespace: StardewUI.Framework.Descriptors
Assembly: StardewUI.dll

Describes a single property on a bindable object (i.e. a view).

public interface IPropertyDescriptor : 
    StardewUI.Framework.Descriptors.IMemberDescriptor

Implements
IMemberDescriptor

Members

Properties

Name Description
CanRead Whether or not the property is readable, i.e. has a public getter.
CanWrite Whether or not the property is writable, i.e. has a public setter.
IsAutoProperty Whether or not the property is likely auto-implemented.
IsField Whether or not the underlying member is a field, rather than a real property.
ValueType The property's value type.

Methods

Name Description
GetUntypedValue(Object) Reads the current property value as an Object.

Details

Properties

CanRead

Whether or not the property is readable, i.e. has a public getter.

bool CanRead { get; }
Property Value

Boolean


CanWrite

Whether or not the property is writable, i.e. has a public setter.

bool CanWrite { get; }
Property Value

Boolean


IsAutoProperty

Whether or not the property is likely auto-implemented.

bool IsAutoProperty { get; }
Property Value

Boolean

Remarks

Auto-property detection is heuristic, relying on the method's IL instructions and the name of its backing field. This can often be interpreted as a signal that the property won't receive property-change notifications, since to do so (whether explicitly or via some weaver/source generator) requires an implementation that is different from the auto-generated getter and setter.

Caveats: This only works as a negative signal (a value of false does not prove that the property will receive notifications, even if the declaring type implements INotifyPropertyChanged), and is somewhat fuzzy even as a negative signal; it is theoretically possible for a source generator or IL weaver to leave behind all the markers of an auto property and still emit notifications, although no known libraries actually do so.


IsField

Whether or not the underlying member is a field, rather than a real property.

bool IsField { get; }
Property Value

Boolean

Remarks

For binding convenience, fields and properties are both called "properties" for descriptors, as the external access pattern is the same; however, mutable fields can never reliably emit property-change notifications regardless of whether the declaring type implements INotifyPropertyChanged, so this is usually used to emit some warning.


ValueType

The property's value type.

System.Type ValueType { get; }
Property Value

Type


Methods

GetUntypedValue(Object)

Reads the current property value as an Object.

System.Object GetUntypedValue(System.Object source);
Parameters

source   Object
An instance of the property's DeclaringType.

Returns

Object

The current property value.

Remarks

This method may be less efficient than GetValue(Object) and should only be used in situations where the actual property type cannot be known ahead of time and therefore the cost of dynamically creating generic types/methods would be higher.