diff --git a/src/AddressBook/AddressBookProtos.cs b/src/AddressBook/AddressBookProtos.cs index fb60d0b3c6..bbae7828e5 100644 --- a/src/AddressBook/AddressBookProtos.cs +++ b/src/AddressBook/AddressBookProtos.cs @@ -159,7 +159,7 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _phoneNumberFieldNames; if (hasNumber) { output.WriteString(1, field_names[0], Number); @@ -175,20 +175,25 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasNumber) { - size += pb::CodedOutputStream.ComputeStringSize(1, Number); - } - if (hasType) { - size += pb::CodedOutputStream.ComputeEnumSize(2, (int) Type); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasNumber) { + size += pb::CodedOutputStream.ComputeStringSize(1, Number); + } + if (hasType) { + size += pb::CodedOutputStream.ComputeEnumSize(2, (int) Type); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static PhoneNumber ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -485,7 +490,7 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _personFieldNames; if (hasName) { output.WriteString(1, field_names[2], Name); @@ -507,26 +512,31 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasName) { - size += pb::CodedOutputStream.ComputeStringSize(1, Name); - } - if (hasId) { - size += pb::CodedOutputStream.ComputeInt32Size(2, Id); - } - if (hasEmail) { - size += pb::CodedOutputStream.ComputeStringSize(3, Email); - } - foreach (global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneNumber element in PhoneList) { - size += pb::CodedOutputStream.ComputeMessageSize(4, element); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasName) { + size += pb::CodedOutputStream.ComputeStringSize(1, Name); + } + if (hasId) { + size += pb::CodedOutputStream.ComputeInt32Size(2, Id); + } + if (hasEmail) { + size += pb::CodedOutputStream.ComputeStringSize(3, Email); + } + foreach (global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneNumber element in PhoneList) { + size += pb::CodedOutputStream.ComputeMessageSize(4, element); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static Person ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -886,7 +896,7 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _addressBookFieldNames; if (person_.Count > 0) { output.WriteMessageArray(1, field_names[0], person_); @@ -899,17 +909,22 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - foreach (global::Google.ProtocolBuffers.Examples.AddressBook.Person element in PersonList) { - size += pb::CodedOutputStream.ComputeMessageSize(1, element); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + foreach (global::Google.ProtocolBuffers.Examples.AddressBook.Person element in PersonList) { + size += pb::CodedOutputStream.ComputeMessageSize(1, element); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static AddressBook ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } diff --git a/src/ProtoBench/TestProtos/GoogleSpeedProtoFile.cs b/src/ProtoBench/TestProtos/GoogleSpeedProtoFile.cs index 22fad4dada..27cf8b361c 100644 --- a/src/ProtoBench/TestProtos/GoogleSpeedProtoFile.cs +++ b/src/ProtoBench/TestProtos/GoogleSpeedProtoFile.cs @@ -582,7 +582,7 @@ namespace Google.ProtocolBuffers.ProtoBench { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _speedMessage1FieldNames; if (hasField1) { output.WriteString(1, field_names[0], Field1); @@ -715,140 +715,145 @@ namespace Google.ProtocolBuffers.ProtoBench { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasField1) { - size += pb::CodedOutputStream.ComputeStringSize(1, Field1); - } - if (hasField9) { - size += pb::CodedOutputStream.ComputeStringSize(9, Field9); - } - if (hasField18) { - size += pb::CodedOutputStream.ComputeStringSize(18, Field18); - } - if (hasField80) { - size += pb::CodedOutputStream.ComputeBoolSize(80, Field80); - } - if (hasField81) { - size += pb::CodedOutputStream.ComputeBoolSize(81, Field81); - } - if (hasField2) { - size += pb::CodedOutputStream.ComputeInt32Size(2, Field2); - } - if (hasField3) { - size += pb::CodedOutputStream.ComputeInt32Size(3, Field3); - } - if (hasField280) { - size += pb::CodedOutputStream.ComputeInt32Size(280, Field280); - } - if (hasField6) { - size += pb::CodedOutputStream.ComputeInt32Size(6, Field6); - } - if (hasField22) { - size += pb::CodedOutputStream.ComputeInt64Size(22, Field22); - } - if (hasField4) { - size += pb::CodedOutputStream.ComputeStringSize(4, Field4); - } - { - int dataSize = 0; - dataSize = 8 * field5_.Count; - size += dataSize; - size += 1 * field5_.Count; - } - if (hasField59) { - size += pb::CodedOutputStream.ComputeBoolSize(59, Field59); - } - if (hasField7) { - size += pb::CodedOutputStream.ComputeStringSize(7, Field7); - } - if (hasField16) { - size += pb::CodedOutputStream.ComputeInt32Size(16, Field16); - } - if (hasField130) { - size += pb::CodedOutputStream.ComputeInt32Size(130, Field130); - } - if (hasField12) { - size += pb::CodedOutputStream.ComputeBoolSize(12, Field12); - } - if (hasField17) { - size += pb::CodedOutputStream.ComputeBoolSize(17, Field17); - } - if (hasField13) { - size += pb::CodedOutputStream.ComputeBoolSize(13, Field13); - } - if (hasField14) { - size += pb::CodedOutputStream.ComputeBoolSize(14, Field14); - } - if (hasField104) { - size += pb::CodedOutputStream.ComputeInt32Size(104, Field104); - } - if (hasField100) { - size += pb::CodedOutputStream.ComputeInt32Size(100, Field100); - } - if (hasField101) { - size += pb::CodedOutputStream.ComputeInt32Size(101, Field101); - } - if (hasField102) { - size += pb::CodedOutputStream.ComputeStringSize(102, Field102); - } - if (hasField103) { - size += pb::CodedOutputStream.ComputeStringSize(103, Field103); - } - if (hasField29) { - size += pb::CodedOutputStream.ComputeInt32Size(29, Field29); - } - if (hasField30) { - size += pb::CodedOutputStream.ComputeBoolSize(30, Field30); - } - if (hasField60) { - size += pb::CodedOutputStream.ComputeInt32Size(60, Field60); - } - if (hasField271) { - size += pb::CodedOutputStream.ComputeInt32Size(271, Field271); - } - if (hasField272) { - size += pb::CodedOutputStream.ComputeInt32Size(272, Field272); - } - if (hasField150) { - size += pb::CodedOutputStream.ComputeInt32Size(150, Field150); - } - if (hasField23) { - size += pb::CodedOutputStream.ComputeInt32Size(23, Field23); - } - if (hasField24) { - size += pb::CodedOutputStream.ComputeBoolSize(24, Field24); - } - if (hasField25) { - size += pb::CodedOutputStream.ComputeInt32Size(25, Field25); - } - if (hasField15) { - size += pb::CodedOutputStream.ComputeMessageSize(15, Field15); - } - if (hasField78) { - size += pb::CodedOutputStream.ComputeBoolSize(78, Field78); - } - if (hasField67) { - size += pb::CodedOutputStream.ComputeInt32Size(67, Field67); - } - if (hasField68) { - size += pb::CodedOutputStream.ComputeInt32Size(68, Field68); - } - if (hasField128) { - size += pb::CodedOutputStream.ComputeInt32Size(128, Field128); - } - if (hasField129) { - size += pb::CodedOutputStream.ComputeStringSize(129, Field129); - } - if (hasField131) { - size += pb::CodedOutputStream.ComputeInt32Size(131, Field131); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasField1) { + size += pb::CodedOutputStream.ComputeStringSize(1, Field1); + } + if (hasField9) { + size += pb::CodedOutputStream.ComputeStringSize(9, Field9); + } + if (hasField18) { + size += pb::CodedOutputStream.ComputeStringSize(18, Field18); + } + if (hasField80) { + size += pb::CodedOutputStream.ComputeBoolSize(80, Field80); + } + if (hasField81) { + size += pb::CodedOutputStream.ComputeBoolSize(81, Field81); + } + if (hasField2) { + size += pb::CodedOutputStream.ComputeInt32Size(2, Field2); + } + if (hasField3) { + size += pb::CodedOutputStream.ComputeInt32Size(3, Field3); + } + if (hasField280) { + size += pb::CodedOutputStream.ComputeInt32Size(280, Field280); + } + if (hasField6) { + size += pb::CodedOutputStream.ComputeInt32Size(6, Field6); + } + if (hasField22) { + size += pb::CodedOutputStream.ComputeInt64Size(22, Field22); + } + if (hasField4) { + size += pb::CodedOutputStream.ComputeStringSize(4, Field4); + } + { + int dataSize = 0; + dataSize = 8 * field5_.Count; + size += dataSize; + size += 1 * field5_.Count; + } + if (hasField59) { + size += pb::CodedOutputStream.ComputeBoolSize(59, Field59); + } + if (hasField7) { + size += pb::CodedOutputStream.ComputeStringSize(7, Field7); + } + if (hasField16) { + size += pb::CodedOutputStream.ComputeInt32Size(16, Field16); + } + if (hasField130) { + size += pb::CodedOutputStream.ComputeInt32Size(130, Field130); + } + if (hasField12) { + size += pb::CodedOutputStream.ComputeBoolSize(12, Field12); + } + if (hasField17) { + size += pb::CodedOutputStream.ComputeBoolSize(17, Field17); + } + if (hasField13) { + size += pb::CodedOutputStream.ComputeBoolSize(13, Field13); + } + if (hasField14) { + size += pb::CodedOutputStream.ComputeBoolSize(14, Field14); + } + if (hasField104) { + size += pb::CodedOutputStream.ComputeInt32Size(104, Field104); + } + if (hasField100) { + size += pb::CodedOutputStream.ComputeInt32Size(100, Field100); + } + if (hasField101) { + size += pb::CodedOutputStream.ComputeInt32Size(101, Field101); + } + if (hasField102) { + size += pb::CodedOutputStream.ComputeStringSize(102, Field102); + } + if (hasField103) { + size += pb::CodedOutputStream.ComputeStringSize(103, Field103); + } + if (hasField29) { + size += pb::CodedOutputStream.ComputeInt32Size(29, Field29); + } + if (hasField30) { + size += pb::CodedOutputStream.ComputeBoolSize(30, Field30); + } + if (hasField60) { + size += pb::CodedOutputStream.ComputeInt32Size(60, Field60); + } + if (hasField271) { + size += pb::CodedOutputStream.ComputeInt32Size(271, Field271); + } + if (hasField272) { + size += pb::CodedOutputStream.ComputeInt32Size(272, Field272); + } + if (hasField150) { + size += pb::CodedOutputStream.ComputeInt32Size(150, Field150); + } + if (hasField23) { + size += pb::CodedOutputStream.ComputeInt32Size(23, Field23); + } + if (hasField24) { + size += pb::CodedOutputStream.ComputeBoolSize(24, Field24); + } + if (hasField25) { + size += pb::CodedOutputStream.ComputeInt32Size(25, Field25); + } + if (hasField15) { + size += pb::CodedOutputStream.ComputeMessageSize(15, Field15); + } + if (hasField78) { + size += pb::CodedOutputStream.ComputeBoolSize(78, Field78); + } + if (hasField67) { + size += pb::CodedOutputStream.ComputeInt32Size(67, Field67); + } + if (hasField68) { + size += pb::CodedOutputStream.ComputeInt32Size(68, Field68); + } + if (hasField128) { + size += pb::CodedOutputStream.ComputeInt32Size(128, Field128); + } + if (hasField129) { + size += pb::CodedOutputStream.ComputeStringSize(129, Field129); + } + if (hasField131) { + size += pb::CodedOutputStream.ComputeInt32Size(131, Field131); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static SpeedMessage1 ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -2419,7 +2424,7 @@ namespace Google.ProtocolBuffers.ProtoBench { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _speedMessage1SubMessageFieldNames; if (hasField1) { output.WriteInt32(1, field_names[0], Field1); @@ -2489,74 +2494,79 @@ namespace Google.ProtocolBuffers.ProtoBench { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasField1) { - size += pb::CodedOutputStream.ComputeInt32Size(1, Field1); - } - if (hasField2) { - size += pb::CodedOutputStream.ComputeInt32Size(2, Field2); - } - if (hasField3) { - size += pb::CodedOutputStream.ComputeInt32Size(3, Field3); - } - if (hasField15) { - size += pb::CodedOutputStream.ComputeStringSize(15, Field15); - } - if (hasField12) { - size += pb::CodedOutputStream.ComputeBoolSize(12, Field12); - } - if (hasField13) { - size += pb::CodedOutputStream.ComputeInt64Size(13, Field13); - } - if (hasField14) { - size += pb::CodedOutputStream.ComputeInt64Size(14, Field14); - } - if (hasField16) { - size += pb::CodedOutputStream.ComputeInt32Size(16, Field16); - } - if (hasField19) { - size += pb::CodedOutputStream.ComputeInt32Size(19, Field19); - } - if (hasField20) { - size += pb::CodedOutputStream.ComputeBoolSize(20, Field20); - } - if (hasField28) { - size += pb::CodedOutputStream.ComputeBoolSize(28, Field28); - } - if (hasField21) { - size += pb::CodedOutputStream.ComputeFixed64Size(21, Field21); - } - if (hasField22) { - size += pb::CodedOutputStream.ComputeInt32Size(22, Field22); - } - if (hasField23) { - size += pb::CodedOutputStream.ComputeBoolSize(23, Field23); - } - if (hasField206) { - size += pb::CodedOutputStream.ComputeBoolSize(206, Field206); - } - if (hasField203) { - size += pb::CodedOutputStream.ComputeFixed32Size(203, Field203); - } - if (hasField204) { - size += pb::CodedOutputStream.ComputeInt32Size(204, Field204); - } - if (hasField205) { - size += pb::CodedOutputStream.ComputeStringSize(205, Field205); - } - if (hasField207) { - size += pb::CodedOutputStream.ComputeUInt64Size(207, Field207); - } - if (hasField300) { - size += pb::CodedOutputStream.ComputeUInt64Size(300, Field300); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasField1) { + size += pb::CodedOutputStream.ComputeInt32Size(1, Field1); + } + if (hasField2) { + size += pb::CodedOutputStream.ComputeInt32Size(2, Field2); + } + if (hasField3) { + size += pb::CodedOutputStream.ComputeInt32Size(3, Field3); + } + if (hasField15) { + size += pb::CodedOutputStream.ComputeStringSize(15, Field15); + } + if (hasField12) { + size += pb::CodedOutputStream.ComputeBoolSize(12, Field12); + } + if (hasField13) { + size += pb::CodedOutputStream.ComputeInt64Size(13, Field13); + } + if (hasField14) { + size += pb::CodedOutputStream.ComputeInt64Size(14, Field14); + } + if (hasField16) { + size += pb::CodedOutputStream.ComputeInt32Size(16, Field16); + } + if (hasField19) { + size += pb::CodedOutputStream.ComputeInt32Size(19, Field19); + } + if (hasField20) { + size += pb::CodedOutputStream.ComputeBoolSize(20, Field20); + } + if (hasField28) { + size += pb::CodedOutputStream.ComputeBoolSize(28, Field28); + } + if (hasField21) { + size += pb::CodedOutputStream.ComputeFixed64Size(21, Field21); + } + if (hasField22) { + size += pb::CodedOutputStream.ComputeInt32Size(22, Field22); + } + if (hasField23) { + size += pb::CodedOutputStream.ComputeBoolSize(23, Field23); + } + if (hasField206) { + size += pb::CodedOutputStream.ComputeBoolSize(206, Field206); + } + if (hasField203) { + size += pb::CodedOutputStream.ComputeFixed32Size(203, Field203); + } + if (hasField204) { + size += pb::CodedOutputStream.ComputeInt32Size(204, Field204); + } + if (hasField205) { + size += pb::CodedOutputStream.ComputeStringSize(205, Field205); + } + if (hasField207) { + size += pb::CodedOutputStream.ComputeUInt64Size(207, Field207); + } + if (hasField300) { + size += pb::CodedOutputStream.ComputeUInt64Size(300, Field300); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static SpeedMessage1SubMessage ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -3514,7 +3524,7 @@ namespace Google.ProtocolBuffers.ProtoBench { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _group1FieldNames; if (hasField5) { output.WriteInt32(5, field_names[14], Field5); @@ -3572,77 +3582,82 @@ namespace Google.ProtocolBuffers.ProtoBench { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasField11) { - size += pb::CodedOutputStream.ComputeFloatSize(11, Field11); - } - if (hasField26) { - size += pb::CodedOutputStream.ComputeFloatSize(26, Field26); - } - if (hasField12) { - size += pb::CodedOutputStream.ComputeStringSize(12, Field12); - } - if (hasField13) { - size += pb::CodedOutputStream.ComputeStringSize(13, Field13); - } - { - int dataSize = 0; - foreach (string element in Field14List) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); - } - size += dataSize; - size += 1 * field14_.Count; - } - if (hasField15) { - size += pb::CodedOutputStream.ComputeUInt64Size(15, Field15); - } - if (hasField5) { - size += pb::CodedOutputStream.ComputeInt32Size(5, Field5); - } - if (hasField27) { - size += pb::CodedOutputStream.ComputeStringSize(27, Field27); - } - if (hasField28) { - size += pb::CodedOutputStream.ComputeInt32Size(28, Field28); - } - if (hasField29) { - size += pb::CodedOutputStream.ComputeStringSize(29, Field29); - } - if (hasField16) { - size += pb::CodedOutputStream.ComputeStringSize(16, Field16); - } - { - int dataSize = 0; - foreach (string element in Field22List) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); - } - size += dataSize; - size += 2 * field22_.Count; - } - { - int dataSize = 0; - foreach (int element in Field73List) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); - } - size += dataSize; - size += 2 * field73_.Count; - } - if (hasField20) { - size += pb::CodedOutputStream.ComputeInt32Size(20, Field20); + return CalcSerializedSize(); + } + } + + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasField11) { + size += pb::CodedOutputStream.ComputeFloatSize(11, Field11); + } + if (hasField26) { + size += pb::CodedOutputStream.ComputeFloatSize(26, Field26); + } + if (hasField12) { + size += pb::CodedOutputStream.ComputeStringSize(12, Field12); + } + if (hasField13) { + size += pb::CodedOutputStream.ComputeStringSize(13, Field13); + } + { + int dataSize = 0; + foreach (string element in Field14List) { + dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); } - if (hasField24) { - size += pb::CodedOutputStream.ComputeStringSize(24, Field24); + size += dataSize; + size += 1 * field14_.Count; + } + if (hasField15) { + size += pb::CodedOutputStream.ComputeUInt64Size(15, Field15); + } + if (hasField5) { + size += pb::CodedOutputStream.ComputeInt32Size(5, Field5); + } + if (hasField27) { + size += pb::CodedOutputStream.ComputeStringSize(27, Field27); + } + if (hasField28) { + size += pb::CodedOutputStream.ComputeInt32Size(28, Field28); + } + if (hasField29) { + size += pb::CodedOutputStream.ComputeStringSize(29, Field29); + } + if (hasField16) { + size += pb::CodedOutputStream.ComputeStringSize(16, Field16); + } + { + int dataSize = 0; + foreach (string element in Field22List) { + dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); } - if (hasField31) { - size += pb::CodedOutputStream.ComputeMessageSize(31, Field31); + size += dataSize; + size += 2 * field22_.Count; + } + { + int dataSize = 0; + foreach (int element in Field73List) { + dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + size += dataSize; + size += 2 * field73_.Count; + } + if (hasField20) { + size += pb::CodedOutputStream.ComputeInt32Size(20, Field20); + } + if (hasField24) { + size += pb::CodedOutputStream.ComputeStringSize(24, Field24); } + if (hasField31) { + size += pb::CodedOutputStream.ComputeMessageSize(31, Field31); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; } - public static Group1 ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -4640,7 +4655,7 @@ namespace Google.ProtocolBuffers.ProtoBench { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _speedMessage2FieldNames; if (hasField1) { output.WriteString(1, field_names[0], Field1); @@ -4740,119 +4755,124 @@ namespace Google.ProtocolBuffers.ProtoBench { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasField1) { - size += pb::CodedOutputStream.ComputeStringSize(1, Field1); - } - if (hasField3) { - size += pb::CodedOutputStream.ComputeInt64Size(3, Field3); - } - if (hasField4) { - size += pb::CodedOutputStream.ComputeInt64Size(4, Field4); - } - if (hasField30) { - size += pb::CodedOutputStream.ComputeInt64Size(30, Field30); - } - if (hasField75) { - size += pb::CodedOutputStream.ComputeBoolSize(75, Field75); - } - if (hasField6) { - size += pb::CodedOutputStream.ComputeStringSize(6, Field6); - } - if (hasField2) { - size += pb::CodedOutputStream.ComputeBytesSize(2, Field2); - } - if (hasField21) { - size += pb::CodedOutputStream.ComputeInt32Size(21, Field21); - } - if (hasField71) { - size += pb::CodedOutputStream.ComputeInt32Size(71, Field71); - } - if (hasField25) { - size += pb::CodedOutputStream.ComputeFloatSize(25, Field25); - } - if (hasField109) { - size += pb::CodedOutputStream.ComputeInt32Size(109, Field109); - } - if (hasField210) { - size += pb::CodedOutputStream.ComputeInt32Size(210, Field210); - } - if (hasField211) { - size += pb::CodedOutputStream.ComputeInt32Size(211, Field211); - } - if (hasField212) { - size += pb::CodedOutputStream.ComputeInt32Size(212, Field212); - } - if (hasField213) { - size += pb::CodedOutputStream.ComputeInt32Size(213, Field213); - } - if (hasField216) { - size += pb::CodedOutputStream.ComputeInt32Size(216, Field216); - } - if (hasField217) { - size += pb::CodedOutputStream.ComputeInt32Size(217, Field217); - } - if (hasField218) { - size += pb::CodedOutputStream.ComputeInt32Size(218, Field218); - } - if (hasField220) { - size += pb::CodedOutputStream.ComputeInt32Size(220, Field220); - } - if (hasField221) { - size += pb::CodedOutputStream.ComputeInt32Size(221, Field221); - } - if (hasField222) { - size += pb::CodedOutputStream.ComputeFloatSize(222, Field222); - } - if (hasField63) { - size += pb::CodedOutputStream.ComputeInt32Size(63, Field63); - } - foreach (global::Google.ProtocolBuffers.ProtoBench.SpeedMessage2.Types.Group1 element in Group1List) { - size += pb::CodedOutputStream.ComputeGroupSize(10, element); - } - { - int dataSize = 0; - foreach (string element in Field128List) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); - } - size += dataSize; - size += 2 * field128_.Count; - } - if (hasField131) { - size += pb::CodedOutputStream.ComputeInt64Size(131, Field131); - } - { - int dataSize = 0; - foreach (string element in Field127List) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); - } - size += dataSize; - size += 2 * field127_.Count; - } - if (hasField129) { - size += pb::CodedOutputStream.ComputeInt32Size(129, Field129); - } - { - int dataSize = 0; - foreach (long element in Field130List) { - dataSize += pb::CodedOutputStream.ComputeInt64SizeNoTag(element); - } - size += dataSize; - size += 2 * field130_.Count; + return CalcSerializedSize(); + } + } + + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasField1) { + size += pb::CodedOutputStream.ComputeStringSize(1, Field1); + } + if (hasField3) { + size += pb::CodedOutputStream.ComputeInt64Size(3, Field3); + } + if (hasField4) { + size += pb::CodedOutputStream.ComputeInt64Size(4, Field4); + } + if (hasField30) { + size += pb::CodedOutputStream.ComputeInt64Size(30, Field30); + } + if (hasField75) { + size += pb::CodedOutputStream.ComputeBoolSize(75, Field75); + } + if (hasField6) { + size += pb::CodedOutputStream.ComputeStringSize(6, Field6); + } + if (hasField2) { + size += pb::CodedOutputStream.ComputeBytesSize(2, Field2); + } + if (hasField21) { + size += pb::CodedOutputStream.ComputeInt32Size(21, Field21); + } + if (hasField71) { + size += pb::CodedOutputStream.ComputeInt32Size(71, Field71); + } + if (hasField25) { + size += pb::CodedOutputStream.ComputeFloatSize(25, Field25); + } + if (hasField109) { + size += pb::CodedOutputStream.ComputeInt32Size(109, Field109); + } + if (hasField210) { + size += pb::CodedOutputStream.ComputeInt32Size(210, Field210); + } + if (hasField211) { + size += pb::CodedOutputStream.ComputeInt32Size(211, Field211); + } + if (hasField212) { + size += pb::CodedOutputStream.ComputeInt32Size(212, Field212); + } + if (hasField213) { + size += pb::CodedOutputStream.ComputeInt32Size(213, Field213); + } + if (hasField216) { + size += pb::CodedOutputStream.ComputeInt32Size(216, Field216); + } + if (hasField217) { + size += pb::CodedOutputStream.ComputeInt32Size(217, Field217); + } + if (hasField218) { + size += pb::CodedOutputStream.ComputeInt32Size(218, Field218); + } + if (hasField220) { + size += pb::CodedOutputStream.ComputeInt32Size(220, Field220); + } + if (hasField221) { + size += pb::CodedOutputStream.ComputeInt32Size(221, Field221); + } + if (hasField222) { + size += pb::CodedOutputStream.ComputeFloatSize(222, Field222); + } + if (hasField63) { + size += pb::CodedOutputStream.ComputeInt32Size(63, Field63); + } + foreach (global::Google.ProtocolBuffers.ProtoBench.SpeedMessage2.Types.Group1 element in Group1List) { + size += pb::CodedOutputStream.ComputeGroupSize(10, element); + } + { + int dataSize = 0; + foreach (string element in Field128List) { + dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); } - if (hasField205) { - size += pb::CodedOutputStream.ComputeBoolSize(205, Field205); + size += dataSize; + size += 2 * field128_.Count; + } + if (hasField131) { + size += pb::CodedOutputStream.ComputeInt64Size(131, Field131); + } + { + int dataSize = 0; + foreach (string element in Field127List) { + dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); } - if (hasField206) { - size += pb::CodedOutputStream.ComputeBoolSize(206, Field206); + size += dataSize; + size += 2 * field127_.Count; + } + if (hasField129) { + size += pb::CodedOutputStream.ComputeInt32Size(129, Field129); + } + { + int dataSize = 0; + foreach (long element in Field130List) { + dataSize += pb::CodedOutputStream.ComputeInt64SizeNoTag(element); } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + size += dataSize; + size += 2 * field130_.Count; + } + if (hasField205) { + size += pb::CodedOutputStream.ComputeBoolSize(205, Field205); } + if (hasField206) { + size += pb::CodedOutputStream.ComputeBoolSize(206, Field206); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; } - public static SpeedMessage2 ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -6048,7 +6068,7 @@ namespace Google.ProtocolBuffers.ProtoBench { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _speedMessage2GroupedMessageFieldNames; if (hasField1) { output.WriteFloat(1, field_names[0], Field1); @@ -6091,47 +6111,52 @@ namespace Google.ProtocolBuffers.ProtoBench { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasField1) { - size += pb::CodedOutputStream.ComputeFloatSize(1, Field1); - } - if (hasField2) { - size += pb::CodedOutputStream.ComputeFloatSize(2, Field2); - } - if (hasField3) { - size += pb::CodedOutputStream.ComputeFloatSize(3, Field3); - } - if (hasField4) { - size += pb::CodedOutputStream.ComputeBoolSize(4, Field4); - } - if (hasField5) { - size += pb::CodedOutputStream.ComputeBoolSize(5, Field5); - } - if (hasField6) { - size += pb::CodedOutputStream.ComputeBoolSize(6, Field6); - } - if (hasField7) { - size += pb::CodedOutputStream.ComputeBoolSize(7, Field7); - } - if (hasField8) { - size += pb::CodedOutputStream.ComputeFloatSize(8, Field8); - } - if (hasField9) { - size += pb::CodedOutputStream.ComputeBoolSize(9, Field9); - } - if (hasField10) { - size += pb::CodedOutputStream.ComputeFloatSize(10, Field10); - } - if (hasField11) { - size += pb::CodedOutputStream.ComputeInt64Size(11, Field11); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasField1) { + size += pb::CodedOutputStream.ComputeFloatSize(1, Field1); + } + if (hasField2) { + size += pb::CodedOutputStream.ComputeFloatSize(2, Field2); + } + if (hasField3) { + size += pb::CodedOutputStream.ComputeFloatSize(3, Field3); + } + if (hasField4) { + size += pb::CodedOutputStream.ComputeBoolSize(4, Field4); + } + if (hasField5) { + size += pb::CodedOutputStream.ComputeBoolSize(5, Field5); + } + if (hasField6) { + size += pb::CodedOutputStream.ComputeBoolSize(6, Field6); + } + if (hasField7) { + size += pb::CodedOutputStream.ComputeBoolSize(7, Field7); + } + if (hasField8) { + size += pb::CodedOutputStream.ComputeFloatSize(8, Field8); + } + if (hasField9) { + size += pb::CodedOutputStream.ComputeBoolSize(9, Field9); + } + if (hasField10) { + size += pb::CodedOutputStream.ComputeFloatSize(10, Field10); + } + if (hasField11) { + size += pb::CodedOutputStream.ComputeInt64Size(11, Field11); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static SpeedMessage2GroupedMessage ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } diff --git a/src/ProtoBench/TestProtos/UnitTestImportProtoFile.cs b/src/ProtoBench/TestProtos/UnitTestImportProtoFile.cs index 57b9e65c8c..61aca3d911 100644 --- a/src/ProtoBench/TestProtos/UnitTestImportProtoFile.cs +++ b/src/ProtoBench/TestProtos/UnitTestImportProtoFile.cs @@ -107,7 +107,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _importMessageFieldNames; if (hasD) { output.WriteInt32(1, field_names[0], D); @@ -120,17 +120,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasD) { - size += pb::CodedOutputStream.ComputeInt32Size(1, D); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasD) { + size += pb::CodedOutputStream.ComputeInt32Size(1, D); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static ImportMessage ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } diff --git a/src/ProtoBench/TestProtos/UnitTestProtoFile.cs b/src/ProtoBench/TestProtos/UnitTestProtoFile.cs index 9a9f00bfdf..53ae17e699 100644 --- a/src/ProtoBench/TestProtos/UnitTestProtoFile.cs +++ b/src/ProtoBench/TestProtos/UnitTestProtoFile.cs @@ -1106,7 +1106,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _nestedMessageFieldNames; if (hasBb) { output.WriteInt32(1, field_names[0], Bb); @@ -1119,17 +1119,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasBb) { - size += pb::CodedOutputStream.ComputeInt32Size(1, Bb); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasBb) { + size += pb::CodedOutputStream.ComputeInt32Size(1, Bb); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static NestedMessage ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -1376,7 +1381,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _optionalGroupFieldNames; if (hasA) { output.WriteInt32(17, field_names[0], A); @@ -1389,17 +1394,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(17, A); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasA) { + size += pb::CodedOutputStream.ComputeInt32Size(17, A); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static OptionalGroup ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -1646,7 +1656,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _repeatedGroupFieldNames; if (hasA) { output.WriteInt32(47, field_names[0], A); @@ -1659,17 +1669,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(47, A); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasA) { + size += pb::CodedOutputStream.ComputeInt32Size(47, A); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static RepeatedGroup ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -2627,7 +2642,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testAllTypesFieldNames; if (hasOptionalInt32) { output.WriteInt32(1, field_names[31], OptionalInt32); @@ -2841,310 +2856,315 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasOptionalInt32) { - size += pb::CodedOutputStream.ComputeInt32Size(1, OptionalInt32); - } - if (hasOptionalInt64) { - size += pb::CodedOutputStream.ComputeInt64Size(2, OptionalInt64); - } - if (hasOptionalUint32) { - size += pb::CodedOutputStream.ComputeUInt32Size(3, OptionalUint32); - } - if (hasOptionalUint64) { - size += pb::CodedOutputStream.ComputeUInt64Size(4, OptionalUint64); - } - if (hasOptionalSint32) { - size += pb::CodedOutputStream.ComputeSInt32Size(5, OptionalSint32); - } - if (hasOptionalSint64) { - size += pb::CodedOutputStream.ComputeSInt64Size(6, OptionalSint64); - } - if (hasOptionalFixed32) { - size += pb::CodedOutputStream.ComputeFixed32Size(7, OptionalFixed32); - } - if (hasOptionalFixed64) { - size += pb::CodedOutputStream.ComputeFixed64Size(8, OptionalFixed64); - } - if (hasOptionalSfixed32) { - size += pb::CodedOutputStream.ComputeSFixed32Size(9, OptionalSfixed32); - } - if (hasOptionalSfixed64) { - size += pb::CodedOutputStream.ComputeSFixed64Size(10, OptionalSfixed64); - } - if (hasOptionalFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(11, OptionalFloat); - } - if (hasOptionalDouble) { - size += pb::CodedOutputStream.ComputeDoubleSize(12, OptionalDouble); - } - if (hasOptionalBool) { - size += pb::CodedOutputStream.ComputeBoolSize(13, OptionalBool); - } - if (hasOptionalString) { - size += pb::CodedOutputStream.ComputeStringSize(14, OptionalString); - } - if (hasOptionalBytes) { - size += pb::CodedOutputStream.ComputeBytesSize(15, OptionalBytes); - } - if (hasOptionalGroup) { - size += pb::CodedOutputStream.ComputeGroupSize(16, OptionalGroup); - } - if (hasOptionalNestedMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(18, OptionalNestedMessage); - } - if (hasOptionalForeignMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(19, OptionalForeignMessage); - } - if (hasOptionalImportMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(20, OptionalImportMessage); - } - if (hasOptionalNestedEnum) { - size += pb::CodedOutputStream.ComputeEnumSize(21, (int) OptionalNestedEnum); - } - if (hasOptionalForeignEnum) { - size += pb::CodedOutputStream.ComputeEnumSize(22, (int) OptionalForeignEnum); - } - if (hasOptionalImportEnum) { - size += pb::CodedOutputStream.ComputeEnumSize(23, (int) OptionalImportEnum); - } - if (hasOptionalStringPiece) { - size += pb::CodedOutputStream.ComputeStringSize(24, OptionalStringPiece); - } - if (hasOptionalCord) { - size += pb::CodedOutputStream.ComputeStringSize(25, OptionalCord); - } - { - int dataSize = 0; - foreach (int element in RepeatedInt32List) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedInt32_.Count; - } - { - int dataSize = 0; - foreach (long element in RepeatedInt64List) { - dataSize += pb::CodedOutputStream.ComputeInt64SizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedInt64_.Count; - } - { - int dataSize = 0; - foreach (uint element in RepeatedUint32List) { - dataSize += pb::CodedOutputStream.ComputeUInt32SizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedUint32_.Count; - } - { - int dataSize = 0; - foreach (ulong element in RepeatedUint64List) { - dataSize += pb::CodedOutputStream.ComputeUInt64SizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedUint64_.Count; - } - { - int dataSize = 0; - foreach (int element in RepeatedSint32List) { - dataSize += pb::CodedOutputStream.ComputeSInt32SizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedSint32_.Count; - } - { - int dataSize = 0; - foreach (long element in RepeatedSint64List) { - dataSize += pb::CodedOutputStream.ComputeSInt64SizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedSint64_.Count; - } - { - int dataSize = 0; - dataSize = 4 * repeatedFixed32_.Count; - size += dataSize; - size += 2 * repeatedFixed32_.Count; - } - { - int dataSize = 0; - dataSize = 8 * repeatedFixed64_.Count; - size += dataSize; - size += 2 * repeatedFixed64_.Count; - } - { - int dataSize = 0; - dataSize = 4 * repeatedSfixed32_.Count; - size += dataSize; - size += 2 * repeatedSfixed32_.Count; - } - { - int dataSize = 0; - dataSize = 8 * repeatedSfixed64_.Count; - size += dataSize; - size += 2 * repeatedSfixed64_.Count; - } - { - int dataSize = 0; - dataSize = 4 * repeatedFloat_.Count; - size += dataSize; - size += 2 * repeatedFloat_.Count; - } - { - int dataSize = 0; - dataSize = 8 * repeatedDouble_.Count; - size += dataSize; - size += 2 * repeatedDouble_.Count; - } - { - int dataSize = 0; - dataSize = 1 * repeatedBool_.Count; - size += dataSize; - size += 2 * repeatedBool_.Count; - } - { - int dataSize = 0; - foreach (string element in RepeatedStringList) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedString_.Count; - } - { - int dataSize = 0; - foreach (pb::ByteString element in RepeatedBytesList) { - dataSize += pb::CodedOutputStream.ComputeBytesSizeNoTag(element); + return CalcSerializedSize(); + } + } + + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasOptionalInt32) { + size += pb::CodedOutputStream.ComputeInt32Size(1, OptionalInt32); + } + if (hasOptionalInt64) { + size += pb::CodedOutputStream.ComputeInt64Size(2, OptionalInt64); + } + if (hasOptionalUint32) { + size += pb::CodedOutputStream.ComputeUInt32Size(3, OptionalUint32); + } + if (hasOptionalUint64) { + size += pb::CodedOutputStream.ComputeUInt64Size(4, OptionalUint64); + } + if (hasOptionalSint32) { + size += pb::CodedOutputStream.ComputeSInt32Size(5, OptionalSint32); + } + if (hasOptionalSint64) { + size += pb::CodedOutputStream.ComputeSInt64Size(6, OptionalSint64); + } + if (hasOptionalFixed32) { + size += pb::CodedOutputStream.ComputeFixed32Size(7, OptionalFixed32); + } + if (hasOptionalFixed64) { + size += pb::CodedOutputStream.ComputeFixed64Size(8, OptionalFixed64); + } + if (hasOptionalSfixed32) { + size += pb::CodedOutputStream.ComputeSFixed32Size(9, OptionalSfixed32); + } + if (hasOptionalSfixed64) { + size += pb::CodedOutputStream.ComputeSFixed64Size(10, OptionalSfixed64); + } + if (hasOptionalFloat) { + size += pb::CodedOutputStream.ComputeFloatSize(11, OptionalFloat); + } + if (hasOptionalDouble) { + size += pb::CodedOutputStream.ComputeDoubleSize(12, OptionalDouble); + } + if (hasOptionalBool) { + size += pb::CodedOutputStream.ComputeBoolSize(13, OptionalBool); + } + if (hasOptionalString) { + size += pb::CodedOutputStream.ComputeStringSize(14, OptionalString); + } + if (hasOptionalBytes) { + size += pb::CodedOutputStream.ComputeBytesSize(15, OptionalBytes); + } + if (hasOptionalGroup) { + size += pb::CodedOutputStream.ComputeGroupSize(16, OptionalGroup); + } + if (hasOptionalNestedMessage) { + size += pb::CodedOutputStream.ComputeMessageSize(18, OptionalNestedMessage); + } + if (hasOptionalForeignMessage) { + size += pb::CodedOutputStream.ComputeMessageSize(19, OptionalForeignMessage); + } + if (hasOptionalImportMessage) { + size += pb::CodedOutputStream.ComputeMessageSize(20, OptionalImportMessage); + } + if (hasOptionalNestedEnum) { + size += pb::CodedOutputStream.ComputeEnumSize(21, (int) OptionalNestedEnum); + } + if (hasOptionalForeignEnum) { + size += pb::CodedOutputStream.ComputeEnumSize(22, (int) OptionalForeignEnum); + } + if (hasOptionalImportEnum) { + size += pb::CodedOutputStream.ComputeEnumSize(23, (int) OptionalImportEnum); + } + if (hasOptionalStringPiece) { + size += pb::CodedOutputStream.ComputeStringSize(24, OptionalStringPiece); + } + if (hasOptionalCord) { + size += pb::CodedOutputStream.ComputeStringSize(25, OptionalCord); + } + { + int dataSize = 0; + foreach (int element in RepeatedInt32List) { + dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); + } + size += dataSize; + size += 2 * repeatedInt32_.Count; + } + { + int dataSize = 0; + foreach (long element in RepeatedInt64List) { + dataSize += pb::CodedOutputStream.ComputeInt64SizeNoTag(element); + } + size += dataSize; + size += 2 * repeatedInt64_.Count; + } + { + int dataSize = 0; + foreach (uint element in RepeatedUint32List) { + dataSize += pb::CodedOutputStream.ComputeUInt32SizeNoTag(element); + } + size += dataSize; + size += 2 * repeatedUint32_.Count; + } + { + int dataSize = 0; + foreach (ulong element in RepeatedUint64List) { + dataSize += pb::CodedOutputStream.ComputeUInt64SizeNoTag(element); + } + size += dataSize; + size += 2 * repeatedUint64_.Count; + } + { + int dataSize = 0; + foreach (int element in RepeatedSint32List) { + dataSize += pb::CodedOutputStream.ComputeSInt32SizeNoTag(element); + } + size += dataSize; + size += 2 * repeatedSint32_.Count; + } + { + int dataSize = 0; + foreach (long element in RepeatedSint64List) { + dataSize += pb::CodedOutputStream.ComputeSInt64SizeNoTag(element); + } + size += dataSize; + size += 2 * repeatedSint64_.Count; + } + { + int dataSize = 0; + dataSize = 4 * repeatedFixed32_.Count; + size += dataSize; + size += 2 * repeatedFixed32_.Count; + } + { + int dataSize = 0; + dataSize = 8 * repeatedFixed64_.Count; + size += dataSize; + size += 2 * repeatedFixed64_.Count; + } + { + int dataSize = 0; + dataSize = 4 * repeatedSfixed32_.Count; + size += dataSize; + size += 2 * repeatedSfixed32_.Count; + } + { + int dataSize = 0; + dataSize = 8 * repeatedSfixed64_.Count; + size += dataSize; + size += 2 * repeatedSfixed64_.Count; + } + { + int dataSize = 0; + dataSize = 4 * repeatedFloat_.Count; + size += dataSize; + size += 2 * repeatedFloat_.Count; + } + { + int dataSize = 0; + dataSize = 8 * repeatedDouble_.Count; + size += dataSize; + size += 2 * repeatedDouble_.Count; + } + { + int dataSize = 0; + dataSize = 1 * repeatedBool_.Count; + size += dataSize; + size += 2 * repeatedBool_.Count; + } + { + int dataSize = 0; + foreach (string element in RepeatedStringList) { + dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); + } + size += dataSize; + size += 2 * repeatedString_.Count; + } + { + int dataSize = 0; + foreach (pb::ByteString element in RepeatedBytesList) { + dataSize += pb::CodedOutputStream.ComputeBytesSizeNoTag(element); + } + size += dataSize; + size += 2 * repeatedBytes_.Count; + } + foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup element in RepeatedGroupList) { + size += pb::CodedOutputStream.ComputeGroupSize(46, element); + } + foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage element in RepeatedNestedMessageList) { + size += pb::CodedOutputStream.ComputeMessageSize(48, element); + } + foreach (global::Google.ProtocolBuffers.TestProtos.ForeignMessage element in RepeatedForeignMessageList) { + size += pb::CodedOutputStream.ComputeMessageSize(49, element); + } + foreach (global::Google.ProtocolBuffers.TestProtos.ImportMessage element in RepeatedImportMessageList) { + size += pb::CodedOutputStream.ComputeMessageSize(50, element); + } + { + int dataSize = 0; + if (repeatedNestedEnum_.Count > 0) { + foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedEnum element in repeatedNestedEnum_) { + dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); } size += dataSize; - size += 2 * repeatedBytes_.Count; - } - foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup element in RepeatedGroupList) { - size += pb::CodedOutputStream.ComputeGroupSize(46, element); + size += 2 * repeatedNestedEnum_.Count; } - foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage element in RepeatedNestedMessageList) { - size += pb::CodedOutputStream.ComputeMessageSize(48, element); - } - foreach (global::Google.ProtocolBuffers.TestProtos.ForeignMessage element in RepeatedForeignMessageList) { - size += pb::CodedOutputStream.ComputeMessageSize(49, element); - } - foreach (global::Google.ProtocolBuffers.TestProtos.ImportMessage element in RepeatedImportMessageList) { - size += pb::CodedOutputStream.ComputeMessageSize(50, element); - } - { - int dataSize = 0; - if (repeatedNestedEnum_.Count > 0) { - foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedEnum element in repeatedNestedEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 2 * repeatedNestedEnum_.Count; - } - } - { - int dataSize = 0; - if (repeatedForeignEnum_.Count > 0) { - foreach (global::Google.ProtocolBuffers.TestProtos.ForeignEnum element in repeatedForeignEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 2 * repeatedForeignEnum_.Count; - } - } - { - int dataSize = 0; - if (repeatedImportEnum_.Count > 0) { - foreach (global::Google.ProtocolBuffers.TestProtos.ImportEnum element in repeatedImportEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 2 * repeatedImportEnum_.Count; - } - } - { - int dataSize = 0; - foreach (string element in RepeatedStringPieceList) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); + } + { + int dataSize = 0; + if (repeatedForeignEnum_.Count > 0) { + foreach (global::Google.ProtocolBuffers.TestProtos.ForeignEnum element in repeatedForeignEnum_) { + dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); } size += dataSize; - size += 2 * repeatedStringPiece_.Count; + size += 2 * repeatedForeignEnum_.Count; } - { - int dataSize = 0; - foreach (string element in RepeatedCordList) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); + } + { + int dataSize = 0; + if (repeatedImportEnum_.Count > 0) { + foreach (global::Google.ProtocolBuffers.TestProtos.ImportEnum element in repeatedImportEnum_) { + dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); } size += dataSize; - size += 2 * repeatedCord_.Count; - } - if (hasDefaultInt32) { - size += pb::CodedOutputStream.ComputeInt32Size(61, DefaultInt32); - } - if (hasDefaultInt64) { - size += pb::CodedOutputStream.ComputeInt64Size(62, DefaultInt64); - } - if (hasDefaultUint32) { - size += pb::CodedOutputStream.ComputeUInt32Size(63, DefaultUint32); - } - if (hasDefaultUint64) { - size += pb::CodedOutputStream.ComputeUInt64Size(64, DefaultUint64); - } - if (hasDefaultSint32) { - size += pb::CodedOutputStream.ComputeSInt32Size(65, DefaultSint32); - } - if (hasDefaultSint64) { - size += pb::CodedOutputStream.ComputeSInt64Size(66, DefaultSint64); + size += 2 * repeatedImportEnum_.Count; } - if (hasDefaultFixed32) { - size += pb::CodedOutputStream.ComputeFixed32Size(67, DefaultFixed32); - } - if (hasDefaultFixed64) { - size += pb::CodedOutputStream.ComputeFixed64Size(68, DefaultFixed64); - } - if (hasDefaultSfixed32) { - size += pb::CodedOutputStream.ComputeSFixed32Size(69, DefaultSfixed32); - } - if (hasDefaultSfixed64) { - size += pb::CodedOutputStream.ComputeSFixed64Size(70, DefaultSfixed64); - } - if (hasDefaultFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(71, DefaultFloat); - } - if (hasDefaultDouble) { - size += pb::CodedOutputStream.ComputeDoubleSize(72, DefaultDouble); - } - if (hasDefaultBool) { - size += pb::CodedOutputStream.ComputeBoolSize(73, DefaultBool); - } - if (hasDefaultString) { - size += pb::CodedOutputStream.ComputeStringSize(74, DefaultString); - } - if (hasDefaultBytes) { - size += pb::CodedOutputStream.ComputeBytesSize(75, DefaultBytes); - } - if (hasDefaultNestedEnum) { - size += pb::CodedOutputStream.ComputeEnumSize(81, (int) DefaultNestedEnum); - } - if (hasDefaultForeignEnum) { - size += pb::CodedOutputStream.ComputeEnumSize(82, (int) DefaultForeignEnum); - } - if (hasDefaultImportEnum) { - size += pb::CodedOutputStream.ComputeEnumSize(83, (int) DefaultImportEnum); - } - if (hasDefaultStringPiece) { - size += pb::CodedOutputStream.ComputeStringSize(84, DefaultStringPiece); + } + { + int dataSize = 0; + foreach (string element in RepeatedStringPieceList) { + dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); } - if (hasDefaultCord) { - size += pb::CodedOutputStream.ComputeStringSize(85, DefaultCord); + size += dataSize; + size += 2 * repeatedStringPiece_.Count; + } + { + int dataSize = 0; + foreach (string element in RepeatedCordList) { + dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + size += dataSize; + size += 2 * repeatedCord_.Count; + } + if (hasDefaultInt32) { + size += pb::CodedOutputStream.ComputeInt32Size(61, DefaultInt32); + } + if (hasDefaultInt64) { + size += pb::CodedOutputStream.ComputeInt64Size(62, DefaultInt64); + } + if (hasDefaultUint32) { + size += pb::CodedOutputStream.ComputeUInt32Size(63, DefaultUint32); + } + if (hasDefaultUint64) { + size += pb::CodedOutputStream.ComputeUInt64Size(64, DefaultUint64); + } + if (hasDefaultSint32) { + size += pb::CodedOutputStream.ComputeSInt32Size(65, DefaultSint32); + } + if (hasDefaultSint64) { + size += pb::CodedOutputStream.ComputeSInt64Size(66, DefaultSint64); + } + if (hasDefaultFixed32) { + size += pb::CodedOutputStream.ComputeFixed32Size(67, DefaultFixed32); + } + if (hasDefaultFixed64) { + size += pb::CodedOutputStream.ComputeFixed64Size(68, DefaultFixed64); } + if (hasDefaultSfixed32) { + size += pb::CodedOutputStream.ComputeSFixed32Size(69, DefaultSfixed32); + } + if (hasDefaultSfixed64) { + size += pb::CodedOutputStream.ComputeSFixed64Size(70, DefaultSfixed64); + } + if (hasDefaultFloat) { + size += pb::CodedOutputStream.ComputeFloatSize(71, DefaultFloat); + } + if (hasDefaultDouble) { + size += pb::CodedOutputStream.ComputeDoubleSize(72, DefaultDouble); + } + if (hasDefaultBool) { + size += pb::CodedOutputStream.ComputeBoolSize(73, DefaultBool); + } + if (hasDefaultString) { + size += pb::CodedOutputStream.ComputeStringSize(74, DefaultString); + } + if (hasDefaultBytes) { + size += pb::CodedOutputStream.ComputeBytesSize(75, DefaultBytes); + } + if (hasDefaultNestedEnum) { + size += pb::CodedOutputStream.ComputeEnumSize(81, (int) DefaultNestedEnum); + } + if (hasDefaultForeignEnum) { + size += pb::CodedOutputStream.ComputeEnumSize(82, (int) DefaultForeignEnum); + } + if (hasDefaultImportEnum) { + size += pb::CodedOutputStream.ComputeEnumSize(83, (int) DefaultImportEnum); + } + if (hasDefaultStringPiece) { + size += pb::CodedOutputStream.ComputeStringSize(84, DefaultStringPiece); + } + if (hasDefaultCord) { + size += pb::CodedOutputStream.ComputeStringSize(85, DefaultCord); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; } - public static TestAllTypes ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -5765,7 +5785,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testDeprecatedFieldsFieldNames; if (hasDeprecatedInt32) { output.WriteInt32(1, field_names[0], DeprecatedInt32); @@ -5778,17 +5798,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasDeprecatedInt32) { - size += pb::CodedOutputStream.ComputeInt32Size(1, DeprecatedInt32); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasDeprecatedInt32) { + size += pb::CodedOutputStream.ComputeInt32Size(1, DeprecatedInt32); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestDeprecatedFields ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -6039,7 +6064,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _foreignMessageFieldNames; if (hasC) { output.WriteInt32(1, field_names[0], C); @@ -6052,17 +6077,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasC) { - size += pb::CodedOutputStream.ComputeInt32Size(1, C); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasC) { + size += pb::CodedOutputStream.ComputeInt32Size(1, C); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static ForeignMessage ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -6300,7 +6330,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testAllExtensionsFieldNames; pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); extensionWriter.WriteUntil(536870912, output); @@ -6312,15 +6342,20 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - size += ExtensionsSerializedSize; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += ExtensionsSerializedSize; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestAllExtensions ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -6541,7 +6576,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _optionalGroupExtensionFieldNames; if (hasA) { output.WriteInt32(17, field_names[0], A); @@ -6554,17 +6589,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(17, A); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasA) { + size += pb::CodedOutputStream.ComputeInt32Size(17, A); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static OptionalGroup_extension ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -6811,7 +6851,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _repeatedGroupExtensionFieldNames; if (hasA) { output.WriteInt32(47, field_names[0], A); @@ -6824,17 +6864,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(47, A); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasA) { + size += pb::CodedOutputStream.ComputeInt32Size(47, A); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static RepeatedGroup_extension ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -7073,7 +7118,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testNestedExtensionFieldNames; UnknownFields.WriteTo(output); } @@ -7083,14 +7128,19 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestNestedExtension ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -7637,7 +7687,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testRequiredFieldNames; if (hasA) { output.WriteInt32(1, field_names[0], A); @@ -7746,113 +7796,118 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(1, A); - } - if (hasDummy2) { - size += pb::CodedOutputStream.ComputeInt32Size(2, Dummy2); - } - if (hasB) { - size += pb::CodedOutputStream.ComputeInt32Size(3, B); - } - if (hasDummy4) { - size += pb::CodedOutputStream.ComputeInt32Size(4, Dummy4); - } - if (hasDummy5) { - size += pb::CodedOutputStream.ComputeInt32Size(5, Dummy5); - } - if (hasDummy6) { - size += pb::CodedOutputStream.ComputeInt32Size(6, Dummy6); - } - if (hasDummy7) { - size += pb::CodedOutputStream.ComputeInt32Size(7, Dummy7); - } - if (hasDummy8) { - size += pb::CodedOutputStream.ComputeInt32Size(8, Dummy8); - } - if (hasDummy9) { - size += pb::CodedOutputStream.ComputeInt32Size(9, Dummy9); - } - if (hasDummy10) { - size += pb::CodedOutputStream.ComputeInt32Size(10, Dummy10); - } - if (hasDummy11) { - size += pb::CodedOutputStream.ComputeInt32Size(11, Dummy11); - } - if (hasDummy12) { - size += pb::CodedOutputStream.ComputeInt32Size(12, Dummy12); - } - if (hasDummy13) { - size += pb::CodedOutputStream.ComputeInt32Size(13, Dummy13); - } - if (hasDummy14) { - size += pb::CodedOutputStream.ComputeInt32Size(14, Dummy14); - } - if (hasDummy15) { - size += pb::CodedOutputStream.ComputeInt32Size(15, Dummy15); - } - if (hasDummy16) { - size += pb::CodedOutputStream.ComputeInt32Size(16, Dummy16); - } - if (hasDummy17) { - size += pb::CodedOutputStream.ComputeInt32Size(17, Dummy17); - } - if (hasDummy18) { - size += pb::CodedOutputStream.ComputeInt32Size(18, Dummy18); - } - if (hasDummy19) { - size += pb::CodedOutputStream.ComputeInt32Size(19, Dummy19); - } - if (hasDummy20) { - size += pb::CodedOutputStream.ComputeInt32Size(20, Dummy20); - } - if (hasDummy21) { - size += pb::CodedOutputStream.ComputeInt32Size(21, Dummy21); - } - if (hasDummy22) { - size += pb::CodedOutputStream.ComputeInt32Size(22, Dummy22); - } - if (hasDummy23) { - size += pb::CodedOutputStream.ComputeInt32Size(23, Dummy23); - } - if (hasDummy24) { - size += pb::CodedOutputStream.ComputeInt32Size(24, Dummy24); - } - if (hasDummy25) { - size += pb::CodedOutputStream.ComputeInt32Size(25, Dummy25); - } - if (hasDummy26) { - size += pb::CodedOutputStream.ComputeInt32Size(26, Dummy26); - } - if (hasDummy27) { - size += pb::CodedOutputStream.ComputeInt32Size(27, Dummy27); - } - if (hasDummy28) { - size += pb::CodedOutputStream.ComputeInt32Size(28, Dummy28); - } - if (hasDummy29) { - size += pb::CodedOutputStream.ComputeInt32Size(29, Dummy29); - } - if (hasDummy30) { - size += pb::CodedOutputStream.ComputeInt32Size(30, Dummy30); - } - if (hasDummy31) { - size += pb::CodedOutputStream.ComputeInt32Size(31, Dummy31); - } - if (hasDummy32) { - size += pb::CodedOutputStream.ComputeInt32Size(32, Dummy32); - } - if (hasC) { - size += pb::CodedOutputStream.ComputeInt32Size(33, C); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasA) { + size += pb::CodedOutputStream.ComputeInt32Size(1, A); + } + if (hasDummy2) { + size += pb::CodedOutputStream.ComputeInt32Size(2, Dummy2); + } + if (hasB) { + size += pb::CodedOutputStream.ComputeInt32Size(3, B); + } + if (hasDummy4) { + size += pb::CodedOutputStream.ComputeInt32Size(4, Dummy4); + } + if (hasDummy5) { + size += pb::CodedOutputStream.ComputeInt32Size(5, Dummy5); + } + if (hasDummy6) { + size += pb::CodedOutputStream.ComputeInt32Size(6, Dummy6); + } + if (hasDummy7) { + size += pb::CodedOutputStream.ComputeInt32Size(7, Dummy7); + } + if (hasDummy8) { + size += pb::CodedOutputStream.ComputeInt32Size(8, Dummy8); + } + if (hasDummy9) { + size += pb::CodedOutputStream.ComputeInt32Size(9, Dummy9); + } + if (hasDummy10) { + size += pb::CodedOutputStream.ComputeInt32Size(10, Dummy10); + } + if (hasDummy11) { + size += pb::CodedOutputStream.ComputeInt32Size(11, Dummy11); + } + if (hasDummy12) { + size += pb::CodedOutputStream.ComputeInt32Size(12, Dummy12); + } + if (hasDummy13) { + size += pb::CodedOutputStream.ComputeInt32Size(13, Dummy13); + } + if (hasDummy14) { + size += pb::CodedOutputStream.ComputeInt32Size(14, Dummy14); + } + if (hasDummy15) { + size += pb::CodedOutputStream.ComputeInt32Size(15, Dummy15); + } + if (hasDummy16) { + size += pb::CodedOutputStream.ComputeInt32Size(16, Dummy16); + } + if (hasDummy17) { + size += pb::CodedOutputStream.ComputeInt32Size(17, Dummy17); + } + if (hasDummy18) { + size += pb::CodedOutputStream.ComputeInt32Size(18, Dummy18); + } + if (hasDummy19) { + size += pb::CodedOutputStream.ComputeInt32Size(19, Dummy19); + } + if (hasDummy20) { + size += pb::CodedOutputStream.ComputeInt32Size(20, Dummy20); + } + if (hasDummy21) { + size += pb::CodedOutputStream.ComputeInt32Size(21, Dummy21); + } + if (hasDummy22) { + size += pb::CodedOutputStream.ComputeInt32Size(22, Dummy22); + } + if (hasDummy23) { + size += pb::CodedOutputStream.ComputeInt32Size(23, Dummy23); + } + if (hasDummy24) { + size += pb::CodedOutputStream.ComputeInt32Size(24, Dummy24); + } + if (hasDummy25) { + size += pb::CodedOutputStream.ComputeInt32Size(25, Dummy25); + } + if (hasDummy26) { + size += pb::CodedOutputStream.ComputeInt32Size(26, Dummy26); + } + if (hasDummy27) { + size += pb::CodedOutputStream.ComputeInt32Size(27, Dummy27); + } + if (hasDummy28) { + size += pb::CodedOutputStream.ComputeInt32Size(28, Dummy28); + } + if (hasDummy29) { + size += pb::CodedOutputStream.ComputeInt32Size(29, Dummy29); + } + if (hasDummy30) { + size += pb::CodedOutputStream.ComputeInt32Size(30, Dummy30); + } + if (hasDummy31) { + size += pb::CodedOutputStream.ComputeInt32Size(31, Dummy31); + } + if (hasDummy32) { + size += pb::CodedOutputStream.ComputeInt32Size(32, Dummy32); + } + if (hasC) { + size += pb::CodedOutputStream.ComputeInt32Size(33, C); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestRequired ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -8991,7 +9046,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testRequiredForeignFieldNames; if (hasOptionalMessage) { output.WriteMessage(1, field_names[1], OptionalMessage); @@ -9010,23 +9065,28 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasOptionalMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(1, OptionalMessage); - } - foreach (global::Google.ProtocolBuffers.TestProtos.TestRequired element in RepeatedMessageList) { - size += pb::CodedOutputStream.ComputeMessageSize(2, element); - } - if (hasDummy) { - size += pb::CodedOutputStream.ComputeInt32Size(3, Dummy); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasOptionalMessage) { + size += pb::CodedOutputStream.ComputeMessageSize(1, OptionalMessage); + } + foreach (global::Google.ProtocolBuffers.TestProtos.TestRequired element in RepeatedMessageList) { + size += pb::CodedOutputStream.ComputeMessageSize(2, element); + } + if (hasDummy) { + size += pb::CodedOutputStream.ComputeInt32Size(3, Dummy); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestRequiredForeign ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -9377,7 +9437,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testForeignNestedFieldNames; if (hasForeignNested) { output.WriteMessage(1, field_names[0], ForeignNested); @@ -9390,17 +9450,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasForeignNested) { - size += pb::CodedOutputStream.ComputeMessageSize(1, ForeignNested); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasForeignNested) { + size += pb::CodedOutputStream.ComputeMessageSize(1, ForeignNested); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestForeignNested ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -9662,7 +9727,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testEmptyMessageFieldNames; UnknownFields.WriteTo(output); } @@ -9672,14 +9737,19 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestEmptyMessage ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -9890,7 +9960,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testEmptyMessageWithExtensionsFieldNames; pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); extensionWriter.WriteUntil(536870912, output); @@ -9902,15 +9972,20 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - size += ExtensionsSerializedSize; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += ExtensionsSerializedSize; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestEmptyMessageWithExtensions ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -10122,7 +10197,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testMultipleExtensionRangesFieldNames; pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); extensionWriter.WriteUntil(43, output); @@ -10136,15 +10211,20 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - size += ExtensionsSerializedSize; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += ExtensionsSerializedSize; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestMultipleExtensionRanges ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -10375,7 +10455,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testReallyLargeTagNumberFieldNames; if (hasA) { output.WriteInt32(1, field_names[0], A); @@ -10391,20 +10471,25 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(1, A); - } - if (hasBb) { - size += pb::CodedOutputStream.ComputeInt32Size(268435455, Bb); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasA) { + size += pb::CodedOutputStream.ComputeInt32Size(1, A); + } + if (hasBb) { + size += pb::CodedOutputStream.ComputeInt32Size(268435455, Bb); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestReallyLargeTagNumber ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -10688,7 +10773,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testRecursiveMessageFieldNames; if (hasA) { output.WriteMessage(1, field_names[0], A); @@ -10704,20 +10789,25 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeMessageSize(1, A); - } - if (hasI) { - size += pb::CodedOutputStream.ComputeInt32Size(2, I); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasA) { + size += pb::CodedOutputStream.ComputeMessageSize(1, A); + } + if (hasI) { + size += pb::CodedOutputStream.ComputeInt32Size(2, I); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestRecursiveMessage ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -11016,7 +11106,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testMutualRecursionAFieldNames; if (hasBb) { output.WriteMessage(1, field_names[0], Bb); @@ -11029,17 +11119,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasBb) { - size += pb::CodedOutputStream.ComputeMessageSize(1, Bb); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasBb) { + size += pb::CodedOutputStream.ComputeMessageSize(1, Bb); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestMutualRecursionA ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -11321,7 +11416,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testMutualRecursionBFieldNames; if (hasA) { output.WriteMessage(1, field_names[0], A); @@ -11337,20 +11432,25 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeMessageSize(1, A); - } - if (hasOptionalInt32) { - size += pb::CodedOutputStream.ComputeInt32Size(2, OptionalInt32); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasA) { + size += pb::CodedOutputStream.ComputeMessageSize(1, A); + } + if (hasOptionalInt32) { + size += pb::CodedOutputStream.ComputeInt32Size(2, OptionalInt32); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestMutualRecursionB ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -11678,7 +11778,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _fooFieldNames; if (hasA) { output.WriteInt32(1, field_names[0], A); @@ -11691,17 +11791,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(1, A); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasA) { + size += pb::CodedOutputStream.ComputeInt32Size(1, A); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static Foo ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -11948,7 +12053,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _barFieldNames; if (hasA) { output.WriteInt32(1, field_names[0], A); @@ -11961,17 +12066,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(1, A); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasA) { + size += pb::CodedOutputStream.ComputeInt32Size(1, A); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static Bar ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -12215,7 +12325,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testDupFieldNumberFieldNames; if (hasA) { output.WriteInt32(1, field_names[0], A); @@ -12234,23 +12344,28 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(1, A); - } - if (hasFoo) { - size += pb::CodedOutputStream.ComputeGroupSize(2, Foo); - } - if (hasBar) { - size += pb::CodedOutputStream.ComputeGroupSize(3, Bar); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasA) { + size += pb::CodedOutputStream.ComputeInt32Size(1, A); + } + if (hasFoo) { + size += pb::CodedOutputStream.ComputeGroupSize(2, Foo); + } + if (hasBar) { + size += pb::CodedOutputStream.ComputeGroupSize(3, Bar); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestDupFieldNumber ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -12644,7 +12759,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _nestedMessageFieldNames; if (nestedmessageRepeatedInt32_.Count > 0) { output.WriteInt32Array(1, field_names[1], nestedmessageRepeatedInt32_); @@ -12660,25 +12775,30 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - { - int dataSize = 0; - foreach (int element in NestedmessageRepeatedInt32List) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); - } - size += dataSize; - size += 1 * nestedmessageRepeatedInt32_.Count; - } - foreach (global::Google.ProtocolBuffers.TestProtos.ForeignMessage element in NestedmessageRepeatedForeignmessageList) { - size += pb::CodedOutputStream.ComputeMessageSize(2, element); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + { + int dataSize = 0; + foreach (int element in NestedmessageRepeatedInt32List) { + dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); + } + size += dataSize; + size += 1 * nestedmessageRepeatedInt32_.Count; + } + foreach (global::Google.ProtocolBuffers.TestProtos.ForeignMessage element in NestedmessageRepeatedForeignmessageList) { + size += pb::CodedOutputStream.ComputeMessageSize(2, element); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static NestedMessage ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -12966,7 +13086,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testNestedMessageHasBitsFieldNames; if (hasOptionalNestedMessage) { output.WriteMessage(1, field_names[0], OptionalNestedMessage); @@ -12979,17 +13099,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasOptionalNestedMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(1, OptionalNestedMessage); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasOptionalNestedMessage) { + size += pb::CodedOutputStream.ComputeMessageSize(1, OptionalNestedMessage); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestNestedMessageHasBits ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -13383,7 +13508,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testCamelCaseFieldNamesFieldNames; if (hasPrimitiveField) { output.WriteInt32(1, field_names[3], PrimitiveField); @@ -13429,77 +13554,82 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasPrimitiveField) { - size += pb::CodedOutputStream.ComputeInt32Size(1, PrimitiveField); - } - if (hasStringField) { - size += pb::CodedOutputStream.ComputeStringSize(2, StringField); - } - if (hasEnumField) { - size += pb::CodedOutputStream.ComputeEnumSize(3, (int) EnumField); - } - if (hasMessageField) { - size += pb::CodedOutputStream.ComputeMessageSize(4, MessageField); - } - if (hasStringPieceField) { - size += pb::CodedOutputStream.ComputeStringSize(5, StringPieceField); - } - if (hasCordField) { - size += pb::CodedOutputStream.ComputeStringSize(6, CordField); + return CalcSerializedSize(); + } + } + + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasPrimitiveField) { + size += pb::CodedOutputStream.ComputeInt32Size(1, PrimitiveField); + } + if (hasStringField) { + size += pb::CodedOutputStream.ComputeStringSize(2, StringField); + } + if (hasEnumField) { + size += pb::CodedOutputStream.ComputeEnumSize(3, (int) EnumField); + } + if (hasMessageField) { + size += pb::CodedOutputStream.ComputeMessageSize(4, MessageField); + } + if (hasStringPieceField) { + size += pb::CodedOutputStream.ComputeStringSize(5, StringPieceField); + } + if (hasCordField) { + size += pb::CodedOutputStream.ComputeStringSize(6, CordField); + } + { + int dataSize = 0; + foreach (int element in RepeatedPrimitiveFieldList) { + dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); } - { - int dataSize = 0; - foreach (int element in RepeatedPrimitiveFieldList) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); - } - size += dataSize; - size += 1 * repeatedPrimitiveField_.Count; + size += dataSize; + size += 1 * repeatedPrimitiveField_.Count; + } + { + int dataSize = 0; + foreach (string element in RepeatedStringFieldList) { + dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); } - { - int dataSize = 0; - foreach (string element in RepeatedStringFieldList) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); + size += dataSize; + size += 1 * repeatedStringField_.Count; + } + { + int dataSize = 0; + if (repeatedEnumField_.Count > 0) { + foreach (global::Google.ProtocolBuffers.TestProtos.ForeignEnum element in repeatedEnumField_) { + dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); } size += dataSize; - size += 1 * repeatedStringField_.Count; - } - { - int dataSize = 0; - if (repeatedEnumField_.Count > 0) { - foreach (global::Google.ProtocolBuffers.TestProtos.ForeignEnum element in repeatedEnumField_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 1 * repeatedEnumField_.Count; - } - } - foreach (global::Google.ProtocolBuffers.TestProtos.ForeignMessage element in RepeatedMessageFieldList) { - size += pb::CodedOutputStream.ComputeMessageSize(10, element); + size += 1 * repeatedEnumField_.Count; } - { - int dataSize = 0; - foreach (string element in RepeatedStringPieceFieldList) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); - } - size += dataSize; - size += 1 * repeatedStringPieceField_.Count; + } + foreach (global::Google.ProtocolBuffers.TestProtos.ForeignMessage element in RepeatedMessageFieldList) { + size += pb::CodedOutputStream.ComputeMessageSize(10, element); + } + { + int dataSize = 0; + foreach (string element in RepeatedStringPieceFieldList) { + dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); } - { - int dataSize = 0; - foreach (string element in RepeatedCordFieldList) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); - } - size += dataSize; - size += 1 * repeatedCordField_.Count; + size += dataSize; + size += 1 * repeatedStringPieceField_.Count; + } + { + int dataSize = 0; + foreach (string element in RepeatedCordFieldList) { + dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + size += dataSize; + size += 1 * repeatedCordField_.Count; } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; } - public static TestCamelCaseFieldNames ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -14197,7 +14327,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testFieldOrderingsFieldNames; pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); if (hasMyInt) { @@ -14216,27 +14346,32 @@ namespace Google.ProtocolBuffers.TestProtos { private int memoizedSerializedSize = -1; public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasMyString) { - size += pb::CodedOutputStream.ComputeStringSize(11, MyString); - } - if (hasMyInt) { - size += pb::CodedOutputStream.ComputeInt64Size(1, MyInt); - } - if (hasMyFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(101, MyFloat); - } - size += ExtensionsSerializedSize; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + get { + int size = memoizedSerializedSize; + if (size != -1) return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasMyString) { + size += pb::CodedOutputStream.ComputeStringSize(11, MyString); + } + if (hasMyInt) { + size += pb::CodedOutputStream.ComputeInt64Size(1, MyInt); + } + if (hasMyFloat) { + size += pb::CodedOutputStream.ComputeFloatSize(101, MyFloat); + } + size += ExtensionsSerializedSize; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestFieldOrderings ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -14731,7 +14866,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testExtremeDefaultValuesFieldNames; if (hasEscapedBytes) { output.WriteBytes(1, field_names[1], EscapedBytes); @@ -14801,74 +14936,79 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasEscapedBytes) { - size += pb::CodedOutputStream.ComputeBytesSize(1, EscapedBytes); - } - if (hasLargeUint32) { - size += pb::CodedOutputStream.ComputeUInt32Size(2, LargeUint32); - } - if (hasLargeUint64) { - size += pb::CodedOutputStream.ComputeUInt64Size(3, LargeUint64); - } - if (hasSmallInt32) { - size += pb::CodedOutputStream.ComputeInt32Size(4, SmallInt32); - } - if (hasSmallInt64) { - size += pb::CodedOutputStream.ComputeInt64Size(5, SmallInt64); - } - if (hasUtf8String) { - size += pb::CodedOutputStream.ComputeStringSize(6, Utf8String); - } - if (hasZeroFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(7, ZeroFloat); - } - if (hasOneFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(8, OneFloat); - } - if (hasSmallFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(9, SmallFloat); - } - if (hasNegativeOneFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(10, NegativeOneFloat); - } - if (hasNegativeFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(11, NegativeFloat); - } - if (hasLargeFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(12, LargeFloat); - } - if (hasSmallNegativeFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(13, SmallNegativeFloat); - } - if (hasInfDouble) { - size += pb::CodedOutputStream.ComputeDoubleSize(14, InfDouble); - } - if (hasNegInfDouble) { - size += pb::CodedOutputStream.ComputeDoubleSize(15, NegInfDouble); - } - if (hasNanDouble) { - size += pb::CodedOutputStream.ComputeDoubleSize(16, NanDouble); - } - if (hasInfFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(17, InfFloat); - } - if (hasNegInfFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(18, NegInfFloat); - } - if (hasNanFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(19, NanFloat); - } - if (hasCppTrigraph) { - size += pb::CodedOutputStream.ComputeStringSize(20, CppTrigraph); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasEscapedBytes) { + size += pb::CodedOutputStream.ComputeBytesSize(1, EscapedBytes); + } + if (hasLargeUint32) { + size += pb::CodedOutputStream.ComputeUInt32Size(2, LargeUint32); + } + if (hasLargeUint64) { + size += pb::CodedOutputStream.ComputeUInt64Size(3, LargeUint64); + } + if (hasSmallInt32) { + size += pb::CodedOutputStream.ComputeInt32Size(4, SmallInt32); + } + if (hasSmallInt64) { + size += pb::CodedOutputStream.ComputeInt64Size(5, SmallInt64); + } + if (hasUtf8String) { + size += pb::CodedOutputStream.ComputeStringSize(6, Utf8String); + } + if (hasZeroFloat) { + size += pb::CodedOutputStream.ComputeFloatSize(7, ZeroFloat); + } + if (hasOneFloat) { + size += pb::CodedOutputStream.ComputeFloatSize(8, OneFloat); + } + if (hasSmallFloat) { + size += pb::CodedOutputStream.ComputeFloatSize(9, SmallFloat); + } + if (hasNegativeOneFloat) { + size += pb::CodedOutputStream.ComputeFloatSize(10, NegativeOneFloat); + } + if (hasNegativeFloat) { + size += pb::CodedOutputStream.ComputeFloatSize(11, NegativeFloat); + } + if (hasLargeFloat) { + size += pb::CodedOutputStream.ComputeFloatSize(12, LargeFloat); + } + if (hasSmallNegativeFloat) { + size += pb::CodedOutputStream.ComputeFloatSize(13, SmallNegativeFloat); + } + if (hasInfDouble) { + size += pb::CodedOutputStream.ComputeDoubleSize(14, InfDouble); + } + if (hasNegInfDouble) { + size += pb::CodedOutputStream.ComputeDoubleSize(15, NegInfDouble); + } + if (hasNanDouble) { + size += pb::CodedOutputStream.ComputeDoubleSize(16, NanDouble); + } + if (hasInfFloat) { + size += pb::CodedOutputStream.ComputeFloatSize(17, InfFloat); + } + if (hasNegInfFloat) { + size += pb::CodedOutputStream.ComputeFloatSize(18, NegInfFloat); + } + if (hasNanFloat) { + size += pb::CodedOutputStream.ComputeFloatSize(19, NanFloat); + } + if (hasCppTrigraph) { + size += pb::CodedOutputStream.ComputeStringSize(20, CppTrigraph); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestExtremeDefaultValues ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -15635,7 +15775,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _sparseEnumMessageFieldNames; if (hasSparseEnum) { output.WriteEnum(1, field_names[0], (int) SparseEnum, SparseEnum); @@ -15648,17 +15788,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasSparseEnum) { - size += pb::CodedOutputStream.ComputeEnumSize(1, (int) SparseEnum); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasSparseEnum) { + size += pb::CodedOutputStream.ComputeEnumSize(1, (int) SparseEnum); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static SparseEnumMessage ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -15913,7 +16058,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _oneStringFieldNames; if (hasData) { output.WriteString(1, field_names[0], Data); @@ -15926,17 +16071,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasData) { - size += pb::CodedOutputStream.ComputeStringSize(1, Data); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasData) { + size += pb::CodedOutputStream.ComputeStringSize(1, Data); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static OneString ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -16184,7 +16334,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _oneBytesFieldNames; if (hasData) { output.WriteBytes(1, field_names[0], Data); @@ -16197,17 +16347,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasData) { - size += pb::CodedOutputStream.ComputeBytesSize(1, Data); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasData) { + size += pb::CodedOutputStream.ComputeBytesSize(1, Data); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static OneBytes ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -16635,7 +16790,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testPackedTypesFieldNames; if (packedInt32_.Count > 0) { output.WritePackedInt32Array(90, field_names[6], packedInt32MemoizedSerializedSize, packedInt32_); @@ -16687,155 +16842,160 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - { - int dataSize = 0; - foreach (int element in PackedInt32List) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); - } - size += dataSize; - if (packedInt32_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedInt32MemoizedSerializedSize = dataSize; + return CalcSerializedSize(); + } + } + + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + { + int dataSize = 0; + foreach (int element in PackedInt32List) { + dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); } - { - int dataSize = 0; - foreach (long element in PackedInt64List) { - dataSize += pb::CodedOutputStream.ComputeInt64SizeNoTag(element); - } - size += dataSize; - if (packedInt64_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedInt64MemoizedSerializedSize = dataSize; + size += dataSize; + if (packedInt32_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { - int dataSize = 0; - foreach (uint element in PackedUint32List) { - dataSize += pb::CodedOutputStream.ComputeUInt32SizeNoTag(element); - } - size += dataSize; - if (packedUint32_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedUint32MemoizedSerializedSize = dataSize; + packedInt32MemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + foreach (long element in PackedInt64List) { + dataSize += pb::CodedOutputStream.ComputeInt64SizeNoTag(element); } - { - int dataSize = 0; - foreach (ulong element in PackedUint64List) { - dataSize += pb::CodedOutputStream.ComputeUInt64SizeNoTag(element); - } - size += dataSize; - if (packedUint64_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedUint64MemoizedSerializedSize = dataSize; + size += dataSize; + if (packedInt64_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { - int dataSize = 0; - foreach (int element in PackedSint32List) { - dataSize += pb::CodedOutputStream.ComputeSInt32SizeNoTag(element); - } - size += dataSize; - if (packedSint32_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedSint32MemoizedSerializedSize = dataSize; + packedInt64MemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + foreach (uint element in PackedUint32List) { + dataSize += pb::CodedOutputStream.ComputeUInt32SizeNoTag(element); } - { - int dataSize = 0; - foreach (long element in PackedSint64List) { - dataSize += pb::CodedOutputStream.ComputeSInt64SizeNoTag(element); - } - size += dataSize; - if (packedSint64_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedSint64MemoizedSerializedSize = dataSize; + size += dataSize; + if (packedUint32_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { - int dataSize = 0; - dataSize = 4 * packedFixed32_.Count; - size += dataSize; - if (packedFixed32_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedFixed32MemoizedSerializedSize = dataSize; + packedUint32MemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + foreach (ulong element in PackedUint64List) { + dataSize += pb::CodedOutputStream.ComputeUInt64SizeNoTag(element); } - { - int dataSize = 0; - dataSize = 8 * packedFixed64_.Count; - size += dataSize; - if (packedFixed64_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedFixed64MemoizedSerializedSize = dataSize; + size += dataSize; + if (packedUint64_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { - int dataSize = 0; - dataSize = 4 * packedSfixed32_.Count; - size += dataSize; - if (packedSfixed32_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedSfixed32MemoizedSerializedSize = dataSize; + packedUint64MemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + foreach (int element in PackedSint32List) { + dataSize += pb::CodedOutputStream.ComputeSInt32SizeNoTag(element); } - { - int dataSize = 0; - dataSize = 8 * packedSfixed64_.Count; - size += dataSize; - if (packedSfixed64_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedSfixed64MemoizedSerializedSize = dataSize; + size += dataSize; + if (packedSint32_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { - int dataSize = 0; - dataSize = 4 * packedFloat_.Count; - size += dataSize; - if (packedFloat_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedFloatMemoizedSerializedSize = dataSize; + packedSint32MemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + foreach (long element in PackedSint64List) { + dataSize += pb::CodedOutputStream.ComputeSInt64SizeNoTag(element); } - { - int dataSize = 0; - dataSize = 8 * packedDouble_.Count; - size += dataSize; - if (packedDouble_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedDoubleMemoizedSerializedSize = dataSize; + size += dataSize; + if (packedSint64_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { - int dataSize = 0; - dataSize = 1 * packedBool_.Count; - size += dataSize; - if (packedBool_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedBoolMemoizedSerializedSize = dataSize; + packedSint64MemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + dataSize = 4 * packedFixed32_.Count; + size += dataSize; + if (packedFixed32_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { - int dataSize = 0; - if (packedEnum_.Count > 0) { - foreach (global::Google.ProtocolBuffers.TestProtos.ForeignEnum element in packedEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 2; - size += pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize); + packedFixed32MemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + dataSize = 8 * packedFixed64_.Count; + size += dataSize; + if (packedFixed64_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + } + packedFixed64MemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + dataSize = 4 * packedSfixed32_.Count; + size += dataSize; + if (packedSfixed32_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + } + packedSfixed32MemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + dataSize = 8 * packedSfixed64_.Count; + size += dataSize; + if (packedSfixed64_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + } + packedSfixed64MemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + dataSize = 4 * packedFloat_.Count; + size += dataSize; + if (packedFloat_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + } + packedFloatMemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + dataSize = 8 * packedDouble_.Count; + size += dataSize; + if (packedDouble_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + } + packedDoubleMemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + dataSize = 1 * packedBool_.Count; + size += dataSize; + if (packedBool_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + } + packedBoolMemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + if (packedEnum_.Count > 0) { + foreach (global::Google.ProtocolBuffers.TestProtos.ForeignEnum element in packedEnum_) { + dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); } - packedEnumMemoizedSerializedSize = dataSize; + size += dataSize; + size += 2; + size += pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize); } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + packedEnumMemoizedSerializedSize = dataSize; } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; } - public static TestPackedTypes ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -17796,7 +17956,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testUnpackedTypesFieldNames; if (unpackedInt32_.Count > 0) { output.WriteInt32Array(90, field_names[6], unpackedInt32_); @@ -17848,114 +18008,119 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - { - int dataSize = 0; - foreach (int element in UnpackedInt32List) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); - } - size += dataSize; - size += 2 * unpackedInt32_.Count; - } - { - int dataSize = 0; - foreach (long element in UnpackedInt64List) { - dataSize += pb::CodedOutputStream.ComputeInt64SizeNoTag(element); - } - size += dataSize; - size += 2 * unpackedInt64_.Count; - } - { - int dataSize = 0; - foreach (uint element in UnpackedUint32List) { - dataSize += pb::CodedOutputStream.ComputeUInt32SizeNoTag(element); - } - size += dataSize; - size += 2 * unpackedUint32_.Count; - } - { - int dataSize = 0; - foreach (ulong element in UnpackedUint64List) { - dataSize += pb::CodedOutputStream.ComputeUInt64SizeNoTag(element); - } - size += dataSize; - size += 2 * unpackedUint64_.Count; - } - { - int dataSize = 0; - foreach (int element in UnpackedSint32List) { - dataSize += pb::CodedOutputStream.ComputeSInt32SizeNoTag(element); + return CalcSerializedSize(); + } + } + + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + { + int dataSize = 0; + foreach (int element in UnpackedInt32List) { + dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); + } + size += dataSize; + size += 2 * unpackedInt32_.Count; + } + { + int dataSize = 0; + foreach (long element in UnpackedInt64List) { + dataSize += pb::CodedOutputStream.ComputeInt64SizeNoTag(element); + } + size += dataSize; + size += 2 * unpackedInt64_.Count; + } + { + int dataSize = 0; + foreach (uint element in UnpackedUint32List) { + dataSize += pb::CodedOutputStream.ComputeUInt32SizeNoTag(element); + } + size += dataSize; + size += 2 * unpackedUint32_.Count; + } + { + int dataSize = 0; + foreach (ulong element in UnpackedUint64List) { + dataSize += pb::CodedOutputStream.ComputeUInt64SizeNoTag(element); + } + size += dataSize; + size += 2 * unpackedUint64_.Count; + } + { + int dataSize = 0; + foreach (int element in UnpackedSint32List) { + dataSize += pb::CodedOutputStream.ComputeSInt32SizeNoTag(element); + } + size += dataSize; + size += 2 * unpackedSint32_.Count; + } + { + int dataSize = 0; + foreach (long element in UnpackedSint64List) { + dataSize += pb::CodedOutputStream.ComputeSInt64SizeNoTag(element); + } + size += dataSize; + size += 2 * unpackedSint64_.Count; + } + { + int dataSize = 0; + dataSize = 4 * unpackedFixed32_.Count; + size += dataSize; + size += 2 * unpackedFixed32_.Count; + } + { + int dataSize = 0; + dataSize = 8 * unpackedFixed64_.Count; + size += dataSize; + size += 2 * unpackedFixed64_.Count; + } + { + int dataSize = 0; + dataSize = 4 * unpackedSfixed32_.Count; + size += dataSize; + size += 2 * unpackedSfixed32_.Count; + } + { + int dataSize = 0; + dataSize = 8 * unpackedSfixed64_.Count; + size += dataSize; + size += 2 * unpackedSfixed64_.Count; + } + { + int dataSize = 0; + dataSize = 4 * unpackedFloat_.Count; + size += dataSize; + size += 2 * unpackedFloat_.Count; + } + { + int dataSize = 0; + dataSize = 8 * unpackedDouble_.Count; + size += dataSize; + size += 2 * unpackedDouble_.Count; + } + { + int dataSize = 0; + dataSize = 1 * unpackedBool_.Count; + size += dataSize; + size += 2 * unpackedBool_.Count; + } + { + int dataSize = 0; + if (unpackedEnum_.Count > 0) { + foreach (global::Google.ProtocolBuffers.TestProtos.ForeignEnum element in unpackedEnum_) { + dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); } size += dataSize; - size += 2 * unpackedSint32_.Count; - } - { - int dataSize = 0; - foreach (long element in UnpackedSint64List) { - dataSize += pb::CodedOutputStream.ComputeSInt64SizeNoTag(element); - } - size += dataSize; - size += 2 * unpackedSint64_.Count; - } - { - int dataSize = 0; - dataSize = 4 * unpackedFixed32_.Count; - size += dataSize; - size += 2 * unpackedFixed32_.Count; - } - { - int dataSize = 0; - dataSize = 8 * unpackedFixed64_.Count; - size += dataSize; - size += 2 * unpackedFixed64_.Count; - } - { - int dataSize = 0; - dataSize = 4 * unpackedSfixed32_.Count; - size += dataSize; - size += 2 * unpackedSfixed32_.Count; - } - { - int dataSize = 0; - dataSize = 8 * unpackedSfixed64_.Count; - size += dataSize; - size += 2 * unpackedSfixed64_.Count; - } - { - int dataSize = 0; - dataSize = 4 * unpackedFloat_.Count; - size += dataSize; - size += 2 * unpackedFloat_.Count; - } - { - int dataSize = 0; - dataSize = 8 * unpackedDouble_.Count; - size += dataSize; - size += 2 * unpackedDouble_.Count; - } - { - int dataSize = 0; - dataSize = 1 * unpackedBool_.Count; - size += dataSize; - size += 2 * unpackedBool_.Count; - } - { - int dataSize = 0; - if (unpackedEnum_.Count > 0) { - foreach (global::Google.ProtocolBuffers.TestProtos.ForeignEnum element in unpackedEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 2 * unpackedEnum_.Count; - } + size += 2 * unpackedEnum_.Count; } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; } - public static TestUnpackedTypes ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -18741,7 +18906,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testPackedExtensionsFieldNames; pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); extensionWriter.WriteUntil(536870912, output); @@ -18753,15 +18918,20 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - size += ExtensionsSerializedSize; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += ExtensionsSerializedSize; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestPackedExtensions ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -19017,7 +19187,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _dynamicMessageTypeFieldNames; if (hasDynamicField) { output.WriteInt32(2100, field_names[0], DynamicField); @@ -19030,17 +19200,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasDynamicField) { - size += pb::CodedOutputStream.ComputeInt32Size(2100, DynamicField); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasDynamicField) { + size += pb::CodedOutputStream.ComputeInt32Size(2100, DynamicField); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static DynamicMessageType ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -19330,7 +19505,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testDynamicExtensionsFieldNames; if (hasScalarExtension) { output.WriteFixed32(2000, field_names[6], ScalarExtension); @@ -19361,48 +19536,53 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasScalarExtension) { - size += pb::CodedOutputStream.ComputeFixed32Size(2000, ScalarExtension); - } - if (hasEnumExtension) { - size += pb::CodedOutputStream.ComputeEnumSize(2001, (int) EnumExtension); - } - if (hasDynamicEnumExtension) { - size += pb::CodedOutputStream.ComputeEnumSize(2002, (int) DynamicEnumExtension); - } - if (hasMessageExtension) { - size += pb::CodedOutputStream.ComputeMessageSize(2003, MessageExtension); - } - if (hasDynamicMessageExtension) { - size += pb::CodedOutputStream.ComputeMessageSize(2004, DynamicMessageExtension); + return CalcSerializedSize(); + } + } + + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasScalarExtension) { + size += pb::CodedOutputStream.ComputeFixed32Size(2000, ScalarExtension); + } + if (hasEnumExtension) { + size += pb::CodedOutputStream.ComputeEnumSize(2001, (int) EnumExtension); + } + if (hasDynamicEnumExtension) { + size += pb::CodedOutputStream.ComputeEnumSize(2002, (int) DynamicEnumExtension); + } + if (hasMessageExtension) { + size += pb::CodedOutputStream.ComputeMessageSize(2003, MessageExtension); + } + if (hasDynamicMessageExtension) { + size += pb::CodedOutputStream.ComputeMessageSize(2004, DynamicMessageExtension); + } + { + int dataSize = 0; + foreach (string element in RepeatedExtensionList) { + dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); } - { - int dataSize = 0; - foreach (string element in RepeatedExtensionList) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedExtension_.Count; + size += dataSize; + size += 2 * repeatedExtension_.Count; + } + { + int dataSize = 0; + foreach (int element in PackedExtensionList) { + dataSize += pb::CodedOutputStream.ComputeSInt32SizeNoTag(element); } - { - int dataSize = 0; - foreach (int element in PackedExtensionList) { - dataSize += pb::CodedOutputStream.ComputeSInt32SizeNoTag(element); - } - size += dataSize; - if (packedExtension_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedExtensionMemoizedSerializedSize = dataSize; + size += dataSize; + if (packedExtension_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + packedExtensionMemoizedSerializedSize = dataSize; } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; } - public static TestDynamicExtensions ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -19972,7 +20152,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testRepeatedScalarDifferentTagSizesFieldNames; if (repeatedFixed32_.Count > 0) { output.WriteFixed32Array(12, field_names[0], repeatedFixed32_); @@ -20000,56 +20180,61 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - { - int dataSize = 0; - dataSize = 4 * repeatedFixed32_.Count; - size += dataSize; - size += 1 * repeatedFixed32_.Count; - } - { - int dataSize = 0; - foreach (int element in RepeatedInt32List) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); - } - size += dataSize; - size += 1 * repeatedInt32_.Count; - } - { - int dataSize = 0; - dataSize = 8 * repeatedFixed64_.Count; - size += dataSize; - size += 2 * repeatedFixed64_.Count; - } - { - int dataSize = 0; - foreach (long element in RepeatedInt64List) { - dataSize += pb::CodedOutputStream.ComputeInt64SizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedInt64_.Count; + return CalcSerializedSize(); + } + } + + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + { + int dataSize = 0; + dataSize = 4 * repeatedFixed32_.Count; + size += dataSize; + size += 1 * repeatedFixed32_.Count; + } + { + int dataSize = 0; + foreach (int element in RepeatedInt32List) { + dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); } - { - int dataSize = 0; - dataSize = 4 * repeatedFloat_.Count; - size += dataSize; - size += 3 * repeatedFloat_.Count; + size += dataSize; + size += 1 * repeatedInt32_.Count; + } + { + int dataSize = 0; + dataSize = 8 * repeatedFixed64_.Count; + size += dataSize; + size += 2 * repeatedFixed64_.Count; + } + { + int dataSize = 0; + foreach (long element in RepeatedInt64List) { + dataSize += pb::CodedOutputStream.ComputeInt64SizeNoTag(element); } - { - int dataSize = 0; - foreach (ulong element in RepeatedUint64List) { - dataSize += pb::CodedOutputStream.ComputeUInt64SizeNoTag(element); - } - size += dataSize; - size += 3 * repeatedUint64_.Count; + size += dataSize; + size += 2 * repeatedInt64_.Count; + } + { + int dataSize = 0; + dataSize = 4 * repeatedFloat_.Count; + size += dataSize; + size += 3 * repeatedFloat_.Count; + } + { + int dataSize = 0; + foreach (ulong element in RepeatedUint64List) { + dataSize += pb::CodedOutputStream.ComputeUInt64SizeNoTag(element); } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + size += dataSize; + size += 3 * repeatedUint64_.Count; } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; } - public static TestRepeatedScalarDifferentTagSizes ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -20508,7 +20693,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _fooRequestFieldNames; UnknownFields.WriteTo(output); } @@ -20518,14 +20703,19 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static FooRequest ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -20735,7 +20925,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _fooResponseFieldNames; UnknownFields.WriteTo(output); } @@ -20745,14 +20935,19 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static FooResponse ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -20962,7 +21157,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _barRequestFieldNames; UnknownFields.WriteTo(output); } @@ -20972,14 +21167,19 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static BarRequest ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -21189,7 +21389,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _barResponseFieldNames; UnknownFields.WriteTo(output); } @@ -21199,14 +21399,19 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static BarResponse ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } diff --git a/src/ProtocolBuffers.Test/TestProtos/UnitTestCSharpOptionsProtoFile.cs b/src/ProtocolBuffers.Test/TestProtos/UnitTestCSharpOptionsProtoFile.cs index b1f7d4a70f..3b2cc3182e 100644 --- a/src/ProtocolBuffers.Test/TestProtos/UnitTestCSharpOptionsProtoFile.cs +++ b/src/ProtocolBuffers.Test/TestProtos/UnitTestCSharpOptionsProtoFile.cs @@ -118,7 +118,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _optionsMessageFieldNames; if (hasNormal) { output.WriteString(1, field_names[1], Normal); @@ -137,23 +137,28 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasNormal) { - size += pb::CodedOutputStream.ComputeStringSize(1, Normal); - } - if (hasOptionsMessage_) { - size += pb::CodedOutputStream.ComputeStringSize(2, OptionsMessage_); - } - if (hasCustomName) { - size += pb::CodedOutputStream.ComputeStringSize(3, CustomName); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasNormal) { + size += pb::CodedOutputStream.ComputeStringSize(1, Normal); + } + if (hasOptionsMessage_) { + size += pb::CodedOutputStream.ComputeStringSize(2, OptionsMessage_); + } + if (hasCustomName) { + size += pb::CodedOutputStream.ComputeStringSize(3, CustomName); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static OptionsMessage ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } diff --git a/src/ProtocolBuffers.Test/TestProtos/UnitTestCustomOptionsProtoFile.cs b/src/ProtocolBuffers.Test/TestProtos/UnitTestCustomOptionsProtoFile.cs index 81770f18ed..f852ee307e 100644 --- a/src/ProtocolBuffers.Test/TestProtos/UnitTestCustomOptionsProtoFile.cs +++ b/src/ProtocolBuffers.Test/TestProtos/UnitTestCustomOptionsProtoFile.cs @@ -541,7 +541,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testMessageWithCustomOptionsFieldNames; if (hasField1) { output.WriteString(1, field_names[0], Field1); @@ -554,17 +554,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasField1) { - size += pb::CodedOutputStream.ComputeStringSize(1, Field1); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasField1) { + size += pb::CodedOutputStream.ComputeStringSize(1, Field1); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestMessageWithCustomOptions ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -802,7 +807,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _customOptionFooRequestFieldNames; UnknownFields.WriteTo(output); } @@ -812,14 +817,19 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static CustomOptionFooRequest ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -1029,7 +1039,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _customOptionFooResponseFieldNames; UnknownFields.WriteTo(output); } @@ -1039,14 +1049,19 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static CustomOptionFooResponse ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -1267,7 +1282,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _dummyMessageContainingEnumFieldNames; UnknownFields.WriteTo(output); } @@ -1277,14 +1292,19 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static DummyMessageContainingEnum ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -1494,7 +1514,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _dummyMessageInvalidAsOptionTypeFieldNames; UnknownFields.WriteTo(output); } @@ -1504,14 +1524,19 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static DummyMessageInvalidAsOptionType ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -1721,7 +1746,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _customOptionMinIntegerValuesFieldNames; UnknownFields.WriteTo(output); } @@ -1731,14 +1756,19 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static CustomOptionMinIntegerValues ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -1948,7 +1978,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _customOptionMaxIntegerValuesFieldNames; UnknownFields.WriteTo(output); } @@ -1958,14 +1988,19 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static CustomOptionMaxIntegerValues ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -2175,7 +2210,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _customOptionOtherValuesFieldNames; UnknownFields.WriteTo(output); } @@ -2185,14 +2220,19 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static CustomOptionOtherValues ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -2402,7 +2442,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _settingRealsFromPositiveIntsFieldNames; UnknownFields.WriteTo(output); } @@ -2412,14 +2452,19 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static SettingRealsFromPositiveInts ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -2629,7 +2674,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _settingRealsFromNegativeIntsFieldNames; UnknownFields.WriteTo(output); } @@ -2639,14 +2684,19 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static SettingRealsFromNegativeInts ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -2887,7 +2937,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _complexOptionType1FieldNames; pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); if (hasFoo) { @@ -2908,24 +2958,29 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasFoo) { - size += pb::CodedOutputStream.ComputeInt32Size(1, Foo); - } - if (hasFoo2) { - size += pb::CodedOutputStream.ComputeInt32Size(2, Foo2); - } - if (hasFoo3) { - size += pb::CodedOutputStream.ComputeInt32Size(3, Foo3); - } - size += ExtensionsSerializedSize; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasFoo) { + size += pb::CodedOutputStream.ComputeInt32Size(1, Foo); + } + if (hasFoo2) { + size += pb::CodedOutputStream.ComputeInt32Size(2, Foo2); + } + if (hasFoo3) { + size += pb::CodedOutputStream.ComputeInt32Size(3, Foo3); + } + size += ExtensionsSerializedSize; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static ComplexOptionType1 ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -3258,7 +3313,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _complexOptionType4FieldNames; if (hasWaldo) { output.WriteInt32(1, field_names[0], Waldo); @@ -3271,17 +3326,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasWaldo) { - size += pb::CodedOutputStream.ComputeInt32Size(1, Waldo); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasWaldo) { + size += pb::CodedOutputStream.ComputeInt32Size(1, Waldo); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static ComplexOptionType4 ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -3529,7 +3589,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _complexOptionType2FieldNames; pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); if (hasBar) { @@ -3550,24 +3610,29 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasBar) { - size += pb::CodedOutputStream.ComputeMessageSize(1, Bar); - } - if (hasBaz) { - size += pb::CodedOutputStream.ComputeInt32Size(2, Baz); - } - if (hasFred) { - size += pb::CodedOutputStream.ComputeMessageSize(3, Fred); - } - size += ExtensionsSerializedSize; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasBar) { + size += pb::CodedOutputStream.ComputeMessageSize(1, Bar); + } + if (hasBaz) { + size += pb::CodedOutputStream.ComputeInt32Size(2, Baz); + } + if (hasFred) { + size += pb::CodedOutputStream.ComputeMessageSize(3, Fred); + } + size += ExtensionsSerializedSize; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static ComplexOptionType2 ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -3948,7 +4013,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _complexOptionType5FieldNames; if (hasPlugh) { output.WriteInt32(3, field_names[0], Plugh); @@ -3961,17 +4026,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasPlugh) { - size += pb::CodedOutputStream.ComputeInt32Size(3, Plugh); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasPlugh) { + size += pb::CodedOutputStream.ComputeInt32Size(3, Plugh); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static ComplexOptionType5 ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -4205,7 +4275,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _complexOptionType3FieldNames; if (hasQux) { output.WriteInt32(1, field_names[1], Qux); @@ -4221,20 +4291,25 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasQux) { - size += pb::CodedOutputStream.ComputeInt32Size(1, Qux); - } - if (hasComplexOptionType5) { - size += pb::CodedOutputStream.ComputeGroupSize(2, ComplexOptionType5); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasQux) { + size += pb::CodedOutputStream.ComputeInt32Size(1, Qux); + } + if (hasComplexOptionType5) { + size += pb::CodedOutputStream.ComputeGroupSize(2, ComplexOptionType5); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static ComplexOptionType3 ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -4533,7 +4608,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _complexOpt6FieldNames; if (hasXyzzy) { output.WriteInt32(7593951, field_names[0], Xyzzy); @@ -4546,17 +4621,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasXyzzy) { - size += pb::CodedOutputStream.ComputeInt32Size(7593951, Xyzzy); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasXyzzy) { + size += pb::CodedOutputStream.ComputeInt32Size(7593951, Xyzzy); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static ComplexOpt6 ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -4793,7 +4873,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _variousComplexOptionsFieldNames; UnknownFields.WriteTo(output); } @@ -4803,14 +4883,19 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static VariousComplexOptions ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -5021,7 +5106,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _aggregateMessageSetFieldNames; pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); extensionWriter.WriteUntil(536870912, output); @@ -5033,15 +5118,20 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - size += ExtensionsSerializedSize; - size += UnknownFields.SerializedSizeAsMessageSet; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += ExtensionsSerializedSize; + size += UnknownFields.SerializedSizeAsMessageSet; + memoizedSerializedSize = size; + return size; + } public static AggregateMessageSet ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -5264,7 +5354,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _aggregateMessageSetElementFieldNames; if (hasS) { output.WriteString(1, field_names[0], S); @@ -5277,17 +5367,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasS) { - size += pb::CodedOutputStream.ComputeStringSize(1, S); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasS) { + size += pb::CodedOutputStream.ComputeStringSize(1, S); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static AggregateMessageSetElement ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -5583,7 +5678,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _aggregateFieldNames; if (hasI) { output.WriteInt32(1, field_names[1], I); @@ -5608,29 +5703,34 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasI) { - size += pb::CodedOutputStream.ComputeInt32Size(1, I); - } - if (hasS) { - size += pb::CodedOutputStream.ComputeStringSize(2, S); - } - if (hasSub) { - size += pb::CodedOutputStream.ComputeMessageSize(3, Sub); - } - if (hasFile) { - size += pb::CodedOutputStream.ComputeMessageSize(4, File); - } - if (hasMset) { - size += pb::CodedOutputStream.ComputeMessageSize(5, Mset); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasI) { + size += pb::CodedOutputStream.ComputeInt32Size(1, I); + } + if (hasS) { + size += pb::CodedOutputStream.ComputeStringSize(2, S); + } + if (hasSub) { + size += pb::CodedOutputStream.ComputeMessageSize(3, Sub); + } + if (hasFile) { + size += pb::CodedOutputStream.ComputeMessageSize(4, File); + } + if (hasMset) { + size += pb::CodedOutputStream.ComputeMessageSize(5, Mset); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static Aggregate ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -6061,7 +6161,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _aggregateMessageFieldNames; if (hasFieldname) { output.WriteInt32(1, field_names[0], Fieldname); @@ -6074,17 +6174,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasFieldname) { - size += pb::CodedOutputStream.ComputeInt32Size(1, Fieldname); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasFieldname) { + size += pb::CodedOutputStream.ComputeInt32Size(1, Fieldname); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static AggregateMessage ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } diff --git a/src/ProtocolBuffers.Test/TestProtos/UnitTestEmbedOptimizeForProtoFile.cs b/src/ProtocolBuffers.Test/TestProtos/UnitTestEmbedOptimizeForProtoFile.cs index f7ecaa4488..5737582d87 100644 --- a/src/ProtocolBuffers.Test/TestProtos/UnitTestEmbedOptimizeForProtoFile.cs +++ b/src/ProtocolBuffers.Test/TestProtos/UnitTestEmbedOptimizeForProtoFile.cs @@ -120,7 +120,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testEmbedOptimizedForSizeFieldNames; if (hasOptionalMessage) { output.WriteMessage(1, field_names[0], OptionalMessage); @@ -136,20 +136,25 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasOptionalMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(1, OptionalMessage); - } - foreach (global::Google.ProtocolBuffers.TestProtos.TestOptimizedForSize element in RepeatedMessageList) { - size += pb::CodedOutputStream.ComputeMessageSize(2, element); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasOptionalMessage) { + size += pb::CodedOutputStream.ComputeMessageSize(1, OptionalMessage); + } + foreach (global::Google.ProtocolBuffers.TestProtos.TestOptimizedForSize element in RepeatedMessageList) { + size += pb::CodedOutputStream.ComputeMessageSize(2, element); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestEmbedOptimizedForSize ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } diff --git a/src/ProtocolBuffers.Test/TestProtos/UnitTestExtrasIssuesProtoFile.cs b/src/ProtocolBuffers.Test/TestProtos/UnitTestExtrasIssuesProtoFile.cs index 82362e4faf..9891104aea 100644 --- a/src/ProtocolBuffers.Test/TestProtos/UnitTestExtrasIssuesProtoFile.cs +++ b/src/ProtocolBuffers.Test/TestProtos/UnitTestExtrasIssuesProtoFile.cs @@ -181,7 +181,7 @@ namespace UnitTest.Issues.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _aFieldNames; if (hasA_) { output.WriteInt32(1, field_names[0], A_); @@ -194,17 +194,22 @@ namespace UnitTest.Issues.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasA_) { - size += pb::CodedOutputStream.ComputeInt32Size(1, A_); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasA_) { + size += pb::CodedOutputStream.ComputeInt32Size(1, A_); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static A ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -451,7 +456,7 @@ namespace UnitTest.Issues.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _bFieldNames; if (hasB_) { output.WriteInt32(1, field_names[0], B_); @@ -464,17 +469,22 @@ namespace UnitTest.Issues.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasB_) { - size += pb::CodedOutputStream.ComputeInt32Size(1, B_); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasB_) { + size += pb::CodedOutputStream.ComputeInt32Size(1, B_); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static B ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -721,7 +731,7 @@ namespace UnitTest.Issues.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _aBFieldNames; if (hasAB_) { output.WriteInt32(1, field_names[0], AB_); @@ -734,17 +744,22 @@ namespace UnitTest.Issues.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasAB_) { - size += pb::CodedOutputStream.ComputeInt32Size(1, AB_); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasAB_) { + size += pb::CodedOutputStream.ComputeInt32Size(1, AB_); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static AB ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -993,7 +1008,7 @@ namespace UnitTest.Issues.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _numberFieldFieldNames; if (has_01) { output.WriteInt32(1, field_names[0], _01); @@ -1006,17 +1021,22 @@ namespace UnitTest.Issues.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (has_01) { - size += pb::CodedOutputStream.ComputeInt32Size(1, _01); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (has_01) { + size += pb::CodedOutputStream.ComputeInt32Size(1, _01); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static NumberField ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -1267,7 +1287,7 @@ namespace UnitTest.Issues.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _myMessageAReferenceBFieldNames; if (hasValue) { output.WriteMessage(1, field_names[0], Value); @@ -1280,17 +1300,22 @@ namespace UnitTest.Issues.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasValue) { - size += pb::CodedOutputStream.ComputeMessageSize(1, Value); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasValue) { + size += pb::CodedOutputStream.ComputeMessageSize(1, Value); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static MyMessageAReferenceB ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -1564,7 +1589,7 @@ namespace UnitTest.Issues.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _myMessageBReferenceAFieldNames; if (hasValue) { output.WriteMessage(1, field_names[0], Value); @@ -1577,17 +1602,22 @@ namespace UnitTest.Issues.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasValue) { - size += pb::CodedOutputStream.ComputeMessageSize(1, Value); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasValue) { + size += pb::CodedOutputStream.ComputeMessageSize(1, Value); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static MyMessageBReferenceA ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -1884,7 +1914,7 @@ namespace UnitTest.Issues.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _negativeEnumMessageFieldNames; if (hasValue) { output.WriteEnum(1, field_names[1], (int) Value, Value); @@ -1903,39 +1933,44 @@ namespace UnitTest.Issues.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasValue) { - size += pb::CodedOutputStream.ComputeEnumSize(1, (int) Value); - } - { - int dataSize = 0; - if (values_.Count > 0) { - foreach (global::UnitTest.Issues.TestProtos.NegativeEnum element in values_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 1 * values_.Count; + return CalcSerializedSize(); + } + } + + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasValue) { + size += pb::CodedOutputStream.ComputeEnumSize(1, (int) Value); + } + { + int dataSize = 0; + if (values_.Count > 0) { + foreach (global::UnitTest.Issues.TestProtos.NegativeEnum element in values_) { + dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); } + size += dataSize; + size += 1 * values_.Count; } - { - int dataSize = 0; - if (packedValues_.Count > 0) { - foreach (global::UnitTest.Issues.TestProtos.NegativeEnum element in packedValues_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 1; - size += pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize); + } + { + int dataSize = 0; + if (packedValues_.Count > 0) { + foreach (global::UnitTest.Issues.TestProtos.NegativeEnum element in packedValues_) { + dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); } - packedValuesMemoizedSerializedSize = dataSize; + size += dataSize; + size += 1; + size += pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize); } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + packedValuesMemoizedSerializedSize = dataSize; } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; } - public static NegativeEnumMessage ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -2276,7 +2311,7 @@ namespace UnitTest.Issues.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _deprecatedChildFieldNames; UnknownFields.WriteTo(output); } @@ -2286,14 +2321,19 @@ namespace UnitTest.Issues.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static DeprecatedChild ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -2584,7 +2624,7 @@ namespace UnitTest.Issues.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _deprecatedFieldsMessageFieldNames; if (hasPrimitiveValue) { output.WriteInt32(1, field_names[5], PrimitiveValue); @@ -2612,44 +2652,49 @@ namespace UnitTest.Issues.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasPrimitiveValue) { - size += pb::CodedOutputStream.ComputeInt32Size(1, PrimitiveValue); - } - { - int dataSize = 0; - foreach (int element in PrimitiveArrayList) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); - } - size += dataSize; - size += 1 * primitiveArray_.Count; - } - if (hasMessageValue) { - size += pb::CodedOutputStream.ComputeMessageSize(3, MessageValue); - } - foreach (global::UnitTest.Issues.TestProtos.DeprecatedChild element in MessageArrayList) { - size += pb::CodedOutputStream.ComputeMessageSize(4, element); - } - if (hasEnumValue) { - size += pb::CodedOutputStream.ComputeEnumSize(5, (int) EnumValue); + return CalcSerializedSize(); + } + } + + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasPrimitiveValue) { + size += pb::CodedOutputStream.ComputeInt32Size(1, PrimitiveValue); + } + { + int dataSize = 0; + foreach (int element in PrimitiveArrayList) { + dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); } - { - int dataSize = 0; - if (enumArray_.Count > 0) { - foreach (global::UnitTest.Issues.TestProtos.DeprecatedEnum element in enumArray_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 1 * enumArray_.Count; + size += dataSize; + size += 1 * primitiveArray_.Count; + } + if (hasMessageValue) { + size += pb::CodedOutputStream.ComputeMessageSize(3, MessageValue); + } + foreach (global::UnitTest.Issues.TestProtos.DeprecatedChild element in MessageArrayList) { + size += pb::CodedOutputStream.ComputeMessageSize(4, element); + } + if (hasEnumValue) { + size += pb::CodedOutputStream.ComputeEnumSize(5, (int) EnumValue); + } + { + int dataSize = 0; + if (enumArray_.Count > 0) { + foreach (global::UnitTest.Issues.TestProtos.DeprecatedEnum element in enumArray_) { + dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); } + size += dataSize; + size += 1 * enumArray_.Count; } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; } - public static DeprecatedFieldsMessage ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -3159,7 +3204,7 @@ namespace UnitTest.Issues.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _itemFieldFieldNames; if (hasItem) { output.WriteInt32(1, field_names[0], Item); @@ -3172,17 +3217,22 @@ namespace UnitTest.Issues.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasItem) { - size += pb::CodedOutputStream.ComputeInt32Size(1, Item); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasItem) { + size += pb::CodedOutputStream.ComputeInt32Size(1, Item); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static ItemField ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } diff --git a/src/ProtocolBuffers.Test/TestProtos/UnitTestExtrasProtoFile.cs b/src/ProtocolBuffers.Test/TestProtos/UnitTestExtrasProtoFile.cs index 30c18ceff9..255439738e 100644 --- a/src/ProtocolBuffers.Test/TestProtos/UnitTestExtrasProtoFile.cs +++ b/src/ProtocolBuffers.Test/TestProtos/UnitTestExtrasProtoFile.cs @@ -190,7 +190,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testUnpackedExtensionsFieldNames; pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); extensionWriter.WriteUntil(536870912, output); @@ -202,15 +202,20 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - size += ExtensionsSerializedSize; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += ExtensionsSerializedSize; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestUnpackedExtensions ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } diff --git a/src/ProtocolBuffers.Test/TestProtos/UnitTestGoogleSpeedProtoFile.cs b/src/ProtocolBuffers.Test/TestProtos/UnitTestGoogleSpeedProtoFile.cs index 0371701d8e..578824f166 100644 --- a/src/ProtocolBuffers.Test/TestProtos/UnitTestGoogleSpeedProtoFile.cs +++ b/src/ProtocolBuffers.Test/TestProtos/UnitTestGoogleSpeedProtoFile.cs @@ -583,7 +583,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _speedMessage1FieldNames; if (hasField1) { output.WriteString(1, field_names[0], Field1); @@ -716,140 +716,145 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasField1) { - size += pb::CodedOutputStream.ComputeStringSize(1, Field1); - } - if (hasField9) { - size += pb::CodedOutputStream.ComputeStringSize(9, Field9); - } - if (hasField18) { - size += pb::CodedOutputStream.ComputeStringSize(18, Field18); - } - if (hasField80) { - size += pb::CodedOutputStream.ComputeBoolSize(80, Field80); - } - if (hasField81) { - size += pb::CodedOutputStream.ComputeBoolSize(81, Field81); - } - if (hasField2) { - size += pb::CodedOutputStream.ComputeInt32Size(2, Field2); - } - if (hasField3) { - size += pb::CodedOutputStream.ComputeInt32Size(3, Field3); - } - if (hasField280) { - size += pb::CodedOutputStream.ComputeInt32Size(280, Field280); - } - if (hasField6) { - size += pb::CodedOutputStream.ComputeInt32Size(6, Field6); - } - if (hasField22) { - size += pb::CodedOutputStream.ComputeInt64Size(22, Field22); - } - if (hasField4) { - size += pb::CodedOutputStream.ComputeStringSize(4, Field4); - } - { - int dataSize = 0; - dataSize = 8 * field5_.Count; - size += dataSize; - size += 1 * field5_.Count; - } - if (hasField59) { - size += pb::CodedOutputStream.ComputeBoolSize(59, Field59); - } - if (hasField7) { - size += pb::CodedOutputStream.ComputeStringSize(7, Field7); - } - if (hasField16) { - size += pb::CodedOutputStream.ComputeInt32Size(16, Field16); - } - if (hasField130) { - size += pb::CodedOutputStream.ComputeInt32Size(130, Field130); - } - if (hasField12) { - size += pb::CodedOutputStream.ComputeBoolSize(12, Field12); - } - if (hasField17) { - size += pb::CodedOutputStream.ComputeBoolSize(17, Field17); - } - if (hasField13) { - size += pb::CodedOutputStream.ComputeBoolSize(13, Field13); - } - if (hasField14) { - size += pb::CodedOutputStream.ComputeBoolSize(14, Field14); - } - if (hasField104) { - size += pb::CodedOutputStream.ComputeInt32Size(104, Field104); - } - if (hasField100) { - size += pb::CodedOutputStream.ComputeInt32Size(100, Field100); - } - if (hasField101) { - size += pb::CodedOutputStream.ComputeInt32Size(101, Field101); - } - if (hasField102) { - size += pb::CodedOutputStream.ComputeStringSize(102, Field102); - } - if (hasField103) { - size += pb::CodedOutputStream.ComputeStringSize(103, Field103); - } - if (hasField29) { - size += pb::CodedOutputStream.ComputeInt32Size(29, Field29); - } - if (hasField30) { - size += pb::CodedOutputStream.ComputeBoolSize(30, Field30); - } - if (hasField60) { - size += pb::CodedOutputStream.ComputeInt32Size(60, Field60); - } - if (hasField271) { - size += pb::CodedOutputStream.ComputeInt32Size(271, Field271); - } - if (hasField272) { - size += pb::CodedOutputStream.ComputeInt32Size(272, Field272); - } - if (hasField150) { - size += pb::CodedOutputStream.ComputeInt32Size(150, Field150); - } - if (hasField23) { - size += pb::CodedOutputStream.ComputeInt32Size(23, Field23); - } - if (hasField24) { - size += pb::CodedOutputStream.ComputeBoolSize(24, Field24); - } - if (hasField25) { - size += pb::CodedOutputStream.ComputeInt32Size(25, Field25); - } - if (hasField15) { - size += pb::CodedOutputStream.ComputeMessageSize(15, Field15); - } - if (hasField78) { - size += pb::CodedOutputStream.ComputeBoolSize(78, Field78); - } - if (hasField67) { - size += pb::CodedOutputStream.ComputeInt32Size(67, Field67); - } - if (hasField68) { - size += pb::CodedOutputStream.ComputeInt32Size(68, Field68); - } - if (hasField128) { - size += pb::CodedOutputStream.ComputeInt32Size(128, Field128); - } - if (hasField129) { - size += pb::CodedOutputStream.ComputeStringSize(129, Field129); - } - if (hasField131) { - size += pb::CodedOutputStream.ComputeInt32Size(131, Field131); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasField1) { + size += pb::CodedOutputStream.ComputeStringSize(1, Field1); + } + if (hasField9) { + size += pb::CodedOutputStream.ComputeStringSize(9, Field9); + } + if (hasField18) { + size += pb::CodedOutputStream.ComputeStringSize(18, Field18); + } + if (hasField80) { + size += pb::CodedOutputStream.ComputeBoolSize(80, Field80); + } + if (hasField81) { + size += pb::CodedOutputStream.ComputeBoolSize(81, Field81); + } + if (hasField2) { + size += pb::CodedOutputStream.ComputeInt32Size(2, Field2); + } + if (hasField3) { + size += pb::CodedOutputStream.ComputeInt32Size(3, Field3); + } + if (hasField280) { + size += pb::CodedOutputStream.ComputeInt32Size(280, Field280); + } + if (hasField6) { + size += pb::CodedOutputStream.ComputeInt32Size(6, Field6); + } + if (hasField22) { + size += pb::CodedOutputStream.ComputeInt64Size(22, Field22); + } + if (hasField4) { + size += pb::CodedOutputStream.ComputeStringSize(4, Field4); + } + { + int dataSize = 0; + dataSize = 8 * field5_.Count; + size += dataSize; + size += 1 * field5_.Count; + } + if (hasField59) { + size += pb::CodedOutputStream.ComputeBoolSize(59, Field59); + } + if (hasField7) { + size += pb::CodedOutputStream.ComputeStringSize(7, Field7); + } + if (hasField16) { + size += pb::CodedOutputStream.ComputeInt32Size(16, Field16); + } + if (hasField130) { + size += pb::CodedOutputStream.ComputeInt32Size(130, Field130); + } + if (hasField12) { + size += pb::CodedOutputStream.ComputeBoolSize(12, Field12); + } + if (hasField17) { + size += pb::CodedOutputStream.ComputeBoolSize(17, Field17); + } + if (hasField13) { + size += pb::CodedOutputStream.ComputeBoolSize(13, Field13); + } + if (hasField14) { + size += pb::CodedOutputStream.ComputeBoolSize(14, Field14); + } + if (hasField104) { + size += pb::CodedOutputStream.ComputeInt32Size(104, Field104); + } + if (hasField100) { + size += pb::CodedOutputStream.ComputeInt32Size(100, Field100); + } + if (hasField101) { + size += pb::CodedOutputStream.ComputeInt32Size(101, Field101); + } + if (hasField102) { + size += pb::CodedOutputStream.ComputeStringSize(102, Field102); + } + if (hasField103) { + size += pb::CodedOutputStream.ComputeStringSize(103, Field103); + } + if (hasField29) { + size += pb::CodedOutputStream.ComputeInt32Size(29, Field29); + } + if (hasField30) { + size += pb::CodedOutputStream.ComputeBoolSize(30, Field30); + } + if (hasField60) { + size += pb::CodedOutputStream.ComputeInt32Size(60, Field60); + } + if (hasField271) { + size += pb::CodedOutputStream.ComputeInt32Size(271, Field271); + } + if (hasField272) { + size += pb::CodedOutputStream.ComputeInt32Size(272, Field272); + } + if (hasField150) { + size += pb::CodedOutputStream.ComputeInt32Size(150, Field150); + } + if (hasField23) { + size += pb::CodedOutputStream.ComputeInt32Size(23, Field23); + } + if (hasField24) { + size += pb::CodedOutputStream.ComputeBoolSize(24, Field24); + } + if (hasField25) { + size += pb::CodedOutputStream.ComputeInt32Size(25, Field25); + } + if (hasField15) { + size += pb::CodedOutputStream.ComputeMessageSize(15, Field15); + } + if (hasField78) { + size += pb::CodedOutputStream.ComputeBoolSize(78, Field78); + } + if (hasField67) { + size += pb::CodedOutputStream.ComputeInt32Size(67, Field67); + } + if (hasField68) { + size += pb::CodedOutputStream.ComputeInt32Size(68, Field68); + } + if (hasField128) { + size += pb::CodedOutputStream.ComputeInt32Size(128, Field128); + } + if (hasField129) { + size += pb::CodedOutputStream.ComputeStringSize(129, Field129); + } + if (hasField131) { + size += pb::CodedOutputStream.ComputeInt32Size(131, Field131); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static SpeedMessage1 ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -2420,7 +2425,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _speedMessage1SubMessageFieldNames; if (hasField1) { output.WriteInt32(1, field_names[0], Field1); @@ -2490,74 +2495,79 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasField1) { - size += pb::CodedOutputStream.ComputeInt32Size(1, Field1); - } - if (hasField2) { - size += pb::CodedOutputStream.ComputeInt32Size(2, Field2); - } - if (hasField3) { - size += pb::CodedOutputStream.ComputeInt32Size(3, Field3); - } - if (hasField15) { - size += pb::CodedOutputStream.ComputeStringSize(15, Field15); - } - if (hasField12) { - size += pb::CodedOutputStream.ComputeBoolSize(12, Field12); - } - if (hasField13) { - size += pb::CodedOutputStream.ComputeInt64Size(13, Field13); - } - if (hasField14) { - size += pb::CodedOutputStream.ComputeInt64Size(14, Field14); - } - if (hasField16) { - size += pb::CodedOutputStream.ComputeInt32Size(16, Field16); - } - if (hasField19) { - size += pb::CodedOutputStream.ComputeInt32Size(19, Field19); - } - if (hasField20) { - size += pb::CodedOutputStream.ComputeBoolSize(20, Field20); - } - if (hasField28) { - size += pb::CodedOutputStream.ComputeBoolSize(28, Field28); - } - if (hasField21) { - size += pb::CodedOutputStream.ComputeFixed64Size(21, Field21); - } - if (hasField22) { - size += pb::CodedOutputStream.ComputeInt32Size(22, Field22); - } - if (hasField23) { - size += pb::CodedOutputStream.ComputeBoolSize(23, Field23); - } - if (hasField206) { - size += pb::CodedOutputStream.ComputeBoolSize(206, Field206); - } - if (hasField203) { - size += pb::CodedOutputStream.ComputeFixed32Size(203, Field203); - } - if (hasField204) { - size += pb::CodedOutputStream.ComputeInt32Size(204, Field204); - } - if (hasField205) { - size += pb::CodedOutputStream.ComputeStringSize(205, Field205); - } - if (hasField207) { - size += pb::CodedOutputStream.ComputeUInt64Size(207, Field207); - } - if (hasField300) { - size += pb::CodedOutputStream.ComputeUInt64Size(300, Field300); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasField1) { + size += pb::CodedOutputStream.ComputeInt32Size(1, Field1); + } + if (hasField2) { + size += pb::CodedOutputStream.ComputeInt32Size(2, Field2); + } + if (hasField3) { + size += pb::CodedOutputStream.ComputeInt32Size(3, Field3); + } + if (hasField15) { + size += pb::CodedOutputStream.ComputeStringSize(15, Field15); + } + if (hasField12) { + size += pb::CodedOutputStream.ComputeBoolSize(12, Field12); + } + if (hasField13) { + size += pb::CodedOutputStream.ComputeInt64Size(13, Field13); + } + if (hasField14) { + size += pb::CodedOutputStream.ComputeInt64Size(14, Field14); + } + if (hasField16) { + size += pb::CodedOutputStream.ComputeInt32Size(16, Field16); + } + if (hasField19) { + size += pb::CodedOutputStream.ComputeInt32Size(19, Field19); + } + if (hasField20) { + size += pb::CodedOutputStream.ComputeBoolSize(20, Field20); + } + if (hasField28) { + size += pb::CodedOutputStream.ComputeBoolSize(28, Field28); + } + if (hasField21) { + size += pb::CodedOutputStream.ComputeFixed64Size(21, Field21); + } + if (hasField22) { + size += pb::CodedOutputStream.ComputeInt32Size(22, Field22); + } + if (hasField23) { + size += pb::CodedOutputStream.ComputeBoolSize(23, Field23); + } + if (hasField206) { + size += pb::CodedOutputStream.ComputeBoolSize(206, Field206); + } + if (hasField203) { + size += pb::CodedOutputStream.ComputeFixed32Size(203, Field203); + } + if (hasField204) { + size += pb::CodedOutputStream.ComputeInt32Size(204, Field204); + } + if (hasField205) { + size += pb::CodedOutputStream.ComputeStringSize(205, Field205); + } + if (hasField207) { + size += pb::CodedOutputStream.ComputeUInt64Size(207, Field207); + } + if (hasField300) { + size += pb::CodedOutputStream.ComputeUInt64Size(300, Field300); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static SpeedMessage1SubMessage ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -3515,7 +3525,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _group1FieldNames; if (hasField5) { output.WriteInt32(5, field_names[14], Field5); @@ -3573,77 +3583,82 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasField11) { - size += pb::CodedOutputStream.ComputeFloatSize(11, Field11); - } - if (hasField26) { - size += pb::CodedOutputStream.ComputeFloatSize(26, Field26); - } - if (hasField12) { - size += pb::CodedOutputStream.ComputeStringSize(12, Field12); - } - if (hasField13) { - size += pb::CodedOutputStream.ComputeStringSize(13, Field13); - } - { - int dataSize = 0; - foreach (string element in Field14List) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); - } - size += dataSize; - size += 1 * field14_.Count; - } - if (hasField15) { - size += pb::CodedOutputStream.ComputeUInt64Size(15, Field15); - } - if (hasField5) { - size += pb::CodedOutputStream.ComputeInt32Size(5, Field5); - } - if (hasField27) { - size += pb::CodedOutputStream.ComputeStringSize(27, Field27); - } - if (hasField28) { - size += pb::CodedOutputStream.ComputeInt32Size(28, Field28); - } - if (hasField29) { - size += pb::CodedOutputStream.ComputeStringSize(29, Field29); - } - if (hasField16) { - size += pb::CodedOutputStream.ComputeStringSize(16, Field16); - } - { - int dataSize = 0; - foreach (string element in Field22List) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); - } - size += dataSize; - size += 2 * field22_.Count; - } - { - int dataSize = 0; - foreach (int element in Field73List) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); - } - size += dataSize; - size += 2 * field73_.Count; - } - if (hasField20) { - size += pb::CodedOutputStream.ComputeInt32Size(20, Field20); + return CalcSerializedSize(); + } + } + + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasField11) { + size += pb::CodedOutputStream.ComputeFloatSize(11, Field11); + } + if (hasField26) { + size += pb::CodedOutputStream.ComputeFloatSize(26, Field26); + } + if (hasField12) { + size += pb::CodedOutputStream.ComputeStringSize(12, Field12); + } + if (hasField13) { + size += pb::CodedOutputStream.ComputeStringSize(13, Field13); + } + { + int dataSize = 0; + foreach (string element in Field14List) { + dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); } - if (hasField24) { - size += pb::CodedOutputStream.ComputeStringSize(24, Field24); + size += dataSize; + size += 1 * field14_.Count; + } + if (hasField15) { + size += pb::CodedOutputStream.ComputeUInt64Size(15, Field15); + } + if (hasField5) { + size += pb::CodedOutputStream.ComputeInt32Size(5, Field5); + } + if (hasField27) { + size += pb::CodedOutputStream.ComputeStringSize(27, Field27); + } + if (hasField28) { + size += pb::CodedOutputStream.ComputeInt32Size(28, Field28); + } + if (hasField29) { + size += pb::CodedOutputStream.ComputeStringSize(29, Field29); + } + if (hasField16) { + size += pb::CodedOutputStream.ComputeStringSize(16, Field16); + } + { + int dataSize = 0; + foreach (string element in Field22List) { + dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); } - if (hasField31) { - size += pb::CodedOutputStream.ComputeMessageSize(31, Field31); + size += dataSize; + size += 2 * field22_.Count; + } + { + int dataSize = 0; + foreach (int element in Field73List) { + dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + size += dataSize; + size += 2 * field73_.Count; + } + if (hasField20) { + size += pb::CodedOutputStream.ComputeInt32Size(20, Field20); + } + if (hasField24) { + size += pb::CodedOutputStream.ComputeStringSize(24, Field24); } + if (hasField31) { + size += pb::CodedOutputStream.ComputeMessageSize(31, Field31); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; } - public static Group1 ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -4641,7 +4656,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _speedMessage2FieldNames; if (hasField1) { output.WriteString(1, field_names[0], Field1); @@ -4741,119 +4756,124 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasField1) { - size += pb::CodedOutputStream.ComputeStringSize(1, Field1); - } - if (hasField3) { - size += pb::CodedOutputStream.ComputeInt64Size(3, Field3); - } - if (hasField4) { - size += pb::CodedOutputStream.ComputeInt64Size(4, Field4); - } - if (hasField30) { - size += pb::CodedOutputStream.ComputeInt64Size(30, Field30); - } - if (hasField75) { - size += pb::CodedOutputStream.ComputeBoolSize(75, Field75); - } - if (hasField6) { - size += pb::CodedOutputStream.ComputeStringSize(6, Field6); - } - if (hasField2) { - size += pb::CodedOutputStream.ComputeBytesSize(2, Field2); - } - if (hasField21) { - size += pb::CodedOutputStream.ComputeInt32Size(21, Field21); - } - if (hasField71) { - size += pb::CodedOutputStream.ComputeInt32Size(71, Field71); - } - if (hasField25) { - size += pb::CodedOutputStream.ComputeFloatSize(25, Field25); - } - if (hasField109) { - size += pb::CodedOutputStream.ComputeInt32Size(109, Field109); - } - if (hasField210) { - size += pb::CodedOutputStream.ComputeInt32Size(210, Field210); - } - if (hasField211) { - size += pb::CodedOutputStream.ComputeInt32Size(211, Field211); - } - if (hasField212) { - size += pb::CodedOutputStream.ComputeInt32Size(212, Field212); - } - if (hasField213) { - size += pb::CodedOutputStream.ComputeInt32Size(213, Field213); - } - if (hasField216) { - size += pb::CodedOutputStream.ComputeInt32Size(216, Field216); - } - if (hasField217) { - size += pb::CodedOutputStream.ComputeInt32Size(217, Field217); - } - if (hasField218) { - size += pb::CodedOutputStream.ComputeInt32Size(218, Field218); - } - if (hasField220) { - size += pb::CodedOutputStream.ComputeInt32Size(220, Field220); - } - if (hasField221) { - size += pb::CodedOutputStream.ComputeInt32Size(221, Field221); - } - if (hasField222) { - size += pb::CodedOutputStream.ComputeFloatSize(222, Field222); - } - if (hasField63) { - size += pb::CodedOutputStream.ComputeInt32Size(63, Field63); - } - foreach (global::Google.ProtocolBuffers.TestProtos.SpeedMessage2.Types.Group1 element in Group1List) { - size += pb::CodedOutputStream.ComputeGroupSize(10, element); - } - { - int dataSize = 0; - foreach (string element in Field128List) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); - } - size += dataSize; - size += 2 * field128_.Count; - } - if (hasField131) { - size += pb::CodedOutputStream.ComputeInt64Size(131, Field131); - } - { - int dataSize = 0; - foreach (string element in Field127List) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); - } - size += dataSize; - size += 2 * field127_.Count; - } - if (hasField129) { - size += pb::CodedOutputStream.ComputeInt32Size(129, Field129); - } - { - int dataSize = 0; - foreach (long element in Field130List) { - dataSize += pb::CodedOutputStream.ComputeInt64SizeNoTag(element); - } - size += dataSize; - size += 2 * field130_.Count; + return CalcSerializedSize(); + } + } + + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasField1) { + size += pb::CodedOutputStream.ComputeStringSize(1, Field1); + } + if (hasField3) { + size += pb::CodedOutputStream.ComputeInt64Size(3, Field3); + } + if (hasField4) { + size += pb::CodedOutputStream.ComputeInt64Size(4, Field4); + } + if (hasField30) { + size += pb::CodedOutputStream.ComputeInt64Size(30, Field30); + } + if (hasField75) { + size += pb::CodedOutputStream.ComputeBoolSize(75, Field75); + } + if (hasField6) { + size += pb::CodedOutputStream.ComputeStringSize(6, Field6); + } + if (hasField2) { + size += pb::CodedOutputStream.ComputeBytesSize(2, Field2); + } + if (hasField21) { + size += pb::CodedOutputStream.ComputeInt32Size(21, Field21); + } + if (hasField71) { + size += pb::CodedOutputStream.ComputeInt32Size(71, Field71); + } + if (hasField25) { + size += pb::CodedOutputStream.ComputeFloatSize(25, Field25); + } + if (hasField109) { + size += pb::CodedOutputStream.ComputeInt32Size(109, Field109); + } + if (hasField210) { + size += pb::CodedOutputStream.ComputeInt32Size(210, Field210); + } + if (hasField211) { + size += pb::CodedOutputStream.ComputeInt32Size(211, Field211); + } + if (hasField212) { + size += pb::CodedOutputStream.ComputeInt32Size(212, Field212); + } + if (hasField213) { + size += pb::CodedOutputStream.ComputeInt32Size(213, Field213); + } + if (hasField216) { + size += pb::CodedOutputStream.ComputeInt32Size(216, Field216); + } + if (hasField217) { + size += pb::CodedOutputStream.ComputeInt32Size(217, Field217); + } + if (hasField218) { + size += pb::CodedOutputStream.ComputeInt32Size(218, Field218); + } + if (hasField220) { + size += pb::CodedOutputStream.ComputeInt32Size(220, Field220); + } + if (hasField221) { + size += pb::CodedOutputStream.ComputeInt32Size(221, Field221); + } + if (hasField222) { + size += pb::CodedOutputStream.ComputeFloatSize(222, Field222); + } + if (hasField63) { + size += pb::CodedOutputStream.ComputeInt32Size(63, Field63); + } + foreach (global::Google.ProtocolBuffers.TestProtos.SpeedMessage2.Types.Group1 element in Group1List) { + size += pb::CodedOutputStream.ComputeGroupSize(10, element); + } + { + int dataSize = 0; + foreach (string element in Field128List) { + dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); } - if (hasField205) { - size += pb::CodedOutputStream.ComputeBoolSize(205, Field205); + size += dataSize; + size += 2 * field128_.Count; + } + if (hasField131) { + size += pb::CodedOutputStream.ComputeInt64Size(131, Field131); + } + { + int dataSize = 0; + foreach (string element in Field127List) { + dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); } - if (hasField206) { - size += pb::CodedOutputStream.ComputeBoolSize(206, Field206); + size += dataSize; + size += 2 * field127_.Count; + } + if (hasField129) { + size += pb::CodedOutputStream.ComputeInt32Size(129, Field129); + } + { + int dataSize = 0; + foreach (long element in Field130List) { + dataSize += pb::CodedOutputStream.ComputeInt64SizeNoTag(element); } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + size += dataSize; + size += 2 * field130_.Count; + } + if (hasField205) { + size += pb::CodedOutputStream.ComputeBoolSize(205, Field205); } + if (hasField206) { + size += pb::CodedOutputStream.ComputeBoolSize(206, Field206); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; } - public static SpeedMessage2 ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -6049,7 +6069,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _speedMessage2GroupedMessageFieldNames; if (hasField1) { output.WriteFloat(1, field_names[0], Field1); @@ -6092,47 +6112,52 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasField1) { - size += pb::CodedOutputStream.ComputeFloatSize(1, Field1); - } - if (hasField2) { - size += pb::CodedOutputStream.ComputeFloatSize(2, Field2); - } - if (hasField3) { - size += pb::CodedOutputStream.ComputeFloatSize(3, Field3); - } - if (hasField4) { - size += pb::CodedOutputStream.ComputeBoolSize(4, Field4); - } - if (hasField5) { - size += pb::CodedOutputStream.ComputeBoolSize(5, Field5); - } - if (hasField6) { - size += pb::CodedOutputStream.ComputeBoolSize(6, Field6); - } - if (hasField7) { - size += pb::CodedOutputStream.ComputeBoolSize(7, Field7); - } - if (hasField8) { - size += pb::CodedOutputStream.ComputeFloatSize(8, Field8); - } - if (hasField9) { - size += pb::CodedOutputStream.ComputeBoolSize(9, Field9); - } - if (hasField10) { - size += pb::CodedOutputStream.ComputeFloatSize(10, Field10); - } - if (hasField11) { - size += pb::CodedOutputStream.ComputeInt64Size(11, Field11); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasField1) { + size += pb::CodedOutputStream.ComputeFloatSize(1, Field1); + } + if (hasField2) { + size += pb::CodedOutputStream.ComputeFloatSize(2, Field2); + } + if (hasField3) { + size += pb::CodedOutputStream.ComputeFloatSize(3, Field3); + } + if (hasField4) { + size += pb::CodedOutputStream.ComputeBoolSize(4, Field4); + } + if (hasField5) { + size += pb::CodedOutputStream.ComputeBoolSize(5, Field5); + } + if (hasField6) { + size += pb::CodedOutputStream.ComputeBoolSize(6, Field6); + } + if (hasField7) { + size += pb::CodedOutputStream.ComputeBoolSize(7, Field7); + } + if (hasField8) { + size += pb::CodedOutputStream.ComputeFloatSize(8, Field8); + } + if (hasField9) { + size += pb::CodedOutputStream.ComputeBoolSize(9, Field9); + } + if (hasField10) { + size += pb::CodedOutputStream.ComputeFloatSize(10, Field10); + } + if (hasField11) { + size += pb::CodedOutputStream.ComputeInt64Size(11, Field11); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static SpeedMessage2GroupedMessage ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } diff --git a/src/ProtocolBuffers.Test/TestProtos/UnitTestImportLiteProtoFile.cs b/src/ProtocolBuffers.Test/TestProtos/UnitTestImportLiteProtoFile.cs index 2f9edc71fd..f190f1f650 100644 --- a/src/ProtocolBuffers.Test/TestProtos/UnitTestImportLiteProtoFile.cs +++ b/src/ProtocolBuffers.Test/TestProtos/UnitTestImportLiteProtoFile.cs @@ -70,7 +70,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _importMessageLiteFieldNames; if (hasD) { output.WriteInt32(1, field_names[0], D); @@ -82,16 +82,21 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasD) { - size += pb::CodedOutputStream.ComputeInt32Size(1, D); - } - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasD) { + size += pb::CodedOutputStream.ComputeInt32Size(1, D); + } + memoizedSerializedSize = size; + return size; + } #region Lite runtime methods public override int GetHashCode() { int hash = GetType().GetHashCode(); diff --git a/src/ProtocolBuffers.Test/TestProtos/UnitTestImportProtoFile.cs b/src/ProtocolBuffers.Test/TestProtos/UnitTestImportProtoFile.cs index 57b9e65c8c..61aca3d911 100644 --- a/src/ProtocolBuffers.Test/TestProtos/UnitTestImportProtoFile.cs +++ b/src/ProtocolBuffers.Test/TestProtos/UnitTestImportProtoFile.cs @@ -107,7 +107,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _importMessageFieldNames; if (hasD) { output.WriteInt32(1, field_names[0], D); @@ -120,17 +120,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasD) { - size += pb::CodedOutputStream.ComputeInt32Size(1, D); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasD) { + size += pb::CodedOutputStream.ComputeInt32Size(1, D); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static ImportMessage ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } diff --git a/src/ProtocolBuffers.Test/TestProtos/UnitTestMessageSetProtoFile.cs b/src/ProtocolBuffers.Test/TestProtos/UnitTestMessageSetProtoFile.cs index 85a01e2c89..b3a980ab52 100644 --- a/src/ProtocolBuffers.Test/TestProtos/UnitTestMessageSetProtoFile.cs +++ b/src/ProtocolBuffers.Test/TestProtos/UnitTestMessageSetProtoFile.cs @@ -132,7 +132,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testMessageSetFieldNames; pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); extensionWriter.WriteUntil(536870912, output); @@ -144,15 +144,20 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - size += ExtensionsSerializedSize; - size += UnknownFields.SerializedSizeAsMessageSet; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += ExtensionsSerializedSize; + size += UnknownFields.SerializedSizeAsMessageSet; + memoizedSerializedSize = size; + return size; + } public static TestMessageSet ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -373,7 +378,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testMessageSetContainerFieldNames; if (hasMessageSet) { output.WriteMessage(1, field_names[0], MessageSet); @@ -386,17 +391,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasMessageSet) { - size += pb::CodedOutputStream.ComputeMessageSize(1, MessageSet); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasMessageSet) { + size += pb::CodedOutputStream.ComputeMessageSize(1, MessageSet); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestMessageSetContainer ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -670,7 +680,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testMessageSetExtension1FieldNames; if (hasI) { output.WriteInt32(15, field_names[0], I); @@ -683,17 +693,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasI) { - size += pb::CodedOutputStream.ComputeInt32Size(15, I); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasI) { + size += pb::CodedOutputStream.ComputeInt32Size(15, I); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestMessageSetExtension1 ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -942,7 +957,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testMessageSetExtension2FieldNames; if (hasStr) { output.WriteString(25, field_names[0], Str); @@ -955,17 +970,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasStr) { - size += pb::CodedOutputStream.ComputeStringSize(25, Str); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasStr) { + size += pb::CodedOutputStream.ComputeStringSize(25, Str); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestMessageSetExtension2 ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -1254,7 +1274,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _itemFieldNames; if (hasTypeId) { output.WriteInt32(2, field_names[1], TypeId); @@ -1270,20 +1290,25 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasTypeId) { - size += pb::CodedOutputStream.ComputeInt32Size(2, TypeId); - } - if (hasMessage) { - size += pb::CodedOutputStream.ComputeBytesSize(3, Message); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasTypeId) { + size += pb::CodedOutputStream.ComputeInt32Size(2, TypeId); + } + if (hasMessage) { + size += pb::CodedOutputStream.ComputeBytesSize(3, Message); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static Item ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -1537,7 +1562,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _rawMessageSetFieldNames; if (item_.Count > 0) { output.WriteGroupArray(1, field_names[0], item_); @@ -1550,17 +1575,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - foreach (global::Google.ProtocolBuffers.TestProtos.RawMessageSet.Types.Item element in ItemList) { - size += pb::CodedOutputStream.ComputeGroupSize(1, element); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + foreach (global::Google.ProtocolBuffers.TestProtos.RawMessageSet.Types.Item element in ItemList) { + size += pb::CodedOutputStream.ComputeGroupSize(1, element); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static RawMessageSet ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } diff --git a/src/ProtocolBuffers.Test/TestProtos/UnitTestNoGenericServicesProtoFile.cs b/src/ProtocolBuffers.Test/TestProtos/UnitTestNoGenericServicesProtoFile.cs index d06cdc3235..3a6fc07112 100644 --- a/src/ProtocolBuffers.Test/TestProtos/UnitTestNoGenericServicesProtoFile.cs +++ b/src/ProtocolBuffers.Test/TestProtos/UnitTestNoGenericServicesProtoFile.cs @@ -118,7 +118,7 @@ namespace Google.ProtocolBuffers.TestProtos.NoGenericService { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testMessageFieldNames; pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); if (hasA) { @@ -133,18 +133,23 @@ namespace Google.ProtocolBuffers.TestProtos.NoGenericService { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(1, A); - } - size += ExtensionsSerializedSize; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasA) { + size += pb::CodedOutputStream.ComputeInt32Size(1, A); + } + size += ExtensionsSerializedSize; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestMessage ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } diff --git a/src/ProtocolBuffers.Test/TestProtos/UnitTestProtoFile.cs b/src/ProtocolBuffers.Test/TestProtos/UnitTestProtoFile.cs index 9a9f00bfdf..53ae17e699 100644 --- a/src/ProtocolBuffers.Test/TestProtos/UnitTestProtoFile.cs +++ b/src/ProtocolBuffers.Test/TestProtos/UnitTestProtoFile.cs @@ -1106,7 +1106,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _nestedMessageFieldNames; if (hasBb) { output.WriteInt32(1, field_names[0], Bb); @@ -1119,17 +1119,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasBb) { - size += pb::CodedOutputStream.ComputeInt32Size(1, Bb); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasBb) { + size += pb::CodedOutputStream.ComputeInt32Size(1, Bb); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static NestedMessage ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -1376,7 +1381,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _optionalGroupFieldNames; if (hasA) { output.WriteInt32(17, field_names[0], A); @@ -1389,17 +1394,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(17, A); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasA) { + size += pb::CodedOutputStream.ComputeInt32Size(17, A); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static OptionalGroup ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -1646,7 +1656,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _repeatedGroupFieldNames; if (hasA) { output.WriteInt32(47, field_names[0], A); @@ -1659,17 +1669,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(47, A); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasA) { + size += pb::CodedOutputStream.ComputeInt32Size(47, A); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static RepeatedGroup ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -2627,7 +2642,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testAllTypesFieldNames; if (hasOptionalInt32) { output.WriteInt32(1, field_names[31], OptionalInt32); @@ -2841,310 +2856,315 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasOptionalInt32) { - size += pb::CodedOutputStream.ComputeInt32Size(1, OptionalInt32); - } - if (hasOptionalInt64) { - size += pb::CodedOutputStream.ComputeInt64Size(2, OptionalInt64); - } - if (hasOptionalUint32) { - size += pb::CodedOutputStream.ComputeUInt32Size(3, OptionalUint32); - } - if (hasOptionalUint64) { - size += pb::CodedOutputStream.ComputeUInt64Size(4, OptionalUint64); - } - if (hasOptionalSint32) { - size += pb::CodedOutputStream.ComputeSInt32Size(5, OptionalSint32); - } - if (hasOptionalSint64) { - size += pb::CodedOutputStream.ComputeSInt64Size(6, OptionalSint64); - } - if (hasOptionalFixed32) { - size += pb::CodedOutputStream.ComputeFixed32Size(7, OptionalFixed32); - } - if (hasOptionalFixed64) { - size += pb::CodedOutputStream.ComputeFixed64Size(8, OptionalFixed64); - } - if (hasOptionalSfixed32) { - size += pb::CodedOutputStream.ComputeSFixed32Size(9, OptionalSfixed32); - } - if (hasOptionalSfixed64) { - size += pb::CodedOutputStream.ComputeSFixed64Size(10, OptionalSfixed64); - } - if (hasOptionalFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(11, OptionalFloat); - } - if (hasOptionalDouble) { - size += pb::CodedOutputStream.ComputeDoubleSize(12, OptionalDouble); - } - if (hasOptionalBool) { - size += pb::CodedOutputStream.ComputeBoolSize(13, OptionalBool); - } - if (hasOptionalString) { - size += pb::CodedOutputStream.ComputeStringSize(14, OptionalString); - } - if (hasOptionalBytes) { - size += pb::CodedOutputStream.ComputeBytesSize(15, OptionalBytes); - } - if (hasOptionalGroup) { - size += pb::CodedOutputStream.ComputeGroupSize(16, OptionalGroup); - } - if (hasOptionalNestedMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(18, OptionalNestedMessage); - } - if (hasOptionalForeignMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(19, OptionalForeignMessage); - } - if (hasOptionalImportMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(20, OptionalImportMessage); - } - if (hasOptionalNestedEnum) { - size += pb::CodedOutputStream.ComputeEnumSize(21, (int) OptionalNestedEnum); - } - if (hasOptionalForeignEnum) { - size += pb::CodedOutputStream.ComputeEnumSize(22, (int) OptionalForeignEnum); - } - if (hasOptionalImportEnum) { - size += pb::CodedOutputStream.ComputeEnumSize(23, (int) OptionalImportEnum); - } - if (hasOptionalStringPiece) { - size += pb::CodedOutputStream.ComputeStringSize(24, OptionalStringPiece); - } - if (hasOptionalCord) { - size += pb::CodedOutputStream.ComputeStringSize(25, OptionalCord); - } - { - int dataSize = 0; - foreach (int element in RepeatedInt32List) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedInt32_.Count; - } - { - int dataSize = 0; - foreach (long element in RepeatedInt64List) { - dataSize += pb::CodedOutputStream.ComputeInt64SizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedInt64_.Count; - } - { - int dataSize = 0; - foreach (uint element in RepeatedUint32List) { - dataSize += pb::CodedOutputStream.ComputeUInt32SizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedUint32_.Count; - } - { - int dataSize = 0; - foreach (ulong element in RepeatedUint64List) { - dataSize += pb::CodedOutputStream.ComputeUInt64SizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedUint64_.Count; - } - { - int dataSize = 0; - foreach (int element in RepeatedSint32List) { - dataSize += pb::CodedOutputStream.ComputeSInt32SizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedSint32_.Count; - } - { - int dataSize = 0; - foreach (long element in RepeatedSint64List) { - dataSize += pb::CodedOutputStream.ComputeSInt64SizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedSint64_.Count; - } - { - int dataSize = 0; - dataSize = 4 * repeatedFixed32_.Count; - size += dataSize; - size += 2 * repeatedFixed32_.Count; - } - { - int dataSize = 0; - dataSize = 8 * repeatedFixed64_.Count; - size += dataSize; - size += 2 * repeatedFixed64_.Count; - } - { - int dataSize = 0; - dataSize = 4 * repeatedSfixed32_.Count; - size += dataSize; - size += 2 * repeatedSfixed32_.Count; - } - { - int dataSize = 0; - dataSize = 8 * repeatedSfixed64_.Count; - size += dataSize; - size += 2 * repeatedSfixed64_.Count; - } - { - int dataSize = 0; - dataSize = 4 * repeatedFloat_.Count; - size += dataSize; - size += 2 * repeatedFloat_.Count; - } - { - int dataSize = 0; - dataSize = 8 * repeatedDouble_.Count; - size += dataSize; - size += 2 * repeatedDouble_.Count; - } - { - int dataSize = 0; - dataSize = 1 * repeatedBool_.Count; - size += dataSize; - size += 2 * repeatedBool_.Count; - } - { - int dataSize = 0; - foreach (string element in RepeatedStringList) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedString_.Count; - } - { - int dataSize = 0; - foreach (pb::ByteString element in RepeatedBytesList) { - dataSize += pb::CodedOutputStream.ComputeBytesSizeNoTag(element); + return CalcSerializedSize(); + } + } + + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasOptionalInt32) { + size += pb::CodedOutputStream.ComputeInt32Size(1, OptionalInt32); + } + if (hasOptionalInt64) { + size += pb::CodedOutputStream.ComputeInt64Size(2, OptionalInt64); + } + if (hasOptionalUint32) { + size += pb::CodedOutputStream.ComputeUInt32Size(3, OptionalUint32); + } + if (hasOptionalUint64) { + size += pb::CodedOutputStream.ComputeUInt64Size(4, OptionalUint64); + } + if (hasOptionalSint32) { + size += pb::CodedOutputStream.ComputeSInt32Size(5, OptionalSint32); + } + if (hasOptionalSint64) { + size += pb::CodedOutputStream.ComputeSInt64Size(6, OptionalSint64); + } + if (hasOptionalFixed32) { + size += pb::CodedOutputStream.ComputeFixed32Size(7, OptionalFixed32); + } + if (hasOptionalFixed64) { + size += pb::CodedOutputStream.ComputeFixed64Size(8, OptionalFixed64); + } + if (hasOptionalSfixed32) { + size += pb::CodedOutputStream.ComputeSFixed32Size(9, OptionalSfixed32); + } + if (hasOptionalSfixed64) { + size += pb::CodedOutputStream.ComputeSFixed64Size(10, OptionalSfixed64); + } + if (hasOptionalFloat) { + size += pb::CodedOutputStream.ComputeFloatSize(11, OptionalFloat); + } + if (hasOptionalDouble) { + size += pb::CodedOutputStream.ComputeDoubleSize(12, OptionalDouble); + } + if (hasOptionalBool) { + size += pb::CodedOutputStream.ComputeBoolSize(13, OptionalBool); + } + if (hasOptionalString) { + size += pb::CodedOutputStream.ComputeStringSize(14, OptionalString); + } + if (hasOptionalBytes) { + size += pb::CodedOutputStream.ComputeBytesSize(15, OptionalBytes); + } + if (hasOptionalGroup) { + size += pb::CodedOutputStream.ComputeGroupSize(16, OptionalGroup); + } + if (hasOptionalNestedMessage) { + size += pb::CodedOutputStream.ComputeMessageSize(18, OptionalNestedMessage); + } + if (hasOptionalForeignMessage) { + size += pb::CodedOutputStream.ComputeMessageSize(19, OptionalForeignMessage); + } + if (hasOptionalImportMessage) { + size += pb::CodedOutputStream.ComputeMessageSize(20, OptionalImportMessage); + } + if (hasOptionalNestedEnum) { + size += pb::CodedOutputStream.ComputeEnumSize(21, (int) OptionalNestedEnum); + } + if (hasOptionalForeignEnum) { + size += pb::CodedOutputStream.ComputeEnumSize(22, (int) OptionalForeignEnum); + } + if (hasOptionalImportEnum) { + size += pb::CodedOutputStream.ComputeEnumSize(23, (int) OptionalImportEnum); + } + if (hasOptionalStringPiece) { + size += pb::CodedOutputStream.ComputeStringSize(24, OptionalStringPiece); + } + if (hasOptionalCord) { + size += pb::CodedOutputStream.ComputeStringSize(25, OptionalCord); + } + { + int dataSize = 0; + foreach (int element in RepeatedInt32List) { + dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); + } + size += dataSize; + size += 2 * repeatedInt32_.Count; + } + { + int dataSize = 0; + foreach (long element in RepeatedInt64List) { + dataSize += pb::CodedOutputStream.ComputeInt64SizeNoTag(element); + } + size += dataSize; + size += 2 * repeatedInt64_.Count; + } + { + int dataSize = 0; + foreach (uint element in RepeatedUint32List) { + dataSize += pb::CodedOutputStream.ComputeUInt32SizeNoTag(element); + } + size += dataSize; + size += 2 * repeatedUint32_.Count; + } + { + int dataSize = 0; + foreach (ulong element in RepeatedUint64List) { + dataSize += pb::CodedOutputStream.ComputeUInt64SizeNoTag(element); + } + size += dataSize; + size += 2 * repeatedUint64_.Count; + } + { + int dataSize = 0; + foreach (int element in RepeatedSint32List) { + dataSize += pb::CodedOutputStream.ComputeSInt32SizeNoTag(element); + } + size += dataSize; + size += 2 * repeatedSint32_.Count; + } + { + int dataSize = 0; + foreach (long element in RepeatedSint64List) { + dataSize += pb::CodedOutputStream.ComputeSInt64SizeNoTag(element); + } + size += dataSize; + size += 2 * repeatedSint64_.Count; + } + { + int dataSize = 0; + dataSize = 4 * repeatedFixed32_.Count; + size += dataSize; + size += 2 * repeatedFixed32_.Count; + } + { + int dataSize = 0; + dataSize = 8 * repeatedFixed64_.Count; + size += dataSize; + size += 2 * repeatedFixed64_.Count; + } + { + int dataSize = 0; + dataSize = 4 * repeatedSfixed32_.Count; + size += dataSize; + size += 2 * repeatedSfixed32_.Count; + } + { + int dataSize = 0; + dataSize = 8 * repeatedSfixed64_.Count; + size += dataSize; + size += 2 * repeatedSfixed64_.Count; + } + { + int dataSize = 0; + dataSize = 4 * repeatedFloat_.Count; + size += dataSize; + size += 2 * repeatedFloat_.Count; + } + { + int dataSize = 0; + dataSize = 8 * repeatedDouble_.Count; + size += dataSize; + size += 2 * repeatedDouble_.Count; + } + { + int dataSize = 0; + dataSize = 1 * repeatedBool_.Count; + size += dataSize; + size += 2 * repeatedBool_.Count; + } + { + int dataSize = 0; + foreach (string element in RepeatedStringList) { + dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); + } + size += dataSize; + size += 2 * repeatedString_.Count; + } + { + int dataSize = 0; + foreach (pb::ByteString element in RepeatedBytesList) { + dataSize += pb::CodedOutputStream.ComputeBytesSizeNoTag(element); + } + size += dataSize; + size += 2 * repeatedBytes_.Count; + } + foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup element in RepeatedGroupList) { + size += pb::CodedOutputStream.ComputeGroupSize(46, element); + } + foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage element in RepeatedNestedMessageList) { + size += pb::CodedOutputStream.ComputeMessageSize(48, element); + } + foreach (global::Google.ProtocolBuffers.TestProtos.ForeignMessage element in RepeatedForeignMessageList) { + size += pb::CodedOutputStream.ComputeMessageSize(49, element); + } + foreach (global::Google.ProtocolBuffers.TestProtos.ImportMessage element in RepeatedImportMessageList) { + size += pb::CodedOutputStream.ComputeMessageSize(50, element); + } + { + int dataSize = 0; + if (repeatedNestedEnum_.Count > 0) { + foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedEnum element in repeatedNestedEnum_) { + dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); } size += dataSize; - size += 2 * repeatedBytes_.Count; - } - foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup element in RepeatedGroupList) { - size += pb::CodedOutputStream.ComputeGroupSize(46, element); + size += 2 * repeatedNestedEnum_.Count; } - foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage element in RepeatedNestedMessageList) { - size += pb::CodedOutputStream.ComputeMessageSize(48, element); - } - foreach (global::Google.ProtocolBuffers.TestProtos.ForeignMessage element in RepeatedForeignMessageList) { - size += pb::CodedOutputStream.ComputeMessageSize(49, element); - } - foreach (global::Google.ProtocolBuffers.TestProtos.ImportMessage element in RepeatedImportMessageList) { - size += pb::CodedOutputStream.ComputeMessageSize(50, element); - } - { - int dataSize = 0; - if (repeatedNestedEnum_.Count > 0) { - foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedEnum element in repeatedNestedEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 2 * repeatedNestedEnum_.Count; - } - } - { - int dataSize = 0; - if (repeatedForeignEnum_.Count > 0) { - foreach (global::Google.ProtocolBuffers.TestProtos.ForeignEnum element in repeatedForeignEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 2 * repeatedForeignEnum_.Count; - } - } - { - int dataSize = 0; - if (repeatedImportEnum_.Count > 0) { - foreach (global::Google.ProtocolBuffers.TestProtos.ImportEnum element in repeatedImportEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 2 * repeatedImportEnum_.Count; - } - } - { - int dataSize = 0; - foreach (string element in RepeatedStringPieceList) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); + } + { + int dataSize = 0; + if (repeatedForeignEnum_.Count > 0) { + foreach (global::Google.ProtocolBuffers.TestProtos.ForeignEnum element in repeatedForeignEnum_) { + dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); } size += dataSize; - size += 2 * repeatedStringPiece_.Count; + size += 2 * repeatedForeignEnum_.Count; } - { - int dataSize = 0; - foreach (string element in RepeatedCordList) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); + } + { + int dataSize = 0; + if (repeatedImportEnum_.Count > 0) { + foreach (global::Google.ProtocolBuffers.TestProtos.ImportEnum element in repeatedImportEnum_) { + dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); } size += dataSize; - size += 2 * repeatedCord_.Count; - } - if (hasDefaultInt32) { - size += pb::CodedOutputStream.ComputeInt32Size(61, DefaultInt32); - } - if (hasDefaultInt64) { - size += pb::CodedOutputStream.ComputeInt64Size(62, DefaultInt64); - } - if (hasDefaultUint32) { - size += pb::CodedOutputStream.ComputeUInt32Size(63, DefaultUint32); - } - if (hasDefaultUint64) { - size += pb::CodedOutputStream.ComputeUInt64Size(64, DefaultUint64); - } - if (hasDefaultSint32) { - size += pb::CodedOutputStream.ComputeSInt32Size(65, DefaultSint32); - } - if (hasDefaultSint64) { - size += pb::CodedOutputStream.ComputeSInt64Size(66, DefaultSint64); + size += 2 * repeatedImportEnum_.Count; } - if (hasDefaultFixed32) { - size += pb::CodedOutputStream.ComputeFixed32Size(67, DefaultFixed32); - } - if (hasDefaultFixed64) { - size += pb::CodedOutputStream.ComputeFixed64Size(68, DefaultFixed64); - } - if (hasDefaultSfixed32) { - size += pb::CodedOutputStream.ComputeSFixed32Size(69, DefaultSfixed32); - } - if (hasDefaultSfixed64) { - size += pb::CodedOutputStream.ComputeSFixed64Size(70, DefaultSfixed64); - } - if (hasDefaultFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(71, DefaultFloat); - } - if (hasDefaultDouble) { - size += pb::CodedOutputStream.ComputeDoubleSize(72, DefaultDouble); - } - if (hasDefaultBool) { - size += pb::CodedOutputStream.ComputeBoolSize(73, DefaultBool); - } - if (hasDefaultString) { - size += pb::CodedOutputStream.ComputeStringSize(74, DefaultString); - } - if (hasDefaultBytes) { - size += pb::CodedOutputStream.ComputeBytesSize(75, DefaultBytes); - } - if (hasDefaultNestedEnum) { - size += pb::CodedOutputStream.ComputeEnumSize(81, (int) DefaultNestedEnum); - } - if (hasDefaultForeignEnum) { - size += pb::CodedOutputStream.ComputeEnumSize(82, (int) DefaultForeignEnum); - } - if (hasDefaultImportEnum) { - size += pb::CodedOutputStream.ComputeEnumSize(83, (int) DefaultImportEnum); - } - if (hasDefaultStringPiece) { - size += pb::CodedOutputStream.ComputeStringSize(84, DefaultStringPiece); + } + { + int dataSize = 0; + foreach (string element in RepeatedStringPieceList) { + dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); } - if (hasDefaultCord) { - size += pb::CodedOutputStream.ComputeStringSize(85, DefaultCord); + size += dataSize; + size += 2 * repeatedStringPiece_.Count; + } + { + int dataSize = 0; + foreach (string element in RepeatedCordList) { + dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + size += dataSize; + size += 2 * repeatedCord_.Count; + } + if (hasDefaultInt32) { + size += pb::CodedOutputStream.ComputeInt32Size(61, DefaultInt32); + } + if (hasDefaultInt64) { + size += pb::CodedOutputStream.ComputeInt64Size(62, DefaultInt64); + } + if (hasDefaultUint32) { + size += pb::CodedOutputStream.ComputeUInt32Size(63, DefaultUint32); + } + if (hasDefaultUint64) { + size += pb::CodedOutputStream.ComputeUInt64Size(64, DefaultUint64); + } + if (hasDefaultSint32) { + size += pb::CodedOutputStream.ComputeSInt32Size(65, DefaultSint32); + } + if (hasDefaultSint64) { + size += pb::CodedOutputStream.ComputeSInt64Size(66, DefaultSint64); + } + if (hasDefaultFixed32) { + size += pb::CodedOutputStream.ComputeFixed32Size(67, DefaultFixed32); + } + if (hasDefaultFixed64) { + size += pb::CodedOutputStream.ComputeFixed64Size(68, DefaultFixed64); } + if (hasDefaultSfixed32) { + size += pb::CodedOutputStream.ComputeSFixed32Size(69, DefaultSfixed32); + } + if (hasDefaultSfixed64) { + size += pb::CodedOutputStream.ComputeSFixed64Size(70, DefaultSfixed64); + } + if (hasDefaultFloat) { + size += pb::CodedOutputStream.ComputeFloatSize(71, DefaultFloat); + } + if (hasDefaultDouble) { + size += pb::CodedOutputStream.ComputeDoubleSize(72, DefaultDouble); + } + if (hasDefaultBool) { + size += pb::CodedOutputStream.ComputeBoolSize(73, DefaultBool); + } + if (hasDefaultString) { + size += pb::CodedOutputStream.ComputeStringSize(74, DefaultString); + } + if (hasDefaultBytes) { + size += pb::CodedOutputStream.ComputeBytesSize(75, DefaultBytes); + } + if (hasDefaultNestedEnum) { + size += pb::CodedOutputStream.ComputeEnumSize(81, (int) DefaultNestedEnum); + } + if (hasDefaultForeignEnum) { + size += pb::CodedOutputStream.ComputeEnumSize(82, (int) DefaultForeignEnum); + } + if (hasDefaultImportEnum) { + size += pb::CodedOutputStream.ComputeEnumSize(83, (int) DefaultImportEnum); + } + if (hasDefaultStringPiece) { + size += pb::CodedOutputStream.ComputeStringSize(84, DefaultStringPiece); + } + if (hasDefaultCord) { + size += pb::CodedOutputStream.ComputeStringSize(85, DefaultCord); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; } - public static TestAllTypes ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -5765,7 +5785,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testDeprecatedFieldsFieldNames; if (hasDeprecatedInt32) { output.WriteInt32(1, field_names[0], DeprecatedInt32); @@ -5778,17 +5798,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasDeprecatedInt32) { - size += pb::CodedOutputStream.ComputeInt32Size(1, DeprecatedInt32); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasDeprecatedInt32) { + size += pb::CodedOutputStream.ComputeInt32Size(1, DeprecatedInt32); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestDeprecatedFields ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -6039,7 +6064,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _foreignMessageFieldNames; if (hasC) { output.WriteInt32(1, field_names[0], C); @@ -6052,17 +6077,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasC) { - size += pb::CodedOutputStream.ComputeInt32Size(1, C); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasC) { + size += pb::CodedOutputStream.ComputeInt32Size(1, C); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static ForeignMessage ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -6300,7 +6330,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testAllExtensionsFieldNames; pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); extensionWriter.WriteUntil(536870912, output); @@ -6312,15 +6342,20 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - size += ExtensionsSerializedSize; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += ExtensionsSerializedSize; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestAllExtensions ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -6541,7 +6576,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _optionalGroupExtensionFieldNames; if (hasA) { output.WriteInt32(17, field_names[0], A); @@ -6554,17 +6589,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(17, A); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasA) { + size += pb::CodedOutputStream.ComputeInt32Size(17, A); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static OptionalGroup_extension ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -6811,7 +6851,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _repeatedGroupExtensionFieldNames; if (hasA) { output.WriteInt32(47, field_names[0], A); @@ -6824,17 +6864,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(47, A); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasA) { + size += pb::CodedOutputStream.ComputeInt32Size(47, A); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static RepeatedGroup_extension ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -7073,7 +7118,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testNestedExtensionFieldNames; UnknownFields.WriteTo(output); } @@ -7083,14 +7128,19 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestNestedExtension ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -7637,7 +7687,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testRequiredFieldNames; if (hasA) { output.WriteInt32(1, field_names[0], A); @@ -7746,113 +7796,118 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(1, A); - } - if (hasDummy2) { - size += pb::CodedOutputStream.ComputeInt32Size(2, Dummy2); - } - if (hasB) { - size += pb::CodedOutputStream.ComputeInt32Size(3, B); - } - if (hasDummy4) { - size += pb::CodedOutputStream.ComputeInt32Size(4, Dummy4); - } - if (hasDummy5) { - size += pb::CodedOutputStream.ComputeInt32Size(5, Dummy5); - } - if (hasDummy6) { - size += pb::CodedOutputStream.ComputeInt32Size(6, Dummy6); - } - if (hasDummy7) { - size += pb::CodedOutputStream.ComputeInt32Size(7, Dummy7); - } - if (hasDummy8) { - size += pb::CodedOutputStream.ComputeInt32Size(8, Dummy8); - } - if (hasDummy9) { - size += pb::CodedOutputStream.ComputeInt32Size(9, Dummy9); - } - if (hasDummy10) { - size += pb::CodedOutputStream.ComputeInt32Size(10, Dummy10); - } - if (hasDummy11) { - size += pb::CodedOutputStream.ComputeInt32Size(11, Dummy11); - } - if (hasDummy12) { - size += pb::CodedOutputStream.ComputeInt32Size(12, Dummy12); - } - if (hasDummy13) { - size += pb::CodedOutputStream.ComputeInt32Size(13, Dummy13); - } - if (hasDummy14) { - size += pb::CodedOutputStream.ComputeInt32Size(14, Dummy14); - } - if (hasDummy15) { - size += pb::CodedOutputStream.ComputeInt32Size(15, Dummy15); - } - if (hasDummy16) { - size += pb::CodedOutputStream.ComputeInt32Size(16, Dummy16); - } - if (hasDummy17) { - size += pb::CodedOutputStream.ComputeInt32Size(17, Dummy17); - } - if (hasDummy18) { - size += pb::CodedOutputStream.ComputeInt32Size(18, Dummy18); - } - if (hasDummy19) { - size += pb::CodedOutputStream.ComputeInt32Size(19, Dummy19); - } - if (hasDummy20) { - size += pb::CodedOutputStream.ComputeInt32Size(20, Dummy20); - } - if (hasDummy21) { - size += pb::CodedOutputStream.ComputeInt32Size(21, Dummy21); - } - if (hasDummy22) { - size += pb::CodedOutputStream.ComputeInt32Size(22, Dummy22); - } - if (hasDummy23) { - size += pb::CodedOutputStream.ComputeInt32Size(23, Dummy23); - } - if (hasDummy24) { - size += pb::CodedOutputStream.ComputeInt32Size(24, Dummy24); - } - if (hasDummy25) { - size += pb::CodedOutputStream.ComputeInt32Size(25, Dummy25); - } - if (hasDummy26) { - size += pb::CodedOutputStream.ComputeInt32Size(26, Dummy26); - } - if (hasDummy27) { - size += pb::CodedOutputStream.ComputeInt32Size(27, Dummy27); - } - if (hasDummy28) { - size += pb::CodedOutputStream.ComputeInt32Size(28, Dummy28); - } - if (hasDummy29) { - size += pb::CodedOutputStream.ComputeInt32Size(29, Dummy29); - } - if (hasDummy30) { - size += pb::CodedOutputStream.ComputeInt32Size(30, Dummy30); - } - if (hasDummy31) { - size += pb::CodedOutputStream.ComputeInt32Size(31, Dummy31); - } - if (hasDummy32) { - size += pb::CodedOutputStream.ComputeInt32Size(32, Dummy32); - } - if (hasC) { - size += pb::CodedOutputStream.ComputeInt32Size(33, C); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasA) { + size += pb::CodedOutputStream.ComputeInt32Size(1, A); + } + if (hasDummy2) { + size += pb::CodedOutputStream.ComputeInt32Size(2, Dummy2); + } + if (hasB) { + size += pb::CodedOutputStream.ComputeInt32Size(3, B); + } + if (hasDummy4) { + size += pb::CodedOutputStream.ComputeInt32Size(4, Dummy4); + } + if (hasDummy5) { + size += pb::CodedOutputStream.ComputeInt32Size(5, Dummy5); + } + if (hasDummy6) { + size += pb::CodedOutputStream.ComputeInt32Size(6, Dummy6); + } + if (hasDummy7) { + size += pb::CodedOutputStream.ComputeInt32Size(7, Dummy7); + } + if (hasDummy8) { + size += pb::CodedOutputStream.ComputeInt32Size(8, Dummy8); + } + if (hasDummy9) { + size += pb::CodedOutputStream.ComputeInt32Size(9, Dummy9); + } + if (hasDummy10) { + size += pb::CodedOutputStream.ComputeInt32Size(10, Dummy10); + } + if (hasDummy11) { + size += pb::CodedOutputStream.ComputeInt32Size(11, Dummy11); + } + if (hasDummy12) { + size += pb::CodedOutputStream.ComputeInt32Size(12, Dummy12); + } + if (hasDummy13) { + size += pb::CodedOutputStream.ComputeInt32Size(13, Dummy13); + } + if (hasDummy14) { + size += pb::CodedOutputStream.ComputeInt32Size(14, Dummy14); + } + if (hasDummy15) { + size += pb::CodedOutputStream.ComputeInt32Size(15, Dummy15); + } + if (hasDummy16) { + size += pb::CodedOutputStream.ComputeInt32Size(16, Dummy16); + } + if (hasDummy17) { + size += pb::CodedOutputStream.ComputeInt32Size(17, Dummy17); + } + if (hasDummy18) { + size += pb::CodedOutputStream.ComputeInt32Size(18, Dummy18); + } + if (hasDummy19) { + size += pb::CodedOutputStream.ComputeInt32Size(19, Dummy19); + } + if (hasDummy20) { + size += pb::CodedOutputStream.ComputeInt32Size(20, Dummy20); + } + if (hasDummy21) { + size += pb::CodedOutputStream.ComputeInt32Size(21, Dummy21); + } + if (hasDummy22) { + size += pb::CodedOutputStream.ComputeInt32Size(22, Dummy22); + } + if (hasDummy23) { + size += pb::CodedOutputStream.ComputeInt32Size(23, Dummy23); + } + if (hasDummy24) { + size += pb::CodedOutputStream.ComputeInt32Size(24, Dummy24); + } + if (hasDummy25) { + size += pb::CodedOutputStream.ComputeInt32Size(25, Dummy25); + } + if (hasDummy26) { + size += pb::CodedOutputStream.ComputeInt32Size(26, Dummy26); + } + if (hasDummy27) { + size += pb::CodedOutputStream.ComputeInt32Size(27, Dummy27); + } + if (hasDummy28) { + size += pb::CodedOutputStream.ComputeInt32Size(28, Dummy28); + } + if (hasDummy29) { + size += pb::CodedOutputStream.ComputeInt32Size(29, Dummy29); + } + if (hasDummy30) { + size += pb::CodedOutputStream.ComputeInt32Size(30, Dummy30); + } + if (hasDummy31) { + size += pb::CodedOutputStream.ComputeInt32Size(31, Dummy31); + } + if (hasDummy32) { + size += pb::CodedOutputStream.ComputeInt32Size(32, Dummy32); + } + if (hasC) { + size += pb::CodedOutputStream.ComputeInt32Size(33, C); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestRequired ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -8991,7 +9046,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testRequiredForeignFieldNames; if (hasOptionalMessage) { output.WriteMessage(1, field_names[1], OptionalMessage); @@ -9010,23 +9065,28 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasOptionalMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(1, OptionalMessage); - } - foreach (global::Google.ProtocolBuffers.TestProtos.TestRequired element in RepeatedMessageList) { - size += pb::CodedOutputStream.ComputeMessageSize(2, element); - } - if (hasDummy) { - size += pb::CodedOutputStream.ComputeInt32Size(3, Dummy); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasOptionalMessage) { + size += pb::CodedOutputStream.ComputeMessageSize(1, OptionalMessage); + } + foreach (global::Google.ProtocolBuffers.TestProtos.TestRequired element in RepeatedMessageList) { + size += pb::CodedOutputStream.ComputeMessageSize(2, element); + } + if (hasDummy) { + size += pb::CodedOutputStream.ComputeInt32Size(3, Dummy); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestRequiredForeign ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -9377,7 +9437,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testForeignNestedFieldNames; if (hasForeignNested) { output.WriteMessage(1, field_names[0], ForeignNested); @@ -9390,17 +9450,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasForeignNested) { - size += pb::CodedOutputStream.ComputeMessageSize(1, ForeignNested); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasForeignNested) { + size += pb::CodedOutputStream.ComputeMessageSize(1, ForeignNested); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestForeignNested ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -9662,7 +9727,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testEmptyMessageFieldNames; UnknownFields.WriteTo(output); } @@ -9672,14 +9737,19 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestEmptyMessage ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -9890,7 +9960,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testEmptyMessageWithExtensionsFieldNames; pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); extensionWriter.WriteUntil(536870912, output); @@ -9902,15 +9972,20 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - size += ExtensionsSerializedSize; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += ExtensionsSerializedSize; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestEmptyMessageWithExtensions ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -10122,7 +10197,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testMultipleExtensionRangesFieldNames; pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); extensionWriter.WriteUntil(43, output); @@ -10136,15 +10211,20 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - size += ExtensionsSerializedSize; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += ExtensionsSerializedSize; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestMultipleExtensionRanges ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -10375,7 +10455,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testReallyLargeTagNumberFieldNames; if (hasA) { output.WriteInt32(1, field_names[0], A); @@ -10391,20 +10471,25 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(1, A); - } - if (hasBb) { - size += pb::CodedOutputStream.ComputeInt32Size(268435455, Bb); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasA) { + size += pb::CodedOutputStream.ComputeInt32Size(1, A); + } + if (hasBb) { + size += pb::CodedOutputStream.ComputeInt32Size(268435455, Bb); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestReallyLargeTagNumber ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -10688,7 +10773,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testRecursiveMessageFieldNames; if (hasA) { output.WriteMessage(1, field_names[0], A); @@ -10704,20 +10789,25 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeMessageSize(1, A); - } - if (hasI) { - size += pb::CodedOutputStream.ComputeInt32Size(2, I); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasA) { + size += pb::CodedOutputStream.ComputeMessageSize(1, A); + } + if (hasI) { + size += pb::CodedOutputStream.ComputeInt32Size(2, I); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestRecursiveMessage ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -11016,7 +11106,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testMutualRecursionAFieldNames; if (hasBb) { output.WriteMessage(1, field_names[0], Bb); @@ -11029,17 +11119,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasBb) { - size += pb::CodedOutputStream.ComputeMessageSize(1, Bb); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasBb) { + size += pb::CodedOutputStream.ComputeMessageSize(1, Bb); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestMutualRecursionA ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -11321,7 +11416,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testMutualRecursionBFieldNames; if (hasA) { output.WriteMessage(1, field_names[0], A); @@ -11337,20 +11432,25 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeMessageSize(1, A); - } - if (hasOptionalInt32) { - size += pb::CodedOutputStream.ComputeInt32Size(2, OptionalInt32); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasA) { + size += pb::CodedOutputStream.ComputeMessageSize(1, A); + } + if (hasOptionalInt32) { + size += pb::CodedOutputStream.ComputeInt32Size(2, OptionalInt32); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestMutualRecursionB ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -11678,7 +11778,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _fooFieldNames; if (hasA) { output.WriteInt32(1, field_names[0], A); @@ -11691,17 +11791,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(1, A); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasA) { + size += pb::CodedOutputStream.ComputeInt32Size(1, A); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static Foo ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -11948,7 +12053,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _barFieldNames; if (hasA) { output.WriteInt32(1, field_names[0], A); @@ -11961,17 +12066,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(1, A); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasA) { + size += pb::CodedOutputStream.ComputeInt32Size(1, A); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static Bar ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -12215,7 +12325,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testDupFieldNumberFieldNames; if (hasA) { output.WriteInt32(1, field_names[0], A); @@ -12234,23 +12344,28 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(1, A); - } - if (hasFoo) { - size += pb::CodedOutputStream.ComputeGroupSize(2, Foo); - } - if (hasBar) { - size += pb::CodedOutputStream.ComputeGroupSize(3, Bar); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasA) { + size += pb::CodedOutputStream.ComputeInt32Size(1, A); + } + if (hasFoo) { + size += pb::CodedOutputStream.ComputeGroupSize(2, Foo); + } + if (hasBar) { + size += pb::CodedOutputStream.ComputeGroupSize(3, Bar); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestDupFieldNumber ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -12644,7 +12759,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _nestedMessageFieldNames; if (nestedmessageRepeatedInt32_.Count > 0) { output.WriteInt32Array(1, field_names[1], nestedmessageRepeatedInt32_); @@ -12660,25 +12775,30 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - { - int dataSize = 0; - foreach (int element in NestedmessageRepeatedInt32List) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); - } - size += dataSize; - size += 1 * nestedmessageRepeatedInt32_.Count; - } - foreach (global::Google.ProtocolBuffers.TestProtos.ForeignMessage element in NestedmessageRepeatedForeignmessageList) { - size += pb::CodedOutputStream.ComputeMessageSize(2, element); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + { + int dataSize = 0; + foreach (int element in NestedmessageRepeatedInt32List) { + dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); + } + size += dataSize; + size += 1 * nestedmessageRepeatedInt32_.Count; + } + foreach (global::Google.ProtocolBuffers.TestProtos.ForeignMessage element in NestedmessageRepeatedForeignmessageList) { + size += pb::CodedOutputStream.ComputeMessageSize(2, element); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static NestedMessage ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -12966,7 +13086,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testNestedMessageHasBitsFieldNames; if (hasOptionalNestedMessage) { output.WriteMessage(1, field_names[0], OptionalNestedMessage); @@ -12979,17 +13099,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasOptionalNestedMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(1, OptionalNestedMessage); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasOptionalNestedMessage) { + size += pb::CodedOutputStream.ComputeMessageSize(1, OptionalNestedMessage); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestNestedMessageHasBits ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -13383,7 +13508,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testCamelCaseFieldNamesFieldNames; if (hasPrimitiveField) { output.WriteInt32(1, field_names[3], PrimitiveField); @@ -13429,77 +13554,82 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasPrimitiveField) { - size += pb::CodedOutputStream.ComputeInt32Size(1, PrimitiveField); - } - if (hasStringField) { - size += pb::CodedOutputStream.ComputeStringSize(2, StringField); - } - if (hasEnumField) { - size += pb::CodedOutputStream.ComputeEnumSize(3, (int) EnumField); - } - if (hasMessageField) { - size += pb::CodedOutputStream.ComputeMessageSize(4, MessageField); - } - if (hasStringPieceField) { - size += pb::CodedOutputStream.ComputeStringSize(5, StringPieceField); - } - if (hasCordField) { - size += pb::CodedOutputStream.ComputeStringSize(6, CordField); + return CalcSerializedSize(); + } + } + + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasPrimitiveField) { + size += pb::CodedOutputStream.ComputeInt32Size(1, PrimitiveField); + } + if (hasStringField) { + size += pb::CodedOutputStream.ComputeStringSize(2, StringField); + } + if (hasEnumField) { + size += pb::CodedOutputStream.ComputeEnumSize(3, (int) EnumField); + } + if (hasMessageField) { + size += pb::CodedOutputStream.ComputeMessageSize(4, MessageField); + } + if (hasStringPieceField) { + size += pb::CodedOutputStream.ComputeStringSize(5, StringPieceField); + } + if (hasCordField) { + size += pb::CodedOutputStream.ComputeStringSize(6, CordField); + } + { + int dataSize = 0; + foreach (int element in RepeatedPrimitiveFieldList) { + dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); } - { - int dataSize = 0; - foreach (int element in RepeatedPrimitiveFieldList) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); - } - size += dataSize; - size += 1 * repeatedPrimitiveField_.Count; + size += dataSize; + size += 1 * repeatedPrimitiveField_.Count; + } + { + int dataSize = 0; + foreach (string element in RepeatedStringFieldList) { + dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); } - { - int dataSize = 0; - foreach (string element in RepeatedStringFieldList) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); + size += dataSize; + size += 1 * repeatedStringField_.Count; + } + { + int dataSize = 0; + if (repeatedEnumField_.Count > 0) { + foreach (global::Google.ProtocolBuffers.TestProtos.ForeignEnum element in repeatedEnumField_) { + dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); } size += dataSize; - size += 1 * repeatedStringField_.Count; - } - { - int dataSize = 0; - if (repeatedEnumField_.Count > 0) { - foreach (global::Google.ProtocolBuffers.TestProtos.ForeignEnum element in repeatedEnumField_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 1 * repeatedEnumField_.Count; - } - } - foreach (global::Google.ProtocolBuffers.TestProtos.ForeignMessage element in RepeatedMessageFieldList) { - size += pb::CodedOutputStream.ComputeMessageSize(10, element); + size += 1 * repeatedEnumField_.Count; } - { - int dataSize = 0; - foreach (string element in RepeatedStringPieceFieldList) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); - } - size += dataSize; - size += 1 * repeatedStringPieceField_.Count; + } + foreach (global::Google.ProtocolBuffers.TestProtos.ForeignMessage element in RepeatedMessageFieldList) { + size += pb::CodedOutputStream.ComputeMessageSize(10, element); + } + { + int dataSize = 0; + foreach (string element in RepeatedStringPieceFieldList) { + dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); } - { - int dataSize = 0; - foreach (string element in RepeatedCordFieldList) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); - } - size += dataSize; - size += 1 * repeatedCordField_.Count; + size += dataSize; + size += 1 * repeatedStringPieceField_.Count; + } + { + int dataSize = 0; + foreach (string element in RepeatedCordFieldList) { + dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + size += dataSize; + size += 1 * repeatedCordField_.Count; } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; } - public static TestCamelCaseFieldNames ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -14197,7 +14327,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testFieldOrderingsFieldNames; pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); if (hasMyInt) { @@ -14216,27 +14346,32 @@ namespace Google.ProtocolBuffers.TestProtos { private int memoizedSerializedSize = -1; public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasMyString) { - size += pb::CodedOutputStream.ComputeStringSize(11, MyString); - } - if (hasMyInt) { - size += pb::CodedOutputStream.ComputeInt64Size(1, MyInt); - } - if (hasMyFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(101, MyFloat); - } - size += ExtensionsSerializedSize; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + get { + int size = memoizedSerializedSize; + if (size != -1) return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasMyString) { + size += pb::CodedOutputStream.ComputeStringSize(11, MyString); + } + if (hasMyInt) { + size += pb::CodedOutputStream.ComputeInt64Size(1, MyInt); + } + if (hasMyFloat) { + size += pb::CodedOutputStream.ComputeFloatSize(101, MyFloat); + } + size += ExtensionsSerializedSize; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestFieldOrderings ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -14731,7 +14866,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testExtremeDefaultValuesFieldNames; if (hasEscapedBytes) { output.WriteBytes(1, field_names[1], EscapedBytes); @@ -14801,74 +14936,79 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasEscapedBytes) { - size += pb::CodedOutputStream.ComputeBytesSize(1, EscapedBytes); - } - if (hasLargeUint32) { - size += pb::CodedOutputStream.ComputeUInt32Size(2, LargeUint32); - } - if (hasLargeUint64) { - size += pb::CodedOutputStream.ComputeUInt64Size(3, LargeUint64); - } - if (hasSmallInt32) { - size += pb::CodedOutputStream.ComputeInt32Size(4, SmallInt32); - } - if (hasSmallInt64) { - size += pb::CodedOutputStream.ComputeInt64Size(5, SmallInt64); - } - if (hasUtf8String) { - size += pb::CodedOutputStream.ComputeStringSize(6, Utf8String); - } - if (hasZeroFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(7, ZeroFloat); - } - if (hasOneFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(8, OneFloat); - } - if (hasSmallFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(9, SmallFloat); - } - if (hasNegativeOneFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(10, NegativeOneFloat); - } - if (hasNegativeFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(11, NegativeFloat); - } - if (hasLargeFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(12, LargeFloat); - } - if (hasSmallNegativeFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(13, SmallNegativeFloat); - } - if (hasInfDouble) { - size += pb::CodedOutputStream.ComputeDoubleSize(14, InfDouble); - } - if (hasNegInfDouble) { - size += pb::CodedOutputStream.ComputeDoubleSize(15, NegInfDouble); - } - if (hasNanDouble) { - size += pb::CodedOutputStream.ComputeDoubleSize(16, NanDouble); - } - if (hasInfFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(17, InfFloat); - } - if (hasNegInfFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(18, NegInfFloat); - } - if (hasNanFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(19, NanFloat); - } - if (hasCppTrigraph) { - size += pb::CodedOutputStream.ComputeStringSize(20, CppTrigraph); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasEscapedBytes) { + size += pb::CodedOutputStream.ComputeBytesSize(1, EscapedBytes); + } + if (hasLargeUint32) { + size += pb::CodedOutputStream.ComputeUInt32Size(2, LargeUint32); + } + if (hasLargeUint64) { + size += pb::CodedOutputStream.ComputeUInt64Size(3, LargeUint64); + } + if (hasSmallInt32) { + size += pb::CodedOutputStream.ComputeInt32Size(4, SmallInt32); + } + if (hasSmallInt64) { + size += pb::CodedOutputStream.ComputeInt64Size(5, SmallInt64); + } + if (hasUtf8String) { + size += pb::CodedOutputStream.ComputeStringSize(6, Utf8String); + } + if (hasZeroFloat) { + size += pb::CodedOutputStream.ComputeFloatSize(7, ZeroFloat); + } + if (hasOneFloat) { + size += pb::CodedOutputStream.ComputeFloatSize(8, OneFloat); + } + if (hasSmallFloat) { + size += pb::CodedOutputStream.ComputeFloatSize(9, SmallFloat); + } + if (hasNegativeOneFloat) { + size += pb::CodedOutputStream.ComputeFloatSize(10, NegativeOneFloat); + } + if (hasNegativeFloat) { + size += pb::CodedOutputStream.ComputeFloatSize(11, NegativeFloat); + } + if (hasLargeFloat) { + size += pb::CodedOutputStream.ComputeFloatSize(12, LargeFloat); + } + if (hasSmallNegativeFloat) { + size += pb::CodedOutputStream.ComputeFloatSize(13, SmallNegativeFloat); + } + if (hasInfDouble) { + size += pb::CodedOutputStream.ComputeDoubleSize(14, InfDouble); + } + if (hasNegInfDouble) { + size += pb::CodedOutputStream.ComputeDoubleSize(15, NegInfDouble); + } + if (hasNanDouble) { + size += pb::CodedOutputStream.ComputeDoubleSize(16, NanDouble); + } + if (hasInfFloat) { + size += pb::CodedOutputStream.ComputeFloatSize(17, InfFloat); + } + if (hasNegInfFloat) { + size += pb::CodedOutputStream.ComputeFloatSize(18, NegInfFloat); + } + if (hasNanFloat) { + size += pb::CodedOutputStream.ComputeFloatSize(19, NanFloat); + } + if (hasCppTrigraph) { + size += pb::CodedOutputStream.ComputeStringSize(20, CppTrigraph); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestExtremeDefaultValues ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -15635,7 +15775,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _sparseEnumMessageFieldNames; if (hasSparseEnum) { output.WriteEnum(1, field_names[0], (int) SparseEnum, SparseEnum); @@ -15648,17 +15788,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasSparseEnum) { - size += pb::CodedOutputStream.ComputeEnumSize(1, (int) SparseEnum); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasSparseEnum) { + size += pb::CodedOutputStream.ComputeEnumSize(1, (int) SparseEnum); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static SparseEnumMessage ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -15913,7 +16058,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _oneStringFieldNames; if (hasData) { output.WriteString(1, field_names[0], Data); @@ -15926,17 +16071,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasData) { - size += pb::CodedOutputStream.ComputeStringSize(1, Data); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasData) { + size += pb::CodedOutputStream.ComputeStringSize(1, Data); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static OneString ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -16184,7 +16334,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _oneBytesFieldNames; if (hasData) { output.WriteBytes(1, field_names[0], Data); @@ -16197,17 +16347,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasData) { - size += pb::CodedOutputStream.ComputeBytesSize(1, Data); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasData) { + size += pb::CodedOutputStream.ComputeBytesSize(1, Data); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static OneBytes ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -16635,7 +16790,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testPackedTypesFieldNames; if (packedInt32_.Count > 0) { output.WritePackedInt32Array(90, field_names[6], packedInt32MemoizedSerializedSize, packedInt32_); @@ -16687,155 +16842,160 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - { - int dataSize = 0; - foreach (int element in PackedInt32List) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); - } - size += dataSize; - if (packedInt32_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedInt32MemoizedSerializedSize = dataSize; + return CalcSerializedSize(); + } + } + + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + { + int dataSize = 0; + foreach (int element in PackedInt32List) { + dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); } - { - int dataSize = 0; - foreach (long element in PackedInt64List) { - dataSize += pb::CodedOutputStream.ComputeInt64SizeNoTag(element); - } - size += dataSize; - if (packedInt64_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedInt64MemoizedSerializedSize = dataSize; + size += dataSize; + if (packedInt32_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { - int dataSize = 0; - foreach (uint element in PackedUint32List) { - dataSize += pb::CodedOutputStream.ComputeUInt32SizeNoTag(element); - } - size += dataSize; - if (packedUint32_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedUint32MemoizedSerializedSize = dataSize; + packedInt32MemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + foreach (long element in PackedInt64List) { + dataSize += pb::CodedOutputStream.ComputeInt64SizeNoTag(element); } - { - int dataSize = 0; - foreach (ulong element in PackedUint64List) { - dataSize += pb::CodedOutputStream.ComputeUInt64SizeNoTag(element); - } - size += dataSize; - if (packedUint64_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedUint64MemoizedSerializedSize = dataSize; + size += dataSize; + if (packedInt64_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { - int dataSize = 0; - foreach (int element in PackedSint32List) { - dataSize += pb::CodedOutputStream.ComputeSInt32SizeNoTag(element); - } - size += dataSize; - if (packedSint32_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedSint32MemoizedSerializedSize = dataSize; + packedInt64MemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + foreach (uint element in PackedUint32List) { + dataSize += pb::CodedOutputStream.ComputeUInt32SizeNoTag(element); } - { - int dataSize = 0; - foreach (long element in PackedSint64List) { - dataSize += pb::CodedOutputStream.ComputeSInt64SizeNoTag(element); - } - size += dataSize; - if (packedSint64_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedSint64MemoizedSerializedSize = dataSize; + size += dataSize; + if (packedUint32_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { - int dataSize = 0; - dataSize = 4 * packedFixed32_.Count; - size += dataSize; - if (packedFixed32_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedFixed32MemoizedSerializedSize = dataSize; + packedUint32MemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + foreach (ulong element in PackedUint64List) { + dataSize += pb::CodedOutputStream.ComputeUInt64SizeNoTag(element); } - { - int dataSize = 0; - dataSize = 8 * packedFixed64_.Count; - size += dataSize; - if (packedFixed64_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedFixed64MemoizedSerializedSize = dataSize; + size += dataSize; + if (packedUint64_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { - int dataSize = 0; - dataSize = 4 * packedSfixed32_.Count; - size += dataSize; - if (packedSfixed32_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedSfixed32MemoizedSerializedSize = dataSize; + packedUint64MemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + foreach (int element in PackedSint32List) { + dataSize += pb::CodedOutputStream.ComputeSInt32SizeNoTag(element); } - { - int dataSize = 0; - dataSize = 8 * packedSfixed64_.Count; - size += dataSize; - if (packedSfixed64_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedSfixed64MemoizedSerializedSize = dataSize; + size += dataSize; + if (packedSint32_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { - int dataSize = 0; - dataSize = 4 * packedFloat_.Count; - size += dataSize; - if (packedFloat_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedFloatMemoizedSerializedSize = dataSize; + packedSint32MemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + foreach (long element in PackedSint64List) { + dataSize += pb::CodedOutputStream.ComputeSInt64SizeNoTag(element); } - { - int dataSize = 0; - dataSize = 8 * packedDouble_.Count; - size += dataSize; - if (packedDouble_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedDoubleMemoizedSerializedSize = dataSize; + size += dataSize; + if (packedSint64_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { - int dataSize = 0; - dataSize = 1 * packedBool_.Count; - size += dataSize; - if (packedBool_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedBoolMemoizedSerializedSize = dataSize; + packedSint64MemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + dataSize = 4 * packedFixed32_.Count; + size += dataSize; + if (packedFixed32_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { - int dataSize = 0; - if (packedEnum_.Count > 0) { - foreach (global::Google.ProtocolBuffers.TestProtos.ForeignEnum element in packedEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 2; - size += pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize); + packedFixed32MemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + dataSize = 8 * packedFixed64_.Count; + size += dataSize; + if (packedFixed64_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + } + packedFixed64MemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + dataSize = 4 * packedSfixed32_.Count; + size += dataSize; + if (packedSfixed32_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + } + packedSfixed32MemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + dataSize = 8 * packedSfixed64_.Count; + size += dataSize; + if (packedSfixed64_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + } + packedSfixed64MemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + dataSize = 4 * packedFloat_.Count; + size += dataSize; + if (packedFloat_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + } + packedFloatMemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + dataSize = 8 * packedDouble_.Count; + size += dataSize; + if (packedDouble_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + } + packedDoubleMemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + dataSize = 1 * packedBool_.Count; + size += dataSize; + if (packedBool_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + } + packedBoolMemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + if (packedEnum_.Count > 0) { + foreach (global::Google.ProtocolBuffers.TestProtos.ForeignEnum element in packedEnum_) { + dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); } - packedEnumMemoizedSerializedSize = dataSize; + size += dataSize; + size += 2; + size += pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize); } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + packedEnumMemoizedSerializedSize = dataSize; } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; } - public static TestPackedTypes ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -17796,7 +17956,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testUnpackedTypesFieldNames; if (unpackedInt32_.Count > 0) { output.WriteInt32Array(90, field_names[6], unpackedInt32_); @@ -17848,114 +18008,119 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - { - int dataSize = 0; - foreach (int element in UnpackedInt32List) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); - } - size += dataSize; - size += 2 * unpackedInt32_.Count; - } - { - int dataSize = 0; - foreach (long element in UnpackedInt64List) { - dataSize += pb::CodedOutputStream.ComputeInt64SizeNoTag(element); - } - size += dataSize; - size += 2 * unpackedInt64_.Count; - } - { - int dataSize = 0; - foreach (uint element in UnpackedUint32List) { - dataSize += pb::CodedOutputStream.ComputeUInt32SizeNoTag(element); - } - size += dataSize; - size += 2 * unpackedUint32_.Count; - } - { - int dataSize = 0; - foreach (ulong element in UnpackedUint64List) { - dataSize += pb::CodedOutputStream.ComputeUInt64SizeNoTag(element); - } - size += dataSize; - size += 2 * unpackedUint64_.Count; - } - { - int dataSize = 0; - foreach (int element in UnpackedSint32List) { - dataSize += pb::CodedOutputStream.ComputeSInt32SizeNoTag(element); + return CalcSerializedSize(); + } + } + + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + { + int dataSize = 0; + foreach (int element in UnpackedInt32List) { + dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); + } + size += dataSize; + size += 2 * unpackedInt32_.Count; + } + { + int dataSize = 0; + foreach (long element in UnpackedInt64List) { + dataSize += pb::CodedOutputStream.ComputeInt64SizeNoTag(element); + } + size += dataSize; + size += 2 * unpackedInt64_.Count; + } + { + int dataSize = 0; + foreach (uint element in UnpackedUint32List) { + dataSize += pb::CodedOutputStream.ComputeUInt32SizeNoTag(element); + } + size += dataSize; + size += 2 * unpackedUint32_.Count; + } + { + int dataSize = 0; + foreach (ulong element in UnpackedUint64List) { + dataSize += pb::CodedOutputStream.ComputeUInt64SizeNoTag(element); + } + size += dataSize; + size += 2 * unpackedUint64_.Count; + } + { + int dataSize = 0; + foreach (int element in UnpackedSint32List) { + dataSize += pb::CodedOutputStream.ComputeSInt32SizeNoTag(element); + } + size += dataSize; + size += 2 * unpackedSint32_.Count; + } + { + int dataSize = 0; + foreach (long element in UnpackedSint64List) { + dataSize += pb::CodedOutputStream.ComputeSInt64SizeNoTag(element); + } + size += dataSize; + size += 2 * unpackedSint64_.Count; + } + { + int dataSize = 0; + dataSize = 4 * unpackedFixed32_.Count; + size += dataSize; + size += 2 * unpackedFixed32_.Count; + } + { + int dataSize = 0; + dataSize = 8 * unpackedFixed64_.Count; + size += dataSize; + size += 2 * unpackedFixed64_.Count; + } + { + int dataSize = 0; + dataSize = 4 * unpackedSfixed32_.Count; + size += dataSize; + size += 2 * unpackedSfixed32_.Count; + } + { + int dataSize = 0; + dataSize = 8 * unpackedSfixed64_.Count; + size += dataSize; + size += 2 * unpackedSfixed64_.Count; + } + { + int dataSize = 0; + dataSize = 4 * unpackedFloat_.Count; + size += dataSize; + size += 2 * unpackedFloat_.Count; + } + { + int dataSize = 0; + dataSize = 8 * unpackedDouble_.Count; + size += dataSize; + size += 2 * unpackedDouble_.Count; + } + { + int dataSize = 0; + dataSize = 1 * unpackedBool_.Count; + size += dataSize; + size += 2 * unpackedBool_.Count; + } + { + int dataSize = 0; + if (unpackedEnum_.Count > 0) { + foreach (global::Google.ProtocolBuffers.TestProtos.ForeignEnum element in unpackedEnum_) { + dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); } size += dataSize; - size += 2 * unpackedSint32_.Count; - } - { - int dataSize = 0; - foreach (long element in UnpackedSint64List) { - dataSize += pb::CodedOutputStream.ComputeSInt64SizeNoTag(element); - } - size += dataSize; - size += 2 * unpackedSint64_.Count; - } - { - int dataSize = 0; - dataSize = 4 * unpackedFixed32_.Count; - size += dataSize; - size += 2 * unpackedFixed32_.Count; - } - { - int dataSize = 0; - dataSize = 8 * unpackedFixed64_.Count; - size += dataSize; - size += 2 * unpackedFixed64_.Count; - } - { - int dataSize = 0; - dataSize = 4 * unpackedSfixed32_.Count; - size += dataSize; - size += 2 * unpackedSfixed32_.Count; - } - { - int dataSize = 0; - dataSize = 8 * unpackedSfixed64_.Count; - size += dataSize; - size += 2 * unpackedSfixed64_.Count; - } - { - int dataSize = 0; - dataSize = 4 * unpackedFloat_.Count; - size += dataSize; - size += 2 * unpackedFloat_.Count; - } - { - int dataSize = 0; - dataSize = 8 * unpackedDouble_.Count; - size += dataSize; - size += 2 * unpackedDouble_.Count; - } - { - int dataSize = 0; - dataSize = 1 * unpackedBool_.Count; - size += dataSize; - size += 2 * unpackedBool_.Count; - } - { - int dataSize = 0; - if (unpackedEnum_.Count > 0) { - foreach (global::Google.ProtocolBuffers.TestProtos.ForeignEnum element in unpackedEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 2 * unpackedEnum_.Count; - } + size += 2 * unpackedEnum_.Count; } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; } - public static TestUnpackedTypes ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -18741,7 +18906,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testPackedExtensionsFieldNames; pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); extensionWriter.WriteUntil(536870912, output); @@ -18753,15 +18918,20 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - size += ExtensionsSerializedSize; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += ExtensionsSerializedSize; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestPackedExtensions ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -19017,7 +19187,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _dynamicMessageTypeFieldNames; if (hasDynamicField) { output.WriteInt32(2100, field_names[0], DynamicField); @@ -19030,17 +19200,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasDynamicField) { - size += pb::CodedOutputStream.ComputeInt32Size(2100, DynamicField); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasDynamicField) { + size += pb::CodedOutputStream.ComputeInt32Size(2100, DynamicField); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static DynamicMessageType ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -19330,7 +19505,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testDynamicExtensionsFieldNames; if (hasScalarExtension) { output.WriteFixed32(2000, field_names[6], ScalarExtension); @@ -19361,48 +19536,53 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasScalarExtension) { - size += pb::CodedOutputStream.ComputeFixed32Size(2000, ScalarExtension); - } - if (hasEnumExtension) { - size += pb::CodedOutputStream.ComputeEnumSize(2001, (int) EnumExtension); - } - if (hasDynamicEnumExtension) { - size += pb::CodedOutputStream.ComputeEnumSize(2002, (int) DynamicEnumExtension); - } - if (hasMessageExtension) { - size += pb::CodedOutputStream.ComputeMessageSize(2003, MessageExtension); - } - if (hasDynamicMessageExtension) { - size += pb::CodedOutputStream.ComputeMessageSize(2004, DynamicMessageExtension); + return CalcSerializedSize(); + } + } + + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasScalarExtension) { + size += pb::CodedOutputStream.ComputeFixed32Size(2000, ScalarExtension); + } + if (hasEnumExtension) { + size += pb::CodedOutputStream.ComputeEnumSize(2001, (int) EnumExtension); + } + if (hasDynamicEnumExtension) { + size += pb::CodedOutputStream.ComputeEnumSize(2002, (int) DynamicEnumExtension); + } + if (hasMessageExtension) { + size += pb::CodedOutputStream.ComputeMessageSize(2003, MessageExtension); + } + if (hasDynamicMessageExtension) { + size += pb::CodedOutputStream.ComputeMessageSize(2004, DynamicMessageExtension); + } + { + int dataSize = 0; + foreach (string element in RepeatedExtensionList) { + dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); } - { - int dataSize = 0; - foreach (string element in RepeatedExtensionList) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedExtension_.Count; + size += dataSize; + size += 2 * repeatedExtension_.Count; + } + { + int dataSize = 0; + foreach (int element in PackedExtensionList) { + dataSize += pb::CodedOutputStream.ComputeSInt32SizeNoTag(element); } - { - int dataSize = 0; - foreach (int element in PackedExtensionList) { - dataSize += pb::CodedOutputStream.ComputeSInt32SizeNoTag(element); - } - size += dataSize; - if (packedExtension_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedExtensionMemoizedSerializedSize = dataSize; + size += dataSize; + if (packedExtension_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + packedExtensionMemoizedSerializedSize = dataSize; } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; } - public static TestDynamicExtensions ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -19972,7 +20152,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testRepeatedScalarDifferentTagSizesFieldNames; if (repeatedFixed32_.Count > 0) { output.WriteFixed32Array(12, field_names[0], repeatedFixed32_); @@ -20000,56 +20180,61 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - { - int dataSize = 0; - dataSize = 4 * repeatedFixed32_.Count; - size += dataSize; - size += 1 * repeatedFixed32_.Count; - } - { - int dataSize = 0; - foreach (int element in RepeatedInt32List) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); - } - size += dataSize; - size += 1 * repeatedInt32_.Count; - } - { - int dataSize = 0; - dataSize = 8 * repeatedFixed64_.Count; - size += dataSize; - size += 2 * repeatedFixed64_.Count; - } - { - int dataSize = 0; - foreach (long element in RepeatedInt64List) { - dataSize += pb::CodedOutputStream.ComputeInt64SizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedInt64_.Count; + return CalcSerializedSize(); + } + } + + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + { + int dataSize = 0; + dataSize = 4 * repeatedFixed32_.Count; + size += dataSize; + size += 1 * repeatedFixed32_.Count; + } + { + int dataSize = 0; + foreach (int element in RepeatedInt32List) { + dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); } - { - int dataSize = 0; - dataSize = 4 * repeatedFloat_.Count; - size += dataSize; - size += 3 * repeatedFloat_.Count; + size += dataSize; + size += 1 * repeatedInt32_.Count; + } + { + int dataSize = 0; + dataSize = 8 * repeatedFixed64_.Count; + size += dataSize; + size += 2 * repeatedFixed64_.Count; + } + { + int dataSize = 0; + foreach (long element in RepeatedInt64List) { + dataSize += pb::CodedOutputStream.ComputeInt64SizeNoTag(element); } - { - int dataSize = 0; - foreach (ulong element in RepeatedUint64List) { - dataSize += pb::CodedOutputStream.ComputeUInt64SizeNoTag(element); - } - size += dataSize; - size += 3 * repeatedUint64_.Count; + size += dataSize; + size += 2 * repeatedInt64_.Count; + } + { + int dataSize = 0; + dataSize = 4 * repeatedFloat_.Count; + size += dataSize; + size += 3 * repeatedFloat_.Count; + } + { + int dataSize = 0; + foreach (ulong element in RepeatedUint64List) { + dataSize += pb::CodedOutputStream.ComputeUInt64SizeNoTag(element); } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + size += dataSize; + size += 3 * repeatedUint64_.Count; } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; } - public static TestRepeatedScalarDifferentTagSizes ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -20508,7 +20693,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _fooRequestFieldNames; UnknownFields.WriteTo(output); } @@ -20518,14 +20703,19 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static FooRequest ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -20735,7 +20925,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _fooResponseFieldNames; UnknownFields.WriteTo(output); } @@ -20745,14 +20935,19 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static FooResponse ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -20962,7 +21157,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _barRequestFieldNames; UnknownFields.WriteTo(output); } @@ -20972,14 +21167,19 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static BarRequest ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -21189,7 +21389,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _barResponseFieldNames; UnknownFields.WriteTo(output); } @@ -21199,14 +21399,19 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static BarResponse ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } diff --git a/src/ProtocolBuffers.Test/TestProtos/UnitTestRpcInterop.cs b/src/ProtocolBuffers.Test/TestProtos/UnitTestRpcInterop.cs index 95704f4935..58eff60fff 100644 --- a/src/ProtocolBuffers.Test/TestProtos/UnitTestRpcInterop.cs +++ b/src/ProtocolBuffers.Test/TestProtos/UnitTestRpcInterop.cs @@ -122,7 +122,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _searchRequestFieldNames; if (criteria_.Count > 0) { output.WriteStringArray(1, field_names[0], criteria_); @@ -135,22 +135,27 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - { - int dataSize = 0; - foreach (string element in CriteriaList) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); - } - size += dataSize; - size += 1 * criteria_.Count; - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + { + int dataSize = 0; + foreach (string element in CriteriaList) { + dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); + } + size += dataSize; + size += 1 * criteria_.Count; + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static SearchRequest ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -450,7 +455,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _resultItemFieldNames; if (hasUrl) { output.WriteString(1, field_names[1], Url); @@ -466,20 +471,25 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasUrl) { - size += pb::CodedOutputStream.ComputeStringSize(1, Url); - } - if (hasName) { - size += pb::CodedOutputStream.ComputeStringSize(2, Name); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasUrl) { + size += pb::CodedOutputStream.ComputeStringSize(1, Url); + } + if (hasName) { + size += pb::CodedOutputStream.ComputeStringSize(2, Name); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static ResultItem ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -737,7 +747,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _searchResponseFieldNames; if (results_.Count > 0) { output.WriteMessageArray(1, field_names[0], results_); @@ -750,17 +760,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - foreach (global::Google.ProtocolBuffers.TestProtos.SearchResponse.Types.ResultItem element in ResultsList) { - size += pb::CodedOutputStream.ComputeMessageSize(1, element); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + foreach (global::Google.ProtocolBuffers.TestProtos.SearchResponse.Types.ResultItem element in ResultsList) { + size += pb::CodedOutputStream.ComputeMessageSize(1, element); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static SearchResponse ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -1046,7 +1061,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _refineSearchRequestFieldNames; if (criteria_.Count > 0) { output.WriteStringArray(1, field_names[0], criteria_); @@ -1062,25 +1077,30 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - { - int dataSize = 0; - foreach (string element in CriteriaList) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); - } - size += dataSize; - size += 1 * criteria_.Count; - } - if (hasPreviousResults) { - size += pb::CodedOutputStream.ComputeMessageSize(2, PreviousResults); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + { + int dataSize = 0; + foreach (string element in CriteriaList) { + dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); + } + size += dataSize; + size += 1 * criteria_.Count; + } + if (hasPreviousResults) { + size += pb::CodedOutputStream.ComputeMessageSize(2, PreviousResults); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static RefineSearchRequest ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } diff --git a/src/ProtocolBuffers.Test/TestProtos/UnitTestXmlSerializerTestProtoFile.cs b/src/ProtocolBuffers.Test/TestProtos/UnitTestXmlSerializerTestProtoFile.cs index 2345047100..5d4e631ae6 100644 --- a/src/ProtocolBuffers.Test/TestProtos/UnitTestXmlSerializerTestProtoFile.cs +++ b/src/ProtocolBuffers.Test/TestProtos/UnitTestXmlSerializerTestProtoFile.cs @@ -187,7 +187,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testXmlChildFieldNames; if (options_.Count > 0) { output.WriteEnumArray(3, field_names[1], options_); @@ -203,27 +203,32 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - { - int dataSize = 0; - if (options_.Count > 0) { - foreach (global::Google.ProtocolBuffers.TestProtos.EnumOptions element in options_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 1 * options_.Count; + return CalcSerializedSize(); + } + } + + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + { + int dataSize = 0; + if (options_.Count > 0) { + foreach (global::Google.ProtocolBuffers.TestProtos.EnumOptions element in options_) { + dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); } + size += dataSize; + size += 1 * options_.Count; } - if (hasBinary) { - size += pb::CodedOutputStream.ComputeBytesSize(4, Binary); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; } + if (hasBinary) { + size += pb::CodedOutputStream.ComputeBytesSize(4, Binary); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; } - public static TestXmlChild ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -511,7 +516,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testXmlNoFieldsFieldNames; UnknownFields.WriteTo(output); } @@ -521,14 +526,19 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestXmlNoFields ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -750,7 +760,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testXmlRescursiveFieldNames; if (hasChild) { output.WriteMessage(1, field_names[0], Child); @@ -763,17 +773,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasChild) { - size += pb::CodedOutputStream.ComputeMessageSize(1, Child); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasChild) { + size += pb::CodedOutputStream.ComputeMessageSize(1, Child); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestXmlRescursive ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -1089,7 +1104,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _childrenFieldNames; if (options_.Count > 0) { output.WriteEnumArray(3, field_names[1], options_); @@ -1105,27 +1120,32 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - { - int dataSize = 0; - if (options_.Count > 0) { - foreach (global::Google.ProtocolBuffers.TestProtos.EnumOptions element in options_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 1 * options_.Count; + return CalcSerializedSize(); + } + } + + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + { + int dataSize = 0; + if (options_.Count > 0) { + foreach (global::Google.ProtocolBuffers.TestProtos.EnumOptions element in options_) { + dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); } + size += dataSize; + size += 1 * options_.Count; } - if (hasBinary) { - size += pb::CodedOutputStream.ComputeBytesSize(4, Binary); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; } + if (hasBinary) { + size += pb::CodedOutputStream.ComputeBytesSize(4, Binary); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; } - public static Children ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -1466,7 +1486,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testXmlMessageFieldNames; pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); if (hasChild) { @@ -1499,46 +1519,51 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasNumber) { - size += pb::CodedOutputStream.ComputeInt64Size(6, Number); - } - { - int dataSize = 0; - foreach (int element in NumbersList) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); - } - size += dataSize; - size += 1 * numbers_.Count; - } - if (hasText) { - size += pb::CodedOutputStream.ComputeStringSize(3, Text); - } - { - int dataSize = 0; - foreach (string element in TextlinesList) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); - } - size += dataSize; - size += 2 * textlines_.Count; - } - if (hasValid) { - size += pb::CodedOutputStream.ComputeBoolSize(5, Valid); - } - if (hasChild) { - size += pb::CodedOutputStream.ComputeMessageSize(1, Child); + return CalcSerializedSize(); + } + } + + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasNumber) { + size += pb::CodedOutputStream.ComputeInt64Size(6, Number); + } + { + int dataSize = 0; + foreach (int element in NumbersList) { + dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); } - foreach (global::Google.ProtocolBuffers.TestProtos.TestXmlMessage.Types.Children element in ChildrenList) { - size += pb::CodedOutputStream.ComputeGroupSize(401, element); + size += dataSize; + size += 1 * numbers_.Count; + } + if (hasText) { + size += pb::CodedOutputStream.ComputeStringSize(3, Text); + } + { + int dataSize = 0; + foreach (string element in TextlinesList) { + dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); } - size += ExtensionsSerializedSize; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + size += dataSize; + size += 2 * textlines_.Count; + } + if (hasValid) { + size += pb::CodedOutputStream.ComputeBoolSize(5, Valid); + } + if (hasChild) { + size += pb::CodedOutputStream.ComputeMessageSize(1, Child); + } + foreach (global::Google.ProtocolBuffers.TestProtos.TestXmlMessage.Types.Children element in ChildrenList) { + size += pb::CodedOutputStream.ComputeGroupSize(401, element); } + size += ExtensionsSerializedSize; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; } - public static TestXmlMessage ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -2027,7 +2052,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testXmlExtensionFieldNames; if (hasNumber) { output.WriteInt32(1, field_names[0], Number); @@ -2040,17 +2065,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasNumber) { - size += pb::CodedOutputStream.ComputeInt32Size(1, Number); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasNumber) { + size += pb::CodedOutputStream.ComputeInt32Size(1, Number); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestXmlExtension ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } diff --git a/src/ProtocolBuffers/DescriptorProtos/CSharpOptions.cs b/src/ProtocolBuffers/DescriptorProtos/CSharpOptions.cs index d7185869f8..fc5e7a56b4 100644 --- a/src/ProtocolBuffers/DescriptorProtos/CSharpOptions.cs +++ b/src/ProtocolBuffers/DescriptorProtos/CSharpOptions.cs @@ -313,7 +313,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _cSharpFileOptionsFieldNames; if (hasNamespace) { output.WriteString(1, field_names[9], Namespace); @@ -371,62 +371,67 @@ namespace Google.ProtocolBuffers.DescriptorProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasNamespace) { - size += pb::CodedOutputStream.ComputeStringSize(1, Namespace); - } - if (hasUmbrellaClassname) { - size += pb::CodedOutputStream.ComputeStringSize(2, UmbrellaClassname); - } - if (hasPublicClasses) { - size += pb::CodedOutputStream.ComputeBoolSize(3, PublicClasses); - } - if (hasMultipleFiles) { - size += pb::CodedOutputStream.ComputeBoolSize(4, MultipleFiles); - } - if (hasNestClasses) { - size += pb::CodedOutputStream.ComputeBoolSize(5, NestClasses); - } - if (hasCodeContracts) { - size += pb::CodedOutputStream.ComputeBoolSize(6, CodeContracts); - } - if (hasExpandNamespaceDirectories) { - size += pb::CodedOutputStream.ComputeBoolSize(7, ExpandNamespaceDirectories); - } - if (hasClsCompliance) { - size += pb::CodedOutputStream.ComputeBoolSize(8, ClsCompliance); - } - if (hasAddSerializable) { - size += pb::CodedOutputStream.ComputeBoolSize(9, AddSerializable); - } - if (hasGeneratePrivateCtor) { - size += pb::CodedOutputStream.ComputeBoolSize(10, GeneratePrivateCtor); - } - if (hasFileExtension) { - size += pb::CodedOutputStream.ComputeStringSize(221, FileExtension); - } - if (hasUmbrellaNamespace) { - size += pb::CodedOutputStream.ComputeStringSize(222, UmbrellaNamespace); - } - if (hasOutputDirectory) { - size += pb::CodedOutputStream.ComputeStringSize(223, OutputDirectory); - } - if (hasIgnoreGoogleProtobuf) { - size += pb::CodedOutputStream.ComputeBoolSize(224, IgnoreGoogleProtobuf); - } - if (hasServiceGeneratorType) { - size += pb::CodedOutputStream.ComputeEnumSize(225, (int) ServiceGeneratorType); - } - if (hasGeneratedCodeAttributes) { - size += pb::CodedOutputStream.ComputeBoolSize(226, GeneratedCodeAttributes); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasNamespace) { + size += pb::CodedOutputStream.ComputeStringSize(1, Namespace); + } + if (hasUmbrellaClassname) { + size += pb::CodedOutputStream.ComputeStringSize(2, UmbrellaClassname); + } + if (hasPublicClasses) { + size += pb::CodedOutputStream.ComputeBoolSize(3, PublicClasses); + } + if (hasMultipleFiles) { + size += pb::CodedOutputStream.ComputeBoolSize(4, MultipleFiles); + } + if (hasNestClasses) { + size += pb::CodedOutputStream.ComputeBoolSize(5, NestClasses); + } + if (hasCodeContracts) { + size += pb::CodedOutputStream.ComputeBoolSize(6, CodeContracts); + } + if (hasExpandNamespaceDirectories) { + size += pb::CodedOutputStream.ComputeBoolSize(7, ExpandNamespaceDirectories); + } + if (hasClsCompliance) { + size += pb::CodedOutputStream.ComputeBoolSize(8, ClsCompliance); + } + if (hasAddSerializable) { + size += pb::CodedOutputStream.ComputeBoolSize(9, AddSerializable); + } + if (hasGeneratePrivateCtor) { + size += pb::CodedOutputStream.ComputeBoolSize(10, GeneratePrivateCtor); + } + if (hasFileExtension) { + size += pb::CodedOutputStream.ComputeStringSize(221, FileExtension); + } + if (hasUmbrellaNamespace) { + size += pb::CodedOutputStream.ComputeStringSize(222, UmbrellaNamespace); + } + if (hasOutputDirectory) { + size += pb::CodedOutputStream.ComputeStringSize(223, OutputDirectory); + } + if (hasIgnoreGoogleProtobuf) { + size += pb::CodedOutputStream.ComputeBoolSize(224, IgnoreGoogleProtobuf); + } + if (hasServiceGeneratorType) { + size += pb::CodedOutputStream.ComputeEnumSize(225, (int) ServiceGeneratorType); + } + if (hasGeneratedCodeAttributes) { + size += pb::CodedOutputStream.ComputeBoolSize(226, GeneratedCodeAttributes); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static CSharpFileOptions ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -1091,7 +1096,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _cSharpFieldOptionsFieldNames; if (hasPropertyName) { output.WriteString(1, field_names[0], PropertyName); @@ -1104,17 +1109,22 @@ namespace Google.ProtocolBuffers.DescriptorProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasPropertyName) { - size += pb::CodedOutputStream.ComputeStringSize(1, PropertyName); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasPropertyName) { + size += pb::CodedOutputStream.ComputeStringSize(1, PropertyName); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static CSharpFieldOptions ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -1362,7 +1372,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _cSharpServiceOptionsFieldNames; if (hasInterfaceId) { output.WriteString(1, field_names[0], InterfaceId); @@ -1375,17 +1385,22 @@ namespace Google.ProtocolBuffers.DescriptorProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasInterfaceId) { - size += pb::CodedOutputStream.ComputeStringSize(1, InterfaceId); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasInterfaceId) { + size += pb::CodedOutputStream.ComputeStringSize(1, InterfaceId); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static CSharpServiceOptions ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -1633,7 +1648,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _cSharpMethodOptionsFieldNames; if (hasDispatchId) { output.WriteInt32(1, field_names[0], DispatchId); @@ -1646,17 +1661,22 @@ namespace Google.ProtocolBuffers.DescriptorProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasDispatchId) { - size += pb::CodedOutputStream.ComputeInt32Size(1, DispatchId); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasDispatchId) { + size += pb::CodedOutputStream.ComputeInt32Size(1, DispatchId); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static CSharpMethodOptions ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } diff --git a/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs b/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs index 15cd629dd9..0d3e401036 100644 --- a/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs +++ b/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs @@ -294,7 +294,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _fileDescriptorSetFieldNames; if (file_.Count > 0) { output.WriteMessageArray(1, field_names[0], file_); @@ -307,17 +307,22 @@ namespace Google.ProtocolBuffers.DescriptorProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - foreach (global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorProto element in FileList) { - size += pb::CodedOutputStream.ComputeMessageSize(1, element); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + foreach (global::Google.ProtocolBuffers.DescriptorProtos.FileDescriptorProto element in FileList) { + size += pb::CodedOutputStream.ComputeMessageSize(1, element); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static FileDescriptorSet ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -694,7 +699,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _fileDescriptorProtoFieldNames; if (hasName) { output.WriteString(1, field_names[4], Name); @@ -731,46 +736,51 @@ namespace Google.ProtocolBuffers.DescriptorProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasName) { - size += pb::CodedOutputStream.ComputeStringSize(1, Name); - } - if (hasPackage) { - size += pb::CodedOutputStream.ComputeStringSize(2, Package); - } - { - int dataSize = 0; - foreach (string element in DependencyList) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); - } - size += dataSize; - size += 1 * dependency_.Count; - } - foreach (global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto element in MessageTypeList) { - size += pb::CodedOutputStream.ComputeMessageSize(4, element); - } - foreach (global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto element in EnumTypeList) { - size += pb::CodedOutputStream.ComputeMessageSize(5, element); - } - foreach (global::Google.ProtocolBuffers.DescriptorProtos.ServiceDescriptorProto element in ServiceList) { - size += pb::CodedOutputStream.ComputeMessageSize(6, element); - } - foreach (global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto element in ExtensionList) { - size += pb::CodedOutputStream.ComputeMessageSize(7, element); - } - if (hasOptions) { - size += pb::CodedOutputStream.ComputeMessageSize(8, Options); - } - if (hasSourceCodeInfo) { - size += pb::CodedOutputStream.ComputeMessageSize(9, SourceCodeInfo); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasName) { + size += pb::CodedOutputStream.ComputeStringSize(1, Name); + } + if (hasPackage) { + size += pb::CodedOutputStream.ComputeStringSize(2, Package); + } + { + int dataSize = 0; + foreach (string element in DependencyList) { + dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); + } + size += dataSize; + size += 1 * dependency_.Count; + } + foreach (global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto element in MessageTypeList) { + size += pb::CodedOutputStream.ComputeMessageSize(4, element); + } + foreach (global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto element in EnumTypeList) { + size += pb::CodedOutputStream.ComputeMessageSize(5, element); + } + foreach (global::Google.ProtocolBuffers.DescriptorProtos.ServiceDescriptorProto element in ServiceList) { + size += pb::CodedOutputStream.ComputeMessageSize(6, element); + } + foreach (global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto element in ExtensionList) { + size += pb::CodedOutputStream.ComputeMessageSize(7, element); + } + if (hasOptions) { + size += pb::CodedOutputStream.ComputeMessageSize(8, Options); + } + if (hasSourceCodeInfo) { + size += pb::CodedOutputStream.ComputeMessageSize(9, SourceCodeInfo); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static FileDescriptorProto ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -1437,7 +1447,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _extensionRangeFieldNames; if (hasStart) { output.WriteInt32(1, field_names[1], Start); @@ -1453,20 +1463,25 @@ namespace Google.ProtocolBuffers.DescriptorProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasStart) { - size += pb::CodedOutputStream.ComputeInt32Size(1, Start); - } - if (hasEnd) { - size += pb::CodedOutputStream.ComputeInt32Size(2, End); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasStart) { + size += pb::CodedOutputStream.ComputeInt32Size(1, Start); + } + if (hasEnd) { + size += pb::CodedOutputStream.ComputeInt32Size(2, End); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static ExtensionRange ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -1802,7 +1817,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _descriptorProtoFieldNames; if (hasName) { output.WriteString(1, field_names[4], Name); @@ -1833,35 +1848,40 @@ namespace Google.ProtocolBuffers.DescriptorProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasName) { - size += pb::CodedOutputStream.ComputeStringSize(1, Name); - } - foreach (global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto element in FieldList) { - size += pb::CodedOutputStream.ComputeMessageSize(2, element); - } - foreach (global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto element in ExtensionList) { - size += pb::CodedOutputStream.ComputeMessageSize(6, element); - } - foreach (global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto element in NestedTypeList) { - size += pb::CodedOutputStream.ComputeMessageSize(3, element); - } - foreach (global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto element in EnumTypeList) { - size += pb::CodedOutputStream.ComputeMessageSize(4, element); - } - foreach (global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ExtensionRange element in ExtensionRangeList) { - size += pb::CodedOutputStream.ComputeMessageSize(5, element); - } - if (hasOptions) { - size += pb::CodedOutputStream.ComputeMessageSize(7, Options); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasName) { + size += pb::CodedOutputStream.ComputeStringSize(1, Name); + } + foreach (global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto element in FieldList) { + size += pb::CodedOutputStream.ComputeMessageSize(2, element); + } + foreach (global::Google.ProtocolBuffers.DescriptorProtos.FieldDescriptorProto element in ExtensionList) { + size += pb::CodedOutputStream.ComputeMessageSize(6, element); + } + foreach (global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto element in NestedTypeList) { + size += pb::CodedOutputStream.ComputeMessageSize(3, element); + } + foreach (global::Google.ProtocolBuffers.DescriptorProtos.EnumDescriptorProto element in EnumTypeList) { + size += pb::CodedOutputStream.ComputeMessageSize(4, element); + } + foreach (global::Google.ProtocolBuffers.DescriptorProtos.DescriptorProto.Types.ExtensionRange element in ExtensionRangeList) { + size += pb::CodedOutputStream.ComputeMessageSize(5, element); + } + if (hasOptions) { + size += pb::CodedOutputStream.ComputeMessageSize(7, Options); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static DescriptorProto ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -2527,7 +2547,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _fieldDescriptorProtoFieldNames; if (hasName) { output.WriteString(1, field_names[3], Name); @@ -2561,38 +2581,43 @@ namespace Google.ProtocolBuffers.DescriptorProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasName) { - size += pb::CodedOutputStream.ComputeStringSize(1, Name); - } - if (hasNumber) { - size += pb::CodedOutputStream.ComputeInt32Size(3, Number); - } - if (hasLabel) { - size += pb::CodedOutputStream.ComputeEnumSize(4, (int) Label); - } - if (hasType) { - size += pb::CodedOutputStream.ComputeEnumSize(5, (int) Type); - } - if (hasTypeName) { - size += pb::CodedOutputStream.ComputeStringSize(6, TypeName); - } - if (hasExtendee) { - size += pb::CodedOutputStream.ComputeStringSize(2, Extendee); - } - if (hasDefaultValue) { - size += pb::CodedOutputStream.ComputeStringSize(7, DefaultValue); - } - if (hasOptions) { - size += pb::CodedOutputStream.ComputeMessageSize(8, Options); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasName) { + size += pb::CodedOutputStream.ComputeStringSize(1, Name); + } + if (hasNumber) { + size += pb::CodedOutputStream.ComputeInt32Size(3, Number); + } + if (hasLabel) { + size += pb::CodedOutputStream.ComputeEnumSize(4, (int) Label); + } + if (hasType) { + size += pb::CodedOutputStream.ComputeEnumSize(5, (int) Type); + } + if (hasTypeName) { + size += pb::CodedOutputStream.ComputeStringSize(6, TypeName); + } + if (hasExtendee) { + size += pb::CodedOutputStream.ComputeStringSize(2, Extendee); + } + if (hasDefaultValue) { + size += pb::CodedOutputStream.ComputeStringSize(7, DefaultValue); + } + if (hasOptions) { + size += pb::CodedOutputStream.ComputeMessageSize(8, Options); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static FieldDescriptorProto ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -3101,7 +3126,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _enumDescriptorProtoFieldNames; if (hasName) { output.WriteString(1, field_names[0], Name); @@ -3120,23 +3145,28 @@ namespace Google.ProtocolBuffers.DescriptorProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasName) { - size += pb::CodedOutputStream.ComputeStringSize(1, Name); - } - foreach (global::Google.ProtocolBuffers.DescriptorProtos.EnumValueDescriptorProto element in ValueList) { - size += pb::CodedOutputStream.ComputeMessageSize(2, element); - } - if (hasOptions) { - size += pb::CodedOutputStream.ComputeMessageSize(3, Options); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasName) { + size += pb::CodedOutputStream.ComputeStringSize(1, Name); + } + foreach (global::Google.ProtocolBuffers.DescriptorProtos.EnumValueDescriptorProto element in ValueList) { + size += pb::CodedOutputStream.ComputeMessageSize(2, element); + } + if (hasOptions) { + size += pb::CodedOutputStream.ComputeMessageSize(3, Options); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static EnumDescriptorProto ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -3511,7 +3541,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _enumValueDescriptorProtoFieldNames; if (hasName) { output.WriteString(1, field_names[0], Name); @@ -3530,23 +3560,28 @@ namespace Google.ProtocolBuffers.DescriptorProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasName) { - size += pb::CodedOutputStream.ComputeStringSize(1, Name); - } - if (hasNumber) { - size += pb::CodedOutputStream.ComputeInt32Size(2, Number); - } - if (hasOptions) { - size += pb::CodedOutputStream.ComputeMessageSize(3, Options); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasName) { + size += pb::CodedOutputStream.ComputeStringSize(1, Name); + } + if (hasNumber) { + size += pb::CodedOutputStream.ComputeInt32Size(2, Number); + } + if (hasOptions) { + size += pb::CodedOutputStream.ComputeMessageSize(3, Options); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static EnumValueDescriptorProto ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -3901,7 +3936,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _serviceDescriptorProtoFieldNames; if (hasName) { output.WriteString(1, field_names[1], Name); @@ -3920,23 +3955,28 @@ namespace Google.ProtocolBuffers.DescriptorProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasName) { - size += pb::CodedOutputStream.ComputeStringSize(1, Name); - } - foreach (global::Google.ProtocolBuffers.DescriptorProtos.MethodDescriptorProto element in MethodList) { - size += pb::CodedOutputStream.ComputeMessageSize(2, element); - } - if (hasOptions) { - size += pb::CodedOutputStream.ComputeMessageSize(3, Options); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasName) { + size += pb::CodedOutputStream.ComputeStringSize(1, Name); + } + foreach (global::Google.ProtocolBuffers.DescriptorProtos.MethodDescriptorProto element in MethodList) { + size += pb::CodedOutputStream.ComputeMessageSize(2, element); + } + if (hasOptions) { + size += pb::CodedOutputStream.ComputeMessageSize(3, Options); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static ServiceDescriptorProto ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -4321,7 +4361,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _methodDescriptorProtoFieldNames; if (hasName) { output.WriteString(1, field_names[1], Name); @@ -4343,26 +4383,31 @@ namespace Google.ProtocolBuffers.DescriptorProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasName) { - size += pb::CodedOutputStream.ComputeStringSize(1, Name); - } - if (hasInputType) { - size += pb::CodedOutputStream.ComputeStringSize(2, InputType); - } - if (hasOutputType) { - size += pb::CodedOutputStream.ComputeStringSize(3, OutputType); - } - if (hasOptions) { - size += pb::CodedOutputStream.ComputeMessageSize(4, Options); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasName) { + size += pb::CodedOutputStream.ComputeStringSize(1, Name); + } + if (hasInputType) { + size += pb::CodedOutputStream.ComputeStringSize(2, InputType); + } + if (hasOutputType) { + size += pb::CodedOutputStream.ComputeStringSize(3, OutputType); + } + if (hasOptions) { + size += pb::CodedOutputStream.ComputeMessageSize(4, Options); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static MethodDescriptorProto ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -4816,7 +4861,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _fileOptionsFieldNames; pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); if (hasJavaPackage) { @@ -4855,42 +4900,47 @@ namespace Google.ProtocolBuffers.DescriptorProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasJavaPackage) { - size += pb::CodedOutputStream.ComputeStringSize(1, JavaPackage); - } - if (hasJavaOuterClassname) { - size += pb::CodedOutputStream.ComputeStringSize(8, JavaOuterClassname); - } - if (hasJavaMultipleFiles) { - size += pb::CodedOutputStream.ComputeBoolSize(10, JavaMultipleFiles); - } - if (hasJavaGenerateEqualsAndHash) { - size += pb::CodedOutputStream.ComputeBoolSize(20, JavaGenerateEqualsAndHash); - } - if (hasOptimizeFor) { - size += pb::CodedOutputStream.ComputeEnumSize(9, (int) OptimizeFor); - } - if (hasCcGenericServices) { - size += pb::CodedOutputStream.ComputeBoolSize(16, CcGenericServices); - } - if (hasJavaGenericServices) { - size += pb::CodedOutputStream.ComputeBoolSize(17, JavaGenericServices); - } - if (hasPyGenericServices) { - size += pb::CodedOutputStream.ComputeBoolSize(18, PyGenericServices); - } - foreach (global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption element in UninterpretedOptionList) { - size += pb::CodedOutputStream.ComputeMessageSize(999, element); - } - size += ExtensionsSerializedSize; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasJavaPackage) { + size += pb::CodedOutputStream.ComputeStringSize(1, JavaPackage); + } + if (hasJavaOuterClassname) { + size += pb::CodedOutputStream.ComputeStringSize(8, JavaOuterClassname); + } + if (hasJavaMultipleFiles) { + size += pb::CodedOutputStream.ComputeBoolSize(10, JavaMultipleFiles); + } + if (hasJavaGenerateEqualsAndHash) { + size += pb::CodedOutputStream.ComputeBoolSize(20, JavaGenerateEqualsAndHash); + } + if (hasOptimizeFor) { + size += pb::CodedOutputStream.ComputeEnumSize(9, (int) OptimizeFor); + } + if (hasCcGenericServices) { + size += pb::CodedOutputStream.ComputeBoolSize(16, CcGenericServices); + } + if (hasJavaGenericServices) { + size += pb::CodedOutputStream.ComputeBoolSize(17, JavaGenericServices); + } + if (hasPyGenericServices) { + size += pb::CodedOutputStream.ComputeBoolSize(18, PyGenericServices); + } + foreach (global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption element in UninterpretedOptionList) { + size += pb::CodedOutputStream.ComputeMessageSize(999, element); + } + size += ExtensionsSerializedSize; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static FileOptions ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -5415,7 +5465,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _messageOptionsFieldNames; pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); if (hasMessageSetWireFormat) { @@ -5436,24 +5486,29 @@ namespace Google.ProtocolBuffers.DescriptorProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasMessageSetWireFormat) { - size += pb::CodedOutputStream.ComputeBoolSize(1, MessageSetWireFormat); - } - if (hasNoStandardDescriptorAccessor) { - size += pb::CodedOutputStream.ComputeBoolSize(2, NoStandardDescriptorAccessor); - } - foreach (global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption element in UninterpretedOptionList) { - size += pb::CodedOutputStream.ComputeMessageSize(999, element); - } - size += ExtensionsSerializedSize; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasMessageSetWireFormat) { + size += pb::CodedOutputStream.ComputeBoolSize(1, MessageSetWireFormat); + } + if (hasNoStandardDescriptorAccessor) { + size += pb::CodedOutputStream.ComputeBoolSize(2, NoStandardDescriptorAccessor); + } + foreach (global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption element in UninterpretedOptionList) { + size += pb::CodedOutputStream.ComputeMessageSize(999, element); + } + size += ExtensionsSerializedSize; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static MessageOptions ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -5838,7 +5893,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _fieldOptionsFieldNames; pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); if (hasCtype) { @@ -5865,30 +5920,35 @@ namespace Google.ProtocolBuffers.DescriptorProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasCtype) { - size += pb::CodedOutputStream.ComputeEnumSize(1, (int) Ctype); - } - if (hasPacked) { - size += pb::CodedOutputStream.ComputeBoolSize(2, Packed); - } - if (hasDeprecated) { - size += pb::CodedOutputStream.ComputeBoolSize(3, Deprecated); - } - if (hasExperimentalMapKey) { - size += pb::CodedOutputStream.ComputeStringSize(9, ExperimentalMapKey); - } - foreach (global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption element in UninterpretedOptionList) { - size += pb::CodedOutputStream.ComputeMessageSize(999, element); - } - size += ExtensionsSerializedSize; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasCtype) { + size += pb::CodedOutputStream.ComputeEnumSize(1, (int) Ctype); + } + if (hasPacked) { + size += pb::CodedOutputStream.ComputeBoolSize(2, Packed); + } + if (hasDeprecated) { + size += pb::CodedOutputStream.ComputeBoolSize(3, Deprecated); + } + if (hasExperimentalMapKey) { + size += pb::CodedOutputStream.ComputeStringSize(9, ExperimentalMapKey); + } + foreach (global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption element in UninterpretedOptionList) { + size += pb::CodedOutputStream.ComputeMessageSize(999, element); + } + size += ExtensionsSerializedSize; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static FieldOptions ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -6284,7 +6344,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _enumOptionsFieldNames; pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); if (uninterpretedOption_.Count > 0) { @@ -6299,18 +6359,23 @@ namespace Google.ProtocolBuffers.DescriptorProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - foreach (global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption element in UninterpretedOptionList) { - size += pb::CodedOutputStream.ComputeMessageSize(999, element); - } - size += ExtensionsSerializedSize; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + foreach (global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption element in UninterpretedOptionList) { + size += pb::CodedOutputStream.ComputeMessageSize(999, element); + } + size += ExtensionsSerializedSize; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static EnumOptions ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -6589,7 +6654,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _enumValueOptionsFieldNames; pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); if (uninterpretedOption_.Count > 0) { @@ -6604,18 +6669,23 @@ namespace Google.ProtocolBuffers.DescriptorProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - foreach (global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption element in UninterpretedOptionList) { - size += pb::CodedOutputStream.ComputeMessageSize(999, element); - } - size += ExtensionsSerializedSize; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + foreach (global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption element in UninterpretedOptionList) { + size += pb::CodedOutputStream.ComputeMessageSize(999, element); + } + size += ExtensionsSerializedSize; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static EnumValueOptions ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -6894,7 +6964,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _serviceOptionsFieldNames; pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); if (uninterpretedOption_.Count > 0) { @@ -6909,18 +6979,23 @@ namespace Google.ProtocolBuffers.DescriptorProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - foreach (global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption element in UninterpretedOptionList) { - size += pb::CodedOutputStream.ComputeMessageSize(999, element); - } - size += ExtensionsSerializedSize; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + foreach (global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption element in UninterpretedOptionList) { + size += pb::CodedOutputStream.ComputeMessageSize(999, element); + } + size += ExtensionsSerializedSize; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static ServiceOptions ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -7199,7 +7274,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _methodOptionsFieldNames; pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); if (uninterpretedOption_.Count > 0) { @@ -7214,18 +7289,23 @@ namespace Google.ProtocolBuffers.DescriptorProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - foreach (global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption element in UninterpretedOptionList) { - size += pb::CodedOutputStream.ComputeMessageSize(999, element); - } - size += ExtensionsSerializedSize; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + foreach (global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption element in UninterpretedOptionList) { + size += pb::CodedOutputStream.ComputeMessageSize(999, element); + } + size += ExtensionsSerializedSize; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static MethodOptions ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -7539,7 +7619,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _namePartFieldNames; if (hasNamePart_) { output.WriteString(1, field_names[1], NamePart_); @@ -7555,20 +7635,25 @@ namespace Google.ProtocolBuffers.DescriptorProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasNamePart_) { - size += pb::CodedOutputStream.ComputeStringSize(1, NamePart_); - } - if (hasIsExtension) { - size += pb::CodedOutputStream.ComputeBoolSize(2, IsExtension); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasNamePart_) { + size += pb::CodedOutputStream.ComputeStringSize(1, NamePart_); + } + if (hasIsExtension) { + size += pb::CodedOutputStream.ComputeBoolSize(2, IsExtension); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static NamePart ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -7886,7 +7971,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _uninterpretedOptionFieldNames; if (name_.Count > 0) { output.WriteMessageArray(2, field_names[3], name_); @@ -7917,35 +8002,40 @@ namespace Google.ProtocolBuffers.DescriptorProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - foreach (global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Types.NamePart element in NameList) { - size += pb::CodedOutputStream.ComputeMessageSize(2, element); - } - if (hasIdentifierValue) { - size += pb::CodedOutputStream.ComputeStringSize(3, IdentifierValue); - } - if (hasPositiveIntValue) { - size += pb::CodedOutputStream.ComputeUInt64Size(4, PositiveIntValue); - } - if (hasNegativeIntValue) { - size += pb::CodedOutputStream.ComputeInt64Size(5, NegativeIntValue); - } - if (hasDoubleValue) { - size += pb::CodedOutputStream.ComputeDoubleSize(6, DoubleValue); - } - if (hasStringValue) { - size += pb::CodedOutputStream.ComputeBytesSize(7, StringValue); - } - if (hasAggregateValue) { - size += pb::CodedOutputStream.ComputeStringSize(8, AggregateValue); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + foreach (global::Google.ProtocolBuffers.DescriptorProtos.UninterpretedOption.Types.NamePart element in NameList) { + size += pb::CodedOutputStream.ComputeMessageSize(2, element); + } + if (hasIdentifierValue) { + size += pb::CodedOutputStream.ComputeStringSize(3, IdentifierValue); + } + if (hasPositiveIntValue) { + size += pb::CodedOutputStream.ComputeUInt64Size(4, PositiveIntValue); + } + if (hasNegativeIntValue) { + size += pb::CodedOutputStream.ComputeInt64Size(5, NegativeIntValue); + } + if (hasDoubleValue) { + size += pb::CodedOutputStream.ComputeDoubleSize(6, DoubleValue); + } + if (hasStringValue) { + size += pb::CodedOutputStream.ComputeBytesSize(7, StringValue); + } + if (hasAggregateValue) { + size += pb::CodedOutputStream.ComputeStringSize(8, AggregateValue); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static UninterpretedOption ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -8429,7 +8519,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _locationFieldNames; if (path_.Count > 0) { output.WritePackedInt32Array(1, field_names[0], pathMemoizedSerializedSize, path_); @@ -8445,36 +8535,41 @@ namespace Google.ProtocolBuffers.DescriptorProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - { - int dataSize = 0; - foreach (int element in PathList) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); - } - size += dataSize; - if (path_.Count != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - pathMemoizedSerializedSize = dataSize; + return CalcSerializedSize(); + } + } + + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + { + int dataSize = 0; + foreach (int element in PathList) { + dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); } - { - int dataSize = 0; - foreach (int element in SpanList) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); - } - size += dataSize; - if (span_.Count != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - spanMemoizedSerializedSize = dataSize; + size += dataSize; + if (path_.Count != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + pathMemoizedSerializedSize = dataSize; } + { + int dataSize = 0; + foreach (int element in SpanList) { + dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); + } + size += dataSize; + if (span_.Count != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + } + spanMemoizedSerializedSize = dataSize; + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; } - public static Location ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -8751,7 +8846,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _sourceCodeInfoFieldNames; if (location_.Count > 0) { output.WriteMessageArray(1, field_names[0], location_); @@ -8764,17 +8859,22 @@ namespace Google.ProtocolBuffers.DescriptorProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - foreach (global::Google.ProtocolBuffers.DescriptorProtos.SourceCodeInfo.Types.Location element in LocationList) { - size += pb::CodedOutputStream.ComputeMessageSize(1, element); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + foreach (global::Google.ProtocolBuffers.DescriptorProtos.SourceCodeInfo.Types.Location element in LocationList) { + size += pb::CodedOutputStream.ComputeMessageSize(1, element); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static SourceCodeInfo ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } diff --git a/src/ProtocolBuffersLite.Test/TestProtos/UnitTestExtrasLiteProtoFile.cs b/src/ProtocolBuffersLite.Test/TestProtos/UnitTestExtrasLiteProtoFile.cs index 3b0883cfbe..95be7031a0 100644 --- a/src/ProtocolBuffersLite.Test/TestProtos/UnitTestExtrasLiteProtoFile.cs +++ b/src/ProtocolBuffersLite.Test/TestProtos/UnitTestExtrasLiteProtoFile.cs @@ -277,7 +277,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testRequiredLiteFieldNames; if (hasD) { output.WriteInt32(1, field_names[0], D); @@ -292,19 +292,24 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasD) { - size += pb::CodedOutputStream.ComputeInt32Size(1, D); - } - if (hasEn) { - size += pb::CodedOutputStream.ComputeEnumSize(2, (int) En); - } - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasD) { + size += pb::CodedOutputStream.ComputeInt32Size(1, D); + } + if (hasEn) { + size += pb::CodedOutputStream.ComputeEnumSize(2, (int) En); + } + memoizedSerializedSize = size; + return size; + } #region Lite runtime methods public override int GetHashCode() { int hash = GetType().GetHashCode(); @@ -619,7 +624,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _phoneNumberFieldNames; if (hasNumber) { output.WriteString(1, field_names[0], Number); @@ -634,19 +639,24 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasNumber) { - size += pb::CodedOutputStream.ComputeStringSize(1, Number); - } - if (hasType) { - size += pb::CodedOutputStream.ComputeEnumSize(2, (int) Type); - } - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasNumber) { + size += pb::CodedOutputStream.ComputeStringSize(1, Number); + } + if (hasType) { + size += pb::CodedOutputStream.ComputeEnumSize(2, (int) Type); + } + memoizedSerializedSize = size; + return size; + } #region Lite runtime methods public override int GetHashCode() { int hash = GetType().GetHashCode(); @@ -968,7 +978,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _addressesFieldNames; if (hasAddress) { output.WriteString(1, field_names[0], Address); @@ -992,28 +1002,33 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasAddress) { - size += pb::CodedOutputStream.ComputeStringSize(1, Address); - } - if (hasAddress2) { - size += pb::CodedOutputStream.ComputeStringSize(2, Address2); - } - if (hasCity) { - size += pb::CodedOutputStream.ComputeStringSize(3, City); - } - if (hasState) { - size += pb::CodedOutputStream.ComputeStringSize(4, State); - } - if (hasZip) { - size += pb::CodedOutputStream.ComputeFixed32Size(5, Zip); - } - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasAddress) { + size += pb::CodedOutputStream.ComputeStringSize(1, Address); + } + if (hasAddress2) { + size += pb::CodedOutputStream.ComputeStringSize(2, Address2); + } + if (hasCity) { + size += pb::CodedOutputStream.ComputeStringSize(3, City); + } + if (hasState) { + size += pb::CodedOutputStream.ComputeStringSize(4, State); + } + if (hasZip) { + size += pb::CodedOutputStream.ComputeFixed32Size(5, Zip); + } + memoizedSerializedSize = size; + return size; + } #region Lite runtime methods public override int GetHashCode() { int hash = GetType().GetHashCode(); @@ -1428,7 +1443,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testInteropPersonLiteFieldNames; pb::ExtendableMessageLite.ExtensionWriter extensionWriter = CreateExtensionWriter(this); if (hasName) { @@ -1457,40 +1472,45 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasName) { - size += pb::CodedOutputStream.ComputeStringSize(1, Name); - } - if (hasId) { - size += pb::CodedOutputStream.ComputeInt32Size(2, Id); - } - if (hasEmail) { - size += pb::CodedOutputStream.ComputeStringSize(3, Email); - } - { - int dataSize = 0; - foreach (int element in CodesList) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); - } - size += dataSize; - if (codes_.Count != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - codesMemoizedSerializedSize = dataSize; - } - foreach (global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.PhoneNumber element in PhoneList) { - size += pb::CodedOutputStream.ComputeMessageSize(4, element); + return CalcSerializedSize(); + } + } + + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasName) { + size += pb::CodedOutputStream.ComputeStringSize(1, Name); + } + if (hasId) { + size += pb::CodedOutputStream.ComputeInt32Size(2, Id); + } + if (hasEmail) { + size += pb::CodedOutputStream.ComputeStringSize(3, Email); + } + { + int dataSize = 0; + foreach (int element in CodesList) { + dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); } - foreach (global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.Addresses element in AddressesList) { - size += pb::CodedOutputStream.ComputeGroupSize(5, element); + size += dataSize; + if (codes_.Count != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - size += ExtensionsSerializedSize; - memoizedSerializedSize = size; - return size; + codesMemoizedSerializedSize = dataSize; + } + foreach (global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.PhoneNumber element in PhoneList) { + size += pb::CodedOutputStream.ComputeMessageSize(4, element); + } + foreach (global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.Addresses element in AddressesList) { + size += pb::CodedOutputStream.ComputeGroupSize(5, element); } + size += ExtensionsSerializedSize; + memoizedSerializedSize = size; + return size; } - #region Lite runtime methods public override int GetHashCode() { int hash = GetType().GetHashCode(); @@ -1960,7 +1980,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testInteropEmployeeIdLiteFieldNames; if (hasNumber) { output.WriteString(1, field_names[0], Number); @@ -1972,16 +1992,21 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasNumber) { - size += pb::CodedOutputStream.ComputeStringSize(1, Number); - } - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasNumber) { + size += pb::CodedOutputStream.ComputeStringSize(1, Number); + } + memoizedSerializedSize = size; + return size; + } #region Lite runtime methods public override int GetHashCode() { int hash = GetType().GetHashCode(); @@ -2215,7 +2240,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testUnpackedExtensionsLiteFieldNames; pb::ExtendableMessageLite.ExtensionWriter extensionWriter = CreateExtensionWriter(this); extensionWriter.WriteUntil(536870912, output); @@ -2226,14 +2251,19 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - size += ExtensionsSerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += ExtensionsSerializedSize; + memoizedSerializedSize = size; + return size; + } #region Lite runtime methods public override int GetHashCode() { int hash = GetType().GetHashCode(); @@ -2615,7 +2645,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testUnpackedTypesLiteFieldNames; if (unpackedInt32_.Count > 0) { output.WriteInt32Array(90, field_names[6], unpackedInt32_); @@ -2666,113 +2696,118 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - { - int dataSize = 0; - foreach (int element in UnpackedInt32List) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); - } - size += dataSize; - size += 2 * unpackedInt32_.Count; - } - { - int dataSize = 0; - foreach (long element in UnpackedInt64List) { - dataSize += pb::CodedOutputStream.ComputeInt64SizeNoTag(element); - } - size += dataSize; - size += 2 * unpackedInt64_.Count; - } - { - int dataSize = 0; - foreach (uint element in UnpackedUint32List) { - dataSize += pb::CodedOutputStream.ComputeUInt32SizeNoTag(element); - } - size += dataSize; - size += 2 * unpackedUint32_.Count; - } - { - int dataSize = 0; - foreach (ulong element in UnpackedUint64List) { - dataSize += pb::CodedOutputStream.ComputeUInt64SizeNoTag(element); - } - size += dataSize; - size += 2 * unpackedUint64_.Count; - } - { - int dataSize = 0; - foreach (int element in UnpackedSint32List) { - dataSize += pb::CodedOutputStream.ComputeSInt32SizeNoTag(element); - } - size += dataSize; - size += 2 * unpackedSint32_.Count; - } - { - int dataSize = 0; - foreach (long element in UnpackedSint64List) { - dataSize += pb::CodedOutputStream.ComputeSInt64SizeNoTag(element); + return CalcSerializedSize(); + } + } + + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + { + int dataSize = 0; + foreach (int element in UnpackedInt32List) { + dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); + } + size += dataSize; + size += 2 * unpackedInt32_.Count; + } + { + int dataSize = 0; + foreach (long element in UnpackedInt64List) { + dataSize += pb::CodedOutputStream.ComputeInt64SizeNoTag(element); + } + size += dataSize; + size += 2 * unpackedInt64_.Count; + } + { + int dataSize = 0; + foreach (uint element in UnpackedUint32List) { + dataSize += pb::CodedOutputStream.ComputeUInt32SizeNoTag(element); + } + size += dataSize; + size += 2 * unpackedUint32_.Count; + } + { + int dataSize = 0; + foreach (ulong element in UnpackedUint64List) { + dataSize += pb::CodedOutputStream.ComputeUInt64SizeNoTag(element); + } + size += dataSize; + size += 2 * unpackedUint64_.Count; + } + { + int dataSize = 0; + foreach (int element in UnpackedSint32List) { + dataSize += pb::CodedOutputStream.ComputeSInt32SizeNoTag(element); + } + size += dataSize; + size += 2 * unpackedSint32_.Count; + } + { + int dataSize = 0; + foreach (long element in UnpackedSint64List) { + dataSize += pb::CodedOutputStream.ComputeSInt64SizeNoTag(element); + } + size += dataSize; + size += 2 * unpackedSint64_.Count; + } + { + int dataSize = 0; + dataSize = 4 * unpackedFixed32_.Count; + size += dataSize; + size += 2 * unpackedFixed32_.Count; + } + { + int dataSize = 0; + dataSize = 8 * unpackedFixed64_.Count; + size += dataSize; + size += 2 * unpackedFixed64_.Count; + } + { + int dataSize = 0; + dataSize = 4 * unpackedSfixed32_.Count; + size += dataSize; + size += 2 * unpackedSfixed32_.Count; + } + { + int dataSize = 0; + dataSize = 8 * unpackedSfixed64_.Count; + size += dataSize; + size += 2 * unpackedSfixed64_.Count; + } + { + int dataSize = 0; + dataSize = 4 * unpackedFloat_.Count; + size += dataSize; + size += 2 * unpackedFloat_.Count; + } + { + int dataSize = 0; + dataSize = 8 * unpackedDouble_.Count; + size += dataSize; + size += 2 * unpackedDouble_.Count; + } + { + int dataSize = 0; + dataSize = 1 * unpackedBool_.Count; + size += dataSize; + size += 2 * unpackedBool_.Count; + } + { + int dataSize = 0; + if (unpackedEnum_.Count > 0) { + foreach (global::Google.ProtocolBuffers.TestProtos.UnpackedTypesForeignEnumLite element in unpackedEnum_) { + dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); } size += dataSize; - size += 2 * unpackedSint64_.Count; - } - { - int dataSize = 0; - dataSize = 4 * unpackedFixed32_.Count; - size += dataSize; - size += 2 * unpackedFixed32_.Count; - } - { - int dataSize = 0; - dataSize = 8 * unpackedFixed64_.Count; - size += dataSize; - size += 2 * unpackedFixed64_.Count; - } - { - int dataSize = 0; - dataSize = 4 * unpackedSfixed32_.Count; - size += dataSize; - size += 2 * unpackedSfixed32_.Count; - } - { - int dataSize = 0; - dataSize = 8 * unpackedSfixed64_.Count; - size += dataSize; - size += 2 * unpackedSfixed64_.Count; - } - { - int dataSize = 0; - dataSize = 4 * unpackedFloat_.Count; - size += dataSize; - size += 2 * unpackedFloat_.Count; + size += 2 * unpackedEnum_.Count; } - { - int dataSize = 0; - dataSize = 8 * unpackedDouble_.Count; - size += dataSize; - size += 2 * unpackedDouble_.Count; - } - { - int dataSize = 0; - dataSize = 1 * unpackedBool_.Count; - size += dataSize; - size += 2 * unpackedBool_.Count; - } - { - int dataSize = 0; - if (unpackedEnum_.Count > 0) { - foreach (global::Google.ProtocolBuffers.TestProtos.UnpackedTypesForeignEnumLite element in unpackedEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 2 * unpackedEnum_.Count; - } - } - memoizedSerializedSize = size; - return size; } + memoizedSerializedSize = size; + return size; } - #region Lite runtime methods public override int GetHashCode() { int hash = GetType().GetHashCode(); @@ -3635,7 +3670,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _bucketOfBytesFieldNames; if (hasValue) { output.WriteBytes(1, field_names[0], Value); @@ -3647,16 +3682,21 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasValue) { - size += pb::CodedOutputStream.ComputeBytesSize(1, Value); - } - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasValue) { + size += pb::CodedOutputStream.ComputeBytesSize(1, Value); + } + memoizedSerializedSize = size; + return size; + } #region Lite runtime methods public override int GetHashCode() { int hash = GetType().GetHashCode(); @@ -3909,7 +3949,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _bucketOfBytesExFieldNames; if (hasValue) { output.WriteBytes(1, field_names[0], Value); @@ -3924,19 +3964,24 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasValue) { - size += pb::CodedOutputStream.ComputeBytesSize(1, Value); - } - if (hasValue2) { - size += pb::CodedOutputStream.ComputeBytesSize(255, Value2); - } - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasValue) { + size += pb::CodedOutputStream.ComputeBytesSize(1, Value); + } + if (hasValue2) { + size += pb::CodedOutputStream.ComputeBytesSize(255, Value2); + } + memoizedSerializedSize = size; + return size; + } #region Lite runtime methods public override int GetHashCode() { int hash = GetType().GetHashCode(); diff --git a/src/ProtocolBuffersLite.Test/TestProtos/UnitTestImportLiteProtoFile.cs b/src/ProtocolBuffersLite.Test/TestProtos/UnitTestImportLiteProtoFile.cs index 2f9edc71fd..f190f1f650 100644 --- a/src/ProtocolBuffersLite.Test/TestProtos/UnitTestImportLiteProtoFile.cs +++ b/src/ProtocolBuffersLite.Test/TestProtos/UnitTestImportLiteProtoFile.cs @@ -70,7 +70,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _importMessageLiteFieldNames; if (hasD) { output.WriteInt32(1, field_names[0], D); @@ -82,16 +82,21 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasD) { - size += pb::CodedOutputStream.ComputeInt32Size(1, D); - } - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasD) { + size += pb::CodedOutputStream.ComputeInt32Size(1, D); + } + memoizedSerializedSize = size; + return size; + } #region Lite runtime methods public override int GetHashCode() { int hash = GetType().GetHashCode(); diff --git a/src/ProtocolBuffersLite.Test/TestProtos/UnitTestImportProtoFile.cs b/src/ProtocolBuffersLite.Test/TestProtos/UnitTestImportProtoFile.cs index 57b9e65c8c..61aca3d911 100644 --- a/src/ProtocolBuffersLite.Test/TestProtos/UnitTestImportProtoFile.cs +++ b/src/ProtocolBuffersLite.Test/TestProtos/UnitTestImportProtoFile.cs @@ -107,7 +107,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _importMessageFieldNames; if (hasD) { output.WriteInt32(1, field_names[0], D); @@ -120,17 +120,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasD) { - size += pb::CodedOutputStream.ComputeInt32Size(1, D); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasD) { + size += pb::CodedOutputStream.ComputeInt32Size(1, D); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static ImportMessage ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } diff --git a/src/ProtocolBuffersLite.Test/TestProtos/UnitTestLiteImportNonLiteProtoFile.cs b/src/ProtocolBuffersLite.Test/TestProtos/UnitTestLiteImportNonLiteProtoFile.cs index bf96d2c39e..cee7d88acc 100644 --- a/src/ProtocolBuffersLite.Test/TestProtos/UnitTestLiteImportNonLiteProtoFile.cs +++ b/src/ProtocolBuffersLite.Test/TestProtos/UnitTestLiteImportNonLiteProtoFile.cs @@ -61,7 +61,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testLiteImportsNonliteFieldNames; if (hasMessage) { output.WriteMessage(1, field_names[0], Message); @@ -73,16 +73,21 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(1, Message); - } - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasMessage) { + size += pb::CodedOutputStream.ComputeMessageSize(1, Message); + } + memoizedSerializedSize = size; + return size; + } #region Lite runtime methods public override int GetHashCode() { int hash = GetType().GetHashCode(); diff --git a/src/ProtocolBuffersLite.Test/TestProtos/UnitTestLiteProtoFile.cs b/src/ProtocolBuffersLite.Test/TestProtos/UnitTestLiteProtoFile.cs index 4264ec9b7d..60346d4c23 100644 --- a/src/ProtocolBuffersLite.Test/TestProtos/UnitTestLiteProtoFile.cs +++ b/src/ProtocolBuffersLite.Test/TestProtos/UnitTestLiteProtoFile.cs @@ -1110,7 +1110,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _nestedMessageFieldNames; if (hasBb) { output.WriteInt32(1, field_names[0], Bb); @@ -1122,16 +1122,21 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasBb) { - size += pb::CodedOutputStream.ComputeInt32Size(1, Bb); - } - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasBb) { + size += pb::CodedOutputStream.ComputeInt32Size(1, Bb); + } + memoizedSerializedSize = size; + return size; + } #region Lite runtime methods public override int GetHashCode() { int hash = GetType().GetHashCode(); @@ -1371,7 +1376,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _optionalGroupFieldNames; if (hasA) { output.WriteInt32(17, field_names[0], A); @@ -1383,16 +1388,21 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(17, A); - } - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasA) { + size += pb::CodedOutputStream.ComputeInt32Size(17, A); + } + memoizedSerializedSize = size; + return size; + } #region Lite runtime methods public override int GetHashCode() { int hash = GetType().GetHashCode(); @@ -1632,7 +1642,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _repeatedGroupFieldNames; if (hasA) { output.WriteInt32(47, field_names[0], A); @@ -1644,16 +1654,21 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(47, A); - } - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasA) { + size += pb::CodedOutputStream.ComputeInt32Size(47, A); + } + memoizedSerializedSize = size; + return size; + } #region Lite runtime methods public override int GetHashCode() { int hash = GetType().GetHashCode(); @@ -2612,7 +2627,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testAllTypesLiteFieldNames; if (hasOptionalInt32) { output.WriteInt32(1, field_names[31], OptionalInt32); @@ -2825,309 +2840,314 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasOptionalInt32) { - size += pb::CodedOutputStream.ComputeInt32Size(1, OptionalInt32); - } - if (hasOptionalInt64) { - size += pb::CodedOutputStream.ComputeInt64Size(2, OptionalInt64); - } - if (hasOptionalUint32) { - size += pb::CodedOutputStream.ComputeUInt32Size(3, OptionalUint32); - } - if (hasOptionalUint64) { - size += pb::CodedOutputStream.ComputeUInt64Size(4, OptionalUint64); - } - if (hasOptionalSint32) { - size += pb::CodedOutputStream.ComputeSInt32Size(5, OptionalSint32); - } - if (hasOptionalSint64) { - size += pb::CodedOutputStream.ComputeSInt64Size(6, OptionalSint64); - } - if (hasOptionalFixed32) { - size += pb::CodedOutputStream.ComputeFixed32Size(7, OptionalFixed32); - } - if (hasOptionalFixed64) { - size += pb::CodedOutputStream.ComputeFixed64Size(8, OptionalFixed64); - } - if (hasOptionalSfixed32) { - size += pb::CodedOutputStream.ComputeSFixed32Size(9, OptionalSfixed32); - } - if (hasOptionalSfixed64) { - size += pb::CodedOutputStream.ComputeSFixed64Size(10, OptionalSfixed64); - } - if (hasOptionalFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(11, OptionalFloat); - } - if (hasOptionalDouble) { - size += pb::CodedOutputStream.ComputeDoubleSize(12, OptionalDouble); - } - if (hasOptionalBool) { - size += pb::CodedOutputStream.ComputeBoolSize(13, OptionalBool); - } - if (hasOptionalString) { - size += pb::CodedOutputStream.ComputeStringSize(14, OptionalString); - } - if (hasOptionalBytes) { - size += pb::CodedOutputStream.ComputeBytesSize(15, OptionalBytes); - } - if (hasOptionalGroup) { - size += pb::CodedOutputStream.ComputeGroupSize(16, OptionalGroup); - } - if (hasOptionalNestedMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(18, OptionalNestedMessage); - } - if (hasOptionalForeignMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(19, OptionalForeignMessage); - } - if (hasOptionalImportMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(20, OptionalImportMessage); - } - if (hasOptionalNestedEnum) { - size += pb::CodedOutputStream.ComputeEnumSize(21, (int) OptionalNestedEnum); - } - if (hasOptionalForeignEnum) { - size += pb::CodedOutputStream.ComputeEnumSize(22, (int) OptionalForeignEnum); - } - if (hasOptionalImportEnum) { - size += pb::CodedOutputStream.ComputeEnumSize(23, (int) OptionalImportEnum); - } - if (hasOptionalStringPiece) { - size += pb::CodedOutputStream.ComputeStringSize(24, OptionalStringPiece); - } - if (hasOptionalCord) { - size += pb::CodedOutputStream.ComputeStringSize(25, OptionalCord); - } - { - int dataSize = 0; - foreach (int element in RepeatedInt32List) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedInt32_.Count; - } - { - int dataSize = 0; - foreach (long element in RepeatedInt64List) { - dataSize += pb::CodedOutputStream.ComputeInt64SizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedInt64_.Count; - } - { - int dataSize = 0; - foreach (uint element in RepeatedUint32List) { - dataSize += pb::CodedOutputStream.ComputeUInt32SizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedUint32_.Count; - } - { - int dataSize = 0; - foreach (ulong element in RepeatedUint64List) { - dataSize += pb::CodedOutputStream.ComputeUInt64SizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedUint64_.Count; - } - { - int dataSize = 0; - foreach (int element in RepeatedSint32List) { - dataSize += pb::CodedOutputStream.ComputeSInt32SizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedSint32_.Count; - } - { - int dataSize = 0; - foreach (long element in RepeatedSint64List) { - dataSize += pb::CodedOutputStream.ComputeSInt64SizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedSint64_.Count; - } - { - int dataSize = 0; - dataSize = 4 * repeatedFixed32_.Count; - size += dataSize; - size += 2 * repeatedFixed32_.Count; - } - { - int dataSize = 0; - dataSize = 8 * repeatedFixed64_.Count; - size += dataSize; - size += 2 * repeatedFixed64_.Count; - } - { - int dataSize = 0; - dataSize = 4 * repeatedSfixed32_.Count; - size += dataSize; - size += 2 * repeatedSfixed32_.Count; - } - { - int dataSize = 0; - dataSize = 8 * repeatedSfixed64_.Count; - size += dataSize; - size += 2 * repeatedSfixed64_.Count; - } - { - int dataSize = 0; - dataSize = 4 * repeatedFloat_.Count; - size += dataSize; - size += 2 * repeatedFloat_.Count; - } - { - int dataSize = 0; - dataSize = 8 * repeatedDouble_.Count; - size += dataSize; - size += 2 * repeatedDouble_.Count; - } - { - int dataSize = 0; - dataSize = 1 * repeatedBool_.Count; - size += dataSize; - size += 2 * repeatedBool_.Count; - } - { - int dataSize = 0; - foreach (string element in RepeatedStringList) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedString_.Count; - } - { - int dataSize = 0; - foreach (pb::ByteString element in RepeatedBytesList) { - dataSize += pb::CodedOutputStream.ComputeBytesSizeNoTag(element); + return CalcSerializedSize(); + } + } + + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasOptionalInt32) { + size += pb::CodedOutputStream.ComputeInt32Size(1, OptionalInt32); + } + if (hasOptionalInt64) { + size += pb::CodedOutputStream.ComputeInt64Size(2, OptionalInt64); + } + if (hasOptionalUint32) { + size += pb::CodedOutputStream.ComputeUInt32Size(3, OptionalUint32); + } + if (hasOptionalUint64) { + size += pb::CodedOutputStream.ComputeUInt64Size(4, OptionalUint64); + } + if (hasOptionalSint32) { + size += pb::CodedOutputStream.ComputeSInt32Size(5, OptionalSint32); + } + if (hasOptionalSint64) { + size += pb::CodedOutputStream.ComputeSInt64Size(6, OptionalSint64); + } + if (hasOptionalFixed32) { + size += pb::CodedOutputStream.ComputeFixed32Size(7, OptionalFixed32); + } + if (hasOptionalFixed64) { + size += pb::CodedOutputStream.ComputeFixed64Size(8, OptionalFixed64); + } + if (hasOptionalSfixed32) { + size += pb::CodedOutputStream.ComputeSFixed32Size(9, OptionalSfixed32); + } + if (hasOptionalSfixed64) { + size += pb::CodedOutputStream.ComputeSFixed64Size(10, OptionalSfixed64); + } + if (hasOptionalFloat) { + size += pb::CodedOutputStream.ComputeFloatSize(11, OptionalFloat); + } + if (hasOptionalDouble) { + size += pb::CodedOutputStream.ComputeDoubleSize(12, OptionalDouble); + } + if (hasOptionalBool) { + size += pb::CodedOutputStream.ComputeBoolSize(13, OptionalBool); + } + if (hasOptionalString) { + size += pb::CodedOutputStream.ComputeStringSize(14, OptionalString); + } + if (hasOptionalBytes) { + size += pb::CodedOutputStream.ComputeBytesSize(15, OptionalBytes); + } + if (hasOptionalGroup) { + size += pb::CodedOutputStream.ComputeGroupSize(16, OptionalGroup); + } + if (hasOptionalNestedMessage) { + size += pb::CodedOutputStream.ComputeMessageSize(18, OptionalNestedMessage); + } + if (hasOptionalForeignMessage) { + size += pb::CodedOutputStream.ComputeMessageSize(19, OptionalForeignMessage); + } + if (hasOptionalImportMessage) { + size += pb::CodedOutputStream.ComputeMessageSize(20, OptionalImportMessage); + } + if (hasOptionalNestedEnum) { + size += pb::CodedOutputStream.ComputeEnumSize(21, (int) OptionalNestedEnum); + } + if (hasOptionalForeignEnum) { + size += pb::CodedOutputStream.ComputeEnumSize(22, (int) OptionalForeignEnum); + } + if (hasOptionalImportEnum) { + size += pb::CodedOutputStream.ComputeEnumSize(23, (int) OptionalImportEnum); + } + if (hasOptionalStringPiece) { + size += pb::CodedOutputStream.ComputeStringSize(24, OptionalStringPiece); + } + if (hasOptionalCord) { + size += pb::CodedOutputStream.ComputeStringSize(25, OptionalCord); + } + { + int dataSize = 0; + foreach (int element in RepeatedInt32List) { + dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); + } + size += dataSize; + size += 2 * repeatedInt32_.Count; + } + { + int dataSize = 0; + foreach (long element in RepeatedInt64List) { + dataSize += pb::CodedOutputStream.ComputeInt64SizeNoTag(element); + } + size += dataSize; + size += 2 * repeatedInt64_.Count; + } + { + int dataSize = 0; + foreach (uint element in RepeatedUint32List) { + dataSize += pb::CodedOutputStream.ComputeUInt32SizeNoTag(element); + } + size += dataSize; + size += 2 * repeatedUint32_.Count; + } + { + int dataSize = 0; + foreach (ulong element in RepeatedUint64List) { + dataSize += pb::CodedOutputStream.ComputeUInt64SizeNoTag(element); + } + size += dataSize; + size += 2 * repeatedUint64_.Count; + } + { + int dataSize = 0; + foreach (int element in RepeatedSint32List) { + dataSize += pb::CodedOutputStream.ComputeSInt32SizeNoTag(element); + } + size += dataSize; + size += 2 * repeatedSint32_.Count; + } + { + int dataSize = 0; + foreach (long element in RepeatedSint64List) { + dataSize += pb::CodedOutputStream.ComputeSInt64SizeNoTag(element); + } + size += dataSize; + size += 2 * repeatedSint64_.Count; + } + { + int dataSize = 0; + dataSize = 4 * repeatedFixed32_.Count; + size += dataSize; + size += 2 * repeatedFixed32_.Count; + } + { + int dataSize = 0; + dataSize = 8 * repeatedFixed64_.Count; + size += dataSize; + size += 2 * repeatedFixed64_.Count; + } + { + int dataSize = 0; + dataSize = 4 * repeatedSfixed32_.Count; + size += dataSize; + size += 2 * repeatedSfixed32_.Count; + } + { + int dataSize = 0; + dataSize = 8 * repeatedSfixed64_.Count; + size += dataSize; + size += 2 * repeatedSfixed64_.Count; + } + { + int dataSize = 0; + dataSize = 4 * repeatedFloat_.Count; + size += dataSize; + size += 2 * repeatedFloat_.Count; + } + { + int dataSize = 0; + dataSize = 8 * repeatedDouble_.Count; + size += dataSize; + size += 2 * repeatedDouble_.Count; + } + { + int dataSize = 0; + dataSize = 1 * repeatedBool_.Count; + size += dataSize; + size += 2 * repeatedBool_.Count; + } + { + int dataSize = 0; + foreach (string element in RepeatedStringList) { + dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); + } + size += dataSize; + size += 2 * repeatedString_.Count; + } + { + int dataSize = 0; + foreach (pb::ByteString element in RepeatedBytesList) { + dataSize += pb::CodedOutputStream.ComputeBytesSizeNoTag(element); + } + size += dataSize; + size += 2 * repeatedBytes_.Count; + } + foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.RepeatedGroup element in RepeatedGroupList) { + size += pb::CodedOutputStream.ComputeGroupSize(46, element); + } + foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage element in RepeatedNestedMessageList) { + size += pb::CodedOutputStream.ComputeMessageSize(48, element); + } + foreach (global::Google.ProtocolBuffers.TestProtos.ForeignMessageLite element in RepeatedForeignMessageList) { + size += pb::CodedOutputStream.ComputeMessageSize(49, element); + } + foreach (global::Google.ProtocolBuffers.TestProtos.ImportMessageLite element in RepeatedImportMessageList) { + size += pb::CodedOutputStream.ComputeMessageSize(50, element); + } + { + int dataSize = 0; + if (repeatedNestedEnum_.Count > 0) { + foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedEnum element in repeatedNestedEnum_) { + dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); } size += dataSize; - size += 2 * repeatedBytes_.Count; - } - foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.RepeatedGroup element in RepeatedGroupList) { - size += pb::CodedOutputStream.ComputeGroupSize(46, element); - } - foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage element in RepeatedNestedMessageList) { - size += pb::CodedOutputStream.ComputeMessageSize(48, element); - } - foreach (global::Google.ProtocolBuffers.TestProtos.ForeignMessageLite element in RepeatedForeignMessageList) { - size += pb::CodedOutputStream.ComputeMessageSize(49, element); - } - foreach (global::Google.ProtocolBuffers.TestProtos.ImportMessageLite element in RepeatedImportMessageList) { - size += pb::CodedOutputStream.ComputeMessageSize(50, element); - } - { - int dataSize = 0; - if (repeatedNestedEnum_.Count > 0) { - foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedEnum element in repeatedNestedEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 2 * repeatedNestedEnum_.Count; - } - } - { - int dataSize = 0; - if (repeatedForeignEnum_.Count > 0) { - foreach (global::Google.ProtocolBuffers.TestProtos.ForeignEnumLite element in repeatedForeignEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 2 * repeatedForeignEnum_.Count; - } - } - { - int dataSize = 0; - if (repeatedImportEnum_.Count > 0) { - foreach (global::Google.ProtocolBuffers.TestProtos.ImportEnumLite element in repeatedImportEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 2 * repeatedImportEnum_.Count; - } + size += 2 * repeatedNestedEnum_.Count; } - { - int dataSize = 0; - foreach (string element in RepeatedStringPieceList) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); + } + { + int dataSize = 0; + if (repeatedForeignEnum_.Count > 0) { + foreach (global::Google.ProtocolBuffers.TestProtos.ForeignEnumLite element in repeatedForeignEnum_) { + dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); } size += dataSize; - size += 2 * repeatedStringPiece_.Count; + size += 2 * repeatedForeignEnum_.Count; } - { - int dataSize = 0; - foreach (string element in RepeatedCordList) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); + } + { + int dataSize = 0; + if (repeatedImportEnum_.Count > 0) { + foreach (global::Google.ProtocolBuffers.TestProtos.ImportEnumLite element in repeatedImportEnum_) { + dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); } size += dataSize; - size += 2 * repeatedCord_.Count; - } - if (hasDefaultInt32) { - size += pb::CodedOutputStream.ComputeInt32Size(61, DefaultInt32); - } - if (hasDefaultInt64) { - size += pb::CodedOutputStream.ComputeInt64Size(62, DefaultInt64); + size += 2 * repeatedImportEnum_.Count; } - if (hasDefaultUint32) { - size += pb::CodedOutputStream.ComputeUInt32Size(63, DefaultUint32); - } - if (hasDefaultUint64) { - size += pb::CodedOutputStream.ComputeUInt64Size(64, DefaultUint64); - } - if (hasDefaultSint32) { - size += pb::CodedOutputStream.ComputeSInt32Size(65, DefaultSint32); - } - if (hasDefaultSint64) { - size += pb::CodedOutputStream.ComputeSInt64Size(66, DefaultSint64); - } - if (hasDefaultFixed32) { - size += pb::CodedOutputStream.ComputeFixed32Size(67, DefaultFixed32); - } - if (hasDefaultFixed64) { - size += pb::CodedOutputStream.ComputeFixed64Size(68, DefaultFixed64); - } - if (hasDefaultSfixed32) { - size += pb::CodedOutputStream.ComputeSFixed32Size(69, DefaultSfixed32); - } - if (hasDefaultSfixed64) { - size += pb::CodedOutputStream.ComputeSFixed64Size(70, DefaultSfixed64); - } - if (hasDefaultFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(71, DefaultFloat); - } - if (hasDefaultDouble) { - size += pb::CodedOutputStream.ComputeDoubleSize(72, DefaultDouble); - } - if (hasDefaultBool) { - size += pb::CodedOutputStream.ComputeBoolSize(73, DefaultBool); - } - if (hasDefaultString) { - size += pb::CodedOutputStream.ComputeStringSize(74, DefaultString); - } - if (hasDefaultBytes) { - size += pb::CodedOutputStream.ComputeBytesSize(75, DefaultBytes); - } - if (hasDefaultNestedEnum) { - size += pb::CodedOutputStream.ComputeEnumSize(81, (int) DefaultNestedEnum); - } - if (hasDefaultForeignEnum) { - size += pb::CodedOutputStream.ComputeEnumSize(82, (int) DefaultForeignEnum); - } - if (hasDefaultImportEnum) { - size += pb::CodedOutputStream.ComputeEnumSize(83, (int) DefaultImportEnum); - } - if (hasDefaultStringPiece) { - size += pb::CodedOutputStream.ComputeStringSize(84, DefaultStringPiece); + } + { + int dataSize = 0; + foreach (string element in RepeatedStringPieceList) { + dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); } - if (hasDefaultCord) { - size += pb::CodedOutputStream.ComputeStringSize(85, DefaultCord); + size += dataSize; + size += 2 * repeatedStringPiece_.Count; + } + { + int dataSize = 0; + foreach (string element in RepeatedCordList) { + dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); } - memoizedSerializedSize = size; - return size; + size += dataSize; + size += 2 * repeatedCord_.Count; } + if (hasDefaultInt32) { + size += pb::CodedOutputStream.ComputeInt32Size(61, DefaultInt32); + } + if (hasDefaultInt64) { + size += pb::CodedOutputStream.ComputeInt64Size(62, DefaultInt64); + } + if (hasDefaultUint32) { + size += pb::CodedOutputStream.ComputeUInt32Size(63, DefaultUint32); + } + if (hasDefaultUint64) { + size += pb::CodedOutputStream.ComputeUInt64Size(64, DefaultUint64); + } + if (hasDefaultSint32) { + size += pb::CodedOutputStream.ComputeSInt32Size(65, DefaultSint32); + } + if (hasDefaultSint64) { + size += pb::CodedOutputStream.ComputeSInt64Size(66, DefaultSint64); + } + if (hasDefaultFixed32) { + size += pb::CodedOutputStream.ComputeFixed32Size(67, DefaultFixed32); + } + if (hasDefaultFixed64) { + size += pb::CodedOutputStream.ComputeFixed64Size(68, DefaultFixed64); + } + if (hasDefaultSfixed32) { + size += pb::CodedOutputStream.ComputeSFixed32Size(69, DefaultSfixed32); + } + if (hasDefaultSfixed64) { + size += pb::CodedOutputStream.ComputeSFixed64Size(70, DefaultSfixed64); + } + if (hasDefaultFloat) { + size += pb::CodedOutputStream.ComputeFloatSize(71, DefaultFloat); + } + if (hasDefaultDouble) { + size += pb::CodedOutputStream.ComputeDoubleSize(72, DefaultDouble); + } + if (hasDefaultBool) { + size += pb::CodedOutputStream.ComputeBoolSize(73, DefaultBool); + } + if (hasDefaultString) { + size += pb::CodedOutputStream.ComputeStringSize(74, DefaultString); + } + if (hasDefaultBytes) { + size += pb::CodedOutputStream.ComputeBytesSize(75, DefaultBytes); + } + if (hasDefaultNestedEnum) { + size += pb::CodedOutputStream.ComputeEnumSize(81, (int) DefaultNestedEnum); + } + if (hasDefaultForeignEnum) { + size += pb::CodedOutputStream.ComputeEnumSize(82, (int) DefaultForeignEnum); + } + if (hasDefaultImportEnum) { + size += pb::CodedOutputStream.ComputeEnumSize(83, (int) DefaultImportEnum); + } + if (hasDefaultStringPiece) { + size += pb::CodedOutputStream.ComputeStringSize(84, DefaultStringPiece); + } + if (hasDefaultCord) { + size += pb::CodedOutputStream.ComputeStringSize(85, DefaultCord); + } + memoizedSerializedSize = size; + return size; } - #region Lite runtime methods public override int GetHashCode() { int hash = GetType().GetHashCode(); @@ -5964,7 +5984,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _foreignMessageLiteFieldNames; if (hasC) { output.WriteInt32(1, field_names[0], C); @@ -5976,16 +5996,21 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasC) { - size += pb::CodedOutputStream.ComputeInt32Size(1, C); - } - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasC) { + size += pb::CodedOutputStream.ComputeInt32Size(1, C); + } + memoizedSerializedSize = size; + return size; + } #region Lite runtime methods public override int GetHashCode() { int hash = GetType().GetHashCode(); @@ -6405,7 +6430,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testPackedTypesLiteFieldNames; if (packedInt32_.Count > 0) { output.WritePackedInt32Array(90, field_names[6], packedInt32MemoizedSerializedSize, packedInt32_); @@ -6456,154 +6481,159 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - { - int dataSize = 0; - foreach (int element in PackedInt32List) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); - } - size += dataSize; - if (packedInt32_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedInt32MemoizedSerializedSize = dataSize; + return CalcSerializedSize(); + } + } + + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + { + int dataSize = 0; + foreach (int element in PackedInt32List) { + dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); } - { - int dataSize = 0; - foreach (long element in PackedInt64List) { - dataSize += pb::CodedOutputStream.ComputeInt64SizeNoTag(element); - } - size += dataSize; - if (packedInt64_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedInt64MemoizedSerializedSize = dataSize; + size += dataSize; + if (packedInt32_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { - int dataSize = 0; - foreach (uint element in PackedUint32List) { - dataSize += pb::CodedOutputStream.ComputeUInt32SizeNoTag(element); - } - size += dataSize; - if (packedUint32_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedUint32MemoizedSerializedSize = dataSize; + packedInt32MemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + foreach (long element in PackedInt64List) { + dataSize += pb::CodedOutputStream.ComputeInt64SizeNoTag(element); } - { - int dataSize = 0; - foreach (ulong element in PackedUint64List) { - dataSize += pb::CodedOutputStream.ComputeUInt64SizeNoTag(element); - } - size += dataSize; - if (packedUint64_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedUint64MemoizedSerializedSize = dataSize; + size += dataSize; + if (packedInt64_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { - int dataSize = 0; - foreach (int element in PackedSint32List) { - dataSize += pb::CodedOutputStream.ComputeSInt32SizeNoTag(element); - } - size += dataSize; - if (packedSint32_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedSint32MemoizedSerializedSize = dataSize; + packedInt64MemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + foreach (uint element in PackedUint32List) { + dataSize += pb::CodedOutputStream.ComputeUInt32SizeNoTag(element); } - { - int dataSize = 0; - foreach (long element in PackedSint64List) { - dataSize += pb::CodedOutputStream.ComputeSInt64SizeNoTag(element); - } - size += dataSize; - if (packedSint64_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedSint64MemoizedSerializedSize = dataSize; + size += dataSize; + if (packedUint32_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { - int dataSize = 0; - dataSize = 4 * packedFixed32_.Count; - size += dataSize; - if (packedFixed32_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedFixed32MemoizedSerializedSize = dataSize; + packedUint32MemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + foreach (ulong element in PackedUint64List) { + dataSize += pb::CodedOutputStream.ComputeUInt64SizeNoTag(element); } - { - int dataSize = 0; - dataSize = 8 * packedFixed64_.Count; - size += dataSize; - if (packedFixed64_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedFixed64MemoizedSerializedSize = dataSize; + size += dataSize; + if (packedUint64_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { - int dataSize = 0; - dataSize = 4 * packedSfixed32_.Count; - size += dataSize; - if (packedSfixed32_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedSfixed32MemoizedSerializedSize = dataSize; + packedUint64MemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + foreach (int element in PackedSint32List) { + dataSize += pb::CodedOutputStream.ComputeSInt32SizeNoTag(element); } - { - int dataSize = 0; - dataSize = 8 * packedSfixed64_.Count; - size += dataSize; - if (packedSfixed64_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedSfixed64MemoizedSerializedSize = dataSize; + size += dataSize; + if (packedSint32_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { - int dataSize = 0; - dataSize = 4 * packedFloat_.Count; - size += dataSize; - if (packedFloat_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedFloatMemoizedSerializedSize = dataSize; + packedSint32MemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + foreach (long element in PackedSint64List) { + dataSize += pb::CodedOutputStream.ComputeSInt64SizeNoTag(element); } - { - int dataSize = 0; - dataSize = 8 * packedDouble_.Count; - size += dataSize; - if (packedDouble_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedDoubleMemoizedSerializedSize = dataSize; + size += dataSize; + if (packedSint64_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { - int dataSize = 0; - dataSize = 1 * packedBool_.Count; - size += dataSize; - if (packedBool_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedBoolMemoizedSerializedSize = dataSize; + packedSint64MemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + dataSize = 4 * packedFixed32_.Count; + size += dataSize; + if (packedFixed32_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { - int dataSize = 0; - if (packedEnum_.Count > 0) { - foreach (global::Google.ProtocolBuffers.TestProtos.ForeignEnumLite element in packedEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 2; - size += pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize); + packedFixed32MemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + dataSize = 8 * packedFixed64_.Count; + size += dataSize; + if (packedFixed64_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + } + packedFixed64MemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + dataSize = 4 * packedSfixed32_.Count; + size += dataSize; + if (packedSfixed32_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + } + packedSfixed32MemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + dataSize = 8 * packedSfixed64_.Count; + size += dataSize; + if (packedSfixed64_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + } + packedSfixed64MemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + dataSize = 4 * packedFloat_.Count; + size += dataSize; + if (packedFloat_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + } + packedFloatMemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + dataSize = 8 * packedDouble_.Count; + size += dataSize; + if (packedDouble_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + } + packedDoubleMemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + dataSize = 1 * packedBool_.Count; + size += dataSize; + if (packedBool_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + } + packedBoolMemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + if (packedEnum_.Count > 0) { + foreach (global::Google.ProtocolBuffers.TestProtos.ForeignEnumLite element in packedEnum_) { + dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); } - packedEnumMemoizedSerializedSize = dataSize; + size += dataSize; + size += 2; + size += pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize); } - memoizedSerializedSize = size; - return size; + packedEnumMemoizedSerializedSize = dataSize; } + memoizedSerializedSize = size; + return size; } - #region Lite runtime methods public override int GetHashCode() { int hash = GetType().GetHashCode(); @@ -7455,7 +7485,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testAllExtensionsLiteFieldNames; pb::ExtendableMessageLite.ExtensionWriter extensionWriter = CreateExtensionWriter(this); extensionWriter.WriteUntil(536870912, output); @@ -7466,14 +7496,19 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - size += ExtensionsSerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += ExtensionsSerializedSize; + memoizedSerializedSize = size; + return size; + } #region Lite runtime methods public override int GetHashCode() { int hash = GetType().GetHashCode(); @@ -7687,7 +7722,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _optionalGroupExtensionLiteFieldNames; if (hasA) { output.WriteInt32(17, field_names[0], A); @@ -7699,16 +7734,21 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(17, A); - } - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasA) { + size += pb::CodedOutputStream.ComputeInt32Size(17, A); + } + memoizedSerializedSize = size; + return size; + } #region Lite runtime methods public override int GetHashCode() { int hash = GetType().GetHashCode(); @@ -7948,7 +7988,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _repeatedGroupExtensionLiteFieldNames; if (hasA) { output.WriteInt32(47, field_names[0], A); @@ -7960,16 +8000,21 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(47, A); - } - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasA) { + size += pb::CodedOutputStream.ComputeInt32Size(47, A); + } + memoizedSerializedSize = size; + return size; + } #region Lite runtime methods public override int GetHashCode() { int hash = GetType().GetHashCode(); @@ -8200,7 +8245,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testPackedExtensionsLiteFieldNames; pb::ExtendableMessageLite.ExtensionWriter extensionWriter = CreateExtensionWriter(this); extensionWriter.WriteUntil(536870912, output); @@ -8211,14 +8256,19 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - size += ExtensionsSerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += ExtensionsSerializedSize; + memoizedSerializedSize = size; + return size; + } #region Lite runtime methods public override int GetHashCode() { int hash = GetType().GetHashCode(); @@ -8424,7 +8474,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testNestedExtensionLiteFieldNames; } @@ -8433,13 +8483,18 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + memoizedSerializedSize = size; + return size; + } #region Lite runtime methods public override int GetHashCode() { int hash = GetType().GetHashCode(); @@ -8651,7 +8706,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testDeprecatedLiteFieldNames; if (hasDeprecatedField) { output.WriteInt32(1, field_names[0], DeprecatedField); @@ -8663,16 +8718,21 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasDeprecatedField) { - size += pb::CodedOutputStream.ComputeInt32Size(1, DeprecatedField); - } - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasDeprecatedField) { + size += pb::CodedOutputStream.ComputeInt32Size(1, DeprecatedField); + } + memoizedSerializedSize = size; + return size; + } #region Lite runtime methods public override int GetHashCode() { int hash = GetType().GetHashCode(); diff --git a/src/ProtocolBuffersLite.Test/TestProtos/UnitTestProtoFile.cs b/src/ProtocolBuffersLite.Test/TestProtos/UnitTestProtoFile.cs index 9a9f00bfdf..53ae17e699 100644 --- a/src/ProtocolBuffersLite.Test/TestProtos/UnitTestProtoFile.cs +++ b/src/ProtocolBuffersLite.Test/TestProtos/UnitTestProtoFile.cs @@ -1106,7 +1106,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _nestedMessageFieldNames; if (hasBb) { output.WriteInt32(1, field_names[0], Bb); @@ -1119,17 +1119,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasBb) { - size += pb::CodedOutputStream.ComputeInt32Size(1, Bb); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasBb) { + size += pb::CodedOutputStream.ComputeInt32Size(1, Bb); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static NestedMessage ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -1376,7 +1381,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _optionalGroupFieldNames; if (hasA) { output.WriteInt32(17, field_names[0], A); @@ -1389,17 +1394,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(17, A); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasA) { + size += pb::CodedOutputStream.ComputeInt32Size(17, A); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static OptionalGroup ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -1646,7 +1656,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _repeatedGroupFieldNames; if (hasA) { output.WriteInt32(47, field_names[0], A); @@ -1659,17 +1669,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(47, A); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasA) { + size += pb::CodedOutputStream.ComputeInt32Size(47, A); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static RepeatedGroup ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -2627,7 +2642,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testAllTypesFieldNames; if (hasOptionalInt32) { output.WriteInt32(1, field_names[31], OptionalInt32); @@ -2841,310 +2856,315 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasOptionalInt32) { - size += pb::CodedOutputStream.ComputeInt32Size(1, OptionalInt32); - } - if (hasOptionalInt64) { - size += pb::CodedOutputStream.ComputeInt64Size(2, OptionalInt64); - } - if (hasOptionalUint32) { - size += pb::CodedOutputStream.ComputeUInt32Size(3, OptionalUint32); - } - if (hasOptionalUint64) { - size += pb::CodedOutputStream.ComputeUInt64Size(4, OptionalUint64); - } - if (hasOptionalSint32) { - size += pb::CodedOutputStream.ComputeSInt32Size(5, OptionalSint32); - } - if (hasOptionalSint64) { - size += pb::CodedOutputStream.ComputeSInt64Size(6, OptionalSint64); - } - if (hasOptionalFixed32) { - size += pb::CodedOutputStream.ComputeFixed32Size(7, OptionalFixed32); - } - if (hasOptionalFixed64) { - size += pb::CodedOutputStream.ComputeFixed64Size(8, OptionalFixed64); - } - if (hasOptionalSfixed32) { - size += pb::CodedOutputStream.ComputeSFixed32Size(9, OptionalSfixed32); - } - if (hasOptionalSfixed64) { - size += pb::CodedOutputStream.ComputeSFixed64Size(10, OptionalSfixed64); - } - if (hasOptionalFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(11, OptionalFloat); - } - if (hasOptionalDouble) { - size += pb::CodedOutputStream.ComputeDoubleSize(12, OptionalDouble); - } - if (hasOptionalBool) { - size += pb::CodedOutputStream.ComputeBoolSize(13, OptionalBool); - } - if (hasOptionalString) { - size += pb::CodedOutputStream.ComputeStringSize(14, OptionalString); - } - if (hasOptionalBytes) { - size += pb::CodedOutputStream.ComputeBytesSize(15, OptionalBytes); - } - if (hasOptionalGroup) { - size += pb::CodedOutputStream.ComputeGroupSize(16, OptionalGroup); - } - if (hasOptionalNestedMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(18, OptionalNestedMessage); - } - if (hasOptionalForeignMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(19, OptionalForeignMessage); - } - if (hasOptionalImportMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(20, OptionalImportMessage); - } - if (hasOptionalNestedEnum) { - size += pb::CodedOutputStream.ComputeEnumSize(21, (int) OptionalNestedEnum); - } - if (hasOptionalForeignEnum) { - size += pb::CodedOutputStream.ComputeEnumSize(22, (int) OptionalForeignEnum); - } - if (hasOptionalImportEnum) { - size += pb::CodedOutputStream.ComputeEnumSize(23, (int) OptionalImportEnum); - } - if (hasOptionalStringPiece) { - size += pb::CodedOutputStream.ComputeStringSize(24, OptionalStringPiece); - } - if (hasOptionalCord) { - size += pb::CodedOutputStream.ComputeStringSize(25, OptionalCord); - } - { - int dataSize = 0; - foreach (int element in RepeatedInt32List) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedInt32_.Count; - } - { - int dataSize = 0; - foreach (long element in RepeatedInt64List) { - dataSize += pb::CodedOutputStream.ComputeInt64SizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedInt64_.Count; - } - { - int dataSize = 0; - foreach (uint element in RepeatedUint32List) { - dataSize += pb::CodedOutputStream.ComputeUInt32SizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedUint32_.Count; - } - { - int dataSize = 0; - foreach (ulong element in RepeatedUint64List) { - dataSize += pb::CodedOutputStream.ComputeUInt64SizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedUint64_.Count; - } - { - int dataSize = 0; - foreach (int element in RepeatedSint32List) { - dataSize += pb::CodedOutputStream.ComputeSInt32SizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedSint32_.Count; - } - { - int dataSize = 0; - foreach (long element in RepeatedSint64List) { - dataSize += pb::CodedOutputStream.ComputeSInt64SizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedSint64_.Count; - } - { - int dataSize = 0; - dataSize = 4 * repeatedFixed32_.Count; - size += dataSize; - size += 2 * repeatedFixed32_.Count; - } - { - int dataSize = 0; - dataSize = 8 * repeatedFixed64_.Count; - size += dataSize; - size += 2 * repeatedFixed64_.Count; - } - { - int dataSize = 0; - dataSize = 4 * repeatedSfixed32_.Count; - size += dataSize; - size += 2 * repeatedSfixed32_.Count; - } - { - int dataSize = 0; - dataSize = 8 * repeatedSfixed64_.Count; - size += dataSize; - size += 2 * repeatedSfixed64_.Count; - } - { - int dataSize = 0; - dataSize = 4 * repeatedFloat_.Count; - size += dataSize; - size += 2 * repeatedFloat_.Count; - } - { - int dataSize = 0; - dataSize = 8 * repeatedDouble_.Count; - size += dataSize; - size += 2 * repeatedDouble_.Count; - } - { - int dataSize = 0; - dataSize = 1 * repeatedBool_.Count; - size += dataSize; - size += 2 * repeatedBool_.Count; - } - { - int dataSize = 0; - foreach (string element in RepeatedStringList) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedString_.Count; - } - { - int dataSize = 0; - foreach (pb::ByteString element in RepeatedBytesList) { - dataSize += pb::CodedOutputStream.ComputeBytesSizeNoTag(element); + return CalcSerializedSize(); + } + } + + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasOptionalInt32) { + size += pb::CodedOutputStream.ComputeInt32Size(1, OptionalInt32); + } + if (hasOptionalInt64) { + size += pb::CodedOutputStream.ComputeInt64Size(2, OptionalInt64); + } + if (hasOptionalUint32) { + size += pb::CodedOutputStream.ComputeUInt32Size(3, OptionalUint32); + } + if (hasOptionalUint64) { + size += pb::CodedOutputStream.ComputeUInt64Size(4, OptionalUint64); + } + if (hasOptionalSint32) { + size += pb::CodedOutputStream.ComputeSInt32Size(5, OptionalSint32); + } + if (hasOptionalSint64) { + size += pb::CodedOutputStream.ComputeSInt64Size(6, OptionalSint64); + } + if (hasOptionalFixed32) { + size += pb::CodedOutputStream.ComputeFixed32Size(7, OptionalFixed32); + } + if (hasOptionalFixed64) { + size += pb::CodedOutputStream.ComputeFixed64Size(8, OptionalFixed64); + } + if (hasOptionalSfixed32) { + size += pb::CodedOutputStream.ComputeSFixed32Size(9, OptionalSfixed32); + } + if (hasOptionalSfixed64) { + size += pb::CodedOutputStream.ComputeSFixed64Size(10, OptionalSfixed64); + } + if (hasOptionalFloat) { + size += pb::CodedOutputStream.ComputeFloatSize(11, OptionalFloat); + } + if (hasOptionalDouble) { + size += pb::CodedOutputStream.ComputeDoubleSize(12, OptionalDouble); + } + if (hasOptionalBool) { + size += pb::CodedOutputStream.ComputeBoolSize(13, OptionalBool); + } + if (hasOptionalString) { + size += pb::CodedOutputStream.ComputeStringSize(14, OptionalString); + } + if (hasOptionalBytes) { + size += pb::CodedOutputStream.ComputeBytesSize(15, OptionalBytes); + } + if (hasOptionalGroup) { + size += pb::CodedOutputStream.ComputeGroupSize(16, OptionalGroup); + } + if (hasOptionalNestedMessage) { + size += pb::CodedOutputStream.ComputeMessageSize(18, OptionalNestedMessage); + } + if (hasOptionalForeignMessage) { + size += pb::CodedOutputStream.ComputeMessageSize(19, OptionalForeignMessage); + } + if (hasOptionalImportMessage) { + size += pb::CodedOutputStream.ComputeMessageSize(20, OptionalImportMessage); + } + if (hasOptionalNestedEnum) { + size += pb::CodedOutputStream.ComputeEnumSize(21, (int) OptionalNestedEnum); + } + if (hasOptionalForeignEnum) { + size += pb::CodedOutputStream.ComputeEnumSize(22, (int) OptionalForeignEnum); + } + if (hasOptionalImportEnum) { + size += pb::CodedOutputStream.ComputeEnumSize(23, (int) OptionalImportEnum); + } + if (hasOptionalStringPiece) { + size += pb::CodedOutputStream.ComputeStringSize(24, OptionalStringPiece); + } + if (hasOptionalCord) { + size += pb::CodedOutputStream.ComputeStringSize(25, OptionalCord); + } + { + int dataSize = 0; + foreach (int element in RepeatedInt32List) { + dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); + } + size += dataSize; + size += 2 * repeatedInt32_.Count; + } + { + int dataSize = 0; + foreach (long element in RepeatedInt64List) { + dataSize += pb::CodedOutputStream.ComputeInt64SizeNoTag(element); + } + size += dataSize; + size += 2 * repeatedInt64_.Count; + } + { + int dataSize = 0; + foreach (uint element in RepeatedUint32List) { + dataSize += pb::CodedOutputStream.ComputeUInt32SizeNoTag(element); + } + size += dataSize; + size += 2 * repeatedUint32_.Count; + } + { + int dataSize = 0; + foreach (ulong element in RepeatedUint64List) { + dataSize += pb::CodedOutputStream.ComputeUInt64SizeNoTag(element); + } + size += dataSize; + size += 2 * repeatedUint64_.Count; + } + { + int dataSize = 0; + foreach (int element in RepeatedSint32List) { + dataSize += pb::CodedOutputStream.ComputeSInt32SizeNoTag(element); + } + size += dataSize; + size += 2 * repeatedSint32_.Count; + } + { + int dataSize = 0; + foreach (long element in RepeatedSint64List) { + dataSize += pb::CodedOutputStream.ComputeSInt64SizeNoTag(element); + } + size += dataSize; + size += 2 * repeatedSint64_.Count; + } + { + int dataSize = 0; + dataSize = 4 * repeatedFixed32_.Count; + size += dataSize; + size += 2 * repeatedFixed32_.Count; + } + { + int dataSize = 0; + dataSize = 8 * repeatedFixed64_.Count; + size += dataSize; + size += 2 * repeatedFixed64_.Count; + } + { + int dataSize = 0; + dataSize = 4 * repeatedSfixed32_.Count; + size += dataSize; + size += 2 * repeatedSfixed32_.Count; + } + { + int dataSize = 0; + dataSize = 8 * repeatedSfixed64_.Count; + size += dataSize; + size += 2 * repeatedSfixed64_.Count; + } + { + int dataSize = 0; + dataSize = 4 * repeatedFloat_.Count; + size += dataSize; + size += 2 * repeatedFloat_.Count; + } + { + int dataSize = 0; + dataSize = 8 * repeatedDouble_.Count; + size += dataSize; + size += 2 * repeatedDouble_.Count; + } + { + int dataSize = 0; + dataSize = 1 * repeatedBool_.Count; + size += dataSize; + size += 2 * repeatedBool_.Count; + } + { + int dataSize = 0; + foreach (string element in RepeatedStringList) { + dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); + } + size += dataSize; + size += 2 * repeatedString_.Count; + } + { + int dataSize = 0; + foreach (pb::ByteString element in RepeatedBytesList) { + dataSize += pb::CodedOutputStream.ComputeBytesSizeNoTag(element); + } + size += dataSize; + size += 2 * repeatedBytes_.Count; + } + foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup element in RepeatedGroupList) { + size += pb::CodedOutputStream.ComputeGroupSize(46, element); + } + foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage element in RepeatedNestedMessageList) { + size += pb::CodedOutputStream.ComputeMessageSize(48, element); + } + foreach (global::Google.ProtocolBuffers.TestProtos.ForeignMessage element in RepeatedForeignMessageList) { + size += pb::CodedOutputStream.ComputeMessageSize(49, element); + } + foreach (global::Google.ProtocolBuffers.TestProtos.ImportMessage element in RepeatedImportMessageList) { + size += pb::CodedOutputStream.ComputeMessageSize(50, element); + } + { + int dataSize = 0; + if (repeatedNestedEnum_.Count > 0) { + foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedEnum element in repeatedNestedEnum_) { + dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); } size += dataSize; - size += 2 * repeatedBytes_.Count; - } - foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup element in RepeatedGroupList) { - size += pb::CodedOutputStream.ComputeGroupSize(46, element); + size += 2 * repeatedNestedEnum_.Count; } - foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage element in RepeatedNestedMessageList) { - size += pb::CodedOutputStream.ComputeMessageSize(48, element); - } - foreach (global::Google.ProtocolBuffers.TestProtos.ForeignMessage element in RepeatedForeignMessageList) { - size += pb::CodedOutputStream.ComputeMessageSize(49, element); - } - foreach (global::Google.ProtocolBuffers.TestProtos.ImportMessage element in RepeatedImportMessageList) { - size += pb::CodedOutputStream.ComputeMessageSize(50, element); - } - { - int dataSize = 0; - if (repeatedNestedEnum_.Count > 0) { - foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedEnum element in repeatedNestedEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 2 * repeatedNestedEnum_.Count; - } - } - { - int dataSize = 0; - if (repeatedForeignEnum_.Count > 0) { - foreach (global::Google.ProtocolBuffers.TestProtos.ForeignEnum element in repeatedForeignEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 2 * repeatedForeignEnum_.Count; - } - } - { - int dataSize = 0; - if (repeatedImportEnum_.Count > 0) { - foreach (global::Google.ProtocolBuffers.TestProtos.ImportEnum element in repeatedImportEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 2 * repeatedImportEnum_.Count; - } - } - { - int dataSize = 0; - foreach (string element in RepeatedStringPieceList) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); + } + { + int dataSize = 0; + if (repeatedForeignEnum_.Count > 0) { + foreach (global::Google.ProtocolBuffers.TestProtos.ForeignEnum element in repeatedForeignEnum_) { + dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); } size += dataSize; - size += 2 * repeatedStringPiece_.Count; + size += 2 * repeatedForeignEnum_.Count; } - { - int dataSize = 0; - foreach (string element in RepeatedCordList) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); + } + { + int dataSize = 0; + if (repeatedImportEnum_.Count > 0) { + foreach (global::Google.ProtocolBuffers.TestProtos.ImportEnum element in repeatedImportEnum_) { + dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); } size += dataSize; - size += 2 * repeatedCord_.Count; - } - if (hasDefaultInt32) { - size += pb::CodedOutputStream.ComputeInt32Size(61, DefaultInt32); - } - if (hasDefaultInt64) { - size += pb::CodedOutputStream.ComputeInt64Size(62, DefaultInt64); - } - if (hasDefaultUint32) { - size += pb::CodedOutputStream.ComputeUInt32Size(63, DefaultUint32); - } - if (hasDefaultUint64) { - size += pb::CodedOutputStream.ComputeUInt64Size(64, DefaultUint64); - } - if (hasDefaultSint32) { - size += pb::CodedOutputStream.ComputeSInt32Size(65, DefaultSint32); - } - if (hasDefaultSint64) { - size += pb::CodedOutputStream.ComputeSInt64Size(66, DefaultSint64); + size += 2 * repeatedImportEnum_.Count; } - if (hasDefaultFixed32) { - size += pb::CodedOutputStream.ComputeFixed32Size(67, DefaultFixed32); - } - if (hasDefaultFixed64) { - size += pb::CodedOutputStream.ComputeFixed64Size(68, DefaultFixed64); - } - if (hasDefaultSfixed32) { - size += pb::CodedOutputStream.ComputeSFixed32Size(69, DefaultSfixed32); - } - if (hasDefaultSfixed64) { - size += pb::CodedOutputStream.ComputeSFixed64Size(70, DefaultSfixed64); - } - if (hasDefaultFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(71, DefaultFloat); - } - if (hasDefaultDouble) { - size += pb::CodedOutputStream.ComputeDoubleSize(72, DefaultDouble); - } - if (hasDefaultBool) { - size += pb::CodedOutputStream.ComputeBoolSize(73, DefaultBool); - } - if (hasDefaultString) { - size += pb::CodedOutputStream.ComputeStringSize(74, DefaultString); - } - if (hasDefaultBytes) { - size += pb::CodedOutputStream.ComputeBytesSize(75, DefaultBytes); - } - if (hasDefaultNestedEnum) { - size += pb::CodedOutputStream.ComputeEnumSize(81, (int) DefaultNestedEnum); - } - if (hasDefaultForeignEnum) { - size += pb::CodedOutputStream.ComputeEnumSize(82, (int) DefaultForeignEnum); - } - if (hasDefaultImportEnum) { - size += pb::CodedOutputStream.ComputeEnumSize(83, (int) DefaultImportEnum); - } - if (hasDefaultStringPiece) { - size += pb::CodedOutputStream.ComputeStringSize(84, DefaultStringPiece); + } + { + int dataSize = 0; + foreach (string element in RepeatedStringPieceList) { + dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); } - if (hasDefaultCord) { - size += pb::CodedOutputStream.ComputeStringSize(85, DefaultCord); + size += dataSize; + size += 2 * repeatedStringPiece_.Count; + } + { + int dataSize = 0; + foreach (string element in RepeatedCordList) { + dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + size += dataSize; + size += 2 * repeatedCord_.Count; + } + if (hasDefaultInt32) { + size += pb::CodedOutputStream.ComputeInt32Size(61, DefaultInt32); + } + if (hasDefaultInt64) { + size += pb::CodedOutputStream.ComputeInt64Size(62, DefaultInt64); + } + if (hasDefaultUint32) { + size += pb::CodedOutputStream.ComputeUInt32Size(63, DefaultUint32); + } + if (hasDefaultUint64) { + size += pb::CodedOutputStream.ComputeUInt64Size(64, DefaultUint64); + } + if (hasDefaultSint32) { + size += pb::CodedOutputStream.ComputeSInt32Size(65, DefaultSint32); + } + if (hasDefaultSint64) { + size += pb::CodedOutputStream.ComputeSInt64Size(66, DefaultSint64); + } + if (hasDefaultFixed32) { + size += pb::CodedOutputStream.ComputeFixed32Size(67, DefaultFixed32); + } + if (hasDefaultFixed64) { + size += pb::CodedOutputStream.ComputeFixed64Size(68, DefaultFixed64); } + if (hasDefaultSfixed32) { + size += pb::CodedOutputStream.ComputeSFixed32Size(69, DefaultSfixed32); + } + if (hasDefaultSfixed64) { + size += pb::CodedOutputStream.ComputeSFixed64Size(70, DefaultSfixed64); + } + if (hasDefaultFloat) { + size += pb::CodedOutputStream.ComputeFloatSize(71, DefaultFloat); + } + if (hasDefaultDouble) { + size += pb::CodedOutputStream.ComputeDoubleSize(72, DefaultDouble); + } + if (hasDefaultBool) { + size += pb::CodedOutputStream.ComputeBoolSize(73, DefaultBool); + } + if (hasDefaultString) { + size += pb::CodedOutputStream.ComputeStringSize(74, DefaultString); + } + if (hasDefaultBytes) { + size += pb::CodedOutputStream.ComputeBytesSize(75, DefaultBytes); + } + if (hasDefaultNestedEnum) { + size += pb::CodedOutputStream.ComputeEnumSize(81, (int) DefaultNestedEnum); + } + if (hasDefaultForeignEnum) { + size += pb::CodedOutputStream.ComputeEnumSize(82, (int) DefaultForeignEnum); + } + if (hasDefaultImportEnum) { + size += pb::CodedOutputStream.ComputeEnumSize(83, (int) DefaultImportEnum); + } + if (hasDefaultStringPiece) { + size += pb::CodedOutputStream.ComputeStringSize(84, DefaultStringPiece); + } + if (hasDefaultCord) { + size += pb::CodedOutputStream.ComputeStringSize(85, DefaultCord); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; } - public static TestAllTypes ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -5765,7 +5785,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testDeprecatedFieldsFieldNames; if (hasDeprecatedInt32) { output.WriteInt32(1, field_names[0], DeprecatedInt32); @@ -5778,17 +5798,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasDeprecatedInt32) { - size += pb::CodedOutputStream.ComputeInt32Size(1, DeprecatedInt32); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasDeprecatedInt32) { + size += pb::CodedOutputStream.ComputeInt32Size(1, DeprecatedInt32); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestDeprecatedFields ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -6039,7 +6064,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _foreignMessageFieldNames; if (hasC) { output.WriteInt32(1, field_names[0], C); @@ -6052,17 +6077,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasC) { - size += pb::CodedOutputStream.ComputeInt32Size(1, C); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasC) { + size += pb::CodedOutputStream.ComputeInt32Size(1, C); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static ForeignMessage ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -6300,7 +6330,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testAllExtensionsFieldNames; pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); extensionWriter.WriteUntil(536870912, output); @@ -6312,15 +6342,20 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - size += ExtensionsSerializedSize; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += ExtensionsSerializedSize; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestAllExtensions ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -6541,7 +6576,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _optionalGroupExtensionFieldNames; if (hasA) { output.WriteInt32(17, field_names[0], A); @@ -6554,17 +6589,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(17, A); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasA) { + size += pb::CodedOutputStream.ComputeInt32Size(17, A); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static OptionalGroup_extension ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -6811,7 +6851,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _repeatedGroupExtensionFieldNames; if (hasA) { output.WriteInt32(47, field_names[0], A); @@ -6824,17 +6864,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(47, A); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasA) { + size += pb::CodedOutputStream.ComputeInt32Size(47, A); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static RepeatedGroup_extension ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -7073,7 +7118,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testNestedExtensionFieldNames; UnknownFields.WriteTo(output); } @@ -7083,14 +7128,19 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestNestedExtension ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -7637,7 +7687,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testRequiredFieldNames; if (hasA) { output.WriteInt32(1, field_names[0], A); @@ -7746,113 +7796,118 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(1, A); - } - if (hasDummy2) { - size += pb::CodedOutputStream.ComputeInt32Size(2, Dummy2); - } - if (hasB) { - size += pb::CodedOutputStream.ComputeInt32Size(3, B); - } - if (hasDummy4) { - size += pb::CodedOutputStream.ComputeInt32Size(4, Dummy4); - } - if (hasDummy5) { - size += pb::CodedOutputStream.ComputeInt32Size(5, Dummy5); - } - if (hasDummy6) { - size += pb::CodedOutputStream.ComputeInt32Size(6, Dummy6); - } - if (hasDummy7) { - size += pb::CodedOutputStream.ComputeInt32Size(7, Dummy7); - } - if (hasDummy8) { - size += pb::CodedOutputStream.ComputeInt32Size(8, Dummy8); - } - if (hasDummy9) { - size += pb::CodedOutputStream.ComputeInt32Size(9, Dummy9); - } - if (hasDummy10) { - size += pb::CodedOutputStream.ComputeInt32Size(10, Dummy10); - } - if (hasDummy11) { - size += pb::CodedOutputStream.ComputeInt32Size(11, Dummy11); - } - if (hasDummy12) { - size += pb::CodedOutputStream.ComputeInt32Size(12, Dummy12); - } - if (hasDummy13) { - size += pb::CodedOutputStream.ComputeInt32Size(13, Dummy13); - } - if (hasDummy14) { - size += pb::CodedOutputStream.ComputeInt32Size(14, Dummy14); - } - if (hasDummy15) { - size += pb::CodedOutputStream.ComputeInt32Size(15, Dummy15); - } - if (hasDummy16) { - size += pb::CodedOutputStream.ComputeInt32Size(16, Dummy16); - } - if (hasDummy17) { - size += pb::CodedOutputStream.ComputeInt32Size(17, Dummy17); - } - if (hasDummy18) { - size += pb::CodedOutputStream.ComputeInt32Size(18, Dummy18); - } - if (hasDummy19) { - size += pb::CodedOutputStream.ComputeInt32Size(19, Dummy19); - } - if (hasDummy20) { - size += pb::CodedOutputStream.ComputeInt32Size(20, Dummy20); - } - if (hasDummy21) { - size += pb::CodedOutputStream.ComputeInt32Size(21, Dummy21); - } - if (hasDummy22) { - size += pb::CodedOutputStream.ComputeInt32Size(22, Dummy22); - } - if (hasDummy23) { - size += pb::CodedOutputStream.ComputeInt32Size(23, Dummy23); - } - if (hasDummy24) { - size += pb::CodedOutputStream.ComputeInt32Size(24, Dummy24); - } - if (hasDummy25) { - size += pb::CodedOutputStream.ComputeInt32Size(25, Dummy25); - } - if (hasDummy26) { - size += pb::CodedOutputStream.ComputeInt32Size(26, Dummy26); - } - if (hasDummy27) { - size += pb::CodedOutputStream.ComputeInt32Size(27, Dummy27); - } - if (hasDummy28) { - size += pb::CodedOutputStream.ComputeInt32Size(28, Dummy28); - } - if (hasDummy29) { - size += pb::CodedOutputStream.ComputeInt32Size(29, Dummy29); - } - if (hasDummy30) { - size += pb::CodedOutputStream.ComputeInt32Size(30, Dummy30); - } - if (hasDummy31) { - size += pb::CodedOutputStream.ComputeInt32Size(31, Dummy31); - } - if (hasDummy32) { - size += pb::CodedOutputStream.ComputeInt32Size(32, Dummy32); - } - if (hasC) { - size += pb::CodedOutputStream.ComputeInt32Size(33, C); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasA) { + size += pb::CodedOutputStream.ComputeInt32Size(1, A); + } + if (hasDummy2) { + size += pb::CodedOutputStream.ComputeInt32Size(2, Dummy2); + } + if (hasB) { + size += pb::CodedOutputStream.ComputeInt32Size(3, B); + } + if (hasDummy4) { + size += pb::CodedOutputStream.ComputeInt32Size(4, Dummy4); + } + if (hasDummy5) { + size += pb::CodedOutputStream.ComputeInt32Size(5, Dummy5); + } + if (hasDummy6) { + size += pb::CodedOutputStream.ComputeInt32Size(6, Dummy6); + } + if (hasDummy7) { + size += pb::CodedOutputStream.ComputeInt32Size(7, Dummy7); + } + if (hasDummy8) { + size += pb::CodedOutputStream.ComputeInt32Size(8, Dummy8); + } + if (hasDummy9) { + size += pb::CodedOutputStream.ComputeInt32Size(9, Dummy9); + } + if (hasDummy10) { + size += pb::CodedOutputStream.ComputeInt32Size(10, Dummy10); + } + if (hasDummy11) { + size += pb::CodedOutputStream.ComputeInt32Size(11, Dummy11); + } + if (hasDummy12) { + size += pb::CodedOutputStream.ComputeInt32Size(12, Dummy12); + } + if (hasDummy13) { + size += pb::CodedOutputStream.ComputeInt32Size(13, Dummy13); + } + if (hasDummy14) { + size += pb::CodedOutputStream.ComputeInt32Size(14, Dummy14); + } + if (hasDummy15) { + size += pb::CodedOutputStream.ComputeInt32Size(15, Dummy15); + } + if (hasDummy16) { + size += pb::CodedOutputStream.ComputeInt32Size(16, Dummy16); + } + if (hasDummy17) { + size += pb::CodedOutputStream.ComputeInt32Size(17, Dummy17); + } + if (hasDummy18) { + size += pb::CodedOutputStream.ComputeInt32Size(18, Dummy18); + } + if (hasDummy19) { + size += pb::CodedOutputStream.ComputeInt32Size(19, Dummy19); + } + if (hasDummy20) { + size += pb::CodedOutputStream.ComputeInt32Size(20, Dummy20); + } + if (hasDummy21) { + size += pb::CodedOutputStream.ComputeInt32Size(21, Dummy21); + } + if (hasDummy22) { + size += pb::CodedOutputStream.ComputeInt32Size(22, Dummy22); + } + if (hasDummy23) { + size += pb::CodedOutputStream.ComputeInt32Size(23, Dummy23); + } + if (hasDummy24) { + size += pb::CodedOutputStream.ComputeInt32Size(24, Dummy24); + } + if (hasDummy25) { + size += pb::CodedOutputStream.ComputeInt32Size(25, Dummy25); + } + if (hasDummy26) { + size += pb::CodedOutputStream.ComputeInt32Size(26, Dummy26); + } + if (hasDummy27) { + size += pb::CodedOutputStream.ComputeInt32Size(27, Dummy27); + } + if (hasDummy28) { + size += pb::CodedOutputStream.ComputeInt32Size(28, Dummy28); + } + if (hasDummy29) { + size += pb::CodedOutputStream.ComputeInt32Size(29, Dummy29); + } + if (hasDummy30) { + size += pb::CodedOutputStream.ComputeInt32Size(30, Dummy30); + } + if (hasDummy31) { + size += pb::CodedOutputStream.ComputeInt32Size(31, Dummy31); + } + if (hasDummy32) { + size += pb::CodedOutputStream.ComputeInt32Size(32, Dummy32); + } + if (hasC) { + size += pb::CodedOutputStream.ComputeInt32Size(33, C); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestRequired ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -8991,7 +9046,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testRequiredForeignFieldNames; if (hasOptionalMessage) { output.WriteMessage(1, field_names[1], OptionalMessage); @@ -9010,23 +9065,28 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasOptionalMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(1, OptionalMessage); - } - foreach (global::Google.ProtocolBuffers.TestProtos.TestRequired element in RepeatedMessageList) { - size += pb::CodedOutputStream.ComputeMessageSize(2, element); - } - if (hasDummy) { - size += pb::CodedOutputStream.ComputeInt32Size(3, Dummy); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasOptionalMessage) { + size += pb::CodedOutputStream.ComputeMessageSize(1, OptionalMessage); + } + foreach (global::Google.ProtocolBuffers.TestProtos.TestRequired element in RepeatedMessageList) { + size += pb::CodedOutputStream.ComputeMessageSize(2, element); + } + if (hasDummy) { + size += pb::CodedOutputStream.ComputeInt32Size(3, Dummy); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestRequiredForeign ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -9377,7 +9437,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testForeignNestedFieldNames; if (hasForeignNested) { output.WriteMessage(1, field_names[0], ForeignNested); @@ -9390,17 +9450,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasForeignNested) { - size += pb::CodedOutputStream.ComputeMessageSize(1, ForeignNested); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasForeignNested) { + size += pb::CodedOutputStream.ComputeMessageSize(1, ForeignNested); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestForeignNested ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -9662,7 +9727,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testEmptyMessageFieldNames; UnknownFields.WriteTo(output); } @@ -9672,14 +9737,19 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestEmptyMessage ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -9890,7 +9960,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testEmptyMessageWithExtensionsFieldNames; pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); extensionWriter.WriteUntil(536870912, output); @@ -9902,15 +9972,20 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - size += ExtensionsSerializedSize; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += ExtensionsSerializedSize; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestEmptyMessageWithExtensions ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -10122,7 +10197,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testMultipleExtensionRangesFieldNames; pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); extensionWriter.WriteUntil(43, output); @@ -10136,15 +10211,20 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - size += ExtensionsSerializedSize; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += ExtensionsSerializedSize; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestMultipleExtensionRanges ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -10375,7 +10455,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testReallyLargeTagNumberFieldNames; if (hasA) { output.WriteInt32(1, field_names[0], A); @@ -10391,20 +10471,25 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(1, A); - } - if (hasBb) { - size += pb::CodedOutputStream.ComputeInt32Size(268435455, Bb); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasA) { + size += pb::CodedOutputStream.ComputeInt32Size(1, A); + } + if (hasBb) { + size += pb::CodedOutputStream.ComputeInt32Size(268435455, Bb); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestReallyLargeTagNumber ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -10688,7 +10773,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testRecursiveMessageFieldNames; if (hasA) { output.WriteMessage(1, field_names[0], A); @@ -10704,20 +10789,25 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeMessageSize(1, A); - } - if (hasI) { - size += pb::CodedOutputStream.ComputeInt32Size(2, I); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasA) { + size += pb::CodedOutputStream.ComputeMessageSize(1, A); + } + if (hasI) { + size += pb::CodedOutputStream.ComputeInt32Size(2, I); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestRecursiveMessage ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -11016,7 +11106,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testMutualRecursionAFieldNames; if (hasBb) { output.WriteMessage(1, field_names[0], Bb); @@ -11029,17 +11119,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasBb) { - size += pb::CodedOutputStream.ComputeMessageSize(1, Bb); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasBb) { + size += pb::CodedOutputStream.ComputeMessageSize(1, Bb); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestMutualRecursionA ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -11321,7 +11416,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testMutualRecursionBFieldNames; if (hasA) { output.WriteMessage(1, field_names[0], A); @@ -11337,20 +11432,25 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeMessageSize(1, A); - } - if (hasOptionalInt32) { - size += pb::CodedOutputStream.ComputeInt32Size(2, OptionalInt32); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasA) { + size += pb::CodedOutputStream.ComputeMessageSize(1, A); + } + if (hasOptionalInt32) { + size += pb::CodedOutputStream.ComputeInt32Size(2, OptionalInt32); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestMutualRecursionB ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -11678,7 +11778,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _fooFieldNames; if (hasA) { output.WriteInt32(1, field_names[0], A); @@ -11691,17 +11791,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(1, A); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasA) { + size += pb::CodedOutputStream.ComputeInt32Size(1, A); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static Foo ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -11948,7 +12053,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _barFieldNames; if (hasA) { output.WriteInt32(1, field_names[0], A); @@ -11961,17 +12066,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(1, A); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasA) { + size += pb::CodedOutputStream.ComputeInt32Size(1, A); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static Bar ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -12215,7 +12325,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testDupFieldNumberFieldNames; if (hasA) { output.WriteInt32(1, field_names[0], A); @@ -12234,23 +12344,28 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(1, A); - } - if (hasFoo) { - size += pb::CodedOutputStream.ComputeGroupSize(2, Foo); - } - if (hasBar) { - size += pb::CodedOutputStream.ComputeGroupSize(3, Bar); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasA) { + size += pb::CodedOutputStream.ComputeInt32Size(1, A); + } + if (hasFoo) { + size += pb::CodedOutputStream.ComputeGroupSize(2, Foo); + } + if (hasBar) { + size += pb::CodedOutputStream.ComputeGroupSize(3, Bar); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestDupFieldNumber ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -12644,7 +12759,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _nestedMessageFieldNames; if (nestedmessageRepeatedInt32_.Count > 0) { output.WriteInt32Array(1, field_names[1], nestedmessageRepeatedInt32_); @@ -12660,25 +12775,30 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - { - int dataSize = 0; - foreach (int element in NestedmessageRepeatedInt32List) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); - } - size += dataSize; - size += 1 * nestedmessageRepeatedInt32_.Count; - } - foreach (global::Google.ProtocolBuffers.TestProtos.ForeignMessage element in NestedmessageRepeatedForeignmessageList) { - size += pb::CodedOutputStream.ComputeMessageSize(2, element); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + { + int dataSize = 0; + foreach (int element in NestedmessageRepeatedInt32List) { + dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); + } + size += dataSize; + size += 1 * nestedmessageRepeatedInt32_.Count; + } + foreach (global::Google.ProtocolBuffers.TestProtos.ForeignMessage element in NestedmessageRepeatedForeignmessageList) { + size += pb::CodedOutputStream.ComputeMessageSize(2, element); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static NestedMessage ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -12966,7 +13086,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testNestedMessageHasBitsFieldNames; if (hasOptionalNestedMessage) { output.WriteMessage(1, field_names[0], OptionalNestedMessage); @@ -12979,17 +13099,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasOptionalNestedMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(1, OptionalNestedMessage); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasOptionalNestedMessage) { + size += pb::CodedOutputStream.ComputeMessageSize(1, OptionalNestedMessage); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestNestedMessageHasBits ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -13383,7 +13508,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testCamelCaseFieldNamesFieldNames; if (hasPrimitiveField) { output.WriteInt32(1, field_names[3], PrimitiveField); @@ -13429,77 +13554,82 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasPrimitiveField) { - size += pb::CodedOutputStream.ComputeInt32Size(1, PrimitiveField); - } - if (hasStringField) { - size += pb::CodedOutputStream.ComputeStringSize(2, StringField); - } - if (hasEnumField) { - size += pb::CodedOutputStream.ComputeEnumSize(3, (int) EnumField); - } - if (hasMessageField) { - size += pb::CodedOutputStream.ComputeMessageSize(4, MessageField); - } - if (hasStringPieceField) { - size += pb::CodedOutputStream.ComputeStringSize(5, StringPieceField); - } - if (hasCordField) { - size += pb::CodedOutputStream.ComputeStringSize(6, CordField); + return CalcSerializedSize(); + } + } + + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasPrimitiveField) { + size += pb::CodedOutputStream.ComputeInt32Size(1, PrimitiveField); + } + if (hasStringField) { + size += pb::CodedOutputStream.ComputeStringSize(2, StringField); + } + if (hasEnumField) { + size += pb::CodedOutputStream.ComputeEnumSize(3, (int) EnumField); + } + if (hasMessageField) { + size += pb::CodedOutputStream.ComputeMessageSize(4, MessageField); + } + if (hasStringPieceField) { + size += pb::CodedOutputStream.ComputeStringSize(5, StringPieceField); + } + if (hasCordField) { + size += pb::CodedOutputStream.ComputeStringSize(6, CordField); + } + { + int dataSize = 0; + foreach (int element in RepeatedPrimitiveFieldList) { + dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); } - { - int dataSize = 0; - foreach (int element in RepeatedPrimitiveFieldList) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); - } - size += dataSize; - size += 1 * repeatedPrimitiveField_.Count; + size += dataSize; + size += 1 * repeatedPrimitiveField_.Count; + } + { + int dataSize = 0; + foreach (string element in RepeatedStringFieldList) { + dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); } - { - int dataSize = 0; - foreach (string element in RepeatedStringFieldList) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); + size += dataSize; + size += 1 * repeatedStringField_.Count; + } + { + int dataSize = 0; + if (repeatedEnumField_.Count > 0) { + foreach (global::Google.ProtocolBuffers.TestProtos.ForeignEnum element in repeatedEnumField_) { + dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); } size += dataSize; - size += 1 * repeatedStringField_.Count; - } - { - int dataSize = 0; - if (repeatedEnumField_.Count > 0) { - foreach (global::Google.ProtocolBuffers.TestProtos.ForeignEnum element in repeatedEnumField_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 1 * repeatedEnumField_.Count; - } - } - foreach (global::Google.ProtocolBuffers.TestProtos.ForeignMessage element in RepeatedMessageFieldList) { - size += pb::CodedOutputStream.ComputeMessageSize(10, element); + size += 1 * repeatedEnumField_.Count; } - { - int dataSize = 0; - foreach (string element in RepeatedStringPieceFieldList) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); - } - size += dataSize; - size += 1 * repeatedStringPieceField_.Count; + } + foreach (global::Google.ProtocolBuffers.TestProtos.ForeignMessage element in RepeatedMessageFieldList) { + size += pb::CodedOutputStream.ComputeMessageSize(10, element); + } + { + int dataSize = 0; + foreach (string element in RepeatedStringPieceFieldList) { + dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); } - { - int dataSize = 0; - foreach (string element in RepeatedCordFieldList) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); - } - size += dataSize; - size += 1 * repeatedCordField_.Count; + size += dataSize; + size += 1 * repeatedStringPieceField_.Count; + } + { + int dataSize = 0; + foreach (string element in RepeatedCordFieldList) { + dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + size += dataSize; + size += 1 * repeatedCordField_.Count; } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; } - public static TestCamelCaseFieldNames ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -14197,7 +14327,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testFieldOrderingsFieldNames; pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); if (hasMyInt) { @@ -14216,27 +14346,32 @@ namespace Google.ProtocolBuffers.TestProtos { private int memoizedSerializedSize = -1; public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasMyString) { - size += pb::CodedOutputStream.ComputeStringSize(11, MyString); - } - if (hasMyInt) { - size += pb::CodedOutputStream.ComputeInt64Size(1, MyInt); - } - if (hasMyFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(101, MyFloat); - } - size += ExtensionsSerializedSize; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + get { + int size = memoizedSerializedSize; + if (size != -1) return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasMyString) { + size += pb::CodedOutputStream.ComputeStringSize(11, MyString); + } + if (hasMyInt) { + size += pb::CodedOutputStream.ComputeInt64Size(1, MyInt); + } + if (hasMyFloat) { + size += pb::CodedOutputStream.ComputeFloatSize(101, MyFloat); + } + size += ExtensionsSerializedSize; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestFieldOrderings ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -14731,7 +14866,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testExtremeDefaultValuesFieldNames; if (hasEscapedBytes) { output.WriteBytes(1, field_names[1], EscapedBytes); @@ -14801,74 +14936,79 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasEscapedBytes) { - size += pb::CodedOutputStream.ComputeBytesSize(1, EscapedBytes); - } - if (hasLargeUint32) { - size += pb::CodedOutputStream.ComputeUInt32Size(2, LargeUint32); - } - if (hasLargeUint64) { - size += pb::CodedOutputStream.ComputeUInt64Size(3, LargeUint64); - } - if (hasSmallInt32) { - size += pb::CodedOutputStream.ComputeInt32Size(4, SmallInt32); - } - if (hasSmallInt64) { - size += pb::CodedOutputStream.ComputeInt64Size(5, SmallInt64); - } - if (hasUtf8String) { - size += pb::CodedOutputStream.ComputeStringSize(6, Utf8String); - } - if (hasZeroFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(7, ZeroFloat); - } - if (hasOneFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(8, OneFloat); - } - if (hasSmallFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(9, SmallFloat); - } - if (hasNegativeOneFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(10, NegativeOneFloat); - } - if (hasNegativeFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(11, NegativeFloat); - } - if (hasLargeFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(12, LargeFloat); - } - if (hasSmallNegativeFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(13, SmallNegativeFloat); - } - if (hasInfDouble) { - size += pb::CodedOutputStream.ComputeDoubleSize(14, InfDouble); - } - if (hasNegInfDouble) { - size += pb::CodedOutputStream.ComputeDoubleSize(15, NegInfDouble); - } - if (hasNanDouble) { - size += pb::CodedOutputStream.ComputeDoubleSize(16, NanDouble); - } - if (hasInfFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(17, InfFloat); - } - if (hasNegInfFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(18, NegInfFloat); - } - if (hasNanFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(19, NanFloat); - } - if (hasCppTrigraph) { - size += pb::CodedOutputStream.ComputeStringSize(20, CppTrigraph); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasEscapedBytes) { + size += pb::CodedOutputStream.ComputeBytesSize(1, EscapedBytes); + } + if (hasLargeUint32) { + size += pb::CodedOutputStream.ComputeUInt32Size(2, LargeUint32); + } + if (hasLargeUint64) { + size += pb::CodedOutputStream.ComputeUInt64Size(3, LargeUint64); + } + if (hasSmallInt32) { + size += pb::CodedOutputStream.ComputeInt32Size(4, SmallInt32); + } + if (hasSmallInt64) { + size += pb::CodedOutputStream.ComputeInt64Size(5, SmallInt64); + } + if (hasUtf8String) { + size += pb::CodedOutputStream.ComputeStringSize(6, Utf8String); + } + if (hasZeroFloat) { + size += pb::CodedOutputStream.ComputeFloatSize(7, ZeroFloat); + } + if (hasOneFloat) { + size += pb::CodedOutputStream.ComputeFloatSize(8, OneFloat); + } + if (hasSmallFloat) { + size += pb::CodedOutputStream.ComputeFloatSize(9, SmallFloat); + } + if (hasNegativeOneFloat) { + size += pb::CodedOutputStream.ComputeFloatSize(10, NegativeOneFloat); + } + if (hasNegativeFloat) { + size += pb::CodedOutputStream.ComputeFloatSize(11, NegativeFloat); + } + if (hasLargeFloat) { + size += pb::CodedOutputStream.ComputeFloatSize(12, LargeFloat); + } + if (hasSmallNegativeFloat) { + size += pb::CodedOutputStream.ComputeFloatSize(13, SmallNegativeFloat); + } + if (hasInfDouble) { + size += pb::CodedOutputStream.ComputeDoubleSize(14, InfDouble); + } + if (hasNegInfDouble) { + size += pb::CodedOutputStream.ComputeDoubleSize(15, NegInfDouble); + } + if (hasNanDouble) { + size += pb::CodedOutputStream.ComputeDoubleSize(16, NanDouble); + } + if (hasInfFloat) { + size += pb::CodedOutputStream.ComputeFloatSize(17, InfFloat); + } + if (hasNegInfFloat) { + size += pb::CodedOutputStream.ComputeFloatSize(18, NegInfFloat); + } + if (hasNanFloat) { + size += pb::CodedOutputStream.ComputeFloatSize(19, NanFloat); + } + if (hasCppTrigraph) { + size += pb::CodedOutputStream.ComputeStringSize(20, CppTrigraph); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestExtremeDefaultValues ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -15635,7 +15775,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _sparseEnumMessageFieldNames; if (hasSparseEnum) { output.WriteEnum(1, field_names[0], (int) SparseEnum, SparseEnum); @@ -15648,17 +15788,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasSparseEnum) { - size += pb::CodedOutputStream.ComputeEnumSize(1, (int) SparseEnum); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasSparseEnum) { + size += pb::CodedOutputStream.ComputeEnumSize(1, (int) SparseEnum); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static SparseEnumMessage ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -15913,7 +16058,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _oneStringFieldNames; if (hasData) { output.WriteString(1, field_names[0], Data); @@ -15926,17 +16071,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasData) { - size += pb::CodedOutputStream.ComputeStringSize(1, Data); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasData) { + size += pb::CodedOutputStream.ComputeStringSize(1, Data); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static OneString ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -16184,7 +16334,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _oneBytesFieldNames; if (hasData) { output.WriteBytes(1, field_names[0], Data); @@ -16197,17 +16347,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasData) { - size += pb::CodedOutputStream.ComputeBytesSize(1, Data); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasData) { + size += pb::CodedOutputStream.ComputeBytesSize(1, Data); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static OneBytes ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -16635,7 +16790,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testPackedTypesFieldNames; if (packedInt32_.Count > 0) { output.WritePackedInt32Array(90, field_names[6], packedInt32MemoizedSerializedSize, packedInt32_); @@ -16687,155 +16842,160 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - { - int dataSize = 0; - foreach (int element in PackedInt32List) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); - } - size += dataSize; - if (packedInt32_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedInt32MemoizedSerializedSize = dataSize; + return CalcSerializedSize(); + } + } + + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + { + int dataSize = 0; + foreach (int element in PackedInt32List) { + dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); } - { - int dataSize = 0; - foreach (long element in PackedInt64List) { - dataSize += pb::CodedOutputStream.ComputeInt64SizeNoTag(element); - } - size += dataSize; - if (packedInt64_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedInt64MemoizedSerializedSize = dataSize; + size += dataSize; + if (packedInt32_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { - int dataSize = 0; - foreach (uint element in PackedUint32List) { - dataSize += pb::CodedOutputStream.ComputeUInt32SizeNoTag(element); - } - size += dataSize; - if (packedUint32_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedUint32MemoizedSerializedSize = dataSize; + packedInt32MemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + foreach (long element in PackedInt64List) { + dataSize += pb::CodedOutputStream.ComputeInt64SizeNoTag(element); } - { - int dataSize = 0; - foreach (ulong element in PackedUint64List) { - dataSize += pb::CodedOutputStream.ComputeUInt64SizeNoTag(element); - } - size += dataSize; - if (packedUint64_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedUint64MemoizedSerializedSize = dataSize; + size += dataSize; + if (packedInt64_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { - int dataSize = 0; - foreach (int element in PackedSint32List) { - dataSize += pb::CodedOutputStream.ComputeSInt32SizeNoTag(element); - } - size += dataSize; - if (packedSint32_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedSint32MemoizedSerializedSize = dataSize; + packedInt64MemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + foreach (uint element in PackedUint32List) { + dataSize += pb::CodedOutputStream.ComputeUInt32SizeNoTag(element); } - { - int dataSize = 0; - foreach (long element in PackedSint64List) { - dataSize += pb::CodedOutputStream.ComputeSInt64SizeNoTag(element); - } - size += dataSize; - if (packedSint64_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedSint64MemoizedSerializedSize = dataSize; + size += dataSize; + if (packedUint32_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { - int dataSize = 0; - dataSize = 4 * packedFixed32_.Count; - size += dataSize; - if (packedFixed32_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedFixed32MemoizedSerializedSize = dataSize; + packedUint32MemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + foreach (ulong element in PackedUint64List) { + dataSize += pb::CodedOutputStream.ComputeUInt64SizeNoTag(element); } - { - int dataSize = 0; - dataSize = 8 * packedFixed64_.Count; - size += dataSize; - if (packedFixed64_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedFixed64MemoizedSerializedSize = dataSize; + size += dataSize; + if (packedUint64_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { - int dataSize = 0; - dataSize = 4 * packedSfixed32_.Count; - size += dataSize; - if (packedSfixed32_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedSfixed32MemoizedSerializedSize = dataSize; + packedUint64MemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + foreach (int element in PackedSint32List) { + dataSize += pb::CodedOutputStream.ComputeSInt32SizeNoTag(element); } - { - int dataSize = 0; - dataSize = 8 * packedSfixed64_.Count; - size += dataSize; - if (packedSfixed64_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedSfixed64MemoizedSerializedSize = dataSize; + size += dataSize; + if (packedSint32_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { - int dataSize = 0; - dataSize = 4 * packedFloat_.Count; - size += dataSize; - if (packedFloat_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedFloatMemoizedSerializedSize = dataSize; + packedSint32MemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + foreach (long element in PackedSint64List) { + dataSize += pb::CodedOutputStream.ComputeSInt64SizeNoTag(element); } - { - int dataSize = 0; - dataSize = 8 * packedDouble_.Count; - size += dataSize; - if (packedDouble_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedDoubleMemoizedSerializedSize = dataSize; + size += dataSize; + if (packedSint64_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { - int dataSize = 0; - dataSize = 1 * packedBool_.Count; - size += dataSize; - if (packedBool_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedBoolMemoizedSerializedSize = dataSize; + packedSint64MemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + dataSize = 4 * packedFixed32_.Count; + size += dataSize; + if (packedFixed32_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { - int dataSize = 0; - if (packedEnum_.Count > 0) { - foreach (global::Google.ProtocolBuffers.TestProtos.ForeignEnum element in packedEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 2; - size += pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize); + packedFixed32MemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + dataSize = 8 * packedFixed64_.Count; + size += dataSize; + if (packedFixed64_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + } + packedFixed64MemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + dataSize = 4 * packedSfixed32_.Count; + size += dataSize; + if (packedSfixed32_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + } + packedSfixed32MemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + dataSize = 8 * packedSfixed64_.Count; + size += dataSize; + if (packedSfixed64_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + } + packedSfixed64MemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + dataSize = 4 * packedFloat_.Count; + size += dataSize; + if (packedFloat_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + } + packedFloatMemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + dataSize = 8 * packedDouble_.Count; + size += dataSize; + if (packedDouble_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + } + packedDoubleMemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + dataSize = 1 * packedBool_.Count; + size += dataSize; + if (packedBool_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + } + packedBoolMemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + if (packedEnum_.Count > 0) { + foreach (global::Google.ProtocolBuffers.TestProtos.ForeignEnum element in packedEnum_) { + dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); } - packedEnumMemoizedSerializedSize = dataSize; + size += dataSize; + size += 2; + size += pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize); } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + packedEnumMemoizedSerializedSize = dataSize; } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; } - public static TestPackedTypes ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -17796,7 +17956,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testUnpackedTypesFieldNames; if (unpackedInt32_.Count > 0) { output.WriteInt32Array(90, field_names[6], unpackedInt32_); @@ -17848,114 +18008,119 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - { - int dataSize = 0; - foreach (int element in UnpackedInt32List) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); - } - size += dataSize; - size += 2 * unpackedInt32_.Count; - } - { - int dataSize = 0; - foreach (long element in UnpackedInt64List) { - dataSize += pb::CodedOutputStream.ComputeInt64SizeNoTag(element); - } - size += dataSize; - size += 2 * unpackedInt64_.Count; - } - { - int dataSize = 0; - foreach (uint element in UnpackedUint32List) { - dataSize += pb::CodedOutputStream.ComputeUInt32SizeNoTag(element); - } - size += dataSize; - size += 2 * unpackedUint32_.Count; - } - { - int dataSize = 0; - foreach (ulong element in UnpackedUint64List) { - dataSize += pb::CodedOutputStream.ComputeUInt64SizeNoTag(element); - } - size += dataSize; - size += 2 * unpackedUint64_.Count; - } - { - int dataSize = 0; - foreach (int element in UnpackedSint32List) { - dataSize += pb::CodedOutputStream.ComputeSInt32SizeNoTag(element); + return CalcSerializedSize(); + } + } + + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + { + int dataSize = 0; + foreach (int element in UnpackedInt32List) { + dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); + } + size += dataSize; + size += 2 * unpackedInt32_.Count; + } + { + int dataSize = 0; + foreach (long element in UnpackedInt64List) { + dataSize += pb::CodedOutputStream.ComputeInt64SizeNoTag(element); + } + size += dataSize; + size += 2 * unpackedInt64_.Count; + } + { + int dataSize = 0; + foreach (uint element in UnpackedUint32List) { + dataSize += pb::CodedOutputStream.ComputeUInt32SizeNoTag(element); + } + size += dataSize; + size += 2 * unpackedUint32_.Count; + } + { + int dataSize = 0; + foreach (ulong element in UnpackedUint64List) { + dataSize += pb::CodedOutputStream.ComputeUInt64SizeNoTag(element); + } + size += dataSize; + size += 2 * unpackedUint64_.Count; + } + { + int dataSize = 0; + foreach (int element in UnpackedSint32List) { + dataSize += pb::CodedOutputStream.ComputeSInt32SizeNoTag(element); + } + size += dataSize; + size += 2 * unpackedSint32_.Count; + } + { + int dataSize = 0; + foreach (long element in UnpackedSint64List) { + dataSize += pb::CodedOutputStream.ComputeSInt64SizeNoTag(element); + } + size += dataSize; + size += 2 * unpackedSint64_.Count; + } + { + int dataSize = 0; + dataSize = 4 * unpackedFixed32_.Count; + size += dataSize; + size += 2 * unpackedFixed32_.Count; + } + { + int dataSize = 0; + dataSize = 8 * unpackedFixed64_.Count; + size += dataSize; + size += 2 * unpackedFixed64_.Count; + } + { + int dataSize = 0; + dataSize = 4 * unpackedSfixed32_.Count; + size += dataSize; + size += 2 * unpackedSfixed32_.Count; + } + { + int dataSize = 0; + dataSize = 8 * unpackedSfixed64_.Count; + size += dataSize; + size += 2 * unpackedSfixed64_.Count; + } + { + int dataSize = 0; + dataSize = 4 * unpackedFloat_.Count; + size += dataSize; + size += 2 * unpackedFloat_.Count; + } + { + int dataSize = 0; + dataSize = 8 * unpackedDouble_.Count; + size += dataSize; + size += 2 * unpackedDouble_.Count; + } + { + int dataSize = 0; + dataSize = 1 * unpackedBool_.Count; + size += dataSize; + size += 2 * unpackedBool_.Count; + } + { + int dataSize = 0; + if (unpackedEnum_.Count > 0) { + foreach (global::Google.ProtocolBuffers.TestProtos.ForeignEnum element in unpackedEnum_) { + dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); } size += dataSize; - size += 2 * unpackedSint32_.Count; - } - { - int dataSize = 0; - foreach (long element in UnpackedSint64List) { - dataSize += pb::CodedOutputStream.ComputeSInt64SizeNoTag(element); - } - size += dataSize; - size += 2 * unpackedSint64_.Count; - } - { - int dataSize = 0; - dataSize = 4 * unpackedFixed32_.Count; - size += dataSize; - size += 2 * unpackedFixed32_.Count; - } - { - int dataSize = 0; - dataSize = 8 * unpackedFixed64_.Count; - size += dataSize; - size += 2 * unpackedFixed64_.Count; - } - { - int dataSize = 0; - dataSize = 4 * unpackedSfixed32_.Count; - size += dataSize; - size += 2 * unpackedSfixed32_.Count; - } - { - int dataSize = 0; - dataSize = 8 * unpackedSfixed64_.Count; - size += dataSize; - size += 2 * unpackedSfixed64_.Count; - } - { - int dataSize = 0; - dataSize = 4 * unpackedFloat_.Count; - size += dataSize; - size += 2 * unpackedFloat_.Count; - } - { - int dataSize = 0; - dataSize = 8 * unpackedDouble_.Count; - size += dataSize; - size += 2 * unpackedDouble_.Count; - } - { - int dataSize = 0; - dataSize = 1 * unpackedBool_.Count; - size += dataSize; - size += 2 * unpackedBool_.Count; - } - { - int dataSize = 0; - if (unpackedEnum_.Count > 0) { - foreach (global::Google.ProtocolBuffers.TestProtos.ForeignEnum element in unpackedEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 2 * unpackedEnum_.Count; - } + size += 2 * unpackedEnum_.Count; } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; } - public static TestUnpackedTypes ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -18741,7 +18906,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testPackedExtensionsFieldNames; pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); extensionWriter.WriteUntil(536870912, output); @@ -18753,15 +18918,20 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - size += ExtensionsSerializedSize; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += ExtensionsSerializedSize; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static TestPackedExtensions ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -19017,7 +19187,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _dynamicMessageTypeFieldNames; if (hasDynamicField) { output.WriteInt32(2100, field_names[0], DynamicField); @@ -19030,17 +19200,22 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasDynamicField) { - size += pb::CodedOutputStream.ComputeInt32Size(2100, DynamicField); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasDynamicField) { + size += pb::CodedOutputStream.ComputeInt32Size(2100, DynamicField); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static DynamicMessageType ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -19330,7 +19505,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testDynamicExtensionsFieldNames; if (hasScalarExtension) { output.WriteFixed32(2000, field_names[6], ScalarExtension); @@ -19361,48 +19536,53 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasScalarExtension) { - size += pb::CodedOutputStream.ComputeFixed32Size(2000, ScalarExtension); - } - if (hasEnumExtension) { - size += pb::CodedOutputStream.ComputeEnumSize(2001, (int) EnumExtension); - } - if (hasDynamicEnumExtension) { - size += pb::CodedOutputStream.ComputeEnumSize(2002, (int) DynamicEnumExtension); - } - if (hasMessageExtension) { - size += pb::CodedOutputStream.ComputeMessageSize(2003, MessageExtension); - } - if (hasDynamicMessageExtension) { - size += pb::CodedOutputStream.ComputeMessageSize(2004, DynamicMessageExtension); + return CalcSerializedSize(); + } + } + + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasScalarExtension) { + size += pb::CodedOutputStream.ComputeFixed32Size(2000, ScalarExtension); + } + if (hasEnumExtension) { + size += pb::CodedOutputStream.ComputeEnumSize(2001, (int) EnumExtension); + } + if (hasDynamicEnumExtension) { + size += pb::CodedOutputStream.ComputeEnumSize(2002, (int) DynamicEnumExtension); + } + if (hasMessageExtension) { + size += pb::CodedOutputStream.ComputeMessageSize(2003, MessageExtension); + } + if (hasDynamicMessageExtension) { + size += pb::CodedOutputStream.ComputeMessageSize(2004, DynamicMessageExtension); + } + { + int dataSize = 0; + foreach (string element in RepeatedExtensionList) { + dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); } - { - int dataSize = 0; - foreach (string element in RepeatedExtensionList) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedExtension_.Count; + size += dataSize; + size += 2 * repeatedExtension_.Count; + } + { + int dataSize = 0; + foreach (int element in PackedExtensionList) { + dataSize += pb::CodedOutputStream.ComputeSInt32SizeNoTag(element); } - { - int dataSize = 0; - foreach (int element in PackedExtensionList) { - dataSize += pb::CodedOutputStream.ComputeSInt32SizeNoTag(element); - } - size += dataSize; - if (packedExtension_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedExtensionMemoizedSerializedSize = dataSize; + size += dataSize; + if (packedExtension_.Count != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + packedExtensionMemoizedSerializedSize = dataSize; } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; } - public static TestDynamicExtensions ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -19972,7 +20152,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _testRepeatedScalarDifferentTagSizesFieldNames; if (repeatedFixed32_.Count > 0) { output.WriteFixed32Array(12, field_names[0], repeatedFixed32_); @@ -20000,56 +20180,61 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - { - int dataSize = 0; - dataSize = 4 * repeatedFixed32_.Count; - size += dataSize; - size += 1 * repeatedFixed32_.Count; - } - { - int dataSize = 0; - foreach (int element in RepeatedInt32List) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); - } - size += dataSize; - size += 1 * repeatedInt32_.Count; - } - { - int dataSize = 0; - dataSize = 8 * repeatedFixed64_.Count; - size += dataSize; - size += 2 * repeatedFixed64_.Count; - } - { - int dataSize = 0; - foreach (long element in RepeatedInt64List) { - dataSize += pb::CodedOutputStream.ComputeInt64SizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedInt64_.Count; + return CalcSerializedSize(); + } + } + + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + { + int dataSize = 0; + dataSize = 4 * repeatedFixed32_.Count; + size += dataSize; + size += 1 * repeatedFixed32_.Count; + } + { + int dataSize = 0; + foreach (int element in RepeatedInt32List) { + dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); } - { - int dataSize = 0; - dataSize = 4 * repeatedFloat_.Count; - size += dataSize; - size += 3 * repeatedFloat_.Count; + size += dataSize; + size += 1 * repeatedInt32_.Count; + } + { + int dataSize = 0; + dataSize = 8 * repeatedFixed64_.Count; + size += dataSize; + size += 2 * repeatedFixed64_.Count; + } + { + int dataSize = 0; + foreach (long element in RepeatedInt64List) { + dataSize += pb::CodedOutputStream.ComputeInt64SizeNoTag(element); } - { - int dataSize = 0; - foreach (ulong element in RepeatedUint64List) { - dataSize += pb::CodedOutputStream.ComputeUInt64SizeNoTag(element); - } - size += dataSize; - size += 3 * repeatedUint64_.Count; + size += dataSize; + size += 2 * repeatedInt64_.Count; + } + { + int dataSize = 0; + dataSize = 4 * repeatedFloat_.Count; + size += dataSize; + size += 3 * repeatedFloat_.Count; + } + { + int dataSize = 0; + foreach (ulong element in RepeatedUint64List) { + dataSize += pb::CodedOutputStream.ComputeUInt64SizeNoTag(element); } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + size += dataSize; + size += 3 * repeatedUint64_.Count; } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; } - public static TestRepeatedScalarDifferentTagSizes ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -20508,7 +20693,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _fooRequestFieldNames; UnknownFields.WriteTo(output); } @@ -20518,14 +20703,19 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static FooRequest ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -20735,7 +20925,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _fooResponseFieldNames; UnknownFields.WriteTo(output); } @@ -20745,14 +20935,19 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static FooResponse ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -20962,7 +21157,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _barRequestFieldNames; UnknownFields.WriteTo(output); } @@ -20972,14 +21167,19 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static BarRequest ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } @@ -21189,7 +21389,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _barResponseFieldNames; UnknownFields.WriteTo(output); } @@ -21199,14 +21399,19 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } public static BarResponse ParseFrom(pb::ByteString data) { return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); } diff --git a/src/ProtocolBuffersLite.Test/TestProtos/UnitTestRpcInteropLite.cs b/src/ProtocolBuffersLite.Test/TestProtos/UnitTestRpcInteropLite.cs index de347f382f..22e4882837 100644 --- a/src/ProtocolBuffersLite.Test/TestProtos/UnitTestRpcInteropLite.cs +++ b/src/ProtocolBuffersLite.Test/TestProtos/UnitTestRpcInteropLite.cs @@ -63,7 +63,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _searchRequestFieldNames; if (criteria_.Count > 0) { output.WriteStringArray(1, field_names[0], criteria_); @@ -75,21 +75,26 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - { - int dataSize = 0; - foreach (string element in CriteriaList) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); - } - size += dataSize; - size += 1 * criteria_.Count; - } - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + { + int dataSize = 0; + foreach (string element in CriteriaList) { + dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); + } + size += dataSize; + size += 1 * criteria_.Count; + } + memoizedSerializedSize = size; + return size; + } #region Lite runtime methods public override int GetHashCode() { int hash = GetType().GetHashCode(); @@ -377,7 +382,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _resultItemFieldNames; if (hasUrl) { output.WriteString(1, field_names[1], Url); @@ -392,19 +397,24 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - if (hasUrl) { - size += pb::CodedOutputStream.ComputeStringSize(1, Url); - } - if (hasName) { - size += pb::CodedOutputStream.ComputeStringSize(2, Name); - } - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasUrl) { + size += pb::CodedOutputStream.ComputeStringSize(1, Url); + } + if (hasName) { + size += pb::CodedOutputStream.ComputeStringSize(2, Name); + } + memoizedSerializedSize = size; + return size; + } #region Lite runtime methods public override int GetHashCode() { int hash = GetType().GetHashCode(); @@ -666,7 +676,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _searchResponseFieldNames; if (results_.Count > 0) { output.WriteMessageArray(1, field_names[0], results_); @@ -678,16 +688,21 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - foreach (global::Google.ProtocolBuffers.TestProtos.SearchResponse.Types.ResultItem element in ResultsList) { - size += pb::CodedOutputStream.ComputeMessageSize(1, element); - } - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + foreach (global::Google.ProtocolBuffers.TestProtos.SearchResponse.Types.ResultItem element in ResultsList) { + size += pb::CodedOutputStream.ComputeMessageSize(1, element); + } + memoizedSerializedSize = size; + return size; + } #region Lite runtime methods public override int GetHashCode() { int hash = GetType().GetHashCode(); @@ -969,7 +984,7 @@ namespace Google.ProtocolBuffers.TestProtos { } public override void WriteTo(pb::ICodedOutputStream output) { - int size = SerializedSize; + CalcSerializedSize(); string[] field_names = _refineSearchRequestFieldNames; if (criteria_.Count > 0) { output.WriteStringArray(1, field_names[0], criteria_); @@ -984,24 +999,29 @@ namespace Google.ProtocolBuffers.TestProtos { get { int size = memoizedSerializedSize; if (size != -1) return size; - - size = 0; - { - int dataSize = 0; - foreach (string element in CriteriaList) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); - } - size += dataSize; - size += 1 * criteria_.Count; - } - if (hasPreviousResults) { - size += pb::CodedOutputStream.ComputeMessageSize(2, PreviousResults); - } - memoizedSerializedSize = size; - return size; + return CalcSerializedSize(); } } + private int CalcSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + { + int dataSize = 0; + foreach (string element in CriteriaList) { + dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); + } + size += dataSize; + size += 1 * criteria_.Count; + } + if (hasPreviousResults) { + size += pb::CodedOutputStream.ComputeMessageSize(2, PreviousResults); + } + memoizedSerializedSize = size; + return size; + } #region Lite runtime methods public override int GetHashCode() { int hash = GetType().GetHashCode();