diff --git a/src/Yarhl/IO/Serialization/Attributes/BinaryFieldOrderAttribute.cs b/src/Yarhl/IO/Serialization/Attributes/BinaryFieldOrderAttribute.cs new file mode 100644 index 0000000..a9081cd --- /dev/null +++ b/src/Yarhl/IO/Serialization/Attributes/BinaryFieldOrderAttribute.cs @@ -0,0 +1,29 @@ +namespace Yarhl.IO.Serialization.Attributes; + +using System; + +/// +/// Specify the order to serialize or deserialize the fields in binary format. +/// +[AttributeUsage(AttributeTargets.Property)] +public class BinaryFieldOrderAttribute : Attribute +{ + /// + /// Initializes a new instance of the class. + /// + /// The order of the field in the binary serialization. + /// The order is less than 0. + public BinaryFieldOrderAttribute(int order) + { + if (order < 0) { + throw new ArgumentOutOfRangeException(nameof(order)); + } + + Order = order; + } + + /// + /// Gets or sets the order of the field in the binary format. + /// + public int Order { get; set; } +}