diff options
Diffstat (limited to 'csharp/src/Google.Protobuf/FieldCodec.cs')
-rw-r--r-- | csharp/src/Google.Protobuf/FieldCodec.cs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/csharp/src/Google.Protobuf/FieldCodec.cs b/csharp/src/Google.Protobuf/FieldCodec.cs index 98313088..c28b47e1 100644 --- a/csharp/src/Google.Protobuf/FieldCodec.cs +++ b/csharp/src/Google.Protobuf/FieldCodec.cs @@ -347,7 +347,8 @@ namespace Google.Protobuf public sealed class FieldCodec<T> { private static readonly T DefaultDefault; - private static readonly bool TypeSupportsPacking = typeof(T).IsValueType() && Nullable.GetUnderlyingType(typeof(T)) == null; + // Only non-nullable value types support packing. This is the simplest way of detecting that. + private static readonly bool TypeSupportsPacking = default(T) != null; static FieldCodec() { |