Serialization Attributes
Namespace: Nalix.Abstractions.Serialization (and Nalix.Abstractions.Networking.Packets)
Assembly: Nalix.Abstractions
Nalix.Abstractions.Serialization defines the compile-time attributes, layout enums, size contracts, and boundary constants used by SerializeFormatterGenerator, PacketSchemaGenerator, and LiteSerializer.
Source Mapping
src/Nalix.Abstractions/Serialization/GenerateFormatterAttribute.cssrc/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
Attributes & Contracts Reference
| Type | Target | Constructors & Members | Purpose |
|---|---|---|---|
[Packet] (PacketAttribute) | Class, Struct, Interface | PacketAttribute() | Marks a PacketBase<TSelf> class (implements IPacketStaticOpcode) for discovery by PacketRegistryGenerator. |
[GenerateFormatter] | Class, Struct | GenerateFormatterAttribute() | Instructs SerializeFormatterGenerator to emit an IFormatter<T> (and IFillableFormatter<T> for classes) at compile time. Target must be partial (NALIX059). |
[SerializePackable] | Class, Struct, Interface | SerializePackableAttribute(SerializeLayout layout = SerializeLayout.Auto)Property: SerializeLayout SerializeLayout | Declares the member ordering mode (Auto, Sequential, or Explicit). |
[SerializeOrder] | Field, Property | SerializeOrderAttribute(int order)SerializeOrderAttribute(PacketHeaderOffset offset)Property: int Order | Assigns the non-negative serialization sequence index (0, 1, 2...) when using SerializeLayout.Explicit. |
[SerializeIgnore] | Field, Property | SerializeIgnoreAttribute() | Excludes a field or property from binary serialization. Cannot be combined with [SerializeOrder] (NALIX015). |
[SerializeHeader] | Field, Property | SerializeHeaderAttribute(int order)SerializeHeaderAttribute(PacketHeaderOffset offset)Property: int Order | Marks a base header field (PacketHeaderOffset.Region = 6 reserves bytes 0..5 on PacketBase<TSelf>, enforced by NALIX022). |
[SerializeDynamicSize] | Field, Property | SerializeDynamicSizeAttribute(int size = 20)Property: int Size | Provides a buffer-sizing hint for variable-length strings, arrays, or collections. |
IFixedSizeSerializable | Interface | static abstract int Size { get; } | Contract for fixed-size structs/packets whose wire size is known at compile time (cannot contain dynamic members per NALIX051). |
SerializerBounds | Static class | Null = -1MaxArray = 1_048_576MaxString = 1_048_576NullArrayMarker => [255, 255, 255, 255] (ReadOnlySpan<byte>)EmptyArrayMarker => [0, 0, 0, 0] (ReadOnlySpan<byte>) | Wire markers and hard safety caps for array and string deserialization. |
Example
using Nalix.Abstractions;
using Nalix.Abstractions.Networking.Packets;
using Nalix.Abstractions.Serialization;
using Nalix.Codec.DataFrames;
[Packet]
[GenerateFormatter]
[SerializePackable(SerializeLayout.Explicit)]
public sealed partial class TransformUpdatePacket : PacketBase<TransformUpdatePacket>, IPacketStaticOpcode
{
public static ushort StaticOpCode => 0x2001;
[SerializeOrder(0)]
public ulong EntityId { get; set; }
[SerializeOrder(1)]
public float X { get; set; }
[SerializeOrder(2)]
public float Y { get; set; }
[SkipClean]
[SerializeIgnore]
public long LocalTimestampTicks { get; set; }
}