[GenerateSerializer] — operates at the type level and triggers source generation of a complete ISerializable implementation. A second type-level attribute, [FixedEchoStructure], switches a type to positional (index-based) serialization for maximum compactness and speed.
[GenerateSerializer]
partial class or struct for automatic source-generated ISerializable implementation. The source generator reads the type’s fields at compile time and emits optimized Serialize and Deserialize methods, taking all other Echo attributes into account.
The generator is bundled in the Prowl.Echo NuGet package — no separate analyzer package reference is required. The type must be declared
partial for the generator to emit code alongside it.Usage
Serialize and Deserialize methods in a separate partial file at build time. You never need to write them by hand.
[FixedEchoStructure]
Compound ({"x": 1.0, "y": 2.0, "z": 3.0}), the type is serialized as an ordered List ([1.0, 2.0, 3.0]). This eliminates field-name overhead entirely, making it ideal for hot-path types like math primitives and network packets.
Usage
[SerializeField]
private or protected field to be included in serialization. By default, Echo only serializes public fields; [SerializeField] opts a non-public field into that set without changing its access modifier.
Usage
[SerializeIgnore]
public field from serialization. The effect is identical to marking the field with [System.NonSerialized] — both annotations cause Echo to skip the field entirely. Use [SerializeIgnore] when you want the exclusion to be expressed in Echo’s own vocabulary rather than the BCL’s attribute.
Usage
[FormerlySerializedAs]
[FormerlySerializedAs] annotation matches a key that does exist in the stored data, and reads from that key instead.
AllowMultiple = true means you can stack the attribute to support an arbitrary chain of historical renames.
[FormerlySerializedAs] only affects deserialization. Serialization always writes the current field name.Properties
string
The historical name that was used in previously serialized data.
Usage
[IgnoreOnNull]
null. Without this attribute, a null field is written as an explicit null entry in the compound. With it, the key is omitted entirely, which reduces the size of the serialized output for sparsely-populated objects.
Usage
[SerializeIf]
bool; it can be a field, a property, or a parameterless method. When the condition member evaluates to false at serialization time, the field is skipped.
[SerializeIf] is evaluated only during serialization, not during deserialization. If the condition was false when data was written, the field simply will not be present in the stored compound.Properties
string
The name of the field, property, or method on the same type whose return value controls whether this field is serialized. The member must return
bool.