Commit 90922db7 authored by csharptest's avatar csharptest Committed by rogerk

Added the field name to all CodedOutputStream.Write??? calls

Refactored 'speed' generated write of arrays to call Write???Array.  This may
have impacted speed write speeds for arrays of non-reference types due to the
use of non-generic IEnumerable and the subsequent boxing of value types.  This
could be addressed later if desired.
parent 8a2d0f48
@echo off @echo off
%WINDIR%\Microsoft.NET\Framework\v4.0.30319\msbuild build.csproj /m /t:RunBenchmarks /p:BuildConfiguration=Release /p:Platform="Any CPU" %WINDIR%\Microsoft.NET\Framework\v4.0.30319\msbuild %~dp0\build.csproj /m /t:RunBenchmarks /p:BuildConfiguration=Release /p:Platform="Any CPU"
pause pause
\ No newline at end of file
...@@ -155,10 +155,10 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { ...@@ -155,10 +155,10 @@ namespace Google.ProtocolBuffers.Examples.AddressBook {
public override void WriteTo(pb::CodedOutputStream output) { public override void WriteTo(pb::CodedOutputStream output) {
int size = SerializedSize; int size = SerializedSize;
if (HasNumber) { if (HasNumber) {
output.WriteString(1, Number); output.WriteString(1, "number", Number);
} }
if (HasType) { if (HasType) {
output.WriteEnum(2, (int) Type); output.WriteEnum(2, "type", (int) Type, Type.ToString());
} }
UnknownFields.WriteTo(output); UnknownFields.WriteTo(output);
} }
...@@ -431,16 +431,16 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { ...@@ -431,16 +431,16 @@ namespace Google.ProtocolBuffers.Examples.AddressBook {
public override void WriteTo(pb::CodedOutputStream output) { public override void WriteTo(pb::CodedOutputStream output) {
int size = SerializedSize; int size = SerializedSize;
if (HasName) { if (HasName) {
output.WriteString(1, Name); output.WriteString(1, "name", Name);
} }
if (HasId) { if (HasId) {
output.WriteInt32(2, Id); output.WriteInt32(2, "id", Id);
} }
if (HasEmail) { if (HasEmail) {
output.WriteString(3, Email); output.WriteString(3, "email", Email);
} }
foreach (global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneNumber element in PhoneList) { if (phone_.Count > 0) {
output.WriteMessage(4, element); output.WriteMessageArray(4, "phone", phone_);
} }
UnknownFields.WriteTo(output); UnknownFields.WriteTo(output);
} }
...@@ -774,8 +774,8 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { ...@@ -774,8 +774,8 @@ namespace Google.ProtocolBuffers.Examples.AddressBook {
public override void WriteTo(pb::CodedOutputStream output) { public override void WriteTo(pb::CodedOutputStream output) {
int size = SerializedSize; int size = SerializedSize;
foreach (global::Google.ProtocolBuffers.Examples.AddressBook.Person element in PersonList) { if (person_.Count > 0) {
output.WriteMessage(1, element); output.WriteMessageArray(1, "person", person_);
} }
UnknownFields.WriteTo(output); UnknownFields.WriteTo(output);
} }
......
...@@ -113,7 +113,7 @@ namespace Google.ProtocolBuffers.ProtoGen ...@@ -113,7 +113,7 @@ namespace Google.ProtocolBuffers.ProtoGen
public void GenerateSerializationCode(TextGenerator writer) public void GenerateSerializationCode(TextGenerator writer)
{ {
writer.WriteLine("if (Has{0}) {{", PropertyName); writer.WriteLine("if (Has{0}) {{", PropertyName);
writer.WriteLine(" output.WriteEnum({0}, (int) {1});", Number, PropertyName); writer.WriteLine(" output.WriteEnum({0}, \"{2}\", (int) {1}, {1}.ToString());", Number, PropertyName, Descriptor.Name);
writer.WriteLine("}"); writer.WriteLine("}");
} }
......
...@@ -129,7 +129,7 @@ namespace Google.ProtocolBuffers.ProtoGen ...@@ -129,7 +129,7 @@ namespace Google.ProtocolBuffers.ProtoGen
public void GenerateSerializationCode(TextGenerator writer) public void GenerateSerializationCode(TextGenerator writer)
{ {
writer.WriteLine("if (Has{0}) {{", PropertyName); writer.WriteLine("if (Has{0}) {{", PropertyName);
writer.WriteLine(" output.Write{0}({1}, {2});", MessageOrGroup, Number, PropertyName); writer.WriteLine(" output.Write{0}({1}, \"{3}\", {2});", MessageOrGroup, Number, PropertyName, Descriptor.Name);
writer.WriteLine("}"); writer.WriteLine("}");
} }
......
...@@ -103,7 +103,7 @@ namespace Google.ProtocolBuffers.ProtoGen ...@@ -103,7 +103,7 @@ namespace Google.ProtocolBuffers.ProtoGen
public void GenerateSerializationCode(TextGenerator writer) public void GenerateSerializationCode(TextGenerator writer)
{ {
writer.WriteLine("if (Has{0}) {{", PropertyName); writer.WriteLine("if (Has{0}) {{", PropertyName);
writer.WriteLine(" output.Write{0}({1}, {2});", CapitalizedTypeName, Number, PropertyName); writer.WriteLine(" output.Write{0}({1}, \"{3}\", {2});", CapitalizedTypeName, Number, PropertyName, Descriptor.Name);
writer.WriteLine("}"); writer.WriteLine("}");
} }
......
...@@ -149,19 +149,23 @@ namespace Google.ProtocolBuffers.ProtoGen ...@@ -149,19 +149,23 @@ namespace Google.ProtocolBuffers.ProtoGen
writer.WriteLine("if ({0}_.Count > 0) {{", Name); writer.WriteLine("if ({0}_.Count > 0) {{", Name);
writer.Indent(); writer.Indent();
if (Descriptor.IsPacked) if (Descriptor.IsPacked)
{ writer.WriteLine("output.WritePackedArray(pbd::FieldType.{3}, {0}, \"{2}\", {1}MemoizedSerializedSize, {1}_);", Number, Name, Descriptor.Name, Descriptor.FieldType);
writer.WriteLine("output.WriteRawVarint32({0});", WireFormat.MakeTag(Descriptor));
writer.WriteLine("output.WriteRawVarint32((uint) {0}MemoizedSerializedSize);", Name);
writer.WriteLine("foreach (int element in {0}_) {{", Name);
writer.WriteLine(" output.WriteEnumNoTag(element);");
writer.WriteLine("}");
}
else else
{ writer.WriteLine("output.WriteArray(pbd::FieldType.{3}, {0}, \"{2}\", {1}_);", Number, Name, Descriptor.Name, Descriptor.FieldType);
writer.WriteLine("foreach (int element in {0}_) {{", Name); //if (Descriptor.IsPacked)
writer.WriteLine(" output.WriteEnum({0}, element);", Number); //{
writer.WriteLine("}"); // writer.WriteLine("output.WriteRawVarint32({0});", WireFormat.MakeTag(Descriptor));
} // writer.WriteLine("output.WriteRawVarint32((uint) {0}MemoizedSerializedSize);", Name);
// writer.WriteLine("foreach (int element in {0}_) {{", Name);
// writer.WriteLine(" output.WriteEnumNoTag(element);");
// writer.WriteLine("}");
//}
//else
//{
// writer.WriteLine("foreach (int element in {0}_) {{", Name);
// writer.WriteLine(" output.WriteEnum({0}, element);", Number);
// writer.WriteLine("}");
//}
writer.Outdent(); writer.Outdent();
writer.WriteLine("}"); writer.WriteLine("}");
} }
......
...@@ -135,8 +135,13 @@ namespace Google.ProtocolBuffers.ProtoGen ...@@ -135,8 +135,13 @@ namespace Google.ProtocolBuffers.ProtoGen
public void GenerateSerializationCode(TextGenerator writer) public void GenerateSerializationCode(TextGenerator writer)
{ {
writer.WriteLine("foreach ({0} element in {1}List) {{", TypeName, PropertyName); writer.WriteLine("if ({0}_.Count > 0) {{", Name);
writer.WriteLine(" output.Write{0}({1}, element);", MessageOrGroup, Number); writer.Indent();
writer.WriteLine("output.Write{0}Array({1}, \"{3}\", {2}_);", MessageOrGroup, Number, Name, Descriptor.Name);
//writer.WriteLine("foreach ({0} element in {1}List) {{", TypeName, PropertyName);
//writer.WriteLine(" output.Write{0}({1}, element);", MessageOrGroup, Number);
//writer.WriteLine("}");
writer.Outdent();
writer.WriteLine("}"); writer.WriteLine("}");
} }
......
...@@ -141,19 +141,23 @@ namespace Google.ProtocolBuffers.ProtoGen ...@@ -141,19 +141,23 @@ namespace Google.ProtocolBuffers.ProtoGen
writer.WriteLine("if ({0}_.Count > 0) {{", Name); writer.WriteLine("if ({0}_.Count > 0) {{", Name);
writer.Indent(); writer.Indent();
if (Descriptor.IsPacked) if (Descriptor.IsPacked)
{ writer.WriteLine("output.WritePackedArray(pbd::FieldType.{3}, {0}, \"{2}\", {1}MemoizedSerializedSize, {1}_);", Number, Name, Descriptor.Name, Descriptor.FieldType);
writer.WriteLine("output.WriteRawVarint32({0});", WireFormat.MakeTag(Descriptor));
writer.WriteLine("output.WriteRawVarint32((uint) {0}MemoizedSerializedSize);", Name);
writer.WriteLine("foreach ({0} element in {1}_) {{", TypeName, Name);
writer.WriteLine(" output.Write{0}NoTag(element);", CapitalizedTypeName);
writer.WriteLine("}");
}
else else
{ writer.WriteLine("output.WriteArray(pbd::FieldType.{3}, {0}, \"{2}\", {1}_);", Number, Name, Descriptor.Name, Descriptor.FieldType);
writer.WriteLine("foreach ({0} element in {1}_) {{", TypeName, Name); //if (Descriptor.IsPacked)
writer.WriteLine(" output.Write{0}({1}, element);", CapitalizedTypeName, Number); //{
writer.WriteLine("}"); // writer.WriteLine("output.WriteRawVarint32({0});", WireFormat.MakeTag(Descriptor));
} // writer.WriteLine("output.WriteRawVarint32((uint) {0}MemoizedSerializedSize);", Name);
// writer.WriteLine("foreach ({0} element in {1}_) {{", TypeName, Name);
// writer.WriteLine(" output.Write{0}NoTag(element);", CapitalizedTypeName);
// writer.WriteLine("}");
//}
//else
//{
// writer.WriteLine("foreach ({0} element in {1}_) {{", TypeName, Name);
// writer.WriteLine(" output.Write{0}({1}, element);", CapitalizedTypeName, Number);
// writer.WriteLine("}");
//}
writer.Outdent(); writer.Outdent();
writer.WriteLine("}"); writer.WriteLine("}");
} }
......
...@@ -118,13 +118,13 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -118,13 +118,13 @@ namespace Google.ProtocolBuffers.TestProtos {
public override void WriteTo(pb::CodedOutputStream output) { public override void WriteTo(pb::CodedOutputStream output) {
int size = SerializedSize; int size = SerializedSize;
if (HasNormal) { if (HasNormal) {
output.WriteString(1, Normal); output.WriteString(1, "normal", Normal);
} }
if (HasOptionsMessage_) { if (HasOptionsMessage_) {
output.WriteString(2, OptionsMessage_); output.WriteString(2, "options_message", OptionsMessage_);
} }
if (HasCustomName) { if (HasCustomName) {
output.WriteString(3, CustomName); output.WriteString(3, "customized", CustomName);
} }
UnknownFields.WriteTo(output); UnknownFields.WriteTo(output);
} }
......
...@@ -453,7 +453,7 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -453,7 +453,7 @@ namespace Google.ProtocolBuffers.TestProtos {
public override void WriteTo(pb::CodedOutputStream output) { public override void WriteTo(pb::CodedOutputStream output) {
int size = SerializedSize; int size = SerializedSize;
if (HasField1) { if (HasField1) {
output.WriteString(1, Field1); output.WriteString(1, "field1", Field1);
} }
UnknownFields.WriteTo(output); UnknownFields.WriteTo(output);
} }
...@@ -2332,13 +2332,13 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -2332,13 +2332,13 @@ namespace Google.ProtocolBuffers.TestProtos {
int size = SerializedSize; int size = SerializedSize;
pb::ExtendableMessage<ComplexOptionType1, ComplexOptionType1.Builder>.ExtensionWriter extensionWriter = CreateExtensionWriter(this); pb::ExtendableMessage<ComplexOptionType1, ComplexOptionType1.Builder>.ExtensionWriter extensionWriter = CreateExtensionWriter(this);
if (HasFoo) { if (HasFoo) {
output.WriteInt32(1, Foo); output.WriteInt32(1, "foo", Foo);
} }
if (HasFoo2) { if (HasFoo2) {
output.WriteInt32(2, Foo2); output.WriteInt32(2, "foo2", Foo2);
} }
if (HasFoo3) { if (HasFoo3) {
output.WriteInt32(3, Foo3); output.WriteInt32(3, "foo3", Foo3);
} }
extensionWriter.WriteUntil(536870912, output); extensionWriter.WriteUntil(536870912, output);
UnknownFields.WriteTo(output); UnknownFields.WriteTo(output);
...@@ -2650,7 +2650,7 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -2650,7 +2650,7 @@ namespace Google.ProtocolBuffers.TestProtos {
public override void WriteTo(pb::CodedOutputStream output) { public override void WriteTo(pb::CodedOutputStream output) {
int size = SerializedSize; int size = SerializedSize;
if (HasWaldo) { if (HasWaldo) {
output.WriteInt32(1, Waldo); output.WriteInt32(1, "waldo", Waldo);
} }
UnknownFields.WriteTo(output); UnknownFields.WriteTo(output);
} }
...@@ -2874,13 +2874,13 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -2874,13 +2874,13 @@ namespace Google.ProtocolBuffers.TestProtos {
int size = SerializedSize; int size = SerializedSize;
pb::ExtendableMessage<ComplexOptionType2, ComplexOptionType2.Builder>.ExtensionWriter extensionWriter = CreateExtensionWriter(this); pb::ExtendableMessage<ComplexOptionType2, ComplexOptionType2.Builder>.ExtensionWriter extensionWriter = CreateExtensionWriter(this);
if (HasBar) { if (HasBar) {
output.WriteMessage(1, Bar); output.WriteMessage(1, "bar", Bar);
} }
if (HasBaz) { if (HasBaz) {
output.WriteInt32(2, Baz); output.WriteInt32(2, "baz", Baz);
} }
if (HasFred) { if (HasFred) {
output.WriteMessage(3, Fred); output.WriteMessage(3, "fred", Fred);
} }
extensionWriter.WriteUntil(536870912, output); extensionWriter.WriteUntil(536870912, output);
UnknownFields.WriteTo(output); UnknownFields.WriteTo(output);
...@@ -3236,7 +3236,7 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -3236,7 +3236,7 @@ namespace Google.ProtocolBuffers.TestProtos {
public override void WriteTo(pb::CodedOutputStream output) { public override void WriteTo(pb::CodedOutputStream output) {
int size = SerializedSize; int size = SerializedSize;
if (HasPlugh) { if (HasPlugh) {
output.WriteInt32(3, Plugh); output.WriteInt32(3, "plugh", Plugh);
} }
UnknownFields.WriteTo(output); UnknownFields.WriteTo(output);
} }
...@@ -3445,10 +3445,10 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -3445,10 +3445,10 @@ namespace Google.ProtocolBuffers.TestProtos {
public override void WriteTo(pb::CodedOutputStream output) { public override void WriteTo(pb::CodedOutputStream output) {
int size = SerializedSize; int size = SerializedSize;
if (HasQux) { if (HasQux) {
output.WriteInt32(1, Qux); output.WriteInt32(1, "qux", Qux);
} }
if (HasComplexOptionType5) { if (HasComplexOptionType5) {
output.WriteGroup(2, ComplexOptionType5); output.WriteGroup(2, "complexoptiontype5", ComplexOptionType5);
} }
UnknownFields.WriteTo(output); UnknownFields.WriteTo(output);
} }
...@@ -3720,7 +3720,7 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -3720,7 +3720,7 @@ namespace Google.ProtocolBuffers.TestProtos {
public override void WriteTo(pb::CodedOutputStream output) { public override void WriteTo(pb::CodedOutputStream output) {
int size = SerializedSize; int size = SerializedSize;
if (HasXyzzy) { if (HasXyzzy) {
output.WriteInt32(7593951, Xyzzy); output.WriteInt32(7593951, "xyzzy", Xyzzy);
} }
UnknownFields.WriteTo(output); UnknownFields.WriteTo(output);
} }
......
...@@ -120,10 +120,10 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -120,10 +120,10 @@ namespace Google.ProtocolBuffers.TestProtos {
public override void WriteTo(pb::CodedOutputStream output) { public override void WriteTo(pb::CodedOutputStream output) {
int size = SerializedSize; int size = SerializedSize;
if (HasOptionalMessage) { if (HasOptionalMessage) {
output.WriteMessage(1, OptionalMessage); output.WriteMessage(1, "optional_message", OptionalMessage);
} }
foreach (global::Google.ProtocolBuffers.TestProtos.TestOptimizedForSize element in RepeatedMessageList) { if (repeatedMessage_.Count > 0) {
output.WriteMessage(2, element); output.WriteMessageArray(2, "repeated_message", repeatedMessage_);
} }
UnknownFields.WriteTo(output); UnknownFields.WriteTo(output);
} }
......
...@@ -73,7 +73,7 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -73,7 +73,7 @@ namespace Google.ProtocolBuffers.TestProtos {
public override void WriteTo(pb::CodedOutputStream output) { public override void WriteTo(pb::CodedOutputStream output) {
int size = SerializedSize; int size = SerializedSize;
if (HasD) { if (HasD) {
output.WriteInt32(1, D); output.WriteInt32(1, "d", D);
} }
} }
......
...@@ -109,7 +109,7 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -109,7 +109,7 @@ namespace Google.ProtocolBuffers.TestProtos {
public override void WriteTo(pb::CodedOutputStream output) { public override void WriteTo(pb::CodedOutputStream output) {
int size = SerializedSize; int size = SerializedSize;
if (HasD) { if (HasD) {
output.WriteInt32(1, D); output.WriteInt32(1, "d", D);
} }
UnknownFields.WriteTo(output); UnknownFields.WriteTo(output);
} }
......
...@@ -326,7 +326,7 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -326,7 +326,7 @@ namespace Google.ProtocolBuffers.TestProtos {
public override void WriteTo(pb::CodedOutputStream output) { public override void WriteTo(pb::CodedOutputStream output) {
int size = SerializedSize; int size = SerializedSize;
if (HasMessageSet) { if (HasMessageSet) {
output.WriteMessage(1, MessageSet); output.WriteMessage(1, "message_set", MessageSet);
} }
UnknownFields.WriteTo(output); UnknownFields.WriteTo(output);
} }
...@@ -572,7 +572,7 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -572,7 +572,7 @@ namespace Google.ProtocolBuffers.TestProtos {
public override void WriteTo(pb::CodedOutputStream output) { public override void WriteTo(pb::CodedOutputStream output) {
int size = SerializedSize; int size = SerializedSize;
if (HasI) { if (HasI) {
output.WriteInt32(15, I); output.WriteInt32(15, "i", I);
} }
UnknownFields.WriteTo(output); UnknownFields.WriteTo(output);
} }
...@@ -795,7 +795,7 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -795,7 +795,7 @@ namespace Google.ProtocolBuffers.TestProtos {
public override void WriteTo(pb::CodedOutputStream output) { public override void WriteTo(pb::CodedOutputStream output) {
int size = SerializedSize; int size = SerializedSize;
if (HasStr) { if (HasStr) {
output.WriteString(25, Str); output.WriteString(25, "str", Str);
} }
UnknownFields.WriteTo(output); UnknownFields.WriteTo(output);
} }
...@@ -1059,10 +1059,10 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -1059,10 +1059,10 @@ namespace Google.ProtocolBuffers.TestProtos {
public override void WriteTo(pb::CodedOutputStream output) { public override void WriteTo(pb::CodedOutputStream output) {
int size = SerializedSize; int size = SerializedSize;
if (HasTypeId) { if (HasTypeId) {
output.WriteInt32(2, TypeId); output.WriteInt32(2, "type_id", TypeId);
} }
if (HasMessage) { if (HasMessage) {
output.WriteBytes(3, Message); output.WriteBytes(3, "message", Message);
} }
UnknownFields.WriteTo(output); UnknownFields.WriteTo(output);
} }
...@@ -1291,8 +1291,8 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -1291,8 +1291,8 @@ namespace Google.ProtocolBuffers.TestProtos {
public override void WriteTo(pb::CodedOutputStream output) { public override void WriteTo(pb::CodedOutputStream output) {
int size = SerializedSize; int size = SerializedSize;
foreach (global::Google.ProtocolBuffers.TestProtos.RawMessageSet.Types.Item element in ItemList) { if (item_.Count > 0) {
output.WriteGroup(1, element); output.WriteGroupArray(1, "item", item_);
} }
UnknownFields.WriteTo(output); UnknownFields.WriteTo(output);
} }
......
...@@ -121,7 +121,7 @@ namespace Google.ProtocolBuffers.TestProtos.NoGenericService { ...@@ -121,7 +121,7 @@ namespace Google.ProtocolBuffers.TestProtos.NoGenericService {
int size = SerializedSize; int size = SerializedSize;
pb::ExtendableMessage<TestMessage, TestMessage.Builder>.ExtensionWriter extensionWriter = CreateExtensionWriter(this); pb::ExtendableMessage<TestMessage, TestMessage.Builder>.ExtensionWriter extensionWriter = CreateExtensionWriter(this);
if (HasA) { if (HasA) {
output.WriteInt32(1, A); output.WriteInt32(1, "a", A);
} }
extensionWriter.WriteUntil(536870912, output); extensionWriter.WriteUntil(536870912, output);
UnknownFields.WriteTo(output); UnknownFields.WriteTo(output);
......
...@@ -123,9 +123,7 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -123,9 +123,7 @@ namespace Google.ProtocolBuffers.TestProtos {
public override void WriteTo(pb::CodedOutputStream output) { public override void WriteTo(pb::CodedOutputStream output) {
int size = SerializedSize; int size = SerializedSize;
if (criteria_.Count > 0) { if (criteria_.Count > 0) {
foreach (string element in criteria_) { output.WriteArray(pbd::FieldType.String, 1, "Criteria", criteria_);
output.WriteString(1, element);
}
} }
UnknownFields.WriteTo(output); UnknownFields.WriteTo(output);
} }
...@@ -403,10 +401,10 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -403,10 +401,10 @@ namespace Google.ProtocolBuffers.TestProtos {
public override void WriteTo(pb::CodedOutputStream output) { public override void WriteTo(pb::CodedOutputStream output) {
int size = SerializedSize; int size = SerializedSize;
if (HasUrl) { if (HasUrl) {
output.WriteString(1, Url); output.WriteString(1, "url", Url);
} }
if (HasName) { if (HasName) {
output.WriteString(2, Name); output.WriteString(2, "name", Name);
} }
UnknownFields.WriteTo(output); UnknownFields.WriteTo(output);
} }
...@@ -639,8 +637,8 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -639,8 +637,8 @@ namespace Google.ProtocolBuffers.TestProtos {
public override void WriteTo(pb::CodedOutputStream output) { public override void WriteTo(pb::CodedOutputStream output) {
int size = SerializedSize; int size = SerializedSize;
foreach (global::Google.ProtocolBuffers.TestProtos.SearchResponse.Types.ResultItem element in ResultsList) { if (results_.Count > 0) {
output.WriteMessage(1, element); output.WriteMessageArray(1, "results", results_);
} }
UnknownFields.WriteTo(output); UnknownFields.WriteTo(output);
} }
...@@ -898,12 +896,10 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -898,12 +896,10 @@ namespace Google.ProtocolBuffers.TestProtos {
public override void WriteTo(pb::CodedOutputStream output) { public override void WriteTo(pb::CodedOutputStream output) {
int size = SerializedSize; int size = SerializedSize;
if (criteria_.Count > 0) { if (criteria_.Count > 0) {
foreach (string element in criteria_) { output.WriteArray(pbd::FieldType.String, 1, "Criteria", criteria_);
output.WriteString(1, element);
}
} }
if (HasPreviousResults) { if (HasPreviousResults) {
output.WriteMessage(2, PreviousResults); output.WriteMessage(2, "previous_results", PreviousResults);
} }
UnknownFields.WriteTo(output); UnknownFields.WriteTo(output);
} }
......
...@@ -180,12 +180,10 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -180,12 +180,10 @@ namespace Google.ProtocolBuffers.TestProtos {
public override void WriteTo(pb::CodedOutputStream output) { public override void WriteTo(pb::CodedOutputStream output) {
int size = SerializedSize; int size = SerializedSize;
if (options_.Count > 0) { if (options_.Count > 0) {
foreach (int element in options_) { output.WriteArray(pbd::FieldType.Enum, 3, "options", options_);
output.WriteEnum(3, element);
}
} }
if (HasBinary) { if (HasBinary) {
output.WriteBytes(4, Binary); output.WriteBytes(4, "binary", Binary);
} }
UnknownFields.WriteTo(output); UnknownFields.WriteTo(output);
} }
...@@ -681,12 +679,10 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -681,12 +679,10 @@ namespace Google.ProtocolBuffers.TestProtos {
public override void WriteTo(pb::CodedOutputStream output) { public override void WriteTo(pb::CodedOutputStream output) {
int size = SerializedSize; int size = SerializedSize;
if (options_.Count > 0) { if (options_.Count > 0) {
foreach (int element in options_) { output.WriteArray(pbd::FieldType.Enum, 3, "options", options_);
output.WriteEnum(3, element);
}
} }
if (HasBinary) { if (HasBinary) {
output.WriteBytes(4, Binary); output.WriteBytes(4, "binary", Binary);
} }
UnknownFields.WriteTo(output); UnknownFields.WriteTo(output);
} }
...@@ -1006,30 +1002,26 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -1006,30 +1002,26 @@ namespace Google.ProtocolBuffers.TestProtos {
int size = SerializedSize; int size = SerializedSize;
pb::ExtendableMessage<TestXmlMessage, TestXmlMessage.Builder>.ExtensionWriter extensionWriter = CreateExtensionWriter(this); pb::ExtendableMessage<TestXmlMessage, TestXmlMessage.Builder>.ExtensionWriter extensionWriter = CreateExtensionWriter(this);
if (HasChild) { if (HasChild) {
output.WriteMessage(1, Child); output.WriteMessage(1, "child", Child);
} }
if (numbers_.Count > 0) { if (numbers_.Count > 0) {
foreach (int element in numbers_) { output.WriteArray(pbd::FieldType.Int32, 2, "numbers", numbers_);
output.WriteInt32(2, element);
}
} }
if (HasText) { if (HasText) {
output.WriteString(3, Text); output.WriteString(3, "text", Text);
} }
if (HasValid) { if (HasValid) {
output.WriteBool(5, Valid); output.WriteBool(5, "valid", Valid);
} }
if (HasNumber) { if (HasNumber) {
output.WriteInt64(6, Number); output.WriteInt64(6, "number", Number);
} }
extensionWriter.WriteUntil(200, output); extensionWriter.WriteUntil(200, output);
foreach (global::Google.ProtocolBuffers.TestProtos.TestXmlMessage.Types.Children element in ChildrenList) { if (children_.Count > 0) {
output.WriteGroup(401, element); output.WriteGroupArray(401, "children", children_);
} }
if (textlines_.Count > 0) { if (textlines_.Count > 0) {
foreach (string element in textlines_) { output.WriteArray(pbd::FieldType.String, 700, "textlines", textlines_);
output.WriteString(700, element);
}
} }
UnknownFields.WriteTo(output); UnknownFields.WriteTo(output);
} }
...@@ -1498,7 +1490,7 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -1498,7 +1490,7 @@ namespace Google.ProtocolBuffers.TestProtos {
public override void WriteTo(pb::CodedOutputStream output) { public override void WriteTo(pb::CodedOutputStream output) {
int size = SerializedSize; int size = SerializedSize;
if (HasNumber) { if (HasNumber) {
output.WriteInt32(1, Number); output.WriteInt32(1, "number", Number);
} }
UnknownFields.WriteTo(output); UnknownFields.WriteTo(output);
} }
......
...@@ -166,13 +166,13 @@ namespace Google.ProtocolBuffers ...@@ -166,13 +166,13 @@ namespace Google.ProtocolBuffers
{ {
foreach (object element in valueList) foreach (object element in valueList)
{ {
output.WriteField(field.FieldType, field.FieldNumber, element); output.WriteField(field.FieldType, field.FieldNumber, field.Name, element);
} }
} }
} }
else else
{ {
output.WriteField(field.FieldType, field.FieldNumber, entry.Value); output.WriteField(field.FieldType, field.FieldNumber, field.Name, entry.Value);
} }
} }
......
This diff is collapsed.
...@@ -283,43 +283,43 @@ namespace Google.ProtocolBuffers.DescriptorProtos { ...@@ -283,43 +283,43 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
public override void WriteTo(pb::CodedOutputStream output) { public override void WriteTo(pb::CodedOutputStream output) {
int size = SerializedSize; int size = SerializedSize;
if (HasNamespace) { if (HasNamespace) {
output.WriteString(1, Namespace); output.WriteString(1, "namespace", Namespace);
} }
if (HasUmbrellaClassname) { if (HasUmbrellaClassname) {
output.WriteString(2, UmbrellaClassname); output.WriteString(2, "umbrella_classname", UmbrellaClassname);
} }
if (HasPublicClasses) { if (HasPublicClasses) {
output.WriteBool(3, PublicClasses); output.WriteBool(3, "public_classes", PublicClasses);
} }
if (HasMultipleFiles) { if (HasMultipleFiles) {
output.WriteBool(4, MultipleFiles); output.WriteBool(4, "multiple_files", MultipleFiles);
} }
if (HasNestClasses) { if (HasNestClasses) {
output.WriteBool(5, NestClasses); output.WriteBool(5, "nest_classes", NestClasses);
} }
if (HasCodeContracts) { if (HasCodeContracts) {
output.WriteBool(6, CodeContracts); output.WriteBool(6, "code_contracts", CodeContracts);
} }
if (HasExpandNamespaceDirectories) { if (HasExpandNamespaceDirectories) {
output.WriteBool(7, ExpandNamespaceDirectories); output.WriteBool(7, "expand_namespace_directories", ExpandNamespaceDirectories);
} }
if (HasClsCompliance) { if (HasClsCompliance) {
output.WriteBool(8, ClsCompliance); output.WriteBool(8, "cls_compliance", ClsCompliance);
} }
if (HasFileExtension) { if (HasFileExtension) {
output.WriteString(221, FileExtension); output.WriteString(221, "file_extension", FileExtension);
} }
if (HasUmbrellaNamespace) { if (HasUmbrellaNamespace) {
output.WriteString(222, UmbrellaNamespace); output.WriteString(222, "umbrella_namespace", UmbrellaNamespace);
} }
if (HasOutputDirectory) { if (HasOutputDirectory) {
output.WriteString(223, OutputDirectory); output.WriteString(223, "output_directory", OutputDirectory);
} }
if (HasIgnoreGoogleProtobuf) { if (HasIgnoreGoogleProtobuf) {
output.WriteBool(224, IgnoreGoogleProtobuf); output.WriteBool(224, "ignore_google_protobuf", IgnoreGoogleProtobuf);
} }
if (HasServiceGeneratorType) { if (HasServiceGeneratorType) {
output.WriteEnum(225, (int) ServiceGeneratorType); output.WriteEnum(225, "service_generator_type", (int) ServiceGeneratorType, ServiceGeneratorType.ToString());
} }
UnknownFields.WriteTo(output); UnknownFields.WriteTo(output);
} }
...@@ -889,7 +889,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { ...@@ -889,7 +889,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
public override void WriteTo(pb::CodedOutputStream output) { public override void WriteTo(pb::CodedOutputStream output) {
int size = SerializedSize; int size = SerializedSize;
if (HasPropertyName) { if (HasPropertyName) {
output.WriteString(1, PropertyName); output.WriteString(1, "property_name", PropertyName);
} }
UnknownFields.WriteTo(output); UnknownFields.WriteTo(output);
} }
...@@ -1111,7 +1111,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { ...@@ -1111,7 +1111,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
public override void WriteTo(pb::CodedOutputStream output) { public override void WriteTo(pb::CodedOutputStream output) {
int size = SerializedSize; int size = SerializedSize;
if (HasInterfaceId) { if (HasInterfaceId) {
output.WriteString(1, InterfaceId); output.WriteString(1, "interface_id", InterfaceId);
} }
UnknownFields.WriteTo(output); UnknownFields.WriteTo(output);
} }
...@@ -1333,7 +1333,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { ...@@ -1333,7 +1333,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
public override void WriteTo(pb::CodedOutputStream output) { public override void WriteTo(pb::CodedOutputStream output) {
int size = SerializedSize; int size = SerializedSize;
if (HasDispatchId) { if (HasDispatchId) {
output.WriteInt32(1, DispatchId); output.WriteInt32(1, "dispatch_id", DispatchId);
} }
UnknownFields.WriteTo(output); UnknownFields.WriteTo(output);
} }
......
...@@ -470,7 +470,7 @@ namespace Google.ProtocolBuffers ...@@ -470,7 +470,7 @@ namespace Google.ProtocolBuffers
{ {
if (field.IsExtension && field.MessageSetWireFormat) if (field.IsExtension && field.MessageSetWireFormat)
{ {
output.WriteMessageSetExtension(field.FieldNumber, (IMessageLite) value); output.WriteMessageSetExtension(field.FieldNumber, field.Name, (IMessageLite)value);
} }
else else
{ {
...@@ -497,13 +497,13 @@ namespace Google.ProtocolBuffers ...@@ -497,13 +497,13 @@ namespace Google.ProtocolBuffers
{ {
foreach (object element in valueList) foreach (object element in valueList)
{ {
output.WriteField(field.FieldType, field.FieldNumber, element); output.WriteField(field.FieldType, field.FieldNumber, field.Name, element);
} }
} }
} }
else else
{ {
output.WriteField(field.FieldType, field.FieldNumber, value); output.WriteField(field.FieldType, field.FieldNumber, field.Name, value);
} }
} }
} }
......
...@@ -59,7 +59,7 @@ namespace Google.ProtocolBuffers ...@@ -59,7 +59,7 @@ namespace Google.ProtocolBuffers
public void Write(T message) public void Write(T message)
{ {
codedOutput.WriteMessage(1, message); codedOutput.WriteMessage(1, "item", message);
} }
public void Flush() public void Flush()
......
...@@ -60,6 +60,7 @@ namespace Google.ProtocolBuffers ...@@ -60,6 +60,7 @@ namespace Google.ProtocolBuffers
/// </summary> /// </summary>
public sealed class UnknownField public sealed class UnknownField
{ {
public const string UnknownFieldName = "unknown_field";
private static readonly UnknownField defaultInstance = CreateBuilder().Build(); private static readonly UnknownField defaultInstance = CreateBuilder().Build();
private readonly ReadOnlyCollection<ulong> varintList; private readonly ReadOnlyCollection<ulong> varintList;
private readonly ReadOnlyCollection<uint> fixed32List; private readonly ReadOnlyCollection<uint> fixed32List;
...@@ -177,24 +178,24 @@ namespace Google.ProtocolBuffers ...@@ -177,24 +178,24 @@ namespace Google.ProtocolBuffers
{ {
foreach (ulong value in varintList) foreach (ulong value in varintList)
{ {
output.WriteUInt64(fieldNumber, value); output.WriteUInt64(fieldNumber, UnknownFieldName, value);
} }
foreach (uint value in fixed32List) foreach (uint value in fixed32List)
{ {
output.WriteFixed32(fieldNumber, value); output.WriteFixed32(fieldNumber, UnknownFieldName, value);
} }
foreach (ulong value in fixed64List) foreach (ulong value in fixed64List)
{ {
output.WriteFixed64(fieldNumber, value); output.WriteFixed64(fieldNumber, UnknownFieldName, value);
} }
foreach (ByteString value in lengthDelimitedList) foreach (ByteString value in lengthDelimitedList)
{ {
output.WriteBytes(fieldNumber, value); output.WriteBytes(fieldNumber, UnknownFieldName, value);
} }
foreach (UnknownFieldSet value in groupList) foreach (UnknownFieldSet value in groupList)
{ {
#pragma warning disable 0612 #pragma warning disable 0612
output.WriteUnknownGroup(fieldNumber, value); output.WriteUnknownGroup(fieldNumber, UnknownFieldName, value);
#pragma warning restore 0612 #pragma warning restore 0612
} }
} }
......
...@@ -101,10 +101,10 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -101,10 +101,10 @@ namespace Google.ProtocolBuffers.TestProtos {
public override void WriteTo(pb::CodedOutputStream output) { public override void WriteTo(pb::CodedOutputStream output) {
int size = SerializedSize; int size = SerializedSize;
if (HasD) { if (HasD) {
output.WriteInt32(1, D); output.WriteInt32(1, "d", D);
} }
if (HasEn) { if (HasEn) {
output.WriteEnum(2, (int) En); output.WriteEnum(2, "en", (int) En, En.ToString());
} }
} }
...@@ -395,10 +395,10 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -395,10 +395,10 @@ namespace Google.ProtocolBuffers.TestProtos {
public override void WriteTo(pb::CodedOutputStream output) { public override void WriteTo(pb::CodedOutputStream output) {
int size = SerializedSize; int size = SerializedSize;
if (HasNumber) { if (HasNumber) {
output.WriteString(1, Number); output.WriteString(1, "number", Number);
} }
if (HasType) { if (HasType) {
output.WriteEnum(2, (int) Type); output.WriteEnum(2, "type", (int) Type, Type.ToString());
} }
} }
...@@ -694,19 +694,19 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -694,19 +694,19 @@ namespace Google.ProtocolBuffers.TestProtos {
public override void WriteTo(pb::CodedOutputStream output) { public override void WriteTo(pb::CodedOutputStream output) {
int size = SerializedSize; int size = SerializedSize;
if (HasAddress) { if (HasAddress) {
output.WriteString(1, Address); output.WriteString(1, "address", Address);
} }
if (HasAddress2) { if (HasAddress2) {
output.WriteString(2, Address2); output.WriteString(2, "address2", Address2);
} }
if (HasCity) { if (HasCity) {
output.WriteString(3, City); output.WriteString(3, "city", City);
} }
if (HasState) { if (HasState) {
output.WriteString(4, State); output.WriteString(4, "state", State);
} }
if (HasZip) { if (HasZip) {
output.WriteFixed32(5, Zip); output.WriteFixed32(5, "zip", Zip);
} }
} }
...@@ -1101,26 +1101,22 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -1101,26 +1101,22 @@ namespace Google.ProtocolBuffers.TestProtos {
int size = SerializedSize; int size = SerializedSize;
pb::ExtendableMessageLite<TestInteropPersonLite, TestInteropPersonLite.Builder>.ExtensionWriter extensionWriter = CreateExtensionWriter(this); pb::ExtendableMessageLite<TestInteropPersonLite, TestInteropPersonLite.Builder>.ExtensionWriter extensionWriter = CreateExtensionWriter(this);
if (HasName) { if (HasName) {
output.WriteString(1, Name); output.WriteString(1, "name", Name);
} }
if (HasId) { if (HasId) {
output.WriteInt32(2, Id); output.WriteInt32(2, "id", Id);
} }
if (HasEmail) { if (HasEmail) {
output.WriteString(3, Email); output.WriteString(3, "email", Email);
} }
foreach (global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.PhoneNumber element in PhoneList) { if (phone_.Count > 0) {
output.WriteMessage(4, element); output.WriteMessageArray(4, "phone", phone_);
} }
foreach (global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.Addresses element in AddressesList) { if (addresses_.Count > 0) {
output.WriteGroup(5, element); output.WriteGroupArray(5, "addresses", addresses_);
} }
if (codes_.Count > 0) { if (codes_.Count > 0) {
output.WriteRawVarint32(82); output.WritePackedArray(pbd::FieldType.Int32, 10, "codes", codesMemoizedSerializedSize, codes_);
output.WriteRawVarint32((uint) codesMemoizedSerializedSize);
foreach (int element in codes_) {
output.WriteInt32NoTag(element);
}
} }
extensionWriter.WriteUntil(200, output); extensionWriter.WriteUntil(200, output);
} }
...@@ -1576,7 +1572,7 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -1576,7 +1572,7 @@ namespace Google.ProtocolBuffers.TestProtos {
public override void WriteTo(pb::CodedOutputStream output) { public override void WriteTo(pb::CodedOutputStream output) {
int size = SerializedSize; int size = SerializedSize;
if (HasNumber) { if (HasNumber) {
output.WriteString(1, Number); output.WriteString(1, "number", Number);
} }
} }
......
...@@ -73,7 +73,7 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -73,7 +73,7 @@ namespace Google.ProtocolBuffers.TestProtos {
public override void WriteTo(pb::CodedOutputStream output) { public override void WriteTo(pb::CodedOutputStream output) {
int size = SerializedSize; int size = SerializedSize;
if (HasD) { if (HasD) {
output.WriteInt32(1, D); output.WriteInt32(1, "d", D);
} }
} }
......
...@@ -109,7 +109,7 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -109,7 +109,7 @@ namespace Google.ProtocolBuffers.TestProtos {
public override void WriteTo(pb::CodedOutputStream output) { public override void WriteTo(pb::CodedOutputStream output) {
int size = SerializedSize; int size = SerializedSize;
if (HasD) { if (HasD) {
output.WriteInt32(1, D); output.WriteInt32(1, "d", D);
} }
UnknownFields.WriteTo(output); UnknownFields.WriteTo(output);
} }
......
...@@ -62,7 +62,7 @@ namespace Google.ProtocolBuffers.TestProtos { ...@@ -62,7 +62,7 @@ namespace Google.ProtocolBuffers.TestProtos {
public override void WriteTo(pb::CodedOutputStream output) { public override void WriteTo(pb::CodedOutputStream output) {
int size = SerializedSize; int size = SerializedSize;
if (HasMessage) { if (HasMessage) {
output.WriteMessage(1, Message); output.WriteMessage(1, "message", Message);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment