aboutsummaryrefslogtreecommitdiffhomepage
path: root/csharp/src/Google.Protobuf/Collections
diff options
context:
space:
mode:
authorGravatar Jon Skeet <jonskeet@google.com>2015-07-23 15:31:34 +0100
committerGravatar Jon Skeet <jonskeet@google.com>2015-07-27 07:47:50 +0100
commit0dbd5ec80d33ea2a37f5362a24fd72b2c5f51aaa (patch)
tree87757b73246b762cede87e54620ef78b791f2881 /csharp/src/Google.Protobuf/Collections
parentedff88886b03055f8dff0c0dad61d9450b59a23e (diff)
First attempt at using profile 259 for Google.Protobuf.
This requires .NET 4.5, and there are a few compatibility changes required around reflection. Creating a PR from this to see how our CI systems handle it. Will want to add more documentation, validation and probably tests before merging. This is in aid of issue #590.
Diffstat (limited to 'csharp/src/Google.Protobuf/Collections')
-rw-r--r--csharp/src/Google.Protobuf/Collections/MapField.cs3
-rw-r--r--csharp/src/Google.Protobuf/Collections/RepeatedField.cs10
2 files changed, 8 insertions, 5 deletions
diff --git a/csharp/src/Google.Protobuf/Collections/MapField.cs b/csharp/src/Google.Protobuf/Collections/MapField.cs
index 9ca5104d..68f2f1cc 100644
--- a/csharp/src/Google.Protobuf/Collections/MapField.cs
+++ b/csharp/src/Google.Protobuf/Collections/MapField.cs
@@ -35,6 +35,7 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
+using Google.Protobuf.Compatibility;
namespace Google.Protobuf.Collections
{
@@ -74,7 +75,7 @@ namespace Google.Protobuf.Collections
/// <param name="allowNullValues">Whether null values are permitted in the map or not.</param>
public MapField(bool allowNullValues)
{
- if (allowNullValues && typeof(TValue).IsValueType && Nullable.GetUnderlyingType(typeof(TValue)) == null)
+ if (allowNullValues && typeof(TValue).IsValueType() && Nullable.GetUnderlyingType(typeof(TValue)) == null)
{
throw new ArgumentException("allowNullValues", "Non-nullable value types do not support null values");
}
diff --git a/csharp/src/Google.Protobuf/Collections/RepeatedField.cs b/csharp/src/Google.Protobuf/Collections/RepeatedField.cs
index 9bab41ea..ccd1a9bb 100644
--- a/csharp/src/Google.Protobuf/Collections/RepeatedField.cs
+++ b/csharp/src/Google.Protobuf/Collections/RepeatedField.cs
@@ -29,10 +29,12 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endregion
-
+
+using Google.Protobuf.Reflection;
using System;
using System.Collections;
using System.Collections.Generic;
+using Google.Protobuf.Compatibility;
namespace Google.Protobuf.Collections
{
@@ -88,7 +90,7 @@ namespace Google.Protobuf.Collections
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)
+ if (typeof(T).IsValueType() && WireFormat.GetTagWireType(tag) == WireFormat.WireType.LengthDelimited)
{
int length = input.ReadLength();
if (length > 0)
@@ -119,7 +121,7 @@ namespace Google.Protobuf.Collections
return 0;
}
uint tag = codec.Tag;
- if (typeof(T).IsValueType && WireFormat.GetTagWireType(tag) == WireFormat.WireType.LengthDelimited)
+ if (typeof(T).IsValueType() && WireFormat.GetTagWireType(tag) == WireFormat.WireType.LengthDelimited)
{
int dataSize = CalculatePackedDataSize(codec);
return CodedOutputStream.ComputeRawVarint32Size(tag) +
@@ -165,7 +167,7 @@ namespace Google.Protobuf.Collections
}
var writer = codec.ValueWriter;
var tag = codec.Tag;
- if (typeof(T).IsValueType && WireFormat.GetTagWireType(tag) == WireFormat.WireType.LengthDelimited)
+ if (typeof(T).IsValueType() && WireFormat.GetTagWireType(tag) == WireFormat.WireType.LengthDelimited)
{
// Packed primitive type
uint size = (uint)CalculatePackedDataSize(codec);