From 5c1be973272b45c381288191c51a51f6866100c8 Mon Sep 17 00:00:00 2001 From: Jan Pluskal Date: Mon, 13 Jul 2020 12:37:13 +0000 Subject: [PATCH] Resolve "ImplicitNullable fails during serialization." --- Kaitai.Struct.Runtime/ImplicitNullable.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kaitai.Struct.Runtime/ImplicitNullable.cs b/Kaitai.Struct.Runtime/ImplicitNullable.cs index e295856..0b8f235 100644 --- a/Kaitai.Struct.Runtime/ImplicitNullable.cs +++ b/Kaitai.Struct.Runtime/ImplicitNullable.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Text; @@ -7,7 +7,7 @@ namespace Kaitai public struct ImplicitNullable where T : struct { public bool HasValue { get { return this._value.HasValue; } } - public T Value { get { return this._value.Value; } } + public T Value { get { return this._value ?? default; } } public ImplicitNullable(T value) : this() { this._value = value; } public ImplicitNullable(T? value) : this() { this._value = value; }