Class PropertyMetadata
Represents cached reflection metadata for a single serializable property or field belonging to a type managed by the Scylla serialization system.
Inherited Members
Namespace: Scylla.Core.Util.Serialization
Assembly: ScyllaCore.dll
Syntax
public sealed class PropertyMetadata
Remarks
PropertyMetadata is constructed once per member during type discovery (performed by TypeMetadata) and stored in a TypeMetadataCache for reuse across all subsequent serialization operations. This design eliminates the per-call overhead of repeated reflection lookups and attribute scanning.
Getter and setter access is provided through compiled delegates rather than raw MemberInfo reflection calls, which reduces invocation cost at the expense of a one-time delegate creation cost during construction.
Instances of this class are immutable and thread-safe after construction. They may be safely shared across multiple concurrent serialization contexts.
A member is included in serialization if it is public, or if it carries the ScyllaIncludeAttribute. A member can be explicitly excluded with ScyllaIgnoreAttribute. Custom serialized names, ordering, and required-field enforcement are controlled via ScyllaPropertyAttribute.
Constructors
PropertyMetadata(FieldInfo, ScyllaPropertyAttribute)
Initializes a new PropertyMetadata instance that describes a C# field member.
Declaration
public PropertyMetadata(FieldInfo field, ScyllaPropertyAttribute attribute)
Parameters
| Type | Name | Description |
|---|---|---|
| FieldInfo | field | The FieldInfo for the field to describe. Must not be |
| ScyllaPropertyAttribute | attribute | The optional ScyllaPropertyAttribute decorating the field, or
|
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
PropertyMetadata(PropertyInfo, ScyllaPropertyAttribute)
Initializes a new PropertyMetadata instance that describes a C# property member.
Declaration
public PropertyMetadata(PropertyInfo property, ScyllaPropertyAttribute attribute)
Parameters
| Type | Name | Description |
|---|---|---|
| PropertyInfo | property | The PropertyInfo for the property to describe. Must not be
|
| ScyllaPropertyAttribute | attribute | The optional ScyllaPropertyAttribute decorating the property, or
|
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
Properties
CanRead
Gets whether the underlying member supports reading its value.
Declaration
public bool CanRead { get; }
Property Value
| Type | Description |
|---|---|
| bool | For a property, |
See Also
CanWrite
Gets whether the underlying member supports writing a value to it.
Declaration
public bool CanWrite { get; }
Property Value
| Type | Description |
|---|---|
| bool | For a property, |
See Also
DefaultValue
Gets the language-default value for this member's Type.
Declaration
public object DefaultValue { get; }
Property Value
| Type | Description |
|---|---|
| object | For value types, the result of CreateInstance(Type)
(e.g., |
See Also
IsRequired
Gets whether this property or field must be present in the serialized data during deserialization.
Declaration
public bool IsRequired { get; }
Property Value
| Type | Description |
|---|---|
| bool |
|
See Also
MemberInfo
Gets the underlying reflection descriptor for this member.
Declaration
public MemberInfo MemberInfo { get; }
Property Value
| Type | Description |
|---|---|
| MemberInfo | Either a PropertyInfo or a FieldInfo instance, depending on which constructor overload was used to create this PropertyMetadata. Callers can cast to the concrete type when property-specific or field-specific reflection behavior is needed. |
MemberName
Gets the original name of the property or field as declared in the source type, independent of any custom serialized name specified via ScyllaPropertyAttribute.
Declaration
public string MemberName { get; }
Property Value
| Type | Description |
|---|---|
| string | The C# identifier name of the underlying PropertyInfo or FieldInfo member. |
See Also
Name
Gets the serialized name of the property or field as it appears in the output document (e.g., the JSON key).
Declaration
public string Name { get; }
Property Value
| Type | Description |
|---|---|
| string | The value of Name if the member is decorated with ScyllaPropertyAttribute and a custom name was specified; otherwise, the original member name as declared in the type (i.e., the same value as MemberName). |
See Also
Order
Gets the relative serialization order for this property or field. Members with lower order values are serialized before members with higher values.
Declaration
public int Order { get; }
Property Value
| Type | Description |
|---|---|
| int | The value of Order if the member is decorated with ScyllaPropertyAttribute and an order was specified; otherwise, MaxValue, which places this member after all explicitly ordered members. Members sharing the same order value are sorted alphabetically by Name. |
See Also
Type
Gets the runtime Type of the value stored in this property or field.
Declaration
public Type Type { get; }
Property Value
| Type | Description |
|---|---|
| Type | For a property, this is PropertyType.
For a field, this is FieldType.
The value is never |
Methods
GetValue(object)
Reads the current value of this property or field from the specified object instance and returns it as an untyped object.
Declaration
public object GetValue(object instance)
Parameters
| Type | Name | Description |
|---|---|---|
| object | instance | The object whose member value should be read. Must be an instance of the type that declares this member; passing an incompatible type will cause the underlying delegate to throw a runtime exception. |
Returns
| Type | Description |
|---|---|
| object | The boxed value of the member on |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Thrown if CanRead is |
IsDefaultValue(object)
Determines whether the specified value is equal to the language-default value for this member's Type.
Declaration
public bool IsDefaultValue(object value)
Parameters
| Type | Name | Description |
|---|---|---|
| object | value | The value to compare against DefaultValue. May be |
Returns
| Type | Description |
|---|---|
| bool |
|
Remarks
Used by the serialization engine when DefaultValueHandling is set to Ignore to decide whether to omit a member from the serialized output.
SetValue(object, object)
Assigns the specified value to this property or field on the given object instance.
Declaration
public void SetValue(object instance, object value)
Parameters
| Type | Name | Description |
|---|---|---|
| object | instance | The object whose member should be updated. Must be an instance of the type that declares this member; passing an incompatible type will cause the underlying delegate to throw a runtime exception. |
| object | value | The value to assign to the member. Must be assignment-compatible with
Type; type mismatches will cause the underlying delegate to throw
a runtime exception. Pass |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Thrown if CanWrite is |