diff options
author | Jan Tattermusch <jtattermusch@users.noreply.github.com> | 2015-07-31 11:29:07 -0700 |
---|---|---|
committer | Jan Tattermusch <jtattermusch@users.noreply.github.com> | 2015-07-31 11:29:07 -0700 |
commit | abd7083b0c5344dddaa5b7097918950251018ab7 (patch) | |
tree | d46c3b14ce2d4d8bef360e35e46734027e115e06 | |
parent | c20f67fdb4fbe752820a43b9ada2557112b0f3e3 (diff) | |
parent | fd02e45b2a2f38da25ee2d202ed911b684fe30ac (diff) | |
download | protobuf-abd7083b0c5344dddaa5b7097918950251018ab7.tar.gz protobuf-abd7083b0c5344dddaa5b7097918950251018ab7.tar.bz2 protobuf-abd7083b0c5344dddaa5b7097918950251018ab7.zip |
Merge pull request #667 from jskeet/fix-field-orderings
Fix trivial bug in field orderings.
-rw-r--r-- | csharp/src/Google.Protobuf.Test/Reflection/DescriptorsTest.cs | 13 | ||||
-rw-r--r-- | csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs | 2 |
2 files changed, 14 insertions, 1 deletions
diff --git a/csharp/src/Google.Protobuf.Test/Reflection/DescriptorsTest.cs b/csharp/src/Google.Protobuf.Test/Reflection/DescriptorsTest.cs index e84a0727..643816e6 100644 --- a/csharp/src/Google.Protobuf.Test/Reflection/DescriptorsTest.cs +++ b/csharp/src/Google.Protobuf.Test/Reflection/DescriptorsTest.cs @@ -238,5 +238,18 @@ namespace Google.Protobuf.Reflection Assert.IsNull(fieldDescriptor.Accessor); Assert.IsNull(messageDescriptor.GeneratedType); } + + // From TestFieldOrdering: + // string my_string = 11; + // int64 my_int = 1; + // float my_float = 101; + // NestedMessage single_nested_message = 200; + [Test] + public void FieldListOrderings() + { + var fields = TestFieldOrderings.Descriptor.Fields; + Assert.AreEqual(new[] { 11, 1, 101, 200 }, fields.InDeclarationOrder().Select(x => x.FieldNumber)); + Assert.AreEqual(new[] { 1, 11, 101, 200 }, fields.InFieldNumberOrder().Select(x => x.FieldNumber)); + } } } diff --git a/csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs b/csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs index 1250774d..0b562de1 100644 --- a/csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs +++ b/csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs @@ -250,7 +250,7 @@ namespace Google.Protobuf.Reflection /// </value> public IList<FieldDescriptor> InFieldNumberOrder() { - return messageDescriptor.fieldsInDeclarationOrder; + return messageDescriptor.fieldsInNumberOrder; } /// <summary> |