In the C# source, the OpenDis.Dis1998.Marking class has a read/write Characters property. If the value is set to something that is not an 11-byte array, the object is invalid. If it is then marshalled to an output stream, the stream may be the wrong length.
Could this be addressed? Some possible ways I can think of include:
- Validate and throw an exception if the specified value is not an 11-byte array
- Accept any array, but truncate long ones and pad short ones so the private field is always 11 bytes long
- Add another property of type string and use the value to set the characters using Encoding.ASCII.GetBytes(value) and truncating/padding as required. For example:
public string CharacterString
{
get { return Encoding.ASCII.GetString(Characters); }
set { Characters = Encoding.ASCII.GetBytes(value).Concat(Enumerable.Repeat((byte) 0, 11)).Take(11).ToArray(); } // Ensures array is always 11 bytes long
}