Class HumlIgnoreDefaultsAttribute
- Namespace
- Huml.Net.Serialization
- Assembly
- Huml.Net.dll
Instructs the HUML serialiser to omit all properties of the decorated type when their runtime value equals the CLR default for their declared type.
[AttributeUsage(AttributeTargets.Class|AttributeTargets.Struct, AllowMultiple = false, Inherited = true)]
public sealed class HumlIgnoreDefaultsAttribute : Attribute
- Inheritance
-
HumlIgnoreDefaultsAttribute
- Inherited Members
Remarks
Applying this attribute to a class or struct is equivalent to adding
[HumlProperty(OmitIfDefault = true)] to every property on that type.
It is intended for DTOs with many optional properties (e.g. patch payloads, diff objects)
where per-property annotation would be repetitive boilerplate.
Precedence: per-property [HumlProperty(OmitIfDefault = true)] takes the highest
priority and is evaluated independently before this class-level attribute.
HumlOptions.DefaultIgnoreCondition is consulted last as the global fallback.
The attribute is inherited by derived classes (Inherited = true). A derived class
whose base is decorated with [HumlIgnoreDefaults] will also suppress its own
properties at their CLR default. However, decorating only the derived class does
not retroactively suppress base-class properties.