aboutsummaryrefslogtreecommitdiffhomepage
path: root/csharp/src/Google.Protobuf.Test/Reflection/DescriptorsTest.cs
diff options
context:
space:
mode:
authorGravatar Jon Skeet <jonskeet@google.com>2015-07-22 15:14:38 +0100
committerGravatar Jon Skeet <jonskeet@google.com>2015-07-22 20:13:37 +0100
commit20bf6a563a94e5772fdb7b1bd6530404b2ea2c0b (patch)
tree49a153ddecda0bb9b89640637e15ad93f7e42d6c /csharp/src/Google.Protobuf.Test/Reflection/DescriptorsTest.cs
parent7b5c3967991b6534f439cb31b0d247501f4a0ef8 (diff)
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 :)
Diffstat (limited to 'csharp/src/Google.Protobuf.Test/Reflection/DescriptorsTest.cs')
-rw-r--r--csharp/src/Google.Protobuf.Test/Reflection/DescriptorsTest.cs15
1 files changed, 15 insertions, 0 deletions
diff --git a/csharp/src/Google.Protobuf.Test/Reflection/DescriptorsTest.cs b/csharp/src/Google.Protobuf.Test/Reflection/DescriptorsTest.cs
index 0aff0a6c..ed4291a4 100644
--- a/csharp/src/Google.Protobuf.Test/Reflection/DescriptorsTest.cs
+++ b/csharp/src/Google.Protobuf.Test/Reflection/DescriptorsTest.cs
@@ -33,6 +33,7 @@
using System.Linq;
using Google.Protobuf.TestProtos;
using NUnit.Framework;
+using UnitTest.Issues.TestProtos;
namespace Google.Protobuf.Reflection
{
@@ -220,5 +221,19 @@ namespace Google.Protobuf.Reflection
CollectionAssert.AreEquivalent(expectedFields, descriptor.Fields);
}
+
+ [Test]
+ public void ConstructionWithoutGeneratedCodeInfo()
+ {
+ var data = UnittestIssues.Descriptor.Proto.ToByteArray();
+ var newDescriptor = Google.Protobuf.Reflection.FileDescriptor.InternalBuildGeneratedFileFrom(data, new Reflection.FileDescriptor[] { }, null);
+
+ // We should still be able to get at a field...
+ var messageDescriptor = newDescriptor.FindTypeByName<MessageDescriptor>("ItemField");
+ var fieldDescriptor = messageDescriptor.FindFieldByName("item");
+ // But there shouldn't be an accessor (or a generated type for the message)
+ Assert.IsNull(fieldDescriptor.Accessor);
+ Assert.IsNull(messageDescriptor.GeneratedType);
+ }
}
} \ No newline at end of file