Serialization Attributes¶
Serialization Attributes¶
Nalix.Abstractions.Serialization contains the low-level attributes and helpers that shape how packets and models are serialized.
Use this page when you need to understand the attribute layer before you work with PacketBase<TSelf> or LiteSerializer.
Source mapping¶
src/Nalix.Abstractions/Networking/Packets/PacketAttribute.cssrc/Nalix.Abstractions/Serialization/SerializePackableAttribute.cssrc/Nalix.Abstractions/Serialization/SerializeOrderAttribute.cssrc/Nalix.Abstractions/Serialization/SerializeIgnoreAttribute.cssrc/Nalix.Abstractions/Serialization/SerializeHeaderAttribute.cssrc/Nalix.Abstractions/Serialization/SerializeDynamicSizeAttribute.cssrc/Nalix.Abstractions/Serialization/SerializeLayout.cssrc/Nalix.Abstractions/Serialization/SerializerBounds.cssrc/Nalix.Abstractions/Serialization/IFixedSizeSerializable.cs
Main types¶
PacketAttribute(aliased as[Packet])SerializePackableAttributeSerializeOrderAttributeSerializeIgnoreAttributeSerializeHeaderAttributeSerializeDynamicSizeAttributeSerializeLayoutSerializerBoundsIFixedSizeSerializable
What this layer does¶
These types define how Nalix interprets a serializable model:
- whether the type is packable
- which members are serialized and in what order
- which members are ignored
- which members belong in the packet header region
- which members use dynamic sizing
- which shapes are considered fixed-size
Important behavior¶
The attribute layer allows the core serialization attributes to be placed on either a field or a property.
For LiteSerializer automatic object and struct serialization, the effective runtime behavior is still field-based:
- fields are serialized directly
- properties mainly act as metadata carriers
- auto-properties usually work because their attributes can be associated with the generated backing field
- custom properties without a compiler-generated backing field are not serialized as independent members
- static members are outside the automatic serialization model
Attributes¶
PacketAttribute (or [Packet])¶
Marks a class for automatic discovery and registration. It allows the PacketRegistryFactory to find and bind the type to its deserializer at runtime without explicit manual registration.
SerializePackableAttribute¶
Marks a type as packable and tells the serializer to treat it as an explicitly supported wire model.
Common use:
- packet models
- value objects that should serialize without a nullable wrapper path
SerializeOrderAttribute¶
Controls the order of serialized members.
Important: SerializeOrder is an ordering key, not a byte offset.
[SerializeOrder(10)] means "after 9", not "start at byte 10".
It is useful when:
Most packet types use these attributes together with PacketBase<TSelf>.
The typical flow is:
- declare the packet model
- add serialization attributes
- let the framework build the serializer or formatter
- send the packet through the runtime