From 17ded8261d19f79181dc71402f019993667fe0df Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Wed, 19 May 2010 21:07:58 +0100 Subject: [PATCH] Fix issue 10 - check serialized size before writing to stream --- src/AddressBook/AddressBookProtos.cs | 3 ++ src/ProtoGen/MessageGenerator.cs | 2 ++ src/ProtocolBuffers.Test/MessageTest.cs | 11 +++++++ .../UnitTestCSharpOptionsProtoFile.cs | 1 + .../UnitTestCustomOptionsProtoFile.cs | 17 ++++++++++ .../UnitTestEmbedOptimizeForProtoFile.cs | 1 + .../TestProtos/UnitTestImportProtoFile.cs | 1 + .../TestProtos/UnitTestMessageSetProtoFile.cs | 6 ++++ .../TestProtos/UnitTestProtoFile.cs | 31 +++++++++++++++++++ .../DescriptorProtos/CSharpOptions.cs | 2 ++ .../DescriptorProtos/DescriptorProtoFile.cs | 18 +++++++++++ 11 files changed, 93 insertions(+) diff --git a/src/AddressBook/AddressBookProtos.cs b/src/AddressBook/AddressBookProtos.cs index 15788fb954..cc3905d166 100644 --- a/src/AddressBook/AddressBookProtos.cs +++ b/src/AddressBook/AddressBookProtos.cs @@ -146,6 +146,7 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; if (HasNumber) { output.WriteString(1, Number); } @@ -418,6 +419,7 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; if (HasName) { output.WriteString(1, Name); } @@ -755,6 +757,7 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; foreach (global::Google.ProtocolBuffers.Examples.AddressBook.Person element in PersonList) { output.WriteMessage(1, element); } diff --git a/src/ProtoGen/MessageGenerator.cs b/src/ProtoGen/MessageGenerator.cs index be32d8025d..3488cdc943 100644 --- a/src/ProtoGen/MessageGenerator.cs +++ b/src/ProtoGen/MessageGenerator.cs @@ -193,6 +193,8 @@ namespace Google.ProtocolBuffers.ProtoGen { writer.WriteLine("public override void WriteTo(pb::CodedOutputStream output) {"); writer.Indent(); + // Make sure we've computed the serialized length, so that packed fields are generated correctly. + writer.WriteLine("int size = SerializedSize;"); if (Descriptor.Proto.ExtensionRangeList.Count > 0) { writer.WriteLine("pb::ExtendableMessage<{0}, {0}.Builder>.ExtensionWriter extensionWriter = CreateExtensionWriter(this);", ClassName); diff --git a/src/ProtocolBuffers.Test/MessageTest.cs b/src/ProtocolBuffers.Test/MessageTest.cs index 936a05e530..e06254d7f2 100644 --- a/src/ProtocolBuffers.Test/MessageTest.cs +++ b/src/ProtocolBuffers.Test/MessageTest.cs @@ -32,6 +32,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #endregion +using System.IO; using Google.ProtocolBuffers.Descriptors; using Google.ProtocolBuffers.TestProtos; using NUnit.Framework; @@ -313,6 +314,16 @@ namespace Google.ProtocolBuffers { Assert.AreEqual("Message missing required fields: a, b, c", e.Message); } } + + [Test] + public void PackedTypesWrittenDirectlyToStream() { + TestPackedTypes message = new TestPackedTypes.Builder {PackedInt32List = {0, 1, 2}}.Build(); + MemoryStream stream = new MemoryStream(); + message.WriteTo(stream); + stream.Position = 0; + TestPackedTypes readMessage = TestPackedTypes.ParseFrom(stream); + Assert.AreEqual(message, readMessage); + } } } diff --git a/src/ProtocolBuffers.Test/TestProtos/UnitTestCSharpOptionsProtoFile.cs b/src/ProtocolBuffers.Test/TestProtos/UnitTestCSharpOptionsProtoFile.cs index 96ee6421de..341dcb2fd1 100644 --- a/src/ProtocolBuffers.Test/TestProtos/UnitTestCSharpOptionsProtoFile.cs +++ b/src/ProtocolBuffers.Test/TestProtos/UnitTestCSharpOptionsProtoFile.cs @@ -110,6 +110,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; if (HasNormal) { output.WriteString(1, Normal); } diff --git a/src/ProtocolBuffers.Test/TestProtos/UnitTestCustomOptionsProtoFile.cs b/src/ProtocolBuffers.Test/TestProtos/UnitTestCustomOptionsProtoFile.cs index d2c3800569..40ac8d3f55 100644 --- a/src/ProtocolBuffers.Test/TestProtos/UnitTestCustomOptionsProtoFile.cs +++ b/src/ProtocolBuffers.Test/TestProtos/UnitTestCustomOptionsProtoFile.cs @@ -432,6 +432,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; if (HasField1) { output.WriteString(1, Field1); } @@ -637,6 +638,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; UnknownFields.WriteTo(output); } @@ -810,6 +812,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; UnknownFields.WriteTo(output); } @@ -993,6 +996,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; UnknownFields.WriteTo(output); } @@ -1166,6 +1170,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; UnknownFields.WriteTo(output); } @@ -1339,6 +1344,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; UnknownFields.WriteTo(output); } @@ -1512,6 +1518,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; UnknownFields.WriteTo(output); } @@ -1685,6 +1692,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; UnknownFields.WriteTo(output); } @@ -1858,6 +1866,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; UnknownFields.WriteTo(output); } @@ -2031,6 +2040,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; UnknownFields.WriteTo(output); } @@ -2215,6 +2225,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); if (HasFoo) { output.WriteInt32(1, Foo); @@ -2459,6 +2470,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; if (HasWaldo) { output.WriteInt32(1, Waldo); } @@ -2678,6 +2690,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); if (HasBar) { output.WriteMessage(1, Bar); @@ -3028,6 +3041,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; if (HasPlugh) { output.WriteInt32(3, Plugh); } @@ -3233,6 +3247,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; if (HasQux) { output.WriteInt32(1, Qux); } @@ -3501,6 +3516,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; if (HasXyzzy) { output.WriteInt32(7593951, Xyzzy); } @@ -3705,6 +3721,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; UnknownFields.WriteTo(output); } diff --git a/src/ProtocolBuffers.Test/TestProtos/UnitTestEmbedOptimizeForProtoFile.cs b/src/ProtocolBuffers.Test/TestProtos/UnitTestEmbedOptimizeForProtoFile.cs index c498245dc9..f3e012ab8a 100644 --- a/src/ProtocolBuffers.Test/TestProtos/UnitTestEmbedOptimizeForProtoFile.cs +++ b/src/ProtocolBuffers.Test/TestProtos/UnitTestEmbedOptimizeForProtoFile.cs @@ -112,6 +112,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; if (HasOptionalMessage) { output.WriteMessage(1, OptionalMessage); } diff --git a/src/ProtocolBuffers.Test/TestProtos/UnitTestImportProtoFile.cs b/src/ProtocolBuffers.Test/TestProtos/UnitTestImportProtoFile.cs index 82dec7a6f7..43a98a4d17 100644 --- a/src/ProtocolBuffers.Test/TestProtos/UnitTestImportProtoFile.cs +++ b/src/ProtocolBuffers.Test/TestProtos/UnitTestImportProtoFile.cs @@ -99,6 +99,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; if (HasD) { output.WriteInt32(1, D); } diff --git a/src/ProtocolBuffers.Test/TestProtos/UnitTestMessageSetProtoFile.cs b/src/ProtocolBuffers.Test/TestProtos/UnitTestMessageSetProtoFile.cs index 177dc6968c..8b2a91171f 100644 --- a/src/ProtocolBuffers.Test/TestProtos/UnitTestMessageSetProtoFile.cs +++ b/src/ProtocolBuffers.Test/TestProtos/UnitTestMessageSetProtoFile.cs @@ -124,6 +124,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); extensionWriter.WriteUntil(536870912, output); UnknownFields.WriteAsMessageSetTo(output); @@ -311,6 +312,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; if (HasMessageSet) { output.WriteMessage(1, MessageSet); } @@ -550,6 +552,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; if (HasI) { output.WriteInt32(15, I); } @@ -766,6 +769,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; if (HasStr) { output.WriteString(25, Str); } @@ -1017,6 +1021,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; if (HasTypeId) { output.WriteInt32(2, TypeId); } @@ -1246,6 +1251,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; foreach (global::Google.ProtocolBuffers.TestProtos.RawMessageSet.Types.Item element in ItemList) { output.WriteGroup(1, element); } diff --git a/src/ProtocolBuffers.Test/TestProtos/UnitTestProtoFile.cs b/src/ProtocolBuffers.Test/TestProtos/UnitTestProtoFile.cs index 811556d833..40d1047b53 100644 --- a/src/ProtocolBuffers.Test/TestProtos/UnitTestProtoFile.cs +++ b/src/ProtocolBuffers.Test/TestProtos/UnitTestProtoFile.cs @@ -989,6 +989,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; if (HasBb) { output.WriteInt32(1, Bb); } @@ -1203,6 +1204,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; if (HasA) { output.WriteInt32(17, A); } @@ -1417,6 +1419,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; if (HasA) { output.WriteInt32(47, A); } @@ -2346,6 +2349,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; if (HasOptionalInt32) { output.WriteInt32(1, OptionalInt32); } @@ -5257,6 +5261,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; if (HasC) { output.WriteInt32(1, C); } @@ -5462,6 +5467,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); extensionWriter.WriteUntil(536870912, output); UnknownFields.WriteTo(output); @@ -5649,6 +5655,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; if (HasA) { output.WriteInt32(17, A); } @@ -5863,6 +5870,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; if (HasA) { output.WriteInt32(47, A); } @@ -6404,6 +6412,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; if (HasA) { output.WriteInt32(1, A); } @@ -7638,6 +7647,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; if (HasOptionalMessage) { output.WriteMessage(1, OptionalMessage); } @@ -7960,6 +7970,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; if (HasForeignNested) { output.WriteMessage(1, ForeignNested); } @@ -8187,6 +8198,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; UnknownFields.WriteTo(output); } @@ -8361,6 +8373,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); extensionWriter.WriteUntil(536870912, output); UnknownFields.WriteTo(output); @@ -8558,6 +8571,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; if (HasA) { output.WriteInt32(1, A); } @@ -8813,6 +8827,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; if (HasA) { output.WriteMessage(1, A); } @@ -9081,6 +9096,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; if (HasBb) { output.WriteMessage(1, Bb); } @@ -9328,6 +9344,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; if (HasA) { output.WriteMessage(1, A); } @@ -9620,6 +9637,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; if (HasA) { output.WriteInt32(1, A); } @@ -9834,6 +9852,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; if (HasA) { output.WriteInt32(1, A); } @@ -10049,6 +10068,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; if (HasA) { output.WriteInt32(1, A); } @@ -10409,6 +10429,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; if (nestedmessageRepeatedInt32_.Count > 0) { foreach (int element in nestedmessageRepeatedInt32_) { output.WriteInt32(1, element); @@ -10674,6 +10695,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; if (HasOptionalNestedMessage) { output.WriteMessage(1, OptionalNestedMessage); } @@ -11033,6 +11055,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; if (HasPrimitiveField) { output.WriteInt32(1, PrimitiveField); } @@ -11762,6 +11785,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); if (HasMyInt) { output.WriteInt64(1, MyInt); @@ -12096,6 +12120,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; if (HasEscapedBytes) { output.WriteBytes(1, EscapedBytes); } @@ -12651,6 +12676,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; if (packedInt32_.Count > 0) { output.WriteRawVarint32(722); output.WriteRawVarint32((uint) packedInt32MemoizedSerializedSize); @@ -13638,6 +13664,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); extensionWriter.WriteUntil(536870912, output); UnknownFields.WriteTo(output); @@ -13815,6 +13842,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; UnknownFields.WriteTo(output); } @@ -13988,6 +14016,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; UnknownFields.WriteTo(output); } @@ -14161,6 +14190,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; UnknownFields.WriteTo(output); } @@ -14334,6 +14364,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; UnknownFields.WriteTo(output); } diff --git a/src/ProtocolBuffers/DescriptorProtos/CSharpOptions.cs b/src/ProtocolBuffers/DescriptorProtos/CSharpOptions.cs index b589a60ce7..a662b1ad02 100644 --- a/src/ProtocolBuffers/DescriptorProtos/CSharpOptions.cs +++ b/src/ProtocolBuffers/DescriptorProtos/CSharpOptions.cs @@ -169,6 +169,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; if (HasNamespace) { output.WriteString(1, Namespace); } @@ -571,6 +572,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; if (HasPropertyName) { output.WriteString(1, PropertyName); } diff --git a/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs b/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs index 3da610364a..0c6be67114 100644 --- a/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs +++ b/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs @@ -264,6 +264,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; foreach (global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorProto element in FileList) { output.WriteMessage(1, element); } @@ -596,6 +597,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; if (HasName) { output.WriteString(1, Name); } @@ -1196,6 +1198,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; if (HasStart) { output.WriteInt32(1, Start); } @@ -1507,6 +1510,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; if (HasName) { output.WriteString(1, Name); } @@ -2151,6 +2155,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; if (HasName) { output.WriteString(1, Name); } @@ -2653,6 +2658,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; if (HasName) { output.WriteString(1, Name); } @@ -2999,6 +3005,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; if (HasName) { output.WriteString(1, Name); } @@ -3327,6 +3334,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; if (HasName) { output.WriteString(1, Name); } @@ -3683,6 +3691,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; if (HasName) { output.WriteString(1, Name); } @@ -4072,6 +4081,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); if (HasJavaPackage) { output.WriteString(1, JavaPackage); @@ -4463,6 +4473,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); if (HasMessageSetWireFormat) { output.WriteBool(1, MessageSetWireFormat); @@ -4791,6 +4802,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); if (HasCtype) { output.WriteEnum(1, (int) Ctype); @@ -5171,6 +5183,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); foreach (global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption element in UninterpretedOptionList) { output.WriteMessage(999, element); @@ -5418,6 +5431,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); foreach (global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption element in UninterpretedOptionList) { output.WriteMessage(999, element); @@ -5665,6 +5679,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); foreach (global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption element in UninterpretedOptionList) { output.WriteMessage(999, element); @@ -5912,6 +5927,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); foreach (global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption element in UninterpretedOptionList) { output.WriteMessage(999, element); @@ -6189,6 +6205,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; if (HasNamePart_) { output.WriteString(1, NamePart_); } @@ -6472,6 +6489,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override void WriteTo(pb::CodedOutputStream output) { + int size = SerializedSize; foreach (global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Types.NamePart element in NameList) { output.WriteMessage(2, element); }