I'm formatting a BCD field:
msg[60] = FieldDescriptor.BcdVar(3, 125, Formatters.Bcd);
The lib throws an exception when packing the message. It's straight-forward to reproduce.
I found that in both BCD and Binary Var, when the length-indicator is odd (1 or 3), the exception occurs.
I changed in VariableLengthFormatter.Pack():
var lengthStr = length.ToString().PadLeft(LengthOfLengthIndicator, '0');
to
var lengthStr = length.ToString().PadLeft(_lengthIndicator, '0');
using the unpacked length for padding the string, and the issue was fixed (well, I added FieldDescriptor.BinaryVar() and a few fixes in BinaryFormatter, which I'll be glad to share).
So, my question is: was it a bug and was fixed, or am I miss-using the (nicely written) lib and barking the wrong tree?
If it is a bug - can it be fixed in some object-oriented magic in my code (like extending the class Iso8583 when wanting to change the default template format), or the fix must be in the lib itself and when a new lib version goes out there will be merge issues?
PS - I'm new to C# (experienced C programmer)
Thanks.