diff options
author | Jon Skeet <jonskeet@google.com> | 2015-10-23 09:37:19 +0100 |
---|---|---|
committer | Jon Skeet <jonskeet@google.com> | 2015-10-30 09:37:01 +0000 |
commit | f5a0a7feeb7dcde7f5eddd4548cbf08e9e3ccd57 (patch) | |
tree | 0eef3fbf64b377e72e1dd3b5ed891903e04909c6 /csharp/src/Google.Protobuf.Test | |
parent | a74e912a8be1274fd561db5e8133937d4e9c4a2b (diff) | |
download | protobuf-f5a0a7feeb7dcde7f5eddd4548cbf08e9e3ccd57.tar.gz protobuf-f5a0a7feeb7dcde7f5eddd4548cbf08e9e3ccd57.tar.bz2 protobuf-f5a0a7feeb7dcde7f5eddd4548cbf08e9e3ccd57.zip |
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.
Diffstat (limited to 'csharp/src/Google.Protobuf.Test')
-rw-r--r-- | csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs b/csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs index fbc0ff07..c87ceb2f 100644 --- a/csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs +++ b/csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs @@ -345,5 +345,15 @@ namespace Google.Protobuf.WellKnownTypes var message = TestWellKnownTypes.Parser.ParseFrom(stream); Assert.AreEqual(6, message.Int32Field); } + + [Test] + public void ClearWithReflection() + { + // String and Bytes are the tricky ones here, as the CLR type of the property + // is the same between the wrapper and non-wrapper types. + var message = new TestWellKnownTypes { StringField = "foo" }; + TestWellKnownTypes.Descriptor.Fields[TestWellKnownTypes.StringFieldFieldNumber].Accessor.Clear(message); + Assert.IsNull(message.StringField); + } } } |