From 20bf6a563a94e5772fdb7b1bd6530404b2ea2c0b Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Wed, 22 Jul 2015 15:14:38 +0100 Subject: First pass at making field access simpler. This is definitely not ready to ship - I'm "troubled" by the disconnect between a list of fields in declaration order, and a mapping of field accessors by field number/name. Discussion required, but I find that easier when we've got code to look at :) --- csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs') diff --git a/csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs b/csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs index c617db36..a8288483 100644 --- a/csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs +++ b/csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs @@ -192,7 +192,7 @@ namespace Google.Protobuf.WellKnownTypes Uint32Field = 3, Uint64Field = 4 }; - var fields = TestWellKnownTypes.Descriptor.FieldAccessorsByFieldNumber; + var fields = TestWellKnownTypes.Descriptor.FieldAccessors; Assert.AreEqual("x", fields[TestWellKnownTypes.StringFieldFieldNumber].GetValue(message)); Assert.AreEqual(ByteString.CopyFrom(1, 2, 3), fields[TestWellKnownTypes.BytesFieldFieldNumber].GetValue(message)); @@ -216,7 +216,7 @@ namespace Google.Protobuf.WellKnownTypes { // Just a single example... note that we can't have a null value here var message = new RepeatedWellKnownTypes { Int32Field = { 1, 2 } }; - var fields = RepeatedWellKnownTypes.Descriptor.FieldAccessorsByFieldNumber; + var fields = RepeatedWellKnownTypes.Descriptor.FieldAccessors; var list = (IList) fields[RepeatedWellKnownTypes.Int32FieldFieldNumber].GetValue(message); CollectionAssert.AreEqual(new[] { 1, 2 }, list); } @@ -226,7 +226,7 @@ namespace Google.Protobuf.WellKnownTypes { // Just a single example... note that we can't have a null value here var message = new MapWellKnownTypes { Int32Field = { { 1, 2 }, { 3, null } } }; - var fields = MapWellKnownTypes.Descriptor.FieldAccessorsByFieldNumber; + var fields = MapWellKnownTypes.Descriptor.FieldAccessors; var dictionary = (IDictionary) fields[MapWellKnownTypes.Int32FieldFieldNumber].GetValue(message); Assert.AreEqual(2, dictionary[1]); Assert.IsNull(dictionary[3]); -- cgit v1.2.3