diff options
Diffstat (limited to 'csharp/src/Google.Protobuf.Test/Reflection/DescriptorsTest.cs')
-rw-r--r-- | csharp/src/Google.Protobuf.Test/Reflection/DescriptorsTest.cs | 15 |
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 |