From f5a0a7feeb7dcde7f5eddd4548cbf08e9e3ccd57 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Fri, 23 Oct 2015 09:37:19 +0100 Subject: Fix clearing wrapper type fields with reflection. The nullable value type fields already worked, but the use of the CLR property concealed the difference between string and StringWrapper fields. --- csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs | 2 +- csharp/src/Google.Protobuf/Reflection/SingleFieldAccessor.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'csharp/src/Google.Protobuf') diff --git a/csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs b/csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs index 619a6ac8..3d6cc59f 100644 --- a/csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs +++ b/csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs @@ -197,7 +197,7 @@ namespace Google.Protobuf.Reflection } /// - /// Returns the type of the field. + /// Returns the type of the field. /// public FieldType FieldType { diff --git a/csharp/src/Google.Protobuf/Reflection/SingleFieldAccessor.cs b/csharp/src/Google.Protobuf/Reflection/SingleFieldAccessor.cs index de92fbc1..bbac2173 100644 --- a/csharp/src/Google.Protobuf/Reflection/SingleFieldAccessor.cs +++ b/csharp/src/Google.Protobuf/Reflection/SingleFieldAccessor.cs @@ -61,7 +61,7 @@ namespace Google.Protobuf.Reflection // TODO: Validate that this is a reasonable single field? (Should be a value type, a message type, or string/ByteString.) object defaultValue = - typeof(IMessage).IsAssignableFrom(clrType) ? null + descriptor.FieldType == FieldType.Message ? null : clrType == typeof(string) ? "" : clrType == typeof(ByteString) ? ByteString.Empty : Activator.CreateInstance(clrType); -- cgit v1.2.3