From 1b66a9a85f39c52728893400a23504844cc78e34 Mon Sep 17 00:00:00 2001 From: Petr Pucil Date: Sat, 6 Jun 2020 23:13:11 +0200 Subject: [PATCH] Add byte array support in validation errors (as in kaitai-io/kaitai_struct_java_runtime@2fb1c5a) See https://github.com/kaitai-io/kaitai_struct/issues/435 --- KaitaiStruct.cs | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/KaitaiStruct.cs b/KaitaiStruct.cs index 42bcd0e..7fb48e3 100644 --- a/KaitaiStruct.cs +++ b/KaitaiStruct.cs @@ -123,27 +123,41 @@ namespace Kaitai } public class ValidationLessThanError : ValidationFailedError { - public ValidationLessThanError(long min, long actual, KaitaiStream io, string srcPath) + public ValidationLessThanError(byte[] min, byte[] actual, KaitaiStream io, string srcPath) + : base("not in range, min " + ByteArrayToHex(min) + ", but got " + ByteArrayToHex(actual), io, srcPath) + { + this.min = min; + this.actual = actual; + } + + public ValidationLessThanError(Object min, Object actual, KaitaiStream io, string srcPath) : base("not in range, min " + min + ", but got " + actual, io, srcPath) { this.min = min; this.actual = actual; } - protected long min; - protected long actual; + protected Object min; + protected Object actual; } public class ValidationGreaterThanError : ValidationFailedError { - public ValidationGreaterThanError(long max, long actual, KaitaiStream io, string srcPath) + public ValidationGreaterThanError(byte[] max, byte[] actual, KaitaiStream io, string srcPath) + : base("not in range, max " + ByteArrayToHex(max) + ", but got " + ByteArrayToHex(actual), io, srcPath) + { + this.max = max; + this.actual = actual; + } + + public ValidationGreaterThanError(Object max, Object actual, KaitaiStream io, string srcPath) : base("not in range, max " + max + ", but got " + actual, io, srcPath) { this.max = max; this.actual = actual; } - protected long max; - protected long actual; + protected Object max; + protected Object actual; } public class ValidationNotAnyOfError : ValidationFailedError {