aboutsummaryrefslogtreecommitdiff
path: root/csharp/src/Google.Protobuf/Collections/RepeatedField.cs
diff options
context:
space:
mode:
authorJon Skeet <jonskeet@google.com>2016-01-15 10:13:56 +0000
committerJon Skeet <jonskeet@google.com>2016-01-15 10:13:56 +0000
commitf262611ff65d5a5d1b4665e2d339f108ef29fcf9 (patch)
tree64f71fc6bb7351df375afdecf799ceb23ed228ee /csharp/src/Google.Protobuf/Collections/RepeatedField.cs
parentf2fe50bfc516cdab99f51fa2ca90ba0db1ef6637 (diff)
downloadprotobuf-f262611ff65d5a5d1b4665e2d339f108ef29fcf9.tar.gz
protobuf-f262611ff65d5a5d1b4665e2d339f108ef29fcf9.tar.bz2
protobuf-f262611ff65d5a5d1b4665e2d339f108ef29fcf9.zip
Fix handling of repeated wrappers
Previously we were incorrectly packing wrapper types. This also refactors FieldCodec a bit as well, using more C# 6-ness.
Diffstat (limited to 'csharp/src/Google.Protobuf/Collections/RepeatedField.cs')
-rw-r--r--csharp/src/Google.Protobuf/Collections/RepeatedField.cs9
1 files changed, 4 insertions, 5 deletions
diff --git a/csharp/src/Google.Protobuf/Collections/RepeatedField.cs b/csharp/src/Google.Protobuf/Collections/RepeatedField.cs
index e3f65afe..1cde03bc 100644
--- a/csharp/src/Google.Protobuf/Collections/RepeatedField.cs
+++ b/csharp/src/Google.Protobuf/Collections/RepeatedField.cs
@@ -34,7 +34,6 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
-using Google.Protobuf.Compatibility;
namespace Google.Protobuf.Collections
{
@@ -96,8 +95,8 @@ namespace Google.Protobuf.Collections
// iteration.
uint tag = input.LastTag;
var reader = codec.ValueReader;
- // Value types can be packed or not.
- if (typeof(T).IsValueType() && WireFormat.GetTagWireType(tag) == WireFormat.WireType.LengthDelimited)
+ // Non-nullable value types can be packed or not.
+ if (FieldCodec<T>.IsPackedRepeatedField(tag))
{
int length = input.ReadLength();
if (length > 0)
@@ -134,7 +133,7 @@ namespace Google.Protobuf.Collections
return 0;
}
uint tag = codec.Tag;
- if (typeof(T).IsValueType() && WireFormat.GetTagWireType(tag) == WireFormat.WireType.LengthDelimited)
+ if (codec.PackedRepeatedField)
{
int dataSize = CalculatePackedDataSize(codec);
return CodedOutputStream.ComputeRawVarint32Size(tag) +
@@ -186,7 +185,7 @@ namespace Google.Protobuf.Collections
}
var writer = codec.ValueWriter;
var tag = codec.Tag;
- if (typeof(T).IsValueType() && WireFormat.GetTagWireType(tag) == WireFormat.WireType.LengthDelimited)
+ if (codec.PackedRepeatedField)
{
// Packed primitive type
uint size = (uint)CalculatePackedDataSize(codec);