Skip to content

FieldCount with a computed ignored property is filling the array with invalid element count #216

@sn4k3

Description

@sn4k3
public class Preview
    {
        /// <summary>
        /// Gets the image width, in pixels.
        /// </summary>
        [FieldOrder(0)] public uint ResolutionX { get; set; } = 224;

        /// <summary>
        /// Gets the operation mark 'x'
        /// </summary>
        [FieldOrder(1)] [FieldLength(4)] [SerializeAs(SerializedType.TerminatedString)] public string Mark { get; set; } = "x";

        /// <summary>
        /// Gets the image height, in pixels.
        /// </summary>
        [FieldOrder(2)] public uint ResolutionY { get; set; } = 168;

        [Ignore] public uint DataSize => ResolutionX * ResolutionY * 2;

        [FieldOrder(3)] [FieldCount(nameof(DataSize))] public byte[] Data { get; set; } = Array.Empty<byte>();
}

Deserializing that results in:

image

Note that outrageous Data[10730659] instead of 75264

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions