Class HumlPropertyAttribute

Namespace
Huml.Net.Serialization
Assembly
Huml.Net.dll

Customises how a property is represented in a HUML document.

[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
public sealed class HumlPropertyAttribute : Attribute
Inheritance
HumlPropertyAttribute
Inherited Members

Remarks

When Name is provided, the HUML key name overrides the property name. When OmitIfDefault is true, the property is omitted during serialisation when its value equals the CLR default for its type.

Constructors

HumlPropertyAttribute(string?)

Initialises a new instance with an optional HUML key name override.

public HumlPropertyAttribute(string? name = null)

Parameters

name string

The HUML key name, or null to use the property name.

Properties

Inline

Per-property inline format override for collection properties. Inline requests inline format (with silent multiline fallback for non-scalar items); Multiline forces multiline regardless of the global setting; Inherit (default) inherits the global HumlOptions.CollectionFormat setting. Has no effect on non-collection properties (scalars, POCOs).

public InlineMode Inline { get; init; }

Property Value

InlineMode

Name

The HUML key name to use instead of the property name, or null to use the property name.

public string? Name { get; }

Property Value

string

OmitIfDefault

When true, the property is omitted from the serialised output if its value equals the CLR default for its type (e.g., 0 for integers, null for reference types). Defaults to false.

public bool OmitIfDefault { get; init; }

Property Value

bool