diff --git a/.gitignore b/.gitignore index 5e38bbf7c283..bf298f658b50 100644 --- a/.gitignore +++ b/.gitignore @@ -208,3 +208,6 @@ cmake/cmake-build-debug/ # IntelliJ .idea *.iml + +# Visual Studio test coverage +*.coverage diff --git a/Makefile.am b/Makefile.am index 079ac7062bd7..06450a23fc84 100644 --- a/Makefile.am +++ b/Makefile.am @@ -87,6 +87,7 @@ csharp_EXTRA_DIST= \ csharp/src/AddressBook/SampleUsage.cs \ csharp/src/Google.Protobuf.Benchmarks/BenchmarkMessage1Proto3.cs \ csharp/src/Google.Protobuf.Benchmarks/Benchmarks.cs \ + csharp/src/Google.Protobuf.Benchmarks/GoogleMessageBenchmark.cs \ csharp/src/Google.Protobuf.Benchmarks/Google.Protobuf.Benchmarks.csproj \ csharp/src/Google.Protobuf.Benchmarks/Program.cs \ csharp/src/Google.Protobuf.Benchmarks/SerializationBenchmark.cs \ @@ -100,9 +101,16 @@ csharp_EXTRA_DIST= \ csharp/src/Google.Protobuf.JsonDump/Google.Protobuf.JsonDump.csproj \ csharp/src/Google.Protobuf.JsonDump/Program.cs \ csharp/src/Google.Protobuf.Test/ByteStringTest.cs \ - csharp/src/Google.Protobuf.Test/CodedInputStreamExtensions.cs \ + csharp/src/Google.Protobuf.Test/CodedInputExtensions.cs \ + csharp/src/Google.Protobuf.Test/CodedInputReaderTest.cs \ csharp/src/Google.Protobuf.Test/CodedInputStreamTest.cs \ + csharp/src/Google.Protobuf.Test/CodedInputTestBase.cs \ csharp/src/Google.Protobuf.Test/CodedOutputStreamTest.cs \ + csharp/src/Google.Protobuf.Test/CodedOutputWriterTest.cs \ + csharp/src/Google.Protobuf.Test/CodedOutputTestBase.cs \ + csharp/src/Google.Protobuf.Test/Buffers/ArrayBufferWriter.cs \ + csharp/src/Google.Protobuf.Test/Buffers/MaxSizeHintBufferWriter.cs \ + csharp/src/Google.Protobuf.Test/Buffers/ReadOnlySequenceFactory.cs \ csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs \ csharp/src/Google.Protobuf.Test/Collections/ProtobufEqualityComparersTest.cs \ csharp/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs \ @@ -121,6 +129,7 @@ csharp_EXTRA_DIST= \ csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs \ csharp/src/Google.Protobuf.Test/JsonParserTest.cs \ csharp/src/Google.Protobuf.Test/JsonTokenizerTest.cs \ + csharp/src/Google.Protobuf.Test/MessageParsingHelpers.cs \ csharp/src/Google.Protobuf.Test/Reflection/CustomOptionsTest.cs \ csharp/src/Google.Protobuf.Test/Reflection/DescriptorDeclarationTest.cs \ csharp/src/Google.Protobuf.Test/Reflection/DescriptorsTest.cs \ @@ -160,8 +169,10 @@ csharp_EXTRA_DIST= \ csharp/src/Google.Protobuf/ByteArray.cs \ csharp/src/Google.Protobuf/ByteString.cs \ csharp/src/Google.Protobuf/CodedInputStream.cs \ + csharp/src/Google.Protobuf/CodedInputReader.cs \ csharp/src/Google.Protobuf/CodedOutputStream.ComputeSize.cs \ csharp/src/Google.Protobuf/CodedOutputStream.cs \ + csharp/src/Google.Protobuf/CodedOutputWriter.cs \ csharp/src/Google.Protobuf/Collections/Lists.cs \ csharp/src/Google.Protobuf/Collections/MapField.cs \ csharp/src/Google.Protobuf/Collections/ProtobufEqualityComparers.cs \ @@ -179,6 +190,7 @@ csharp_EXTRA_DIST= \ csharp/src/Google.Protobuf/FieldMaskTree.cs \ csharp/src/Google.Protobuf/FrameworkPortability.cs \ csharp/src/Google.Protobuf/Google.Protobuf.csproj \ + csharp/src/Google.Protobuf/IBufferMessage.cs \ csharp/src/Google.Protobuf/ICustomDiagnosticMessage.cs \ csharp/src/Google.Protobuf/IDeepCloneable.cs \ csharp/src/Google.Protobuf/IExtendableMessage.cs \ @@ -225,6 +237,7 @@ csharp_EXTRA_DIST= \ csharp/src/Google.Protobuf/Reflection/ServiceDescriptor.cs \ csharp/src/Google.Protobuf/Reflection/SingleFieldAccessor.cs \ csharp/src/Google.Protobuf/Reflection/TypeRegistry.cs \ + csharp/src/Google.Protobuf/SequenceReader.cs \ csharp/src/Google.Protobuf/WellKnownTypes/Any.cs \ csharp/src/Google.Protobuf/WellKnownTypes/AnyPartial.cs \ csharp/src/Google.Protobuf/WellKnownTypes/Api.cs \ diff --git a/conformance/Makefile.am b/conformance/Makefile.am index 6815c733a522..6e0505b41355 100644 --- a/conformance/Makefile.am +++ b/conformance/Makefile.am @@ -343,6 +343,7 @@ test_java_lite: protoc_middleman conformance-test-runner conformance-java-lite test_csharp: protoc_middleman conformance-test-runner conformance-csharp ./conformance-test-runner --enforce_recommended --failure_list failure_list_csharp.txt --text_format_failure_list text_format_failure_list_csharp.txt ./conformance-csharp + ./conformance-test-runner --enforce_recommended --failure_list failure_list_csharp.txt --text_format_failure_list text_format_failure_list_csharp.txt ./conformance-csharp --use_buffer_serialization test_ruby: protoc_middleman conformance-test-runner $(other_language_protoc_outputs) RUBYLIB=../ruby/lib:. ./conformance-test-runner --enforce_recommended --failure_list failure_list_ruby.txt --text_format_failure_list text_format_failure_list_ruby.txt ./conformance_ruby.rb diff --git a/csharp/generate_protos.sh b/csharp/generate_protos.sh index e6687c308e47..c4285ce6e508 100755 --- a/csharp/generate_protos.sh +++ b/csharp/generate_protos.sh @@ -27,7 +27,7 @@ fi # descriptor.proto and well-known types $PROTOC -Isrc --csharp_out=csharp/src/Google.Protobuf \ - --csharp_opt=base_namespace=Google.Protobuf \ + --csharp_opt=base_namespace=Google.Protobuf,use_buffer_serialization \ src/google/protobuf/descriptor.proto \ src/google/protobuf/any.proto \ src/google/protobuf/api.proto \ @@ -46,6 +46,7 @@ $PROTOC -Isrc --csharp_out=csharp/src/Google.Protobuf \ # of protoc. $PROTOC -Isrc -Icsharp/protos \ --csharp_out=csharp/src/Google.Protobuf.Test.TestProtos \ + --csharp_opt=use_buffer_serialization \ --descriptor_set_out=csharp/src/Google.Protobuf.Test/testprotos.pb \ --include_source_info \ --include_imports \ @@ -67,18 +68,22 @@ $PROTOC -Isrc -Icsharp/protos \ # AddressBook sample protos $PROTOC -Iexamples -Isrc --csharp_out=csharp/src/AddressBook \ + --csharp_opt=use_buffer_serialization \ examples/addressbook.proto $PROTOC -Iconformance -Isrc --csharp_out=csharp/src/Google.Protobuf.Conformance \ + --csharp_opt=use_buffer_serialization \ conformance/conformance.proto # Benchmark protos $PROTOC -Ibenchmarks \ benchmarks/datasets/google_message1/proto3/*.proto \ benchmarks/benchmarks.proto \ - --csharp_out=csharp/src/Google.Protobuf.Benchmarks + --csharp_out=csharp/src/Google.Protobuf.Benchmarks \ + --csharp_opt=use_buffer_serialization # C# only benchmark protos $PROTOC -Isrc -Icsharp/src/Google.Protobuf.Benchmarks \ csharp/src/Google.Protobuf.Benchmarks/*.proto \ - --csharp_out=csharp/src/Google.Protobuf.Benchmarks + --csharp_out=csharp/src/Google.Protobuf.Benchmarks \ + --csharp_opt=use_buffer_serialization diff --git a/csharp/src/AddressBook/Addressbook.cs b/csharp/src/AddressBook/Addressbook.cs index cbd977269620..9e90930d2c9b 100644 --- a/csharp/src/AddressBook/Addressbook.cs +++ b/csharp/src/AddressBook/Addressbook.cs @@ -49,7 +49,11 @@ public static partial class AddressbookReflection { /// /// [START messages] /// - public sealed partial class Person : pb::IMessage { + public sealed partial class Person : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Person()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -208,6 +212,33 @@ public sealed partial class Person : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (Name.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Name); + } + if (Id != 0) { + output.WriteRawTag(16); + output.WriteInt32(Id); + } + if (Email.Length != 0) { + output.WriteRawTag(26); + output.WriteString(Email); + } + phones_.WriteTo(ref output, _repeated_phones_codec); + if (lastUpdated_ != null) { + output.WriteRawTag(42); + output.WriteMessage(LastUpdated); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -289,6 +320,44 @@ public sealed partial class Person : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + Name = input.ReadString(); + break; + } + case 16: { + Id = input.ReadInt32(); + break; + } + case 26: { + Email = input.ReadString(); + break; + } + case 34: { + phones_.AddEntriesFrom(ref input, _repeated_phones_codec); + break; + } + case 42: { + if (lastUpdated_ == null) { + LastUpdated = new global::Google.Protobuf.WellKnownTypes.Timestamp(); + } + input.ReadMessage(LastUpdated); + break; + } + } + } + } + #endif + #region Nested types /// Container for nested types declared in the Person message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -299,7 +368,11 @@ public enum PhoneType { [pbr::OriginalName("WORK")] Work = 2, } - public sealed partial class PhoneNumber : pb::IMessage { + public sealed partial class PhoneNumber : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new PhoneNumber()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -405,6 +478,24 @@ public sealed partial class PhoneNumber : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (Number.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Number); + } + if (Type != global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType.Mobile) { + output.WriteRawTag(16); + output.WriteEnum((int) Type); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -454,6 +545,29 @@ public sealed partial class PhoneNumber : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + Number = input.ReadString(); + break; + } + case 16: { + Type = (global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType) input.ReadEnum(); + break; + } + } + } + } + #endif + } } @@ -464,7 +578,11 @@ public sealed partial class PhoneNumber : pb::IMessage { /// /// Our address book file is just one of these. /// - public sealed partial class AddressBook : pb::IMessage { + public sealed partial class AddressBook : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new AddressBook()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -548,6 +666,17 @@ public sealed partial class AddressBook : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + people_.WriteTo(ref output, _repeated_people_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -583,6 +712,25 @@ public sealed partial class AddressBook : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + people_.AddEntriesFrom(ref input, _repeated_people_codec); + break; + } + } + } + } + #endif + } #endregion diff --git a/csharp/src/Google.Protobuf.Benchmarks/BenchmarkMessage1Proto3.cs b/csharp/src/Google.Protobuf.Benchmarks/BenchmarkMessage1Proto3.cs index 9e8c330a2b63..b1231c100269 100644 --- a/csharp/src/Google.Protobuf.Benchmarks/BenchmarkMessage1Proto3.cs +++ b/csharp/src/Google.Protobuf.Benchmarks/BenchmarkMessage1Proto3.cs @@ -64,7 +64,11 @@ public static partial class BenchmarkMessage1Proto3Reflection { } #region Messages - public sealed partial class GoogleMessage1 : pb::IMessage { + public sealed partial class GoogleMessage1 : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new GoogleMessage1()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -868,6 +872,177 @@ public sealed partial class GoogleMessage1 : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (Field1.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Field1); + } + if (Field2 != 0) { + output.WriteRawTag(16); + output.WriteInt32(Field2); + } + if (Field3 != 0) { + output.WriteRawTag(24); + output.WriteInt32(Field3); + } + if (Field4.Length != 0) { + output.WriteRawTag(34); + output.WriteString(Field4); + } + field5_.WriteTo(ref output, _repeated_field5_codec); + if (Field6 != 0) { + output.WriteRawTag(48); + output.WriteInt32(Field6); + } + if (Field7.Length != 0) { + output.WriteRawTag(58); + output.WriteString(Field7); + } + if (Field9.Length != 0) { + output.WriteRawTag(74); + output.WriteString(Field9); + } + if (Field12 != false) { + output.WriteRawTag(96); + output.WriteBool(Field12); + } + if (Field13 != false) { + output.WriteRawTag(104); + output.WriteBool(Field13); + } + if (Field14 != false) { + output.WriteRawTag(112); + output.WriteBool(Field14); + } + if (field15_ != null) { + output.WriteRawTag(122); + output.WriteMessage(Field15); + } + if (Field16 != 0) { + output.WriteRawTag(128, 1); + output.WriteInt32(Field16); + } + if (Field17 != false) { + output.WriteRawTag(136, 1); + output.WriteBool(Field17); + } + if (Field18.Length != 0) { + output.WriteRawTag(146, 1); + output.WriteString(Field18); + } + if (Field22 != 0L) { + output.WriteRawTag(176, 1); + output.WriteInt64(Field22); + } + if (Field23 != 0) { + output.WriteRawTag(184, 1); + output.WriteInt32(Field23); + } + if (Field24 != false) { + output.WriteRawTag(192, 1); + output.WriteBool(Field24); + } + if (Field25 != 0) { + output.WriteRawTag(200, 1); + output.WriteInt32(Field25); + } + if (Field29 != 0) { + output.WriteRawTag(232, 1); + output.WriteInt32(Field29); + } + if (Field30 != false) { + output.WriteRawTag(240, 1); + output.WriteBool(Field30); + } + if (Field59 != false) { + output.WriteRawTag(216, 3); + output.WriteBool(Field59); + } + if (Field60 != 0) { + output.WriteRawTag(224, 3); + output.WriteInt32(Field60); + } + if (Field67 != 0) { + output.WriteRawTag(152, 4); + output.WriteInt32(Field67); + } + if (Field68 != 0) { + output.WriteRawTag(160, 4); + output.WriteInt32(Field68); + } + if (Field78 != false) { + output.WriteRawTag(240, 4); + output.WriteBool(Field78); + } + if (Field80 != false) { + output.WriteRawTag(128, 5); + output.WriteBool(Field80); + } + if (Field81 != false) { + output.WriteRawTag(136, 5); + output.WriteBool(Field81); + } + if (Field100 != 0) { + output.WriteRawTag(160, 6); + output.WriteInt32(Field100); + } + if (Field101 != 0) { + output.WriteRawTag(168, 6); + output.WriteInt32(Field101); + } + if (Field102.Length != 0) { + output.WriteRawTag(178, 6); + output.WriteString(Field102); + } + if (Field103.Length != 0) { + output.WriteRawTag(186, 6); + output.WriteString(Field103); + } + if (Field104 != 0) { + output.WriteRawTag(192, 6); + output.WriteInt32(Field104); + } + if (Field128 != 0) { + output.WriteRawTag(128, 8); + output.WriteInt32(Field128); + } + if (Field129.Length != 0) { + output.WriteRawTag(138, 8); + output.WriteString(Field129); + } + if (Field130 != 0) { + output.WriteRawTag(144, 8); + output.WriteInt32(Field130); + } + if (Field131 != 0) { + output.WriteRawTag(152, 8); + output.WriteInt32(Field131); + } + if (Field150 != 0) { + output.WriteRawTag(176, 9); + output.WriteInt32(Field150); + } + if (Field271 != 0) { + output.WriteRawTag(248, 16); + output.WriteInt32(Field271); + } + if (Field272 != 0) { + output.WriteRawTag(128, 17); + output.WriteInt32(Field272); + } + if (Field280 != 0) { + output.WriteRawTag(192, 17); + output.WriteInt32(Field280); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -1107,36 +1282,218 @@ public sealed partial class GoogleMessage1 : pb::IMessage { if (field15_ == null) { Field15 = new global::Benchmarks.Proto3.GoogleMessage1SubMessage(); } - Field15.MergeFrom(other.Field15); - } - if (other.Field78 != false) { - Field78 = other.Field78; - } - if (other.Field67 != 0) { - Field67 = other.Field67; - } - if (other.Field68 != 0) { - Field68 = other.Field68; - } - if (other.Field128 != 0) { - Field128 = other.Field128; - } - if (other.Field129.Length != 0) { - Field129 = other.Field129; - } - if (other.Field131 != 0) { - Field131 = other.Field131; + Field15.MergeFrom(other.Field15); + } + if (other.Field78 != false) { + Field78 = other.Field78; + } + if (other.Field67 != 0) { + Field67 = other.Field67; + } + if (other.Field68 != 0) { + Field68 = other.Field68; + } + if (other.Field128 != 0) { + Field128 = other.Field128; + } + if (other.Field129.Length != 0) { + Field129 = other.Field129; + } + if (other.Field131 != 0) { + Field131 = other.Field131; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + Field1 = input.ReadString(); + break; + } + case 16: { + Field2 = input.ReadInt32(); + break; + } + case 24: { + Field3 = input.ReadInt32(); + break; + } + case 34: { + Field4 = input.ReadString(); + break; + } + case 42: + case 41: { + field5_.AddEntriesFrom(input, _repeated_field5_codec); + break; + } + case 48: { + Field6 = input.ReadInt32(); + break; + } + case 58: { + Field7 = input.ReadString(); + break; + } + case 74: { + Field9 = input.ReadString(); + break; + } + case 96: { + Field12 = input.ReadBool(); + break; + } + case 104: { + Field13 = input.ReadBool(); + break; + } + case 112: { + Field14 = input.ReadBool(); + break; + } + case 122: { + if (field15_ == null) { + Field15 = new global::Benchmarks.Proto3.GoogleMessage1SubMessage(); + } + input.ReadMessage(Field15); + break; + } + case 128: { + Field16 = input.ReadInt32(); + break; + } + case 136: { + Field17 = input.ReadBool(); + break; + } + case 146: { + Field18 = input.ReadString(); + break; + } + case 176: { + Field22 = input.ReadInt64(); + break; + } + case 184: { + Field23 = input.ReadInt32(); + break; + } + case 192: { + Field24 = input.ReadBool(); + break; + } + case 200: { + Field25 = input.ReadInt32(); + break; + } + case 232: { + Field29 = input.ReadInt32(); + break; + } + case 240: { + Field30 = input.ReadBool(); + break; + } + case 472: { + Field59 = input.ReadBool(); + break; + } + case 480: { + Field60 = input.ReadInt32(); + break; + } + case 536: { + Field67 = input.ReadInt32(); + break; + } + case 544: { + Field68 = input.ReadInt32(); + break; + } + case 624: { + Field78 = input.ReadBool(); + break; + } + case 640: { + Field80 = input.ReadBool(); + break; + } + case 648: { + Field81 = input.ReadBool(); + break; + } + case 800: { + Field100 = input.ReadInt32(); + break; + } + case 808: { + Field101 = input.ReadInt32(); + break; + } + case 818: { + Field102 = input.ReadString(); + break; + } + case 826: { + Field103 = input.ReadString(); + break; + } + case 832: { + Field104 = input.ReadInt32(); + break; + } + case 1024: { + Field128 = input.ReadInt32(); + break; + } + case 1034: { + Field129 = input.ReadString(); + break; + } + case 1040: { + Field130 = input.ReadInt32(); + break; + } + case 1048: { + Field131 = input.ReadInt32(); + break; + } + case 1200: { + Field150 = input.ReadInt32(); + break; + } + case 2168: { + Field271 = input.ReadInt32(); + break; + } + case 2176: { + Field272 = input.ReadInt32(); + break; + } + case 2240: { + Field280 = input.ReadInt32(); + break; + } + } } - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(pb::CodedInputStream input) { + public void MergeFrom(ref pb::CodedInputReader input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { Field1 = input.ReadString(); @@ -1156,7 +1513,7 @@ public sealed partial class GoogleMessage1 : pb::IMessage { } case 42: case 41: { - field5_.AddEntriesFrom(input, _repeated_field5_codec); + field5_.AddEntriesFrom(ref input, _repeated_field5_codec); break; } case 48: { @@ -1309,10 +1666,15 @@ public sealed partial class GoogleMessage1 : pb::IMessage { } } } + #endif } - public sealed partial class GoogleMessage1SubMessage : pb::IMessage { + public sealed partial class GoogleMessage1SubMessage : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new GoogleMessage1SubMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1742,6 +2104,96 @@ public sealed partial class GoogleMessage1SubMessage : pb::IMessage { + public sealed partial class BenchmarkDataset : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new BenchmarkDataset()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -186,6 +190,25 @@ public sealed partial class BenchmarkDataset : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (Name.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Name); + } + if (MessageName.Length != 0) { + output.WriteRawTag(18); + output.WriteString(MessageName); + } + payload_.WriteTo(ref output, _repeated_payload_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -241,6 +264,33 @@ public sealed partial class BenchmarkDataset : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + Name = input.ReadString(); + break; + } + case 18: { + MessageName = input.ReadString(); + break; + } + case 26: { + payload_.AddEntriesFrom(ref input, _repeated_payload_codec); + break; + } + } + } + } + #endif + } #endregion diff --git a/csharp/src/Google.Protobuf.Benchmarks/Google.Protobuf.Benchmarks.csproj b/csharp/src/Google.Protobuf.Benchmarks/Google.Protobuf.Benchmarks.csproj index ecc064ea7d09..69b985ec97a5 100644 --- a/csharp/src/Google.Protobuf.Benchmarks/Google.Protobuf.Benchmarks.csproj +++ b/csharp/src/Google.Protobuf.Benchmarks/Google.Protobuf.Benchmarks.csproj @@ -2,15 +2,21 @@ Exe - netcoreapp2.1 + netcoreapp3.0 False + $(DefineConstants);GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY - + + + + + + diff --git a/csharp/src/Google.Protobuf.Benchmarks/GoogleMessageBenchmark.cs b/csharp/src/Google.Protobuf.Benchmarks/GoogleMessageBenchmark.cs new file mode 100644 index 000000000000..2720f75ba2bc --- /dev/null +++ b/csharp/src/Google.Protobuf.Benchmarks/GoogleMessageBenchmark.cs @@ -0,0 +1,114 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2019 Google Inc. All rights reserved. +// https://github.com/protocolbuffers/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; +using System.IO; +using Benchmarks; +using Benchmarks.Proto3; + +namespace Google.Protobuf.Benchmarks +{ + public static class GoogleMessageBenchmark + { + public static ByteString GetMessageData(MessageSize messageSize) + { + var ms = new MemoryStream(); + var output = new CodedOutputStream(ms); + + var googleMessage1 = new GoogleMessage1(); + switch (messageSize) + { + case MessageSize.Empty: + break; + case MessageSize.Small: + SetString(googleMessage1, 1); + AddRepeatingItems(googleMessage1, 1); + googleMessage1.Field2 = 2; + googleMessage1.Field15 = new GoogleMessage1SubMessage(); + googleMessage1.Field15.Field1 = 1; + break; + case MessageSize.Medium: + SetString(googleMessage1, 1024); + AddRepeatingItems(googleMessage1, 1024); + googleMessage1.Field2 = 2; + googleMessage1.Field15 = new GoogleMessage1SubMessage(); + googleMessage1.Field15.Field1 = 1; + break; + case MessageSize.Large: + SetString(googleMessage1, 1024 * 512); + AddRepeatingItems(googleMessage1, 1024 * 512); + googleMessage1.Field2 = 2; + googleMessage1.Field15 = new GoogleMessage1SubMessage(); + googleMessage1.Field15.Field1 = 1; + break; + default: + throw new ArgumentOutOfRangeException(nameof(MessageSize)); + } + + googleMessage1.WriteTo(output); + output.Flush(); + + return ByteString.CopyFrom(ms.ToArray()); + } + + private static void SetString(GoogleMessage1 googleMessage1, int count) + { + googleMessage1.Field1 = "Text" + new string('!', count); + } + + private static void AddRepeatingItems(GoogleMessage1 googleMessage1, ulong count) + { + for (var i = 0UL; i < count; i++) + { + googleMessage1.Field5.Add(i); + } + } + + public static SerializationConfig CreateGoogleMessageConfig(MessageSize messageSize) + { + return new SerializationConfig(new BenchmarkDataset + { + MessageName = "benchmarks.proto3.GoogleMessage1", + Name = "GoogleMessage1 " + messageSize, + Payload = { GoogleMessageBenchmark.GetMessageData(messageSize) } + }); + } + } + + public enum MessageSize + { + Empty, + Small, + Medium, + Large + } +} diff --git a/csharp/src/Google.Protobuf.Benchmarks/Program.cs b/csharp/src/Google.Protobuf.Benchmarks/Program.cs index 1f77a26135eb..7acdd38184bd 100644 --- a/csharp/src/Google.Protobuf.Benchmarks/Program.cs +++ b/csharp/src/Google.Protobuf.Benchmarks/Program.cs @@ -30,6 +30,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #endregion +using System; using BenchmarkDotNet.Running; namespace Google.Protobuf.Benchmarks @@ -44,6 +45,4 @@ public static void Main(string[] args) BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args); } } - - } diff --git a/csharp/src/Google.Protobuf.Benchmarks/SerializationBenchmark.cs b/csharp/src/Google.Protobuf.Benchmarks/SerializationBenchmark.cs index d8c2ec11d73e..34f3a9167fe8 100644 --- a/csharp/src/Google.Protobuf.Benchmarks/SerializationBenchmark.cs +++ b/csharp/src/Google.Protobuf.Benchmarks/SerializationBenchmark.cs @@ -31,8 +31,13 @@ #endregion using BenchmarkDotNet.Attributes; +using Benchmarks; +using Google.Protobuf.Buffers; +using System; +using System.Buffers; using System.Collections.Generic; using System.IO; +using System.IO.Pipelines; using System.Linq; namespace Google.Protobuf.Benchmarks @@ -50,7 +55,11 @@ public class SerializationBenchmark /// public static SerializationConfig[] Configurations => new[] { - new SerializationConfig("dataset.google_message1_proto3.pb") + new SerializationConfig("dataset.google_message1_proto3.pb"), + GoogleMessageBenchmark.CreateGoogleMessageConfig(MessageSize.Empty), + GoogleMessageBenchmark.CreateGoogleMessageConfig(MessageSize.Small), + GoogleMessageBenchmark.CreateGoogleMessageConfig(MessageSize.Medium), + GoogleMessageBenchmark.CreateGoogleMessageConfig(MessageSize.Large) }; [ParamsSource(nameof(Configurations))] @@ -68,53 +77,142 @@ public class SerializationBenchmark public void GlobalSetup() { parser = Configuration.Parser; - subTests = Configuration.Payloads.Select(p => new SubTest(p, parser.ParseFrom(p))).ToList(); + subTests = Configuration.Payloads.Select(p => new SubTest(p, (IBufferMessage)parser.ParseFrom(p))).ToList(); } [Benchmark] - public void WriteToStream() => subTests.ForEach(item => item.WriteToStream()); + public void WriteToStream() + { + foreach (var subTest in subTests) + { + subTest.WriteToStream(); + } + } + + [Benchmark] + public void WriteToBufferWriter() + { + foreach (var subTest in subTests) + { + subTest.WriteToBufferWriter(); + } + } + + [Benchmark] + public void WriteToPipeWriter() + { + foreach (var subTest in subTests) + { + subTest.WriteToPipeWriter(); + } + } + + [Benchmark] + public void ToByteArray() + { + foreach (var subTest in subTests) + { + subTest.ToByteArray(); + } + } + + [Benchmark] + public void ParseFromByteString() + { + foreach (var subTest in subTests) + { + subTest.ParseFromByteString(parser); + } + } [Benchmark] - public void ToByteArray() => subTests.ForEach(item => item.ToByteArray()); + public void ParseFromNewByteString() + { + foreach (var subTest in subTests) + { + subTest.ParseFromNewByteString(parser); + } + } [Benchmark] - public void ParseFromByteString() => subTests.ForEach(item => item.ParseFromByteString(parser)); + public void ParseFromStream() + { + foreach (var subTest in subTests) + { + subTest.ParseFromStream(parser); + } + } [Benchmark] - public void ParseFromStream() => subTests.ForEach(item => item.ParseFromStream(parser)); + public void ParseFromReadOnlySequence() + { + foreach (var subTest in subTests) + { + subTest.ParseFromReadOnlySequence(parser); + } + } private class SubTest { private readonly Stream destinationStream; + private readonly Google.Protobuf.Buffers.ArrayBufferWriter bufferWriter; private readonly Stream sourceStream; + private readonly ReadOnlySequence readOnlySequence; private readonly ByteString data; - private readonly IMessage message; + private readonly IBufferMessage message; + private readonly Pipe pipe; - public SubTest(ByteString data, IMessage message) + public SubTest(ByteString data, IBufferMessage message) { destinationStream = new MemoryStream(data.Length); + bufferWriter = new Google.Protobuf.Buffers.ArrayBufferWriter(); sourceStream = new MemoryStream(data.ToByteArray()); + readOnlySequence = new ReadOnlySequence(data.ToByteArray()); + pipe = new Pipe(); this.data = data; this.message = message; } - public void Reset() => destinationStream.Position = 0; - public void WriteToStream() { destinationStream.Position = 0; message.WriteTo(destinationStream); } + public void WriteToPipeWriter() + { + var writer = new CodedOutputWriter(pipe.Writer); + message.WriteTo(ref writer); + + pipe.Writer.Complete(); + pipe.Reader.Complete(); + pipe.Reset(); + } + + public void WriteToBufferWriter() + { + bufferWriter.Clear(); + var writer = new CodedOutputWriter(bufferWriter); + message.WriteTo(ref writer); + } + public void ToByteArray() => message.ToByteArray(); public void ParseFromByteString(MessageParser parser) => parser.ParseFrom(data); + public void ParseFromNewByteString(MessageParser parser) => parser.ParseFrom(readOnlySequence.ToArray()); + public void ParseFromStream(MessageParser parser) { sourceStream.Position = 0; parser.ParseFrom(sourceStream); } + + public void ParseFromReadOnlySequence(MessageParser parser) + { + var reader = new CodedInputReader(readOnlySequence); + parser.ParseFrom(ref reader); + } } } } diff --git a/csharp/src/Google.Protobuf.Benchmarks/SerializationConfig.cs b/csharp/src/Google.Protobuf.Benchmarks/SerializationConfig.cs index 679f16cb9a87..6c3fe86c8aff 100644 --- a/csharp/src/Google.Protobuf.Benchmarks/SerializationConfig.cs +++ b/csharp/src/Google.Protobuf.Benchmarks/SerializationConfig.cs @@ -52,15 +52,25 @@ public class SerializationConfig t => ((MessageDescriptor) t.GetProperty("Descriptor", BindingFlags.Static | BindingFlags.Public).GetValue(null)).FullName, t => ((MessageParser) t.GetProperty("Parser", BindingFlags.Static | BindingFlags.Public).GetValue(null))); - public MessageParser Parser { get; } - public IEnumerable Payloads { get; } - public string Name { get; } + public MessageParser Parser { get; private set; } + public IEnumerable Payloads { get; private set; } + public string Name { get; private set; } public SerializationConfig(string resource) { var data = LoadData(resource); var dataset = BenchmarkDataset.Parser.ParseFrom(data); + Initialize(dataset); + } + + public SerializationConfig(BenchmarkDataset dataset) + { + Initialize(dataset); + } + + private void Initialize(BenchmarkDataset dataset) + { if (!parsersByMessageName.TryGetValue(dataset.MessageName, out var parser)) { throw new ArgumentException($"No parser for message {dataset.MessageName} in this assembly"); diff --git a/csharp/src/Google.Protobuf.Benchmarks/WrapperBenchmark.cs b/csharp/src/Google.Protobuf.Benchmarks/WrapperBenchmark.cs index ae17c1819af0..f9ca29bf7707 100644 --- a/csharp/src/Google.Protobuf.Benchmarks/WrapperBenchmark.cs +++ b/csharp/src/Google.Protobuf.Benchmarks/WrapperBenchmark.cs @@ -31,6 +31,7 @@ #endregion using BenchmarkDotNet.Attributes; +using System.Buffers; using System.Collections.Generic; using System.IO; using System.Linq; @@ -43,26 +44,56 @@ namespace Google.Protobuf.Benchmarks [MemoryDiagnoser] public class WrapperBenchmark { - byte[] manyWrapperFieldsData; - byte[] manyPrimitiveFieldsData; + byte[] manyWrapperFieldsByteArray; + ReadOnlySequence manyWrapperFieldsReadOnlySequence; + byte[] manyPrimitiveFieldsByteArray; + ReadOnlySequence manyPrimitiveFieldsReadOnlySequence; [GlobalSetup] public void GlobalSetup() { - manyWrapperFieldsData = CreateManyWrapperFieldsMessage().ToByteArray(); - manyPrimitiveFieldsData = CreateManyPrimitiveFieldsMessage().ToByteArray(); + manyWrapperFieldsByteArray = CreateManyWrapperFieldsMessage().ToByteArray(); + manyWrapperFieldsReadOnlySequence = new ReadOnlySequence(manyWrapperFieldsByteArray); + manyPrimitiveFieldsByteArray = CreateManyPrimitiveFieldsMessage().ToByteArray(); + manyPrimitiveFieldsReadOnlySequence = new ReadOnlySequence(manyPrimitiveFieldsByteArray); } [Benchmark] - public ManyWrapperFieldsMessage ParseWrapperFields() + public ManyWrapperFieldsMessage ParseWrapperFieldsFromByteArray() { - return ManyWrapperFieldsMessage.Parser.ParseFrom(manyWrapperFieldsData); + return ManyWrapperFieldsMessage.Parser.ParseFrom(manyWrapperFieldsByteArray); } [Benchmark] - public ManyPrimitiveFieldsMessage ParsePrimitiveFields() + public ManyWrapperFieldsMessage ParseWrapperFieldsFromNewByteArray() { - return ManyPrimitiveFieldsMessage.Parser.ParseFrom(manyPrimitiveFieldsData); + return ManyWrapperFieldsMessage.Parser.ParseFrom(manyWrapperFieldsReadOnlySequence.ToArray()); + } + + [Benchmark] + public ManyWrapperFieldsMessage ParseWrapperFieldsFromReadOnlySequence() + { + var input = new CodedInputReader(manyWrapperFieldsReadOnlySequence); + return ManyWrapperFieldsMessage.Parser.ParseFrom(ref input); + } + + [Benchmark] + public ManyPrimitiveFieldsMessage ParsePrimitiveFieldsFromByteArray() + { + return ManyPrimitiveFieldsMessage.Parser.ParseFrom(manyPrimitiveFieldsByteArray); + } + + [Benchmark] + public ManyPrimitiveFieldsMessage ParsePrimitiveFieldsFromNewByteArray() + { + return ManyPrimitiveFieldsMessage.Parser.ParseFrom(manyPrimitiveFieldsByteArray.ToArray()); + } + + [Benchmark] + public ManyPrimitiveFieldsMessage ParsePrimitiveFieldsFromReadOnlySequence() + { + var input = new CodedInputReader(manyPrimitiveFieldsReadOnlySequence); + return ManyPrimitiveFieldsMessage.Parser.ParseFrom(ref input); } private static ManyWrapperFieldsMessage CreateManyWrapperFieldsMessage() diff --git a/csharp/src/Google.Protobuf.Benchmarks/WrapperBenchmarkMessages.cs b/csharp/src/Google.Protobuf.Benchmarks/WrapperBenchmarkMessages.cs index 0cc86e2ad406..3b29e5a13be1 100644 --- a/csharp/src/Google.Protobuf.Benchmarks/WrapperBenchmarkMessages.cs +++ b/csharp/src/Google.Protobuf.Benchmarks/WrapperBenchmarkMessages.cs @@ -237,7 +237,11 @@ public static partial class WrapperBenchmarkMessagesReflection { /// a message that has a large number of wrapper fields /// obfuscated version of an internal message /// - public sealed partial class ManyWrapperFieldsMessage : pb::IMessage { + public sealed partial class ManyWrapperFieldsMessage : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ManyWrapperFieldsMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -2408,6 +2412,350 @@ public sealed partial class ManyWrapperFieldsMessage : pb::IMessage - /// same as ManyWrapperFieldsMessages, but with primitive fields - /// for comparison. - /// - public sealed partial class ManyPrimitiveFieldsMessage : pb::IMessage { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ManyPrimitiveFieldsMessage()); - private pb::UnknownFieldSet _unknownFields; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pbr::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.Benchmarks.WrapperBenchmarkMessagesReflection.Descriptor.MessageTypes[1]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public ManyPrimitiveFieldsMessage() { - OnConstruction(); - } - + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + double? value = _single_doubleField1_codec.Read(ref input); + if (doubleField1_ == null || value != 0D) { + DoubleField1 = value; + } + break; + } + case 18: { + long? value = _single_int64Field2_codec.Read(ref input); + if (int64Field2_ == null || value != 0L) { + Int64Field2 = value; + } + break; + } + case 26: { + long? value = _single_int64Field3_codec.Read(ref input); + if (int64Field3_ == null || value != 0L) { + Int64Field3 = value; + } + break; + } + case 34: { + long? value = _single_int64Field4_codec.Read(ref input); + if (int64Field4_ == null || value != 0L) { + Int64Field4 = value; + } + break; + } + case 58: { + double? value = _single_doubleField7_codec.Read(ref input); + if (doubleField7_ == null || value != 0D) { + DoubleField7 = value; + } + break; + } + case 66: { + double? value = _single_doubleField8_codec.Read(ref input); + if (doubleField8_ == null || value != 0D) { + DoubleField8 = value; + } + break; + } + case 74: { + double? value = _single_doubleField9_codec.Read(ref input); + if (doubleField9_ == null || value != 0D) { + DoubleField9 = value; + } + break; + } + case 82: { + double? value = _single_doubleField10_codec.Read(ref input); + if (doubleField10_ == null || value != 0D) { + DoubleField10 = value; + } + break; + } + case 90: { + double? value = _single_doubleField11_codec.Read(ref input); + if (doubleField11_ == null || value != 0D) { + DoubleField11 = value; + } + break; + } + case 114: { + double? value = _single_doubleField14_codec.Read(ref input); + if (doubleField14_ == null || value != 0D) { + DoubleField14 = value; + } + break; + } + case 122: { + double? value = _single_doubleField15_codec.Read(ref input); + if (doubleField15_ == null || value != 0D) { + DoubleField15 = value; + } + break; + } + case 154: { + long? value = _single_int64Field19_codec.Read(ref input); + if (int64Field19_ == null || value != 0L) { + Int64Field19 = value; + } + break; + } + case 162: { + double? value = _single_doubleField20_codec.Read(ref input); + if (doubleField20_ == null || value != 0D) { + DoubleField20 = value; + } + break; + } + case 170: { + double? value = _single_doubleField21_codec.Read(ref input); + if (doubleField21_ == null || value != 0D) { + DoubleField21 = value; + } + break; + } + case 178: { + double? value = _single_doubleField22_codec.Read(ref input); + if (doubleField22_ == null || value != 0D) { + DoubleField22 = value; + } + break; + } + case 202: { + double? value = _single_doubleField25_codec.Read(ref input); + if (doubleField25_ == null || value != 0D) { + DoubleField25 = value; + } + break; + } + case 210: { + long? value = _single_int64Field26_codec.Read(ref input); + if (int64Field26_ == null || value != 0L) { + Int64Field26 = value; + } + break; + } + case 226: { + double? value = _single_doubleField28_codec.Read(ref input); + if (doubleField28_ == null || value != 0D) { + DoubleField28 = value; + } + break; + } + case 234: { + double? value = _single_doubleField29_codec.Read(ref input); + if (doubleField29_ == null || value != 0D) { + DoubleField29 = value; + } + break; + } + case 242: { + double? value = _single_doubleField30_codec.Read(ref input); + if (doubleField30_ == null || value != 0D) { + DoubleField30 = value; + } + break; + } + case 250: { + double? value = _single_doubleField31_codec.Read(ref input); + if (doubleField31_ == null || value != 0D) { + DoubleField31 = value; + } + break; + } + case 258: { + long? value = _single_int64Field32_codec.Read(ref input); + if (int64Field32_ == null || value != 0L) { + Int64Field32 = value; + } + break; + } + case 298: { + long? value = _single_int64Field37_codec.Read(ref input); + if (int64Field37_ == null || value != 0L) { + Int64Field37 = value; + } + break; + } + case 306: { + double? value = _single_doubleField38_codec.Read(ref input); + if (doubleField38_ == null || value != 0D) { + DoubleField38 = value; + } + break; + } + case 314: { + long? value = _single_interactions_codec.Read(ref input); + if (interactions_ == null || value != 0L) { + Interactions = value; + } + break; + } + case 322: { + double? value = _single_doubleField40_codec.Read(ref input); + if (doubleField40_ == null || value != 0D) { + DoubleField40 = value; + } + break; + } + case 330: { + long? value = _single_int64Field41_codec.Read(ref input); + if (int64Field41_ == null || value != 0L) { + Int64Field41 = value; + } + break; + } + case 338: { + double? value = _single_doubleField42_codec.Read(ref input); + if (doubleField42_ == null || value != 0D) { + DoubleField42 = value; + } + break; + } + case 346: { + long? value = _single_int64Field43_codec.Read(ref input); + if (int64Field43_ == null || value != 0L) { + Int64Field43 = value; + } + break; + } + case 354: { + long? value = _single_int64Field44_codec.Read(ref input); + if (int64Field44_ == null || value != 0L) { + Int64Field44 = value; + } + break; + } + case 362: { + double? value = _single_doubleField45_codec.Read(ref input); + if (doubleField45_ == null || value != 0D) { + DoubleField45 = value; + } + break; + } + case 370: { + double? value = _single_doubleField46_codec.Read(ref input); + if (doubleField46_ == null || value != 0D) { + DoubleField46 = value; + } + break; + } + case 378: { + double? value = _single_doubleField47_codec.Read(ref input); + if (doubleField47_ == null || value != 0D) { + DoubleField47 = value; + } + break; + } + case 386: { + double? value = _single_doubleField48_codec.Read(ref input); + if (doubleField48_ == null || value != 0D) { + DoubleField48 = value; + } + break; + } + case 394: { + double? value = _single_doubleField49_codec.Read(ref input); + if (doubleField49_ == null || value != 0D) { + DoubleField49 = value; + } + break; + } + case 402: { + double? value = _single_doubleField50_codec.Read(ref input); + if (doubleField50_ == null || value != 0D) { + DoubleField50 = value; + } + break; + } + case 410: { + double? value = _single_doubleField51_codec.Read(ref input); + if (doubleField51_ == null || value != 0D) { + DoubleField51 = value; + } + break; + } + case 418: { + double? value = _single_doubleField52_codec.Read(ref input); + if (doubleField52_ == null || value != 0D) { + DoubleField52 = value; + } + break; + } + case 426: { + double? value = _single_doubleField53_codec.Read(ref input); + if (doubleField53_ == null || value != 0D) { + DoubleField53 = value; + } + break; + } + case 434: { + double? value = _single_doubleField54_codec.Read(ref input); + if (doubleField54_ == null || value != 0D) { + DoubleField54 = value; + } + break; + } + case 442: { + double? value = _single_doubleField55_codec.Read(ref input); + if (doubleField55_ == null || value != 0D) { + DoubleField55 = value; + } + break; + } + case 450: { + double? value = _single_doubleField56_codec.Read(ref input); + if (doubleField56_ == null || value != 0D) { + DoubleField56 = value; + } + break; + } + case 458: { + double? value = _single_doubleField57_codec.Read(ref input); + if (doubleField57_ == null || value != 0D) { + DoubleField57 = value; + } + break; + } + case 466: { + double? value = _single_doubleField58_codec.Read(ref input); + if (doubleField58_ == null || value != 0D) { + DoubleField58 = value; + } + break; + } + case 474: { + long? value = _single_int64Field59_codec.Read(ref input); + if (int64Field59_ == null || value != 0L) { + Int64Field59 = value; + } + break; + } + case 482: { + long? value = _single_int64Field60_codec.Read(ref input); + if (int64Field60_ == null || value != 0L) { + Int64Field60 = value; + } + break; + } + case 498: { + double? value = _single_doubleField62_codec.Read(ref input); + if (doubleField62_ == null || value != 0D) { + DoubleField62 = value; + } + break; + } + case 522: { + double? value = _single_doubleField65_codec.Read(ref input); + if (doubleField65_ == null || value != 0D) { + DoubleField65 = value; + } + break; + } + case 530: { + double? value = _single_doubleField66_codec.Read(ref input); + if (doubleField66_ == null || value != 0D) { + DoubleField66 = value; + } + break; + } + case 538: { + double? value = _single_doubleField67_codec.Read(ref input); + if (doubleField67_ == null || value != 0D) { + DoubleField67 = value; + } + break; + } + case 546: { + double? value = _single_doubleField68_codec.Read(ref input); + if (doubleField68_ == null || value != 0D) { + DoubleField68 = value; + } + break; + } + case 554: { + double? value = _single_doubleField69_codec.Read(ref input); + if (doubleField69_ == null || value != 0D) { + DoubleField69 = value; + } + break; + } + case 562: { + double? value = _single_doubleField70_codec.Read(ref input); + if (doubleField70_ == null || value != 0D) { + DoubleField70 = value; + } + break; + } + case 570: { + double? value = _single_doubleField71_codec.Read(ref input); + if (doubleField71_ == null || value != 0D) { + DoubleField71 = value; + } + break; + } + case 578: { + double? value = _single_doubleField72_codec.Read(ref input); + if (doubleField72_ == null || value != 0D) { + DoubleField72 = value; + } + break; + } + case 586: { + string value = _single_stringField73_codec.Read(ref input); + if (stringField73_ == null || value != "") { + StringField73 = value; + } + break; + } + case 594: { + string value = _single_stringField74_codec.Read(ref input); + if (stringField74_ == null || value != "") { + StringField74 = value; + } + break; + } + case 602: { + double? value = _single_doubleField75_codec.Read(ref input); + if (doubleField75_ == null || value != 0D) { + DoubleField75 = value; + } + break; + } + case 618: { + double? value = _single_doubleField77_codec.Read(ref input); + if (doubleField77_ == null || value != 0D) { + DoubleField77 = value; + } + break; + } + case 626: { + double? value = _single_doubleField78_codec.Read(ref input); + if (doubleField78_ == null || value != 0D) { + DoubleField78 = value; + } + break; + } + case 634: { + double? value = _single_doubleField79_codec.Read(ref input); + if (doubleField79_ == null || value != 0D) { + DoubleField79 = value; + } + break; + } + case 640: { + EnumField80 = input.ReadInt32(); + break; + } + case 648: { + EnumField81 = input.ReadInt32(); + break; + } + case 658: { + long? value = _single_int64Field82_codec.Read(ref input); + if (int64Field82_ == null || value != 0L) { + Int64Field82 = value; + } + break; + } + case 664: { + EnumField83 = input.ReadInt32(); + break; + } + case 674: { + double? value = _single_doubleField84_codec.Read(ref input); + if (doubleField84_ == null || value != 0D) { + DoubleField84 = value; + } + break; + } + case 682: { + long? value = _single_int64Field85_codec.Read(ref input); + if (int64Field85_ == null || value != 0L) { + Int64Field85 = value; + } + break; + } + case 690: { + long? value = _single_int64Field86_codec.Read(ref input); + if (int64Field86_ == null || value != 0L) { + Int64Field86 = value; + } + break; + } + case 698: { + long? value = _single_int64Field87_codec.Read(ref input); + if (int64Field87_ == null || value != 0L) { + Int64Field87 = value; + } + break; + } + case 706: { + double? value = _single_doubleField88_codec.Read(ref input); + if (doubleField88_ == null || value != 0D) { + DoubleField88 = value; + } + break; + } + case 714: { + double? value = _single_doubleField89_codec.Read(ref input); + if (doubleField89_ == null || value != 0D) { + DoubleField89 = value; + } + break; + } + case 722: { + double? value = _single_doubleField90_codec.Read(ref input); + if (doubleField90_ == null || value != 0D) { + DoubleField90 = value; + } + break; + } + case 730: { + double? value = _single_doubleField91_codec.Read(ref input); + if (doubleField91_ == null || value != 0D) { + DoubleField91 = value; + } + break; + } + case 738: { + double? value = _single_doubleField92_codec.Read(ref input); + if (doubleField92_ == null || value != 0D) { + DoubleField92 = value; + } + break; + } + case 746: { + double? value = _single_doubleField93_codec.Read(ref input); + if (doubleField93_ == null || value != 0D) { + DoubleField93 = value; + } + break; + } + case 754: { + double? value = _single_doubleField94_codec.Read(ref input); + if (doubleField94_ == null || value != 0D) { + DoubleField94 = value; + } + break; + } + case 762: { + double? value = _single_doubleField95_codec.Read(ref input); + if (doubleField95_ == null || value != 0D) { + DoubleField95 = value; + } + break; + } + case 770: { + double? value = _single_doubleField96_codec.Read(ref input); + if (doubleField96_ == null || value != 0D) { + DoubleField96 = value; + } + break; + } + case 778: { + double? value = _single_doubleField97_codec.Read(ref input); + if (doubleField97_ == null || value != 0D) { + DoubleField97 = value; + } + break; + } + case 786: { + double? value = _single_doubleField98_codec.Read(ref input); + if (doubleField98_ == null || value != 0D) { + DoubleField98 = value; + } + break; + } + case 794: { + double? value = _single_doubleField99_codec.Read(ref input); + if (doubleField99_ == null || value != 0D) { + DoubleField99 = value; + } + break; + } + case 802: + case 800: { + repeatedIntField100_.AddEntriesFrom(ref input, _repeated_repeatedIntField100_codec); + break; + } + case 810: { + double? value = _single_doubleField101_codec.Read(ref input); + if (doubleField101_ == null || value != 0D) { + DoubleField101 = value; + } + break; + } + case 818: { + double? value = _single_doubleField102_codec.Read(ref input); + if (doubleField102_ == null || value != 0D) { + DoubleField102 = value; + } + break; + } + case 826: { + double? value = _single_doubleField103_codec.Read(ref input); + if (doubleField103_ == null || value != 0D) { + DoubleField103 = value; + } + break; + } + case 834: { + double? value = _single_doubleField104_codec.Read(ref input); + if (doubleField104_ == null || value != 0D) { + DoubleField104 = value; + } + break; + } + case 842: { + double? value = _single_doubleField105_codec.Read(ref input); + if (doubleField105_ == null || value != 0D) { + DoubleField105 = value; + } + break; + } + case 850: { + double? value = _single_doubleField106_codec.Read(ref input); + if (doubleField106_ == null || value != 0D) { + DoubleField106 = value; + } + break; + } + case 858: { + long? value = _single_int64Field107_codec.Read(ref input); + if (int64Field107_ == null || value != 0L) { + Int64Field107 = value; + } + break; + } + case 866: { + double? value = _single_doubleField108_codec.Read(ref input); + if (doubleField108_ == null || value != 0D) { + DoubleField108 = value; + } + break; + } + case 874: { + double? value = _single_doubleField109_codec.Read(ref input); + if (doubleField109_ == null || value != 0D) { + DoubleField109 = value; + } + break; + } + case 882: { + long? value = _single_int64Field110_codec.Read(ref input); + if (int64Field110_ == null || value != 0L) { + Int64Field110 = value; + } + break; + } + case 890: { + double? value = _single_doubleField111_codec.Read(ref input); + if (doubleField111_ == null || value != 0D) { + DoubleField111 = value; + } + break; + } + case 898: { + long? value = _single_int64Field112_codec.Read(ref input); + if (int64Field112_ == null || value != 0L) { + Int64Field112 = value; + } + break; + } + case 906: { + double? value = _single_doubleField113_codec.Read(ref input); + if (doubleField113_ == null || value != 0D) { + DoubleField113 = value; + } + break; + } + case 914: { + long? value = _single_int64Field114_codec.Read(ref input); + if (int64Field114_ == null || value != 0L) { + Int64Field114 = value; + } + break; + } + case 922: { + long? value = _single_int64Field115_codec.Read(ref input); + if (int64Field115_ == null || value != 0L) { + Int64Field115 = value; + } + break; + } + case 930: { + double? value = _single_doubleField116_codec.Read(ref input); + if (doubleField116_ == null || value != 0D) { + DoubleField116 = value; + } + break; + } + case 938: { + long? value = _single_int64Field117_codec.Read(ref input); + if (int64Field117_ == null || value != 0L) { + Int64Field117 = value; + } + break; + } + case 946: { + double? value = _single_doubleField118_codec.Read(ref input); + if (doubleField118_ == null || value != 0D) { + DoubleField118 = value; + } + break; + } + case 954: { + double? value = _single_doubleField119_codec.Read(ref input); + if (doubleField119_ == null || value != 0D) { + DoubleField119 = value; + } + break; + } + case 962: { + double? value = _single_doubleField120_codec.Read(ref input); + if (doubleField120_ == null || value != 0D) { + DoubleField120 = value; + } + break; + } + case 970: { + double? value = _single_doubleField121_codec.Read(ref input); + if (doubleField121_ == null || value != 0D) { + DoubleField121 = value; + } + break; + } + case 978: { + double? value = _single_doubleField122_codec.Read(ref input); + if (doubleField122_ == null || value != 0D) { + DoubleField122 = value; + } + break; + } + case 986: { + double? value = _single_doubleField123_codec.Read(ref input); + if (doubleField123_ == null || value != 0D) { + DoubleField123 = value; + } + break; + } + case 994: { + double? value = _single_doubleField124_codec.Read(ref input); + if (doubleField124_ == null || value != 0D) { + DoubleField124 = value; + } + break; + } + case 1002: { + long? value = _single_int64Field125_codec.Read(ref input); + if (int64Field125_ == null || value != 0L) { + Int64Field125 = value; + } + break; + } + case 1010: { + long? value = _single_int64Field126_codec.Read(ref input); + if (int64Field126_ == null || value != 0L) { + Int64Field126 = value; + } + break; + } + case 1018: { + long? value = _single_int64Field127_codec.Read(ref input); + if (int64Field127_ == null || value != 0L) { + Int64Field127 = value; + } + break; + } + case 1026: { + double? value = _single_doubleField128_codec.Read(ref input); + if (doubleField128_ == null || value != 0D) { + DoubleField128 = value; + } + break; + } + case 1034: { + double? value = _single_doubleField129_codec.Read(ref input); + if (doubleField129_ == null || value != 0D) { + DoubleField129 = value; + } + break; + } + } + } + } + #endif + + } + + /// + /// same as ManyWrapperFieldsMessages, but with primitive fields + /// for comparison. + /// + public sealed partial class ManyPrimitiveFieldsMessage : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ManyPrimitiveFieldsMessage()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.Benchmarks.WrapperBenchmarkMessagesReflection.Descriptor.MessageTypes[1]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ManyPrimitiveFieldsMessage() { + OnConstruction(); + } + partial void OnConstruction(); [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public ManyPrimitiveFieldsMessage(ManyPrimitiveFieldsMessage other) : this() { - doubleField95_ = other.doubleField95_; - doubleField1_ = other.doubleField1_; - doubleField79_ = other.doubleField79_; - int64Field2_ = other.int64Field2_; - doubleField96_ = other.doubleField96_; - int64Field3_ = other.int64Field3_; - int64Field4_ = other.int64Field4_; - doubleField97_ = other.doubleField97_; - doubleField65_ = other.doubleField65_; - doubleField66_ = other.doubleField66_; - doubleField7_ = other.doubleField7_; - doubleField62_ = other.doubleField62_; - doubleField118_ = other.doubleField118_; - doubleField119_ = other.doubleField119_; - doubleField67_ = other.doubleField67_; - doubleField120_ = other.doubleField120_; - doubleField121_ = other.doubleField121_; - doubleField122_ = other.doubleField122_; - doubleField123_ = other.doubleField123_; - doubleField124_ = other.doubleField124_; - doubleField8_ = other.doubleField8_; - doubleField9_ = other.doubleField9_; - doubleField98_ = other.doubleField98_; - doubleField10_ = other.doubleField10_; - doubleField11_ = other.doubleField11_; - doubleField99_ = other.doubleField99_; - doubleField84_ = other.doubleField84_; - doubleField14_ = other.doubleField14_; - doubleField77_ = other.doubleField77_; - doubleField15_ = other.doubleField15_; - int64Field19_ = other.int64Field19_; - int64Field115_ = other.int64Field115_; - doubleField116_ = other.doubleField116_; - int64Field117_ = other.int64Field117_; - doubleField20_ = other.doubleField20_; - doubleField21_ = other.doubleField21_; - stringField73_ = other.stringField73_; - stringField74_ = other.stringField74_; - doubleField22_ = other.doubleField22_; - doubleField69_ = other.doubleField69_; - doubleField70_ = other.doubleField70_; - doubleField71_ = other.doubleField71_; - doubleField72_ = other.doubleField72_; - doubleField25_ = other.doubleField25_; - int64Field26_ = other.int64Field26_; - doubleField68_ = other.doubleField68_; - doubleField28_ = other.doubleField28_; - doubleField106_ = other.doubleField106_; - doubleField29_ = other.doubleField29_; - doubleField30_ = other.doubleField30_; - doubleField101_ = other.doubleField101_; - doubleField102_ = other.doubleField102_; - doubleField103_ = other.doubleField103_; - doubleField104_ = other.doubleField104_; - doubleField105_ = other.doubleField105_; - doubleField31_ = other.doubleField31_; - int64Field32_ = other.int64Field32_; - doubleField75_ = other.doubleField75_; - doubleField129_ = other.doubleField129_; - enumField80_ = other.enumField80_; - enumField81_ = other.enumField81_; - int64Field82_ = other.int64Field82_; - enumField83_ = other.enumField83_; - int64Field85_ = other.int64Field85_; - int64Field86_ = other.int64Field86_; - int64Field87_ = other.int64Field87_; - int64Field125_ = other.int64Field125_; - int64Field37_ = other.int64Field37_; - doubleField38_ = other.doubleField38_; - interactions_ = other.interactions_; - repeatedIntField100_ = other.repeatedIntField100_.Clone(); - doubleField40_ = other.doubleField40_; - int64Field41_ = other.int64Field41_; - int64Field126_ = other.int64Field126_; - int64Field127_ = other.int64Field127_; - doubleField128_ = other.doubleField128_; - doubleField109_ = other.doubleField109_; - int64Field110_ = other.int64Field110_; - doubleField111_ = other.doubleField111_; - int64Field112_ = other.int64Field112_; - doubleField113_ = other.doubleField113_; - int64Field114_ = other.int64Field114_; - doubleField42_ = other.doubleField42_; - int64Field43_ = other.int64Field43_; - int64Field44_ = other.int64Field44_; - doubleField45_ = other.doubleField45_; - doubleField46_ = other.doubleField46_; - doubleField78_ = other.doubleField78_; - doubleField88_ = other.doubleField88_; - doubleField47_ = other.doubleField47_; - doubleField89_ = other.doubleField89_; - doubleField48_ = other.doubleField48_; - doubleField49_ = other.doubleField49_; - doubleField50_ = other.doubleField50_; - doubleField90_ = other.doubleField90_; - doubleField51_ = other.doubleField51_; - doubleField91_ = other.doubleField91_; - doubleField92_ = other.doubleField92_; - int64Field107_ = other.int64Field107_; - doubleField93_ = other.doubleField93_; - doubleField108_ = other.doubleField108_; - doubleField52_ = other.doubleField52_; - doubleField53_ = other.doubleField53_; - doubleField94_ = other.doubleField94_; - doubleField54_ = other.doubleField54_; - doubleField55_ = other.doubleField55_; - doubleField56_ = other.doubleField56_; - doubleField57_ = other.doubleField57_; - doubleField58_ = other.doubleField58_; - int64Field59_ = other.int64Field59_; - int64Field60_ = other.int64Field60_; - _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + public ManyPrimitiveFieldsMessage(ManyPrimitiveFieldsMessage other) : this() { + doubleField95_ = other.doubleField95_; + doubleField1_ = other.doubleField1_; + doubleField79_ = other.doubleField79_; + int64Field2_ = other.int64Field2_; + doubleField96_ = other.doubleField96_; + int64Field3_ = other.int64Field3_; + int64Field4_ = other.int64Field4_; + doubleField97_ = other.doubleField97_; + doubleField65_ = other.doubleField65_; + doubleField66_ = other.doubleField66_; + doubleField7_ = other.doubleField7_; + doubleField62_ = other.doubleField62_; + doubleField118_ = other.doubleField118_; + doubleField119_ = other.doubleField119_; + doubleField67_ = other.doubleField67_; + doubleField120_ = other.doubleField120_; + doubleField121_ = other.doubleField121_; + doubleField122_ = other.doubleField122_; + doubleField123_ = other.doubleField123_; + doubleField124_ = other.doubleField124_; + doubleField8_ = other.doubleField8_; + doubleField9_ = other.doubleField9_; + doubleField98_ = other.doubleField98_; + doubleField10_ = other.doubleField10_; + doubleField11_ = other.doubleField11_; + doubleField99_ = other.doubleField99_; + doubleField84_ = other.doubleField84_; + doubleField14_ = other.doubleField14_; + doubleField77_ = other.doubleField77_; + doubleField15_ = other.doubleField15_; + int64Field19_ = other.int64Field19_; + int64Field115_ = other.int64Field115_; + doubleField116_ = other.doubleField116_; + int64Field117_ = other.int64Field117_; + doubleField20_ = other.doubleField20_; + doubleField21_ = other.doubleField21_; + stringField73_ = other.stringField73_; + stringField74_ = other.stringField74_; + doubleField22_ = other.doubleField22_; + doubleField69_ = other.doubleField69_; + doubleField70_ = other.doubleField70_; + doubleField71_ = other.doubleField71_; + doubleField72_ = other.doubleField72_; + doubleField25_ = other.doubleField25_; + int64Field26_ = other.int64Field26_; + doubleField68_ = other.doubleField68_; + doubleField28_ = other.doubleField28_; + doubleField106_ = other.doubleField106_; + doubleField29_ = other.doubleField29_; + doubleField30_ = other.doubleField30_; + doubleField101_ = other.doubleField101_; + doubleField102_ = other.doubleField102_; + doubleField103_ = other.doubleField103_; + doubleField104_ = other.doubleField104_; + doubleField105_ = other.doubleField105_; + doubleField31_ = other.doubleField31_; + int64Field32_ = other.int64Field32_; + doubleField75_ = other.doubleField75_; + doubleField129_ = other.doubleField129_; + enumField80_ = other.enumField80_; + enumField81_ = other.enumField81_; + int64Field82_ = other.int64Field82_; + enumField83_ = other.enumField83_; + int64Field85_ = other.int64Field85_; + int64Field86_ = other.int64Field86_; + int64Field87_ = other.int64Field87_; + int64Field125_ = other.int64Field125_; + int64Field37_ = other.int64Field37_; + doubleField38_ = other.doubleField38_; + interactions_ = other.interactions_; + repeatedIntField100_ = other.repeatedIntField100_.Clone(); + doubleField40_ = other.doubleField40_; + int64Field41_ = other.int64Field41_; + int64Field126_ = other.int64Field126_; + int64Field127_ = other.int64Field127_; + doubleField128_ = other.doubleField128_; + doubleField109_ = other.doubleField109_; + int64Field110_ = other.int64Field110_; + doubleField111_ = other.doubleField111_; + int64Field112_ = other.int64Field112_; + doubleField113_ = other.doubleField113_; + int64Field114_ = other.int64Field114_; + doubleField42_ = other.doubleField42_; + int64Field43_ = other.int64Field43_; + int64Field44_ = other.int64Field44_; + doubleField45_ = other.doubleField45_; + doubleField46_ = other.doubleField46_; + doubleField78_ = other.doubleField78_; + doubleField88_ = other.doubleField88_; + doubleField47_ = other.doubleField47_; + doubleField89_ = other.doubleField89_; + doubleField48_ = other.doubleField48_; + doubleField49_ = other.doubleField49_; + doubleField50_ = other.doubleField50_; + doubleField90_ = other.doubleField90_; + doubleField51_ = other.doubleField51_; + doubleField91_ = other.doubleField91_; + doubleField92_ = other.doubleField92_; + int64Field107_ = other.int64Field107_; + doubleField93_ = other.doubleField93_; + doubleField108_ = other.doubleField108_; + doubleField52_ = other.doubleField52_; + doubleField53_ = other.doubleField53_; + doubleField94_ = other.doubleField94_; + doubleField54_ = other.doubleField54_; + doubleField55_ = other.doubleField55_; + doubleField56_ = other.doubleField56_; + doubleField57_ = other.doubleField57_; + doubleField58_ = other.doubleField58_; + int64Field59_ = other.int64Field59_; + int64Field60_ = other.int64Field60_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ManyPrimitiveFieldsMessage Clone() { + return new ManyPrimitiveFieldsMessage(this); + } + + /// Field number for the "double_field_95" field. + public const int DoubleField95FieldNumber = 95; + private double doubleField95_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField95 { + get { return doubleField95_; } + set { + doubleField95_ = value; + } + } + + /// Field number for the "double_field_1" field. + public const int DoubleField1FieldNumber = 1; + private double doubleField1_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField1 { + get { return doubleField1_; } + set { + doubleField1_ = value; + } + } + + /// Field number for the "double_field_79" field. + public const int DoubleField79FieldNumber = 79; + private double doubleField79_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField79 { + get { return doubleField79_; } + set { + doubleField79_ = value; + } + } + + /// Field number for the "int64_field_2" field. + public const int Int64Field2FieldNumber = 2; + private long int64Field2_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long Int64Field2 { + get { return int64Field2_; } + set { + int64Field2_ = value; + } + } + + /// Field number for the "double_field_96" field. + public const int DoubleField96FieldNumber = 96; + private double doubleField96_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField96 { + get { return doubleField96_; } + set { + doubleField96_ = value; + } + } + + /// Field number for the "int64_field_3" field. + public const int Int64Field3FieldNumber = 3; + private long int64Field3_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long Int64Field3 { + get { return int64Field3_; } + set { + int64Field3_ = value; + } + } + + /// Field number for the "int64_field_4" field. + public const int Int64Field4FieldNumber = 4; + private long int64Field4_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long Int64Field4 { + get { return int64Field4_; } + set { + int64Field4_ = value; + } + } + + /// Field number for the "double_field_97" field. + public const int DoubleField97FieldNumber = 97; + private double doubleField97_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField97 { + get { return doubleField97_; } + set { + doubleField97_ = value; + } + } + + /// Field number for the "double_field_65" field. + public const int DoubleField65FieldNumber = 65; + private double doubleField65_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField65 { + get { return doubleField65_; } + set { + doubleField65_ = value; + } + } + + /// Field number for the "double_field_66" field. + public const int DoubleField66FieldNumber = 66; + private double doubleField66_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField66 { + get { return doubleField66_; } + set { + doubleField66_ = value; + } + } + + /// Field number for the "double_field_7" field. + public const int DoubleField7FieldNumber = 7; + private double doubleField7_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField7 { + get { return doubleField7_; } + set { + doubleField7_ = value; + } + } + + /// Field number for the "double_field_62" field. + public const int DoubleField62FieldNumber = 62; + private double doubleField62_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField62 { + get { return doubleField62_; } + set { + doubleField62_ = value; + } + } + + /// Field number for the "double_field_118" field. + public const int DoubleField118FieldNumber = 118; + private double doubleField118_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField118 { + get { return doubleField118_; } + set { + doubleField118_ = value; + } + } + + /// Field number for the "double_field_119" field. + public const int DoubleField119FieldNumber = 119; + private double doubleField119_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField119 { + get { return doubleField119_; } + set { + doubleField119_ = value; + } + } + + /// Field number for the "double_field_67" field. + public const int DoubleField67FieldNumber = 67; + private double doubleField67_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField67 { + get { return doubleField67_; } + set { + doubleField67_ = value; + } + } + + /// Field number for the "double_field_120" field. + public const int DoubleField120FieldNumber = 120; + private double doubleField120_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField120 { + get { return doubleField120_; } + set { + doubleField120_ = value; + } + } + + /// Field number for the "double_field_121" field. + public const int DoubleField121FieldNumber = 121; + private double doubleField121_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField121 { + get { return doubleField121_; } + set { + doubleField121_ = value; + } + } + + /// Field number for the "double_field_122" field. + public const int DoubleField122FieldNumber = 122; + private double doubleField122_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField122 { + get { return doubleField122_; } + set { + doubleField122_ = value; + } + } + + /// Field number for the "double_field_123" field. + public const int DoubleField123FieldNumber = 123; + private double doubleField123_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField123 { + get { return doubleField123_; } + set { + doubleField123_ = value; + } + } + + /// Field number for the "double_field_124" field. + public const int DoubleField124FieldNumber = 124; + private double doubleField124_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField124 { + get { return doubleField124_; } + set { + doubleField124_ = value; + } + } + + /// Field number for the "double_field_8" field. + public const int DoubleField8FieldNumber = 8; + private double doubleField8_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField8 { + get { return doubleField8_; } + set { + doubleField8_ = value; + } + } + + /// Field number for the "double_field_9" field. + public const int DoubleField9FieldNumber = 9; + private double doubleField9_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField9 { + get { return doubleField9_; } + set { + doubleField9_ = value; + } + } + + /// Field number for the "double_field_98" field. + public const int DoubleField98FieldNumber = 98; + private double doubleField98_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField98 { + get { return doubleField98_; } + set { + doubleField98_ = value; + } + } + + /// Field number for the "double_field_10" field. + public const int DoubleField10FieldNumber = 10; + private double doubleField10_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField10 { + get { return doubleField10_; } + set { + doubleField10_ = value; + } + } + + /// Field number for the "double_field_11" field. + public const int DoubleField11FieldNumber = 11; + private double doubleField11_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField11 { + get { return doubleField11_; } + set { + doubleField11_ = value; + } + } + + /// Field number for the "double_field_99" field. + public const int DoubleField99FieldNumber = 99; + private double doubleField99_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField99 { + get { return doubleField99_; } + set { + doubleField99_ = value; + } + } + + /// Field number for the "double_field_84" field. + public const int DoubleField84FieldNumber = 84; + private double doubleField84_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField84 { + get { return doubleField84_; } + set { + doubleField84_ = value; + } + } + + /// Field number for the "double_field_14" field. + public const int DoubleField14FieldNumber = 14; + private double doubleField14_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField14 { + get { return doubleField14_; } + set { + doubleField14_ = value; + } + } + + /// Field number for the "double_field_77" field. + public const int DoubleField77FieldNumber = 77; + private double doubleField77_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField77 { + get { return doubleField77_; } + set { + doubleField77_ = value; + } + } + + /// Field number for the "double_field_15" field. + public const int DoubleField15FieldNumber = 15; + private double doubleField15_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField15 { + get { return doubleField15_; } + set { + doubleField15_ = value; + } + } + + /// Field number for the "int64_field_19" field. + public const int Int64Field19FieldNumber = 19; + private long int64Field19_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long Int64Field19 { + get { return int64Field19_; } + set { + int64Field19_ = value; + } + } + + /// Field number for the "int64_field_115" field. + public const int Int64Field115FieldNumber = 115; + private long int64Field115_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long Int64Field115 { + get { return int64Field115_; } + set { + int64Field115_ = value; + } + } + + /// Field number for the "double_field_116" field. + public const int DoubleField116FieldNumber = 116; + private double doubleField116_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField116 { + get { return doubleField116_; } + set { + doubleField116_ = value; + } + } + + /// Field number for the "int64_field_117" field. + public const int Int64Field117FieldNumber = 117; + private long int64Field117_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long Int64Field117 { + get { return int64Field117_; } + set { + int64Field117_ = value; + } + } + + /// Field number for the "double_field_20" field. + public const int DoubleField20FieldNumber = 20; + private double doubleField20_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField20 { + get { return doubleField20_; } + set { + doubleField20_ = value; + } + } + + /// Field number for the "double_field_21" field. + public const int DoubleField21FieldNumber = 21; + private double doubleField21_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField21 { + get { return doubleField21_; } + set { + doubleField21_ = value; + } + } + + /// Field number for the "string_field_73" field. + public const int StringField73FieldNumber = 73; + private string stringField73_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string StringField73 { + get { return stringField73_; } + set { + stringField73_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "string_field_74" field. + public const int StringField74FieldNumber = 74; + private string stringField74_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string StringField74 { + get { return stringField74_; } + set { + stringField74_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "double_field_22" field. + public const int DoubleField22FieldNumber = 22; + private double doubleField22_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField22 { + get { return doubleField22_; } + set { + doubleField22_ = value; + } + } + + /// Field number for the "double_field_69" field. + public const int DoubleField69FieldNumber = 69; + private double doubleField69_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField69 { + get { return doubleField69_; } + set { + doubleField69_ = value; + } + } + + /// Field number for the "double_field_70" field. + public const int DoubleField70FieldNumber = 70; + private double doubleField70_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField70 { + get { return doubleField70_; } + set { + doubleField70_ = value; + } + } + + /// Field number for the "double_field_71" field. + public const int DoubleField71FieldNumber = 71; + private double doubleField71_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField71 { + get { return doubleField71_; } + set { + doubleField71_ = value; + } + } + + /// Field number for the "double_field_72" field. + public const int DoubleField72FieldNumber = 72; + private double doubleField72_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField72 { + get { return doubleField72_; } + set { + doubleField72_ = value; + } + } + + /// Field number for the "double_field_25" field. + public const int DoubleField25FieldNumber = 25; + private double doubleField25_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField25 { + get { return doubleField25_; } + set { + doubleField25_ = value; + } + } + + /// Field number for the "int64_field_26" field. + public const int Int64Field26FieldNumber = 26; + private long int64Field26_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long Int64Field26 { + get { return int64Field26_; } + set { + int64Field26_ = value; + } + } + + /// Field number for the "double_field_68" field. + public const int DoubleField68FieldNumber = 68; + private double doubleField68_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField68 { + get { return doubleField68_; } + set { + doubleField68_ = value; + } + } + + /// Field number for the "double_field_28" field. + public const int DoubleField28FieldNumber = 28; + private double doubleField28_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField28 { + get { return doubleField28_; } + set { + doubleField28_ = value; + } + } + + /// Field number for the "double_field_106" field. + public const int DoubleField106FieldNumber = 106; + private double doubleField106_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField106 { + get { return doubleField106_; } + set { + doubleField106_ = value; + } + } + + /// Field number for the "double_field_29" field. + public const int DoubleField29FieldNumber = 29; + private double doubleField29_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField29 { + get { return doubleField29_; } + set { + doubleField29_ = value; + } + } + + /// Field number for the "double_field_30" field. + public const int DoubleField30FieldNumber = 30; + private double doubleField30_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField30 { + get { return doubleField30_; } + set { + doubleField30_ = value; + } + } + + /// Field number for the "double_field_101" field. + public const int DoubleField101FieldNumber = 101; + private double doubleField101_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField101 { + get { return doubleField101_; } + set { + doubleField101_ = value; + } + } + + /// Field number for the "double_field_102" field. + public const int DoubleField102FieldNumber = 102; + private double doubleField102_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField102 { + get { return doubleField102_; } + set { + doubleField102_ = value; + } + } + + /// Field number for the "double_field_103" field. + public const int DoubleField103FieldNumber = 103; + private double doubleField103_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField103 { + get { return doubleField103_; } + set { + doubleField103_ = value; + } + } + + /// Field number for the "double_field_104" field. + public const int DoubleField104FieldNumber = 104; + private double doubleField104_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField104 { + get { return doubleField104_; } + set { + doubleField104_ = value; + } + } + + /// Field number for the "double_field_105" field. + public const int DoubleField105FieldNumber = 105; + private double doubleField105_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField105 { + get { return doubleField105_; } + set { + doubleField105_ = value; + } + } + + /// Field number for the "double_field_31" field. + public const int DoubleField31FieldNumber = 31; + private double doubleField31_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField31 { + get { return doubleField31_; } + set { + doubleField31_ = value; + } + } + + /// Field number for the "int64_field_32" field. + public const int Int64Field32FieldNumber = 32; + private long int64Field32_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long Int64Field32 { + get { return int64Field32_; } + set { + int64Field32_ = value; + } + } + + /// Field number for the "double_field_75" field. + public const int DoubleField75FieldNumber = 75; + private double doubleField75_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField75 { + get { return doubleField75_; } + set { + doubleField75_ = value; + } + } + + /// Field number for the "double_field_129" field. + public const int DoubleField129FieldNumber = 129; + private double doubleField129_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField129 { + get { return doubleField129_; } + set { + doubleField129_ = value; + } + } + + /// Field number for the "enum_field_80" field. + public const int EnumField80FieldNumber = 80; + private int enumField80_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int EnumField80 { + get { return enumField80_; } + set { + enumField80_ = value; + } + } + + /// Field number for the "enum_field_81" field. + public const int EnumField81FieldNumber = 81; + private int enumField81_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int EnumField81 { + get { return enumField81_; } + set { + enumField81_ = value; + } + } + + /// Field number for the "int64_field_82" field. + public const int Int64Field82FieldNumber = 82; + private long int64Field82_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long Int64Field82 { + get { return int64Field82_; } + set { + int64Field82_ = value; + } + } + + /// Field number for the "enum_field_83" field. + public const int EnumField83FieldNumber = 83; + private int enumField83_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int EnumField83 { + get { return enumField83_; } + set { + enumField83_ = value; + } + } + + /// Field number for the "int64_field_85" field. + public const int Int64Field85FieldNumber = 85; + private long int64Field85_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long Int64Field85 { + get { return int64Field85_; } + set { + int64Field85_ = value; + } + } + + /// Field number for the "int64_field_86" field. + public const int Int64Field86FieldNumber = 86; + private long int64Field86_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long Int64Field86 { + get { return int64Field86_; } + set { + int64Field86_ = value; + } + } + + /// Field number for the "int64_field_87" field. + public const int Int64Field87FieldNumber = 87; + private long int64Field87_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long Int64Field87 { + get { return int64Field87_; } + set { + int64Field87_ = value; + } + } + + /// Field number for the "int64_field_125" field. + public const int Int64Field125FieldNumber = 125; + private long int64Field125_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long Int64Field125 { + get { return int64Field125_; } + set { + int64Field125_ = value; + } + } + + /// Field number for the "int64_field_37" field. + public const int Int64Field37FieldNumber = 37; + private long int64Field37_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long Int64Field37 { + get { return int64Field37_; } + set { + int64Field37_ = value; + } + } + + /// Field number for the "double_field_38" field. + public const int DoubleField38FieldNumber = 38; + private double doubleField38_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField38 { + get { return doubleField38_; } + set { + doubleField38_ = value; + } + } + + /// Field number for the "interactions" field. + public const int InteractionsFieldNumber = 39; + private long interactions_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long Interactions { + get { return interactions_; } + set { + interactions_ = value; + } + } + + /// Field number for the "repeated_int_field_100" field. + public const int RepeatedIntField100FieldNumber = 100; + private static readonly pb::FieldCodec _repeated_repeatedIntField100_codec + = pb::FieldCodec.ForInt32(802); + private readonly pbc::RepeatedField repeatedIntField100_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField RepeatedIntField100 { + get { return repeatedIntField100_; } + } + + /// Field number for the "double_field_40" field. + public const int DoubleField40FieldNumber = 40; + private double doubleField40_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField40 { + get { return doubleField40_; } + set { + doubleField40_ = value; + } + } + + /// Field number for the "int64_field_41" field. + public const int Int64Field41FieldNumber = 41; + private long int64Field41_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long Int64Field41 { + get { return int64Field41_; } + set { + int64Field41_ = value; + } + } + + /// Field number for the "int64_field_126" field. + public const int Int64Field126FieldNumber = 126; + private long int64Field126_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long Int64Field126 { + get { return int64Field126_; } + set { + int64Field126_ = value; + } + } + + /// Field number for the "int64_field_127" field. + public const int Int64Field127FieldNumber = 127; + private long int64Field127_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long Int64Field127 { + get { return int64Field127_; } + set { + int64Field127_ = value; + } + } + + /// Field number for the "double_field_128" field. + public const int DoubleField128FieldNumber = 128; + private double doubleField128_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField128 { + get { return doubleField128_; } + set { + doubleField128_ = value; + } + } + + /// Field number for the "double_field_109" field. + public const int DoubleField109FieldNumber = 109; + private double doubleField109_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField109 { + get { return doubleField109_; } + set { + doubleField109_ = value; + } + } + + /// Field number for the "int64_field_110" field. + public const int Int64Field110FieldNumber = 110; + private long int64Field110_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long Int64Field110 { + get { return int64Field110_; } + set { + int64Field110_ = value; + } + } + + /// Field number for the "double_field_111" field. + public const int DoubleField111FieldNumber = 111; + private double doubleField111_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField111 { + get { return doubleField111_; } + set { + doubleField111_ = value; + } + } + + /// Field number for the "int64_field_112" field. + public const int Int64Field112FieldNumber = 112; + private long int64Field112_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long Int64Field112 { + get { return int64Field112_; } + set { + int64Field112_ = value; + } + } + + /// Field number for the "double_field_113" field. + public const int DoubleField113FieldNumber = 113; + private double doubleField113_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField113 { + get { return doubleField113_; } + set { + doubleField113_ = value; + } + } + + /// Field number for the "int64_field_114" field. + public const int Int64Field114FieldNumber = 114; + private long int64Field114_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long Int64Field114 { + get { return int64Field114_; } + set { + int64Field114_ = value; + } + } + + /// Field number for the "double_field_42" field. + public const int DoubleField42FieldNumber = 42; + private double doubleField42_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField42 { + get { return doubleField42_; } + set { + doubleField42_ = value; + } + } + + /// Field number for the "int64_field_43" field. + public const int Int64Field43FieldNumber = 43; + private long int64Field43_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long Int64Field43 { + get { return int64Field43_; } + set { + int64Field43_ = value; + } } + /// Field number for the "int64_field_44" field. + public const int Int64Field44FieldNumber = 44; + private long int64Field44_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public ManyPrimitiveFieldsMessage Clone() { - return new ManyPrimitiveFieldsMessage(this); + public long Int64Field44 { + get { return int64Field44_; } + set { + int64Field44_ = value; + } } - /// Field number for the "double_field_95" field. - public const int DoubleField95FieldNumber = 95; - private double doubleField95_; + /// Field number for the "double_field_45" field. + public const int DoubleField45FieldNumber = 45; + private double doubleField45_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField95 { - get { return doubleField95_; } + public double DoubleField45 { + get { return doubleField45_; } set { - doubleField95_ = value; + doubleField45_ = value; } } - /// Field number for the "double_field_1" field. - public const int DoubleField1FieldNumber = 1; - private double doubleField1_; + /// Field number for the "double_field_46" field. + public const int DoubleField46FieldNumber = 46; + private double doubleField46_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField1 { - get { return doubleField1_; } + public double DoubleField46 { + get { return doubleField46_; } set { - doubleField1_ = value; + doubleField46_ = value; } } - /// Field number for the "double_field_79" field. - public const int DoubleField79FieldNumber = 79; - private double doubleField79_; + /// Field number for the "double_field_78" field. + public const int DoubleField78FieldNumber = 78; + private double doubleField78_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField79 { - get { return doubleField79_; } + public double DoubleField78 { + get { return doubleField78_; } set { - doubleField79_ = value; + doubleField78_ = value; } } - /// Field number for the "int64_field_2" field. - public const int Int64Field2FieldNumber = 2; - private long int64Field2_; + /// Field number for the "double_field_88" field. + public const int DoubleField88FieldNumber = 88; + private double doubleField88_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public long Int64Field2 { - get { return int64Field2_; } + public double DoubleField88 { + get { return doubleField88_; } set { - int64Field2_ = value; + doubleField88_ = value; } } - /// Field number for the "double_field_96" field. - public const int DoubleField96FieldNumber = 96; - private double doubleField96_; + /// Field number for the "double_field_47" field. + public const int DoubleField47FieldNumber = 47; + private double doubleField47_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField96 { - get { return doubleField96_; } + public double DoubleField47 { + get { return doubleField47_; } set { - doubleField96_ = value; + doubleField47_ = value; } } - /// Field number for the "int64_field_3" field. - public const int Int64Field3FieldNumber = 3; - private long int64Field3_; + /// Field number for the "double_field_89" field. + public const int DoubleField89FieldNumber = 89; + private double doubleField89_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public long Int64Field3 { - get { return int64Field3_; } + public double DoubleField89 { + get { return doubleField89_; } set { - int64Field3_ = value; + doubleField89_ = value; } } - /// Field number for the "int64_field_4" field. - public const int Int64Field4FieldNumber = 4; - private long int64Field4_; + /// Field number for the "double_field_48" field. + public const int DoubleField48FieldNumber = 48; + private double doubleField48_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public long Int64Field4 { - get { return int64Field4_; } + public double DoubleField48 { + get { return doubleField48_; } set { - int64Field4_ = value; + doubleField48_ = value; } } - /// Field number for the "double_field_97" field. - public const int DoubleField97FieldNumber = 97; - private double doubleField97_; + /// Field number for the "double_field_49" field. + public const int DoubleField49FieldNumber = 49; + private double doubleField49_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField97 { - get { return doubleField97_; } + public double DoubleField49 { + get { return doubleField49_; } set { - doubleField97_ = value; + doubleField49_ = value; } } - /// Field number for the "double_field_65" field. - public const int DoubleField65FieldNumber = 65; - private double doubleField65_; + /// Field number for the "double_field_50" field. + public const int DoubleField50FieldNumber = 50; + private double doubleField50_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField65 { - get { return doubleField65_; } + public double DoubleField50 { + get { return doubleField50_; } set { - doubleField65_ = value; + doubleField50_ = value; } } - /// Field number for the "double_field_66" field. - public const int DoubleField66FieldNumber = 66; - private double doubleField66_; + /// Field number for the "double_field_90" field. + public const int DoubleField90FieldNumber = 90; + private double doubleField90_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField66 { - get { return doubleField66_; } + public double DoubleField90 { + get { return doubleField90_; } set { - doubleField66_ = value; + doubleField90_ = value; } } - /// Field number for the "double_field_7" field. - public const int DoubleField7FieldNumber = 7; - private double doubleField7_; + /// Field number for the "double_field_51" field. + public const int DoubleField51FieldNumber = 51; + private double doubleField51_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField7 { - get { return doubleField7_; } + public double DoubleField51 { + get { return doubleField51_; } + set { + doubleField51_ = value; + } + } + + /// Field number for the "double_field_91" field. + public const int DoubleField91FieldNumber = 91; + private double doubleField91_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField91 { + get { return doubleField91_; } + set { + doubleField91_ = value; + } + } + + /// Field number for the "double_field_92" field. + public const int DoubleField92FieldNumber = 92; + private double doubleField92_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField92 { + get { return doubleField92_; } + set { + doubleField92_ = value; + } + } + + /// Field number for the "int64_field_107" field. + public const int Int64Field107FieldNumber = 107; + private long int64Field107_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long Int64Field107 { + get { return int64Field107_; } + set { + int64Field107_ = value; + } + } + + /// Field number for the "double_field_93" field. + public const int DoubleField93FieldNumber = 93; + private double doubleField93_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField93 { + get { return doubleField93_; } + set { + doubleField93_ = value; + } + } + + /// Field number for the "double_field_108" field. + public const int DoubleField108FieldNumber = 108; + private double doubleField108_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField108 { + get { return doubleField108_; } + set { + doubleField108_ = value; + } + } + + /// Field number for the "double_field_52" field. + public const int DoubleField52FieldNumber = 52; + private double doubleField52_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField52 { + get { return doubleField52_; } + set { + doubleField52_ = value; + } + } + + /// Field number for the "double_field_53" field. + public const int DoubleField53FieldNumber = 53; + private double doubleField53_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField53 { + get { return doubleField53_; } + set { + doubleField53_ = value; + } + } + + /// Field number for the "double_field_94" field. + public const int DoubleField94FieldNumber = 94; + private double doubleField94_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField94 { + get { return doubleField94_; } + set { + doubleField94_ = value; + } + } + + /// Field number for the "double_field_54" field. + public const int DoubleField54FieldNumber = 54; + private double doubleField54_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField54 { + get { return doubleField54_; } + set { + doubleField54_ = value; + } + } + + /// Field number for the "double_field_55" field. + public const int DoubleField55FieldNumber = 55; + private double doubleField55_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double DoubleField55 { + get { return doubleField55_; } set { - doubleField7_ = value; + doubleField55_ = value; } } - /// Field number for the "double_field_62" field. - public const int DoubleField62FieldNumber = 62; - private double doubleField62_; + /// Field number for the "double_field_56" field. + public const int DoubleField56FieldNumber = 56; + private double doubleField56_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField62 { - get { return doubleField62_; } + public double DoubleField56 { + get { return doubleField56_; } set { - doubleField62_ = value; + doubleField56_ = value; } } - /// Field number for the "double_field_118" field. - public const int DoubleField118FieldNumber = 118; - private double doubleField118_; + /// Field number for the "double_field_57" field. + public const int DoubleField57FieldNumber = 57; + private double doubleField57_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField118 { - get { return doubleField118_; } + public double DoubleField57 { + get { return doubleField57_; } set { - doubleField118_ = value; + doubleField57_ = value; } } - /// Field number for the "double_field_119" field. - public const int DoubleField119FieldNumber = 119; - private double doubleField119_; + /// Field number for the "double_field_58" field. + public const int DoubleField58FieldNumber = 58; + private double doubleField58_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField119 { - get { return doubleField119_; } + public double DoubleField58 { + get { return doubleField58_; } set { - doubleField119_ = value; + doubleField58_ = value; } } - /// Field number for the "double_field_67" field. - public const int DoubleField67FieldNumber = 67; - private double doubleField67_; + /// Field number for the "int64_field_59" field. + public const int Int64Field59FieldNumber = 59; + private long int64Field59_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField67 { - get { return doubleField67_; } + public long Int64Field59 { + get { return int64Field59_; } set { - doubleField67_ = value; + int64Field59_ = value; } } - /// Field number for the "double_field_120" field. - public const int DoubleField120FieldNumber = 120; - private double doubleField120_; + /// Field number for the "int64_field_60" field. + public const int Int64Field60FieldNumber = 60; + private long int64Field60_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField120 { - get { return doubleField120_; } + public long Int64Field60 { + get { return int64Field60_; } set { - doubleField120_ = value; + int64Field60_ = value; } } - /// Field number for the "double_field_121" field. - public const int DoubleField121FieldNumber = 121; - private double doubleField121_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField121 { - get { return doubleField121_; } - set { - doubleField121_ = value; - } + public override bool Equals(object other) { + return Equals(other as ManyPrimitiveFieldsMessage); } - /// Field number for the "double_field_122" field. - public const int DoubleField122FieldNumber = 122; - private double doubleField122_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField122 { - get { return doubleField122_; } - set { - doubleField122_ = value; + public bool Equals(ManyPrimitiveFieldsMessage other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; } + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField95, other.DoubleField95)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField1, other.DoubleField1)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField79, other.DoubleField79)) return false; + if (Int64Field2 != other.Int64Field2) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField96, other.DoubleField96)) return false; + if (Int64Field3 != other.Int64Field3) return false; + if (Int64Field4 != other.Int64Field4) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField97, other.DoubleField97)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField65, other.DoubleField65)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField66, other.DoubleField66)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField7, other.DoubleField7)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField62, other.DoubleField62)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField118, other.DoubleField118)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField119, other.DoubleField119)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField67, other.DoubleField67)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField120, other.DoubleField120)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField121, other.DoubleField121)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField122, other.DoubleField122)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField123, other.DoubleField123)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField124, other.DoubleField124)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField8, other.DoubleField8)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField9, other.DoubleField9)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField98, other.DoubleField98)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField10, other.DoubleField10)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField11, other.DoubleField11)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField99, other.DoubleField99)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField84, other.DoubleField84)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField14, other.DoubleField14)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField77, other.DoubleField77)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField15, other.DoubleField15)) return false; + if (Int64Field19 != other.Int64Field19) return false; + if (Int64Field115 != other.Int64Field115) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField116, other.DoubleField116)) return false; + if (Int64Field117 != other.Int64Field117) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField20, other.DoubleField20)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField21, other.DoubleField21)) return false; + if (StringField73 != other.StringField73) return false; + if (StringField74 != other.StringField74) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField22, other.DoubleField22)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField69, other.DoubleField69)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField70, other.DoubleField70)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField71, other.DoubleField71)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField72, other.DoubleField72)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField25, other.DoubleField25)) return false; + if (Int64Field26 != other.Int64Field26) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField68, other.DoubleField68)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField28, other.DoubleField28)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField106, other.DoubleField106)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField29, other.DoubleField29)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField30, other.DoubleField30)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField101, other.DoubleField101)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField102, other.DoubleField102)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField103, other.DoubleField103)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField104, other.DoubleField104)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField105, other.DoubleField105)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField31, other.DoubleField31)) return false; + if (Int64Field32 != other.Int64Field32) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField75, other.DoubleField75)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField129, other.DoubleField129)) return false; + if (EnumField80 != other.EnumField80) return false; + if (EnumField81 != other.EnumField81) return false; + if (Int64Field82 != other.Int64Field82) return false; + if (EnumField83 != other.EnumField83) return false; + if (Int64Field85 != other.Int64Field85) return false; + if (Int64Field86 != other.Int64Field86) return false; + if (Int64Field87 != other.Int64Field87) return false; + if (Int64Field125 != other.Int64Field125) return false; + if (Int64Field37 != other.Int64Field37) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField38, other.DoubleField38)) return false; + if (Interactions != other.Interactions) return false; + if(!repeatedIntField100_.Equals(other.repeatedIntField100_)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField40, other.DoubleField40)) return false; + if (Int64Field41 != other.Int64Field41) return false; + if (Int64Field126 != other.Int64Field126) return false; + if (Int64Field127 != other.Int64Field127) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField128, other.DoubleField128)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField109, other.DoubleField109)) return false; + if (Int64Field110 != other.Int64Field110) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField111, other.DoubleField111)) return false; + if (Int64Field112 != other.Int64Field112) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField113, other.DoubleField113)) return false; + if (Int64Field114 != other.Int64Field114) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField42, other.DoubleField42)) return false; + if (Int64Field43 != other.Int64Field43) return false; + if (Int64Field44 != other.Int64Field44) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField45, other.DoubleField45)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField46, other.DoubleField46)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField78, other.DoubleField78)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField88, other.DoubleField88)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField47, other.DoubleField47)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField89, other.DoubleField89)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField48, other.DoubleField48)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField49, other.DoubleField49)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField50, other.DoubleField50)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField90, other.DoubleField90)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField51, other.DoubleField51)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField91, other.DoubleField91)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField92, other.DoubleField92)) return false; + if (Int64Field107 != other.Int64Field107) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField93, other.DoubleField93)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField108, other.DoubleField108)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField52, other.DoubleField52)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField53, other.DoubleField53)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField94, other.DoubleField94)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField54, other.DoubleField54)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField55, other.DoubleField55)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField56, other.DoubleField56)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField57, other.DoubleField57)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField58, other.DoubleField58)) return false; + if (Int64Field59 != other.Int64Field59) return false; + if (Int64Field60 != other.Int64Field60) return false; + return Equals(_unknownFields, other._unknownFields); } - /// Field number for the "double_field_123" field. - public const int DoubleField123FieldNumber = 123; - private double doubleField123_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField123 { - get { return doubleField123_; } - set { - doubleField123_ = value; + public override int GetHashCode() { + int hash = 1; + if (DoubleField95 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField95); + if (DoubleField1 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField1); + if (DoubleField79 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField79); + if (Int64Field2 != 0L) hash ^= Int64Field2.GetHashCode(); + if (DoubleField96 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField96); + if (Int64Field3 != 0L) hash ^= Int64Field3.GetHashCode(); + if (Int64Field4 != 0L) hash ^= Int64Field4.GetHashCode(); + if (DoubleField97 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField97); + if (DoubleField65 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField65); + if (DoubleField66 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField66); + if (DoubleField7 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField7); + if (DoubleField62 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField62); + if (DoubleField118 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField118); + if (DoubleField119 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField119); + if (DoubleField67 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField67); + if (DoubleField120 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField120); + if (DoubleField121 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField121); + if (DoubleField122 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField122); + if (DoubleField123 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField123); + if (DoubleField124 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField124); + if (DoubleField8 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField8); + if (DoubleField9 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField9); + if (DoubleField98 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField98); + if (DoubleField10 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField10); + if (DoubleField11 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField11); + if (DoubleField99 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField99); + if (DoubleField84 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField84); + if (DoubleField14 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField14); + if (DoubleField77 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField77); + if (DoubleField15 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField15); + if (Int64Field19 != 0L) hash ^= Int64Field19.GetHashCode(); + if (Int64Field115 != 0L) hash ^= Int64Field115.GetHashCode(); + if (DoubleField116 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField116); + if (Int64Field117 != 0L) hash ^= Int64Field117.GetHashCode(); + if (DoubleField20 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField20); + if (DoubleField21 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField21); + if (StringField73.Length != 0) hash ^= StringField73.GetHashCode(); + if (StringField74.Length != 0) hash ^= StringField74.GetHashCode(); + if (DoubleField22 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField22); + if (DoubleField69 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField69); + if (DoubleField70 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField70); + if (DoubleField71 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField71); + if (DoubleField72 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField72); + if (DoubleField25 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField25); + if (Int64Field26 != 0L) hash ^= Int64Field26.GetHashCode(); + if (DoubleField68 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField68); + if (DoubleField28 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField28); + if (DoubleField106 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField106); + if (DoubleField29 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField29); + if (DoubleField30 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField30); + if (DoubleField101 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField101); + if (DoubleField102 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField102); + if (DoubleField103 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField103); + if (DoubleField104 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField104); + if (DoubleField105 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField105); + if (DoubleField31 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField31); + if (Int64Field32 != 0L) hash ^= Int64Field32.GetHashCode(); + if (DoubleField75 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField75); + if (DoubleField129 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField129); + if (EnumField80 != 0) hash ^= EnumField80.GetHashCode(); + if (EnumField81 != 0) hash ^= EnumField81.GetHashCode(); + if (Int64Field82 != 0L) hash ^= Int64Field82.GetHashCode(); + if (EnumField83 != 0) hash ^= EnumField83.GetHashCode(); + if (Int64Field85 != 0L) hash ^= Int64Field85.GetHashCode(); + if (Int64Field86 != 0L) hash ^= Int64Field86.GetHashCode(); + if (Int64Field87 != 0L) hash ^= Int64Field87.GetHashCode(); + if (Int64Field125 != 0L) hash ^= Int64Field125.GetHashCode(); + if (Int64Field37 != 0L) hash ^= Int64Field37.GetHashCode(); + if (DoubleField38 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField38); + if (Interactions != 0L) hash ^= Interactions.GetHashCode(); + hash ^= repeatedIntField100_.GetHashCode(); + if (DoubleField40 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField40); + if (Int64Field41 != 0L) hash ^= Int64Field41.GetHashCode(); + if (Int64Field126 != 0L) hash ^= Int64Field126.GetHashCode(); + if (Int64Field127 != 0L) hash ^= Int64Field127.GetHashCode(); + if (DoubleField128 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField128); + if (DoubleField109 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField109); + if (Int64Field110 != 0L) hash ^= Int64Field110.GetHashCode(); + if (DoubleField111 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField111); + if (Int64Field112 != 0L) hash ^= Int64Field112.GetHashCode(); + if (DoubleField113 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField113); + if (Int64Field114 != 0L) hash ^= Int64Field114.GetHashCode(); + if (DoubleField42 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField42); + if (Int64Field43 != 0L) hash ^= Int64Field43.GetHashCode(); + if (Int64Field44 != 0L) hash ^= Int64Field44.GetHashCode(); + if (DoubleField45 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField45); + if (DoubleField46 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField46); + if (DoubleField78 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField78); + if (DoubleField88 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField88); + if (DoubleField47 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField47); + if (DoubleField89 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField89); + if (DoubleField48 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField48); + if (DoubleField49 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField49); + if (DoubleField50 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField50); + if (DoubleField90 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField90); + if (DoubleField51 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField51); + if (DoubleField91 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField91); + if (DoubleField92 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField92); + if (Int64Field107 != 0L) hash ^= Int64Field107.GetHashCode(); + if (DoubleField93 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField93); + if (DoubleField108 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField108); + if (DoubleField52 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField52); + if (DoubleField53 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField53); + if (DoubleField94 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField94); + if (DoubleField54 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField54); + if (DoubleField55 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField55); + if (DoubleField56 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField56); + if (DoubleField57 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField57); + if (DoubleField58 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField58); + if (Int64Field59 != 0L) hash ^= Int64Field59.GetHashCode(); + if (Int64Field60 != 0L) hash ^= Int64Field60.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); } + return hash; } - /// Field number for the "double_field_124" field. - public const int DoubleField124FieldNumber = 124; - private double doubleField124_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField124 { - get { return doubleField124_; } - set { - doubleField124_ = value; - } + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); } - /// Field number for the "double_field_8" field. - public const int DoubleField8FieldNumber = 8; - private double doubleField8_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField8 { - get { return doubleField8_; } - set { - doubleField8_ = value; + public void WriteTo(pb::CodedOutputStream output) { + if (DoubleField1 != 0D) { + output.WriteRawTag(9); + output.WriteDouble(DoubleField1); } - } - - /// Field number for the "double_field_9" field. - public const int DoubleField9FieldNumber = 9; - private double doubleField9_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField9 { - get { return doubleField9_; } - set { - doubleField9_ = value; + if (Int64Field2 != 0L) { + output.WriteRawTag(16); + output.WriteInt64(Int64Field2); } - } - - /// Field number for the "double_field_98" field. - public const int DoubleField98FieldNumber = 98; - private double doubleField98_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField98 { - get { return doubleField98_; } - set { - doubleField98_ = value; + if (Int64Field3 != 0L) { + output.WriteRawTag(24); + output.WriteInt64(Int64Field3); } - } - - /// Field number for the "double_field_10" field. - public const int DoubleField10FieldNumber = 10; - private double doubleField10_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField10 { - get { return doubleField10_; } - set { - doubleField10_ = value; + if (Int64Field4 != 0L) { + output.WriteRawTag(32); + output.WriteInt64(Int64Field4); } - } - - /// Field number for the "double_field_11" field. - public const int DoubleField11FieldNumber = 11; - private double doubleField11_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField11 { - get { return doubleField11_; } - set { - doubleField11_ = value; + if (DoubleField7 != 0D) { + output.WriteRawTag(57); + output.WriteDouble(DoubleField7); } - } - - /// Field number for the "double_field_99" field. - public const int DoubleField99FieldNumber = 99; - private double doubleField99_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField99 { - get { return doubleField99_; } - set { - doubleField99_ = value; + if (DoubleField8 != 0D) { + output.WriteRawTag(65); + output.WriteDouble(DoubleField8); } - } - - /// Field number for the "double_field_84" field. - public const int DoubleField84FieldNumber = 84; - private double doubleField84_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField84 { - get { return doubleField84_; } - set { - doubleField84_ = value; + if (DoubleField9 != 0D) { + output.WriteRawTag(73); + output.WriteDouble(DoubleField9); } - } - - /// Field number for the "double_field_14" field. - public const int DoubleField14FieldNumber = 14; - private double doubleField14_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField14 { - get { return doubleField14_; } - set { - doubleField14_ = value; + if (DoubleField10 != 0D) { + output.WriteRawTag(81); + output.WriteDouble(DoubleField10); } - } - - /// Field number for the "double_field_77" field. - public const int DoubleField77FieldNumber = 77; - private double doubleField77_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField77 { - get { return doubleField77_; } - set { - doubleField77_ = value; + if (DoubleField11 != 0D) { + output.WriteRawTag(89); + output.WriteDouble(DoubleField11); } - } - - /// Field number for the "double_field_15" field. - public const int DoubleField15FieldNumber = 15; - private double doubleField15_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField15 { - get { return doubleField15_; } - set { - doubleField15_ = value; + if (DoubleField14 != 0D) { + output.WriteRawTag(113); + output.WriteDouble(DoubleField14); } - } - - /// Field number for the "int64_field_19" field. - public const int Int64Field19FieldNumber = 19; - private long int64Field19_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public long Int64Field19 { - get { return int64Field19_; } - set { - int64Field19_ = value; + if (DoubleField15 != 0D) { + output.WriteRawTag(121); + output.WriteDouble(DoubleField15); } - } - - /// Field number for the "int64_field_115" field. - public const int Int64Field115FieldNumber = 115; - private long int64Field115_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public long Int64Field115 { - get { return int64Field115_; } - set { - int64Field115_ = value; + if (Int64Field19 != 0L) { + output.WriteRawTag(152, 1); + output.WriteInt64(Int64Field19); } - } - - /// Field number for the "double_field_116" field. - public const int DoubleField116FieldNumber = 116; - private double doubleField116_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField116 { - get { return doubleField116_; } - set { - doubleField116_ = value; + if (DoubleField20 != 0D) { + output.WriteRawTag(161, 1); + output.WriteDouble(DoubleField20); } - } - - /// Field number for the "int64_field_117" field. - public const int Int64Field117FieldNumber = 117; - private long int64Field117_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public long Int64Field117 { - get { return int64Field117_; } - set { - int64Field117_ = value; + if (DoubleField21 != 0D) { + output.WriteRawTag(169, 1); + output.WriteDouble(DoubleField21); } - } - - /// Field number for the "double_field_20" field. - public const int DoubleField20FieldNumber = 20; - private double doubleField20_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField20 { - get { return doubleField20_; } - set { - doubleField20_ = value; + if (DoubleField22 != 0D) { + output.WriteRawTag(177, 1); + output.WriteDouble(DoubleField22); } - } - - /// Field number for the "double_field_21" field. - public const int DoubleField21FieldNumber = 21; - private double doubleField21_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField21 { - get { return doubleField21_; } - set { - doubleField21_ = value; + if (DoubleField25 != 0D) { + output.WriteRawTag(201, 1); + output.WriteDouble(DoubleField25); } - } - - /// Field number for the "string_field_73" field. - public const int StringField73FieldNumber = 73; - private string stringField73_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public string StringField73 { - get { return stringField73_; } - set { - stringField73_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + if (Int64Field26 != 0L) { + output.WriteRawTag(208, 1); + output.WriteInt64(Int64Field26); } - } - - /// Field number for the "string_field_74" field. - public const int StringField74FieldNumber = 74; - private string stringField74_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public string StringField74 { - get { return stringField74_; } - set { - stringField74_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + if (DoubleField28 != 0D) { + output.WriteRawTag(225, 1); + output.WriteDouble(DoubleField28); } - } - - /// Field number for the "double_field_22" field. - public const int DoubleField22FieldNumber = 22; - private double doubleField22_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField22 { - get { return doubleField22_; } - set { - doubleField22_ = value; + if (DoubleField29 != 0D) { + output.WriteRawTag(233, 1); + output.WriteDouble(DoubleField29); } - } - - /// Field number for the "double_field_69" field. - public const int DoubleField69FieldNumber = 69; - private double doubleField69_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField69 { - get { return doubleField69_; } - set { - doubleField69_ = value; + if (DoubleField30 != 0D) { + output.WriteRawTag(241, 1); + output.WriteDouble(DoubleField30); } - } - - /// Field number for the "double_field_70" field. - public const int DoubleField70FieldNumber = 70; - private double doubleField70_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField70 { - get { return doubleField70_; } - set { - doubleField70_ = value; + if (DoubleField31 != 0D) { + output.WriteRawTag(249, 1); + output.WriteDouble(DoubleField31); } - } - - /// Field number for the "double_field_71" field. - public const int DoubleField71FieldNumber = 71; - private double doubleField71_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField71 { - get { return doubleField71_; } - set { - doubleField71_ = value; + if (Int64Field32 != 0L) { + output.WriteRawTag(128, 2); + output.WriteInt64(Int64Field32); } - } - - /// Field number for the "double_field_72" field. - public const int DoubleField72FieldNumber = 72; - private double doubleField72_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField72 { - get { return doubleField72_; } - set { - doubleField72_ = value; + if (Int64Field37 != 0L) { + output.WriteRawTag(168, 2); + output.WriteInt64(Int64Field37); } - } - - /// Field number for the "double_field_25" field. - public const int DoubleField25FieldNumber = 25; - private double doubleField25_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField25 { - get { return doubleField25_; } - set { - doubleField25_ = value; + if (DoubleField38 != 0D) { + output.WriteRawTag(177, 2); + output.WriteDouble(DoubleField38); } - } - - /// Field number for the "int64_field_26" field. - public const int Int64Field26FieldNumber = 26; - private long int64Field26_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public long Int64Field26 { - get { return int64Field26_; } - set { - int64Field26_ = value; + if (Interactions != 0L) { + output.WriteRawTag(184, 2); + output.WriteInt64(Interactions); } - } - - /// Field number for the "double_field_68" field. - public const int DoubleField68FieldNumber = 68; - private double doubleField68_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField68 { - get { return doubleField68_; } - set { - doubleField68_ = value; + if (DoubleField40 != 0D) { + output.WriteRawTag(193, 2); + output.WriteDouble(DoubleField40); } - } - - /// Field number for the "double_field_28" field. - public const int DoubleField28FieldNumber = 28; - private double doubleField28_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField28 { - get { return doubleField28_; } - set { - doubleField28_ = value; + if (Int64Field41 != 0L) { + output.WriteRawTag(200, 2); + output.WriteInt64(Int64Field41); } - } - - /// Field number for the "double_field_106" field. - public const int DoubleField106FieldNumber = 106; - private double doubleField106_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField106 { - get { return doubleField106_; } - set { - doubleField106_ = value; + if (DoubleField42 != 0D) { + output.WriteRawTag(209, 2); + output.WriteDouble(DoubleField42); } - } - - /// Field number for the "double_field_29" field. - public const int DoubleField29FieldNumber = 29; - private double doubleField29_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField29 { - get { return doubleField29_; } - set { - doubleField29_ = value; + if (Int64Field43 != 0L) { + output.WriteRawTag(216, 2); + output.WriteInt64(Int64Field43); } - } - - /// Field number for the "double_field_30" field. - public const int DoubleField30FieldNumber = 30; - private double doubleField30_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField30 { - get { return doubleField30_; } - set { - doubleField30_ = value; + if (Int64Field44 != 0L) { + output.WriteRawTag(224, 2); + output.WriteInt64(Int64Field44); } - } - - /// Field number for the "double_field_101" field. - public const int DoubleField101FieldNumber = 101; - private double doubleField101_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField101 { - get { return doubleField101_; } - set { - doubleField101_ = value; + if (DoubleField45 != 0D) { + output.WriteRawTag(233, 2); + output.WriteDouble(DoubleField45); } - } - - /// Field number for the "double_field_102" field. - public const int DoubleField102FieldNumber = 102; - private double doubleField102_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField102 { - get { return doubleField102_; } - set { - doubleField102_ = value; + if (DoubleField46 != 0D) { + output.WriteRawTag(241, 2); + output.WriteDouble(DoubleField46); } - } - - /// Field number for the "double_field_103" field. - public const int DoubleField103FieldNumber = 103; - private double doubleField103_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField103 { - get { return doubleField103_; } - set { - doubleField103_ = value; + if (DoubleField47 != 0D) { + output.WriteRawTag(249, 2); + output.WriteDouble(DoubleField47); + } + if (DoubleField48 != 0D) { + output.WriteRawTag(129, 3); + output.WriteDouble(DoubleField48); + } + if (DoubleField49 != 0D) { + output.WriteRawTag(137, 3); + output.WriteDouble(DoubleField49); } - } - - /// Field number for the "double_field_104" field. - public const int DoubleField104FieldNumber = 104; - private double doubleField104_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField104 { - get { return doubleField104_; } - set { - doubleField104_ = value; + if (DoubleField50 != 0D) { + output.WriteRawTag(145, 3); + output.WriteDouble(DoubleField50); } - } - - /// Field number for the "double_field_105" field. - public const int DoubleField105FieldNumber = 105; - private double doubleField105_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField105 { - get { return doubleField105_; } - set { - doubleField105_ = value; + if (DoubleField51 != 0D) { + output.WriteRawTag(153, 3); + output.WriteDouble(DoubleField51); } - } - - /// Field number for the "double_field_31" field. - public const int DoubleField31FieldNumber = 31; - private double doubleField31_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField31 { - get { return doubleField31_; } - set { - doubleField31_ = value; + if (DoubleField52 != 0D) { + output.WriteRawTag(161, 3); + output.WriteDouble(DoubleField52); } - } - - /// Field number for the "int64_field_32" field. - public const int Int64Field32FieldNumber = 32; - private long int64Field32_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public long Int64Field32 { - get { return int64Field32_; } - set { - int64Field32_ = value; + if (DoubleField53 != 0D) { + output.WriteRawTag(169, 3); + output.WriteDouble(DoubleField53); } - } - - /// Field number for the "double_field_75" field. - public const int DoubleField75FieldNumber = 75; - private double doubleField75_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField75 { - get { return doubleField75_; } - set { - doubleField75_ = value; + if (DoubleField54 != 0D) { + output.WriteRawTag(177, 3); + output.WriteDouble(DoubleField54); } - } - - /// Field number for the "double_field_129" field. - public const int DoubleField129FieldNumber = 129; - private double doubleField129_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField129 { - get { return doubleField129_; } - set { - doubleField129_ = value; + if (DoubleField55 != 0D) { + output.WriteRawTag(185, 3); + output.WriteDouble(DoubleField55); } - } - - /// Field number for the "enum_field_80" field. - public const int EnumField80FieldNumber = 80; - private int enumField80_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int EnumField80 { - get { return enumField80_; } - set { - enumField80_ = value; + if (DoubleField56 != 0D) { + output.WriteRawTag(193, 3); + output.WriteDouble(DoubleField56); } - } - - /// Field number for the "enum_field_81" field. - public const int EnumField81FieldNumber = 81; - private int enumField81_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int EnumField81 { - get { return enumField81_; } - set { - enumField81_ = value; + if (DoubleField57 != 0D) { + output.WriteRawTag(201, 3); + output.WriteDouble(DoubleField57); } - } - - /// Field number for the "int64_field_82" field. - public const int Int64Field82FieldNumber = 82; - private long int64Field82_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public long Int64Field82 { - get { return int64Field82_; } - set { - int64Field82_ = value; + if (DoubleField58 != 0D) { + output.WriteRawTag(209, 3); + output.WriteDouble(DoubleField58); } - } - - /// Field number for the "enum_field_83" field. - public const int EnumField83FieldNumber = 83; - private int enumField83_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int EnumField83 { - get { return enumField83_; } - set { - enumField83_ = value; + if (Int64Field59 != 0L) { + output.WriteRawTag(216, 3); + output.WriteInt64(Int64Field59); } - } - - /// Field number for the "int64_field_85" field. - public const int Int64Field85FieldNumber = 85; - private long int64Field85_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public long Int64Field85 { - get { return int64Field85_; } - set { - int64Field85_ = value; + if (Int64Field60 != 0L) { + output.WriteRawTag(224, 3); + output.WriteInt64(Int64Field60); } - } - - /// Field number for the "int64_field_86" field. - public const int Int64Field86FieldNumber = 86; - private long int64Field86_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public long Int64Field86 { - get { return int64Field86_; } - set { - int64Field86_ = value; + if (DoubleField62 != 0D) { + output.WriteRawTag(241, 3); + output.WriteDouble(DoubleField62); } - } - - /// Field number for the "int64_field_87" field. - public const int Int64Field87FieldNumber = 87; - private long int64Field87_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public long Int64Field87 { - get { return int64Field87_; } - set { - int64Field87_ = value; + if (DoubleField65 != 0D) { + output.WriteRawTag(137, 4); + output.WriteDouble(DoubleField65); } - } - - /// Field number for the "int64_field_125" field. - public const int Int64Field125FieldNumber = 125; - private long int64Field125_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public long Int64Field125 { - get { return int64Field125_; } - set { - int64Field125_ = value; + if (DoubleField66 != 0D) { + output.WriteRawTag(145, 4); + output.WriteDouble(DoubleField66); } - } - - /// Field number for the "int64_field_37" field. - public const int Int64Field37FieldNumber = 37; - private long int64Field37_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public long Int64Field37 { - get { return int64Field37_; } - set { - int64Field37_ = value; + if (DoubleField67 != 0D) { + output.WriteRawTag(153, 4); + output.WriteDouble(DoubleField67); } - } - - /// Field number for the "double_field_38" field. - public const int DoubleField38FieldNumber = 38; - private double doubleField38_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField38 { - get { return doubleField38_; } - set { - doubleField38_ = value; + if (DoubleField68 != 0D) { + output.WriteRawTag(161, 4); + output.WriteDouble(DoubleField68); } - } - - /// Field number for the "interactions" field. - public const int InteractionsFieldNumber = 39; - private long interactions_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public long Interactions { - get { return interactions_; } - set { - interactions_ = value; + if (DoubleField69 != 0D) { + output.WriteRawTag(169, 4); + output.WriteDouble(DoubleField69); } - } - - /// Field number for the "repeated_int_field_100" field. - public const int RepeatedIntField100FieldNumber = 100; - private static readonly pb::FieldCodec _repeated_repeatedIntField100_codec - = pb::FieldCodec.ForInt32(802); - private readonly pbc::RepeatedField repeatedIntField100_ = new pbc::RepeatedField(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::RepeatedField RepeatedIntField100 { - get { return repeatedIntField100_; } - } - - /// Field number for the "double_field_40" field. - public const int DoubleField40FieldNumber = 40; - private double doubleField40_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField40 { - get { return doubleField40_; } - set { - doubleField40_ = value; + if (DoubleField70 != 0D) { + output.WriteRawTag(177, 4); + output.WriteDouble(DoubleField70); } - } - - /// Field number for the "int64_field_41" field. - public const int Int64Field41FieldNumber = 41; - private long int64Field41_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public long Int64Field41 { - get { return int64Field41_; } - set { - int64Field41_ = value; + if (DoubleField71 != 0D) { + output.WriteRawTag(185, 4); + output.WriteDouble(DoubleField71); } - } - - /// Field number for the "int64_field_126" field. - public const int Int64Field126FieldNumber = 126; - private long int64Field126_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public long Int64Field126 { - get { return int64Field126_; } - set { - int64Field126_ = value; + if (DoubleField72 != 0D) { + output.WriteRawTag(193, 4); + output.WriteDouble(DoubleField72); } - } - - /// Field number for the "int64_field_127" field. - public const int Int64Field127FieldNumber = 127; - private long int64Field127_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public long Int64Field127 { - get { return int64Field127_; } - set { - int64Field127_ = value; + if (StringField73.Length != 0) { + output.WriteRawTag(202, 4); + output.WriteString(StringField73); } - } - - /// Field number for the "double_field_128" field. - public const int DoubleField128FieldNumber = 128; - private double doubleField128_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField128 { - get { return doubleField128_; } - set { - doubleField128_ = value; + if (StringField74.Length != 0) { + output.WriteRawTag(210, 4); + output.WriteString(StringField74); } - } - - /// Field number for the "double_field_109" field. - public const int DoubleField109FieldNumber = 109; - private double doubleField109_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField109 { - get { return doubleField109_; } - set { - doubleField109_ = value; + if (DoubleField75 != 0D) { + output.WriteRawTag(217, 4); + output.WriteDouble(DoubleField75); } - } - - /// Field number for the "int64_field_110" field. - public const int Int64Field110FieldNumber = 110; - private long int64Field110_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public long Int64Field110 { - get { return int64Field110_; } - set { - int64Field110_ = value; + if (DoubleField77 != 0D) { + output.WriteRawTag(233, 4); + output.WriteDouble(DoubleField77); } - } - - /// Field number for the "double_field_111" field. - public const int DoubleField111FieldNumber = 111; - private double doubleField111_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField111 { - get { return doubleField111_; } - set { - doubleField111_ = value; + if (DoubleField78 != 0D) { + output.WriteRawTag(241, 4); + output.WriteDouble(DoubleField78); } - } - - /// Field number for the "int64_field_112" field. - public const int Int64Field112FieldNumber = 112; - private long int64Field112_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public long Int64Field112 { - get { return int64Field112_; } - set { - int64Field112_ = value; + if (DoubleField79 != 0D) { + output.WriteRawTag(249, 4); + output.WriteDouble(DoubleField79); } - } - - /// Field number for the "double_field_113" field. - public const int DoubleField113FieldNumber = 113; - private double doubleField113_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField113 { - get { return doubleField113_; } - set { - doubleField113_ = value; + if (EnumField80 != 0) { + output.WriteRawTag(128, 5); + output.WriteInt32(EnumField80); } - } - - /// Field number for the "int64_field_114" field. - public const int Int64Field114FieldNumber = 114; - private long int64Field114_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public long Int64Field114 { - get { return int64Field114_; } - set { - int64Field114_ = value; + if (EnumField81 != 0) { + output.WriteRawTag(136, 5); + output.WriteInt32(EnumField81); } - } - - /// Field number for the "double_field_42" field. - public const int DoubleField42FieldNumber = 42; - private double doubleField42_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField42 { - get { return doubleField42_; } - set { - doubleField42_ = value; + if (Int64Field82 != 0L) { + output.WriteRawTag(144, 5); + output.WriteInt64(Int64Field82); } - } - - /// Field number for the "int64_field_43" field. - public const int Int64Field43FieldNumber = 43; - private long int64Field43_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public long Int64Field43 { - get { return int64Field43_; } - set { - int64Field43_ = value; + if (EnumField83 != 0) { + output.WriteRawTag(152, 5); + output.WriteInt32(EnumField83); } - } - - /// Field number for the "int64_field_44" field. - public const int Int64Field44FieldNumber = 44; - private long int64Field44_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public long Int64Field44 { - get { return int64Field44_; } - set { - int64Field44_ = value; + if (DoubleField84 != 0D) { + output.WriteRawTag(161, 5); + output.WriteDouble(DoubleField84); } - } - - /// Field number for the "double_field_45" field. - public const int DoubleField45FieldNumber = 45; - private double doubleField45_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField45 { - get { return doubleField45_; } - set { - doubleField45_ = value; + if (Int64Field85 != 0L) { + output.WriteRawTag(168, 5); + output.WriteInt64(Int64Field85); } - } - - /// Field number for the "double_field_46" field. - public const int DoubleField46FieldNumber = 46; - private double doubleField46_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField46 { - get { return doubleField46_; } - set { - doubleField46_ = value; + if (Int64Field86 != 0L) { + output.WriteRawTag(176, 5); + output.WriteInt64(Int64Field86); } - } - - /// Field number for the "double_field_78" field. - public const int DoubleField78FieldNumber = 78; - private double doubleField78_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField78 { - get { return doubleField78_; } - set { - doubleField78_ = value; + if (Int64Field87 != 0L) { + output.WriteRawTag(184, 5); + output.WriteInt64(Int64Field87); } - } - - /// Field number for the "double_field_88" field. - public const int DoubleField88FieldNumber = 88; - private double doubleField88_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField88 { - get { return doubleField88_; } - set { - doubleField88_ = value; + if (DoubleField88 != 0D) { + output.WriteRawTag(193, 5); + output.WriteDouble(DoubleField88); } - } - - /// Field number for the "double_field_47" field. - public const int DoubleField47FieldNumber = 47; - private double doubleField47_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField47 { - get { return doubleField47_; } - set { - doubleField47_ = value; + if (DoubleField89 != 0D) { + output.WriteRawTag(201, 5); + output.WriteDouble(DoubleField89); } - } - - /// Field number for the "double_field_89" field. - public const int DoubleField89FieldNumber = 89; - private double doubleField89_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField89 { - get { return doubleField89_; } - set { - doubleField89_ = value; + if (DoubleField90 != 0D) { + output.WriteRawTag(209, 5); + output.WriteDouble(DoubleField90); } - } - - /// Field number for the "double_field_48" field. - public const int DoubleField48FieldNumber = 48; - private double doubleField48_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField48 { - get { return doubleField48_; } - set { - doubleField48_ = value; + if (DoubleField91 != 0D) { + output.WriteRawTag(217, 5); + output.WriteDouble(DoubleField91); + } + if (DoubleField92 != 0D) { + output.WriteRawTag(225, 5); + output.WriteDouble(DoubleField92); + } + if (DoubleField93 != 0D) { + output.WriteRawTag(233, 5); + output.WriteDouble(DoubleField93); } - } - - /// Field number for the "double_field_49" field. - public const int DoubleField49FieldNumber = 49; - private double doubleField49_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField49 { - get { return doubleField49_; } - set { - doubleField49_ = value; + if (DoubleField94 != 0D) { + output.WriteRawTag(241, 5); + output.WriteDouble(DoubleField94); } - } - - /// Field number for the "double_field_50" field. - public const int DoubleField50FieldNumber = 50; - private double doubleField50_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField50 { - get { return doubleField50_; } - set { - doubleField50_ = value; + if (DoubleField95 != 0D) { + output.WriteRawTag(249, 5); + output.WriteDouble(DoubleField95); } - } - - /// Field number for the "double_field_90" field. - public const int DoubleField90FieldNumber = 90; - private double doubleField90_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField90 { - get { return doubleField90_; } - set { - doubleField90_ = value; + if (DoubleField96 != 0D) { + output.WriteRawTag(129, 6); + output.WriteDouble(DoubleField96); } - } - - /// Field number for the "double_field_51" field. - public const int DoubleField51FieldNumber = 51; - private double doubleField51_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField51 { - get { return doubleField51_; } - set { - doubleField51_ = value; + if (DoubleField97 != 0D) { + output.WriteRawTag(137, 6); + output.WriteDouble(DoubleField97); } - } - - /// Field number for the "double_field_91" field. - public const int DoubleField91FieldNumber = 91; - private double doubleField91_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField91 { - get { return doubleField91_; } - set { - doubleField91_ = value; + if (DoubleField98 != 0D) { + output.WriteRawTag(145, 6); + output.WriteDouble(DoubleField98); } - } - - /// Field number for the "double_field_92" field. - public const int DoubleField92FieldNumber = 92; - private double doubleField92_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField92 { - get { return doubleField92_; } - set { - doubleField92_ = value; + if (DoubleField99 != 0D) { + output.WriteRawTag(153, 6); + output.WriteDouble(DoubleField99); } - } - - /// Field number for the "int64_field_107" field. - public const int Int64Field107FieldNumber = 107; - private long int64Field107_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public long Int64Field107 { - get { return int64Field107_; } - set { - int64Field107_ = value; + repeatedIntField100_.WriteTo(output, _repeated_repeatedIntField100_codec); + if (DoubleField101 != 0D) { + output.WriteRawTag(169, 6); + output.WriteDouble(DoubleField101); } - } - - /// Field number for the "double_field_93" field. - public const int DoubleField93FieldNumber = 93; - private double doubleField93_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField93 { - get { return doubleField93_; } - set { - doubleField93_ = value; + if (DoubleField102 != 0D) { + output.WriteRawTag(177, 6); + output.WriteDouble(DoubleField102); } - } - - /// Field number for the "double_field_108" field. - public const int DoubleField108FieldNumber = 108; - private double doubleField108_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField108 { - get { return doubleField108_; } - set { - doubleField108_ = value; + if (DoubleField103 != 0D) { + output.WriteRawTag(185, 6); + output.WriteDouble(DoubleField103); } - } - - /// Field number for the "double_field_52" field. - public const int DoubleField52FieldNumber = 52; - private double doubleField52_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField52 { - get { return doubleField52_; } - set { - doubleField52_ = value; + if (DoubleField104 != 0D) { + output.WriteRawTag(193, 6); + output.WriteDouble(DoubleField104); } - } - - /// Field number for the "double_field_53" field. - public const int DoubleField53FieldNumber = 53; - private double doubleField53_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField53 { - get { return doubleField53_; } - set { - doubleField53_ = value; + if (DoubleField105 != 0D) { + output.WriteRawTag(201, 6); + output.WriteDouble(DoubleField105); } - } - - /// Field number for the "double_field_94" field. - public const int DoubleField94FieldNumber = 94; - private double doubleField94_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField94 { - get { return doubleField94_; } - set { - doubleField94_ = value; + if (DoubleField106 != 0D) { + output.WriteRawTag(209, 6); + output.WriteDouble(DoubleField106); } - } - - /// Field number for the "double_field_54" field. - public const int DoubleField54FieldNumber = 54; - private double doubleField54_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField54 { - get { return doubleField54_; } - set { - doubleField54_ = value; + if (Int64Field107 != 0L) { + output.WriteRawTag(216, 6); + output.WriteInt64(Int64Field107); } - } - - /// Field number for the "double_field_55" field. - public const int DoubleField55FieldNumber = 55; - private double doubleField55_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField55 { - get { return doubleField55_; } - set { - doubleField55_ = value; + if (DoubleField108 != 0D) { + output.WriteRawTag(225, 6); + output.WriteDouble(DoubleField108); } - } - - /// Field number for the "double_field_56" field. - public const int DoubleField56FieldNumber = 56; - private double doubleField56_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField56 { - get { return doubleField56_; } - set { - doubleField56_ = value; + if (DoubleField109 != 0D) { + output.WriteRawTag(233, 6); + output.WriteDouble(DoubleField109); } - } - - /// Field number for the "double_field_57" field. - public const int DoubleField57FieldNumber = 57; - private double doubleField57_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField57 { - get { return doubleField57_; } - set { - doubleField57_ = value; + if (Int64Field110 != 0L) { + output.WriteRawTag(240, 6); + output.WriteInt64(Int64Field110); } - } - - /// Field number for the "double_field_58" field. - public const int DoubleField58FieldNumber = 58; - private double doubleField58_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double DoubleField58 { - get { return doubleField58_; } - set { - doubleField58_ = value; + if (DoubleField111 != 0D) { + output.WriteRawTag(249, 6); + output.WriteDouble(DoubleField111); } - } - - /// Field number for the "int64_field_59" field. - public const int Int64Field59FieldNumber = 59; - private long int64Field59_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public long Int64Field59 { - get { return int64Field59_; } - set { - int64Field59_ = value; + if (Int64Field112 != 0L) { + output.WriteRawTag(128, 7); + output.WriteInt64(Int64Field112); } - } - - /// Field number for the "int64_field_60" field. - public const int Int64Field60FieldNumber = 60; - private long int64Field60_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public long Int64Field60 { - get { return int64Field60_; } - set { - int64Field60_ = value; + if (DoubleField113 != 0D) { + output.WriteRawTag(137, 7); + output.WriteDouble(DoubleField113); + } + if (Int64Field114 != 0L) { + output.WriteRawTag(144, 7); + output.WriteInt64(Int64Field114); + } + if (Int64Field115 != 0L) { + output.WriteRawTag(152, 7); + output.WriteInt64(Int64Field115); } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override bool Equals(object other) { - return Equals(other as ManyPrimitiveFieldsMessage); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public bool Equals(ManyPrimitiveFieldsMessage other) { - if (ReferenceEquals(other, null)) { - return false; + if (DoubleField116 != 0D) { + output.WriteRawTag(161, 7); + output.WriteDouble(DoubleField116); } - if (ReferenceEquals(other, this)) { - return true; + if (Int64Field117 != 0L) { + output.WriteRawTag(168, 7); + output.WriteInt64(Int64Field117); + } + if (DoubleField118 != 0D) { + output.WriteRawTag(177, 7); + output.WriteDouble(DoubleField118); + } + if (DoubleField119 != 0D) { + output.WriteRawTag(185, 7); + output.WriteDouble(DoubleField119); + } + if (DoubleField120 != 0D) { + output.WriteRawTag(193, 7); + output.WriteDouble(DoubleField120); + } + if (DoubleField121 != 0D) { + output.WriteRawTag(201, 7); + output.WriteDouble(DoubleField121); + } + if (DoubleField122 != 0D) { + output.WriteRawTag(209, 7); + output.WriteDouble(DoubleField122); + } + if (DoubleField123 != 0D) { + output.WriteRawTag(217, 7); + output.WriteDouble(DoubleField123); + } + if (DoubleField124 != 0D) { + output.WriteRawTag(225, 7); + output.WriteDouble(DoubleField124); + } + if (Int64Field125 != 0L) { + output.WriteRawTag(232, 7); + output.WriteInt64(Int64Field125); + } + if (Int64Field126 != 0L) { + output.WriteRawTag(240, 7); + output.WriteInt64(Int64Field126); + } + if (Int64Field127 != 0L) { + output.WriteRawTag(248, 7); + output.WriteInt64(Int64Field127); + } + if (DoubleField128 != 0D) { + output.WriteRawTag(129, 8); + output.WriteDouble(DoubleField128); + } + if (DoubleField129 != 0D) { + output.WriteRawTag(137, 8); + output.WriteDouble(DoubleField129); } - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField95, other.DoubleField95)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField1, other.DoubleField1)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField79, other.DoubleField79)) return false; - if (Int64Field2 != other.Int64Field2) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField96, other.DoubleField96)) return false; - if (Int64Field3 != other.Int64Field3) return false; - if (Int64Field4 != other.Int64Field4) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField97, other.DoubleField97)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField65, other.DoubleField65)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField66, other.DoubleField66)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField7, other.DoubleField7)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField62, other.DoubleField62)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField118, other.DoubleField118)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField119, other.DoubleField119)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField67, other.DoubleField67)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField120, other.DoubleField120)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField121, other.DoubleField121)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField122, other.DoubleField122)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField123, other.DoubleField123)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField124, other.DoubleField124)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField8, other.DoubleField8)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField9, other.DoubleField9)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField98, other.DoubleField98)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField10, other.DoubleField10)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField11, other.DoubleField11)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField99, other.DoubleField99)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField84, other.DoubleField84)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField14, other.DoubleField14)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField77, other.DoubleField77)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField15, other.DoubleField15)) return false; - if (Int64Field19 != other.Int64Field19) return false; - if (Int64Field115 != other.Int64Field115) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField116, other.DoubleField116)) return false; - if (Int64Field117 != other.Int64Field117) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField20, other.DoubleField20)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField21, other.DoubleField21)) return false; - if (StringField73 != other.StringField73) return false; - if (StringField74 != other.StringField74) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField22, other.DoubleField22)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField69, other.DoubleField69)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField70, other.DoubleField70)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField71, other.DoubleField71)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField72, other.DoubleField72)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField25, other.DoubleField25)) return false; - if (Int64Field26 != other.Int64Field26) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField68, other.DoubleField68)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField28, other.DoubleField28)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField106, other.DoubleField106)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField29, other.DoubleField29)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField30, other.DoubleField30)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField101, other.DoubleField101)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField102, other.DoubleField102)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField103, other.DoubleField103)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField104, other.DoubleField104)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField105, other.DoubleField105)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField31, other.DoubleField31)) return false; - if (Int64Field32 != other.Int64Field32) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField75, other.DoubleField75)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField129, other.DoubleField129)) return false; - if (EnumField80 != other.EnumField80) return false; - if (EnumField81 != other.EnumField81) return false; - if (Int64Field82 != other.Int64Field82) return false; - if (EnumField83 != other.EnumField83) return false; - if (Int64Field85 != other.Int64Field85) return false; - if (Int64Field86 != other.Int64Field86) return false; - if (Int64Field87 != other.Int64Field87) return false; - if (Int64Field125 != other.Int64Field125) return false; - if (Int64Field37 != other.Int64Field37) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField38, other.DoubleField38)) return false; - if (Interactions != other.Interactions) return false; - if(!repeatedIntField100_.Equals(other.repeatedIntField100_)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField40, other.DoubleField40)) return false; - if (Int64Field41 != other.Int64Field41) return false; - if (Int64Field126 != other.Int64Field126) return false; - if (Int64Field127 != other.Int64Field127) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField128, other.DoubleField128)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField109, other.DoubleField109)) return false; - if (Int64Field110 != other.Int64Field110) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField111, other.DoubleField111)) return false; - if (Int64Field112 != other.Int64Field112) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField113, other.DoubleField113)) return false; - if (Int64Field114 != other.Int64Field114) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField42, other.DoubleField42)) return false; - if (Int64Field43 != other.Int64Field43) return false; - if (Int64Field44 != other.Int64Field44) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField45, other.DoubleField45)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField46, other.DoubleField46)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField78, other.DoubleField78)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField88, other.DoubleField88)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField47, other.DoubleField47)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField89, other.DoubleField89)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField48, other.DoubleField48)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField49, other.DoubleField49)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField50, other.DoubleField50)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField90, other.DoubleField90)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField51, other.DoubleField51)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField91, other.DoubleField91)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField92, other.DoubleField92)) return false; - if (Int64Field107 != other.Int64Field107) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField93, other.DoubleField93)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField108, other.DoubleField108)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField52, other.DoubleField52)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField53, other.DoubleField53)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField94, other.DoubleField94)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField54, other.DoubleField54)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField55, other.DoubleField55)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField56, other.DoubleField56)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField57, other.DoubleField57)) return false; - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DoubleField58, other.DoubleField58)) return false; - if (Int64Field59 != other.Int64Field59) return false; - if (Int64Field60 != other.Int64Field60) return false; - return Equals(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override int GetHashCode() { - int hash = 1; - if (DoubleField95 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField95); - if (DoubleField1 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField1); - if (DoubleField79 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField79); - if (Int64Field2 != 0L) hash ^= Int64Field2.GetHashCode(); - if (DoubleField96 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField96); - if (Int64Field3 != 0L) hash ^= Int64Field3.GetHashCode(); - if (Int64Field4 != 0L) hash ^= Int64Field4.GetHashCode(); - if (DoubleField97 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField97); - if (DoubleField65 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField65); - if (DoubleField66 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField66); - if (DoubleField7 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField7); - if (DoubleField62 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField62); - if (DoubleField118 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField118); - if (DoubleField119 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField119); - if (DoubleField67 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField67); - if (DoubleField120 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField120); - if (DoubleField121 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField121); - if (DoubleField122 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField122); - if (DoubleField123 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField123); - if (DoubleField124 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField124); - if (DoubleField8 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField8); - if (DoubleField9 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField9); - if (DoubleField98 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField98); - if (DoubleField10 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField10); - if (DoubleField11 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField11); - if (DoubleField99 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField99); - if (DoubleField84 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField84); - if (DoubleField14 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField14); - if (DoubleField77 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField77); - if (DoubleField15 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField15); - if (Int64Field19 != 0L) hash ^= Int64Field19.GetHashCode(); - if (Int64Field115 != 0L) hash ^= Int64Field115.GetHashCode(); - if (DoubleField116 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField116); - if (Int64Field117 != 0L) hash ^= Int64Field117.GetHashCode(); - if (DoubleField20 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField20); - if (DoubleField21 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField21); - if (StringField73.Length != 0) hash ^= StringField73.GetHashCode(); - if (StringField74.Length != 0) hash ^= StringField74.GetHashCode(); - if (DoubleField22 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField22); - if (DoubleField69 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField69); - if (DoubleField70 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField70); - if (DoubleField71 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField71); - if (DoubleField72 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField72); - if (DoubleField25 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField25); - if (Int64Field26 != 0L) hash ^= Int64Field26.GetHashCode(); - if (DoubleField68 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField68); - if (DoubleField28 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField28); - if (DoubleField106 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField106); - if (DoubleField29 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField29); - if (DoubleField30 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField30); - if (DoubleField101 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField101); - if (DoubleField102 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField102); - if (DoubleField103 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField103); - if (DoubleField104 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField104); - if (DoubleField105 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField105); - if (DoubleField31 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField31); - if (Int64Field32 != 0L) hash ^= Int64Field32.GetHashCode(); - if (DoubleField75 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField75); - if (DoubleField129 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField129); - if (EnumField80 != 0) hash ^= EnumField80.GetHashCode(); - if (EnumField81 != 0) hash ^= EnumField81.GetHashCode(); - if (Int64Field82 != 0L) hash ^= Int64Field82.GetHashCode(); - if (EnumField83 != 0) hash ^= EnumField83.GetHashCode(); - if (Int64Field85 != 0L) hash ^= Int64Field85.GetHashCode(); - if (Int64Field86 != 0L) hash ^= Int64Field86.GetHashCode(); - if (Int64Field87 != 0L) hash ^= Int64Field87.GetHashCode(); - if (Int64Field125 != 0L) hash ^= Int64Field125.GetHashCode(); - if (Int64Field37 != 0L) hash ^= Int64Field37.GetHashCode(); - if (DoubleField38 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField38); - if (Interactions != 0L) hash ^= Interactions.GetHashCode(); - hash ^= repeatedIntField100_.GetHashCode(); - if (DoubleField40 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField40); - if (Int64Field41 != 0L) hash ^= Int64Field41.GetHashCode(); - if (Int64Field126 != 0L) hash ^= Int64Field126.GetHashCode(); - if (Int64Field127 != 0L) hash ^= Int64Field127.GetHashCode(); - if (DoubleField128 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField128); - if (DoubleField109 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField109); - if (Int64Field110 != 0L) hash ^= Int64Field110.GetHashCode(); - if (DoubleField111 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField111); - if (Int64Field112 != 0L) hash ^= Int64Field112.GetHashCode(); - if (DoubleField113 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField113); - if (Int64Field114 != 0L) hash ^= Int64Field114.GetHashCode(); - if (DoubleField42 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField42); - if (Int64Field43 != 0L) hash ^= Int64Field43.GetHashCode(); - if (Int64Field44 != 0L) hash ^= Int64Field44.GetHashCode(); - if (DoubleField45 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField45); - if (DoubleField46 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField46); - if (DoubleField78 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField78); - if (DoubleField88 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField88); - if (DoubleField47 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField47); - if (DoubleField89 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField89); - if (DoubleField48 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField48); - if (DoubleField49 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField49); - if (DoubleField50 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField50); - if (DoubleField90 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField90); - if (DoubleField51 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField51); - if (DoubleField91 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField91); - if (DoubleField92 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField92); - if (Int64Field107 != 0L) hash ^= Int64Field107.GetHashCode(); - if (DoubleField93 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField93); - if (DoubleField108 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField108); - if (DoubleField52 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField52); - if (DoubleField53 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField53); - if (DoubleField94 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField94); - if (DoubleField54 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField54); - if (DoubleField55 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField55); - if (DoubleField56 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField56); - if (DoubleField57 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField57); - if (DoubleField58 != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleField58); - if (Int64Field59 != 0L) hash ^= Int64Field59.GetHashCode(); - if (Int64Field60 != 0L) hash ^= Int64Field60.GetHashCode(); if (_unknownFields != null) { - hash ^= _unknownFields.GetHashCode(); + _unknownFields.WriteTo(output); } - return hash; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void WriteTo(pb::CodedOutputStream output) { + public void WriteTo(ref pb::CodedOutputWriter output) { if (DoubleField1 != 0D) { output.WriteRawTag(9); output.WriteDouble(DoubleField1); @@ -6027,7 +7610,7 @@ public sealed partial class ManyPrimitiveFieldsMessage : pb::IMessage - public sealed partial class FailureSet : pb::IMessage { + public sealed partial class FailureSet : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FailureSet()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -191,6 +195,17 @@ public sealed partial class FailureSet : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + failure_.WriteTo(ref output, _repeated_failure_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -226,6 +241,25 @@ public sealed partial class FailureSet : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + failure_.AddEntriesFrom(ref input, _repeated_failure_codec); + break; + } + } + } + } + #endif + } /// @@ -235,7 +269,11 @@ public sealed partial class FailureSet : pb::IMessage { /// 2. parse the protobuf or JSON payload in "payload" (which may fail) /// 3. if the parse succeeded, serialize the message in the requested format. /// - public sealed partial class ConformanceRequest : pb::IMessage { + public sealed partial class ConformanceRequest : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ConformanceRequest()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -524,6 +562,52 @@ public enum PayloadOneofCase { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (payloadCase_ == PayloadOneofCase.ProtobufPayload) { + output.WriteRawTag(10); + output.WriteBytes(ProtobufPayload); + } + if (payloadCase_ == PayloadOneofCase.JsonPayload) { + output.WriteRawTag(18); + output.WriteString(JsonPayload); + } + if (RequestedOutputFormat != global::Conformance.WireFormat.Unspecified) { + output.WriteRawTag(24); + output.WriteEnum((int) RequestedOutputFormat); + } + if (MessageType.Length != 0) { + output.WriteRawTag(34); + output.WriteString(MessageType); + } + if (TestCategory != global::Conformance.TestCategory.UnspecifiedTest) { + output.WriteRawTag(40); + output.WriteEnum((int) TestCategory); + } + if (jspbEncodingOptions_ != null) { + output.WriteRawTag(50); + output.WriteMessage(JspbEncodingOptions); + } + if (payloadCase_ == PayloadOneofCase.JspbPayload) { + output.WriteRawTag(58); + output.WriteString(JspbPayload); + } + if (payloadCase_ == PayloadOneofCase.TextPayload) { + output.WriteRawTag(66); + output.WriteString(TextPayload); + } + if (PrintUnknownFields != false) { + output.WriteRawTag(72); + output.WriteBool(PrintUnknownFields); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -652,12 +736,70 @@ public enum PayloadOneofCase { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + ProtobufPayload = input.ReadBytes(); + break; + } + case 18: { + JsonPayload = input.ReadString(); + break; + } + case 24: { + RequestedOutputFormat = (global::Conformance.WireFormat) input.ReadEnum(); + break; + } + case 34: { + MessageType = input.ReadString(); + break; + } + case 40: { + TestCategory = (global::Conformance.TestCategory) input.ReadEnum(); + break; + } + case 50: { + if (jspbEncodingOptions_ == null) { + JspbEncodingOptions = new global::Conformance.JspbEncodingConfig(); + } + input.ReadMessage(JspbEncodingOptions); + break; + } + case 58: { + JspbPayload = input.ReadString(); + break; + } + case 66: { + TextPayload = input.ReadString(); + break; + } + case 72: { + PrintUnknownFields = input.ReadBool(); + break; + } + } + } + } + #endif + } /// /// Represents a single test case's output. /// - public sealed partial class ConformanceResponse : pb::IMessage { + public sealed partial class ConformanceResponse : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ConformanceResponse()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -955,6 +1097,48 @@ public enum ResultOneofCase { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (resultCase_ == ResultOneofCase.ParseError) { + output.WriteRawTag(10); + output.WriteString(ParseError); + } + if (resultCase_ == ResultOneofCase.RuntimeError) { + output.WriteRawTag(18); + output.WriteString(RuntimeError); + } + if (resultCase_ == ResultOneofCase.ProtobufPayload) { + output.WriteRawTag(26); + output.WriteBytes(ProtobufPayload); + } + if (resultCase_ == ResultOneofCase.JsonPayload) { + output.WriteRawTag(34); + output.WriteString(JsonPayload); + } + if (resultCase_ == ResultOneofCase.Skipped) { + output.WriteRawTag(42); + output.WriteString(Skipped); + } + if (resultCase_ == ResultOneofCase.SerializeError) { + output.WriteRawTag(50); + output.WriteString(SerializeError); + } + if (resultCase_ == ResultOneofCase.JspbPayload) { + output.WriteRawTag(58); + output.WriteString(JspbPayload); + } + if (resultCase_ == ResultOneofCase.TextPayload) { + output.WriteRawTag(66); + output.WriteString(TextPayload); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -1067,12 +1251,63 @@ public enum ResultOneofCase { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + ParseError = input.ReadString(); + break; + } + case 18: { + RuntimeError = input.ReadString(); + break; + } + case 26: { + ProtobufPayload = input.ReadBytes(); + break; + } + case 34: { + JsonPayload = input.ReadString(); + break; + } + case 42: { + Skipped = input.ReadString(); + break; + } + case 50: { + SerializeError = input.ReadString(); + break; + } + case 58: { + JspbPayload = input.ReadString(); + break; + } + case 66: { + TextPayload = input.ReadString(); + break; + } + } + } + } + #endif + } /// /// Encoding options for jspb format. /// - public sealed partial class JspbEncodingConfig : pb::IMessage { + public sealed partial class JspbEncodingConfig : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new JspbEncodingConfig()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1163,6 +1398,20 @@ public sealed partial class JspbEncodingConfig : pb::IMessagenetcoreapp2.1 Exe False + $(DefineConstants);GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + + + + diff --git a/csharp/src/Google.Protobuf.Conformance/Program.cs b/csharp/src/Google.Protobuf.Conformance/Program.cs index d1093abee1f3..8ee58691274b 100644 --- a/csharp/src/Google.Protobuf.Conformance/Program.cs +++ b/csharp/src/Google.Protobuf.Conformance/Program.cs @@ -31,9 +31,12 @@ #endregion using Conformance; +using Google.Protobuf.Buffers; using Google.Protobuf.Reflection; using System; +using System.Buffers; using System.IO; +using System.Linq; namespace Google.Protobuf.Conformance { @@ -45,6 +48,8 @@ class Program { private static void Main(string[] args) { + var mode = ParseCmdline(args); + // This way we get the binary streams instead of readers/writers. var input = new BinaryReader(Console.OpenStandardInput()); var output = new BinaryWriter(Console.OpenStandardOutput()); @@ -53,14 +58,31 @@ private static void Main(string[] args) ProtobufTestMessages.Proto2.TestAllTypesProto2.Descriptor); int count = 0; - while (RunTest(input, output, typeRegistry)) + while (RunTest(input, output, typeRegistry, mode)) { count++; } Console.Error.WriteLine("Received EOF after {0} tests", count); } - private static bool RunTest(BinaryReader input, BinaryWriter output, TypeRegistry typeRegistry) + private static SerializationMode ParseCmdline(string[] args) + { + var mode = SerializationMode.Stream; + foreach (var arg in args.Skip(1)) + { + switch (arg) + { + case "--use_buffer_serialization": + mode = SerializationMode.Buffer; + break; + default: + throw new Exception($"Unknown command line argument: {arg}"); + } + } + return mode; + } + + private static bool RunTest(BinaryReader input, BinaryWriter output, TypeRegistry typeRegistry, SerializationMode mode) { int? size = ReadInt32(input); if (size == null) @@ -72,8 +94,9 @@ private static bool RunTest(BinaryReader input, BinaryWriter output, TypeRegistr { throw new EndOfStreamException("Read " + inputData.Length + " bytes of data when expecting " + size); } + // It doesn't matter what parser mode we use for ConformanceRequest, it isn't being tested ConformanceRequest request = ConformanceRequest.Parser.ParseFrom(inputData); - ConformanceResponse response = PerformRequest(request, typeRegistry); + ConformanceResponse response = PerformRequest(request, typeRegistry, mode); byte[] outputData = response.ToByteArray(); output.Write(outputData.Length); output.Write(outputData); @@ -81,7 +104,7 @@ private static bool RunTest(BinaryReader input, BinaryWriter output, TypeRegistr return true; } - private static ConformanceResponse PerformRequest(ConformanceRequest request, TypeRegistry typeRegistry) + private static ConformanceResponse PerformRequest(ConformanceRequest request, TypeRegistry typeRegistry, SerializationMode mode) { IMessage message; try @@ -89,17 +112,30 @@ private static ConformanceResponse PerformRequest(ConformanceRequest request, Ty switch (request.PayloadCase) { case ConformanceRequest.PayloadOneofCase.JsonPayload: - if (request.TestCategory == global::Conformance.TestCategory.JsonIgnoreUnknownParsingTest) { + { + // There is no buffer implementation of JSON. Use standard implementation + if (request.TestCategory == global::Conformance.TestCategory.JsonIgnoreUnknownParsingTest) + { return new ConformanceResponse { Skipped = "CSharp doesn't support skipping unknown fields in json parsing." }; } var parser = new JsonParser(new JsonParser.Settings(20, typeRegistry)); message = parser.Parse(request.JsonPayload); break; + } case ConformanceRequest.PayloadOneofCase.ProtobufPayload: { if (request.MessageType.Equals("protobuf_test_messages.proto3.TestAllTypesProto3")) { - message = ProtobufTestMessages.Proto3.TestAllTypesProto3.Parser.ParseFrom(request.ProtobufPayload); + var messageParser = ProtobufTestMessages.Proto3.TestAllTypesProto3.Parser; + + if (mode == SerializationMode.Stream) + { + message = messageParser.ParseFrom(request.ProtobufPayload); + } + else + { + message = messageParser.ParseFrom(new ReadOnlySequence(request.ProtobufPayload.ToByteArray())); + } } else if (request.MessageType.Equals("protobuf_test_messages.proto2.TestAllTypesProto2")) { @@ -109,18 +145,27 @@ private static ConformanceResponse PerformRequest(ConformanceRequest request, Ty ProtobufTestMessages.Proto2.TestAllTypesProto2.Types.MessageSetCorrectExtension1.Extensions.MessageSetExtension, ProtobufTestMessages.Proto2.TestAllTypesProto2.Types.MessageSetCorrectExtension2.Extensions.MessageSetExtension }; - message = ProtobufTestMessages.Proto2.TestAllTypesProto2.Parser.WithExtensionRegistry(registry).ParseFrom(request.ProtobufPayload); + var messageParser = ProtobufTestMessages.Proto2.TestAllTypesProto2.Parser.WithExtensionRegistry(registry); + + if (mode == SerializationMode.Stream) + { + message = messageParser.ParseFrom(request.ProtobufPayload); + } + else + { + message = messageParser.ParseFrom(new ReadOnlySequence(request.ProtobufPayload.ToByteArray())); + } } else { - throw new Exception(" Protobuf request doesn't have specific payload type"); + throw new Exception("Protobuf request doesn't have specific payload type"); } break; } - case ConformanceRequest.PayloadOneofCase.TextPayload: - { - return new ConformanceResponse { Skipped = "CSharp doesn't support text format" }; - } + case ConformanceRequest.PayloadOneofCase.TextPayload: + { + return new ConformanceResponse { Skipped = "CSharp doesn't support text format" }; + } default: throw new Exception("Unsupported request payload: " + request.PayloadCase); } @@ -141,7 +186,19 @@ private static ConformanceResponse PerformRequest(ConformanceRequest request, Ty var formatter = new JsonFormatter(new JsonFormatter.Settings(false, typeRegistry)); return new ConformanceResponse { JsonPayload = formatter.Format(message) }; case global::Conformance.WireFormat.Protobuf: - return new ConformanceResponse { ProtobufPayload = message.ToByteString() }; + if (mode == SerializationMode.Stream) + { + return new ConformanceResponse { ProtobufPayload = message.ToByteString() }; + } + else + { + var bufferMessage = (IBufferMessage)message; + var byteArrayWriter = new ArrayBufferWriter(); + var codedOutputWriter = new CodedOutputWriter(byteArrayWriter); + bufferMessage.WriteTo(ref codedOutputWriter); + codedOutputWriter.Flush(); + return new ConformanceResponse { ProtobufPayload = ByteString.CopyFrom(byteArrayWriter.WrittenSpan.ToArray()) }; + } default: throw new Exception("Unsupported request output format: " + request.RequestedOutputFormat); } @@ -166,5 +223,11 @@ private static ConformanceResponse PerformRequest(ConformanceRequest request, Ty } return bytes[0] | (bytes[1] << 8) | (bytes[2] << 16) | (bytes[3] << 24); } + + private enum SerializationMode + { + Stream, + Buffer + } } } diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/Google.Protobuf.Test.TestProtos.csproj b/csharp/src/Google.Protobuf.Test.TestProtos/Google.Protobuf.Test.TestProtos.csproj index 5b705804aa27..b3a2393fce2d 100644 --- a/csharp/src/Google.Protobuf.Test.TestProtos/Google.Protobuf.Test.TestProtos.csproj +++ b/csharp/src/Google.Protobuf.Test.TestProtos/Google.Protobuf.Test.TestProtos.csproj @@ -14,6 +14,10 @@ False + + $(DefineConstants);GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + + diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/MapUnittestProto3.cs b/csharp/src/Google.Protobuf.Test.TestProtos/MapUnittestProto3.cs index 197b197d0ea4..9349119c668a 100644 --- a/csharp/src/Google.Protobuf.Test.TestProtos/MapUnittestProto3.cs +++ b/csharp/src/Google.Protobuf.Test.TestProtos/MapUnittestProto3.cs @@ -176,7 +176,11 @@ public enum MapEnum { /// /// Tests maps. /// - public sealed partial class TestMap : pb::IMessage { + public sealed partial class TestMap : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestMap()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -484,6 +488,33 @@ public sealed partial class TestMap : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + mapInt32Int32_.WriteTo(ref output, _map_mapInt32Int32_codec); + mapInt64Int64_.WriteTo(ref output, _map_mapInt64Int64_codec); + mapUint32Uint32_.WriteTo(ref output, _map_mapUint32Uint32_codec); + mapUint64Uint64_.WriteTo(ref output, _map_mapUint64Uint64_codec); + mapSint32Sint32_.WriteTo(ref output, _map_mapSint32Sint32_codec); + mapSint64Sint64_.WriteTo(ref output, _map_mapSint64Sint64_codec); + mapFixed32Fixed32_.WriteTo(ref output, _map_mapFixed32Fixed32_codec); + mapFixed64Fixed64_.WriteTo(ref output, _map_mapFixed64Fixed64_codec); + mapSfixed32Sfixed32_.WriteTo(ref output, _map_mapSfixed32Sfixed32_codec); + mapSfixed64Sfixed64_.WriteTo(ref output, _map_mapSfixed64Sfixed64_codec); + mapInt32Float_.WriteTo(ref output, _map_mapInt32Float_codec); + mapInt32Double_.WriteTo(ref output, _map_mapInt32Double_codec); + mapBoolBool_.WriteTo(ref output, _map_mapBoolBool_codec); + mapStringString_.WriteTo(ref output, _map_mapStringString_codec); + mapInt32Bytes_.WriteTo(ref output, _map_mapInt32Bytes_codec); + mapInt32Enum_.WriteTo(ref output, _map_mapInt32Enum_codec); + mapInt32ForeignMessage_.WriteTo(ref output, _map_mapInt32ForeignMessage_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -615,9 +646,96 @@ public sealed partial class TestMap : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + mapInt32Int32_.AddEntriesFrom(ref input, _map_mapInt32Int32_codec); + break; + } + case 18: { + mapInt64Int64_.AddEntriesFrom(ref input, _map_mapInt64Int64_codec); + break; + } + case 26: { + mapUint32Uint32_.AddEntriesFrom(ref input, _map_mapUint32Uint32_codec); + break; + } + case 34: { + mapUint64Uint64_.AddEntriesFrom(ref input, _map_mapUint64Uint64_codec); + break; + } + case 42: { + mapSint32Sint32_.AddEntriesFrom(ref input, _map_mapSint32Sint32_codec); + break; + } + case 50: { + mapSint64Sint64_.AddEntriesFrom(ref input, _map_mapSint64Sint64_codec); + break; + } + case 58: { + mapFixed32Fixed32_.AddEntriesFrom(ref input, _map_mapFixed32Fixed32_codec); + break; + } + case 66: { + mapFixed64Fixed64_.AddEntriesFrom(ref input, _map_mapFixed64Fixed64_codec); + break; + } + case 74: { + mapSfixed32Sfixed32_.AddEntriesFrom(ref input, _map_mapSfixed32Sfixed32_codec); + break; + } + case 82: { + mapSfixed64Sfixed64_.AddEntriesFrom(ref input, _map_mapSfixed64Sfixed64_codec); + break; + } + case 90: { + mapInt32Float_.AddEntriesFrom(ref input, _map_mapInt32Float_codec); + break; + } + case 98: { + mapInt32Double_.AddEntriesFrom(ref input, _map_mapInt32Double_codec); + break; + } + case 106: { + mapBoolBool_.AddEntriesFrom(ref input, _map_mapBoolBool_codec); + break; + } + case 114: { + mapStringString_.AddEntriesFrom(ref input, _map_mapStringString_codec); + break; + } + case 122: { + mapInt32Bytes_.AddEntriesFrom(ref input, _map_mapInt32Bytes_codec); + break; + } + case 130: { + mapInt32Enum_.AddEntriesFrom(ref input, _map_mapInt32Enum_codec); + break; + } + case 138: { + mapInt32ForeignMessage_.AddEntriesFrom(ref input, _map_mapInt32ForeignMessage_codec); + break; + } + } + } + } + #endif + } - public sealed partial class TestMapSubmessage : pb::IMessage { + public sealed partial class TestMapSubmessage : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestMapSubmessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -705,6 +823,20 @@ public sealed partial class TestMapSubmessage : pb::IMessage } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (testMap_ != null) { + output.WriteRawTag(10); + output.WriteMessage(TestMap); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -750,9 +882,35 @@ public sealed partial class TestMapSubmessage : pb::IMessage } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + if (testMap_ == null) { + TestMap = new global::Google.Protobuf.TestProtos.TestMap(); + } + input.ReadMessage(TestMap); + break; + } + } + } + } + #endif + } - public sealed partial class TestMessageMap : pb::IMessage { + public sealed partial class TestMessageMap : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestMessageMap()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -836,6 +994,17 @@ public sealed partial class TestMessageMap : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + mapInt32Message_.WriteTo(ref output, _map_mapInt32Message_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -871,12 +1040,35 @@ public sealed partial class TestMessageMap : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + mapInt32Message_.AddEntriesFrom(ref input, _map_mapInt32Message_codec); + break; + } + } + } + } + #endif + } /// /// Two map fields share the same entry default instance. /// - public sealed partial class TestSameTypeMap : pb::IMessage { + public sealed partial class TestSameTypeMap : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestSameTypeMap()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -974,6 +1166,18 @@ public sealed partial class TestSameTypeMap : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + map1_.WriteTo(ref output, _map_map1_codec); + map2_.WriteTo(ref output, _map_map2_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -1015,9 +1219,36 @@ public sealed partial class TestSameTypeMap : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + map1_.AddEntriesFrom(ref input, _map_map1_codec); + break; + } + case 18: { + map2_.AddEntriesFrom(ref input, _map_map2_codec); + break; + } + } + } + } + #endif + } - public sealed partial class TestArenaMap : pb::IMessage { + public sealed partial class TestArenaMap : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestArenaMap()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1297,6 +1528,31 @@ public sealed partial class TestArenaMap : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + mapInt32Int32_.WriteTo(ref output, _map_mapInt32Int32_codec); + mapInt64Int64_.WriteTo(ref output, _map_mapInt64Int64_codec); + mapUint32Uint32_.WriteTo(ref output, _map_mapUint32Uint32_codec); + mapUint64Uint64_.WriteTo(ref output, _map_mapUint64Uint64_codec); + mapSint32Sint32_.WriteTo(ref output, _map_mapSint32Sint32_codec); + mapSint64Sint64_.WriteTo(ref output, _map_mapSint64Sint64_codec); + mapFixed32Fixed32_.WriteTo(ref output, _map_mapFixed32Fixed32_codec); + mapFixed64Fixed64_.WriteTo(ref output, _map_mapFixed64Fixed64_codec); + mapSfixed32Sfixed32_.WriteTo(ref output, _map_mapSfixed32Sfixed32_codec); + mapSfixed64Sfixed64_.WriteTo(ref output, _map_mapSfixed64Sfixed64_codec); + mapInt32Float_.WriteTo(ref output, _map_mapInt32Float_codec); + mapInt32Double_.WriteTo(ref output, _map_mapInt32Double_codec); + mapBoolBool_.WriteTo(ref output, _map_mapBoolBool_codec); + mapInt32Enum_.WriteTo(ref output, _map_mapInt32Enum_codec); + mapInt32ForeignMessage_.WriteTo(ref output, _map_mapInt32ForeignMessage_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -1416,13 +1672,92 @@ public sealed partial class TestArenaMap : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + mapInt32Int32_.AddEntriesFrom(ref input, _map_mapInt32Int32_codec); + break; + } + case 18: { + mapInt64Int64_.AddEntriesFrom(ref input, _map_mapInt64Int64_codec); + break; + } + case 26: { + mapUint32Uint32_.AddEntriesFrom(ref input, _map_mapUint32Uint32_codec); + break; + } + case 34: { + mapUint64Uint64_.AddEntriesFrom(ref input, _map_mapUint64Uint64_codec); + break; + } + case 42: { + mapSint32Sint32_.AddEntriesFrom(ref input, _map_mapSint32Sint32_codec); + break; + } + case 50: { + mapSint64Sint64_.AddEntriesFrom(ref input, _map_mapSint64Sint64_codec); + break; + } + case 58: { + mapFixed32Fixed32_.AddEntriesFrom(ref input, _map_mapFixed32Fixed32_codec); + break; + } + case 66: { + mapFixed64Fixed64_.AddEntriesFrom(ref input, _map_mapFixed64Fixed64_codec); + break; + } + case 74: { + mapSfixed32Sfixed32_.AddEntriesFrom(ref input, _map_mapSfixed32Sfixed32_codec); + break; + } + case 82: { + mapSfixed64Sfixed64_.AddEntriesFrom(ref input, _map_mapSfixed64Sfixed64_codec); + break; + } + case 90: { + mapInt32Float_.AddEntriesFrom(ref input, _map_mapInt32Float_codec); + break; + } + case 98: { + mapInt32Double_.AddEntriesFrom(ref input, _map_mapInt32Double_codec); + break; + } + case 106: { + mapBoolBool_.AddEntriesFrom(ref input, _map_mapBoolBool_codec); + break; + } + case 114: { + mapInt32Enum_.AddEntriesFrom(ref input, _map_mapInt32Enum_codec); + break; + } + case 122: { + mapInt32ForeignMessage_.AddEntriesFrom(ref input, _map_mapInt32ForeignMessage_codec); + break; + } + } + } + } + #endif + } /// /// Previously, message containing enum called Type cannot be used as value of /// map field. /// - public sealed partial class MessageContainingEnumCalledType : pb::IMessage { + public sealed partial class MessageContainingEnumCalledType : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MessageContainingEnumCalledType()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1506,6 +1841,17 @@ public sealed partial class MessageContainingEnumCalledType : pb::IMessageContainer for nested types declared in the MessageContainingEnumCalledType message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1557,7 +1922,11 @@ public enum Type { /// /// Previously, message cannot contain map field called "entry". /// - public sealed partial class MessageContainingMapCalledEntry : pb::IMessage { + public sealed partial class MessageContainingMapCalledEntry : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MessageContainingMapCalledEntry()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1641,6 +2010,17 @@ public sealed partial class MessageContainingMapCalledEntry : pb::IMessage - public sealed partial class TestAllTypesProto2 : pb::IExtendableMessage { + public sealed partial class TestAllTypesProto2 : pb::IExtendableMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestAllTypesProto2()); private pb::UnknownFieldSet _unknownFields; private pb::ExtensionSet _extensions; @@ -2876,6 +2880,288 @@ public enum OneofFieldOneofCase { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasOptionalInt32) { + output.WriteRawTag(8); + output.WriteInt32(OptionalInt32); + } + if (HasOptionalInt64) { + output.WriteRawTag(16); + output.WriteInt64(OptionalInt64); + } + if (HasOptionalUint32) { + output.WriteRawTag(24); + output.WriteUInt32(OptionalUint32); + } + if (HasOptionalUint64) { + output.WriteRawTag(32); + output.WriteUInt64(OptionalUint64); + } + if (HasOptionalSint32) { + output.WriteRawTag(40); + output.WriteSInt32(OptionalSint32); + } + if (HasOptionalSint64) { + output.WriteRawTag(48); + output.WriteSInt64(OptionalSint64); + } + if (HasOptionalFixed32) { + output.WriteRawTag(61); + output.WriteFixed32(OptionalFixed32); + } + if (HasOptionalFixed64) { + output.WriteRawTag(65); + output.WriteFixed64(OptionalFixed64); + } + if (HasOptionalSfixed32) { + output.WriteRawTag(77); + output.WriteSFixed32(OptionalSfixed32); + } + if (HasOptionalSfixed64) { + output.WriteRawTag(81); + output.WriteSFixed64(OptionalSfixed64); + } + if (HasOptionalFloat) { + output.WriteRawTag(93); + output.WriteFloat(OptionalFloat); + } + if (HasOptionalDouble) { + output.WriteRawTag(97); + output.WriteDouble(OptionalDouble); + } + if (HasOptionalBool) { + output.WriteRawTag(104); + output.WriteBool(OptionalBool); + } + if (HasOptionalString) { + output.WriteRawTag(114); + output.WriteString(OptionalString); + } + if (HasOptionalBytes) { + output.WriteRawTag(122); + output.WriteBytes(OptionalBytes); + } + if (HasOptionalNestedMessage) { + output.WriteRawTag(146, 1); + output.WriteMessage(OptionalNestedMessage); + } + if (HasOptionalForeignMessage) { + output.WriteRawTag(154, 1); + output.WriteMessage(OptionalForeignMessage); + } + if (HasOptionalNestedEnum) { + output.WriteRawTag(168, 1); + output.WriteEnum((int) OptionalNestedEnum); + } + if (HasOptionalForeignEnum) { + output.WriteRawTag(176, 1); + output.WriteEnum((int) OptionalForeignEnum); + } + if (HasOptionalStringPiece) { + output.WriteRawTag(194, 1); + output.WriteString(OptionalStringPiece); + } + if (HasOptionalCord) { + output.WriteRawTag(202, 1); + output.WriteString(OptionalCord); + } + if (HasRecursiveMessage) { + output.WriteRawTag(218, 1); + output.WriteMessage(RecursiveMessage); + } + repeatedInt32_.WriteTo(ref output, _repeated_repeatedInt32_codec); + repeatedInt64_.WriteTo(ref output, _repeated_repeatedInt64_codec); + repeatedUint32_.WriteTo(ref output, _repeated_repeatedUint32_codec); + repeatedUint64_.WriteTo(ref output, _repeated_repeatedUint64_codec); + repeatedSint32_.WriteTo(ref output, _repeated_repeatedSint32_codec); + repeatedSint64_.WriteTo(ref output, _repeated_repeatedSint64_codec); + repeatedFixed32_.WriteTo(ref output, _repeated_repeatedFixed32_codec); + repeatedFixed64_.WriteTo(ref output, _repeated_repeatedFixed64_codec); + repeatedSfixed32_.WriteTo(ref output, _repeated_repeatedSfixed32_codec); + repeatedSfixed64_.WriteTo(ref output, _repeated_repeatedSfixed64_codec); + repeatedFloat_.WriteTo(ref output, _repeated_repeatedFloat_codec); + repeatedDouble_.WriteTo(ref output, _repeated_repeatedDouble_codec); + repeatedBool_.WriteTo(ref output, _repeated_repeatedBool_codec); + repeatedString_.WriteTo(ref output, _repeated_repeatedString_codec); + repeatedBytes_.WriteTo(ref output, _repeated_repeatedBytes_codec); + repeatedNestedMessage_.WriteTo(ref output, _repeated_repeatedNestedMessage_codec); + repeatedForeignMessage_.WriteTo(ref output, _repeated_repeatedForeignMessage_codec); + repeatedNestedEnum_.WriteTo(ref output, _repeated_repeatedNestedEnum_codec); + repeatedForeignEnum_.WriteTo(ref output, _repeated_repeatedForeignEnum_codec); + repeatedStringPiece_.WriteTo(ref output, _repeated_repeatedStringPiece_codec); + repeatedCord_.WriteTo(ref output, _repeated_repeatedCord_codec); + mapInt32Int32_.WriteTo(ref output, _map_mapInt32Int32_codec); + mapInt64Int64_.WriteTo(ref output, _map_mapInt64Int64_codec); + mapUint32Uint32_.WriteTo(ref output, _map_mapUint32Uint32_codec); + mapUint64Uint64_.WriteTo(ref output, _map_mapUint64Uint64_codec); + mapSint32Sint32_.WriteTo(ref output, _map_mapSint32Sint32_codec); + mapSint64Sint64_.WriteTo(ref output, _map_mapSint64Sint64_codec); + mapFixed32Fixed32_.WriteTo(ref output, _map_mapFixed32Fixed32_codec); + mapFixed64Fixed64_.WriteTo(ref output, _map_mapFixed64Fixed64_codec); + mapSfixed32Sfixed32_.WriteTo(ref output, _map_mapSfixed32Sfixed32_codec); + mapSfixed64Sfixed64_.WriteTo(ref output, _map_mapSfixed64Sfixed64_codec); + mapInt32Float_.WriteTo(ref output, _map_mapInt32Float_codec); + mapInt32Double_.WriteTo(ref output, _map_mapInt32Double_codec); + mapBoolBool_.WriteTo(ref output, _map_mapBoolBool_codec); + mapStringString_.WriteTo(ref output, _map_mapStringString_codec); + mapStringBytes_.WriteTo(ref output, _map_mapStringBytes_codec); + mapStringNestedMessage_.WriteTo(ref output, _map_mapStringNestedMessage_codec); + mapStringForeignMessage_.WriteTo(ref output, _map_mapStringForeignMessage_codec); + mapStringNestedEnum_.WriteTo(ref output, _map_mapStringNestedEnum_codec); + mapStringForeignEnum_.WriteTo(ref output, _map_mapStringForeignEnum_codec); + packedInt32_.WriteTo(ref output, _repeated_packedInt32_codec); + packedInt64_.WriteTo(ref output, _repeated_packedInt64_codec); + packedUint32_.WriteTo(ref output, _repeated_packedUint32_codec); + packedUint64_.WriteTo(ref output, _repeated_packedUint64_codec); + packedSint32_.WriteTo(ref output, _repeated_packedSint32_codec); + packedSint64_.WriteTo(ref output, _repeated_packedSint64_codec); + packedFixed32_.WriteTo(ref output, _repeated_packedFixed32_codec); + packedFixed64_.WriteTo(ref output, _repeated_packedFixed64_codec); + packedSfixed32_.WriteTo(ref output, _repeated_packedSfixed32_codec); + packedSfixed64_.WriteTo(ref output, _repeated_packedSfixed64_codec); + packedFloat_.WriteTo(ref output, _repeated_packedFloat_codec); + packedDouble_.WriteTo(ref output, _repeated_packedDouble_codec); + packedBool_.WriteTo(ref output, _repeated_packedBool_codec); + packedNestedEnum_.WriteTo(ref output, _repeated_packedNestedEnum_codec); + unpackedInt32_.WriteTo(ref output, _repeated_unpackedInt32_codec); + unpackedInt64_.WriteTo(ref output, _repeated_unpackedInt64_codec); + unpackedUint32_.WriteTo(ref output, _repeated_unpackedUint32_codec); + unpackedUint64_.WriteTo(ref output, _repeated_unpackedUint64_codec); + unpackedSint32_.WriteTo(ref output, _repeated_unpackedSint32_codec); + unpackedSint64_.WriteTo(ref output, _repeated_unpackedSint64_codec); + unpackedFixed32_.WriteTo(ref output, _repeated_unpackedFixed32_codec); + unpackedFixed64_.WriteTo(ref output, _repeated_unpackedFixed64_codec); + unpackedSfixed32_.WriteTo(ref output, _repeated_unpackedSfixed32_codec); + unpackedSfixed64_.WriteTo(ref output, _repeated_unpackedSfixed64_codec); + unpackedFloat_.WriteTo(ref output, _repeated_unpackedFloat_codec); + unpackedDouble_.WriteTo(ref output, _repeated_unpackedDouble_codec); + unpackedBool_.WriteTo(ref output, _repeated_unpackedBool_codec); + unpackedNestedEnum_.WriteTo(ref output, _repeated_unpackedNestedEnum_codec); + if (HasOneofUint32) { + output.WriteRawTag(248, 6); + output.WriteUInt32(OneofUint32); + } + if (HasOneofNestedMessage) { + output.WriteRawTag(130, 7); + output.WriteMessage(OneofNestedMessage); + } + if (HasOneofString) { + output.WriteRawTag(138, 7); + output.WriteString(OneofString); + } + if (HasOneofBytes) { + output.WriteRawTag(146, 7); + output.WriteBytes(OneofBytes); + } + if (HasOneofBool) { + output.WriteRawTag(152, 7); + output.WriteBool(OneofBool); + } + if (HasOneofUint64) { + output.WriteRawTag(160, 7); + output.WriteUInt64(OneofUint64); + } + if (HasOneofFloat) { + output.WriteRawTag(173, 7); + output.WriteFloat(OneofFloat); + } + if (HasOneofDouble) { + output.WriteRawTag(177, 7); + output.WriteDouble(OneofDouble); + } + if (HasOneofEnum) { + output.WriteRawTag(184, 7); + output.WriteEnum((int) OneofEnum); + } + if (HasData) { + output.WriteRawTag(203, 12); + output.WriteGroup(Data); + output.WriteRawTag(204, 12); + } + if (HasFieldname1) { + output.WriteRawTag(136, 25); + output.WriteInt32(Fieldname1); + } + if (HasFieldName2) { + output.WriteRawTag(144, 25); + output.WriteInt32(FieldName2); + } + if (HasFieldName3) { + output.WriteRawTag(152, 25); + output.WriteInt32(FieldName3); + } + if (HasFieldName4) { + output.WriteRawTag(160, 25); + output.WriteInt32(FieldName4); + } + if (HasField0Name5) { + output.WriteRawTag(168, 25); + output.WriteInt32(Field0Name5); + } + if (HasField0Name6) { + output.WriteRawTag(176, 25); + output.WriteInt32(Field0Name6); + } + if (HasFieldName7) { + output.WriteRawTag(184, 25); + output.WriteInt32(FieldName7); + } + if (HasFieldName8) { + output.WriteRawTag(192, 25); + output.WriteInt32(FieldName8); + } + if (HasFieldName9) { + output.WriteRawTag(200, 25); + output.WriteInt32(FieldName9); + } + if (HasFieldName10) { + output.WriteRawTag(208, 25); + output.WriteInt32(FieldName10); + } + if (HasFIELDNAME11) { + output.WriteRawTag(216, 25); + output.WriteInt32(FIELDNAME11); + } + if (HasFIELDName12) { + output.WriteRawTag(224, 25); + output.WriteInt32(FIELDName12); + } + if (HasFieldName13) { + output.WriteRawTag(232, 25); + output.WriteInt32(FieldName13); + } + if (HasFieldName14) { + output.WriteRawTag(240, 25); + output.WriteInt32(FieldName14); + } + if (HasFieldName15) { + output.WriteRawTag(248, 25); + output.WriteInt32(FieldName15); + } + if (HasFieldName16) { + output.WriteRawTag(128, 26); + output.WriteInt32(FieldName16); + } + if (HasFieldName17) { + output.WriteRawTag(136, 26); + output.WriteInt32(FieldName17); + } + if (HasFieldName18) { + output.WriteRawTag(144, 26); + output.WriteInt32(FieldName18); + } + if (_extensions != null) { + _extensions.WriteTo(ref output); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -3898,56 +4184,610 @@ public enum OneofFieldOneofCase { } } - public TValue GetExtension(pb::Extension extension) { - return pb::ExtensionSet.Get(ref _extensions, extension); - } - public pbc::RepeatedField GetExtension(pb::RepeatedExtension extension) { - return pb::ExtensionSet.Get(ref _extensions, extension); - } - public pbc::RepeatedField GetOrInitializeExtension(pb::RepeatedExtension extension) { - return pb::ExtensionSet.GetOrInitialize(ref _extensions, extension); - } - public void SetExtension(pb::Extension extension, TValue value) { - pb::ExtensionSet.Set(ref _extensions, extension, value); - } - public bool HasExtension(pb::Extension extension) { - return pb::ExtensionSet.Has(ref _extensions, extension); - } - public void ClearExtension(pb::Extension extension) { - pb::ExtensionSet.Clear(ref _extensions, extension); - } - public void ClearExtension(pb::RepeatedExtension extension) { - pb::ExtensionSet.Clear(ref _extensions, extension); - } - #region Nested types - /// Container for nested types declared in the TestAllTypesProto2 message type. + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static partial class Types { - public enum NestedEnum { - [pbr::OriginalName("FOO")] Foo = 0, - [pbr::OriginalName("BAR")] Bar = 1, - [pbr::OriginalName("BAZ")] Baz = 2, - /// - /// Intentionally negative. - /// - [pbr::OriginalName("NEG")] Neg = -1, - } - - public sealed partial class NestedMessage : pb::IMessage { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedMessage()); - private pb::UnknownFieldSet _unknownFields; - private int _hasBits0; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pbr::MessageDescriptor Descriptor { - get { return global::ProtobufTestMessages.Proto2.TestAllTypesProto2.Descriptor.NestedTypes[0]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - pbr::MessageDescriptor pb::IMessage.Descriptor { + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, ref input)) { + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + } + break; + case 8: { + OptionalInt32 = input.ReadInt32(); + break; + } + case 16: { + OptionalInt64 = input.ReadInt64(); + break; + } + case 24: { + OptionalUint32 = input.ReadUInt32(); + break; + } + case 32: { + OptionalUint64 = input.ReadUInt64(); + break; + } + case 40: { + OptionalSint32 = input.ReadSInt32(); + break; + } + case 48: { + OptionalSint64 = input.ReadSInt64(); + break; + } + case 61: { + OptionalFixed32 = input.ReadFixed32(); + break; + } + case 65: { + OptionalFixed64 = input.ReadFixed64(); + break; + } + case 77: { + OptionalSfixed32 = input.ReadSFixed32(); + break; + } + case 81: { + OptionalSfixed64 = input.ReadSFixed64(); + break; + } + case 93: { + OptionalFloat = input.ReadFloat(); + break; + } + case 97: { + OptionalDouble = input.ReadDouble(); + break; + } + case 104: { + OptionalBool = input.ReadBool(); + break; + } + case 114: { + OptionalString = input.ReadString(); + break; + } + case 122: { + OptionalBytes = input.ReadBytes(); + break; + } + case 146: { + if (!HasOptionalNestedMessage) { + OptionalNestedMessage = new global::ProtobufTestMessages.Proto2.TestAllTypesProto2.Types.NestedMessage(); + } + input.ReadMessage(OptionalNestedMessage); + break; + } + case 154: { + if (!HasOptionalForeignMessage) { + OptionalForeignMessage = new global::ProtobufTestMessages.Proto2.ForeignMessageProto2(); + } + input.ReadMessage(OptionalForeignMessage); + break; + } + case 168: { + OptionalNestedEnum = (global::ProtobufTestMessages.Proto2.TestAllTypesProto2.Types.NestedEnum) input.ReadEnum(); + break; + } + case 176: { + OptionalForeignEnum = (global::ProtobufTestMessages.Proto2.ForeignEnumProto2) input.ReadEnum(); + break; + } + case 194: { + OptionalStringPiece = input.ReadString(); + break; + } + case 202: { + OptionalCord = input.ReadString(); + break; + } + case 218: { + if (!HasRecursiveMessage) { + RecursiveMessage = new global::ProtobufTestMessages.Proto2.TestAllTypesProto2(); + } + input.ReadMessage(RecursiveMessage); + break; + } + case 250: + case 248: { + repeatedInt32_.AddEntriesFrom(ref input, _repeated_repeatedInt32_codec); + break; + } + case 258: + case 256: { + repeatedInt64_.AddEntriesFrom(ref input, _repeated_repeatedInt64_codec); + break; + } + case 266: + case 264: { + repeatedUint32_.AddEntriesFrom(ref input, _repeated_repeatedUint32_codec); + break; + } + case 274: + case 272: { + repeatedUint64_.AddEntriesFrom(ref input, _repeated_repeatedUint64_codec); + break; + } + case 282: + case 280: { + repeatedSint32_.AddEntriesFrom(ref input, _repeated_repeatedSint32_codec); + break; + } + case 290: + case 288: { + repeatedSint64_.AddEntriesFrom(ref input, _repeated_repeatedSint64_codec); + break; + } + case 298: + case 301: { + repeatedFixed32_.AddEntriesFrom(ref input, _repeated_repeatedFixed32_codec); + break; + } + case 306: + case 305: { + repeatedFixed64_.AddEntriesFrom(ref input, _repeated_repeatedFixed64_codec); + break; + } + case 314: + case 317: { + repeatedSfixed32_.AddEntriesFrom(ref input, _repeated_repeatedSfixed32_codec); + break; + } + case 322: + case 321: { + repeatedSfixed64_.AddEntriesFrom(ref input, _repeated_repeatedSfixed64_codec); + break; + } + case 330: + case 333: { + repeatedFloat_.AddEntriesFrom(ref input, _repeated_repeatedFloat_codec); + break; + } + case 338: + case 337: { + repeatedDouble_.AddEntriesFrom(ref input, _repeated_repeatedDouble_codec); + break; + } + case 346: + case 344: { + repeatedBool_.AddEntriesFrom(ref input, _repeated_repeatedBool_codec); + break; + } + case 354: { + repeatedString_.AddEntriesFrom(ref input, _repeated_repeatedString_codec); + break; + } + case 362: { + repeatedBytes_.AddEntriesFrom(ref input, _repeated_repeatedBytes_codec); + break; + } + case 386: { + repeatedNestedMessage_.AddEntriesFrom(ref input, _repeated_repeatedNestedMessage_codec); + break; + } + case 394: { + repeatedForeignMessage_.AddEntriesFrom(ref input, _repeated_repeatedForeignMessage_codec); + break; + } + case 410: + case 408: { + repeatedNestedEnum_.AddEntriesFrom(ref input, _repeated_repeatedNestedEnum_codec); + break; + } + case 418: + case 416: { + repeatedForeignEnum_.AddEntriesFrom(ref input, _repeated_repeatedForeignEnum_codec); + break; + } + case 434: { + repeatedStringPiece_.AddEntriesFrom(ref input, _repeated_repeatedStringPiece_codec); + break; + } + case 442: { + repeatedCord_.AddEntriesFrom(ref input, _repeated_repeatedCord_codec); + break; + } + case 450: { + mapInt32Int32_.AddEntriesFrom(ref input, _map_mapInt32Int32_codec); + break; + } + case 458: { + mapInt64Int64_.AddEntriesFrom(ref input, _map_mapInt64Int64_codec); + break; + } + case 466: { + mapUint32Uint32_.AddEntriesFrom(ref input, _map_mapUint32Uint32_codec); + break; + } + case 474: { + mapUint64Uint64_.AddEntriesFrom(ref input, _map_mapUint64Uint64_codec); + break; + } + case 482: { + mapSint32Sint32_.AddEntriesFrom(ref input, _map_mapSint32Sint32_codec); + break; + } + case 490: { + mapSint64Sint64_.AddEntriesFrom(ref input, _map_mapSint64Sint64_codec); + break; + } + case 498: { + mapFixed32Fixed32_.AddEntriesFrom(ref input, _map_mapFixed32Fixed32_codec); + break; + } + case 506: { + mapFixed64Fixed64_.AddEntriesFrom(ref input, _map_mapFixed64Fixed64_codec); + break; + } + case 514: { + mapSfixed32Sfixed32_.AddEntriesFrom(ref input, _map_mapSfixed32Sfixed32_codec); + break; + } + case 522: { + mapSfixed64Sfixed64_.AddEntriesFrom(ref input, _map_mapSfixed64Sfixed64_codec); + break; + } + case 530: { + mapInt32Float_.AddEntriesFrom(ref input, _map_mapInt32Float_codec); + break; + } + case 538: { + mapInt32Double_.AddEntriesFrom(ref input, _map_mapInt32Double_codec); + break; + } + case 546: { + mapBoolBool_.AddEntriesFrom(ref input, _map_mapBoolBool_codec); + break; + } + case 554: { + mapStringString_.AddEntriesFrom(ref input, _map_mapStringString_codec); + break; + } + case 562: { + mapStringBytes_.AddEntriesFrom(ref input, _map_mapStringBytes_codec); + break; + } + case 570: { + mapStringNestedMessage_.AddEntriesFrom(ref input, _map_mapStringNestedMessage_codec); + break; + } + case 578: { + mapStringForeignMessage_.AddEntriesFrom(ref input, _map_mapStringForeignMessage_codec); + break; + } + case 586: { + mapStringNestedEnum_.AddEntriesFrom(ref input, _map_mapStringNestedEnum_codec); + break; + } + case 594: { + mapStringForeignEnum_.AddEntriesFrom(ref input, _map_mapStringForeignEnum_codec); + break; + } + case 602: + case 600: { + packedInt32_.AddEntriesFrom(ref input, _repeated_packedInt32_codec); + break; + } + case 610: + case 608: { + packedInt64_.AddEntriesFrom(ref input, _repeated_packedInt64_codec); + break; + } + case 618: + case 616: { + packedUint32_.AddEntriesFrom(ref input, _repeated_packedUint32_codec); + break; + } + case 626: + case 624: { + packedUint64_.AddEntriesFrom(ref input, _repeated_packedUint64_codec); + break; + } + case 634: + case 632: { + packedSint32_.AddEntriesFrom(ref input, _repeated_packedSint32_codec); + break; + } + case 642: + case 640: { + packedSint64_.AddEntriesFrom(ref input, _repeated_packedSint64_codec); + break; + } + case 650: + case 653: { + packedFixed32_.AddEntriesFrom(ref input, _repeated_packedFixed32_codec); + break; + } + case 658: + case 657: { + packedFixed64_.AddEntriesFrom(ref input, _repeated_packedFixed64_codec); + break; + } + case 666: + case 669: { + packedSfixed32_.AddEntriesFrom(ref input, _repeated_packedSfixed32_codec); + break; + } + case 674: + case 673: { + packedSfixed64_.AddEntriesFrom(ref input, _repeated_packedSfixed64_codec); + break; + } + case 682: + case 685: { + packedFloat_.AddEntriesFrom(ref input, _repeated_packedFloat_codec); + break; + } + case 690: + case 689: { + packedDouble_.AddEntriesFrom(ref input, _repeated_packedDouble_codec); + break; + } + case 698: + case 696: { + packedBool_.AddEntriesFrom(ref input, _repeated_packedBool_codec); + break; + } + case 706: + case 704: { + packedNestedEnum_.AddEntriesFrom(ref input, _repeated_packedNestedEnum_codec); + break; + } + case 714: + case 712: { + unpackedInt32_.AddEntriesFrom(ref input, _repeated_unpackedInt32_codec); + break; + } + case 722: + case 720: { + unpackedInt64_.AddEntriesFrom(ref input, _repeated_unpackedInt64_codec); + break; + } + case 730: + case 728: { + unpackedUint32_.AddEntriesFrom(ref input, _repeated_unpackedUint32_codec); + break; + } + case 738: + case 736: { + unpackedUint64_.AddEntriesFrom(ref input, _repeated_unpackedUint64_codec); + break; + } + case 746: + case 744: { + unpackedSint32_.AddEntriesFrom(ref input, _repeated_unpackedSint32_codec); + break; + } + case 754: + case 752: { + unpackedSint64_.AddEntriesFrom(ref input, _repeated_unpackedSint64_codec); + break; + } + case 762: + case 765: { + unpackedFixed32_.AddEntriesFrom(ref input, _repeated_unpackedFixed32_codec); + break; + } + case 770: + case 769: { + unpackedFixed64_.AddEntriesFrom(ref input, _repeated_unpackedFixed64_codec); + break; + } + case 778: + case 781: { + unpackedSfixed32_.AddEntriesFrom(ref input, _repeated_unpackedSfixed32_codec); + break; + } + case 786: + case 785: { + unpackedSfixed64_.AddEntriesFrom(ref input, _repeated_unpackedSfixed64_codec); + break; + } + case 794: + case 797: { + unpackedFloat_.AddEntriesFrom(ref input, _repeated_unpackedFloat_codec); + break; + } + case 802: + case 801: { + unpackedDouble_.AddEntriesFrom(ref input, _repeated_unpackedDouble_codec); + break; + } + case 810: + case 808: { + unpackedBool_.AddEntriesFrom(ref input, _repeated_unpackedBool_codec); + break; + } + case 818: + case 816: { + unpackedNestedEnum_.AddEntriesFrom(ref input, _repeated_unpackedNestedEnum_codec); + break; + } + case 888: { + OneofUint32 = input.ReadUInt32(); + break; + } + case 898: { + global::ProtobufTestMessages.Proto2.TestAllTypesProto2.Types.NestedMessage subBuilder = new global::ProtobufTestMessages.Proto2.TestAllTypesProto2.Types.NestedMessage(); + if (HasOneofNestedMessage) { + subBuilder.MergeFrom(OneofNestedMessage); + } + input.ReadMessage(subBuilder); + OneofNestedMessage = subBuilder; + break; + } + case 906: { + OneofString = input.ReadString(); + break; + } + case 914: { + OneofBytes = input.ReadBytes(); + break; + } + case 920: { + OneofBool = input.ReadBool(); + break; + } + case 928: { + OneofUint64 = input.ReadUInt64(); + break; + } + case 941: { + OneofFloat = input.ReadFloat(); + break; + } + case 945: { + OneofDouble = input.ReadDouble(); + break; + } + case 952: { + oneofField_ = input.ReadEnum(); + oneofFieldCase_ = OneofFieldOneofCase.OneofEnum; + break; + } + case 1611: { + if (!HasData) { + Data = new global::ProtobufTestMessages.Proto2.TestAllTypesProto2.Types.Data(); + } + input.ReadGroup(Data); + break; + } + case 3208: { + Fieldname1 = input.ReadInt32(); + break; + } + case 3216: { + FieldName2 = input.ReadInt32(); + break; + } + case 3224: { + FieldName3 = input.ReadInt32(); + break; + } + case 3232: { + FieldName4 = input.ReadInt32(); + break; + } + case 3240: { + Field0Name5 = input.ReadInt32(); + break; + } + case 3248: { + Field0Name6 = input.ReadInt32(); + break; + } + case 3256: { + FieldName7 = input.ReadInt32(); + break; + } + case 3264: { + FieldName8 = input.ReadInt32(); + break; + } + case 3272: { + FieldName9 = input.ReadInt32(); + break; + } + case 3280: { + FieldName10 = input.ReadInt32(); + break; + } + case 3288: { + FIELDNAME11 = input.ReadInt32(); + break; + } + case 3296: { + FIELDName12 = input.ReadInt32(); + break; + } + case 3304: { + FieldName13 = input.ReadInt32(); + break; + } + case 3312: { + FieldName14 = input.ReadInt32(); + break; + } + case 3320: { + FieldName15 = input.ReadInt32(); + break; + } + case 3328: { + FieldName16 = input.ReadInt32(); + break; + } + case 3336: { + FieldName17 = input.ReadInt32(); + break; + } + case 3344: { + FieldName18 = input.ReadInt32(); + break; + } + } + } + } + #endif + + public TValue GetExtension(pb::Extension extension) { + return pb::ExtensionSet.Get(ref _extensions, extension); + } + public pbc::RepeatedField GetExtension(pb::RepeatedExtension extension) { + return pb::ExtensionSet.Get(ref _extensions, extension); + } + public pbc::RepeatedField GetOrInitializeExtension(pb::RepeatedExtension extension) { + return pb::ExtensionSet.GetOrInitialize(ref _extensions, extension); + } + public void SetExtension(pb::Extension extension, TValue value) { + pb::ExtensionSet.Set(ref _extensions, extension, value); + } + public bool HasExtension(pb::Extension extension) { + return pb::ExtensionSet.Has(ref _extensions, extension); + } + public void ClearExtension(pb::Extension extension) { + pb::ExtensionSet.Clear(ref _extensions, extension); + } + public void ClearExtension(pb::RepeatedExtension extension) { + pb::ExtensionSet.Clear(ref _extensions, extension); + } + + #region Nested types + /// Container for nested types declared in the TestAllTypesProto2 message type. + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static partial class Types { + public enum NestedEnum { + [pbr::OriginalName("FOO")] Foo = 0, + [pbr::OriginalName("BAR")] Bar = 1, + [pbr::OriginalName("BAZ")] Baz = 2, + /// + /// Intentionally negative. + /// + [pbr::OriginalName("NEG")] Neg = -1, + } + + public sealed partial class NestedMessage : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedMessage()); + private pb::UnknownFieldSet _unknownFields; + private int _hasBits0; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::ProtobufTestMessages.Proto2.TestAllTypesProto2.Descriptor.NestedTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } @@ -4040,18 +4880,35 @@ public sealed partial class NestedMessage : pb::IMessage { if (HasA) hash ^= A.GetHashCode(); if (HasCorecursive) hash ^= Corecursive.GetHashCode(); if (_unknownFields != null) { - hash ^= _unknownFields.GetHashCode(); + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (HasA) { + output.WriteRawTag(8); + output.WriteInt32(A); + } + if (HasCorecursive) { + output.WriteRawTag(18); + output.WriteMessage(Corecursive); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); } - return hash; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void WriteTo(pb::CodedOutputStream output) { + public void WriteTo(ref pb::CodedOutputWriter output) { if (HasA) { output.WriteRawTag(8); output.WriteInt32(A); @@ -4061,9 +4918,10 @@ public sealed partial class NestedMessage : pb::IMessage { output.WriteMessage(Corecursive); } if (_unknownFields != null) { - _unknownFields.WriteTo(output); + _unknownFields.WriteTo(ref output); } } + #endif [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { @@ -4120,12 +4978,42 @@ public sealed partial class NestedMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + A = input.ReadInt32(); + break; + } + case 18: { + if (!HasCorecursive) { + Corecursive = new global::ProtobufTestMessages.Proto2.TestAllTypesProto2(); + } + input.ReadMessage(Corecursive); + break; + } + } + } + } + #endif + } /// /// groups /// - public sealed partial class Data : pb::IMessage { + public sealed partial class Data : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Data()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -4259,6 +5147,24 @@ public sealed partial class Data : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasGroupInt32) { + output.WriteRawTag(208, 12); + output.WriteInt32(GroupInt32); + } + if (HasGroupUint32) { + output.WriteRawTag(216, 12); + output.WriteUInt32(GroupUint32); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -4310,12 +5216,41 @@ public sealed partial class Data : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + case 1612: + return; + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 1616: { + GroupInt32 = input.ReadInt32(); + break; + } + case 1624: { + GroupUint32 = input.ReadUInt32(); + break; + } + } + } + } + #endif + } /// /// message_set test case. /// - public sealed partial class MessageSetCorrect : pb::IExtendableMessage { + public sealed partial class MessageSetCorrect : pb::IExtendableMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MessageSetCorrect()); private pb::UnknownFieldSet _unknownFields; private pb::ExtensionSet _extensions; @@ -4397,6 +5332,19 @@ public sealed partial class MessageSetCorrect : pb::IExtendableMessage(pb::Extension extension) { return pb::ExtensionSet.Get(ref _extensions, extension); } @@ -4456,7 +5421,11 @@ public sealed partial class MessageSetCorrect : pb::IExtendableMessage { + public sealed partial class MessageSetCorrectExtension1 : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MessageSetCorrectExtension1()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -4556,6 +5525,20 @@ public sealed partial class MessageSetCorrectExtension1 : pb::IMessageContainer for extensions for other messages declared in the MessageSetCorrectExtension1 message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -4606,7 +5608,11 @@ public static partial class Extensions { } - public sealed partial class MessageSetCorrectExtension2 : pb::IMessage { + public sealed partial class MessageSetCorrectExtension2 : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MessageSetCorrectExtension2()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -4709,6 +5715,20 @@ public sealed partial class MessageSetCorrectExtension2 : pb::IMessageContainer for extensions for other messages declared in the MessageSetCorrectExtension2 message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -4764,7 +5803,11 @@ public static partial class Extensions { } - public sealed partial class ForeignMessageProto2 : pb::IMessage { + public sealed partial class ForeignMessageProto2 : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ForeignMessageProto2()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -4867,6 +5910,20 @@ public sealed partial class ForeignMessageProto2 : pb::IMessage { + public sealed partial class UnknownToTestAllTypes : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new UnknownToTestAllTypes()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -5143,6 +6223,38 @@ public sealed partial class UnknownToTestAllTypes : pb::IMessageContainer for nested types declared in the UnknownToTestAllTypes message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - public sealed partial class OptionalGroup : pb::IMessage { + public sealed partial class OptionalGroup : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new OptionalGroup()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -5348,6 +6510,20 @@ public sealed partial class OptionalGroup : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasA) { + output.WriteRawTag(8); + output.WriteInt32(A); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -5389,6 +6565,27 @@ public sealed partial class OptionalGroup : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + case 8036: + return; + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + A = input.ReadInt32(); + break; + } + } + } + } + #endif + } } diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/TestMessagesProto3.cs b/csharp/src/Google.Protobuf.Test.TestProtos/TestMessagesProto3.cs index 064d0c0acec0..b1859a8292f6 100644 --- a/csharp/src/Google.Protobuf.Test.TestProtos/TestMessagesProto3.cs +++ b/csharp/src/Google.Protobuf.Test.TestProtos/TestMessagesProto3.cs @@ -259,7 +259,11 @@ public enum ForeignEnum { /// could trigger bugs that occur in any message type in this file. We verify /// this stays true in a unit test. /// - public sealed partial class TestAllTypesProto3 : pb::IMessage { + public sealed partial class TestAllTypesProto3 : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestAllTypesProto3()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -2755,6 +2759,351 @@ public enum OneofFieldOneofCase { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (OptionalInt32 != 0) { + output.WriteRawTag(8); + output.WriteInt32(OptionalInt32); + } + if (OptionalInt64 != 0L) { + output.WriteRawTag(16); + output.WriteInt64(OptionalInt64); + } + if (OptionalUint32 != 0) { + output.WriteRawTag(24); + output.WriteUInt32(OptionalUint32); + } + if (OptionalUint64 != 0UL) { + output.WriteRawTag(32); + output.WriteUInt64(OptionalUint64); + } + if (OptionalSint32 != 0) { + output.WriteRawTag(40); + output.WriteSInt32(OptionalSint32); + } + if (OptionalSint64 != 0L) { + output.WriteRawTag(48); + output.WriteSInt64(OptionalSint64); + } + if (OptionalFixed32 != 0) { + output.WriteRawTag(61); + output.WriteFixed32(OptionalFixed32); + } + if (OptionalFixed64 != 0UL) { + output.WriteRawTag(65); + output.WriteFixed64(OptionalFixed64); + } + if (OptionalSfixed32 != 0) { + output.WriteRawTag(77); + output.WriteSFixed32(OptionalSfixed32); + } + if (OptionalSfixed64 != 0L) { + output.WriteRawTag(81); + output.WriteSFixed64(OptionalSfixed64); + } + if (OptionalFloat != 0F) { + output.WriteRawTag(93); + output.WriteFloat(OptionalFloat); + } + if (OptionalDouble != 0D) { + output.WriteRawTag(97); + output.WriteDouble(OptionalDouble); + } + if (OptionalBool != false) { + output.WriteRawTag(104); + output.WriteBool(OptionalBool); + } + if (OptionalString.Length != 0) { + output.WriteRawTag(114); + output.WriteString(OptionalString); + } + if (OptionalBytes.Length != 0) { + output.WriteRawTag(122); + output.WriteBytes(OptionalBytes); + } + if (optionalNestedMessage_ != null) { + output.WriteRawTag(146, 1); + output.WriteMessage(OptionalNestedMessage); + } + if (optionalForeignMessage_ != null) { + output.WriteRawTag(154, 1); + output.WriteMessage(OptionalForeignMessage); + } + if (OptionalNestedEnum != global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.NestedEnum.Foo) { + output.WriteRawTag(168, 1); + output.WriteEnum((int) OptionalNestedEnum); + } + if (OptionalForeignEnum != global::ProtobufTestMessages.Proto3.ForeignEnum.ForeignFoo) { + output.WriteRawTag(176, 1); + output.WriteEnum((int) OptionalForeignEnum); + } + if (OptionalAliasedEnum != global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.AliasedEnum.AliasFoo) { + output.WriteRawTag(184, 1); + output.WriteEnum((int) OptionalAliasedEnum); + } + if (OptionalStringPiece.Length != 0) { + output.WriteRawTag(194, 1); + output.WriteString(OptionalStringPiece); + } + if (OptionalCord.Length != 0) { + output.WriteRawTag(202, 1); + output.WriteString(OptionalCord); + } + if (recursiveMessage_ != null) { + output.WriteRawTag(218, 1); + output.WriteMessage(RecursiveMessage); + } + repeatedInt32_.WriteTo(ref output, _repeated_repeatedInt32_codec); + repeatedInt64_.WriteTo(ref output, _repeated_repeatedInt64_codec); + repeatedUint32_.WriteTo(ref output, _repeated_repeatedUint32_codec); + repeatedUint64_.WriteTo(ref output, _repeated_repeatedUint64_codec); + repeatedSint32_.WriteTo(ref output, _repeated_repeatedSint32_codec); + repeatedSint64_.WriteTo(ref output, _repeated_repeatedSint64_codec); + repeatedFixed32_.WriteTo(ref output, _repeated_repeatedFixed32_codec); + repeatedFixed64_.WriteTo(ref output, _repeated_repeatedFixed64_codec); + repeatedSfixed32_.WriteTo(ref output, _repeated_repeatedSfixed32_codec); + repeatedSfixed64_.WriteTo(ref output, _repeated_repeatedSfixed64_codec); + repeatedFloat_.WriteTo(ref output, _repeated_repeatedFloat_codec); + repeatedDouble_.WriteTo(ref output, _repeated_repeatedDouble_codec); + repeatedBool_.WriteTo(ref output, _repeated_repeatedBool_codec); + repeatedString_.WriteTo(ref output, _repeated_repeatedString_codec); + repeatedBytes_.WriteTo(ref output, _repeated_repeatedBytes_codec); + repeatedNestedMessage_.WriteTo(ref output, _repeated_repeatedNestedMessage_codec); + repeatedForeignMessage_.WriteTo(ref output, _repeated_repeatedForeignMessage_codec); + repeatedNestedEnum_.WriteTo(ref output, _repeated_repeatedNestedEnum_codec); + repeatedForeignEnum_.WriteTo(ref output, _repeated_repeatedForeignEnum_codec); + repeatedStringPiece_.WriteTo(ref output, _repeated_repeatedStringPiece_codec); + repeatedCord_.WriteTo(ref output, _repeated_repeatedCord_codec); + mapInt32Int32_.WriteTo(ref output, _map_mapInt32Int32_codec); + mapInt64Int64_.WriteTo(ref output, _map_mapInt64Int64_codec); + mapUint32Uint32_.WriteTo(ref output, _map_mapUint32Uint32_codec); + mapUint64Uint64_.WriteTo(ref output, _map_mapUint64Uint64_codec); + mapSint32Sint32_.WriteTo(ref output, _map_mapSint32Sint32_codec); + mapSint64Sint64_.WriteTo(ref output, _map_mapSint64Sint64_codec); + mapFixed32Fixed32_.WriteTo(ref output, _map_mapFixed32Fixed32_codec); + mapFixed64Fixed64_.WriteTo(ref output, _map_mapFixed64Fixed64_codec); + mapSfixed32Sfixed32_.WriteTo(ref output, _map_mapSfixed32Sfixed32_codec); + mapSfixed64Sfixed64_.WriteTo(ref output, _map_mapSfixed64Sfixed64_codec); + mapInt32Float_.WriteTo(ref output, _map_mapInt32Float_codec); + mapInt32Double_.WriteTo(ref output, _map_mapInt32Double_codec); + mapBoolBool_.WriteTo(ref output, _map_mapBoolBool_codec); + mapStringString_.WriteTo(ref output, _map_mapStringString_codec); + mapStringBytes_.WriteTo(ref output, _map_mapStringBytes_codec); + mapStringNestedMessage_.WriteTo(ref output, _map_mapStringNestedMessage_codec); + mapStringForeignMessage_.WriteTo(ref output, _map_mapStringForeignMessage_codec); + mapStringNestedEnum_.WriteTo(ref output, _map_mapStringNestedEnum_codec); + mapStringForeignEnum_.WriteTo(ref output, _map_mapStringForeignEnum_codec); + packedInt32_.WriteTo(ref output, _repeated_packedInt32_codec); + packedInt64_.WriteTo(ref output, _repeated_packedInt64_codec); + packedUint32_.WriteTo(ref output, _repeated_packedUint32_codec); + packedUint64_.WriteTo(ref output, _repeated_packedUint64_codec); + packedSint32_.WriteTo(ref output, _repeated_packedSint32_codec); + packedSint64_.WriteTo(ref output, _repeated_packedSint64_codec); + packedFixed32_.WriteTo(ref output, _repeated_packedFixed32_codec); + packedFixed64_.WriteTo(ref output, _repeated_packedFixed64_codec); + packedSfixed32_.WriteTo(ref output, _repeated_packedSfixed32_codec); + packedSfixed64_.WriteTo(ref output, _repeated_packedSfixed64_codec); + packedFloat_.WriteTo(ref output, _repeated_packedFloat_codec); + packedDouble_.WriteTo(ref output, _repeated_packedDouble_codec); + packedBool_.WriteTo(ref output, _repeated_packedBool_codec); + packedNestedEnum_.WriteTo(ref output, _repeated_packedNestedEnum_codec); + unpackedInt32_.WriteTo(ref output, _repeated_unpackedInt32_codec); + unpackedInt64_.WriteTo(ref output, _repeated_unpackedInt64_codec); + unpackedUint32_.WriteTo(ref output, _repeated_unpackedUint32_codec); + unpackedUint64_.WriteTo(ref output, _repeated_unpackedUint64_codec); + unpackedSint32_.WriteTo(ref output, _repeated_unpackedSint32_codec); + unpackedSint64_.WriteTo(ref output, _repeated_unpackedSint64_codec); + unpackedFixed32_.WriteTo(ref output, _repeated_unpackedFixed32_codec); + unpackedFixed64_.WriteTo(ref output, _repeated_unpackedFixed64_codec); + unpackedSfixed32_.WriteTo(ref output, _repeated_unpackedSfixed32_codec); + unpackedSfixed64_.WriteTo(ref output, _repeated_unpackedSfixed64_codec); + unpackedFloat_.WriteTo(ref output, _repeated_unpackedFloat_codec); + unpackedDouble_.WriteTo(ref output, _repeated_unpackedDouble_codec); + unpackedBool_.WriteTo(ref output, _repeated_unpackedBool_codec); + unpackedNestedEnum_.WriteTo(ref output, _repeated_unpackedNestedEnum_codec); + if (oneofFieldCase_ == OneofFieldOneofCase.OneofUint32) { + output.WriteRawTag(248, 6); + output.WriteUInt32(OneofUint32); + } + if (oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage) { + output.WriteRawTag(130, 7); + output.WriteMessage(OneofNestedMessage); + } + if (oneofFieldCase_ == OneofFieldOneofCase.OneofString) { + output.WriteRawTag(138, 7); + output.WriteString(OneofString); + } + if (oneofFieldCase_ == OneofFieldOneofCase.OneofBytes) { + output.WriteRawTag(146, 7); + output.WriteBytes(OneofBytes); + } + if (oneofFieldCase_ == OneofFieldOneofCase.OneofBool) { + output.WriteRawTag(152, 7); + output.WriteBool(OneofBool); + } + if (oneofFieldCase_ == OneofFieldOneofCase.OneofUint64) { + output.WriteRawTag(160, 7); + output.WriteUInt64(OneofUint64); + } + if (oneofFieldCase_ == OneofFieldOneofCase.OneofFloat) { + output.WriteRawTag(173, 7); + output.WriteFloat(OneofFloat); + } + if (oneofFieldCase_ == OneofFieldOneofCase.OneofDouble) { + output.WriteRawTag(177, 7); + output.WriteDouble(OneofDouble); + } + if (oneofFieldCase_ == OneofFieldOneofCase.OneofEnum) { + output.WriteRawTag(184, 7); + output.WriteEnum((int) OneofEnum); + } + if (optionalBoolWrapper_ != null) { + _single_optionalBoolWrapper_codec.WriteTagAndValue(ref output, OptionalBoolWrapper); + } + if (optionalInt32Wrapper_ != null) { + _single_optionalInt32Wrapper_codec.WriteTagAndValue(ref output, OptionalInt32Wrapper); + } + if (optionalInt64Wrapper_ != null) { + _single_optionalInt64Wrapper_codec.WriteTagAndValue(ref output, OptionalInt64Wrapper); + } + if (optionalUint32Wrapper_ != null) { + _single_optionalUint32Wrapper_codec.WriteTagAndValue(ref output, OptionalUint32Wrapper); + } + if (optionalUint64Wrapper_ != null) { + _single_optionalUint64Wrapper_codec.WriteTagAndValue(ref output, OptionalUint64Wrapper); + } + if (optionalFloatWrapper_ != null) { + _single_optionalFloatWrapper_codec.WriteTagAndValue(ref output, OptionalFloatWrapper); + } + if (optionalDoubleWrapper_ != null) { + _single_optionalDoubleWrapper_codec.WriteTagAndValue(ref output, OptionalDoubleWrapper); + } + if (optionalStringWrapper_ != null) { + _single_optionalStringWrapper_codec.WriteTagAndValue(ref output, OptionalStringWrapper); + } + if (optionalBytesWrapper_ != null) { + _single_optionalBytesWrapper_codec.WriteTagAndValue(ref output, OptionalBytesWrapper); + } + repeatedBoolWrapper_.WriteTo(ref output, _repeated_repeatedBoolWrapper_codec); + repeatedInt32Wrapper_.WriteTo(ref output, _repeated_repeatedInt32Wrapper_codec); + repeatedInt64Wrapper_.WriteTo(ref output, _repeated_repeatedInt64Wrapper_codec); + repeatedUint32Wrapper_.WriteTo(ref output, _repeated_repeatedUint32Wrapper_codec); + repeatedUint64Wrapper_.WriteTo(ref output, _repeated_repeatedUint64Wrapper_codec); + repeatedFloatWrapper_.WriteTo(ref output, _repeated_repeatedFloatWrapper_codec); + repeatedDoubleWrapper_.WriteTo(ref output, _repeated_repeatedDoubleWrapper_codec); + repeatedStringWrapper_.WriteTo(ref output, _repeated_repeatedStringWrapper_codec); + repeatedBytesWrapper_.WriteTo(ref output, _repeated_repeatedBytesWrapper_codec); + if (optionalDuration_ != null) { + output.WriteRawTag(234, 18); + output.WriteMessage(OptionalDuration); + } + if (optionalTimestamp_ != null) { + output.WriteRawTag(242, 18); + output.WriteMessage(OptionalTimestamp); + } + if (optionalFieldMask_ != null) { + output.WriteRawTag(250, 18); + output.WriteMessage(OptionalFieldMask); + } + if (optionalStruct_ != null) { + output.WriteRawTag(130, 19); + output.WriteMessage(OptionalStruct); + } + if (optionalAny_ != null) { + output.WriteRawTag(138, 19); + output.WriteMessage(OptionalAny); + } + if (optionalValue_ != null) { + output.WriteRawTag(146, 19); + output.WriteMessage(OptionalValue); + } + repeatedDuration_.WriteTo(ref output, _repeated_repeatedDuration_codec); + repeatedTimestamp_.WriteTo(ref output, _repeated_repeatedTimestamp_codec); + repeatedFieldmask_.WriteTo(ref output, _repeated_repeatedFieldmask_codec); + repeatedAny_.WriteTo(ref output, _repeated_repeatedAny_codec); + repeatedValue_.WriteTo(ref output, _repeated_repeatedValue_codec); + repeatedListValue_.WriteTo(ref output, _repeated_repeatedListValue_codec); + repeatedStruct_.WriteTo(ref output, _repeated_repeatedStruct_codec); + if (Fieldname1 != 0) { + output.WriteRawTag(136, 25); + output.WriteInt32(Fieldname1); + } + if (FieldName2 != 0) { + output.WriteRawTag(144, 25); + output.WriteInt32(FieldName2); + } + if (FieldName3 != 0) { + output.WriteRawTag(152, 25); + output.WriteInt32(FieldName3); + } + if (FieldName4 != 0) { + output.WriteRawTag(160, 25); + output.WriteInt32(FieldName4); + } + if (Field0Name5 != 0) { + output.WriteRawTag(168, 25); + output.WriteInt32(Field0Name5); + } + if (Field0Name6 != 0) { + output.WriteRawTag(176, 25); + output.WriteInt32(Field0Name6); + } + if (FieldName7 != 0) { + output.WriteRawTag(184, 25); + output.WriteInt32(FieldName7); + } + if (FieldName8 != 0) { + output.WriteRawTag(192, 25); + output.WriteInt32(FieldName8); + } + if (FieldName9 != 0) { + output.WriteRawTag(200, 25); + output.WriteInt32(FieldName9); + } + if (FieldName10 != 0) { + output.WriteRawTag(208, 25); + output.WriteInt32(FieldName10); + } + if (FIELDNAME11 != 0) { + output.WriteRawTag(216, 25); + output.WriteInt32(FIELDNAME11); + } + if (FIELDName12 != 0) { + output.WriteRawTag(224, 25); + output.WriteInt32(FIELDName12); + } + if (FieldName13 != 0) { + output.WriteRawTag(232, 25); + output.WriteInt32(FieldName13); + } + if (FieldName14 != 0) { + output.WriteRawTag(240, 25); + output.WriteInt32(FieldName14); + } + if (FieldName15 != 0) { + output.WriteRawTag(248, 25); + output.WriteInt32(FieldName15); + } + if (FieldName16 != 0) { + output.WriteRawTag(128, 26); + output.WriteInt32(FieldName16); + } + if (FieldName17 != 0) { + output.WriteRawTag(136, 26); + output.WriteInt32(FieldName17); + } + if (FieldName18 != 0) { + output.WriteRawTag(144, 26); + output.WriteInt32(FieldName18); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -4092,15 +4441,729 @@ public enum OneofFieldOneofCase { } } - #region Nested types - /// Container for nested types declared in the TestAllTypesProto3 message type. + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static partial class Types { - public enum NestedEnum { - [pbr::OriginalName("FOO")] Foo = 0, - [pbr::OriginalName("BAR")] Bar = 1, - [pbr::OriginalName("BAZ")] Baz = 2, - /// + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + OptionalInt32 = input.ReadInt32(); + break; + } + case 16: { + OptionalInt64 = input.ReadInt64(); + break; + } + case 24: { + OptionalUint32 = input.ReadUInt32(); + break; + } + case 32: { + OptionalUint64 = input.ReadUInt64(); + break; + } + case 40: { + OptionalSint32 = input.ReadSInt32(); + break; + } + case 48: { + OptionalSint64 = input.ReadSInt64(); + break; + } + case 61: { + OptionalFixed32 = input.ReadFixed32(); + break; + } + case 65: { + OptionalFixed64 = input.ReadFixed64(); + break; + } + case 77: { + OptionalSfixed32 = input.ReadSFixed32(); + break; + } + case 81: { + OptionalSfixed64 = input.ReadSFixed64(); + break; + } + case 93: { + OptionalFloat = input.ReadFloat(); + break; + } + case 97: { + OptionalDouble = input.ReadDouble(); + break; + } + case 104: { + OptionalBool = input.ReadBool(); + break; + } + case 114: { + OptionalString = input.ReadString(); + break; + } + case 122: { + OptionalBytes = input.ReadBytes(); + break; + } + case 146: { + if (optionalNestedMessage_ == null) { + OptionalNestedMessage = new global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.NestedMessage(); + } + input.ReadMessage(OptionalNestedMessage); + break; + } + case 154: { + if (optionalForeignMessage_ == null) { + OptionalForeignMessage = new global::ProtobufTestMessages.Proto3.ForeignMessage(); + } + input.ReadMessage(OptionalForeignMessage); + break; + } + case 168: { + OptionalNestedEnum = (global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.NestedEnum) input.ReadEnum(); + break; + } + case 176: { + OptionalForeignEnum = (global::ProtobufTestMessages.Proto3.ForeignEnum) input.ReadEnum(); + break; + } + case 184: { + OptionalAliasedEnum = (global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.AliasedEnum) input.ReadEnum(); + break; + } + case 194: { + OptionalStringPiece = input.ReadString(); + break; + } + case 202: { + OptionalCord = input.ReadString(); + break; + } + case 218: { + if (recursiveMessage_ == null) { + RecursiveMessage = new global::ProtobufTestMessages.Proto3.TestAllTypesProto3(); + } + input.ReadMessage(RecursiveMessage); + break; + } + case 250: + case 248: { + repeatedInt32_.AddEntriesFrom(ref input, _repeated_repeatedInt32_codec); + break; + } + case 258: + case 256: { + repeatedInt64_.AddEntriesFrom(ref input, _repeated_repeatedInt64_codec); + break; + } + case 266: + case 264: { + repeatedUint32_.AddEntriesFrom(ref input, _repeated_repeatedUint32_codec); + break; + } + case 274: + case 272: { + repeatedUint64_.AddEntriesFrom(ref input, _repeated_repeatedUint64_codec); + break; + } + case 282: + case 280: { + repeatedSint32_.AddEntriesFrom(ref input, _repeated_repeatedSint32_codec); + break; + } + case 290: + case 288: { + repeatedSint64_.AddEntriesFrom(ref input, _repeated_repeatedSint64_codec); + break; + } + case 298: + case 301: { + repeatedFixed32_.AddEntriesFrom(ref input, _repeated_repeatedFixed32_codec); + break; + } + case 306: + case 305: { + repeatedFixed64_.AddEntriesFrom(ref input, _repeated_repeatedFixed64_codec); + break; + } + case 314: + case 317: { + repeatedSfixed32_.AddEntriesFrom(ref input, _repeated_repeatedSfixed32_codec); + break; + } + case 322: + case 321: { + repeatedSfixed64_.AddEntriesFrom(ref input, _repeated_repeatedSfixed64_codec); + break; + } + case 330: + case 333: { + repeatedFloat_.AddEntriesFrom(ref input, _repeated_repeatedFloat_codec); + break; + } + case 338: + case 337: { + repeatedDouble_.AddEntriesFrom(ref input, _repeated_repeatedDouble_codec); + break; + } + case 346: + case 344: { + repeatedBool_.AddEntriesFrom(ref input, _repeated_repeatedBool_codec); + break; + } + case 354: { + repeatedString_.AddEntriesFrom(ref input, _repeated_repeatedString_codec); + break; + } + case 362: { + repeatedBytes_.AddEntriesFrom(ref input, _repeated_repeatedBytes_codec); + break; + } + case 386: { + repeatedNestedMessage_.AddEntriesFrom(ref input, _repeated_repeatedNestedMessage_codec); + break; + } + case 394: { + repeatedForeignMessage_.AddEntriesFrom(ref input, _repeated_repeatedForeignMessage_codec); + break; + } + case 410: + case 408: { + repeatedNestedEnum_.AddEntriesFrom(ref input, _repeated_repeatedNestedEnum_codec); + break; + } + case 418: + case 416: { + repeatedForeignEnum_.AddEntriesFrom(ref input, _repeated_repeatedForeignEnum_codec); + break; + } + case 434: { + repeatedStringPiece_.AddEntriesFrom(ref input, _repeated_repeatedStringPiece_codec); + break; + } + case 442: { + repeatedCord_.AddEntriesFrom(ref input, _repeated_repeatedCord_codec); + break; + } + case 450: { + mapInt32Int32_.AddEntriesFrom(ref input, _map_mapInt32Int32_codec); + break; + } + case 458: { + mapInt64Int64_.AddEntriesFrom(ref input, _map_mapInt64Int64_codec); + break; + } + case 466: { + mapUint32Uint32_.AddEntriesFrom(ref input, _map_mapUint32Uint32_codec); + break; + } + case 474: { + mapUint64Uint64_.AddEntriesFrom(ref input, _map_mapUint64Uint64_codec); + break; + } + case 482: { + mapSint32Sint32_.AddEntriesFrom(ref input, _map_mapSint32Sint32_codec); + break; + } + case 490: { + mapSint64Sint64_.AddEntriesFrom(ref input, _map_mapSint64Sint64_codec); + break; + } + case 498: { + mapFixed32Fixed32_.AddEntriesFrom(ref input, _map_mapFixed32Fixed32_codec); + break; + } + case 506: { + mapFixed64Fixed64_.AddEntriesFrom(ref input, _map_mapFixed64Fixed64_codec); + break; + } + case 514: { + mapSfixed32Sfixed32_.AddEntriesFrom(ref input, _map_mapSfixed32Sfixed32_codec); + break; + } + case 522: { + mapSfixed64Sfixed64_.AddEntriesFrom(ref input, _map_mapSfixed64Sfixed64_codec); + break; + } + case 530: { + mapInt32Float_.AddEntriesFrom(ref input, _map_mapInt32Float_codec); + break; + } + case 538: { + mapInt32Double_.AddEntriesFrom(ref input, _map_mapInt32Double_codec); + break; + } + case 546: { + mapBoolBool_.AddEntriesFrom(ref input, _map_mapBoolBool_codec); + break; + } + case 554: { + mapStringString_.AddEntriesFrom(ref input, _map_mapStringString_codec); + break; + } + case 562: { + mapStringBytes_.AddEntriesFrom(ref input, _map_mapStringBytes_codec); + break; + } + case 570: { + mapStringNestedMessage_.AddEntriesFrom(ref input, _map_mapStringNestedMessage_codec); + break; + } + case 578: { + mapStringForeignMessage_.AddEntriesFrom(ref input, _map_mapStringForeignMessage_codec); + break; + } + case 586: { + mapStringNestedEnum_.AddEntriesFrom(ref input, _map_mapStringNestedEnum_codec); + break; + } + case 594: { + mapStringForeignEnum_.AddEntriesFrom(ref input, _map_mapStringForeignEnum_codec); + break; + } + case 602: + case 600: { + packedInt32_.AddEntriesFrom(ref input, _repeated_packedInt32_codec); + break; + } + case 610: + case 608: { + packedInt64_.AddEntriesFrom(ref input, _repeated_packedInt64_codec); + break; + } + case 618: + case 616: { + packedUint32_.AddEntriesFrom(ref input, _repeated_packedUint32_codec); + break; + } + case 626: + case 624: { + packedUint64_.AddEntriesFrom(ref input, _repeated_packedUint64_codec); + break; + } + case 634: + case 632: { + packedSint32_.AddEntriesFrom(ref input, _repeated_packedSint32_codec); + break; + } + case 642: + case 640: { + packedSint64_.AddEntriesFrom(ref input, _repeated_packedSint64_codec); + break; + } + case 650: + case 653: { + packedFixed32_.AddEntriesFrom(ref input, _repeated_packedFixed32_codec); + break; + } + case 658: + case 657: { + packedFixed64_.AddEntriesFrom(ref input, _repeated_packedFixed64_codec); + break; + } + case 666: + case 669: { + packedSfixed32_.AddEntriesFrom(ref input, _repeated_packedSfixed32_codec); + break; + } + case 674: + case 673: { + packedSfixed64_.AddEntriesFrom(ref input, _repeated_packedSfixed64_codec); + break; + } + case 682: + case 685: { + packedFloat_.AddEntriesFrom(ref input, _repeated_packedFloat_codec); + break; + } + case 690: + case 689: { + packedDouble_.AddEntriesFrom(ref input, _repeated_packedDouble_codec); + break; + } + case 698: + case 696: { + packedBool_.AddEntriesFrom(ref input, _repeated_packedBool_codec); + break; + } + case 706: + case 704: { + packedNestedEnum_.AddEntriesFrom(ref input, _repeated_packedNestedEnum_codec); + break; + } + case 714: + case 712: { + unpackedInt32_.AddEntriesFrom(ref input, _repeated_unpackedInt32_codec); + break; + } + case 722: + case 720: { + unpackedInt64_.AddEntriesFrom(ref input, _repeated_unpackedInt64_codec); + break; + } + case 730: + case 728: { + unpackedUint32_.AddEntriesFrom(ref input, _repeated_unpackedUint32_codec); + break; + } + case 738: + case 736: { + unpackedUint64_.AddEntriesFrom(ref input, _repeated_unpackedUint64_codec); + break; + } + case 746: + case 744: { + unpackedSint32_.AddEntriesFrom(ref input, _repeated_unpackedSint32_codec); + break; + } + case 754: + case 752: { + unpackedSint64_.AddEntriesFrom(ref input, _repeated_unpackedSint64_codec); + break; + } + case 762: + case 765: { + unpackedFixed32_.AddEntriesFrom(ref input, _repeated_unpackedFixed32_codec); + break; + } + case 770: + case 769: { + unpackedFixed64_.AddEntriesFrom(ref input, _repeated_unpackedFixed64_codec); + break; + } + case 778: + case 781: { + unpackedSfixed32_.AddEntriesFrom(ref input, _repeated_unpackedSfixed32_codec); + break; + } + case 786: + case 785: { + unpackedSfixed64_.AddEntriesFrom(ref input, _repeated_unpackedSfixed64_codec); + break; + } + case 794: + case 797: { + unpackedFloat_.AddEntriesFrom(ref input, _repeated_unpackedFloat_codec); + break; + } + case 802: + case 801: { + unpackedDouble_.AddEntriesFrom(ref input, _repeated_unpackedDouble_codec); + break; + } + case 810: + case 808: { + unpackedBool_.AddEntriesFrom(ref input, _repeated_unpackedBool_codec); + break; + } + case 818: + case 816: { + unpackedNestedEnum_.AddEntriesFrom(ref input, _repeated_unpackedNestedEnum_codec); + break; + } + case 888: { + OneofUint32 = input.ReadUInt32(); + break; + } + case 898: { + global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.NestedMessage subBuilder = new global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.NestedMessage(); + if (oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage) { + subBuilder.MergeFrom(OneofNestedMessage); + } + input.ReadMessage(subBuilder); + OneofNestedMessage = subBuilder; + break; + } + case 906: { + OneofString = input.ReadString(); + break; + } + case 914: { + OneofBytes = input.ReadBytes(); + break; + } + case 920: { + OneofBool = input.ReadBool(); + break; + } + case 928: { + OneofUint64 = input.ReadUInt64(); + break; + } + case 941: { + OneofFloat = input.ReadFloat(); + break; + } + case 945: { + OneofDouble = input.ReadDouble(); + break; + } + case 952: { + oneofField_ = input.ReadEnum(); + oneofFieldCase_ = OneofFieldOneofCase.OneofEnum; + break; + } + case 1610: { + bool? value = _single_optionalBoolWrapper_codec.Read(ref input); + if (optionalBoolWrapper_ == null || value != false) { + OptionalBoolWrapper = value; + } + break; + } + case 1618: { + int? value = _single_optionalInt32Wrapper_codec.Read(ref input); + if (optionalInt32Wrapper_ == null || value != 0) { + OptionalInt32Wrapper = value; + } + break; + } + case 1626: { + long? value = _single_optionalInt64Wrapper_codec.Read(ref input); + if (optionalInt64Wrapper_ == null || value != 0L) { + OptionalInt64Wrapper = value; + } + break; + } + case 1634: { + uint? value = _single_optionalUint32Wrapper_codec.Read(ref input); + if (optionalUint32Wrapper_ == null || value != 0) { + OptionalUint32Wrapper = value; + } + break; + } + case 1642: { + ulong? value = _single_optionalUint64Wrapper_codec.Read(ref input); + if (optionalUint64Wrapper_ == null || value != 0UL) { + OptionalUint64Wrapper = value; + } + break; + } + case 1650: { + float? value = _single_optionalFloatWrapper_codec.Read(ref input); + if (optionalFloatWrapper_ == null || value != 0F) { + OptionalFloatWrapper = value; + } + break; + } + case 1658: { + double? value = _single_optionalDoubleWrapper_codec.Read(ref input); + if (optionalDoubleWrapper_ == null || value != 0D) { + OptionalDoubleWrapper = value; + } + break; + } + case 1666: { + string value = _single_optionalStringWrapper_codec.Read(ref input); + if (optionalStringWrapper_ == null || value != "") { + OptionalStringWrapper = value; + } + break; + } + case 1674: { + pb::ByteString value = _single_optionalBytesWrapper_codec.Read(ref input); + if (optionalBytesWrapper_ == null || value != pb::ByteString.Empty) { + OptionalBytesWrapper = value; + } + break; + } + case 1690: { + repeatedBoolWrapper_.AddEntriesFrom(ref input, _repeated_repeatedBoolWrapper_codec); + break; + } + case 1698: { + repeatedInt32Wrapper_.AddEntriesFrom(ref input, _repeated_repeatedInt32Wrapper_codec); + break; + } + case 1706: { + repeatedInt64Wrapper_.AddEntriesFrom(ref input, _repeated_repeatedInt64Wrapper_codec); + break; + } + case 1714: { + repeatedUint32Wrapper_.AddEntriesFrom(ref input, _repeated_repeatedUint32Wrapper_codec); + break; + } + case 1722: { + repeatedUint64Wrapper_.AddEntriesFrom(ref input, _repeated_repeatedUint64Wrapper_codec); + break; + } + case 1730: { + repeatedFloatWrapper_.AddEntriesFrom(ref input, _repeated_repeatedFloatWrapper_codec); + break; + } + case 1738: { + repeatedDoubleWrapper_.AddEntriesFrom(ref input, _repeated_repeatedDoubleWrapper_codec); + break; + } + case 1746: { + repeatedStringWrapper_.AddEntriesFrom(ref input, _repeated_repeatedStringWrapper_codec); + break; + } + case 1754: { + repeatedBytesWrapper_.AddEntriesFrom(ref input, _repeated_repeatedBytesWrapper_codec); + break; + } + case 2410: { + if (optionalDuration_ == null) { + OptionalDuration = new global::Google.Protobuf.WellKnownTypes.Duration(); + } + input.ReadMessage(OptionalDuration); + break; + } + case 2418: { + if (optionalTimestamp_ == null) { + OptionalTimestamp = new global::Google.Protobuf.WellKnownTypes.Timestamp(); + } + input.ReadMessage(OptionalTimestamp); + break; + } + case 2426: { + if (optionalFieldMask_ == null) { + OptionalFieldMask = new global::Google.Protobuf.WellKnownTypes.FieldMask(); + } + input.ReadMessage(OptionalFieldMask); + break; + } + case 2434: { + if (optionalStruct_ == null) { + OptionalStruct = new global::Google.Protobuf.WellKnownTypes.Struct(); + } + input.ReadMessage(OptionalStruct); + break; + } + case 2442: { + if (optionalAny_ == null) { + OptionalAny = new global::Google.Protobuf.WellKnownTypes.Any(); + } + input.ReadMessage(OptionalAny); + break; + } + case 2450: { + if (optionalValue_ == null) { + OptionalValue = new global::Google.Protobuf.WellKnownTypes.Value(); + } + input.ReadMessage(OptionalValue); + break; + } + case 2490: { + repeatedDuration_.AddEntriesFrom(ref input, _repeated_repeatedDuration_codec); + break; + } + case 2498: { + repeatedTimestamp_.AddEntriesFrom(ref input, _repeated_repeatedTimestamp_codec); + break; + } + case 2506: { + repeatedFieldmask_.AddEntriesFrom(ref input, _repeated_repeatedFieldmask_codec); + break; + } + case 2522: { + repeatedAny_.AddEntriesFrom(ref input, _repeated_repeatedAny_codec); + break; + } + case 2530: { + repeatedValue_.AddEntriesFrom(ref input, _repeated_repeatedValue_codec); + break; + } + case 2538: { + repeatedListValue_.AddEntriesFrom(ref input, _repeated_repeatedListValue_codec); + break; + } + case 2594: { + repeatedStruct_.AddEntriesFrom(ref input, _repeated_repeatedStruct_codec); + break; + } + case 3208: { + Fieldname1 = input.ReadInt32(); + break; + } + case 3216: { + FieldName2 = input.ReadInt32(); + break; + } + case 3224: { + FieldName3 = input.ReadInt32(); + break; + } + case 3232: { + FieldName4 = input.ReadInt32(); + break; + } + case 3240: { + Field0Name5 = input.ReadInt32(); + break; + } + case 3248: { + Field0Name6 = input.ReadInt32(); + break; + } + case 3256: { + FieldName7 = input.ReadInt32(); + break; + } + case 3264: { + FieldName8 = input.ReadInt32(); + break; + } + case 3272: { + FieldName9 = input.ReadInt32(); + break; + } + case 3280: { + FieldName10 = input.ReadInt32(); + break; + } + case 3288: { + FIELDNAME11 = input.ReadInt32(); + break; + } + case 3296: { + FIELDName12 = input.ReadInt32(); + break; + } + case 3304: { + FieldName13 = input.ReadInt32(); + break; + } + case 3312: { + FieldName14 = input.ReadInt32(); + break; + } + case 3320: { + FieldName15 = input.ReadInt32(); + break; + } + case 3328: { + FieldName16 = input.ReadInt32(); + break; + } + case 3336: { + FieldName17 = input.ReadInt32(); + break; + } + case 3344: { + FieldName18 = input.ReadInt32(); + break; + } + } + } + } + #endif + + #region Nested types + /// Container for nested types declared in the TestAllTypesProto3 message type. + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static partial class Types { + public enum NestedEnum { + [pbr::OriginalName("FOO")] Foo = 0, + [pbr::OriginalName("BAR")] Bar = 1, + [pbr::OriginalName("BAZ")] Baz = 2, + /// /// Intentionally negative. /// [pbr::OriginalName("NEG")] Neg = -1, @@ -4115,7 +5178,11 @@ public enum AliasedEnum { [pbr::OriginalName("bAz", PreferredAlias = false)] BAz = 2, } - public sealed partial class NestedMessage : pb::IMessage { + public sealed partial class NestedMessage : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -4221,6 +5288,24 @@ public sealed partial class NestedMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (A != 0) { + output.WriteRawTag(8); + output.WriteInt32(A); + } + if (corecursive_ != null) { + output.WriteRawTag(18); + output.WriteMessage(Corecursive); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -4276,6 +5361,32 @@ public sealed partial class NestedMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + A = input.ReadInt32(); + break; + } + case 18: { + if (corecursive_ == null) { + Corecursive = new global::ProtobufTestMessages.Proto3.TestAllTypesProto3(); + } + input.ReadMessage(Corecursive); + break; + } + } + } + } + #endif + } } @@ -4283,7 +5394,11 @@ public sealed partial class NestedMessage : pb::IMessage { } - public sealed partial class ForeignMessage : pb::IMessage { + public sealed partial class ForeignMessage : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ForeignMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -4371,6 +5486,20 @@ public sealed partial class ForeignMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (C != 0) { + output.WriteRawTag(8); + output.WriteInt32(C); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -4410,6 +5539,25 @@ public sealed partial class ForeignMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + C = input.ReadInt32(); + break; + } + } + } + } + #endif + } #endregion diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/Unittest.cs b/csharp/src/Google.Protobuf.Test.TestProtos/Unittest.cs index e55df12f2ec8..f4e57671c605 100644 --- a/csharp/src/Google.Protobuf.Test.TestProtos/Unittest.cs +++ b/csharp/src/Google.Protobuf.Test.TestProtos/Unittest.cs @@ -1120,7 +1120,11 @@ public enum VeryLargeEnum { /// This proto includes every type of field in both singular and repeated /// forms. /// - public sealed partial class TestAllTypes : pb::IMessage { + public sealed partial class TestAllTypes : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestAllTypes()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -3111,6 +3115,242 @@ public enum OneofFieldOneofCase { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasOptionalInt32) { + output.WriteRawTag(8); + output.WriteInt32(OptionalInt32); + } + if (HasOptionalInt64) { + output.WriteRawTag(16); + output.WriteInt64(OptionalInt64); + } + if (HasOptionalUint32) { + output.WriteRawTag(24); + output.WriteUInt32(OptionalUint32); + } + if (HasOptionalUint64) { + output.WriteRawTag(32); + output.WriteUInt64(OptionalUint64); + } + if (HasOptionalSint32) { + output.WriteRawTag(40); + output.WriteSInt32(OptionalSint32); + } + if (HasOptionalSint64) { + output.WriteRawTag(48); + output.WriteSInt64(OptionalSint64); + } + if (HasOptionalFixed32) { + output.WriteRawTag(61); + output.WriteFixed32(OptionalFixed32); + } + if (HasOptionalFixed64) { + output.WriteRawTag(65); + output.WriteFixed64(OptionalFixed64); + } + if (HasOptionalSfixed32) { + output.WriteRawTag(77); + output.WriteSFixed32(OptionalSfixed32); + } + if (HasOptionalSfixed64) { + output.WriteRawTag(81); + output.WriteSFixed64(OptionalSfixed64); + } + if (HasOptionalFloat) { + output.WriteRawTag(93); + output.WriteFloat(OptionalFloat); + } + if (HasOptionalDouble) { + output.WriteRawTag(97); + output.WriteDouble(OptionalDouble); + } + if (HasOptionalBool) { + output.WriteRawTag(104); + output.WriteBool(OptionalBool); + } + if (HasOptionalString) { + output.WriteRawTag(114); + output.WriteString(OptionalString); + } + if (HasOptionalBytes) { + output.WriteRawTag(122); + output.WriteBytes(OptionalBytes); + } + if (HasOptionalGroup) { + output.WriteRawTag(131, 1); + output.WriteGroup(OptionalGroup); + output.WriteRawTag(132, 1); + } + if (HasOptionalNestedMessage) { + output.WriteRawTag(146, 1); + output.WriteMessage(OptionalNestedMessage); + } + if (HasOptionalForeignMessage) { + output.WriteRawTag(154, 1); + output.WriteMessage(OptionalForeignMessage); + } + if (HasOptionalImportMessage) { + output.WriteRawTag(162, 1); + output.WriteMessage(OptionalImportMessage); + } + if (HasOptionalNestedEnum) { + output.WriteRawTag(168, 1); + output.WriteEnum((int) OptionalNestedEnum); + } + if (HasOptionalForeignEnum) { + output.WriteRawTag(176, 1); + output.WriteEnum((int) OptionalForeignEnum); + } + if (HasOptionalImportEnum) { + output.WriteRawTag(184, 1); + output.WriteEnum((int) OptionalImportEnum); + } + if (HasOptionalStringPiece) { + output.WriteRawTag(194, 1); + output.WriteString(OptionalStringPiece); + } + if (HasOptionalCord) { + output.WriteRawTag(202, 1); + output.WriteString(OptionalCord); + } + if (HasOptionalPublicImportMessage) { + output.WriteRawTag(210, 1); + output.WriteMessage(OptionalPublicImportMessage); + } + if (HasOptionalLazyMessage) { + output.WriteRawTag(218, 1); + output.WriteMessage(OptionalLazyMessage); + } + repeatedInt32_.WriteTo(ref output, _repeated_repeatedInt32_codec); + repeatedInt64_.WriteTo(ref output, _repeated_repeatedInt64_codec); + repeatedUint32_.WriteTo(ref output, _repeated_repeatedUint32_codec); + repeatedUint64_.WriteTo(ref output, _repeated_repeatedUint64_codec); + repeatedSint32_.WriteTo(ref output, _repeated_repeatedSint32_codec); + repeatedSint64_.WriteTo(ref output, _repeated_repeatedSint64_codec); + repeatedFixed32_.WriteTo(ref output, _repeated_repeatedFixed32_codec); + repeatedFixed64_.WriteTo(ref output, _repeated_repeatedFixed64_codec); + repeatedSfixed32_.WriteTo(ref output, _repeated_repeatedSfixed32_codec); + repeatedSfixed64_.WriteTo(ref output, _repeated_repeatedSfixed64_codec); + repeatedFloat_.WriteTo(ref output, _repeated_repeatedFloat_codec); + repeatedDouble_.WriteTo(ref output, _repeated_repeatedDouble_codec); + repeatedBool_.WriteTo(ref output, _repeated_repeatedBool_codec); + repeatedString_.WriteTo(ref output, _repeated_repeatedString_codec); + repeatedBytes_.WriteTo(ref output, _repeated_repeatedBytes_codec); + repeatedGroup_.WriteTo(ref output, _repeated_repeatedGroup_codec); + repeatedNestedMessage_.WriteTo(ref output, _repeated_repeatedNestedMessage_codec); + repeatedForeignMessage_.WriteTo(ref output, _repeated_repeatedForeignMessage_codec); + repeatedImportMessage_.WriteTo(ref output, _repeated_repeatedImportMessage_codec); + repeatedNestedEnum_.WriteTo(ref output, _repeated_repeatedNestedEnum_codec); + repeatedForeignEnum_.WriteTo(ref output, _repeated_repeatedForeignEnum_codec); + repeatedImportEnum_.WriteTo(ref output, _repeated_repeatedImportEnum_codec); + repeatedStringPiece_.WriteTo(ref output, _repeated_repeatedStringPiece_codec); + repeatedCord_.WriteTo(ref output, _repeated_repeatedCord_codec); + repeatedLazyMessage_.WriteTo(ref output, _repeated_repeatedLazyMessage_codec); + if (HasDefaultInt32) { + output.WriteRawTag(232, 3); + output.WriteInt32(DefaultInt32); + } + if (HasDefaultInt64) { + output.WriteRawTag(240, 3); + output.WriteInt64(DefaultInt64); + } + if (HasDefaultUint32) { + output.WriteRawTag(248, 3); + output.WriteUInt32(DefaultUint32); + } + if (HasDefaultUint64) { + output.WriteRawTag(128, 4); + output.WriteUInt64(DefaultUint64); + } + if (HasDefaultSint32) { + output.WriteRawTag(136, 4); + output.WriteSInt32(DefaultSint32); + } + if (HasDefaultSint64) { + output.WriteRawTag(144, 4); + output.WriteSInt64(DefaultSint64); + } + if (HasDefaultFixed32) { + output.WriteRawTag(157, 4); + output.WriteFixed32(DefaultFixed32); + } + if (HasDefaultFixed64) { + output.WriteRawTag(161, 4); + output.WriteFixed64(DefaultFixed64); + } + if (HasDefaultSfixed32) { + output.WriteRawTag(173, 4); + output.WriteSFixed32(DefaultSfixed32); + } + if (HasDefaultSfixed64) { + output.WriteRawTag(177, 4); + output.WriteSFixed64(DefaultSfixed64); + } + if (HasDefaultFloat) { + output.WriteRawTag(189, 4); + output.WriteFloat(DefaultFloat); + } + if (HasDefaultDouble) { + output.WriteRawTag(193, 4); + output.WriteDouble(DefaultDouble); + } + if (HasDefaultBool) { + output.WriteRawTag(200, 4); + output.WriteBool(DefaultBool); + } + if (HasDefaultString) { + output.WriteRawTag(210, 4); + output.WriteString(DefaultString); + } + if (HasDefaultBytes) { + output.WriteRawTag(218, 4); + output.WriteBytes(DefaultBytes); + } + if (HasDefaultNestedEnum) { + output.WriteRawTag(136, 5); + output.WriteEnum((int) DefaultNestedEnum); + } + if (HasDefaultForeignEnum) { + output.WriteRawTag(144, 5); + output.WriteEnum((int) DefaultForeignEnum); + } + if (HasDefaultImportEnum) { + output.WriteRawTag(152, 5); + output.WriteEnum((int) DefaultImportEnum); + } + if (HasDefaultStringPiece) { + output.WriteRawTag(162, 5); + output.WriteString(DefaultStringPiece); + } + if (HasDefaultCord) { + output.WriteRawTag(170, 5); + output.WriteString(DefaultCord); + } + if (HasOneofUint32) { + output.WriteRawTag(248, 6); + output.WriteUInt32(OneofUint32); + } + if (HasOneofNestedMessage) { + output.WriteRawTag(130, 7); + output.WriteMessage(OneofNestedMessage); + } + if (HasOneofString) { + output.WriteRawTag(138, 7); + output.WriteString(OneofString); + } + if (HasOneofBytes) { + output.WriteRawTag(146, 7); + output.WriteBytes(OneofBytes); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -3853,57 +4093,415 @@ public enum OneofFieldOneofCase { } } - #region Nested types - /// Container for nested types declared in the TestAllTypes message type. - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static partial class Types { - public enum NestedEnum { - [pbr::OriginalName("FOO")] Foo = 1, - [pbr::OriginalName("BAR")] Bar = 2, - [pbr::OriginalName("BAZ")] Baz = 3, - /// - /// Intentionally negative. - /// - [pbr::OriginalName("NEG")] Neg = -1, - } - - public sealed partial class NestedMessage : pb::IMessage { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedMessage()); - private pb::UnknownFieldSet _unknownFields; - private int _hasBits0; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pbr::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.Proto2.TestAllTypes.Descriptor.NestedTypes[0]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public NestedMessage() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public NestedMessage(NestedMessage other) : this() { - _hasBits0 = other._hasBits0; - bb_ = other.bb_; - _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public NestedMessage Clone() { - return new NestedMessage(this); - } - /// Field number for the "bb" field. + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + OptionalInt32 = input.ReadInt32(); + break; + } + case 16: { + OptionalInt64 = input.ReadInt64(); + break; + } + case 24: { + OptionalUint32 = input.ReadUInt32(); + break; + } + case 32: { + OptionalUint64 = input.ReadUInt64(); + break; + } + case 40: { + OptionalSint32 = input.ReadSInt32(); + break; + } + case 48: { + OptionalSint64 = input.ReadSInt64(); + break; + } + case 61: { + OptionalFixed32 = input.ReadFixed32(); + break; + } + case 65: { + OptionalFixed64 = input.ReadFixed64(); + break; + } + case 77: { + OptionalSfixed32 = input.ReadSFixed32(); + break; + } + case 81: { + OptionalSfixed64 = input.ReadSFixed64(); + break; + } + case 93: { + OptionalFloat = input.ReadFloat(); + break; + } + case 97: { + OptionalDouble = input.ReadDouble(); + break; + } + case 104: { + OptionalBool = input.ReadBool(); + break; + } + case 114: { + OptionalString = input.ReadString(); + break; + } + case 122: { + OptionalBytes = input.ReadBytes(); + break; + } + case 131: { + if (!HasOptionalGroup) { + OptionalGroup = new global::Google.Protobuf.TestProtos.Proto2.TestAllTypes.Types.OptionalGroup(); + } + input.ReadGroup(OptionalGroup); + break; + } + case 146: { + if (!HasOptionalNestedMessage) { + OptionalNestedMessage = new global::Google.Protobuf.TestProtos.Proto2.TestAllTypes.Types.NestedMessage(); + } + input.ReadMessage(OptionalNestedMessage); + break; + } + case 154: { + if (!HasOptionalForeignMessage) { + OptionalForeignMessage = new global::Google.Protobuf.TestProtos.Proto2.ForeignMessage(); + } + input.ReadMessage(OptionalForeignMessage); + break; + } + case 162: { + if (!HasOptionalImportMessage) { + OptionalImportMessage = new global::Google.Protobuf.TestProtos.Proto2.ImportMessage(); + } + input.ReadMessage(OptionalImportMessage); + break; + } + case 168: { + OptionalNestedEnum = (global::Google.Protobuf.TestProtos.Proto2.TestAllTypes.Types.NestedEnum) input.ReadEnum(); + break; + } + case 176: { + OptionalForeignEnum = (global::Google.Protobuf.TestProtos.Proto2.ForeignEnum) input.ReadEnum(); + break; + } + case 184: { + OptionalImportEnum = (global::Google.Protobuf.TestProtos.Proto2.ImportEnum) input.ReadEnum(); + break; + } + case 194: { + OptionalStringPiece = input.ReadString(); + break; + } + case 202: { + OptionalCord = input.ReadString(); + break; + } + case 210: { + if (!HasOptionalPublicImportMessage) { + OptionalPublicImportMessage = new global::Google.Protobuf.TestProtos.Proto2.PublicImportMessage(); + } + input.ReadMessage(OptionalPublicImportMessage); + break; + } + case 218: { + if (!HasOptionalLazyMessage) { + OptionalLazyMessage = new global::Google.Protobuf.TestProtos.Proto2.TestAllTypes.Types.NestedMessage(); + } + input.ReadMessage(OptionalLazyMessage); + break; + } + case 250: + case 248: { + repeatedInt32_.AddEntriesFrom(ref input, _repeated_repeatedInt32_codec); + break; + } + case 258: + case 256: { + repeatedInt64_.AddEntriesFrom(ref input, _repeated_repeatedInt64_codec); + break; + } + case 266: + case 264: { + repeatedUint32_.AddEntriesFrom(ref input, _repeated_repeatedUint32_codec); + break; + } + case 274: + case 272: { + repeatedUint64_.AddEntriesFrom(ref input, _repeated_repeatedUint64_codec); + break; + } + case 282: + case 280: { + repeatedSint32_.AddEntriesFrom(ref input, _repeated_repeatedSint32_codec); + break; + } + case 290: + case 288: { + repeatedSint64_.AddEntriesFrom(ref input, _repeated_repeatedSint64_codec); + break; + } + case 298: + case 301: { + repeatedFixed32_.AddEntriesFrom(ref input, _repeated_repeatedFixed32_codec); + break; + } + case 306: + case 305: { + repeatedFixed64_.AddEntriesFrom(ref input, _repeated_repeatedFixed64_codec); + break; + } + case 314: + case 317: { + repeatedSfixed32_.AddEntriesFrom(ref input, _repeated_repeatedSfixed32_codec); + break; + } + case 322: + case 321: { + repeatedSfixed64_.AddEntriesFrom(ref input, _repeated_repeatedSfixed64_codec); + break; + } + case 330: + case 333: { + repeatedFloat_.AddEntriesFrom(ref input, _repeated_repeatedFloat_codec); + break; + } + case 338: + case 337: { + repeatedDouble_.AddEntriesFrom(ref input, _repeated_repeatedDouble_codec); + break; + } + case 346: + case 344: { + repeatedBool_.AddEntriesFrom(ref input, _repeated_repeatedBool_codec); + break; + } + case 354: { + repeatedString_.AddEntriesFrom(ref input, _repeated_repeatedString_codec); + break; + } + case 362: { + repeatedBytes_.AddEntriesFrom(ref input, _repeated_repeatedBytes_codec); + break; + } + case 371: { + repeatedGroup_.AddEntriesFrom(ref input, _repeated_repeatedGroup_codec); + break; + } + case 386: { + repeatedNestedMessage_.AddEntriesFrom(ref input, _repeated_repeatedNestedMessage_codec); + break; + } + case 394: { + repeatedForeignMessage_.AddEntriesFrom(ref input, _repeated_repeatedForeignMessage_codec); + break; + } + case 402: { + repeatedImportMessage_.AddEntriesFrom(ref input, _repeated_repeatedImportMessage_codec); + break; + } + case 410: + case 408: { + repeatedNestedEnum_.AddEntriesFrom(ref input, _repeated_repeatedNestedEnum_codec); + break; + } + case 418: + case 416: { + repeatedForeignEnum_.AddEntriesFrom(ref input, _repeated_repeatedForeignEnum_codec); + break; + } + case 426: + case 424: { + repeatedImportEnum_.AddEntriesFrom(ref input, _repeated_repeatedImportEnum_codec); + break; + } + case 434: { + repeatedStringPiece_.AddEntriesFrom(ref input, _repeated_repeatedStringPiece_codec); + break; + } + case 442: { + repeatedCord_.AddEntriesFrom(ref input, _repeated_repeatedCord_codec); + break; + } + case 458: { + repeatedLazyMessage_.AddEntriesFrom(ref input, _repeated_repeatedLazyMessage_codec); + break; + } + case 488: { + DefaultInt32 = input.ReadInt32(); + break; + } + case 496: { + DefaultInt64 = input.ReadInt64(); + break; + } + case 504: { + DefaultUint32 = input.ReadUInt32(); + break; + } + case 512: { + DefaultUint64 = input.ReadUInt64(); + break; + } + case 520: { + DefaultSint32 = input.ReadSInt32(); + break; + } + case 528: { + DefaultSint64 = input.ReadSInt64(); + break; + } + case 541: { + DefaultFixed32 = input.ReadFixed32(); + break; + } + case 545: { + DefaultFixed64 = input.ReadFixed64(); + break; + } + case 557: { + DefaultSfixed32 = input.ReadSFixed32(); + break; + } + case 561: { + DefaultSfixed64 = input.ReadSFixed64(); + break; + } + case 573: { + DefaultFloat = input.ReadFloat(); + break; + } + case 577: { + DefaultDouble = input.ReadDouble(); + break; + } + case 584: { + DefaultBool = input.ReadBool(); + break; + } + case 594: { + DefaultString = input.ReadString(); + break; + } + case 602: { + DefaultBytes = input.ReadBytes(); + break; + } + case 648: { + DefaultNestedEnum = (global::Google.Protobuf.TestProtos.Proto2.TestAllTypes.Types.NestedEnum) input.ReadEnum(); + break; + } + case 656: { + DefaultForeignEnum = (global::Google.Protobuf.TestProtos.Proto2.ForeignEnum) input.ReadEnum(); + break; + } + case 664: { + DefaultImportEnum = (global::Google.Protobuf.TestProtos.Proto2.ImportEnum) input.ReadEnum(); + break; + } + case 674: { + DefaultStringPiece = input.ReadString(); + break; + } + case 682: { + DefaultCord = input.ReadString(); + break; + } + case 888: { + OneofUint32 = input.ReadUInt32(); + break; + } + case 898: { + global::Google.Protobuf.TestProtos.Proto2.TestAllTypes.Types.NestedMessage subBuilder = new global::Google.Protobuf.TestProtos.Proto2.TestAllTypes.Types.NestedMessage(); + if (HasOneofNestedMessage) { + subBuilder.MergeFrom(OneofNestedMessage); + } + input.ReadMessage(subBuilder); + OneofNestedMessage = subBuilder; + break; + } + case 906: { + OneofString = input.ReadString(); + break; + } + case 914: { + OneofBytes = input.ReadBytes(); + break; + } + } + } + } + #endif + + #region Nested types + /// Container for nested types declared in the TestAllTypes message type. + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static partial class Types { + public enum NestedEnum { + [pbr::OriginalName("FOO")] Foo = 1, + [pbr::OriginalName("BAR")] Bar = 2, + [pbr::OriginalName("BAZ")] Baz = 3, + /// + /// Intentionally negative. + /// + [pbr::OriginalName("NEG")] Neg = -1, + } + + public sealed partial class NestedMessage : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedMessage()); + private pb::UnknownFieldSet _unknownFields; + private int _hasBits0; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.Proto2.TestAllTypes.Descriptor.NestedTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public NestedMessage() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public NestedMessage(NestedMessage other) : this() { + _hasBits0 = other._hasBits0; + bb_ = other.bb_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public NestedMessage Clone() { + return new NestedMessage(this); + } + + /// Field number for the "bb" field. public const int BbFieldNumber = 1; private readonly static int BbDefaultValue = 0; @@ -3975,6 +4573,20 @@ public sealed partial class NestedMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasBb) { + output.WriteRawTag(8); + output.WriteInt32(Bb); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -4014,9 +4626,32 @@ public sealed partial class NestedMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + Bb = input.ReadInt32(); + break; + } + } + } + } + #endif + } - public sealed partial class OptionalGroup : pb::IMessage { + public sealed partial class OptionalGroup : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new OptionalGroup()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -4119,6 +4754,20 @@ public sealed partial class OptionalGroup : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasA) { + output.WriteRawTag(136, 1); + output.WriteInt32(A); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -4160,9 +4809,34 @@ public sealed partial class OptionalGroup : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + case 132: + return; + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 136: { + A = input.ReadInt32(); + break; + } + } + } + } + #endif + } - public sealed partial class RepeatedGroup : pb::IMessage { + public sealed partial class RepeatedGroup : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new RepeatedGroup()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -4265,6 +4939,20 @@ public sealed partial class RepeatedGroup : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasA) { + output.WriteRawTag(248, 2); + output.WriteInt32(A); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -4306,6 +4994,27 @@ public sealed partial class RepeatedGroup : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + case 372: + return; + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 376: { + A = input.ReadInt32(); + break; + } + } + } + } + #endif + } } @@ -4314,9 +5023,13 @@ public sealed partial class RepeatedGroup : pb::IMessage { } /// - /// This proto includes a recusively nested message. + /// This proto includes a recursively nested message. /// - public sealed partial class NestedTestAllTypes : pb::IMessage { + public sealed partial class NestedTestAllTypes : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedTestAllTypes()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -4456,6 +5169,25 @@ public sealed partial class NestedTestAllTypes : pb::IMessage { + public sealed partial class TestDeprecatedFields : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestDeprecatedFields()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -4689,6 +5458,24 @@ public enum OneofFieldsOneofCase { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasDeprecatedInt32) { + output.WriteRawTag(8); + output.WriteInt32(DeprecatedInt32); + } + if (HasDeprecatedInt32InOneof) { + output.WriteRawTag(16); + output.WriteInt32(DeprecatedInt32InOneof); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -4741,10 +5528,37 @@ public enum OneofFieldsOneofCase { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + DeprecatedInt32 = input.ReadInt32(); + break; + } + case 16: { + DeprecatedInt32InOneof = input.ReadInt32(); + break; + } + } + } + } + #endif + } [global::System.ObsoleteAttribute] - public sealed partial class TestDeprecatedMessage : pb::IMessage { + public sealed partial class TestDeprecatedMessage : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestDeprecatedMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -4814,6 +5628,16 @@ public sealed partial class TestDeprecatedMessage : pb::IMessage /// Define these after TestAllTypes to make sure the compiler can handle /// that. /// - public sealed partial class ForeignMessage : pb::IMessage { + public sealed partial class ForeignMessage : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ForeignMessage()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -4983,6 +5826,24 @@ public sealed partial class ForeignMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasC) { + output.WriteRawTag(8); + output.WriteInt32(C); + } + if (HasD) { + output.WriteRawTag(16); + output.WriteInt32(D); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -5032,9 +5893,36 @@ public sealed partial class ForeignMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + C = input.ReadInt32(); + break; + } + case 16: { + D = input.ReadInt32(); + break; + } + } + } + } + #endif + } - public sealed partial class TestReservedFields : pb::IMessage { + public sealed partial class TestReservedFields : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestReservedFields()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -5104,6 +5992,16 @@ public sealed partial class TestReservedFields : pb::IMessage { + public sealed partial class TestAllExtensions : pb::IExtendableMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestAllExtensions()); private pb::UnknownFieldSet _unknownFields; private pb::ExtensionSet _extensions; @@ -5217,6 +6134,19 @@ public sealed partial class TestAllExtensions : pb::IExtendableMessage(pb::Extension extension) { return pb::ExtensionSet.Get(ref _extensions, extension); } @@ -5276,7 +6223,11 @@ public sealed partial class TestAllExtensions : pb::IExtendableMessage { + public sealed partial class OptionalGroup_extension : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new OptionalGroup_extension()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -5369,15 +6320,29 @@ public sealed partial class OptionalGroup_extension : pb::IMessage { + public sealed partial class RepeatedGroup_extension : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new RepeatedGroup_extension()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -5525,6 +6515,20 @@ public sealed partial class RepeatedGroup_extension : pb::IMessage { + public sealed partial class TestGroup : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestGroup()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -5700,6 +6729,25 @@ public sealed partial class TestGroup : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasOptionalGroup) { + output.WriteRawTag(131, 1); + output.WriteGroup(OptionalGroup); + output.WriteRawTag(132, 1); + } + if (HasOptionalForeignEnum) { + output.WriteRawTag(176, 1); + output.WriteEnum((int) OptionalForeignEnum); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -5755,11 +6803,41 @@ public sealed partial class TestGroup : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 131: { + if (!HasOptionalGroup) { + OptionalGroup = new global::Google.Protobuf.TestProtos.Proto2.TestGroup.Types.OptionalGroup(); + } + input.ReadGroup(OptionalGroup); + break; + } + case 176: { + OptionalForeignEnum = (global::Google.Protobuf.TestProtos.Proto2.ForeignEnum) input.ReadEnum(); + break; + } + } + } + } + #endif + #region Nested types /// Container for nested types declared in the TestGroup message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - public sealed partial class OptionalGroup : pb::IMessage { + public sealed partial class OptionalGroup : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new OptionalGroup()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -5862,6 +6940,20 @@ public sealed partial class OptionalGroup : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasA) { + output.WriteRawTag(136, 1); + output.WriteInt32(A); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -5903,6 +6995,27 @@ public sealed partial class OptionalGroup : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + case 132: + return; + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 136: { + A = input.ReadInt32(); + break; + } + } + } + } + #endif + } } @@ -5910,7 +7023,11 @@ public sealed partial class OptionalGroup : pb::IMessage { } - public sealed partial class TestGroupExtension : pb::IExtendableMessage { + public sealed partial class TestGroupExtension : pb::IExtendableMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestGroupExtension()); private pb::UnknownFieldSet _unknownFields; private pb::ExtensionSet _extensions; @@ -5992,6 +7109,19 @@ public sealed partial class TestGroupExtension : pb::IExtendableMessage(pb::Extension extension) { return pb::ExtensionSet.Get(ref _extensions, extension); } @@ -6051,7 +7198,11 @@ public sealed partial class TestGroupExtension : pb::IExtendableMessage { + public sealed partial class TestNestedExtension : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestNestedExtension()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -6121,6 +7272,16 @@ public sealed partial class TestNestedExtension : pb::IMessageContainer for nested types declared in the TestNestedExtension message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - public sealed partial class OptionalGroup_extension : pb::IMessage { + public sealed partial class OptionalGroup_extension : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new OptionalGroup_extension()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -6257,6 +7437,20 @@ public sealed partial class OptionalGroup_extension : pb::IMessage - public sealed partial class TestRequired : pb::IMessage { + public sealed partial class TestRequired : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestRequired()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -7287,18 +8506,159 @@ public sealed partial class TestRequired : pb::IMessage { if (HasDummy32) hash ^= Dummy32.GetHashCode(); if (HasC) hash ^= C.GetHashCode(); if (_unknownFields != null) { - hash ^= _unknownFields.GetHashCode(); + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (HasA) { + output.WriteRawTag(8); + output.WriteInt32(A); + } + if (HasDummy2) { + output.WriteRawTag(16); + output.WriteInt32(Dummy2); + } + if (HasB) { + output.WriteRawTag(24); + output.WriteInt32(B); + } + if (HasDummy4) { + output.WriteRawTag(32); + output.WriteInt32(Dummy4); + } + if (HasDummy5) { + output.WriteRawTag(40); + output.WriteInt32(Dummy5); + } + if (HasDummy6) { + output.WriteRawTag(48); + output.WriteInt32(Dummy6); + } + if (HasDummy7) { + output.WriteRawTag(56); + output.WriteInt32(Dummy7); + } + if (HasDummy8) { + output.WriteRawTag(64); + output.WriteInt32(Dummy8); + } + if (HasDummy9) { + output.WriteRawTag(72); + output.WriteInt32(Dummy9); + } + if (HasDummy10) { + output.WriteRawTag(80); + output.WriteInt32(Dummy10); + } + if (HasDummy11) { + output.WriteRawTag(88); + output.WriteInt32(Dummy11); + } + if (HasDummy12) { + output.WriteRawTag(96); + output.WriteInt32(Dummy12); + } + if (HasDummy13) { + output.WriteRawTag(104); + output.WriteInt32(Dummy13); + } + if (HasDummy14) { + output.WriteRawTag(112); + output.WriteInt32(Dummy14); + } + if (HasDummy15) { + output.WriteRawTag(120); + output.WriteInt32(Dummy15); + } + if (HasDummy16) { + output.WriteRawTag(128, 1); + output.WriteInt32(Dummy16); + } + if (HasDummy17) { + output.WriteRawTag(136, 1); + output.WriteInt32(Dummy17); + } + if (HasDummy18) { + output.WriteRawTag(144, 1); + output.WriteInt32(Dummy18); + } + if (HasDummy19) { + output.WriteRawTag(152, 1); + output.WriteInt32(Dummy19); + } + if (HasDummy20) { + output.WriteRawTag(160, 1); + output.WriteInt32(Dummy20); + } + if (HasDummy21) { + output.WriteRawTag(168, 1); + output.WriteInt32(Dummy21); + } + if (HasDummy22) { + output.WriteRawTag(176, 1); + output.WriteInt32(Dummy22); + } + if (HasDummy23) { + output.WriteRawTag(184, 1); + output.WriteInt32(Dummy23); + } + if (HasDummy24) { + output.WriteRawTag(192, 1); + output.WriteInt32(Dummy24); + } + if (HasDummy25) { + output.WriteRawTag(200, 1); + output.WriteInt32(Dummy25); + } + if (HasDummy26) { + output.WriteRawTag(208, 1); + output.WriteInt32(Dummy26); + } + if (HasDummy27) { + output.WriteRawTag(216, 1); + output.WriteInt32(Dummy27); + } + if (HasDummy28) { + output.WriteRawTag(224, 1); + output.WriteInt32(Dummy28); + } + if (HasDummy29) { + output.WriteRawTag(232, 1); + output.WriteInt32(Dummy29); + } + if (HasDummy30) { + output.WriteRawTag(240, 1); + output.WriteInt32(Dummy30); + } + if (HasDummy31) { + output.WriteRawTag(248, 1); + output.WriteInt32(Dummy31); + } + if (HasDummy32) { + output.WriteRawTag(128, 2); + output.WriteInt32(Dummy32); + } + if (HasC) { + output.WriteRawTag(136, 2); + output.WriteInt32(C); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); } - return hash; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void WriteTo(pb::CodedOutputStream output) { + public void WriteTo(ref pb::CodedOutputWriter output) { if (HasA) { output.WriteRawTag(8); output.WriteInt32(A); @@ -7432,9 +8792,10 @@ public sealed partial class TestRequired : pb::IMessage { output.WriteInt32(C); } if (_unknownFields != null) { - _unknownFields.WriteTo(output); + _unknownFields.WriteTo(ref output); } } + #endif [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { @@ -7795,6 +9156,153 @@ public sealed partial class TestRequired : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + A = input.ReadInt32(); + break; + } + case 16: { + Dummy2 = input.ReadInt32(); + break; + } + case 24: { + B = input.ReadInt32(); + break; + } + case 32: { + Dummy4 = input.ReadInt32(); + break; + } + case 40: { + Dummy5 = input.ReadInt32(); + break; + } + case 48: { + Dummy6 = input.ReadInt32(); + break; + } + case 56: { + Dummy7 = input.ReadInt32(); + break; + } + case 64: { + Dummy8 = input.ReadInt32(); + break; + } + case 72: { + Dummy9 = input.ReadInt32(); + break; + } + case 80: { + Dummy10 = input.ReadInt32(); + break; + } + case 88: { + Dummy11 = input.ReadInt32(); + break; + } + case 96: { + Dummy12 = input.ReadInt32(); + break; + } + case 104: { + Dummy13 = input.ReadInt32(); + break; + } + case 112: { + Dummy14 = input.ReadInt32(); + break; + } + case 120: { + Dummy15 = input.ReadInt32(); + break; + } + case 128: { + Dummy16 = input.ReadInt32(); + break; + } + case 136: { + Dummy17 = input.ReadInt32(); + break; + } + case 144: { + Dummy18 = input.ReadInt32(); + break; + } + case 152: { + Dummy19 = input.ReadInt32(); + break; + } + case 160: { + Dummy20 = input.ReadInt32(); + break; + } + case 168: { + Dummy21 = input.ReadInt32(); + break; + } + case 176: { + Dummy22 = input.ReadInt32(); + break; + } + case 184: { + Dummy23 = input.ReadInt32(); + break; + } + case 192: { + Dummy24 = input.ReadInt32(); + break; + } + case 200: { + Dummy25 = input.ReadInt32(); + break; + } + case 208: { + Dummy26 = input.ReadInt32(); + break; + } + case 216: { + Dummy27 = input.ReadInt32(); + break; + } + case 224: { + Dummy28 = input.ReadInt32(); + break; + } + case 232: { + Dummy29 = input.ReadInt32(); + break; + } + case 240: { + Dummy30 = input.ReadInt32(); + break; + } + case 248: { + Dummy31 = input.ReadInt32(); + break; + } + case 256: { + Dummy32 = input.ReadInt32(); + break; + } + case 264: { + C = input.ReadInt32(); + break; + } + } + } + } + #endif + #region Extensions /// Container for extensions for other messages declared in the TestRequired message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -7808,7 +9316,11 @@ public static partial class Extensions { } - public sealed partial class TestRequiredForeign : pb::IMessage { + public sealed partial class TestRequiredForeign : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestRequiredForeign()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -7953,6 +9465,25 @@ public sealed partial class TestRequiredForeign : pb::IMessage { + public sealed partial class TestRequiredMessage : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestRequiredMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -8156,6 +9721,25 @@ public sealed partial class TestRequiredMessage : pb::IMessage /// Test that we can use NestedMessage from outside TestAllTypes. /// - public sealed partial class TestForeignNested : pb::IMessage { + public sealed partial class TestForeignNested : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestForeignNested()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -8326,6 +9947,20 @@ public sealed partial class TestForeignNested : pb::IMessage } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasForeignNested) { + output.WriteRawTag(10); + output.WriteMessage(ForeignNested); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -8371,12 +10006,38 @@ public sealed partial class TestForeignNested : pb::IMessage } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + if (!HasForeignNested) { + ForeignNested = new global::Google.Protobuf.TestProtos.Proto2.TestAllTypes.Types.NestedMessage(); + } + input.ReadMessage(ForeignNested); + break; + } + } + } + } + #endif + } /// /// TestEmptyMessage is used to test unknown field support. /// - public sealed partial class TestEmptyMessage : pb::IMessage { + public sealed partial class TestEmptyMessage : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestEmptyMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -8446,6 +10107,16 @@ public sealed partial class TestEmptyMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -8475,13 +10146,32 @@ public sealed partial class TestEmptyMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + } + } + } + #endif + } /// /// Like above, but declare all field numbers as potential extensions. No /// actual extensions should ever be defined for this type. /// - public sealed partial class TestEmptyMessageWithExtensions : pb::IExtendableMessage { + public sealed partial class TestEmptyMessageWithExtensions : pb::IExtendableMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestEmptyMessageWithExtensions()); private pb::UnknownFieldSet _unknownFields; private pb::ExtensionSet _extensions; @@ -8563,6 +10253,19 @@ public sealed partial class TestEmptyMessageWithExtensions : pb::IExtendableMess } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (_extensions != null) { + _extensions.WriteTo(ref output); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -8598,6 +10301,23 @@ public sealed partial class TestEmptyMessageWithExtensions : pb::IExtendableMess } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, ref input)) { + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + } + break; + } + } + } + #endif + public TValue GetExtension(pb::Extension extension) { return pb::ExtensionSet.Get(ref _extensions, extension); } @@ -8622,7 +10342,11 @@ public sealed partial class TestEmptyMessageWithExtensions : pb::IExtendableMess } - public sealed partial class TestMultipleExtensionRanges : pb::IExtendableMessage { + public sealed partial class TestMultipleExtensionRanges : pb::IExtendableMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestMultipleExtensionRanges()); private pb::UnknownFieldSet _unknownFields; private pb::ExtensionSet _extensions; @@ -8704,6 +10428,19 @@ public sealed partial class TestMultipleExtensionRanges : pb::IExtendableMessage } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (_extensions != null) { + _extensions.WriteTo(ref output); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -8739,6 +10476,23 @@ public sealed partial class TestMultipleExtensionRanges : pb::IExtendableMessage } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, ref input)) { + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + } + break; + } + } + } + #endif + public TValue GetExtension(pb::Extension extension) { return pb::ExtensionSet.Get(ref _extensions, extension); } @@ -8766,7 +10520,11 @@ public sealed partial class TestMultipleExtensionRanges : pb::IExtendableMessage /// /// Test that really large tag numbers don't break anything. /// - public sealed partial class TestReallyLargeTagNumber : pb::IMessage { + public sealed partial class TestReallyLargeTagNumber : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestReallyLargeTagNumber()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -8904,6 +10662,24 @@ public sealed partial class TestReallyLargeTagNumber : pb::IMessage { + public sealed partial class TestRecursiveMessage : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestRecursiveMessage()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -9086,6 +10889,24 @@ public sealed partial class TestRecursiveMessage : pb::IMessage /// Test that mutual recursion works. /// - public sealed partial class TestMutualRecursionA : pb::IMessage { + public sealed partial class TestMutualRecursionA : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestMutualRecursionA()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -9273,6 +11124,25 @@ public sealed partial class TestMutualRecursionA : pb::IMessageContainer for nested types declared in the TestMutualRecursionA message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - public sealed partial class SubMessage : pb::IMessage { + public sealed partial class SubMessage : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new SubMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -9426,15 +11329,29 @@ public sealed partial class SubMessage : pb::IMessage { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void WriteTo(pb::CodedOutputStream output) { + public void WriteTo(pb::CodedOutputStream output) { + if (HasB) { + output.WriteRawTag(10); + output.WriteMessage(B); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + } + + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { if (HasB) { output.WriteRawTag(10); output.WriteMessage(B); } if (_unknownFields != null) { - _unknownFields.WriteTo(output); + _unknownFields.WriteTo(ref output); } } + #endif [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { @@ -9481,9 +11398,35 @@ public sealed partial class SubMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + if (!HasB) { + B = new global::Google.Protobuf.TestProtos.Proto2.TestMutualRecursionB(); + } + input.ReadMessage(B); + break; + } + } + } + } + #endif + } - public sealed partial class SubGroup : pb::IMessage { + public sealed partial class SubGroup : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new SubGroup()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -9612,6 +11555,24 @@ public sealed partial class SubGroup : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasSubMessage) { + output.WriteRawTag(26); + output.WriteMessage(SubMessage); + } + if (HasNotInThisScc) { + output.WriteRawTag(34); + output.WriteMessage(NotInThisScc); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -9675,6 +11636,37 @@ public sealed partial class SubGroup : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + case 20: + return; + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 26: { + if (!HasSubMessage) { + SubMessage = new global::Google.Protobuf.TestProtos.Proto2.TestMutualRecursionA.Types.SubMessage(); + } + input.ReadMessage(SubMessage); + break; + } + case 34: { + if (!HasNotInThisScc) { + NotInThisScc = new global::Google.Protobuf.TestProtos.Proto2.TestAllTypes(); + } + input.ReadMessage(NotInThisScc); + break; + } + } + } + } + #endif + } } @@ -9682,7 +11674,11 @@ public sealed partial class SubGroup : pb::IMessage { } - public sealed partial class TestMutualRecursionB : pb::IMessage { + public sealed partial class TestMutualRecursionB : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestMutualRecursionB()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -9813,6 +11809,24 @@ public sealed partial class TestMutualRecursionB : pb::IMessage { + public sealed partial class TestIsInitialized : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestIsInitialized()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -9968,6 +12012,20 @@ public sealed partial class TestIsInitialized : pb::IMessage } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasSubMessage) { + output.WriteRawTag(10); + output.WriteMessage(SubMessage); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -10013,11 +12071,37 @@ public sealed partial class TestIsInitialized : pb::IMessage } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + if (!HasSubMessage) { + SubMessage = new global::Google.Protobuf.TestProtos.Proto2.TestIsInitialized.Types.SubMessage(); + } + input.ReadMessage(SubMessage); + break; + } + } + } + } + #endif + #region Nested types /// Container for nested types declared in the TestIsInitialized message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - public sealed partial class SubMessage : pb::IMessage { + public sealed partial class SubMessage : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new SubMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -10116,6 +12200,21 @@ public sealed partial class SubMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasSubGroup) { + output.WriteRawTag(11); + output.WriteGroup(SubGroup); + output.WriteRawTag(12); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -10161,11 +12260,37 @@ public sealed partial class SubMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 11: { + if (!HasSubGroup) { + SubGroup = new global::Google.Protobuf.TestProtos.Proto2.TestIsInitialized.Types.SubMessage.Types.SubGroup(); + } + input.ReadGroup(SubGroup); + break; + } + } + } + } + #endif + #region Nested types /// Container for nested types declared in the SubMessage message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - public sealed partial class SubGroup : pb::IMessage { + public sealed partial class SubGroup : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new SubGroup()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -10268,6 +12393,20 @@ public sealed partial class SubGroup : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasI) { + output.WriteRawTag(16); + output.WriteInt32(I); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -10309,6 +12448,27 @@ public sealed partial class SubGroup : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + case 12: + return; + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 16: { + I = input.ReadInt32(); + break; + } + } + } + } + #endif + } } @@ -10327,7 +12487,11 @@ public sealed partial class SubGroup : pb::IMessage { /// to compile with proto1, this will emit an error; so we only include it /// in protobuf_unittest_proto. /// - public sealed partial class TestDupFieldNumber : pb::IMessage { + public sealed partial class TestDupFieldNumber : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestDupFieldNumber()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -10491,6 +12655,30 @@ public sealed partial class TestDupFieldNumber : pb::IMessageContainer for nested types declared in the TestDupFieldNumber message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - public sealed partial class Foo : pb::IMessage { + public sealed partial class Foo : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Foo()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -10669,6 +12894,20 @@ public sealed partial class Foo : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasA) { + output.WriteRawTag(8); + output.WriteInt32(A); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -10689,18 +12928,38 @@ public sealed partial class Foo : pb::IMessage { if (other.HasA) { A = other.A; } - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + case 20: + return; + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + A = input.ReadInt32(); + break; + } + } + } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(pb::CodedInputStream input) { + public void MergeFrom(ref pb::CodedInputReader input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { case 20: return; default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { A = input.ReadInt32(); @@ -10709,10 +12968,15 @@ public sealed partial class Foo : pb::IMessage { } } } + #endif } - public sealed partial class Bar : pb::IMessage { + public sealed partial class Bar : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Bar()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -10815,6 +13079,20 @@ public sealed partial class Bar : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasA) { + output.WriteRawTag(8); + output.WriteInt32(A); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -10856,6 +13134,27 @@ public sealed partial class Bar : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + case 28: + return; + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + A = input.ReadInt32(); + break; + } + } + } + } + #endif + } } @@ -10866,7 +13165,11 @@ public sealed partial class Bar : pb::IMessage { /// /// Additional messages for testing lazy fields. /// - public sealed partial class TestEagerMessage : pb::IMessage { + public sealed partial class TestEagerMessage : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestEagerMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -10964,6 +13267,20 @@ public sealed partial class TestEagerMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasSubMessage) { + output.WriteRawTag(10); + output.WriteMessage(SubMessage); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -11009,9 +13326,35 @@ public sealed partial class TestEagerMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + if (!HasSubMessage) { + SubMessage = new global::Google.Protobuf.TestProtos.Proto2.TestAllTypes(); + } + input.ReadMessage(SubMessage); + break; + } + } + } + } + #endif + } - public sealed partial class TestLazyMessage : pb::IMessage { + public sealed partial class TestLazyMessage : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestLazyMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -11109,6 +13452,20 @@ public sealed partial class TestLazyMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasSubMessage) { + output.WriteRawTag(10); + output.WriteMessage(SubMessage); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -11154,12 +13511,38 @@ public sealed partial class TestLazyMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + if (!HasSubMessage) { + SubMessage = new global::Google.Protobuf.TestProtos.Proto2.TestAllTypes(); + } + input.ReadMessage(SubMessage); + break; + } + } + } + } + #endif + } /// /// Needed for a Python test. /// - public sealed partial class TestNestedMessageHasBits : pb::IMessage { + public sealed partial class TestNestedMessageHasBits : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestNestedMessageHasBits()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -11257,6 +13640,20 @@ public sealed partial class TestNestedMessageHasBits : pb::IMessageContainer for nested types declared in the TestNestedMessageHasBits message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - public sealed partial class NestedMessage : pb::IMessage { + public sealed partial class NestedMessage : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -11404,6 +13827,18 @@ public sealed partial class NestedMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + nestedmessageRepeatedInt32_.WriteTo(ref output, _repeated_nestedmessageRepeatedInt32_codec); + nestedmessageRepeatedForeignmessage_.WriteTo(ref output, _repeated_nestedmessageRepeatedForeignmessage_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -11446,6 +13881,30 @@ public sealed partial class NestedMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: + case 8: { + nestedmessageRepeatedInt32_.AddEntriesFrom(ref input, _repeated_nestedmessageRepeatedInt32_codec); + break; + } + case 18: { + nestedmessageRepeatedForeignmessage_.AddEntriesFrom(ref input, _repeated_nestedmessageRepeatedForeignmessage_codec); + break; + } + } + } + } + #endif + } } @@ -11457,7 +13916,11 @@ public sealed partial class NestedMessage : pb::IMessage { /// Test message with CamelCase field names. This violates Protocol Buffer /// standard style. /// - public sealed partial class TestCamelCaseFieldNames : pb::IMessage { + public sealed partial class TestCamelCaseFieldNames : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestCamelCaseFieldNames()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -11793,6 +14256,46 @@ public sealed partial class TestCamelCaseFieldNames : pb::IMessage /// We list fields out of order, to ensure that we're using field number and not /// field index to determine serialization order. /// - public sealed partial class TestFieldOrderings : pb::IExtendableMessage { + public sealed partial class TestFieldOrderings : pb::IExtendableMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestFieldOrderings()); private pb::UnknownFieldSet _unknownFields; private pb::ExtensionSet _extensions; @@ -12111,7 +14686,35 @@ public sealed partial class TestFieldOrderings : pb::IExtendableMessage(pb::Extension extension) { return pb::ExtensionSet.Get(ref _extensions, extension); } @@ -12243,7 +14883,11 @@ public sealed partial class TestFieldOrderings : pb::IExtendableMessageContainer for nested types declared in the TestFieldOrderings message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - public sealed partial class NestedMessage : pb::IMessage { + public sealed partial class NestedMessage : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedMessage()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -12382,6 +15026,24 @@ public sealed partial class NestedMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasBb) { + output.WriteRawTag(8); + output.WriteInt32(Bb); + } + if (HasOo) { + output.WriteRawTag(16); + output.WriteInt64(Oo); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -12431,6 +15093,29 @@ public sealed partial class NestedMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + Bb = input.ReadInt32(); + break; + } + case 16: { + Oo = input.ReadInt64(); + break; + } + } + } + } + #endif + } } @@ -12438,7 +15123,11 @@ public sealed partial class NestedMessage : pb::IMessage { } - public sealed partial class TestExtensionOrderings1 : pb::IMessage { + public sealed partial class TestExtensionOrderings1 : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestExtensionOrderings1()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -12538,6 +15227,20 @@ public sealed partial class TestExtensionOrderings1 : pb::IMessageContainer for extensions for other messages declared in the TestExtensionOrderings1 message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -12588,7 +15310,11 @@ public static partial class Extensions { } - public sealed partial class TestExtensionOrderings2 : pb::IMessage { + public sealed partial class TestExtensionOrderings2 : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestExtensionOrderings2()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -12688,6 +15414,20 @@ public sealed partial class TestExtensionOrderings2 : pb::IMessageContainer for nested types declared in the TestExtensionOrderings2 message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - public sealed partial class TestExtensionOrderings3 : pb::IMessage { + public sealed partial class TestExtensionOrderings3 : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestExtensionOrderings3()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -12831,6 +15594,20 @@ public sealed partial class TestExtensionOrderings3 : pb::IMessageContainer for extensions for other messages declared in the TestExtensionOrderings3 message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -12895,7 +15691,11 @@ public static partial class Extensions { } - public sealed partial class TestExtremeDefaultValues : pb::IMessage { + public sealed partial class TestExtremeDefaultValues : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestExtremeDefaultValues()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -13695,18 +16495,135 @@ public sealed partial class TestExtremeDefaultValues : pb::IMessage { + public sealed partial class SparseEnumMessage : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new SparseEnumMessage()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -14224,6 +17269,20 @@ public sealed partial class SparseEnumMessage : pb::IMessage } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasSparseEnum) { + output.WriteRawTag(8); + output.WriteEnum((int) SparseEnum); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -14263,12 +17322,35 @@ public sealed partial class SparseEnumMessage : pb::IMessage } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + SparseEnum = (global::Google.Protobuf.TestProtos.Proto2.TestSparseEnum) input.ReadEnum(); + break; + } + } + } + } + #endif + } /// /// Test String and Bytes: string is for valid UTF-8 strings /// - public sealed partial class OneString : pb::IMessage { + public sealed partial class OneString : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new OneString()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -14368,6 +17450,20 @@ public sealed partial class OneString : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasData) { + output.WriteRawTag(10); + output.WriteString(Data); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -14407,9 +17503,32 @@ public sealed partial class OneString : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + Data = input.ReadString(); + break; + } + } + } + } + #endif + } - public sealed partial class MoreString : pb::IMessage { + public sealed partial class MoreString : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MoreString()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -14493,6 +17612,17 @@ public sealed partial class MoreString : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + data_.WriteTo(ref output, _repeated_data_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -14528,9 +17658,32 @@ public sealed partial class MoreString : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + data_.AddEntriesFrom(ref input, _repeated_data_codec); + break; + } + } + } + } + #endif + } - public sealed partial class OneBytes : pb::IMessage { + public sealed partial class OneBytes : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new OneBytes()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -14630,6 +17783,20 @@ public sealed partial class OneBytes : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasData) { + output.WriteRawTag(10); + output.WriteBytes(Data); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -14669,9 +17836,32 @@ public sealed partial class OneBytes : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + Data = input.ReadBytes(); + break; + } + } + } + } + #endif + } - public sealed partial class MoreBytes : pb::IMessage { + public sealed partial class MoreBytes : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MoreBytes()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -14755,6 +17945,17 @@ public sealed partial class MoreBytes : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + data_.WriteTo(ref output, _repeated_data_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -14770,32 +17971,55 @@ public sealed partial class MoreBytes : pb::IMessage { if (other == null) { return; } - data_.Add(other.data_); - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + data_.Add(other.data_); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + data_.AddEntriesFrom(input, _repeated_data_codec); + break; + } + } + } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(pb::CodedInputStream input) { + public void MergeFrom(ref pb::CodedInputReader input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 10: { - data_.AddEntriesFrom(input, _repeated_data_codec); + data_.AddEntriesFrom(ref input, _repeated_data_codec); break; } } } } + #endif } /// /// Test int32, uint32, int64, uint64, and bool are all compatible /// - public sealed partial class Int32Message : pb::IMessage { + public sealed partial class Int32Message : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Int32Message()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -14898,6 +18122,20 @@ public sealed partial class Int32Message : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasData) { + output.WriteRawTag(8); + output.WriteInt32(Data); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -14937,9 +18175,32 @@ public sealed partial class Int32Message : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + Data = input.ReadInt32(); + break; + } + } + } + } + #endif + } - public sealed partial class Uint32Message : pb::IMessage { + public sealed partial class Uint32Message : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Uint32Message()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -15042,6 +18303,20 @@ public sealed partial class Uint32Message : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasData) { + output.WriteRawTag(8); + output.WriteUInt32(Data); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -15081,9 +18356,32 @@ public sealed partial class Uint32Message : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + Data = input.ReadUInt32(); + break; + } + } + } + } + #endif + } - public sealed partial class Int64Message : pb::IMessage { + public sealed partial class Int64Message : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Int64Message()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -15186,6 +18484,20 @@ public sealed partial class Int64Message : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasData) { + output.WriteRawTag(8); + output.WriteInt64(Data); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -15225,9 +18537,32 @@ public sealed partial class Int64Message : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + Data = input.ReadInt64(); + break; + } + } + } + } + #endif + } - public sealed partial class Uint64Message : pb::IMessage { + public sealed partial class Uint64Message : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Uint64Message()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -15330,6 +18665,20 @@ public sealed partial class Uint64Message : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasData) { + output.WriteRawTag(8); + output.WriteUInt64(Data); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -15369,9 +18718,32 @@ public sealed partial class Uint64Message : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + Data = input.ReadUInt64(); + break; + } + } + } + } + #endif + } - public sealed partial class BoolMessage : pb::IMessage { + public sealed partial class BoolMessage : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new BoolMessage()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -15474,6 +18846,20 @@ public sealed partial class BoolMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasData) { + output.WriteRawTag(8); + output.WriteBool(Data); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -15513,12 +18899,35 @@ public sealed partial class BoolMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + Data = input.ReadBool(); + break; + } + } + } + } + #endif + } /// /// Test oneofs. /// - public sealed partial class TestOneof : pb::IMessage { + public sealed partial class TestOneof : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestOneof()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -15745,6 +19154,33 @@ public enum FooOneofCase { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasFooInt) { + output.WriteRawTag(8); + output.WriteInt32(FooInt); + } + if (HasFooString) { + output.WriteRawTag(18); + output.WriteString(FooString); + } + if (HasFooMessage) { + output.WriteRawTag(26); + output.WriteMessage(FooMessage); + } + if (HasFooGroup) { + output.WriteRawTag(35); + output.WriteGroup(FooGroup); + output.WriteRawTag(36); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -15833,11 +19269,56 @@ public enum FooOneofCase { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + FooInt = input.ReadInt32(); + break; + } + case 18: { + FooString = input.ReadString(); + break; + } + case 26: { + global::Google.Protobuf.TestProtos.Proto2.TestAllTypes subBuilder = new global::Google.Protobuf.TestProtos.Proto2.TestAllTypes(); + if (HasFooMessage) { + subBuilder.MergeFrom(FooMessage); + } + input.ReadMessage(subBuilder); + FooMessage = subBuilder; + break; + } + case 35: { + global::Google.Protobuf.TestProtos.Proto2.TestOneof.Types.FooGroup subBuilder = new global::Google.Protobuf.TestProtos.Proto2.TestOneof.Types.FooGroup(); + if (HasFooGroup) { + subBuilder.MergeFrom(FooGroup); + } + input.ReadGroup(subBuilder); + FooGroup = subBuilder; + break; + } + } + } + } + #endif + #region Nested types /// Container for nested types declared in the TestOneof message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - public sealed partial class FooGroup : pb::IMessage { + public sealed partial class FooGroup : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FooGroup()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -15970,6 +19451,24 @@ public sealed partial class FooGroup : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasA) { + output.WriteRawTag(40); + output.WriteInt32(A); + } + if (HasB) { + output.WriteRawTag(50); + output.WriteString(B); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -16021,6 +19520,31 @@ public sealed partial class FooGroup : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + case 36: + return; + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 40: { + A = input.ReadInt32(); + break; + } + case 50: { + B = input.ReadString(); + break; + } + } + } + } + #endif + } } @@ -16028,7 +19552,11 @@ public sealed partial class FooGroup : pb::IMessage { } - public sealed partial class TestOneofBackwardsCompatible : pb::IMessage { + public sealed partial class TestOneofBackwardsCompatible : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestOneofBackwardsCompatible()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -16186,16 +19714,42 @@ public sealed partial class TestOneofBackwardsCompatible : pb::IMessageContainer for nested types declared in the TestOneofBackwardsCompatible message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - public sealed partial class FooGroup : pb::IMessage { + public sealed partial class FooGroup : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FooGroup()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -16436,6 +20032,24 @@ public sealed partial class FooGroup : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasA) { + output.WriteRawTag(40); + output.WriteInt32(A); + } + if (HasB) { + output.WriteRawTag(50); + output.WriteString(B); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -16487,6 +20101,31 @@ public sealed partial class FooGroup : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + case 36: + return; + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 40: { + A = input.ReadInt32(); + break; + } + case 50: { + B = input.ReadString(); + break; + } + } + } + } + #endif + } } @@ -16494,7 +20133,11 @@ public sealed partial class FooGroup : pb::IMessage { } - public sealed partial class TestOneof2 : pb::IMessage { + public sealed partial class TestOneof2 : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestOneof2()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -17167,6 +20810,85 @@ public enum BarOneofCase { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasFooInt) { + output.WriteRawTag(8); + output.WriteInt32(FooInt); + } + if (HasFooString) { + output.WriteRawTag(18); + output.WriteString(FooString); + } + if (HasFooCord) { + output.WriteRawTag(26); + output.WriteString(FooCord); + } + if (HasFooStringPiece) { + output.WriteRawTag(34); + output.WriteString(FooStringPiece); + } + if (HasFooBytes) { + output.WriteRawTag(42); + output.WriteBytes(FooBytes); + } + if (HasFooEnum) { + output.WriteRawTag(48); + output.WriteEnum((int) FooEnum); + } + if (HasFooMessage) { + output.WriteRawTag(58); + output.WriteMessage(FooMessage); + } + if (HasFooGroup) { + output.WriteRawTag(67); + output.WriteGroup(FooGroup); + output.WriteRawTag(68); + } + if (HasFooLazyMessage) { + output.WriteRawTag(90); + output.WriteMessage(FooLazyMessage); + } + if (HasBarInt) { + output.WriteRawTag(96); + output.WriteInt32(BarInt); + } + if (HasBarString) { + output.WriteRawTag(106); + output.WriteString(BarString); + } + if (HasBarCord) { + output.WriteRawTag(114); + output.WriteString(BarCord); + } + if (HasBarStringPiece) { + output.WriteRawTag(122); + output.WriteString(BarStringPiece); + } + if (HasBarBytes) { + output.WriteRawTag(130, 1); + output.WriteBytes(BarBytes); + } + if (HasBarEnum) { + output.WriteRawTag(136, 1); + output.WriteEnum((int) BarEnum); + } + if (HasBazInt) { + output.WriteRawTag(144, 1); + output.WriteInt32(BazInt); + } + if (HasBazString) { + output.WriteRawTag(154, 1); + output.WriteString(BazString); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -17261,53 +20983,152 @@ public enum BarOneofCase { if (FooMessage == null) { FooMessage = new global::Google.Protobuf.TestProtos.Proto2.TestOneof2.Types.NestedMessage(); } - FooMessage.MergeFrom(other.FooMessage); - break; - case FooOneofCase.FooGroup: - if (FooGroup == null) { - FooGroup = new global::Google.Protobuf.TestProtos.Proto2.TestOneof2.Types.FooGroup(); + FooMessage.MergeFrom(other.FooMessage); + break; + case FooOneofCase.FooGroup: + if (FooGroup == null) { + FooGroup = new global::Google.Protobuf.TestProtos.Proto2.TestOneof2.Types.FooGroup(); + } + FooGroup.MergeFrom(other.FooGroup); + break; + case FooOneofCase.FooLazyMessage: + if (FooLazyMessage == null) { + FooLazyMessage = new global::Google.Protobuf.TestProtos.Proto2.TestOneof2.Types.NestedMessage(); + } + FooLazyMessage.MergeFrom(other.FooLazyMessage); + break; + } + + switch (other.BarCase) { + case BarOneofCase.BarInt: + BarInt = other.BarInt; + break; + case BarOneofCase.BarString: + BarString = other.BarString; + break; + case BarOneofCase.BarCord: + BarCord = other.BarCord; + break; + case BarOneofCase.BarStringPiece: + BarStringPiece = other.BarStringPiece; + break; + case BarOneofCase.BarBytes: + BarBytes = other.BarBytes; + break; + case BarOneofCase.BarEnum: + BarEnum = other.BarEnum; + break; + } + + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + FooInt = input.ReadInt32(); + break; + } + case 18: { + FooString = input.ReadString(); + break; + } + case 26: { + FooCord = input.ReadString(); + break; + } + case 34: { + FooStringPiece = input.ReadString(); + break; + } + case 42: { + FooBytes = input.ReadBytes(); + break; + } + case 48: { + foo_ = input.ReadEnum(); + fooCase_ = FooOneofCase.FooEnum; + break; + } + case 58: { + global::Google.Protobuf.TestProtos.Proto2.TestOneof2.Types.NestedMessage subBuilder = new global::Google.Protobuf.TestProtos.Proto2.TestOneof2.Types.NestedMessage(); + if (HasFooMessage) { + subBuilder.MergeFrom(FooMessage); + } + input.ReadMessage(subBuilder); + FooMessage = subBuilder; + break; + } + case 67: { + global::Google.Protobuf.TestProtos.Proto2.TestOneof2.Types.FooGroup subBuilder = new global::Google.Protobuf.TestProtos.Proto2.TestOneof2.Types.FooGroup(); + if (HasFooGroup) { + subBuilder.MergeFrom(FooGroup); + } + input.ReadGroup(subBuilder); + FooGroup = subBuilder; + break; + } + case 90: { + global::Google.Protobuf.TestProtos.Proto2.TestOneof2.Types.NestedMessage subBuilder = new global::Google.Protobuf.TestProtos.Proto2.TestOneof2.Types.NestedMessage(); + if (HasFooLazyMessage) { + subBuilder.MergeFrom(FooLazyMessage); + } + input.ReadMessage(subBuilder); + FooLazyMessage = subBuilder; + break; + } + case 96: { + BarInt = input.ReadInt32(); + break; + } + case 106: { + BarString = input.ReadString(); + break; + } + case 114: { + BarCord = input.ReadString(); + break; } - FooGroup.MergeFrom(other.FooGroup); - break; - case FooOneofCase.FooLazyMessage: - if (FooLazyMessage == null) { - FooLazyMessage = new global::Google.Protobuf.TestProtos.Proto2.TestOneof2.Types.NestedMessage(); + case 122: { + BarStringPiece = input.ReadString(); + break; } - FooLazyMessage.MergeFrom(other.FooLazyMessage); - break; - } - - switch (other.BarCase) { - case BarOneofCase.BarInt: - BarInt = other.BarInt; - break; - case BarOneofCase.BarString: - BarString = other.BarString; - break; - case BarOneofCase.BarCord: - BarCord = other.BarCord; - break; - case BarOneofCase.BarStringPiece: - BarStringPiece = other.BarStringPiece; - break; - case BarOneofCase.BarBytes: - BarBytes = other.BarBytes; - break; - case BarOneofCase.BarEnum: - BarEnum = other.BarEnum; - break; + case 130: { + BarBytes = input.ReadBytes(); + break; + } + case 136: { + bar_ = input.ReadEnum(); + barCase_ = BarOneofCase.BarEnum; + break; + } + case 144: { + BazInt = input.ReadInt32(); + break; + } + case 154: { + BazString = input.ReadString(); + break; + } + } } - - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(pb::CodedInputStream input) { + public void MergeFrom(ref pb::CodedInputReader input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { FooInt = input.ReadInt32(); @@ -17397,6 +21218,7 @@ public enum BarOneofCase { } } } + #endif #region Nested types /// Container for nested types declared in the TestOneof2 message type. @@ -17408,7 +21230,11 @@ public enum NestedEnum { [pbr::OriginalName("BAZ")] Baz = 3, } - public sealed partial class FooGroup : pb::IMessage { + public sealed partial class FooGroup : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FooGroup()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -17541,6 +21367,24 @@ public sealed partial class FooGroup : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasA) { + output.WriteRawTag(72); + output.WriteInt32(A); + } + if (HasB) { + output.WriteRawTag(82); + output.WriteString(B); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -17592,9 +21436,38 @@ public sealed partial class FooGroup : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + case 68: + return; + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 72: { + A = input.ReadInt32(); + break; + } + case 82: { + B = input.ReadString(); + break; + } + } + } + } + #endif + } - public sealed partial class NestedMessage : pb::IMessage { + public sealed partial class NestedMessage : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedMessage()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -17711,6 +21584,21 @@ public sealed partial class NestedMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasQuxInt) { + output.WriteRawTag(8); + output.WriteInt64(QuxInt); + } + corgeInt_.WriteTo(ref output, _repeated_corgeInt_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -17757,6 +21645,30 @@ public sealed partial class NestedMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + QuxInt = input.ReadInt64(); + break; + } + case 18: + case 16: { + corgeInt_.AddEntriesFrom(ref input, _repeated_corgeInt_codec); + break; + } + } + } + } + #endif + } } @@ -17764,7 +21676,11 @@ public sealed partial class NestedMessage : pb::IMessage { } - public sealed partial class TestRequiredOneof : pb::IMessage { + public sealed partial class TestRequiredOneof : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestRequiredOneof()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -17957,6 +21873,28 @@ public enum FooOneofCase { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasFooInt) { + output.WriteRawTag(8); + output.WriteInt32(FooInt); + } + if (HasFooString) { + output.WriteRawTag(18); + output.WriteString(FooString); + } + if (HasFooMessage) { + output.WriteRawTag(26); + output.WriteMessage(FooMessage); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -18027,11 +21965,47 @@ public enum FooOneofCase { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + FooInt = input.ReadInt32(); + break; + } + case 18: { + FooString = input.ReadString(); + break; + } + case 26: { + global::Google.Protobuf.TestProtos.Proto2.TestRequiredOneof.Types.NestedMessage subBuilder = new global::Google.Protobuf.TestProtos.Proto2.TestRequiredOneof.Types.NestedMessage(); + if (HasFooMessage) { + subBuilder.MergeFrom(FooMessage); + } + input.ReadMessage(subBuilder); + FooMessage = subBuilder; + break; + } + } + } + } + #endif + #region Nested types /// Container for nested types declared in the TestRequiredOneof message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - public sealed partial class NestedMessage : pb::IMessage { + public sealed partial class NestedMessage : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedMessage()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -18134,6 +22108,20 @@ public sealed partial class NestedMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasRequiredDouble) { + output.WriteRawTag(9); + output.WriteDouble(RequiredDouble); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -18173,6 +22161,25 @@ public sealed partial class NestedMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 9: { + RequiredDouble = input.ReadDouble(); + break; + } + } + } + } + #endif + } } @@ -18180,7 +22187,11 @@ public sealed partial class NestedMessage : pb::IMessage { } - public sealed partial class TestRequiredMap : pb::IMessage { + public sealed partial class TestRequiredMap : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestRequiredMap()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -18264,6 +22275,17 @@ public sealed partial class TestRequiredMap : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + foo_.WriteTo(ref output, _map_foo_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -18299,11 +22321,34 @@ public sealed partial class TestRequiredMap : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + foo_.AddEntriesFrom(ref input, _map_foo_codec); + break; + } + } + } + } + #endif + #region Nested types /// Container for nested types declared in the TestRequiredMap message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - public sealed partial class NestedMessage : pb::IMessage { + public sealed partial class NestedMessage : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedMessage()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -18406,6 +22451,20 @@ public sealed partial class NestedMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasRequiredInt32) { + output.WriteRawTag(8); + output.WriteInt32(RequiredInt32); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -18415,27 +22474,45 @@ public sealed partial class NestedMessage : pb::IMessage { if (_unknownFields != null) { size += _unknownFields.CalculateSize(); } - return size; + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(NestedMessage other) { + if (other == null) { + return; + } + if (other.HasRequiredInt32) { + RequiredInt32 = other.RequiredInt32; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + RequiredInt32 = input.ReadInt32(); + break; + } + } + } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(NestedMessage other) { - if (other == null) { - return; - } - if (other.HasRequiredInt32) { - RequiredInt32 = other.RequiredInt32; - } - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); - } + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(pb::CodedInputStream input) { + public void MergeFrom(ref pb::CodedInputReader input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { RequiredInt32 = input.ReadInt32(); @@ -18444,6 +22521,7 @@ public sealed partial class NestedMessage : pb::IMessage { } } } + #endif } @@ -18452,7 +22530,11 @@ public sealed partial class NestedMessage : pb::IMessage { } - public sealed partial class TestPackedTypes : pb::IMessage { + public sealed partial class TestPackedTypes : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestPackedTypes()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -18718,6 +22800,30 @@ public sealed partial class TestPackedTypes : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + packedInt32_.WriteTo(ref output, _repeated_packedInt32_codec); + packedInt64_.WriteTo(ref output, _repeated_packedInt64_codec); + packedUint32_.WriteTo(ref output, _repeated_packedUint32_codec); + packedUint64_.WriteTo(ref output, _repeated_packedUint64_codec); + packedSint32_.WriteTo(ref output, _repeated_packedSint32_codec); + packedSint64_.WriteTo(ref output, _repeated_packedSint64_codec); + packedFixed32_.WriteTo(ref output, _repeated_packedFixed32_codec); + packedFixed64_.WriteTo(ref output, _repeated_packedFixed64_codec); + packedSfixed32_.WriteTo(ref output, _repeated_packedSfixed32_codec); + packedSfixed64_.WriteTo(ref output, _repeated_packedSfixed64_codec); + packedFloat_.WriteTo(ref output, _repeated_packedFloat_codec); + packedDouble_.WriteTo(ref output, _repeated_packedDouble_codec); + packedBool_.WriteTo(ref output, _repeated_packedBool_codec); + packedEnum_.WriteTo(ref output, _repeated_packedEnum_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -18845,13 +22951,102 @@ public sealed partial class TestPackedTypes : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 722: + case 720: { + packedInt32_.AddEntriesFrom(ref input, _repeated_packedInt32_codec); + break; + } + case 730: + case 728: { + packedInt64_.AddEntriesFrom(ref input, _repeated_packedInt64_codec); + break; + } + case 738: + case 736: { + packedUint32_.AddEntriesFrom(ref input, _repeated_packedUint32_codec); + break; + } + case 746: + case 744: { + packedUint64_.AddEntriesFrom(ref input, _repeated_packedUint64_codec); + break; + } + case 754: + case 752: { + packedSint32_.AddEntriesFrom(ref input, _repeated_packedSint32_codec); + break; + } + case 762: + case 760: { + packedSint64_.AddEntriesFrom(ref input, _repeated_packedSint64_codec); + break; + } + case 770: + case 773: { + packedFixed32_.AddEntriesFrom(ref input, _repeated_packedFixed32_codec); + break; + } + case 778: + case 777: { + packedFixed64_.AddEntriesFrom(ref input, _repeated_packedFixed64_codec); + break; + } + case 786: + case 789: { + packedSfixed32_.AddEntriesFrom(ref input, _repeated_packedSfixed32_codec); + break; + } + case 794: + case 793: { + packedSfixed64_.AddEntriesFrom(ref input, _repeated_packedSfixed64_codec); + break; + } + case 802: + case 805: { + packedFloat_.AddEntriesFrom(ref input, _repeated_packedFloat_codec); + break; + } + case 810: + case 809: { + packedDouble_.AddEntriesFrom(ref input, _repeated_packedDouble_codec); + break; + } + case 818: + case 816: { + packedBool_.AddEntriesFrom(ref input, _repeated_packedBool_codec); + break; + } + case 826: + case 824: { + packedEnum_.AddEntriesFrom(ref input, _repeated_packedEnum_codec); + break; + } + } + } + } + #endif + } /// /// A message with the same fields as TestPackedTypes, but without packing. Used /// to test packed <-> unpacked wire compatibility. /// - public sealed partial class TestUnpackedTypes : pb::IMessage { + public sealed partial class TestUnpackedTypes : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestUnpackedTypes()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -19117,6 +23312,30 @@ public sealed partial class TestUnpackedTypes : pb::IMessage } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + unpackedInt32_.WriteTo(ref output, _repeated_unpackedInt32_codec); + unpackedInt64_.WriteTo(ref output, _repeated_unpackedInt64_codec); + unpackedUint32_.WriteTo(ref output, _repeated_unpackedUint32_codec); + unpackedUint64_.WriteTo(ref output, _repeated_unpackedUint64_codec); + unpackedSint32_.WriteTo(ref output, _repeated_unpackedSint32_codec); + unpackedSint64_.WriteTo(ref output, _repeated_unpackedSint64_codec); + unpackedFixed32_.WriteTo(ref output, _repeated_unpackedFixed32_codec); + unpackedFixed64_.WriteTo(ref output, _repeated_unpackedFixed64_codec); + unpackedSfixed32_.WriteTo(ref output, _repeated_unpackedSfixed32_codec); + unpackedSfixed64_.WriteTo(ref output, _repeated_unpackedSfixed64_codec); + unpackedFloat_.WriteTo(ref output, _repeated_unpackedFloat_codec); + unpackedDouble_.WriteTo(ref output, _repeated_unpackedDouble_codec); + unpackedBool_.WriteTo(ref output, _repeated_unpackedBool_codec); + unpackedEnum_.WriteTo(ref output, _repeated_unpackedEnum_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -19244,9 +23463,98 @@ public sealed partial class TestUnpackedTypes : pb::IMessage } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 722: + case 720: { + unpackedInt32_.AddEntriesFrom(ref input, _repeated_unpackedInt32_codec); + break; + } + case 730: + case 728: { + unpackedInt64_.AddEntriesFrom(ref input, _repeated_unpackedInt64_codec); + break; + } + case 738: + case 736: { + unpackedUint32_.AddEntriesFrom(ref input, _repeated_unpackedUint32_codec); + break; + } + case 746: + case 744: { + unpackedUint64_.AddEntriesFrom(ref input, _repeated_unpackedUint64_codec); + break; + } + case 754: + case 752: { + unpackedSint32_.AddEntriesFrom(ref input, _repeated_unpackedSint32_codec); + break; + } + case 762: + case 760: { + unpackedSint64_.AddEntriesFrom(ref input, _repeated_unpackedSint64_codec); + break; + } + case 770: + case 773: { + unpackedFixed32_.AddEntriesFrom(ref input, _repeated_unpackedFixed32_codec); + break; + } + case 778: + case 777: { + unpackedFixed64_.AddEntriesFrom(ref input, _repeated_unpackedFixed64_codec); + break; + } + case 786: + case 789: { + unpackedSfixed32_.AddEntriesFrom(ref input, _repeated_unpackedSfixed32_codec); + break; + } + case 794: + case 793: { + unpackedSfixed64_.AddEntriesFrom(ref input, _repeated_unpackedSfixed64_codec); + break; + } + case 802: + case 805: { + unpackedFloat_.AddEntriesFrom(ref input, _repeated_unpackedFloat_codec); + break; + } + case 810: + case 809: { + unpackedDouble_.AddEntriesFrom(ref input, _repeated_unpackedDouble_codec); + break; + } + case 818: + case 816: { + unpackedBool_.AddEntriesFrom(ref input, _repeated_unpackedBool_codec); + break; + } + case 826: + case 824: { + unpackedEnum_.AddEntriesFrom(ref input, _repeated_unpackedEnum_codec); + break; + } + } + } + } + #endif + } - public sealed partial class TestPackedExtensions : pb::IExtendableMessage { + public sealed partial class TestPackedExtensions : pb::IExtendableMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestPackedExtensions()); private pb::UnknownFieldSet _unknownFields; private pb::ExtensionSet _extensions; @@ -19328,6 +23636,19 @@ public sealed partial class TestPackedExtensions : pb::IExtendableMessage(pb::Extension extension) { return pb::ExtensionSet.Get(ref _extensions, extension); } @@ -19387,7 +23725,11 @@ public sealed partial class TestPackedExtensions : pb::IExtendableMessage { + public sealed partial class TestUnpackedExtensions : pb::IExtendableMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestUnpackedExtensions()); private pb::UnknownFieldSet _unknownFields; private pb::ExtensionSet _extensions; @@ -19469,6 +23811,19 @@ public sealed partial class TestUnpackedExtensions : pb::IExtendableMessage(pb::Extension extension) { return pb::ExtensionSet.Get(ref _extensions, extension); } @@ -19533,7 +23905,11 @@ public sealed partial class TestUnpackedExtensions : pb::IExtendableMessage - public sealed partial class TestDynamicExtensions : pb::IMessage { + public sealed partial class TestDynamicExtensions : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestDynamicExtensions()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -19782,6 +24158,38 @@ public sealed partial class TestDynamicExtensions : pb::IMessageContainer for nested types declared in the TestDynamicExtensions message type. @@ -19896,7 +24354,11 @@ public enum DynamicEnumType { [pbr::OriginalName("DYNAMIC_BAZ")] DynamicBaz = 2202, } - public sealed partial class DynamicMessageType : pb::IMessage { + public sealed partial class DynamicMessageType : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new DynamicMessageType()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -19999,6 +24461,20 @@ public sealed partial class DynamicMessageType : pb::IMessage { + public sealed partial class TestRepeatedScalarDifferentTagSizes : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestRepeatedScalarDifferentTagSizes()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -20213,6 +24712,22 @@ public sealed partial class TestRepeatedScalarDifferentTagSizes : pb::IMessage /// Test that if an optional or required message/group field appears multiple /// times in the input, they need to be merged. /// - public sealed partial class TestParsingMerge : pb::IExtendableMessage { + public sealed partial class TestParsingMerge : pb::IExtendableMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestParsingMerge()); private pb::UnknownFieldSet _unknownFields; private pb::ExtensionSet _extensions; @@ -20485,6 +25049,34 @@ public sealed partial class TestParsingMerge : pb::IExtendableMessage(pb::Extension extension) { return pb::ExtensionSet.Get(ref _extensions, extension); } @@ -20613,7 +25251,11 @@ public static partial class Types { /// Repeated fields in RepeatedFieldsGenerator are expected to be merged into /// the corresponding required/optional fields in TestParsingMerge. /// - public sealed partial class RepeatedFieldsGenerator : pb::IMessage { + public sealed partial class RepeatedFieldsGenerator : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new RepeatedFieldsGenerator()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -20781,6 +25423,23 @@ public sealed partial class RepeatedFieldsGenerator : pb::IMessageContainer for nested types declared in the RepeatedFieldsGenerator message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - public sealed partial class Group1 : pb::IMessage { + public sealed partial class Group1 : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Group1()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -20954,6 +25660,20 @@ public sealed partial class Group1 : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasField1) { + output.WriteRawTag(90); + output.WriteMessage(Field1); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -21001,9 +25721,37 @@ public sealed partial class Group1 : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + case 84: + return; + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 90: { + if (!HasField1) { + Field1 = new global::Google.Protobuf.TestProtos.Proto2.TestAllTypes(); + } + input.ReadMessage(Field1); + break; + } + } + } + } + #endif + } - public sealed partial class Group2 : pb::IMessage { + public sealed partial class Group2 : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Group2()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -21101,6 +25849,20 @@ public sealed partial class Group2 : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasField1) { + output.WriteRawTag(170, 1); + output.WriteMessage(Field1); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -21124,18 +25886,41 @@ public sealed partial class Group2 : pb::IMessage { } Field1.MergeFrom(other.Field1); } - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + case 164: + return; + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 170: { + if (!HasField1) { + Field1 = new global::Google.Protobuf.TestProtos.Proto2.TestAllTypes(); + } + input.ReadMessage(Field1); + break; + } + } + } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(pb::CodedInputStream input) { + public void MergeFrom(ref pb::CodedInputReader input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { case 164: return; default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 170: { if (!HasField1) { @@ -21147,6 +25932,7 @@ public sealed partial class Group2 : pb::IMessage { } } } + #endif } @@ -21155,7 +25941,11 @@ public sealed partial class Group2 : pb::IMessage { } - public sealed partial class OptionalGroup : pb::IMessage { + public sealed partial class OptionalGroup : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new OptionalGroup()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -21253,6 +26043,20 @@ public sealed partial class OptionalGroup : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasOptionalGroupAllTypes) { + output.WriteRawTag(90); + output.WriteMessage(OptionalGroupAllTypes); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -21300,9 +26104,37 @@ public sealed partial class OptionalGroup : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + case 84: + return; + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 90: { + if (!HasOptionalGroupAllTypes) { + OptionalGroupAllTypes = new global::Google.Protobuf.TestProtos.Proto2.TestAllTypes(); + } + input.ReadMessage(OptionalGroupAllTypes); + break; + } + } + } + } + #endif + } - public sealed partial class RepeatedGroup : pb::IMessage { + public sealed partial class RepeatedGroup : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new RepeatedGroup()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -21400,6 +26232,20 @@ public sealed partial class RepeatedGroup : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasRepeatedGroupAllTypes) { + output.WriteRawTag(170, 1); + output.WriteMessage(RepeatedGroupAllTypes); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -21447,6 +26293,30 @@ public sealed partial class RepeatedGroup : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + case 164: + return; + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 170: { + if (!HasRepeatedGroupAllTypes) { + RepeatedGroupAllTypes = new global::Google.Protobuf.TestProtos.Proto2.TestAllTypes(); + } + input.ReadMessage(RepeatedGroupAllTypes); + break; + } + } + } + } + #endif + } } @@ -21465,7 +26335,11 @@ public static partial class Extensions { } - public sealed partial class TestCommentInjectionMessage : pb::IMessage { + public sealed partial class TestCommentInjectionMessage : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestCommentInjectionMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -21568,6 +26442,20 @@ public sealed partial class TestCommentInjectionMessage : pb::IMessage /// Test that RPC services work. /// - public sealed partial class FooRequest : pb::IMessage { + public sealed partial class FooRequest : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FooRequest()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -21682,6 +26593,16 @@ public sealed partial class FooRequest : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -21711,9 +26632,28 @@ public sealed partial class FooRequest : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + } + } + } + #endif + } - public sealed partial class FooResponse : pb::IMessage { + public sealed partial class FooResponse : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FooResponse()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -21783,6 +26723,16 @@ public sealed partial class FooResponse : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -21812,9 +26762,28 @@ public sealed partial class FooResponse : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + } + } + } + #endif + } - public sealed partial class FooClientMessage : pb::IMessage { + public sealed partial class FooClientMessage : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FooClientMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -21884,6 +26853,16 @@ public sealed partial class FooClientMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -21913,9 +26892,28 @@ public sealed partial class FooClientMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + } + } + } + #endif + } - public sealed partial class FooServerMessage : pb::IMessage { + public sealed partial class FooServerMessage : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FooServerMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -21985,6 +26983,16 @@ public sealed partial class FooServerMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -22014,9 +27022,28 @@ public sealed partial class FooServerMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + } + } + } + #endif + } - public sealed partial class BarRequest : pb::IMessage { + public sealed partial class BarRequest : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new BarRequest()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -22086,6 +27113,16 @@ public sealed partial class BarRequest : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -22115,9 +27152,28 @@ public sealed partial class BarRequest : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + } + } + } + #endif + } - public sealed partial class BarResponse : pb::IMessage { + public sealed partial class BarResponse : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new BarResponse()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -22187,6 +27243,16 @@ public sealed partial class BarResponse : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -22216,9 +27282,28 @@ public sealed partial class BarResponse : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + } + } + } + #endif + } - public sealed partial class TestJsonName : pb::IMessage { + public sealed partial class TestJsonName : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestJsonName()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -22476,6 +27561,40 @@ public sealed partial class TestJsonName : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasFieldName1) { + output.WriteRawTag(8); + output.WriteInt32(FieldName1); + } + if (HasFieldName2) { + output.WriteRawTag(16); + output.WriteInt32(FieldName2); + } + if (HasFieldName3) { + output.WriteRawTag(24); + output.WriteInt32(FieldName3); + } + if (HasFieldName4) { + output.WriteRawTag(32); + output.WriteInt32(FieldName4); + } + if (HasFIELDNAME5) { + output.WriteRawTag(40); + output.WriteInt32(FIELDNAME5); + } + if (HasFieldName6) { + output.WriteRawTag(48); + output.WriteInt32(FieldName6); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -22526,16 +27645,54 @@ public sealed partial class TestJsonName : pb::IMessage { if (other.HasFieldName6) { FieldName6 = other.FieldName6; } - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + FieldName1 = input.ReadInt32(); + break; + } + case 16: { + FieldName2 = input.ReadInt32(); + break; + } + case 24: { + FieldName3 = input.ReadInt32(); + break; + } + case 32: { + FieldName4 = input.ReadInt32(); + break; + } + case 40: { + FIELDNAME5 = input.ReadInt32(); + break; + } + case 48: { + FieldName6 = input.ReadInt32(); + break; + } + } + } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(pb::CodedInputStream input) { + public void MergeFrom(ref pb::CodedInputReader input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { FieldName1 = input.ReadInt32(); @@ -22564,10 +27721,15 @@ public sealed partial class TestJsonName : pb::IMessage { } } } + #endif } - public sealed partial class TestHugeFieldNumbers : pb::IExtendableMessage { + public sealed partial class TestHugeFieldNumbers : pb::IExtendableMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestHugeFieldNumbers()); private pb::UnknownFieldSet _unknownFields; private pb::ExtensionSet _extensions; @@ -23057,6 +28219,67 @@ public enum OneofFieldOneofCase { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasOptionalInt32) { + output.WriteRawTag(128, 199, 255, 255, 15); + output.WriteInt32(OptionalInt32); + } + if (HasFixed32) { + output.WriteRawTag(136, 199, 255, 255, 15); + output.WriteInt32(Fixed32); + } + repeatedInt32_.WriteTo(ref output, _repeated_repeatedInt32_codec); + packedInt32_.WriteTo(ref output, _repeated_packedInt32_codec); + if (HasOptionalEnum) { + output.WriteRawTag(160, 199, 255, 255, 15); + output.WriteEnum((int) OptionalEnum); + } + if (HasOptionalString) { + output.WriteRawTag(170, 199, 255, 255, 15); + output.WriteString(OptionalString); + } + if (HasOptionalBytes) { + output.WriteRawTag(178, 199, 255, 255, 15); + output.WriteBytes(OptionalBytes); + } + if (HasOptionalMessage) { + output.WriteRawTag(186, 199, 255, 255, 15); + output.WriteMessage(OptionalMessage); + } + if (HasOptionalGroup) { + output.WriteRawTag(195, 199, 255, 255, 15); + output.WriteGroup(OptionalGroup); + output.WriteRawTag(196, 199, 255, 255, 15); + } + stringStringMap_.WriteTo(ref output, _map_stringStringMap_codec); + if (HasOneofUint32) { + output.WriteRawTag(216, 199, 255, 255, 15); + output.WriteUInt32(OneofUint32); + } + if (HasOneofTestAllTypes) { + output.WriteRawTag(226, 199, 255, 255, 15); + output.WriteMessage(OneofTestAllTypes); + } + if (HasOneofString) { + output.WriteRawTag(234, 199, 255, 255, 15); + output.WriteString(OneofString); + } + if (HasOneofBytes) { + output.WriteRawTag(242, 199, 255, 255, 15); + output.WriteBytes(OneofBytes); + } + if (_extensions != null) { + _extensions.WriteTo(ref output); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -23245,6 +28468,92 @@ public enum OneofFieldOneofCase { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, ref input)) { + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + } + break; + case 4294960000: { + OptionalInt32 = input.ReadInt32(); + break; + } + case 4294960008: { + Fixed32 = input.ReadInt32(); + break; + } + case 4294960018: + case 4294960016: { + repeatedInt32_.AddEntriesFrom(ref input, _repeated_repeatedInt32_codec); + break; + } + case 4294960026: + case 4294960024: { + packedInt32_.AddEntriesFrom(ref input, _repeated_packedInt32_codec); + break; + } + case 4294960032: { + OptionalEnum = (global::Google.Protobuf.TestProtos.Proto2.ForeignEnum) input.ReadEnum(); + break; + } + case 4294960042: { + OptionalString = input.ReadString(); + break; + } + case 4294960050: { + OptionalBytes = input.ReadBytes(); + break; + } + case 4294960058: { + if (!HasOptionalMessage) { + OptionalMessage = new global::Google.Protobuf.TestProtos.Proto2.ForeignMessage(); + } + input.ReadMessage(OptionalMessage); + break; + } + case 4294960067: { + if (!HasOptionalGroup) { + OptionalGroup = new global::Google.Protobuf.TestProtos.Proto2.TestHugeFieldNumbers.Types.OptionalGroup(); + } + input.ReadGroup(OptionalGroup); + break; + } + case 4294960082: { + stringStringMap_.AddEntriesFrom(ref input, _map_stringStringMap_codec); + break; + } + case 4294960088: { + OneofUint32 = input.ReadUInt32(); + break; + } + case 4294960098: { + global::Google.Protobuf.TestProtos.Proto2.TestAllTypes subBuilder = new global::Google.Protobuf.TestProtos.Proto2.TestAllTypes(); + if (HasOneofTestAllTypes) { + subBuilder.MergeFrom(OneofTestAllTypes); + } + input.ReadMessage(subBuilder); + OneofTestAllTypes = subBuilder; + break; + } + case 4294960106: { + OneofString = input.ReadString(); + break; + } + case 4294960114: { + OneofBytes = input.ReadBytes(); + break; + } + } + } + } + #endif + public TValue GetExtension(pb::Extension extension) { return pb::ExtensionSet.Get(ref _extensions, extension); } @@ -23271,7 +28580,11 @@ public enum OneofFieldOneofCase { /// Container for nested types declared in the TestHugeFieldNumbers message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - public sealed partial class OptionalGroup : pb::IMessage { + public sealed partial class OptionalGroup : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new OptionalGroup()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -23374,6 +28687,20 @@ public sealed partial class OptionalGroup : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasGroupA) { + output.WriteRawTag(200, 199, 255, 255, 15); + output.WriteInt32(GroupA); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -23415,6 +28742,27 @@ public sealed partial class OptionalGroup : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + case 4294960068: + return; + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 4294960072: { + GroupA = input.ReadInt32(); + break; + } + } + } + } + #endif + } } @@ -23422,7 +28770,11 @@ public sealed partial class OptionalGroup : pb::IMessage { } - public sealed partial class TestExtensionInsideTable : pb::IExtendableMessage { + public sealed partial class TestExtensionInsideTable : pb::IExtendableMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestExtensionInsideTable()); private pb::UnknownFieldSet _unknownFields; private pb::ExtensionSet _extensions; @@ -23785,6 +29137,55 @@ public sealed partial class TestExtensionInsideTable : pb::IExtendableMessage(pb::Extension extension) { return pb::ExtensionSet.Get(ref _extensions, extension); } diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestCustomOptionsProto3.cs b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestCustomOptionsProto3.cs index cb5edf75472d..3b48aa8b6574 100644 --- a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestCustomOptionsProto3.cs +++ b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestCustomOptionsProto3.cs @@ -257,7 +257,11 @@ public enum AggregateEnum { /// A test message with custom options at all possible locations (and also some /// regular options, to make sure they interact nicely). /// - public sealed partial class TestMessageWithCustomOptions : pb::IMessage { + public sealed partial class TestMessageWithCustomOptions : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestMessageWithCustomOptions()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -388,6 +392,24 @@ public enum AnOneofOneofCase { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (Field1.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Field1); + } + if (anOneofCase_ == AnOneofOneofCase.OneofField) { + output.WriteRawTag(16); + output.WriteInt32(OneofField); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -440,6 +462,29 @@ public enum AnOneofOneofCase { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + Field1 = input.ReadString(); + break; + } + case 16: { + OneofField = input.ReadInt32(); + break; + } + } + } + } + #endif + #region Nested types /// Container for nested types declared in the TestMessageWithCustomOptions message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -459,7 +504,11 @@ public enum AnEnum { /// A test RPC service with custom options at all possible locations (and also /// some regular options, to make sure they interact nicely). /// - public sealed partial class CustomOptionFooRequest : pb::IMessage { + public sealed partial class CustomOptionFooRequest : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new CustomOptionFooRequest()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -529,6 +578,16 @@ public sealed partial class CustomOptionFooRequest : pb::IMessage { + public sealed partial class CustomOptionFooResponse : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new CustomOptionFooResponse()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -630,6 +708,16 @@ public sealed partial class CustomOptionFooResponse : pb::IMessage { + public sealed partial class CustomOptionFooClientMessage : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new CustomOptionFooClientMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -731,6 +838,16 @@ public sealed partial class CustomOptionFooClientMessage : pb::IMessage { + public sealed partial class CustomOptionFooServerMessage : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new CustomOptionFooServerMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -832,6 +968,16 @@ public sealed partial class CustomOptionFooServerMessage : pb::IMessage { + public sealed partial class DummyMessageContainingEnum : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new DummyMessageContainingEnum()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -933,6 +1098,16 @@ public sealed partial class DummyMessageContainingEnum : pb::IMessageContainer for nested types declared in the DummyMessageContainingEnum message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -977,7 +1167,11 @@ public enum TestEnumType { } - public sealed partial class DummyMessageInvalidAsOptionType : pb::IMessage { + public sealed partial class DummyMessageInvalidAsOptionType : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new DummyMessageInvalidAsOptionType()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1047,6 +1241,16 @@ public sealed partial class DummyMessageInvalidAsOptionType : pb::IMessage { + public sealed partial class CustomOptionMinIntegerValues : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new CustomOptionMinIntegerValues()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1148,6 +1371,16 @@ public sealed partial class CustomOptionMinIntegerValues : pb::IMessage { + public sealed partial class CustomOptionMaxIntegerValues : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new CustomOptionMaxIntegerValues()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1249,6 +1501,16 @@ public sealed partial class CustomOptionMaxIntegerValues : pb::IMessage { + public sealed partial class CustomOptionOtherValues : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new CustomOptionOtherValues()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1350,6 +1631,16 @@ public sealed partial class CustomOptionOtherValues : pb::IMessage { + public sealed partial class SettingRealsFromPositiveInts : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new SettingRealsFromPositiveInts()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1451,6 +1761,16 @@ public sealed partial class SettingRealsFromPositiveInts : pb::IMessage { + public sealed partial class SettingRealsFromNegativeInts : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new SettingRealsFromNegativeInts()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1552,6 +1891,16 @@ public sealed partial class SettingRealsFromNegativeInts : pb::IMessage { + public sealed partial class ComplexOptionType1 : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ComplexOptionType1()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1721,6 +2089,29 @@ public sealed partial class ComplexOptionType1 : pb::IMessage { + public sealed partial class ComplexOptionType2 : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ComplexOptionType2()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1927,6 +2354,29 @@ public sealed partial class ComplexOptionType2 : pb::IMessageContainer for nested types declared in the ComplexOptionType2 message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - public sealed partial class ComplexOptionType4 : pb::IMessage { + public sealed partial class ComplexOptionType4 : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ComplexOptionType4()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -2096,6 +2587,20 @@ public sealed partial class ComplexOptionType4 : pb::IMessageContainer for extensions for other messages declared in the ComplexOptionType4 message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -2151,7 +2675,11 @@ public static partial class Extensions { } - public sealed partial class ComplexOptionType3 : pb::IMessage { + public sealed partial class ComplexOptionType3 : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ComplexOptionType3()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -2239,6 +2767,20 @@ public sealed partial class ComplexOptionType3 : pb::IMessage /// Note that we try various different ways of naming the same extension. /// - public sealed partial class VariousComplexOptions : pb::IMessage { + public sealed partial class VariousComplexOptions : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new VariousComplexOptions()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -2353,6 +2918,16 @@ public sealed partial class VariousComplexOptions : pb::IMessage /// A helper type used to test aggregate option parsing /// - public sealed partial class Aggregate : pb::IMessage { + public sealed partial class Aggregate : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Aggregate()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -2514,6 +3108,28 @@ public sealed partial class Aggregate : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (I != 0) { + output.WriteRawTag(8); + output.WriteInt32(I); + } + if (S.Length != 0) { + output.WriteRawTag(18); + output.WriteString(S); + } + if (sub_ != null) { + output.WriteRawTag(26); + output.WriteMessage(Sub); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -2579,9 +3195,43 @@ public sealed partial class Aggregate : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + I = input.ReadInt32(); + break; + } + case 18: { + S = input.ReadString(); + break; + } + case 26: { + if (sub_ == null) { + Sub = new global::UnitTest.Issues.TestProtos.Aggregate(); + } + input.ReadMessage(Sub); + break; + } + } + } + } + #endif + } - public sealed partial class AggregateMessage : pb::IMessage { + public sealed partial class AggregateMessage : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new AggregateMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -2669,6 +3319,20 @@ public sealed partial class AggregateMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (Fieldname != 0) { + output.WriteRawTag(8); + output.WriteInt32(Fieldname); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -2708,12 +3372,35 @@ public sealed partial class AggregateMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + Fieldname = input.ReadInt32(); + break; + } + } + } + } + #endif + } /// /// Test custom options for nested type. /// - public sealed partial class NestedOptionType : pb::IMessage { + public sealed partial class NestedOptionType : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedOptionType()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -2783,6 +3470,16 @@ public sealed partial class NestedOptionType : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -2812,6 +3509,21 @@ public sealed partial class NestedOptionType : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + } + } + } + #endif + #region Nested types /// Container for nested types declared in the NestedOptionType message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -2821,7 +3533,11 @@ public enum NestedEnum { [pbr::OriginalName("NESTED_ENUM_VALUE")] Value = 1, } - public sealed partial class NestedMessage : pb::IMessage { + public sealed partial class NestedMessage : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -2909,6 +3625,20 @@ public sealed partial class NestedMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (NestedField != 0) { + output.WriteRawTag(8); + output.WriteInt32(NestedField); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -2948,6 +3678,25 @@ public sealed partial class NestedMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + NestedField = input.ReadInt32(); + break; + } + } + } + } + #endif + } } diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestImport.cs b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestImport.cs index d5f8589315e3..86e406127a32 100644 --- a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestImport.cs +++ b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestImport.cs @@ -59,7 +59,11 @@ public enum ImportEnumForMap { #endregion #region Messages - public sealed partial class ImportMessage : pb::IMessage { + public sealed partial class ImportMessage : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ImportMessage()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -162,6 +166,20 @@ public sealed partial class ImportMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasD) { + output.WriteRawTag(8); + output.WriteInt32(D); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -201,6 +219,25 @@ public sealed partial class ImportMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + D = input.ReadInt32(); + break; + } + } + } + } + #endif + } #endregion diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestImportProto3.cs b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestImportProto3.cs index 19a1a34634f9..778984ad40b5 100644 --- a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestImportProto3.cs +++ b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestImportProto3.cs @@ -50,7 +50,11 @@ public enum ImportEnum { #endregion #region Messages - public sealed partial class ImportMessage : pb::IMessage { + public sealed partial class ImportMessage : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ImportMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -138,6 +142,20 @@ public sealed partial class ImportMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (D != 0) { + output.WriteRawTag(8); + output.WriteInt32(D); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -177,6 +195,25 @@ public sealed partial class ImportMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + D = input.ReadInt32(); + break; + } + } + } + } + #endif + } #endregion diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestImportPublic.cs b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestImportPublic.cs index 77f212176035..5d67d9a04a25 100644 --- a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestImportPublic.cs +++ b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestImportPublic.cs @@ -37,7 +37,11 @@ public static partial class UnittestImportPublicReflection { } #region Messages - public sealed partial class PublicImportMessage : pb::IMessage { + public sealed partial class PublicImportMessage : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new PublicImportMessage()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -140,6 +144,20 @@ public sealed partial class PublicImportMessage : pb::IMessage { + public sealed partial class PublicImportMessage : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new PublicImportMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -126,6 +130,20 @@ public sealed partial class PublicImportMessage : pb::IMessage { + public sealed partial class Foo : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Foo()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -107,6 +111,16 @@ public sealed partial class Foo : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -136,6 +150,21 @@ public sealed partial class Foo : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + } + } + } + #endif + } #endregion diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssue6936C.cs b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssue6936C.cs index a8a73f6cb6ec..947857f58d4a 100644 --- a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssue6936C.cs +++ b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssue6936C.cs @@ -39,7 +39,11 @@ public static partial class UnittestIssue6936CReflection { } #region Messages - public sealed partial class Bar : pb::IMessage { + public sealed partial class Bar : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Bar()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -127,6 +131,20 @@ public sealed partial class Bar : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (foo_ != null) { + output.WriteRawTag(10); + output.WriteMessage(Foo); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -172,6 +190,28 @@ public sealed partial class Bar : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + if (foo_ == null) { + Foo = new global::UnitTest.Issues.TestProtos.Foo(); + } + input.ReadMessage(Foo); + break; + } + } + } + } + #endif + } #endregion diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssues.cs b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssues.cs index f3f40c6a70cf..cea81be2fe7d 100644 --- a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssues.cs +++ b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssues.cs @@ -88,7 +88,11 @@ public enum DeprecatedEnum { /// Issue 307: when generating doubly-nested types, any references /// should be of the form A.Types.B.Types.C. /// - public sealed partial class Issue307 : pb::IMessage { + public sealed partial class Issue307 : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Issue307()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -158,6 +162,16 @@ public sealed partial class Issue307 : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -187,11 +201,30 @@ public sealed partial class Issue307 : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + } + } + } + #endif + #region Nested types /// Container for nested types declared in the Issue307 message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - public sealed partial class NestedOnce : pb::IMessage { + public sealed partial class NestedOnce : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedOnce()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -261,6 +294,16 @@ public sealed partial class NestedOnce : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -290,11 +333,30 @@ public sealed partial class NestedOnce : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + } + } + } + #endif + #region Nested types /// Container for nested types declared in the NestedOnce message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - public sealed partial class NestedTwice : pb::IMessage { + public sealed partial class NestedTwice : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedTwice()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -364,6 +426,16 @@ public sealed partial class NestedTwice : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -393,6 +465,21 @@ public sealed partial class NestedTwice : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + } + } + } + #endif + } } @@ -405,7 +492,11 @@ public sealed partial class NestedTwice : pb::IMessage { } - public sealed partial class NegativeEnumMessage : pb::IMessage { + public sealed partial class NegativeEnumMessage : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NegativeEnumMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -521,6 +612,22 @@ public sealed partial class NegativeEnumMessage : pb::IMessage { + public sealed partial class DeprecatedChild : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new DeprecatedChild()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -646,6 +786,16 @@ public sealed partial class DeprecatedChild : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -675,9 +825,28 @@ public sealed partial class DeprecatedChild : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + } + } + } + #endif + } - public sealed partial class DeprecatedFieldsMessage : pb::IMessage { + public sealed partial class DeprecatedFieldsMessage : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new DeprecatedFieldsMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -849,6 +1018,31 @@ public sealed partial class DeprecatedFieldsMessage : pb::IMessage /// Issue 45: http://code.google.com/p/protobuf-csharp-port/issues/detail?id=45 /// - public sealed partial class ItemField : pb::IMessage { + public sealed partial class ItemField : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ItemField()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1027,6 +1269,20 @@ public sealed partial class ItemField : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (Item != 0) { + output.WriteRawTag(8); + output.WriteInt32(Item); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -1066,9 +1322,32 @@ public sealed partial class ItemField : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + Item = input.ReadInt32(); + break; + } + } + } + } + #endif + } - public sealed partial class ReservedNames : pb::IMessage { + public sealed partial class ReservedNames : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ReservedNames()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1174,6 +1453,24 @@ public sealed partial class ReservedNames : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (Types_ != 0) { + output.WriteRawTag(8); + output.WriteInt32(Types_); + } + if (Descriptor_ != 0) { + output.WriteRawTag(16); + output.WriteInt32(Descriptor_); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -1223,6 +1520,29 @@ public sealed partial class ReservedNames : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + Types_ = input.ReadInt32(); + break; + } + case 16: { + Descriptor_ = input.ReadInt32(); + break; + } + } + } + } + #endif + #region Nested types /// Container for nested types declared in the ReservedNames message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1230,7 +1550,11 @@ public static partial class Types { /// /// Force a nested type called Types /// - public sealed partial class SomeNestedType : pb::IMessage { + public sealed partial class SomeNestedType : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new SomeNestedType()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1300,6 +1624,16 @@ public sealed partial class SomeNestedType : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -1329,6 +1663,21 @@ public sealed partial class SomeNestedType : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + } + } + } + #endif + } } @@ -1348,7 +1697,11 @@ public sealed partial class SomeNestedType : pb::IMessage { /// Alternatively, consider just adding this to /// unittest_proto3.proto if multiple platforms want it. /// - public sealed partial class TestJsonFieldOrdering : pb::IMessage { + public sealed partial class TestJsonFieldOrdering : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestJsonFieldOrdering()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1582,6 +1935,40 @@ public enum O2OneofCase { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (PlainString.Length != 0) { + output.WriteRawTag(10); + output.WriteString(PlainString); + } + if (o1Case_ == O1OneofCase.O1String) { + output.WriteRawTag(18); + output.WriteString(O1String); + } + if (o2Case_ == O2OneofCase.O2String) { + output.WriteRawTag(26); + output.WriteString(O2String); + } + if (PlainInt32 != 0) { + output.WriteRawTag(32); + output.WriteInt32(PlainInt32); + } + if (o1Case_ == O1OneofCase.O1Int32) { + output.WriteRawTag(40); + output.WriteInt32(O1Int32); + } + if (o2Case_ == O2OneofCase.O2Int32) { + output.WriteRawTag(48); + output.WriteInt32(O2Int32); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -1677,9 +2064,52 @@ public enum O2OneofCase { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + PlainString = input.ReadString(); + break; + } + case 18: { + O1String = input.ReadString(); + break; + } + case 26: { + O2String = input.ReadString(); + break; + } + case 32: { + PlainInt32 = input.ReadInt32(); + break; + } + case 40: { + O1Int32 = input.ReadInt32(); + break; + } + case 48: { + O2Int32 = input.ReadInt32(); + break; + } + } + } + } + #endif + } - public sealed partial class TestJsonName : pb::IMessage { + public sealed partial class TestJsonName : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestJsonName()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1806,6 +2236,28 @@ public sealed partial class TestJsonName : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (Name.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Name); + } + if (Description.Length != 0) { + output.WriteRawTag(18); + output.WriteString(Description); + } + if (Guid.Length != 0) { + output.WriteRawTag(26); + output.WriteString(Guid); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -1865,6 +2317,33 @@ public sealed partial class TestJsonName : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + Name = input.ReadString(); + break; + } + case 18: { + Description = input.ReadString(); + break; + } + case 26: { + Guid = input.ReadString(); + break; + } + } + } + } + #endif + } /// @@ -1872,7 +2351,11 @@ public sealed partial class TestJsonName : pb::IMessage { /// oneof case, which is itself a message type, the submessages should /// be merged. /// - public sealed partial class OneofMerging : pb::IMessage { + public sealed partial class OneofMerging : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new OneofMerging()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -2006,6 +2489,24 @@ public enum ValueOneofCase { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (valueCase_ == ValueOneofCase.Text) { + output.WriteRawTag(10); + output.WriteString(Text); + } + if (valueCase_ == ValueOneofCase.Nested) { + output.WriteRawTag(18); + output.WriteMessage(Nested); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -2066,11 +2567,43 @@ public enum ValueOneofCase { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + Text = input.ReadString(); + break; + } + case 18: { + global::UnitTest.Issues.TestProtos.OneofMerging.Types.Nested subBuilder = new global::UnitTest.Issues.TestProtos.OneofMerging.Types.Nested(); + if (valueCase_ == ValueOneofCase.Nested) { + subBuilder.MergeFrom(Nested); + } + input.ReadMessage(subBuilder); + Nested = subBuilder; + break; + } + } + } + } + #endif + #region Nested types /// Container for nested types declared in the OneofMerging message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - public sealed partial class Nested : pb::IMessage { + public sealed partial class Nested : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Nested()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -2176,6 +2709,24 @@ public sealed partial class Nested : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (X != 0) { + output.WriteRawTag(8); + output.WriteInt32(X); + } + if (Y != 0) { + output.WriteRawTag(16); + output.WriteInt32(Y); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -2225,6 +2776,29 @@ public sealed partial class Nested : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + X = input.ReadInt32(); + break; + } + case 16: { + Y = input.ReadInt32(); + break; + } + } + } + } + #endif + } } diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestProto3.cs b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestProto3.cs index 3f01e38bb973..c3a238528ad6 100644 --- a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestProto3.cs +++ b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestProto3.cs @@ -254,7 +254,11 @@ public enum CommentEnum { /// This proto includes every type of field in both singular and repeated /// forms. /// - public sealed partial class TestAllTypes : pb::IMessage { + public sealed partial class TestAllTypes : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestAllTypes()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1146,6 +1150,142 @@ public enum OneofFieldOneofCase { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (SingleInt32 != 0) { + output.WriteRawTag(8); + output.WriteInt32(SingleInt32); + } + if (SingleInt64 != 0L) { + output.WriteRawTag(16); + output.WriteInt64(SingleInt64); + } + if (SingleUint32 != 0) { + output.WriteRawTag(24); + output.WriteUInt32(SingleUint32); + } + if (SingleUint64 != 0UL) { + output.WriteRawTag(32); + output.WriteUInt64(SingleUint64); + } + if (SingleSint32 != 0) { + output.WriteRawTag(40); + output.WriteSInt32(SingleSint32); + } + if (SingleSint64 != 0L) { + output.WriteRawTag(48); + output.WriteSInt64(SingleSint64); + } + if (SingleFixed32 != 0) { + output.WriteRawTag(61); + output.WriteFixed32(SingleFixed32); + } + if (SingleFixed64 != 0UL) { + output.WriteRawTag(65); + output.WriteFixed64(SingleFixed64); + } + if (SingleSfixed32 != 0) { + output.WriteRawTag(77); + output.WriteSFixed32(SingleSfixed32); + } + if (SingleSfixed64 != 0L) { + output.WriteRawTag(81); + output.WriteSFixed64(SingleSfixed64); + } + if (SingleFloat != 0F) { + output.WriteRawTag(93); + output.WriteFloat(SingleFloat); + } + if (SingleDouble != 0D) { + output.WriteRawTag(97); + output.WriteDouble(SingleDouble); + } + if (SingleBool != false) { + output.WriteRawTag(104); + output.WriteBool(SingleBool); + } + if (SingleString.Length != 0) { + output.WriteRawTag(114); + output.WriteString(SingleString); + } + if (SingleBytes.Length != 0) { + output.WriteRawTag(122); + output.WriteBytes(SingleBytes); + } + if (singleNestedMessage_ != null) { + output.WriteRawTag(146, 1); + output.WriteMessage(SingleNestedMessage); + } + if (singleForeignMessage_ != null) { + output.WriteRawTag(154, 1); + output.WriteMessage(SingleForeignMessage); + } + if (singleImportMessage_ != null) { + output.WriteRawTag(162, 1); + output.WriteMessage(SingleImportMessage); + } + if (SingleNestedEnum != global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum.Unspecified) { + output.WriteRawTag(168, 1); + output.WriteEnum((int) SingleNestedEnum); + } + if (SingleForeignEnum != global::Google.Protobuf.TestProtos.ForeignEnum.ForeignUnspecified) { + output.WriteRawTag(176, 1); + output.WriteEnum((int) SingleForeignEnum); + } + if (SingleImportEnum != global::Google.Protobuf.TestProtos.ImportEnum.Unspecified) { + output.WriteRawTag(184, 1); + output.WriteEnum((int) SingleImportEnum); + } + if (singlePublicImportMessage_ != null) { + output.WriteRawTag(210, 1); + output.WriteMessage(SinglePublicImportMessage); + } + repeatedInt32_.WriteTo(ref output, _repeated_repeatedInt32_codec); + repeatedInt64_.WriteTo(ref output, _repeated_repeatedInt64_codec); + repeatedUint32_.WriteTo(ref output, _repeated_repeatedUint32_codec); + repeatedUint64_.WriteTo(ref output, _repeated_repeatedUint64_codec); + repeatedSint32_.WriteTo(ref output, _repeated_repeatedSint32_codec); + repeatedSint64_.WriteTo(ref output, _repeated_repeatedSint64_codec); + repeatedFixed32_.WriteTo(ref output, _repeated_repeatedFixed32_codec); + repeatedFixed64_.WriteTo(ref output, _repeated_repeatedFixed64_codec); + repeatedSfixed32_.WriteTo(ref output, _repeated_repeatedSfixed32_codec); + repeatedSfixed64_.WriteTo(ref output, _repeated_repeatedSfixed64_codec); + repeatedFloat_.WriteTo(ref output, _repeated_repeatedFloat_codec); + repeatedDouble_.WriteTo(ref output, _repeated_repeatedDouble_codec); + repeatedBool_.WriteTo(ref output, _repeated_repeatedBool_codec); + repeatedString_.WriteTo(ref output, _repeated_repeatedString_codec); + repeatedBytes_.WriteTo(ref output, _repeated_repeatedBytes_codec); + repeatedNestedMessage_.WriteTo(ref output, _repeated_repeatedNestedMessage_codec); + repeatedForeignMessage_.WriteTo(ref output, _repeated_repeatedForeignMessage_codec); + repeatedImportMessage_.WriteTo(ref output, _repeated_repeatedImportMessage_codec); + repeatedNestedEnum_.WriteTo(ref output, _repeated_repeatedNestedEnum_codec); + repeatedForeignEnum_.WriteTo(ref output, _repeated_repeatedForeignEnum_codec); + repeatedImportEnum_.WriteTo(ref output, _repeated_repeatedImportEnum_codec); + repeatedPublicImportMessage_.WriteTo(ref output, _repeated_repeatedPublicImportMessage_codec); + if (oneofFieldCase_ == OneofFieldOneofCase.OneofUint32) { + output.WriteRawTag(248, 6); + output.WriteUInt32(OneofUint32); + } + if (oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage) { + output.WriteRawTag(130, 7); + output.WriteMessage(OneofNestedMessage); + } + if (oneofFieldCase_ == OneofFieldOneofCase.OneofString) { + output.WriteRawTag(138, 7); + output.WriteString(OneofString); + } + if (oneofFieldCase_ == OneofFieldOneofCase.OneofBytes) { + output.WriteRawTag(146, 7); + output.WriteBytes(OneofBytes); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -1618,6 +1758,246 @@ public enum OneofFieldOneofCase { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + SingleInt32 = input.ReadInt32(); + break; + } + case 16: { + SingleInt64 = input.ReadInt64(); + break; + } + case 24: { + SingleUint32 = input.ReadUInt32(); + break; + } + case 32: { + SingleUint64 = input.ReadUInt64(); + break; + } + case 40: { + SingleSint32 = input.ReadSInt32(); + break; + } + case 48: { + SingleSint64 = input.ReadSInt64(); + break; + } + case 61: { + SingleFixed32 = input.ReadFixed32(); + break; + } + case 65: { + SingleFixed64 = input.ReadFixed64(); + break; + } + case 77: { + SingleSfixed32 = input.ReadSFixed32(); + break; + } + case 81: { + SingleSfixed64 = input.ReadSFixed64(); + break; + } + case 93: { + SingleFloat = input.ReadFloat(); + break; + } + case 97: { + SingleDouble = input.ReadDouble(); + break; + } + case 104: { + SingleBool = input.ReadBool(); + break; + } + case 114: { + SingleString = input.ReadString(); + break; + } + case 122: { + SingleBytes = input.ReadBytes(); + break; + } + case 146: { + if (singleNestedMessage_ == null) { + SingleNestedMessage = new global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage(); + } + input.ReadMessage(SingleNestedMessage); + break; + } + case 154: { + if (singleForeignMessage_ == null) { + SingleForeignMessage = new global::Google.Protobuf.TestProtos.ForeignMessage(); + } + input.ReadMessage(SingleForeignMessage); + break; + } + case 162: { + if (singleImportMessage_ == null) { + SingleImportMessage = new global::Google.Protobuf.TestProtos.ImportMessage(); + } + input.ReadMessage(SingleImportMessage); + break; + } + case 168: { + SingleNestedEnum = (global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum) input.ReadEnum(); + break; + } + case 176: { + SingleForeignEnum = (global::Google.Protobuf.TestProtos.ForeignEnum) input.ReadEnum(); + break; + } + case 184: { + SingleImportEnum = (global::Google.Protobuf.TestProtos.ImportEnum) input.ReadEnum(); + break; + } + case 210: { + if (singlePublicImportMessage_ == null) { + SinglePublicImportMessage = new global::Google.Protobuf.TestProtos.PublicImportMessage(); + } + input.ReadMessage(SinglePublicImportMessage); + break; + } + case 250: + case 248: { + repeatedInt32_.AddEntriesFrom(ref input, _repeated_repeatedInt32_codec); + break; + } + case 258: + case 256: { + repeatedInt64_.AddEntriesFrom(ref input, _repeated_repeatedInt64_codec); + break; + } + case 266: + case 264: { + repeatedUint32_.AddEntriesFrom(ref input, _repeated_repeatedUint32_codec); + break; + } + case 274: + case 272: { + repeatedUint64_.AddEntriesFrom(ref input, _repeated_repeatedUint64_codec); + break; + } + case 282: + case 280: { + repeatedSint32_.AddEntriesFrom(ref input, _repeated_repeatedSint32_codec); + break; + } + case 290: + case 288: { + repeatedSint64_.AddEntriesFrom(ref input, _repeated_repeatedSint64_codec); + break; + } + case 298: + case 301: { + repeatedFixed32_.AddEntriesFrom(ref input, _repeated_repeatedFixed32_codec); + break; + } + case 306: + case 305: { + repeatedFixed64_.AddEntriesFrom(ref input, _repeated_repeatedFixed64_codec); + break; + } + case 314: + case 317: { + repeatedSfixed32_.AddEntriesFrom(ref input, _repeated_repeatedSfixed32_codec); + break; + } + case 322: + case 321: { + repeatedSfixed64_.AddEntriesFrom(ref input, _repeated_repeatedSfixed64_codec); + break; + } + case 330: + case 333: { + repeatedFloat_.AddEntriesFrom(ref input, _repeated_repeatedFloat_codec); + break; + } + case 338: + case 337: { + repeatedDouble_.AddEntriesFrom(ref input, _repeated_repeatedDouble_codec); + break; + } + case 346: + case 344: { + repeatedBool_.AddEntriesFrom(ref input, _repeated_repeatedBool_codec); + break; + } + case 354: { + repeatedString_.AddEntriesFrom(ref input, _repeated_repeatedString_codec); + break; + } + case 362: { + repeatedBytes_.AddEntriesFrom(ref input, _repeated_repeatedBytes_codec); + break; + } + case 386: { + repeatedNestedMessage_.AddEntriesFrom(ref input, _repeated_repeatedNestedMessage_codec); + break; + } + case 394: { + repeatedForeignMessage_.AddEntriesFrom(ref input, _repeated_repeatedForeignMessage_codec); + break; + } + case 402: { + repeatedImportMessage_.AddEntriesFrom(ref input, _repeated_repeatedImportMessage_codec); + break; + } + case 410: + case 408: { + repeatedNestedEnum_.AddEntriesFrom(ref input, _repeated_repeatedNestedEnum_codec); + break; + } + case 418: + case 416: { + repeatedForeignEnum_.AddEntriesFrom(ref input, _repeated_repeatedForeignEnum_codec); + break; + } + case 426: + case 424: { + repeatedImportEnum_.AddEntriesFrom(ref input, _repeated_repeatedImportEnum_codec); + break; + } + case 434: { + repeatedPublicImportMessage_.AddEntriesFrom(ref input, _repeated_repeatedPublicImportMessage_codec); + break; + } + case 888: { + OneofUint32 = input.ReadUInt32(); + break; + } + case 898: { + global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage subBuilder = new global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage(); + if (oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage) { + subBuilder.MergeFrom(OneofNestedMessage); + } + input.ReadMessage(subBuilder); + OneofNestedMessage = subBuilder; + break; + } + case 906: { + OneofString = input.ReadString(); + break; + } + case 914: { + OneofBytes = input.ReadBytes(); + break; + } + } + } + } + #endif + #region Nested types /// Container for nested types declared in the TestAllTypes message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1633,7 +2013,11 @@ public enum NestedEnum { [pbr::OriginalName("NEG")] Neg = -1, } - public sealed partial class NestedMessage : pb::IMessage { + public sealed partial class NestedMessage : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1726,6 +2110,20 @@ public sealed partial class NestedMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (Bb != 0) { + output.WriteRawTag(8); + output.WriteInt32(Bb); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -1765,6 +2163,25 @@ public sealed partial class NestedMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + Bb = input.ReadInt32(); + break; + } + } + } + } + #endif + } } @@ -1775,7 +2192,11 @@ public sealed partial class NestedMessage : pb::IMessage { /// /// This proto includes a recursively nested message. /// - public sealed partial class NestedTestAllTypes : pb::IMessage { + public sealed partial class NestedTestAllTypes : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedTestAllTypes()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1895,6 +2316,25 @@ public sealed partial class NestedTestAllTypes : pb::IMessage { + public sealed partial class TestDeprecatedFields : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestDeprecatedFields()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -2053,6 +2530,20 @@ public sealed partial class TestDeprecatedFields : pb::IMessage /// Define these after TestAllTypes to make sure the compiler can handle /// that. /// - public sealed partial class ForeignMessage : pb::IMessage { + public sealed partial class ForeignMessage : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ForeignMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -2186,6 +2700,20 @@ public sealed partial class ForeignMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (C != 0) { + output.WriteRawTag(8); + output.WriteInt32(C); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -2225,9 +2753,32 @@ public sealed partial class ForeignMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + C = input.ReadInt32(); + break; + } + } + } + } + #endif + } - public sealed partial class TestReservedFields : pb::IMessage { + public sealed partial class TestReservedFields : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestReservedFields()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -2297,6 +2848,16 @@ public sealed partial class TestReservedFields : pb::IMessage /// Test that we can use NestedMessage from outside TestAllTypes. /// - public sealed partial class TestForeignNested : pb::IMessage { + public sealed partial class TestForeignNested : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestForeignNested()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -2419,6 +2999,20 @@ public sealed partial class TestForeignNested : pb::IMessage } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (foreignNested_ != null) { + output.WriteRawTag(10); + output.WriteMessage(ForeignNested); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -2464,12 +3058,38 @@ public sealed partial class TestForeignNested : pb::IMessage } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + if (foreignNested_ == null) { + ForeignNested = new global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage(); + } + input.ReadMessage(ForeignNested); + break; + } + } + } + } + #endif + } /// /// Test that really large tag numbers don't break anything. /// - public sealed partial class TestReallyLargeTagNumber : pb::IMessage { + public sealed partial class TestReallyLargeTagNumber : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestReallyLargeTagNumber()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -2554,18 +3174,35 @@ public sealed partial class TestReallyLargeTagNumber : pb::IMessage { + public sealed partial class TestRecursiveMessage : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestRecursiveMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -2736,6 +3401,24 @@ public sealed partial class TestRecursiveMessage : pb::IMessage /// Test that mutual recursion works. /// - public sealed partial class TestMutualRecursionA : pb::IMessage { + public sealed partial class TestMutualRecursionA : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestMutualRecursionA()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -2884,6 +3597,20 @@ public sealed partial class TestMutualRecursionA : pb::IMessage { + public sealed partial class TestMutualRecursionB : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestMutualRecursionB()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -3037,6 +3790,24 @@ public sealed partial class TestMutualRecursionB : pb::IMessage { + public sealed partial class TestEnumAllowAlias : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestEnumAllowAlias()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -3182,6 +3983,20 @@ public sealed partial class TestEnumAllowAlias : pb::IMessage /// Test message with CamelCase field names. This violates Protocol Buffer /// standard style. /// - public sealed partial class TestCamelCaseFieldNames : pb::IMessage { + public sealed partial class TestCamelCaseFieldNames : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestCamelCaseFieldNames()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -3425,6 +4263,36 @@ public sealed partial class TestCamelCaseFieldNames : pb::IMessage /// We list fields out of order, to ensure that we're using field number and not /// field index to determine serialization order. /// - public sealed partial class TestFieldOrderings : pb::IMessage { + public sealed partial class TestFieldOrderings : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestFieldOrderings()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -3674,6 +4598,32 @@ public sealed partial class TestFieldOrderings : pb::IMessageContainer for nested types declared in the TestFieldOrderings message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - public sealed partial class NestedMessage : pb::IMessage { + public sealed partial class NestedMessage : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -3864,6 +4852,24 @@ public sealed partial class NestedMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (Bb != 0) { + output.WriteRawTag(8); + output.WriteInt32(Bb); + } + if (Oo != 0L) { + output.WriteRawTag(16); + output.WriteInt64(Oo); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -3913,6 +4919,29 @@ public sealed partial class NestedMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + Bb = input.ReadInt32(); + break; + } + case 16: { + Oo = input.ReadInt64(); + break; + } + } + } + } + #endif + } } @@ -3920,7 +4949,11 @@ public sealed partial class NestedMessage : pb::IMessage { } - public sealed partial class SparseEnumMessage : pb::IMessage { + public sealed partial class SparseEnumMessage : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new SparseEnumMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -4008,6 +5041,20 @@ public sealed partial class SparseEnumMessage : pb::IMessage } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (SparseEnum != global::Google.Protobuf.TestProtos.TestSparseEnum.Unspecified) { + output.WriteRawTag(8); + output.WriteEnum((int) SparseEnum); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -4047,12 +5094,35 @@ public sealed partial class SparseEnumMessage : pb::IMessage } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + SparseEnum = (global::Google.Protobuf.TestProtos.TestSparseEnum) input.ReadEnum(); + break; + } + } + } + } + #endif + } /// /// Test String and Bytes: string is for valid UTF-8 strings /// - public sealed partial class OneString : pb::IMessage { + public sealed partial class OneString : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new OneString()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -4140,6 +5210,20 @@ public sealed partial class OneString : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (Data.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Data); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -4179,9 +5263,32 @@ public sealed partial class OneString : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + Data = input.ReadString(); + break; + } + } + } + } + #endif + } - public sealed partial class MoreString : pb::IMessage { + public sealed partial class MoreString : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MoreString()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -4265,6 +5372,17 @@ public sealed partial class MoreString : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + data_.WriteTo(ref output, _repeated_data_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -4300,9 +5418,32 @@ public sealed partial class MoreString : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + data_.AddEntriesFrom(ref input, _repeated_data_codec); + break; + } + } + } + } + #endif + } - public sealed partial class OneBytes : pb::IMessage { + public sealed partial class OneBytes : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new OneBytes()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -4390,6 +5531,20 @@ public sealed partial class OneBytes : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (Data.Length != 0) { + output.WriteRawTag(10); + output.WriteBytes(Data); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -4429,9 +5584,32 @@ public sealed partial class OneBytes : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + Data = input.ReadBytes(); + break; + } + } + } + } + #endif + } - public sealed partial class MoreBytes : pb::IMessage { + public sealed partial class MoreBytes : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MoreBytes()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -4519,6 +5697,20 @@ public sealed partial class MoreBytes : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (Data.Length != 0) { + output.WriteRawTag(10); + output.WriteBytes(Data); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -4558,12 +5750,35 @@ public sealed partial class MoreBytes : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + Data = input.ReadBytes(); + break; + } + } + } + } + #endif + } /// /// Test int32, uint32, int64, uint64, and bool are all compatible /// - public sealed partial class Int32Message : pb::IMessage { + public sealed partial class Int32Message : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Int32Message()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -4651,6 +5866,20 @@ public sealed partial class Int32Message : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (Data != 0) { + output.WriteRawTag(8); + output.WriteInt32(Data); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -4690,9 +5919,32 @@ public sealed partial class Int32Message : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + Data = input.ReadInt32(); + break; + } + } + } + } + #endif + } - public sealed partial class Uint32Message : pb::IMessage { + public sealed partial class Uint32Message : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Uint32Message()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -4780,6 +6032,20 @@ public sealed partial class Uint32Message : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (Data != 0) { + output.WriteRawTag(8); + output.WriteUInt32(Data); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -4819,9 +6085,32 @@ public sealed partial class Uint32Message : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + Data = input.ReadUInt32(); + break; + } + } + } + } + #endif + } - public sealed partial class Int64Message : pb::IMessage { + public sealed partial class Int64Message : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Int64Message()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -4909,6 +6198,20 @@ public sealed partial class Int64Message : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (Data != 0L) { + output.WriteRawTag(8); + output.WriteInt64(Data); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -4933,12 +6236,30 @@ public sealed partial class Int64Message : pb::IMessage { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(pb::CodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + Data = input.ReadInt64(); + break; + } + } + } + } + + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 8: { Data = input.ReadInt64(); @@ -4947,10 +6268,15 @@ public sealed partial class Int64Message : pb::IMessage { } } } + #endif } - public sealed partial class Uint64Message : pb::IMessage { + public sealed partial class Uint64Message : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Uint64Message()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -5038,6 +6364,20 @@ public sealed partial class Uint64Message : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (Data != 0UL) { + output.WriteRawTag(8); + output.WriteUInt64(Data); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -5077,9 +6417,32 @@ public sealed partial class Uint64Message : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + Data = input.ReadUInt64(); + break; + } + } + } + } + #endif + } - public sealed partial class BoolMessage : pb::IMessage { + public sealed partial class BoolMessage : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new BoolMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -5167,6 +6530,20 @@ public sealed partial class BoolMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (Data != false) { + output.WriteRawTag(8); + output.WriteBool(Data); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -5206,12 +6583,35 @@ public sealed partial class BoolMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + Data = input.ReadBool(); + break; + } + } + } + } + #endif + } /// /// Test oneofs. /// - public sealed partial class TestOneof : pb::IMessage { + public sealed partial class TestOneof : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestOneof()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -5366,6 +6766,28 @@ public enum FooOneofCase { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (fooCase_ == FooOneofCase.FooInt) { + output.WriteRawTag(8); + output.WriteInt32(FooInt); + } + if (fooCase_ == FooOneofCase.FooString) { + output.WriteRawTag(18); + output.WriteString(FooString); + } + if (fooCase_ == FooOneofCase.FooMessage) { + output.WriteRawTag(26); + output.WriteMessage(FooMessage); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -5436,9 +6858,45 @@ public enum FooOneofCase { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + FooInt = input.ReadInt32(); + break; + } + case 18: { + FooString = input.ReadString(); + break; + } + case 26: { + global::Google.Protobuf.TestProtos.TestAllTypes subBuilder = new global::Google.Protobuf.TestProtos.TestAllTypes(); + if (fooCase_ == FooOneofCase.FooMessage) { + subBuilder.MergeFrom(FooMessage); + } + input.ReadMessage(subBuilder); + FooMessage = subBuilder; + break; + } + } + } + } + #endif + } - public sealed partial class TestPackedTypes : pb::IMessage { + public sealed partial class TestPackedTypes : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestPackedTypes()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -5704,6 +7162,30 @@ public sealed partial class TestPackedTypes : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + packedInt32_.WriteTo(ref output, _repeated_packedInt32_codec); + packedInt64_.WriteTo(ref output, _repeated_packedInt64_codec); + packedUint32_.WriteTo(ref output, _repeated_packedUint32_codec); + packedUint64_.WriteTo(ref output, _repeated_packedUint64_codec); + packedSint32_.WriteTo(ref output, _repeated_packedSint32_codec); + packedSint64_.WriteTo(ref output, _repeated_packedSint64_codec); + packedFixed32_.WriteTo(ref output, _repeated_packedFixed32_codec); + packedFixed64_.WriteTo(ref output, _repeated_packedFixed64_codec); + packedSfixed32_.WriteTo(ref output, _repeated_packedSfixed32_codec); + packedSfixed64_.WriteTo(ref output, _repeated_packedSfixed64_codec); + packedFloat_.WriteTo(ref output, _repeated_packedFloat_codec); + packedDouble_.WriteTo(ref output, _repeated_packedDouble_codec); + packedBool_.WriteTo(ref output, _repeated_packedBool_codec); + packedEnum_.WriteTo(ref output, _repeated_packedEnum_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -5831,13 +7313,102 @@ public sealed partial class TestPackedTypes : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 722: + case 720: { + packedInt32_.AddEntriesFrom(ref input, _repeated_packedInt32_codec); + break; + } + case 730: + case 728: { + packedInt64_.AddEntriesFrom(ref input, _repeated_packedInt64_codec); + break; + } + case 738: + case 736: { + packedUint32_.AddEntriesFrom(ref input, _repeated_packedUint32_codec); + break; + } + case 746: + case 744: { + packedUint64_.AddEntriesFrom(ref input, _repeated_packedUint64_codec); + break; + } + case 754: + case 752: { + packedSint32_.AddEntriesFrom(ref input, _repeated_packedSint32_codec); + break; + } + case 762: + case 760: { + packedSint64_.AddEntriesFrom(ref input, _repeated_packedSint64_codec); + break; + } + case 770: + case 773: { + packedFixed32_.AddEntriesFrom(ref input, _repeated_packedFixed32_codec); + break; + } + case 778: + case 777: { + packedFixed64_.AddEntriesFrom(ref input, _repeated_packedFixed64_codec); + break; + } + case 786: + case 789: { + packedSfixed32_.AddEntriesFrom(ref input, _repeated_packedSfixed32_codec); + break; + } + case 794: + case 793: { + packedSfixed64_.AddEntriesFrom(ref input, _repeated_packedSfixed64_codec); + break; + } + case 802: + case 805: { + packedFloat_.AddEntriesFrom(ref input, _repeated_packedFloat_codec); + break; + } + case 810: + case 809: { + packedDouble_.AddEntriesFrom(ref input, _repeated_packedDouble_codec); + break; + } + case 818: + case 816: { + packedBool_.AddEntriesFrom(ref input, _repeated_packedBool_codec); + break; + } + case 826: + case 824: { + packedEnum_.AddEntriesFrom(ref input, _repeated_packedEnum_codec); + break; + } + } + } + } + #endif + } /// /// A message with the same fields as TestPackedTypes, but without packing. Used /// to test packed <-> unpacked wire compatibility. /// - public sealed partial class TestUnpackedTypes : pb::IMessage { + public sealed partial class TestUnpackedTypes : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestUnpackedTypes()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -6103,6 +7674,30 @@ public sealed partial class TestUnpackedTypes : pb::IMessage } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + unpackedInt32_.WriteTo(ref output, _repeated_unpackedInt32_codec); + unpackedInt64_.WriteTo(ref output, _repeated_unpackedInt64_codec); + unpackedUint32_.WriteTo(ref output, _repeated_unpackedUint32_codec); + unpackedUint64_.WriteTo(ref output, _repeated_unpackedUint64_codec); + unpackedSint32_.WriteTo(ref output, _repeated_unpackedSint32_codec); + unpackedSint64_.WriteTo(ref output, _repeated_unpackedSint64_codec); + unpackedFixed32_.WriteTo(ref output, _repeated_unpackedFixed32_codec); + unpackedFixed64_.WriteTo(ref output, _repeated_unpackedFixed64_codec); + unpackedSfixed32_.WriteTo(ref output, _repeated_unpackedSfixed32_codec); + unpackedSfixed64_.WriteTo(ref output, _repeated_unpackedSfixed64_codec); + unpackedFloat_.WriteTo(ref output, _repeated_unpackedFloat_codec); + unpackedDouble_.WriteTo(ref output, _repeated_unpackedDouble_codec); + unpackedBool_.WriteTo(ref output, _repeated_unpackedBool_codec); + unpackedEnum_.WriteTo(ref output, _repeated_unpackedEnum_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -6149,90 +7744,179 @@ public sealed partial class TestUnpackedTypes : pb::IMessage } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(pb::CodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 722: + case 720: { + unpackedInt32_.AddEntriesFrom(input, _repeated_unpackedInt32_codec); + break; + } + case 730: + case 728: { + unpackedInt64_.AddEntriesFrom(input, _repeated_unpackedInt64_codec); + break; + } + case 738: + case 736: { + unpackedUint32_.AddEntriesFrom(input, _repeated_unpackedUint32_codec); + break; + } + case 746: + case 744: { + unpackedUint64_.AddEntriesFrom(input, _repeated_unpackedUint64_codec); + break; + } + case 754: + case 752: { + unpackedSint32_.AddEntriesFrom(input, _repeated_unpackedSint32_codec); + break; + } + case 762: + case 760: { + unpackedSint64_.AddEntriesFrom(input, _repeated_unpackedSint64_codec); + break; + } + case 770: + case 773: { + unpackedFixed32_.AddEntriesFrom(input, _repeated_unpackedFixed32_codec); + break; + } + case 778: + case 777: { + unpackedFixed64_.AddEntriesFrom(input, _repeated_unpackedFixed64_codec); + break; + } + case 786: + case 789: { + unpackedSfixed32_.AddEntriesFrom(input, _repeated_unpackedSfixed32_codec); + break; + } + case 794: + case 793: { + unpackedSfixed64_.AddEntriesFrom(input, _repeated_unpackedSfixed64_codec); + break; + } + case 802: + case 805: { + unpackedFloat_.AddEntriesFrom(input, _repeated_unpackedFloat_codec); + break; + } + case 810: + case 809: { + unpackedDouble_.AddEntriesFrom(input, _repeated_unpackedDouble_codec); + break; + } + case 818: + case 816: { + unpackedBool_.AddEntriesFrom(input, _repeated_unpackedBool_codec); + break; + } + case 826: + case 824: { + unpackedEnum_.AddEntriesFrom(input, _repeated_unpackedEnum_codec); + break; + } + } + } + } + + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); break; case 722: case 720: { - unpackedInt32_.AddEntriesFrom(input, _repeated_unpackedInt32_codec); + unpackedInt32_.AddEntriesFrom(ref input, _repeated_unpackedInt32_codec); break; } case 730: case 728: { - unpackedInt64_.AddEntriesFrom(input, _repeated_unpackedInt64_codec); + unpackedInt64_.AddEntriesFrom(ref input, _repeated_unpackedInt64_codec); break; } case 738: case 736: { - unpackedUint32_.AddEntriesFrom(input, _repeated_unpackedUint32_codec); + unpackedUint32_.AddEntriesFrom(ref input, _repeated_unpackedUint32_codec); break; } case 746: case 744: { - unpackedUint64_.AddEntriesFrom(input, _repeated_unpackedUint64_codec); + unpackedUint64_.AddEntriesFrom(ref input, _repeated_unpackedUint64_codec); break; } case 754: case 752: { - unpackedSint32_.AddEntriesFrom(input, _repeated_unpackedSint32_codec); + unpackedSint32_.AddEntriesFrom(ref input, _repeated_unpackedSint32_codec); break; } case 762: case 760: { - unpackedSint64_.AddEntriesFrom(input, _repeated_unpackedSint64_codec); + unpackedSint64_.AddEntriesFrom(ref input, _repeated_unpackedSint64_codec); break; } case 770: case 773: { - unpackedFixed32_.AddEntriesFrom(input, _repeated_unpackedFixed32_codec); + unpackedFixed32_.AddEntriesFrom(ref input, _repeated_unpackedFixed32_codec); break; } case 778: case 777: { - unpackedFixed64_.AddEntriesFrom(input, _repeated_unpackedFixed64_codec); + unpackedFixed64_.AddEntriesFrom(ref input, _repeated_unpackedFixed64_codec); break; } case 786: case 789: { - unpackedSfixed32_.AddEntriesFrom(input, _repeated_unpackedSfixed32_codec); + unpackedSfixed32_.AddEntriesFrom(ref input, _repeated_unpackedSfixed32_codec); break; } case 794: case 793: { - unpackedSfixed64_.AddEntriesFrom(input, _repeated_unpackedSfixed64_codec); + unpackedSfixed64_.AddEntriesFrom(ref input, _repeated_unpackedSfixed64_codec); break; } case 802: case 805: { - unpackedFloat_.AddEntriesFrom(input, _repeated_unpackedFloat_codec); + unpackedFloat_.AddEntriesFrom(ref input, _repeated_unpackedFloat_codec); break; } case 810: case 809: { - unpackedDouble_.AddEntriesFrom(input, _repeated_unpackedDouble_codec); + unpackedDouble_.AddEntriesFrom(ref input, _repeated_unpackedDouble_codec); break; } case 818: case 816: { - unpackedBool_.AddEntriesFrom(input, _repeated_unpackedBool_codec); + unpackedBool_.AddEntriesFrom(ref input, _repeated_unpackedBool_codec); break; } case 826: case 824: { - unpackedEnum_.AddEntriesFrom(input, _repeated_unpackedEnum_codec); + unpackedEnum_.AddEntriesFrom(ref input, _repeated_unpackedEnum_codec); break; } } } } + #endif } - public sealed partial class TestRepeatedScalarDifferentTagSizes : pb::IMessage { + public sealed partial class TestRepeatedScalarDifferentTagSizes : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestRepeatedScalarDifferentTagSizes()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -6400,6 +8084,22 @@ public sealed partial class TestRepeatedScalarDifferentTagSizes : pb::IMessage { + public sealed partial class TestCommentInjectionMessage : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestCommentInjectionMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -6564,6 +8313,20 @@ public sealed partial class TestCommentInjectionMessage : pb::IMessage /// Test that RPC services work. /// - public sealed partial class FooRequest : pb::IMessage { + public sealed partial class FooRequest : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FooRequest()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -6678,6 +8464,16 @@ public sealed partial class FooRequest : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -6707,9 +8503,28 @@ public sealed partial class FooRequest : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + } + } + } + #endif + } - public sealed partial class FooResponse : pb::IMessage { + public sealed partial class FooResponse : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FooResponse()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -6779,6 +8594,16 @@ public sealed partial class FooResponse : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -6808,9 +8633,28 @@ public sealed partial class FooResponse : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + } + } + } + #endif + } - public sealed partial class FooClientMessage : pb::IMessage { + public sealed partial class FooClientMessage : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FooClientMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -6880,6 +8724,16 @@ public sealed partial class FooClientMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -6909,9 +8763,28 @@ public sealed partial class FooClientMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + } + } + } + #endif + } - public sealed partial class FooServerMessage : pb::IMessage { + public sealed partial class FooServerMessage : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FooServerMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -6981,6 +8854,16 @@ public sealed partial class FooServerMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -7010,9 +8893,28 @@ public sealed partial class FooServerMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + } + } + } + #endif + } - public sealed partial class BarRequest : pb::IMessage { + public sealed partial class BarRequest : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new BarRequest()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -7082,6 +8984,16 @@ public sealed partial class BarRequest : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -7111,9 +9023,28 @@ public sealed partial class BarRequest : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + } + } + } + #endif + } - public sealed partial class BarResponse : pb::IMessage { + public sealed partial class BarResponse : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new BarResponse()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -7183,6 +9114,16 @@ public sealed partial class BarResponse : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -7212,9 +9153,28 @@ public sealed partial class BarResponse : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + } + } + } + #endif + } - public sealed partial class TestEmptyMessage : pb::IMessage { + public sealed partial class TestEmptyMessage : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestEmptyMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -7284,6 +9244,16 @@ public sealed partial class TestEmptyMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -7313,12 +9283,31 @@ public sealed partial class TestEmptyMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + } + } + } + #endif + } /// /// This is a leading comment /// - public sealed partial class CommentMessage : pb::IMessage { + public sealed partial class CommentMessage : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new CommentMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -7409,6 +9398,20 @@ public sealed partial class CommentMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (Text.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Text); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -7448,6 +9451,25 @@ public sealed partial class CommentMessage : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + Text = input.ReadString(); + break; + } + } + } + } + #endif + #region Nested types /// Container for nested types declared in the CommentMessage message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -7465,7 +9487,11 @@ public enum NestedCommentEnum { /// /// Leading nested message comment /// - public sealed partial class NestedCommentMessage : pb::IMessage { + public sealed partial class NestedCommentMessage : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedCommentMessage()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -7556,6 +9582,20 @@ public sealed partial class NestedCommentMessage : pb::IMessage - public sealed partial class TestWellKnownTypes : pb::IMessage { + public sealed partial class TestWellKnownTypes : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestWellKnownTypes()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -603,6 +607,83 @@ public sealed partial class TestWellKnownTypes : pb::IMessage /// A repeated field for each well-known type. /// - public sealed partial class RepeatedWellKnownTypes : pb::IMessage { + public sealed partial class RepeatedWellKnownTypes : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new RepeatedWellKnownTypes()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1257,6 +1490,34 @@ public sealed partial class RepeatedWellKnownTypes : pb::IMessage { + public sealed partial class OneofWellKnownTypes : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new OneofWellKnownTypes()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1866,6 +2218,79 @@ public enum OneofFieldOneofCase { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (oneofFieldCase_ == OneofFieldOneofCase.AnyField) { + output.WriteRawTag(10); + output.WriteMessage(AnyField); + } + if (oneofFieldCase_ == OneofFieldOneofCase.ApiField) { + output.WriteRawTag(18); + output.WriteMessage(ApiField); + } + if (oneofFieldCase_ == OneofFieldOneofCase.DurationField) { + output.WriteRawTag(26); + output.WriteMessage(DurationField); + } + if (oneofFieldCase_ == OneofFieldOneofCase.EmptyField) { + output.WriteRawTag(34); + output.WriteMessage(EmptyField); + } + if (oneofFieldCase_ == OneofFieldOneofCase.FieldMaskField) { + output.WriteRawTag(42); + output.WriteMessage(FieldMaskField); + } + if (oneofFieldCase_ == OneofFieldOneofCase.SourceContextField) { + output.WriteRawTag(50); + output.WriteMessage(SourceContextField); + } + if (oneofFieldCase_ == OneofFieldOneofCase.StructField) { + output.WriteRawTag(58); + output.WriteMessage(StructField); + } + if (oneofFieldCase_ == OneofFieldOneofCase.TimestampField) { + output.WriteRawTag(66); + output.WriteMessage(TimestampField); + } + if (oneofFieldCase_ == OneofFieldOneofCase.TypeField) { + output.WriteRawTag(74); + output.WriteMessage(TypeField); + } + if (oneofFieldCase_ == OneofFieldOneofCase.DoubleField) { + _oneof_doubleField_codec.WriteTagAndValue(ref output, (double?) oneofField_); + } + if (oneofFieldCase_ == OneofFieldOneofCase.FloatField) { + _oneof_floatField_codec.WriteTagAndValue(ref output, (float?) oneofField_); + } + if (oneofFieldCase_ == OneofFieldOneofCase.Int64Field) { + _oneof_int64Field_codec.WriteTagAndValue(ref output, (long?) oneofField_); + } + if (oneofFieldCase_ == OneofFieldOneofCase.Uint64Field) { + _oneof_uint64Field_codec.WriteTagAndValue(ref output, (ulong?) oneofField_); + } + if (oneofFieldCase_ == OneofFieldOneofCase.Int32Field) { + _oneof_int32Field_codec.WriteTagAndValue(ref output, (int?) oneofField_); + } + if (oneofFieldCase_ == OneofFieldOneofCase.Uint32Field) { + _oneof_uint32Field_codec.WriteTagAndValue(ref output, (uint?) oneofField_); + } + if (oneofFieldCase_ == OneofFieldOneofCase.BoolField) { + _oneof_boolField_codec.WriteTagAndValue(ref output, (bool?) oneofField_); + } + if (oneofFieldCase_ == OneofFieldOneofCase.StringField) { + _oneof_stringField_codec.WriteTagAndValue(ref output, (string) oneofField_); + } + if (oneofFieldCase_ == OneofFieldOneofCase.BytesField) { + _oneof_bytesField_codec.WriteTagAndValue(ref output, (pb::ByteString) oneofField_); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -2150,6 +2575,138 @@ public enum OneofFieldOneofCase { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + global::Google.Protobuf.WellKnownTypes.Any subBuilder = new global::Google.Protobuf.WellKnownTypes.Any(); + if (oneofFieldCase_ == OneofFieldOneofCase.AnyField) { + subBuilder.MergeFrom(AnyField); + } + input.ReadMessage(subBuilder); + AnyField = subBuilder; + break; + } + case 18: { + global::Google.Protobuf.WellKnownTypes.Api subBuilder = new global::Google.Protobuf.WellKnownTypes.Api(); + if (oneofFieldCase_ == OneofFieldOneofCase.ApiField) { + subBuilder.MergeFrom(ApiField); + } + input.ReadMessage(subBuilder); + ApiField = subBuilder; + break; + } + case 26: { + global::Google.Protobuf.WellKnownTypes.Duration subBuilder = new global::Google.Protobuf.WellKnownTypes.Duration(); + if (oneofFieldCase_ == OneofFieldOneofCase.DurationField) { + subBuilder.MergeFrom(DurationField); + } + input.ReadMessage(subBuilder); + DurationField = subBuilder; + break; + } + case 34: { + global::Google.Protobuf.WellKnownTypes.Empty subBuilder = new global::Google.Protobuf.WellKnownTypes.Empty(); + if (oneofFieldCase_ == OneofFieldOneofCase.EmptyField) { + subBuilder.MergeFrom(EmptyField); + } + input.ReadMessage(subBuilder); + EmptyField = subBuilder; + break; + } + case 42: { + global::Google.Protobuf.WellKnownTypes.FieldMask subBuilder = new global::Google.Protobuf.WellKnownTypes.FieldMask(); + if (oneofFieldCase_ == OneofFieldOneofCase.FieldMaskField) { + subBuilder.MergeFrom(FieldMaskField); + } + input.ReadMessage(subBuilder); + FieldMaskField = subBuilder; + break; + } + case 50: { + global::Google.Protobuf.WellKnownTypes.SourceContext subBuilder = new global::Google.Protobuf.WellKnownTypes.SourceContext(); + if (oneofFieldCase_ == OneofFieldOneofCase.SourceContextField) { + subBuilder.MergeFrom(SourceContextField); + } + input.ReadMessage(subBuilder); + SourceContextField = subBuilder; + break; + } + case 58: { + global::Google.Protobuf.WellKnownTypes.Struct subBuilder = new global::Google.Protobuf.WellKnownTypes.Struct(); + if (oneofFieldCase_ == OneofFieldOneofCase.StructField) { + subBuilder.MergeFrom(StructField); + } + input.ReadMessage(subBuilder); + StructField = subBuilder; + break; + } + case 66: { + global::Google.Protobuf.WellKnownTypes.Timestamp subBuilder = new global::Google.Protobuf.WellKnownTypes.Timestamp(); + if (oneofFieldCase_ == OneofFieldOneofCase.TimestampField) { + subBuilder.MergeFrom(TimestampField); + } + input.ReadMessage(subBuilder); + TimestampField = subBuilder; + break; + } + case 74: { + global::Google.Protobuf.WellKnownTypes.Type subBuilder = new global::Google.Protobuf.WellKnownTypes.Type(); + if (oneofFieldCase_ == OneofFieldOneofCase.TypeField) { + subBuilder.MergeFrom(TypeField); + } + input.ReadMessage(subBuilder); + TypeField = subBuilder; + break; + } + case 82: { + DoubleField = _oneof_doubleField_codec.Read(ref input); + break; + } + case 90: { + FloatField = _oneof_floatField_codec.Read(ref input); + break; + } + case 98: { + Int64Field = _oneof_int64Field_codec.Read(ref input); + break; + } + case 106: { + Uint64Field = _oneof_uint64Field_codec.Read(ref input); + break; + } + case 114: { + Int32Field = _oneof_int32Field_codec.Read(ref input); + break; + } + case 122: { + Uint32Field = _oneof_uint32Field_codec.Read(ref input); + break; + } + case 130: { + BoolField = _oneof_boolField_codec.Read(ref input); + break; + } + case 138: { + StringField = _oneof_stringField_codec.Read(ref input); + break; + } + case 146: { + BytesField = _oneof_bytesField_codec.Read(ref input); + break; + } + } + } + } + #endif + } /// @@ -2157,7 +2714,11 @@ public enum OneofFieldOneofCase { /// need to worry about the value part of the map being the /// well-known types, as messages can't be map keys. /// - public sealed partial class MapWellKnownTypes : pb::IMessage { + public sealed partial class MapWellKnownTypes : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MapWellKnownTypes()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -2479,6 +3040,34 @@ public sealed partial class MapWellKnownTypes : pb::IMessage } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + anyField_.WriteTo(ref output, _map_anyField_codec); + apiField_.WriteTo(ref output, _map_apiField_codec); + durationField_.WriteTo(ref output, _map_durationField_codec); + emptyField_.WriteTo(ref output, _map_emptyField_codec); + fieldMaskField_.WriteTo(ref output, _map_fieldMaskField_codec); + sourceContextField_.WriteTo(ref output, _map_sourceContextField_codec); + structField_.WriteTo(ref output, _map_structField_codec); + timestampField_.WriteTo(ref output, _map_timestampField_codec); + typeField_.WriteTo(ref output, _map_typeField_codec); + doubleField_.WriteTo(ref output, _map_doubleField_codec); + floatField_.WriteTo(ref output, _map_floatField_codec); + int64Field_.WriteTo(ref output, _map_int64Field_codec); + uint64Field_.WriteTo(ref output, _map_uint64Field_codec); + int32Field_.WriteTo(ref output, _map_int32Field_codec); + uint32Field_.WriteTo(ref output, _map_uint32Field_codec); + boolField_.WriteTo(ref output, _map_boolField_codec); + stringField_.WriteTo(ref output, _map_stringField_codec); + bytesField_.WriteTo(ref output, _map_bytesField_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -2616,6 +3205,93 @@ public sealed partial class MapWellKnownTypes : pb::IMessage } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + anyField_.AddEntriesFrom(ref input, _map_anyField_codec); + break; + } + case 18: { + apiField_.AddEntriesFrom(ref input, _map_apiField_codec); + break; + } + case 26: { + durationField_.AddEntriesFrom(ref input, _map_durationField_codec); + break; + } + case 34: { + emptyField_.AddEntriesFrom(ref input, _map_emptyField_codec); + break; + } + case 42: { + fieldMaskField_.AddEntriesFrom(ref input, _map_fieldMaskField_codec); + break; + } + case 50: { + sourceContextField_.AddEntriesFrom(ref input, _map_sourceContextField_codec); + break; + } + case 58: { + structField_.AddEntriesFrom(ref input, _map_structField_codec); + break; + } + case 66: { + timestampField_.AddEntriesFrom(ref input, _map_timestampField_codec); + break; + } + case 74: { + typeField_.AddEntriesFrom(ref input, _map_typeField_codec); + break; + } + case 82: { + doubleField_.AddEntriesFrom(ref input, _map_doubleField_codec); + break; + } + case 90: { + floatField_.AddEntriesFrom(ref input, _map_floatField_codec); + break; + } + case 98: { + int64Field_.AddEntriesFrom(ref input, _map_int64Field_codec); + break; + } + case 106: { + uint64Field_.AddEntriesFrom(ref input, _map_uint64Field_codec); + break; + } + case 114: { + int32Field_.AddEntriesFrom(ref input, _map_int32Field_codec); + break; + } + case 122: { + uint32Field_.AddEntriesFrom(ref input, _map_uint32Field_codec); + break; + } + case 130: { + boolField_.AddEntriesFrom(ref input, _map_boolField_codec); + break; + } + case 138: { + stringField_.AddEntriesFrom(ref input, _map_stringField_codec); + break; + } + case 146: { + bytesField_.AddEntriesFrom(ref input, _map_bytesField_codec); + break; + } + } + } + } + #endif + } #endregion diff --git a/csharp/src/Google.Protobuf.Test/Buffers/ArrayBufferWriter.cs b/csharp/src/Google.Protobuf.Test/Buffers/ArrayBufferWriter.cs new file mode 100644 index 000000000000..8166fe12f090 --- /dev/null +++ b/csharp/src/Google.Protobuf.Test/Buffers/ArrayBufferWriter.cs @@ -0,0 +1,215 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY +using System; +using System.Buffers; +using System.Diagnostics; + +namespace Google.Protobuf.Buffers +{ + /// + /// Represents a heap-based, array-backed output sink into which data can be written. + /// + /// ArrayBufferWriter is originally from corefx, and has been contributed to Protobuf + /// https://github.com/dotnet/runtime/blob/071da4c41aa808c949a773b92dca6f88de9d11f3/src/libraries/Common/src/System/Buffers/ArrayBufferWriter.cs + /// + internal sealed class ArrayBufferWriter : IBufferWriter + { + private T[] _buffer; + private int _index; + + private const int DefaultInitialBufferSize = 256; + + /// + /// Creates an instance of an , in which data can be written to, + /// with the default initial capacity. + /// + public ArrayBufferWriter() + { + _buffer = new T[0]; + _index = 0; + } + + /// + /// Creates an instance of an , in which data can be written to, + /// with an initial capacity specified. + /// + /// The minimum capacity with which to initialize the underlying buffer. + /// + /// Thrown when is not positive (i.e. less than or equal to 0). + /// + public ArrayBufferWriter(int initialCapacity) + { + if (initialCapacity <= 0) + throw new ArgumentException(nameof(initialCapacity)); + + _buffer = new T[initialCapacity]; + _index = 0; + } + + /// + /// Returns the data written to the underlying buffer so far, as a . + /// + public ReadOnlyMemory WrittenMemory => _buffer.AsMemory(0, _index); + + /// + /// Returns the data written to the underlying buffer so far, as a . + /// + public ReadOnlySpan WrittenSpan => _buffer.AsSpan(0, _index); + + /// + /// Returns the amount of data written to the underlying buffer so far. + /// + public int WrittenCount => _index; + + /// + /// Returns the total amount of space within the underlying buffer. + /// + public int Capacity => _buffer.Length; + + /// + /// Returns the amount of space available that can still be written into without forcing the underlying buffer to grow. + /// + public int FreeCapacity => _buffer.Length - _index; + + /// + /// Clears the data written to the underlying buffer. + /// + /// + /// You must clear the before trying to re-use it. + /// + public void Clear() + { + Debug.Assert(_buffer.Length >= _index); + _buffer.AsSpan(0, _index).Clear(); + _index = 0; + } + + /// + /// Notifies that amount of data was written to the output / + /// + /// + /// Thrown when is negative. + /// + /// + /// Thrown when attempting to advance past the end of the underlying buffer. + /// + /// + /// You must request a new buffer after calling Advance to continue writing more data and cannot write to a previously acquired buffer. + /// + public void Advance(int count) + { + if (count < 0) + throw new ArgumentException(nameof(count)); + + if (_index > _buffer.Length - count) + throw new InvalidOperationException("Advanced past capacity."); + + _index += count; + } + + /// + /// Returns a to write to that is at least the requested length (specified by ). + /// If no is provided (or it's equal to 0), some non-empty buffer is returned. + /// + /// + /// Thrown when is negative. + /// + /// + /// This will never return an empty . + /// + /// + /// There is no guarantee that successive calls will return the same buffer or the same-sized buffer. + /// + /// + /// You must request a new buffer after calling Advance to continue writing more data and cannot write to a previously acquired buffer. + /// + public Memory GetMemory(int sizeHint = 0) + { + CheckAndResizeBuffer(sizeHint); + Debug.Assert(_buffer.Length > _index); + return _buffer.AsMemory(_index); + } + + /// + /// Returns a to write to that is at least the requested length (specified by ). + /// If no is provided (or it's equal to 0), some non-empty buffer is returned. + /// + /// + /// Thrown when is negative. + /// + /// + /// This will never return an empty . + /// + /// + /// There is no guarantee that successive calls will return the same buffer or the same-sized buffer. + /// + /// + /// You must request a new buffer after calling Advance to continue writing more data and cannot write to a previously acquired buffer. + /// + public Span GetSpan(int sizeHint = 0) + { + CheckAndResizeBuffer(sizeHint); + Debug.Assert(_buffer.Length > _index); + return _buffer.AsSpan(_index); + } + + private void CheckAndResizeBuffer(int sizeHint) + { + if (sizeHint < 0) + throw new ArgumentException(nameof(sizeHint)); + + if (sizeHint == 0) + { + sizeHint = 1; + } + + if (sizeHint > FreeCapacity) + { + int growBy = Math.Max(sizeHint, _buffer.Length); + + if (_buffer.Length == 0) + { + growBy = Math.Max(growBy, DefaultInitialBufferSize); + } + + int newSize = checked(_buffer.Length + growBy); + + Array.Resize(ref _buffer, newSize); + } + + Debug.Assert(FreeCapacity > 0 && FreeCapacity >= sizeHint); + } + } +} +#endif \ No newline at end of file diff --git a/csharp/src/Google.Protobuf.Test/Buffers/MaxSizeHintBufferWriter.cs b/csharp/src/Google.Protobuf.Test/Buffers/MaxSizeHintBufferWriter.cs new file mode 100644 index 000000000000..5b2b89972d80 --- /dev/null +++ b/csharp/src/Google.Protobuf.Test/Buffers/MaxSizeHintBufferWriter.cs @@ -0,0 +1,76 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY +using System; +using System.Buffers; + +namespace Google.Protobuf.Buffers +{ + internal class MaxSizeHintBufferWriter : IBufferWriter + { + private readonly IBufferWriter bufferWriter; + private readonly int maxSizeHint; + + public MaxSizeHintBufferWriter(IBufferWriter bufferWriter, int maxSizeHint) + { + this.bufferWriter = bufferWriter; + this.maxSizeHint = maxSizeHint; + } + + public void Advance(int count) + { + bufferWriter.Advance(count); + } + + public Memory GetMemory(int sizeHint = 0) + { + if (sizeHint == 0) + { + sizeHint = maxSizeHint; + } + // IBufferWriter contract defines that when a size is specified then that is the minimum size returned + return bufferWriter.GetMemory(sizeHint); + } + + public Span GetSpan(int sizeHint = 0) + { + if (sizeHint == 0) + { + sizeHint = maxSizeHint; + } + // IBufferWriter contract defines that when a size is specified then that is the minimum size returned + return bufferWriter.GetSpan(sizeHint); + } + } +} +#endif \ No newline at end of file diff --git a/csharp/src/Google.Protobuf.Test/Buffers/ReadOnlySequenceFactory.cs b/csharp/src/Google.Protobuf.Test/Buffers/ReadOnlySequenceFactory.cs new file mode 100644 index 000000000000..0112a6ece993 --- /dev/null +++ b/csharp/src/Google.Protobuf.Test/Buffers/ReadOnlySequenceFactory.cs @@ -0,0 +1,130 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY +using System; +using System.Buffers; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Google.Protobuf.Buffers +{ + internal static class ReadOnlySequenceFactory + { + public static ReadOnlySequence CreateWithContent(byte[] data, int segmentSize = 1) + { + var segments = new List(); + + segments.Add(new byte[0]); + var currentIndex = 0; + while (currentIndex < data.Length) + { + var segment = new List(); + for (; currentIndex < Math.Min(currentIndex + segmentSize, data.Length); currentIndex++) + { + segment.Add(data[currentIndex]); + } + segments.Add(segment.ToArray()); + segments.Add(new byte[0]); + } + + return CreateSegments(segments.ToArray()); + } + + /// + /// Originally from corefx, and has been contributed to Protobuf + /// https://github.com/dotnet/corefx/blob/e99ec129cfd594d53f4390bf97d1d736cff6f860/src/System.Memory/tests/ReadOnlyBuffer/ReadOnlySequenceFactory.byte.cs + /// + private static ReadOnlySequence CreateSegments(params byte[][] inputs) + { + if (inputs == null || inputs.Length == 0) + { + throw new InvalidOperationException(); + } + + int i = 0; + + BufferSegment last = null; + BufferSegment first = null; + + do + { + byte[] s = inputs[i]; + int length = s.Length; + int dataOffset = length; + var chars = new byte[length * 2]; + + for (int j = 0; j < length; j++) + { + chars[dataOffset + j] = s[j]; + } + + // Create a segment that has offset relative to the OwnedMemory and OwnedMemory itself has offset relative to array + var memory = new Memory(chars).Slice(length, length); + + if (first == null) + { + first = new BufferSegment(memory); + last = first; + } + else + { + last = last.Append(memory); + } + i++; + } while (i < inputs.Length); + + return new ReadOnlySequence(first, 0, last, last.Memory.Length); + } + + private class BufferSegment : ReadOnlySequenceSegment + { + public BufferSegment(Memory memory) + { + Memory = memory; + } + + public BufferSegment Append(Memory memory) + { + var segment = new BufferSegment(memory) + { + RunningIndex = RunningIndex + Memory.Length + }; + Next = segment; + return segment; + } + } + } +} +#endif diff --git a/csharp/src/Google.Protobuf.Test/CodedInputStreamExtensions.cs b/csharp/src/Google.Protobuf.Test/CodedInputExtensions.cs similarity index 79% rename from csharp/src/Google.Protobuf.Test/CodedInputStreamExtensions.cs rename to csharp/src/Google.Protobuf.Test/CodedInputExtensions.cs index 23af28870ab4..ab962b6d9db3 100644 --- a/csharp/src/Google.Protobuf.Test/CodedInputStreamExtensions.cs +++ b/csharp/src/Google.Protobuf.Test/CodedInputExtensions.cs @@ -34,7 +34,7 @@ namespace Google.Protobuf { - internal static class CodedInputStreamExtensions + internal static class CodedInputExtensions { public static void AssertNextTag(this CodedInputStream input, uint expectedTag) { @@ -49,5 +49,21 @@ public static T ReadMessage(this CodedInputStream stream, MessageParser pa stream.ReadMessage(message); return message; } + +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + public static void AssertNextTag(this ref CodedInputReader input, uint expectedTag) + { + uint tag = input.ReadTag(); + Assert.AreEqual(expectedTag, tag); + } + + public static T ReadMessage(this ref CodedInputReader input, MessageParser parser) + where T : IMessage + { + var message = parser.CreateTemplate(); + input.ReadMessage((IBufferMessage)message); + return message; + } +#endif } } diff --git a/csharp/src/Google.Protobuf.Test/CodedInputReaderTest.cs b/csharp/src/Google.Protobuf.Test/CodedInputReaderTest.cs new file mode 100644 index 000000000000..a9da432ae4f6 --- /dev/null +++ b/csharp/src/Google.Protobuf.Test/CodedInputReaderTest.cs @@ -0,0 +1,419 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY +using System; +using System.Buffers; +using System.IO; +using Google.Protobuf.Buffers; +using Google.Protobuf.TestProtos; +using NUnit.Framework; + +namespace Google.Protobuf +{ + public class CodedInputReaderTest : CodedInputTestBase + { + [Test] + public void ReadWholeMessage_VaryingSegmentSizes() + { + TestAllTypes message = SampleMessages.CreateFullTestAllTypes(); + + byte[] rawBytes = message.ToByteArray(); + Assert.AreEqual(rawBytes.Length, message.CalculateSize()); + TestAllTypes message2 = TestAllTypes.Parser.ParseFrom(new ReadOnlySequence(rawBytes)); + Assert.AreEqual(message, message2); + + // Try different block sizes. + for (int blockSize = 1; blockSize < 256; blockSize *= 2) + { + message2 = TestAllTypes.Parser.ParseFrom(ReadOnlySequenceFactory.CreateWithContent(rawBytes, blockSize)); + Assert.AreEqual(message, message2); + } + } + + [Test] + public void ReadMaliciouslyLargeBlob() + { + MemoryStream ms = new MemoryStream(); + CodedOutputStream output = new CodedOutputStream(ms); + + uint tag = WireFormat.MakeTag(1, WireFormat.WireType.LengthDelimited); + output.WriteRawVarint32(tag); + output.WriteRawVarint32(0x7FFFFFFF); + output.WriteRawBytes(new byte[32]); // Pad with a few random bytes. + output.Flush(); + ms.Position = 0; + + CodedInputReader input = new CodedInputReader(new ReadOnlySequence(ms.ToArray())); + Assert.AreEqual(tag, input.ReadTag()); + + try + { + input.ReadBytes(); + Assert.Fail(); + } + catch (InvalidProtocolBufferException) + { + } + } + + /// + /// Tests that if we read an string that contains invalid UTF-8, no exception + /// is thrown. Instead, the invalid bytes are replaced with the Unicode + /// "replacement character" U+FFFD. + /// + [Test] + public void ReadInvalidUtf8() + { + MemoryStream ms = new MemoryStream(); + CodedOutputStream output = new CodedOutputStream(ms); + + uint tag = WireFormat.MakeTag(1, WireFormat.WireType.LengthDelimited); + output.WriteRawVarint32(tag); + output.WriteRawVarint32(1); + output.WriteRawBytes(new byte[] {0x80}); + output.Flush(); + ms.Position = 0; + + CodedInputReader input = new CodedInputReader(new ReadOnlySequence(ms.ToArray())); + + Assert.AreEqual(tag, input.ReadTag()); + string text = input.ReadString(); + Assert.AreEqual('\ufffd', text[0]); + } + + [Test] + public void ReadNegativeSizedStringThrowsInvalidProtocolBufferException() + { + MemoryStream ms = new MemoryStream(); + CodedOutputStream output = new CodedOutputStream(ms); + + uint tag = WireFormat.MakeTag(1, WireFormat.WireType.LengthDelimited); + output.WriteRawVarint32(tag); + output.WriteLength(-1); + output.Flush(); + ms.Position = 0; + + CodedInputReader input = new CodedInputReader(new ReadOnlySequence(ms.ToArray())); + + Assert.AreEqual(tag, input.ReadTag()); + try + { + input.ReadString(); + Assert.Fail(); + } + catch (InvalidProtocolBufferException) + { + } + } + + [Test] + public void ReadNegativeSizedBytesThrowsInvalidProtocolBufferException() + { + MemoryStream ms = new MemoryStream(); + CodedOutputStream output = new CodedOutputStream(ms); + + uint tag = WireFormat.MakeTag(1, WireFormat.WireType.LengthDelimited); + output.WriteRawVarint32(tag); + output.WriteLength(-1); + output.Flush(); + ms.Position = 0; + + CodedInputReader input = new CodedInputReader(new ReadOnlySequence(ms.ToArray())); + + Assert.AreEqual(tag, input.ReadTag()); + try + { + input.ReadBytes(); + Assert.Fail(); + } + catch (InvalidProtocolBufferException) + { + } + } + + [Test] + public void SkipGroup() + { + // Create an output stream with a group in: + // Field 1: string "field 1" + // Field 2: group containing: + // Field 1: fixed int32 value 100 + // Field 2: string "ignore me" + // Field 3: nested group containing + // Field 1: fixed int64 value 1000 + // Field 3: string "field 3" + var stream = new MemoryStream(); + var output = new CodedOutputStream(stream); + output.WriteTag(1, WireFormat.WireType.LengthDelimited); + output.WriteString("field 1"); + + // The outer group... + output.WriteTag(2, WireFormat.WireType.StartGroup); + output.WriteTag(1, WireFormat.WireType.Fixed32); + output.WriteFixed32(100); + output.WriteTag(2, WireFormat.WireType.LengthDelimited); + output.WriteString("ignore me"); + // The nested group... + output.WriteTag(3, WireFormat.WireType.StartGroup); + output.WriteTag(1, WireFormat.WireType.Fixed64); + output.WriteFixed64(1000); + // Note: Not sure the field number is relevant for end group... + output.WriteTag(3, WireFormat.WireType.EndGroup); + + // End the outer group + output.WriteTag(2, WireFormat.WireType.EndGroup); + + output.WriteTag(3, WireFormat.WireType.LengthDelimited); + output.WriteString("field 3"); + output.Flush(); + stream.Position = 0; + + // Now act like a generated client + var input = new CodedInputReader(new ReadOnlySequence(stream.ToArray())); + Assert.AreEqual(WireFormat.MakeTag(1, WireFormat.WireType.LengthDelimited), input.ReadTag()); + Assert.AreEqual("field 1", input.ReadString()); + Assert.AreEqual(WireFormat.MakeTag(2, WireFormat.WireType.StartGroup), input.ReadTag()); + input.SkipLastField(); // Should consume the whole group, including the nested one. + Assert.AreEqual(WireFormat.MakeTag(3, WireFormat.WireType.LengthDelimited), input.ReadTag()); + Assert.AreEqual("field 3", input.ReadString()); + } + + [Test] + public void SkipGroup_WrongEndGroupTag() + { + // Create an output stream with: + // Field 1: string "field 1" + // Start group 2 + // Field 3: fixed int32 + // End group 4 (should give an error) + var stream = new MemoryStream(); + var output = new CodedOutputStream(stream); + output.WriteTag(1, WireFormat.WireType.LengthDelimited); + output.WriteString("field 1"); + + // The outer group... + output.WriteTag(2, WireFormat.WireType.StartGroup); + output.WriteTag(3, WireFormat.WireType.Fixed32); + output.WriteFixed32(100); + output.WriteTag(4, WireFormat.WireType.EndGroup); + output.Flush(); + stream.Position = 0; + + // Now act like a generated client + var input = new CodedInputReader(new ReadOnlySequence(stream.ToArray())); + Assert.AreEqual(WireFormat.MakeTag(1, WireFormat.WireType.LengthDelimited), input.ReadTag()); + Assert.AreEqual("field 1", input.ReadString()); + Assert.AreEqual(WireFormat.MakeTag(2, WireFormat.WireType.StartGroup), input.ReadTag()); + + try + { + input.SkipLastField(); + Assert.Fail(); + } + catch (InvalidProtocolBufferException) + { + } + } + + [Test] + public void RogueEndGroupTag() + { + // If we have an end-group tag without a leading start-group tag, generated + // code will just call SkipLastField... so that should fail. + + var stream = new MemoryStream(); + var output = new CodedOutputStream(stream); + output.WriteTag(1, WireFormat.WireType.EndGroup); + output.Flush(); + stream.Position = 0; + + var input = new CodedInputReader(new ReadOnlySequence(stream.ToArray())); + Assert.AreEqual(WireFormat.MakeTag(1, WireFormat.WireType.EndGroup), input.ReadTag()); + + try + { + input.SkipLastField(); + Assert.Fail(); + } + catch (InvalidProtocolBufferException) + { + } + } + + [Test] + public void EndOfStreamReachedWhileSkippingGroup() + { + var stream = new MemoryStream(); + var output = new CodedOutputStream(stream); + output.WriteTag(1, WireFormat.WireType.StartGroup); + output.WriteTag(2, WireFormat.WireType.StartGroup); + output.WriteTag(2, WireFormat.WireType.EndGroup); + + output.Flush(); + stream.Position = 0; + + // Now act like a generated client + var input = new CodedInputReader(new ReadOnlySequence(stream.ToArray())); + input.ReadTag(); + + try + { + input.SkipLastField(); + Assert.Fail(); + } + catch (InvalidProtocolBufferException) + { + } + } + + [Test] + public void RecursionLimitAppliedWhileSkippingGroup() + { + var stream = new MemoryStream(); + var output = new CodedOutputStream(stream); + for (int i = 0; i < CodedInputStream.DefaultRecursionLimit + 1; i++) + { + output.WriteTag(1, WireFormat.WireType.StartGroup); + } + for (int i = 0; i < CodedInputStream.DefaultRecursionLimit + 1; i++) + { + output.WriteTag(1, WireFormat.WireType.EndGroup); + } + output.Flush(); + stream.Position = 0; + + // Now act like a generated client + var input = new CodedInputReader(new ReadOnlySequence(stream.ToArray())); + Assert.AreEqual(WireFormat.MakeTag(1, WireFormat.WireType.StartGroup), input.ReadTag()); + + try + { + input.SkipLastField(); + Assert.Fail(); + } + catch (InvalidProtocolBufferException) + { + } + } + + protected override void AssertReadVarint(byte[] data, ulong value) + { + CodedInputReader input = new CodedInputReader(new ReadOnlySequence(data)); + Assert.AreEqual((uint)value, input.ReadRawVarint32()); + + Assert.AreEqual(true, input.IsAtEnd); + + input = new CodedInputReader(new ReadOnlySequence(data)); + Assert.AreEqual(value, input.ReadRawVarint64()); + + Assert.AreEqual(true, input.IsAtEnd); + } + + protected override void AssertReadVarintFailure(InvalidProtocolBufferException expected, byte[] data) + { + var exception = Assert.Throws(() => + { + CodedInputReader input = new CodedInputReader(new ReadOnlySequence(data)); + input.ReadRawVarint32(); + }); + Assert.AreEqual(expected.Message, exception.Message); + + exception = Assert.Throws(() => + { + CodedInputReader input = new CodedInputReader(new ReadOnlySequence(data)); + input.ReadRawVarint64(); + }); + Assert.AreEqual(expected.Message, exception.Message); + } + + protected override void AssertReadLittleEndian32(byte[] data, uint value) + { + CodedInputReader input = new CodedInputReader(new ReadOnlySequence(data)); + Assert.AreEqual(value, input.ReadRawLittleEndian32()); + Assert.IsTrue(input.IsAtEnd); + } + + protected override void AssertReadLittleEndian64(byte[] data, ulong value) + { + CodedInputReader input = new CodedInputReader(new ReadOnlySequence(data)); + Assert.AreEqual(value, input.ReadRawLittleEndian64()); + Assert.IsTrue(input.IsAtEnd); + } + + protected override void ReadTag(byte[] data) + { + CodedInputReader input = new CodedInputReader(new ReadOnlySequence(data)); + input.ReadTag(); + } + + protected override void AssertEnum(byte[] data, int value) + { + CodedInputReader input = new CodedInputReader(new ReadOnlySequence(data)); + Assert.AreEqual(value, input.ReadEnum()); + Assert.IsTrue(input.IsAtEnd); + } + + protected override void AssertReadFloat(byte[] data, float value) + { + CodedInputReader input = new CodedInputReader(new ReadOnlySequence(data)); + + Assert.AreEqual(value, input.ReadFloat()); + Assert.IsTrue(input.IsAtEnd); + } + + protected override void AssertReadDouble(byte[] data, double value) + { + CodedInputReader input = new CodedInputReader(new ReadOnlySequence(data)); + + Assert.AreEqual(value, input.ReadDouble()); + Assert.IsTrue(input.IsAtEnd); + } + + protected override T ParseFrom(MessageParser messageParser, ByteString bytes) + { + CodedInputReader input = new CodedInputReader(new ReadOnlySequence(bytes.ToByteArray())); + return messageParser.ParseFrom(ref input); + } + + protected override T ParseFromWithLimits(MessageParser messageParser, ByteString bytes, int sizeLimit, int resursionLimits) + { + if (sizeLimit != int.MaxValue) + { + throw new ArgumentException("sizeLimit not supported when parsing with CodedInputReader", nameof(sizeLimit)); + } + CodedInputReader input = CodedInputReader.CreateWithLimits(new ReadOnlySequence(bytes.ToByteArray()), resursionLimits); + return messageParser.ParseFrom(ref input); + } + } +} +#endif \ No newline at end of file diff --git a/csharp/src/Google.Protobuf.Test/CodedInputStreamTest.cs b/csharp/src/Google.Protobuf.Test/CodedInputStreamTest.cs index ba65b328e806..30762dc927b6 100644 --- a/csharp/src/Google.Protobuf.Test/CodedInputStreamTest.cs +++ b/csharp/src/Google.Protobuf.Test/CodedInputStreamTest.cs @@ -37,195 +37,8 @@ namespace Google.Protobuf { - public class CodedInputStreamTest + public class CodedInputStreamTest : CodedInputTestBase { - /// - /// Helper to construct a byte array from a bunch of bytes. The inputs are - /// actually ints so that I can use hex notation and not get stupid errors - /// about precision. - /// - private static byte[] Bytes(params int[] bytesAsInts) - { - byte[] bytes = new byte[bytesAsInts.Length]; - for (int i = 0; i < bytesAsInts.Length; i++) - { - bytes[i] = (byte) bytesAsInts[i]; - } - return bytes; - } - - /// - /// Parses the given bytes using ReadRawVarint32() and ReadRawVarint64() - /// - private static void AssertReadVarint(byte[] data, ulong value) - { - CodedInputStream input = new CodedInputStream(data); - Assert.AreEqual((uint) value, input.ReadRawVarint32()); - - input = new CodedInputStream(data); - Assert.AreEqual(value, input.ReadRawVarint64()); - Assert.IsTrue(input.IsAtEnd); - - // Try different block sizes. - for (int bufferSize = 1; bufferSize <= 16; bufferSize *= 2) - { - input = new CodedInputStream(new SmallBlockInputStream(data, bufferSize)); - Assert.AreEqual((uint) value, input.ReadRawVarint32()); - - input = new CodedInputStream(new SmallBlockInputStream(data, bufferSize)); - Assert.AreEqual(value, input.ReadRawVarint64()); - Assert.IsTrue(input.IsAtEnd); - } - - // Try reading directly from a MemoryStream. We want to verify that it - // doesn't read past the end of the input, so write an extra byte - this - // lets us test the position at the end. - MemoryStream memoryStream = new MemoryStream(); - memoryStream.Write(data, 0, data.Length); - memoryStream.WriteByte(0); - memoryStream.Position = 0; - Assert.AreEqual((uint) value, CodedInputStream.ReadRawVarint32(memoryStream)); - Assert.AreEqual(data.Length, memoryStream.Position); - } - - /// - /// Parses the given bytes using ReadRawVarint32() and ReadRawVarint64() and - /// expects them to fail with an InvalidProtocolBufferException whose - /// description matches the given one. - /// - private static void AssertReadVarintFailure(InvalidProtocolBufferException expected, byte[] data) - { - CodedInputStream input = new CodedInputStream(data); - var exception = Assert.Throws(() => input.ReadRawVarint32()); - Assert.AreEqual(expected.Message, exception.Message); - - input = new CodedInputStream(data); - exception = Assert.Throws(() => input.ReadRawVarint64()); - Assert.AreEqual(expected.Message, exception.Message); - - // Make sure we get the same error when reading directly from a Stream. - exception = Assert.Throws(() => CodedInputStream.ReadRawVarint32(new MemoryStream(data))); - Assert.AreEqual(expected.Message, exception.Message); - } - - [Test] - public void ReadVarint() - { - AssertReadVarint(Bytes(0x00), 0); - AssertReadVarint(Bytes(0x01), 1); - AssertReadVarint(Bytes(0x7f), 127); - // 14882 - AssertReadVarint(Bytes(0xa2, 0x74), (0x22 << 0) | (0x74 << 7)); - // 2961488830 - AssertReadVarint(Bytes(0xbe, 0xf7, 0x92, 0x84, 0x0b), - (0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) | - (0x0bL << 28)); - - // 64-bit - // 7256456126 - AssertReadVarint(Bytes(0xbe, 0xf7, 0x92, 0x84, 0x1b), - (0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) | - (0x1bL << 28)); - // 41256202580718336 - AssertReadVarint(Bytes(0x80, 0xe6, 0xeb, 0x9c, 0xc3, 0xc9, 0xa4, 0x49), - (0x00 << 0) | (0x66 << 7) | (0x6b << 14) | (0x1c << 21) | - (0x43L << 28) | (0x49L << 35) | (0x24L << 42) | (0x49L << 49)); - // 11964378330978735131 - AssertReadVarint(Bytes(0x9b, 0xa8, 0xf9, 0xc2, 0xbb, 0xd6, 0x80, 0x85, 0xa6, 0x01), - (0x1b << 0) | (0x28 << 7) | (0x79 << 14) | (0x42 << 21) | - (0x3bUL << 28) | (0x56UL << 35) | (0x00UL << 42) | - (0x05UL << 49) | (0x26UL << 56) | (0x01UL << 63)); - - // Failures - AssertReadVarintFailure( - InvalidProtocolBufferException.MalformedVarint(), - Bytes(0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x00)); - AssertReadVarintFailure( - InvalidProtocolBufferException.TruncatedMessage(), - Bytes(0x80)); - } - - /// - /// Parses the given bytes using ReadRawLittleEndian32() and checks - /// that the result matches the given value. - /// - private static void AssertReadLittleEndian32(byte[] data, uint value) - { - CodedInputStream input = new CodedInputStream(data); - Assert.AreEqual(value, input.ReadRawLittleEndian32()); - Assert.IsTrue(input.IsAtEnd); - - // Try different block sizes. - for (int blockSize = 1; blockSize <= 16; blockSize *= 2) - { - input = new CodedInputStream( - new SmallBlockInputStream(data, blockSize)); - Assert.AreEqual(value, input.ReadRawLittleEndian32()); - Assert.IsTrue(input.IsAtEnd); - } - } - - /// - /// Parses the given bytes using ReadRawLittleEndian64() and checks - /// that the result matches the given value. - /// - private static void AssertReadLittleEndian64(byte[] data, ulong value) - { - CodedInputStream input = new CodedInputStream(data); - Assert.AreEqual(value, input.ReadRawLittleEndian64()); - Assert.IsTrue(input.IsAtEnd); - - // Try different block sizes. - for (int blockSize = 1; blockSize <= 16; blockSize *= 2) - { - input = new CodedInputStream( - new SmallBlockInputStream(data, blockSize)); - Assert.AreEqual(value, input.ReadRawLittleEndian64()); - Assert.IsTrue(input.IsAtEnd); - } - } - - [Test] - public void ReadLittleEndian() - { - AssertReadLittleEndian32(Bytes(0x78, 0x56, 0x34, 0x12), 0x12345678); - AssertReadLittleEndian32(Bytes(0xf0, 0xde, 0xbc, 0x9a), 0x9abcdef0); - - AssertReadLittleEndian64(Bytes(0xf0, 0xde, 0xbc, 0x9a, 0x78, 0x56, 0x34, 0x12), - 0x123456789abcdef0L); - AssertReadLittleEndian64( - Bytes(0x78, 0x56, 0x34, 0x12, 0xf0, 0xde, 0xbc, 0x9a), 0x9abcdef012345678UL); - } - - [Test] - public void DecodeZigZag32() - { - Assert.AreEqual(0, CodedInputStream.DecodeZigZag32(0)); - Assert.AreEqual(-1, CodedInputStream.DecodeZigZag32(1)); - Assert.AreEqual(1, CodedInputStream.DecodeZigZag32(2)); - Assert.AreEqual(-2, CodedInputStream.DecodeZigZag32(3)); - Assert.AreEqual(0x3FFFFFFF, CodedInputStream.DecodeZigZag32(0x7FFFFFFE)); - Assert.AreEqual(unchecked((int) 0xC0000000), CodedInputStream.DecodeZigZag32(0x7FFFFFFF)); - Assert.AreEqual(0x7FFFFFFF, CodedInputStream.DecodeZigZag32(0xFFFFFFFE)); - Assert.AreEqual(unchecked((int) 0x80000000), CodedInputStream.DecodeZigZag32(0xFFFFFFFF)); - } - - [Test] - public void DecodeZigZag64() - { - Assert.AreEqual(0, CodedInputStream.DecodeZigZag64(0)); - Assert.AreEqual(-1, CodedInputStream.DecodeZigZag64(1)); - Assert.AreEqual(1, CodedInputStream.DecodeZigZag64(2)); - Assert.AreEqual(-2, CodedInputStream.DecodeZigZag64(3)); - Assert.AreEqual(0x000000003FFFFFFFL, CodedInputStream.DecodeZigZag64(0x000000007FFFFFFEL)); - Assert.AreEqual(unchecked((long) 0xFFFFFFFFC0000000L), CodedInputStream.DecodeZigZag64(0x000000007FFFFFFFL)); - Assert.AreEqual(0x000000007FFFFFFFL, CodedInputStream.DecodeZigZag64(0x00000000FFFFFFFEL)); - Assert.AreEqual(unchecked((long) 0xFFFFFFFF80000000L), CodedInputStream.DecodeZigZag64(0x00000000FFFFFFFFL)); - Assert.AreEqual(0x7FFFFFFFFFFFFFFFL, CodedInputStream.DecodeZigZag64(0xFFFFFFFFFFFFFFFEL)); - Assert.AreEqual(unchecked((long) 0x8000000000000000L), CodedInputStream.DecodeZigZag64(0xFFFFFFFFFFFFFFFFL)); - } - [Test] public void ReadWholeMessage_VaryingBlockSizes() { @@ -243,109 +56,13 @@ public void ReadWholeMessage_VaryingBlockSizes() Assert.AreEqual(message, message2); } } - - [Test] - public void ReadHugeBlob() - { - // Allocate and initialize a 1MB blob. - byte[] blob = new byte[1 << 20]; - for (int i = 0; i < blob.Length; i++) - { - blob[i] = (byte) i; - } - - // Make a message containing it. - var message = new TestAllTypes { SingleBytes = ByteString.CopyFrom(blob) }; - - // Serialize and parse it. Make sure to parse from an InputStream, not - // directly from a ByteString, so that CodedInputStream uses buffered - // reading. - TestAllTypes message2 = TestAllTypes.Parser.ParseFrom(message.ToByteString()); - - Assert.AreEqual(message, message2); - } - - [Test] - public void ReadMaliciouslyLargeBlob() - { - MemoryStream ms = new MemoryStream(); - CodedOutputStream output = new CodedOutputStream(ms); - - uint tag = WireFormat.MakeTag(1, WireFormat.WireType.LengthDelimited); - output.WriteRawVarint32(tag); - output.WriteRawVarint32(0x7FFFFFFF); - output.WriteRawBytes(new byte[32]); // Pad with a few random bytes. - output.Flush(); - ms.Position = 0; - - CodedInputStream input = new CodedInputStream(ms); - Assert.AreEqual(tag, input.ReadTag()); - - Assert.Throws(() => input.ReadBytes()); - } - - // Representations of a tag for field 0 with various wire types - [Test] - [TestCase(0)] - [TestCase(1)] - [TestCase(2)] - [TestCase(3)] - [TestCase(4)] - [TestCase(5)] - public void ReadTag_ZeroFieldRejected(byte tag) - { - CodedInputStream cis = new CodedInputStream(new byte[] { tag }); - Assert.Throws(() => cis.ReadTag()); - } - - internal static TestRecursiveMessage MakeRecursiveMessage(int depth) - { - if (depth == 0) - { - return new TestRecursiveMessage { I = 5 }; - } - else - { - return new TestRecursiveMessage { A = MakeRecursiveMessage(depth - 1) }; - } - } - - internal static void AssertMessageDepth(TestRecursiveMessage message, int depth) - { - if (depth == 0) - { - Assert.IsNull(message.A); - Assert.AreEqual(5, message.I); - } - else - { - Assert.IsNotNull(message.A); - AssertMessageDepth(message.A, depth - 1); - } - } - - [Test] - public void MaliciousRecursion() - { - ByteString atRecursiveLimit = MakeRecursiveMessage(CodedInputStream.DefaultRecursionLimit).ToByteString(); - ByteString beyondRecursiveLimit = MakeRecursiveMessage(CodedInputStream.DefaultRecursionLimit + 1).ToByteString(); - - AssertMessageDepth(TestRecursiveMessage.Parser.ParseFrom(atRecursiveLimit), CodedInputStream.DefaultRecursionLimit); - - Assert.Throws(() => TestRecursiveMessage.Parser.ParseFrom(beyondRecursiveLimit)); - - CodedInputStream input = CodedInputStream.CreateWithLimits(new MemoryStream(atRecursiveLimit.ToByteArray()), 1000000, CodedInputStream.DefaultRecursionLimit - 1); - Assert.Throws(() => TestRecursiveMessage.Parser.ParseFrom(input)); - } [Test] public void SizeLimit() { - // Have to use a Stream rather than ByteString.CreateCodedInput as SizeLimit doesn't - // apply to the latter case. - MemoryStream ms = new MemoryStream(SampleMessages.CreateFullTestAllTypes().ToByteArray()); - CodedInputStream input = CodedInputStream.CreateWithLimits(ms, 16, 100); - Assert.Throws(() => TestAllTypes.Parser.ParseFrom(input)); + var data = ByteString.CopyFrom(SampleMessages.CreateFullTestAllTypes().ToByteArray()); + + Assert.Throws(() => ParseFromWithLimits(TestAllTypes.Parser, data, sizeLimit: 16, resursionLimits: 100)); } /// @@ -430,15 +147,6 @@ public override int Read(byte[] buffer, int offset, int count) } } - [Test] - public void TestNegativeEnum() - { - byte[] bytes = { 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01 }; - CodedInputStream input = new CodedInputStream(bytes); - Assert.AreEqual((int)SampleEnum.NegativeValue, input.ReadEnum()); - Assert.IsTrue(input.IsAtEnd); - } - //Issue 71: CodedInputStream.ReadBytes go to slow path unnecessarily [Test] public void TestSlowPathAvoidance() @@ -465,13 +173,6 @@ public void TestSlowPathAvoidance() } } - [Test] - public void Tag0Throws() - { - var input = new CodedInputStream(new byte[] { 0 }); - Assert.Throws(() => input.ReadTag()); - } - [Test] public void SkipGroup() { @@ -693,6 +394,124 @@ private static byte[] GenerateBigSerializedMessage() return message.ToByteArray(); } + protected override void AssertReadVarint(byte[] data, ulong value) + { + CodedInputStream input = new CodedInputStream(data); + Assert.AreEqual((uint)value, input.ReadRawVarint32()); + + input = new CodedInputStream(data); + Assert.AreEqual(value, input.ReadRawVarint64()); + Assert.IsTrue(input.IsAtEnd); + + // Try different block sizes. + for (int bufferSize = 1; bufferSize <= 16; bufferSize *= 2) + { + input = new CodedInputStream(new SmallBlockInputStream(data, bufferSize)); + Assert.AreEqual((uint)value, input.ReadRawVarint32()); + + input = new CodedInputStream(new SmallBlockInputStream(data, bufferSize)); + Assert.AreEqual(value, input.ReadRawVarint64()); + Assert.IsTrue(input.IsAtEnd); + } + + // Try reading directly from a MemoryStream. We want to verify that it + // doesn't read past the end of the input, so write an extra byte - this + // lets us test the position at the end. + MemoryStream memoryStream = new MemoryStream(); + memoryStream.Write(data, 0, data.Length); + memoryStream.WriteByte(0); + memoryStream.Position = 0; + Assert.AreEqual((uint)value, CodedInputStream.ReadRawVarint32(memoryStream)); + Assert.AreEqual(data.Length, memoryStream.Position); + } + + protected override void AssertReadVarintFailure(InvalidProtocolBufferException expected, byte[] data) + { + CodedInputStream input = new CodedInputStream(data); + var exception = Assert.Throws(() => input.ReadRawVarint32()); + Assert.AreEqual(expected.Message, exception.Message); + + input = new CodedInputStream(data); + exception = Assert.Throws(() => input.ReadRawVarint64()); + Assert.AreEqual(expected.Message, exception.Message); + + // Make sure we get the same error when reading directly from a Stream. + exception = Assert.Throws(() => CodedInputStream.ReadRawVarint32(new MemoryStream(data))); + Assert.AreEqual(expected.Message, exception.Message); + } + + protected override void AssertReadLittleEndian32(byte[] data, uint value) + { + CodedInputStream input = new CodedInputStream(data); + Assert.AreEqual(value, input.ReadRawLittleEndian32()); + Assert.IsTrue(input.IsAtEnd); + + // Try different block sizes. + for (int blockSize = 1; blockSize <= 16; blockSize *= 2) + { + input = new CodedInputStream( + new SmallBlockInputStream(data, blockSize)); + Assert.AreEqual(value, input.ReadRawLittleEndian32()); + Assert.IsTrue(input.IsAtEnd); + } + } + + protected override void AssertReadLittleEndian64(byte[] data, ulong value) + { + CodedInputStream input = new CodedInputStream(data); + Assert.AreEqual(value, input.ReadRawLittleEndian64()); + Assert.IsTrue(input.IsAtEnd); + + // Try different block sizes. + for (int blockSize = 1; blockSize <= 16; blockSize *= 2) + { + input = new CodedInputStream( + new SmallBlockInputStream(data, blockSize)); + Assert.AreEqual(value, input.ReadRawLittleEndian64()); + Assert.IsTrue(input.IsAtEnd); + } + } + + protected override void AssertEnum(byte[] data, int value) + { + CodedInputStream input = new CodedInputStream(data); + Assert.AreEqual(value, input.ReadEnum()); + Assert.IsTrue(input.IsAtEnd); + } + + protected override void ReadTag(byte[] data) + { + CodedInputStream input = new CodedInputStream(data); + input.ReadTag(); + } + + protected override void AssertReadFloat(byte[] data, float value) + { + CodedInputStream input = new CodedInputStream(data); + + Assert.AreEqual(value, input.ReadFloat()); + Assert.IsTrue(input.IsAtEnd); + } + + protected override void AssertReadDouble(byte[] data, double value) + { + CodedInputStream input = new CodedInputStream(data); + + Assert.AreEqual(value, input.ReadDouble()); + Assert.IsTrue(input.IsAtEnd); + } + + protected override T ParseFrom(MessageParser messageParser, ByteString bytes) + { + return messageParser.ParseFrom(bytes); + } + + protected override T ParseFromWithLimits(MessageParser messageParser, ByteString bytes, int sizeLimit, int resursionLimits) + { + CodedInputStream input = CodedInputStream.CreateWithLimits(new MemoryStream(bytes.ToByteArray()), sizeLimit, resursionLimits); + return messageParser.ParseFrom(input); + } + /// /// A MemoryStream that repeats a byte arrays' content a number of times. /// Simulates really large input without consuming loads of memory. Used above diff --git a/csharp/src/Google.Protobuf.Test/CodedInputTestBase.cs b/csharp/src/Google.Protobuf.Test/CodedInputTestBase.cs new file mode 100644 index 000000000000..95eac3e1c91d --- /dev/null +++ b/csharp/src/Google.Protobuf.Test/CodedInputTestBase.cs @@ -0,0 +1,279 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System.IO; +using Google.Protobuf.TestProtos; +using NUnit.Framework; + +namespace Google.Protobuf +{ + public abstract class CodedInputTestBase + { + /// + /// Helper to construct a byte array from a bunch of bytes. The inputs are + /// actually ints so that I can use hex notation and not get stupid errors + /// about precision. + /// + protected static byte[] Bytes(params int[] bytesAsInts) + { + byte[] bytes = new byte[bytesAsInts.Length]; + for (int i = 0; i < bytesAsInts.Length; i++) + { + bytes[i] = (byte) bytesAsInts[i]; + } + return bytes; + } + + /// + /// Parses the given bytes using ReadRawVarint32() and ReadRawVarint64() + /// + protected abstract void AssertReadVarint(byte[] data, ulong value); + + /// + /// Parses the given bytes using ReadRawVarint32() and ReadRawVarint64() and + /// expects them to fail with an InvalidProtocolBufferException whose + /// description matches the given one. + /// + protected abstract void AssertReadVarintFailure(InvalidProtocolBufferException expected, byte[] data); + + /// + /// Parses the given bytes using ReadRawLittleEndian32() and checks + /// that the result matches the given value. + /// + protected abstract void AssertReadLittleEndian32(byte[] data, uint value); + + /// + /// Parses the given bytes using ReadRawLittleEndian64() and checks + /// that the result matches the given value. + /// + protected abstract void AssertReadLittleEndian64(byte[] data, ulong value); + + protected abstract void AssertEnum(byte[] data, int value); + + protected abstract void ReadTag(byte[] data); + + protected abstract void AssertReadFloat(byte[] data, float value); + + protected abstract void AssertReadDouble(byte[] data, double value); + + protected abstract T ParseFrom(MessageParser messageParser, ByteString bytes) where T : IMessage; + + protected abstract T ParseFromWithLimits(MessageParser messageParser, ByteString bytes, int sizeLimit, int resursionLimits) where T : IMessage; + + internal static TestRecursiveMessage MakeRecursiveMessage(int depth) + { + if (depth == 0) + { + return new TestRecursiveMessage { I = 5 }; + } + else + { + return new TestRecursiveMessage { A = MakeRecursiveMessage(depth - 1) }; + } + } + + internal static void AssertMessageDepth(TestRecursiveMessage message, int depth) + { + if (depth == 0) + { + Assert.IsNull(message.A); + Assert.AreEqual(5, message.I); + } + else + { + Assert.IsNotNull(message.A); + AssertMessageDepth(message.A, depth - 1); + } + } + + [Test] + public void MaliciousRecursion() + { + ByteString atRecursiveLimit = MakeRecursiveMessage(CodedInputStream.DefaultRecursionLimit).ToByteString(); + ByteString beyondRecursiveLimit = MakeRecursiveMessage(CodedInputStream.DefaultRecursionLimit + 1).ToByteString(); + + AssertMessageDepth(ParseFrom(TestRecursiveMessage.Parser, atRecursiveLimit), CodedInputStream.DefaultRecursionLimit); + + Assert.Throws(() => ParseFrom(TestRecursiveMessage.Parser, beyondRecursiveLimit)); + + CodedInputStream input = CodedInputStream.CreateWithLimits(new MemoryStream(atRecursiveLimit.ToByteArray()), int.MaxValue, CodedInputStream.DefaultRecursionLimit - 1); + Assert.Throws(() => TestRecursiveMessage.Parser.ParseFrom(input)); + + Assert.Throws(() => ParseFromWithLimits(TestRecursiveMessage.Parser, atRecursiveLimit, sizeLimit: int.MaxValue, resursionLimits: CodedInputStream.DefaultRecursionLimit - 1)); + } + + [Test] + public void ReadHugeBlob() + { + // Allocate and initialize a 1MB blob. + byte[] blob = new byte[1 << 20]; + for (int i = 0; i < blob.Length; i++) + { + blob[i] = (byte)i; + } + + // Make a message containing it. + var message = new TestAllTypes { SingleBytes = ByteString.CopyFrom(blob) }; + + // Serialize and parse it. Make sure to parse from an InputStream, not + // directly from a ByteString, so that CodedInputStream uses buffered + // reading. + TestAllTypes message2 = ParseFrom(TestAllTypes.Parser, message.ToByteString()); + + Assert.AreEqual(message, message2); + } + + [Test] + public void ReadLittleEndian() + { + AssertReadLittleEndian32(Bytes(0x78, 0x56, 0x34, 0x12), 0x12345678); + AssertReadLittleEndian32(Bytes(0xf0, 0xde, 0xbc, 0x9a), 0x9abcdef0); + + AssertReadLittleEndian64(Bytes(0xf0, 0xde, 0xbc, 0x9a, 0x78, 0x56, 0x34, 0x12), + 0x123456789abcdef0L); + AssertReadLittleEndian64( + Bytes(0x78, 0x56, 0x34, 0x12, 0xf0, 0xde, 0xbc, 0x9a), 0x9abcdef012345678UL); + } + + [Test] + public void ReadVarint() + { + AssertReadVarint(Bytes(0x00), 0); + AssertReadVarint(Bytes(0x01), 1); + AssertReadVarint(Bytes(0x7f), 127); + // 14882 + AssertReadVarint(Bytes(0xa2, 0x74), (0x22 << 0) | (0x74 << 7)); + // 2961488830 + AssertReadVarint(Bytes(0xbe, 0xf7, 0x92, 0x84, 0x0b), + (0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) | + (0x0bL << 28)); + + // 64-bit + // 7256456126 + AssertReadVarint(Bytes(0xbe, 0xf7, 0x92, 0x84, 0x1b), + (0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) | + (0x1bL << 28)); + // 41256202580718336 + AssertReadVarint(Bytes(0x80, 0xe6, 0xeb, 0x9c, 0xc3, 0xc9, 0xa4, 0x49), + (0x00 << 0) | (0x66 << 7) | (0x6b << 14) | (0x1c << 21) | + (0x43L << 28) | (0x49L << 35) | (0x24L << 42) | (0x49L << 49)); + // 11964378330978735131 + AssertReadVarint(Bytes(0x9b, 0xa8, 0xf9, 0xc2, 0xbb, 0xd6, 0x80, 0x85, 0xa6, 0x01), + (0x1b << 0) | (0x28 << 7) | (0x79 << 14) | (0x42 << 21) | + (0x3bUL << 28) | (0x56UL << 35) | (0x00UL << 42) | + (0x05UL << 49) | (0x26UL << 56) | (0x01UL << 63)); + + // Failures + AssertReadVarintFailure( + InvalidProtocolBufferException.MalformedVarint(), + Bytes(0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x00)); + AssertReadVarintFailure( + InvalidProtocolBufferException.TruncatedMessage(), + Bytes(0x80)); + } + + // Representations of a tag for field 0 with various wire types + [Test] + [TestCase(0)] + [TestCase(1)] + [TestCase(2)] + [TestCase(3)] + [TestCase(4)] + [TestCase(5)] + public void ReadTag_ZeroFieldRejected(byte tag) + { + try + { + ReadTag(new byte[] { tag }); + Assert.Fail(); + } + catch (InvalidProtocolBufferException) + { + } + } + + [Test] + public void TestNegativeEnum() + { + byte[] bytes = { 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01 }; + + AssertEnum(bytes, (int)SampleEnum.NegativeValue); + } + + [Test] + public void DecodeZigZag32() + { + Assert.AreEqual(0, CodedInputStream.DecodeZigZag32(0)); + Assert.AreEqual(-1, CodedInputStream.DecodeZigZag32(1)); + Assert.AreEqual(1, CodedInputStream.DecodeZigZag32(2)); + Assert.AreEqual(-2, CodedInputStream.DecodeZigZag32(3)); + Assert.AreEqual(0x3FFFFFFF, CodedInputStream.DecodeZigZag32(0x7FFFFFFE)); + Assert.AreEqual(unchecked((int)0xC0000000), CodedInputStream.DecodeZigZag32(0x7FFFFFFF)); + Assert.AreEqual(0x7FFFFFFF, CodedInputStream.DecodeZigZag32(0xFFFFFFFE)); + Assert.AreEqual(unchecked((int)0x80000000), CodedInputStream.DecodeZigZag32(0xFFFFFFFF)); + } + + [Test] + public void DecodeZigZag64() + { + Assert.AreEqual(0, CodedInputStream.DecodeZigZag64(0)); + Assert.AreEqual(-1, CodedInputStream.DecodeZigZag64(1)); + Assert.AreEqual(1, CodedInputStream.DecodeZigZag64(2)); + Assert.AreEqual(-2, CodedInputStream.DecodeZigZag64(3)); + Assert.AreEqual(0x000000003FFFFFFFL, CodedInputStream.DecodeZigZag64(0x000000007FFFFFFEL)); + Assert.AreEqual(unchecked((long)0xFFFFFFFFC0000000L), CodedInputStream.DecodeZigZag64(0x000000007FFFFFFFL)); + Assert.AreEqual(0x000000007FFFFFFFL, CodedInputStream.DecodeZigZag64(0x00000000FFFFFFFEL)); + Assert.AreEqual(unchecked((long)0xFFFFFFFF80000000L), CodedInputStream.DecodeZigZag64(0x00000000FFFFFFFFL)); + Assert.AreEqual(0x7FFFFFFFFFFFFFFFL, CodedInputStream.DecodeZigZag64(0xFFFFFFFFFFFFFFFEL)); + Assert.AreEqual(unchecked((long)0x8000000000000000L), CodedInputStream.DecodeZigZag64(0xFFFFFFFFFFFFFFFFL)); + } + + [Test] + public void ReadFloat() + { + AssertReadFloat(new byte[] { 0, 0, 0, 0 }, 0f); + AssertReadFloat(new byte[] { 205, 204, 140, 63 }, 1.1f); + AssertReadFloat(new byte[] { 255, 255, 127, 127 }, float.MaxValue); + AssertReadFloat(new byte[] { 255, 255, 127, 255 }, float.MinValue); + } + + [Test] + public void ReadDouble() + { + AssertReadDouble(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }, 0f); + AssertReadDouble(new byte[] { 0, 0, 0, 160, 153, 153, 241, 63 }, 1.1f); + AssertReadDouble(new byte[] { 255, 255, 255, 255, 255, 255, 239, 127 }, double.MaxValue); + AssertReadDouble(new byte[] { 255, 255, 255, 255, 255, 255, 239, 255 }, double.MinValue); + } + } +} diff --git a/csharp/src/Google.Protobuf.Test/CodedOutputStreamTest.cs b/csharp/src/Google.Protobuf.Test/CodedOutputStreamTest.cs index 98cabd55adc4..17c12e596e01 100644 --- a/csharp/src/Google.Protobuf.Test/CodedOutputStreamTest.cs +++ b/csharp/src/Google.Protobuf.Test/CodedOutputStreamTest.cs @@ -32,164 +32,14 @@ using System; using System.IO; +using System.Text; using Google.Protobuf.TestProtos; using NUnit.Framework; namespace Google.Protobuf { - public class CodedOutputStreamTest + public class CodedOutputStreamTest : CodedOutputTestBase { - /// - /// Writes the given value using WriteRawVarint32() and WriteRawVarint64() and - /// checks that the result matches the given bytes - /// - private static void AssertWriteVarint(byte[] data, ulong value) - { - // Only do 32-bit write if the value fits in 32 bits. - if ((value >> 32) == 0) - { - MemoryStream rawOutput = new MemoryStream(); - CodedOutputStream output = new CodedOutputStream(rawOutput); - output.WriteRawVarint32((uint) value); - output.Flush(); - Assert.AreEqual(data, rawOutput.ToArray()); - // Also try computing size. - Assert.AreEqual(data.Length, CodedOutputStream.ComputeRawVarint32Size((uint) value)); - } - - { - MemoryStream rawOutput = new MemoryStream(); - CodedOutputStream output = new CodedOutputStream(rawOutput); - output.WriteRawVarint64(value); - output.Flush(); - Assert.AreEqual(data, rawOutput.ToArray()); - - // Also try computing size. - Assert.AreEqual(data.Length, CodedOutputStream.ComputeRawVarint64Size(value)); - } - - // Try different buffer sizes. - for (int bufferSize = 1; bufferSize <= 16; bufferSize *= 2) - { - // Only do 32-bit write if the value fits in 32 bits. - if ((value >> 32) == 0) - { - MemoryStream rawOutput = new MemoryStream(); - CodedOutputStream output = - new CodedOutputStream(rawOutput, bufferSize); - output.WriteRawVarint32((uint) value); - output.Flush(); - Assert.AreEqual(data, rawOutput.ToArray()); - } - - { - MemoryStream rawOutput = new MemoryStream(); - CodedOutputStream output = new CodedOutputStream(rawOutput, bufferSize); - output.WriteRawVarint64(value); - output.Flush(); - Assert.AreEqual(data, rawOutput.ToArray()); - } - } - } - - /// - /// Tests WriteRawVarint32() and WriteRawVarint64() - /// - [Test] - public void WriteVarint() - { - AssertWriteVarint(new byte[] {0x00}, 0); - AssertWriteVarint(new byte[] {0x01}, 1); - AssertWriteVarint(new byte[] {0x7f}, 127); - // 14882 - AssertWriteVarint(new byte[] {0xa2, 0x74}, (0x22 << 0) | (0x74 << 7)); - // 2961488830 - AssertWriteVarint(new byte[] {0xbe, 0xf7, 0x92, 0x84, 0x0b}, - (0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) | - (0x0bL << 28)); - - // 64-bit - // 7256456126 - AssertWriteVarint(new byte[] {0xbe, 0xf7, 0x92, 0x84, 0x1b}, - (0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) | - (0x1bL << 28)); - // 41256202580718336 - AssertWriteVarint( - new byte[] {0x80, 0xe6, 0xeb, 0x9c, 0xc3, 0xc9, 0xa4, 0x49}, - (0x00 << 0) | (0x66 << 7) | (0x6b << 14) | (0x1c << 21) | - (0x43UL << 28) | (0x49L << 35) | (0x24UL << 42) | (0x49UL << 49)); - // 11964378330978735131 - AssertWriteVarint( - new byte[] {0x9b, 0xa8, 0xf9, 0xc2, 0xbb, 0xd6, 0x80, 0x85, 0xa6, 0x01}, - unchecked((ulong) - ((0x1b << 0) | (0x28 << 7) | (0x79 << 14) | (0x42 << 21) | - (0x3bL << 28) | (0x56L << 35) | (0x00L << 42) | - (0x05L << 49) | (0x26L << 56) | (0x01L << 63)))); - } - - /// - /// Parses the given bytes using WriteRawLittleEndian32() and checks - /// that the result matches the given value. - /// - private static void AssertWriteLittleEndian32(byte[] data, uint value) - { - MemoryStream rawOutput = new MemoryStream(); - CodedOutputStream output = new CodedOutputStream(rawOutput); - output.WriteRawLittleEndian32(value); - output.Flush(); - Assert.AreEqual(data, rawOutput.ToArray()); - - // Try different buffer sizes. - for (int bufferSize = 1; bufferSize <= 16; bufferSize *= 2) - { - rawOutput = new MemoryStream(); - output = new CodedOutputStream(rawOutput, bufferSize); - output.WriteRawLittleEndian32(value); - output.Flush(); - Assert.AreEqual(data, rawOutput.ToArray()); - } - } - - /// - /// Parses the given bytes using WriteRawLittleEndian64() and checks - /// that the result matches the given value. - /// - private static void AssertWriteLittleEndian64(byte[] data, ulong value) - { - MemoryStream rawOutput = new MemoryStream(); - CodedOutputStream output = new CodedOutputStream(rawOutput); - output.WriteRawLittleEndian64(value); - output.Flush(); - Assert.AreEqual(data, rawOutput.ToArray()); - - // Try different block sizes. - for (int blockSize = 1; blockSize <= 16; blockSize *= 2) - { - rawOutput = new MemoryStream(); - output = new CodedOutputStream(rawOutput, blockSize); - output.WriteRawLittleEndian64(value); - output.Flush(); - Assert.AreEqual(data, rawOutput.ToArray()); - } - } - - /// - /// Tests writeRawLittleEndian32() and writeRawLittleEndian64(). - /// - [Test] - public void WriteLittleEndian() - { - AssertWriteLittleEndian32(new byte[] {0x78, 0x56, 0x34, 0x12}, 0x12345678); - AssertWriteLittleEndian32(new byte[] {0xf0, 0xde, 0xbc, 0x9a}, 0x9abcdef0); - - AssertWriteLittleEndian64( - new byte[] {0xf0, 0xde, 0xbc, 0x9a, 0x78, 0x56, 0x34, 0x12}, - 0x123456789abcdef0L); - AssertWriteLittleEndian64( - new byte[] {0x78, 0x56, 0x34, 0x12, 0xf0, 0xde, 0xbc, 0x9a}, - 0x9abcdef012345678UL); - } - [Test] public void WriteWholeMessage_VaryingBlockSizes() { @@ -207,81 +57,6 @@ public void WriteWholeMessage_VaryingBlockSizes() Assert.AreEqual(rawBytes, rawOutput.ToArray()); } } - - [Test] - public void EncodeZigZag32() - { - Assert.AreEqual(0u, CodedOutputStream.EncodeZigZag32(0)); - Assert.AreEqual(1u, CodedOutputStream.EncodeZigZag32(-1)); - Assert.AreEqual(2u, CodedOutputStream.EncodeZigZag32(1)); - Assert.AreEqual(3u, CodedOutputStream.EncodeZigZag32(-2)); - Assert.AreEqual(0x7FFFFFFEu, CodedOutputStream.EncodeZigZag32(0x3FFFFFFF)); - Assert.AreEqual(0x7FFFFFFFu, CodedOutputStream.EncodeZigZag32(unchecked((int) 0xC0000000))); - Assert.AreEqual(0xFFFFFFFEu, CodedOutputStream.EncodeZigZag32(0x7FFFFFFF)); - Assert.AreEqual(0xFFFFFFFFu, CodedOutputStream.EncodeZigZag32(unchecked((int) 0x80000000))); - } - - [Test] - public void EncodeZigZag64() - { - Assert.AreEqual(0u, CodedOutputStream.EncodeZigZag64(0)); - Assert.AreEqual(1u, CodedOutputStream.EncodeZigZag64(-1)); - Assert.AreEqual(2u, CodedOutputStream.EncodeZigZag64(1)); - Assert.AreEqual(3u, CodedOutputStream.EncodeZigZag64(-2)); - Assert.AreEqual(0x000000007FFFFFFEuL, - CodedOutputStream.EncodeZigZag64(unchecked((long) 0x000000003FFFFFFFUL))); - Assert.AreEqual(0x000000007FFFFFFFuL, - CodedOutputStream.EncodeZigZag64(unchecked((long) 0xFFFFFFFFC0000000UL))); - Assert.AreEqual(0x00000000FFFFFFFEuL, - CodedOutputStream.EncodeZigZag64(unchecked((long) 0x000000007FFFFFFFUL))); - Assert.AreEqual(0x00000000FFFFFFFFuL, - CodedOutputStream.EncodeZigZag64(unchecked((long) 0xFFFFFFFF80000000UL))); - Assert.AreEqual(0xFFFFFFFFFFFFFFFEL, - CodedOutputStream.EncodeZigZag64(unchecked((long) 0x7FFFFFFFFFFFFFFFUL))); - Assert.AreEqual(0xFFFFFFFFFFFFFFFFL, - CodedOutputStream.EncodeZigZag64(unchecked((long) 0x8000000000000000UL))); - } - - [Test] - public void RoundTripZigZag32() - { - // Some easier-to-verify round-trip tests. The inputs (other than 0, 1, -1) - // were chosen semi-randomly via keyboard bashing. - Assert.AreEqual(0, CodedInputStream.DecodeZigZag32(CodedOutputStream.EncodeZigZag32(0))); - Assert.AreEqual(1, CodedInputStream.DecodeZigZag32(CodedOutputStream.EncodeZigZag32(1))); - Assert.AreEqual(-1, CodedInputStream.DecodeZigZag32(CodedOutputStream.EncodeZigZag32(-1))); - Assert.AreEqual(14927, CodedInputStream.DecodeZigZag32(CodedOutputStream.EncodeZigZag32(14927))); - Assert.AreEqual(-3612, CodedInputStream.DecodeZigZag32(CodedOutputStream.EncodeZigZag32(-3612))); - } - - [Test] - public void RoundTripZigZag64() - { - Assert.AreEqual(0, CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(0))); - Assert.AreEqual(1, CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(1))); - Assert.AreEqual(-1, CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(-1))); - Assert.AreEqual(14927, CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(14927))); - Assert.AreEqual(-3612, CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(-3612))); - - Assert.AreEqual(856912304801416L, - CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(856912304801416L))); - Assert.AreEqual(-75123905439571256L, - CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(-75123905439571256L))); - } - - [Test] - public void TestNegativeEnumNoTag() - { - Assert.AreEqual(10, CodedOutputStream.ComputeInt32Size(-2)); - Assert.AreEqual(10, CodedOutputStream.ComputeEnumSize((int) SampleEnum.NegativeValue)); - - byte[] bytes = new byte[10]; - CodedOutputStream output = new CodedOutputStream(bytes); - output.WriteEnum((int) SampleEnum.NegativeValue); - - Assert.AreEqual(0, output.SpaceLeft); - Assert.AreEqual("FE-FF-FF-FF-FF-FF-FF-FF-FF-01", BitConverter.ToString(bytes)); - } [Test] public void TestCodedInputOutputPosition() @@ -422,5 +197,174 @@ public void Dispose_FromByteArray() var stream = new CodedOutputStream(new byte[10]); stream.Dispose(); } + + protected override void AssertWriteVarint(byte[] data, ulong value) + { + // Only do 32-bit write if the value fits in 32 bits. + if ((value >> 32) == 0) + { + MemoryStream rawOutput = new MemoryStream(); + CodedOutputStream output = new CodedOutputStream(rawOutput); + output.WriteRawVarint32((uint)value); + output.Flush(); + Assert.AreEqual(data, rawOutput.ToArray()); + // Also try computing size. + Assert.AreEqual(data.Length, CodedOutputStream.ComputeRawVarint32Size((uint)value)); + } + + { + MemoryStream rawOutput = new MemoryStream(); + CodedOutputStream output = new CodedOutputStream(rawOutput); + output.WriteRawVarint64(value); + output.Flush(); + Assert.AreEqual(data, rawOutput.ToArray()); + + // Also try computing size. + Assert.AreEqual(data.Length, CodedOutputStream.ComputeRawVarint64Size(value)); + } + + // Try different buffer sizes. + for (int bufferSize = 1; bufferSize <= 16; bufferSize *= 2) + { + // Only do 32-bit write if the value fits in 32 bits. + if ((value >> 32) == 0) + { + MemoryStream rawOutput = new MemoryStream(); + CodedOutputStream output = + new CodedOutputStream(rawOutput, bufferSize); + output.WriteRawVarint32((uint)value); + output.Flush(); + Assert.AreEqual(data, rawOutput.ToArray()); + } + + { + MemoryStream rawOutput = new MemoryStream(); + CodedOutputStream output = new CodedOutputStream(rawOutput, bufferSize); + output.WriteRawVarint64(value); + output.Flush(); + Assert.AreEqual(data, rawOutput.ToArray()); + } + } + } + + protected override void AssertWriteLittleEndian32(byte[] data, uint value) + { + MemoryStream rawOutput = new MemoryStream(); + CodedOutputStream output = new CodedOutputStream(rawOutput); + output.WriteRawLittleEndian32(value); + output.Flush(); + Assert.AreEqual(data, rawOutput.ToArray()); + + // Try different buffer sizes. + for (int bufferSize = 1; bufferSize <= 16; bufferSize *= 2) + { + rawOutput = new MemoryStream(); + output = new CodedOutputStream(rawOutput, bufferSize); + output.WriteRawLittleEndian32(value); + output.Flush(); + Assert.AreEqual(data, rawOutput.ToArray()); + } + } + + protected override void AssertWriteLittleEndian64(byte[] data, ulong value) + { + MemoryStream rawOutput = new MemoryStream(); + CodedOutputStream output = new CodedOutputStream(rawOutput); + output.WriteRawLittleEndian64(value); + output.Flush(); + Assert.AreEqual(data, rawOutput.ToArray()); + + // Try different block sizes. + for (int blockSize = 1; blockSize <= 16; blockSize *= 2) + { + rawOutput = new MemoryStream(); + output = new CodedOutputStream(rawOutput, blockSize); + output.WriteRawLittleEndian64(value); + output.Flush(); + Assert.AreEqual(data, rawOutput.ToArray()); + } + } + + protected override void AssertWriteEnum(byte[] data, int value) + { + MemoryStream rawOutput = new MemoryStream(); + CodedOutputStream output = new CodedOutputStream(rawOutput); + output.WriteEnum(value); + output.Flush(); + + Assert.AreEqual(data, rawOutput.ToArray()); + } + + protected override void AssertWriteBytes(ByteString value) + { + MemoryStream rawOutput = new MemoryStream(); + CodedOutputStream output = new CodedOutputStream(rawOutput); + output.WriteBytes(value); + output.Flush(); + + CodedInputStream input = new CodedInputStream(rawOutput.ToArray()); + Assert.AreEqual(value, input.ReadBytes()); + } + + protected override void AssertWriteString(string value) + { + MemoryStream rawOutput = new MemoryStream(); + CodedOutputStream output = new CodedOutputStream(rawOutput); + output.WriteString(value); + output.Flush(); + + CodedInputStream input = new CodedInputStream(rawOutput.ToArray()); + Assert.AreEqual(value, input.ReadString()); + } + + protected override void AssertWriteFloat(byte[] data, float value) + { + MemoryStream rawOutput = new MemoryStream(); + CodedOutputStream output = new CodedOutputStream(rawOutput); + output.WriteFloat(value); + output.Flush(); + Assert.AreEqual(data, rawOutput.ToArray()); + } + + protected override void AssertWriteDouble(byte[] data, double value) + { + MemoryStream rawOutput = new MemoryStream(); + CodedOutputStream output = new CodedOutputStream(rawOutput); + output.WriteDouble(value); + output.Flush(); + Assert.AreEqual(data, rawOutput.ToArray()); + } + + protected override void AssertWriteRawTag(byte[] data, int value) + { + MemoryStream rawOutput = new MemoryStream(); + CodedOutputStream output = new CodedOutputStream(rawOutput); + + switch (data.Length) + { + case 1: + output.WriteRawTag(data[0]); + break; + case 2: + output.WriteRawTag(data[0], data[1]); + break; + case 3: + output.WriteRawTag(data[0], data[1], data[2]); + break; + case 4: + output.WriteRawTag(data[0], data[1], data[2], data[3]); + break; + case 5: + output.WriteRawTag(data[0], data[1], data[2], data[3], data[4]); + break; + default: + throw new ArgumentException(); + } + + output.Flush(); + + CodedInputStream input = new CodedInputStream(rawOutput.ToArray()); + Assert.AreEqual(value, input.ReadTag()); + } } } \ No newline at end of file diff --git a/csharp/src/Google.Protobuf.Test/CodedOutputTestBase.cs b/csharp/src/Google.Protobuf.Test/CodedOutputTestBase.cs new file mode 100644 index 000000000000..cf00b89e0ce1 --- /dev/null +++ b/csharp/src/Google.Protobuf.Test/CodedOutputTestBase.cs @@ -0,0 +1,294 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System.Text; +using NUnit.Framework; + +namespace Google.Protobuf +{ + public abstract class CodedOutputTestBase + { + /// + /// Writes the given value using WriteRawVarint32() and WriteRawVarint64() and + /// checks that the result matches the given bytes + /// + protected abstract void AssertWriteVarint(byte[] data, ulong value); + + /// + /// Parses the given bytes using WriteRawLittleEndian32() and checks + /// that the result matches the given value. + /// + protected abstract void AssertWriteLittleEndian32(byte[] data, uint value); + + /// + /// Parses the given bytes using WriteRawLittleEndian64() and checks + /// that the result matches the given value. + /// + protected abstract void AssertWriteLittleEndian64(byte[] data, ulong value); + + protected abstract void AssertWriteEnum(byte[] data, int value); + + protected abstract void AssertWriteString(string value); + + protected abstract void AssertWriteBytes(ByteString value); + + protected abstract void AssertWriteFloat(byte[] data, float value); + + protected abstract void AssertWriteDouble(byte[] data, double value); + + protected abstract void AssertWriteRawTag(byte[] data, int value); + + /// + /// Tests WriteRawVarint32() and WriteRawVarint64() + /// + [Test] + public void WriteVarint() + { + AssertWriteVarint(new byte[] {0x00}, 0); + AssertWriteVarint(new byte[] {0x01}, 1); + AssertWriteVarint(new byte[] {0x7f}, 127); + // 14882 + AssertWriteVarint(new byte[] {0xa2, 0x74}, (0x22 << 0) | (0x74 << 7)); + // 2961488830 + AssertWriteVarint(new byte[] {0xbe, 0xf7, 0x92, 0x84, 0x0b}, + (0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) | + (0x0bL << 28)); + + // 64-bit + // 7256456126 + AssertWriteVarint(new byte[] {0xbe, 0xf7, 0x92, 0x84, 0x1b}, + (0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) | + (0x1bL << 28)); + // 41256202580718336 + AssertWriteVarint( + new byte[] {0x80, 0xe6, 0xeb, 0x9c, 0xc3, 0xc9, 0xa4, 0x49}, + (0x00 << 0) | (0x66 << 7) | (0x6b << 14) | (0x1c << 21) | + (0x43UL << 28) | (0x49L << 35) | (0x24UL << 42) | (0x49UL << 49)); + // 11964378330978735131 + AssertWriteVarint( + new byte[] {0x9b, 0xa8, 0xf9, 0xc2, 0xbb, 0xd6, 0x80, 0x85, 0xa6, 0x01}, + unchecked((ulong) + ((0x1b << 0) | (0x28 << 7) | (0x79 << 14) | (0x42 << 21) | + (0x3bL << 28) | (0x56L << 35) | (0x00L << 42) | + (0x05L << 49) | (0x26L << 56) | (0x01L << 63)))); + } + + /// + /// Tests writeRawLittleEndian32() and writeRawLittleEndian64(). + /// + [Test] + public void WriteLittleEndian() + { + AssertWriteLittleEndian32(new byte[] {0x78, 0x56, 0x34, 0x12}, 0x12345678); + AssertWriteLittleEndian32(new byte[] {0xf0, 0xde, 0xbc, 0x9a}, 0x9abcdef0); + + AssertWriteLittleEndian64( + new byte[] {0xf0, 0xde, 0xbc, 0x9a, 0x78, 0x56, 0x34, 0x12}, + 0x123456789abcdef0L); + AssertWriteLittleEndian64( + new byte[] {0x78, 0x56, 0x34, 0x12, 0xf0, 0xde, 0xbc, 0x9a}, + 0x9abcdef012345678UL); + } + + [Test] + public void EncodeZigZag32() + { + Assert.AreEqual(0u, CodedOutputStream.EncodeZigZag32(0)); + Assert.AreEqual(1u, CodedOutputStream.EncodeZigZag32(-1)); + Assert.AreEqual(2u, CodedOutputStream.EncodeZigZag32(1)); + Assert.AreEqual(3u, CodedOutputStream.EncodeZigZag32(-2)); + Assert.AreEqual(0x7FFFFFFEu, CodedOutputStream.EncodeZigZag32(0x3FFFFFFF)); + Assert.AreEqual(0x7FFFFFFFu, CodedOutputStream.EncodeZigZag32(unchecked((int) 0xC0000000))); + Assert.AreEqual(0xFFFFFFFEu, CodedOutputStream.EncodeZigZag32(0x7FFFFFFF)); + Assert.AreEqual(0xFFFFFFFFu, CodedOutputStream.EncodeZigZag32(unchecked((int) 0x80000000))); + } + + [Test] + public void EncodeZigZag64() + { + Assert.AreEqual(0u, CodedOutputStream.EncodeZigZag64(0)); + Assert.AreEqual(1u, CodedOutputStream.EncodeZigZag64(-1)); + Assert.AreEqual(2u, CodedOutputStream.EncodeZigZag64(1)); + Assert.AreEqual(3u, CodedOutputStream.EncodeZigZag64(-2)); + Assert.AreEqual(0x000000007FFFFFFEuL, + CodedOutputStream.EncodeZigZag64(unchecked((long) 0x000000003FFFFFFFUL))); + Assert.AreEqual(0x000000007FFFFFFFuL, + CodedOutputStream.EncodeZigZag64(unchecked((long) 0xFFFFFFFFC0000000UL))); + Assert.AreEqual(0x00000000FFFFFFFEuL, + CodedOutputStream.EncodeZigZag64(unchecked((long) 0x000000007FFFFFFFUL))); + Assert.AreEqual(0x00000000FFFFFFFFuL, + CodedOutputStream.EncodeZigZag64(unchecked((long) 0xFFFFFFFF80000000UL))); + Assert.AreEqual(0xFFFFFFFFFFFFFFFEL, + CodedOutputStream.EncodeZigZag64(unchecked((long) 0x7FFFFFFFFFFFFFFFUL))); + Assert.AreEqual(0xFFFFFFFFFFFFFFFFL, + CodedOutputStream.EncodeZigZag64(unchecked((long) 0x8000000000000000UL))); + } + + [Test] + public void RoundTripZigZag32() + { + // Some easier-to-verify round-trip tests. The inputs (other than 0, 1, -1) + // were chosen semi-randomly via keyboard bashing. + Assert.AreEqual(0, CodedInputStream.DecodeZigZag32(CodedOutputStream.EncodeZigZag32(0))); + Assert.AreEqual(1, CodedInputStream.DecodeZigZag32(CodedOutputStream.EncodeZigZag32(1))); + Assert.AreEqual(-1, CodedInputStream.DecodeZigZag32(CodedOutputStream.EncodeZigZag32(-1))); + Assert.AreEqual(14927, CodedInputStream.DecodeZigZag32(CodedOutputStream.EncodeZigZag32(14927))); + Assert.AreEqual(-3612, CodedInputStream.DecodeZigZag32(CodedOutputStream.EncodeZigZag32(-3612))); + } + + [Test] + public void RoundTripZigZag64() + { + Assert.AreEqual(0, CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(0))); + Assert.AreEqual(1, CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(1))); + Assert.AreEqual(-1, CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(-1))); + Assert.AreEqual(14927, CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(14927))); + Assert.AreEqual(-3612, CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(-3612))); + + Assert.AreEqual(856912304801416L, + CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(856912304801416L))); + Assert.AreEqual(-75123905439571256L, + CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(-75123905439571256L))); + } + + [Test] + public void TestNegativeEnumNoTag() + { + Assert.AreEqual(10, CodedOutputStream.ComputeInt32Size(-2)); + Assert.AreEqual(10, CodedOutputStream.ComputeEnumSize((int) SampleEnum.NegativeValue)); + + byte[] bytes = { 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01 }; + + AssertWriteEnum(bytes, (int)SampleEnum.NegativeValue); + } + + [Test] + public void WriteSmallBytes() + { + byte[] data = new byte[32]; + for (int i = 0; i < data.Length; i++) + { + data[i] = (byte)i; + } + + AssertWriteBytes(ByteString.CopyFrom(data)); + } + + [Test] + public void WriteLargeBytes() + { + byte[] data = new byte[1024 * 100]; + for (int i = 0; i < data.Length; i++) + { + data[i] = (byte)i; + } + + AssertWriteBytes(ByteString.CopyFrom(data)); + } + + [Test] + public void WriteAsciiSmallString() + { + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < 32; i++) + { + sb.AppendLine(i.ToString()); + } + + AssertWriteString(sb.ToString()); + } + + [Test] + public void WriteUnicodeSmallString() + { + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < 32; i++) + { + sb.AppendLine(i.ToString().Replace("0", "\x1369")); + } + + AssertWriteString(sb.ToString()); + } + + [Test] + public void WriteAsciiLargeString() + { + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < 2048; i++) + { + sb.AppendLine(i.ToString()); + } + + AssertWriteString(sb.ToString()); + } + + [Test] + public void WriteUnicodeLargeString() + { + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < 2048; i++) + { + sb.AppendLine(i.ToString().Replace("0", "\x1369")); + } + + AssertWriteString(sb.ToString()); + } + + [Test] + public void WriteFloat() + { + AssertWriteFloat(new byte[] { 0, 0, 0, 0 }, 0f); + AssertWriteFloat(new byte[] { 205, 204, 140, 63 }, 1.1f); + AssertWriteFloat(new byte[] { 255, 255, 127, 127 }, float.MaxValue); + AssertWriteFloat(new byte[] { 255, 255, 127, 255 }, float.MinValue); + } + + [Test] + public void WriteDouble() + { + AssertWriteDouble(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }, 0f); + AssertWriteDouble(new byte[] { 0, 0, 0, 160, 153, 153, 241, 63 }, 1.1f); + AssertWriteDouble(new byte[] { 255, 255, 255, 255, 255, 255, 239, 127 }, double.MaxValue); + AssertWriteDouble(new byte[] { 255, 255, 255, 255, 255, 255, 239, 255 }, double.MinValue); + } + + [Test] + public void WriteTag() + { + AssertWriteRawTag(new byte[] { 128, 128, 128, 128, 1 }, 268435456); + AssertWriteRawTag(new byte[] { 128, 128, 128, 1 }, 2097152); + AssertWriteRawTag(new byte[] { 128, 128, 1 }, 16384); + AssertWriteRawTag(new byte[] { 128, 1 }, 128); + AssertWriteRawTag(new byte[] { 127 }, 127); + } + } +} diff --git a/csharp/src/Google.Protobuf.Test/CodedOutputWriterTest.cs b/csharp/src/Google.Protobuf.Test/CodedOutputWriterTest.cs new file mode 100644 index 000000000000..fcc995e90b38 --- /dev/null +++ b/csharp/src/Google.Protobuf.Test/CodedOutputWriterTest.cs @@ -0,0 +1,314 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY +using System; +using System.Buffers; +using System.IO; +using System.Text; +using Google.Protobuf.Buffers; +using Google.Protobuf.TestProtos; +using NUnit.Framework; + +namespace Google.Protobuf +{ + public class CodedOutputWriterTest : CodedOutputTestBase + { + [Test] + public void WriteWholeMessage_VaryingSegmentSizes() + { + TestAllTypes message = SampleMessages.CreateFullTestAllTypes(); + + byte[] rawBytes = message.ToByteArray(); + + // Try different block sizes. + for (int blockSize = 1; blockSize < 256; blockSize *= 2) + { + ArrayBufferWriter rawOutput = new ArrayBufferWriter(1024); + CodedOutputWriter output = new CodedOutputWriter(new MaxSizeHintBufferWriter(rawOutput, blockSize)); + + message.WriteTo(ref output); + output.Flush(); + Assert.AreEqual(rawBytes, rawOutput.WrittenSpan.ToArray()); + } + } + + [Test] + public void TestCodedInputOutputPosition() + { + byte[] content = new byte[110]; + for (int i = 0; i < content.Length; i++) + content[i] = (byte)i; + + byte[] child; + { + ArrayBufferWriter rawOutput = new ArrayBufferWriter(1024); + CodedOutputWriter cout = new CodedOutputWriter(rawOutput); + // Field 11: numeric value: 500 + cout.WriteTag(11, WireFormat.WireType.Varint); + cout.Flush(); + Assert.AreEqual(1, rawOutput.WrittenCount); + cout.WriteInt32(500); + cout.Flush(); + Assert.AreEqual(3, rawOutput.WrittenCount); + //Field 12: length delimited 120 bytes + cout.WriteTag(12, WireFormat.WireType.LengthDelimited); + cout.Flush(); + Assert.AreEqual(4, rawOutput.WrittenCount); + cout.WriteBytes(ByteString.CopyFrom(content)); + cout.Flush(); + Assert.AreEqual(115, rawOutput.WrittenCount); + // Field 13: fixed numeric value: 501 + cout.WriteTag(13, WireFormat.WireType.Fixed32); + cout.Flush(); + Assert.AreEqual(116, rawOutput.WrittenCount); + cout.WriteSFixed32(501); + cout.Flush(); + Assert.AreEqual(120, rawOutput.WrittenCount); + + child = rawOutput.WrittenSpan.ToArray(); + } + + byte[] bytes; + { + ArrayBufferWriter rawOutput = new ArrayBufferWriter(1024); + CodedOutputWriter cout = new CodedOutputWriter(rawOutput); + // Field 1: numeric value: 500 + cout.WriteTag(1, WireFormat.WireType.Varint); + cout.Flush(); + Assert.AreEqual(1, rawOutput.WrittenCount); + cout.WriteInt32(500); + cout.Flush(); + Assert.AreEqual(3, rawOutput.WrittenCount); + //Field 2: length delimited 120 bytes + cout.WriteTag(2, WireFormat.WireType.LengthDelimited); + cout.Flush(); + Assert.AreEqual(4, rawOutput.WrittenCount); + cout.WriteBytes(ByteString.CopyFrom(child)); + cout.Flush(); + Assert.AreEqual(125, rawOutput.WrittenCount); + // Field 3: fixed numeric value: 500 + cout.WriteTag(3, WireFormat.WireType.Fixed32); + cout.Flush(); + Assert.AreEqual(126, rawOutput.WrittenCount); + cout.WriteSFixed32(501); + cout.Flush(); + Assert.AreEqual(130, rawOutput.WrittenCount); + + bytes = rawOutput.WrittenSpan.ToArray(); + } + + // Now test Input stream: + { + CodedInputReader cin = new CodedInputReader(new ReadOnlySequence(bytes)); + Assert.AreEqual(0, cin.Position); + // Field 1: + uint tag = cin.ReadTag(); + Assert.AreEqual(1, tag >> 3); + Assert.AreEqual(1, cin.Position); + Assert.AreEqual(500, cin.ReadInt32()); + Assert.AreEqual(3, cin.Position); + //Field 2: + tag = cin.ReadTag(); + Assert.AreEqual(2, tag >> 3); + Assert.AreEqual(4, cin.Position); + int childlen = cin.ReadLength(); + Assert.AreEqual(120, childlen); + Assert.AreEqual(5, cin.Position); + Assert.AreEqual(5, cin.Position); + // Now we are reading child message + { + // Field 11: numeric value: 500 + tag = cin.ReadTag(); + Assert.AreEqual(11, tag >> 3); + Assert.AreEqual(6, cin.Position); + Assert.AreEqual(500, cin.ReadInt32()); + Assert.AreEqual(8, cin.Position); + //Field 12: length delimited 120 bytes + tag = cin.ReadTag(); + Assert.AreEqual(12, tag >> 3); + Assert.AreEqual(9, cin.Position); + ByteString bstr = cin.ReadBytes(); + Assert.AreEqual(110, bstr.Length); + Assert.AreEqual((byte) 109, bstr[109]); + Assert.AreEqual(120, cin.Position); + // Field 13: fixed numeric value: 501 + tag = cin.ReadTag(); + Assert.AreEqual(13, tag >> 3); + // ROK - Previously broken here, this returned 126 failing to account for bufferSizeAfterLimit + Assert.AreEqual(121, cin.Position); + Assert.AreEqual(501, cin.ReadSFixed32()); + Assert.AreEqual(125, cin.Position); + } + Assert.AreEqual(125, cin.Position); + // Field 3: fixed numeric value: 501 + tag = cin.ReadTag(); + Assert.AreEqual(3, tag >> 3); + Assert.AreEqual(126, cin.Position); + Assert.AreEqual(501, cin.ReadSFixed32()); + Assert.AreEqual(130, cin.Position); + Assert.IsTrue(cin.IsAtEnd); + } + } + + protected override void AssertWriteVarint(byte[] data, ulong value) + { + // Only do 32-bit write if the value fits in 32 bits. + if ((value >> 32) == 0) + { + ArrayBufferWriter rawOutput = new ArrayBufferWriter(1024); + CodedOutputWriter output = new CodedOutputWriter(rawOutput); + output.WriteRawVarint32((uint)value); + output.Flush(); + Assert.AreEqual(data, rawOutput.WrittenSpan.ToArray()); + // Also try computing size. + Assert.AreEqual(data.Length, CodedOutputStream.ComputeRawVarint32Size((uint)value)); + } + + { + ArrayBufferWriter rawOutput = new ArrayBufferWriter(1024); + CodedOutputWriter output = new CodedOutputWriter(rawOutput); + output.WriteRawVarint64(value); + output.Flush(); + Assert.AreEqual(data, rawOutput.WrittenSpan.ToArray()); + + // Also try computing size. + Assert.AreEqual(data.Length, CodedOutputStream.ComputeRawVarint64Size(value)); + } + } + + protected override void AssertWriteLittleEndian32(byte[] data, uint value) + { + ArrayBufferWriter rawOutput = new ArrayBufferWriter(1024); + CodedOutputWriter output = new CodedOutputWriter(rawOutput); + output.WriteRawLittleEndian32(value); + output.Flush(); + Assert.AreEqual(data, rawOutput.WrittenSpan.ToArray()); + } + + protected override void AssertWriteLittleEndian64(byte[] data, ulong value) + { + ArrayBufferWriter rawOutput = new ArrayBufferWriter(1024); + CodedOutputWriter output = new CodedOutputWriter(rawOutput); + output.WriteRawLittleEndian64(value); + output.Flush(); + Assert.AreEqual(data, rawOutput.WrittenSpan.ToArray()); + } + + protected override void AssertWriteEnum(byte[] data, int value) + { + ArrayBufferWriter rawOutput = new ArrayBufferWriter(10); + CodedOutputWriter output = new CodedOutputWriter(rawOutput); + output.WriteEnum(value); + output.Flush(); + + Assert.AreEqual(data, rawOutput.WrittenSpan.ToArray()); + } + + protected override void AssertWriteString(string value) + { + ArrayBufferWriter rawOutput = new ArrayBufferWriter(1024); + // Limit the max span size to force string to be written in multiple parts + CodedOutputWriter output = new CodedOutputWriter(new MaxSizeHintBufferWriter(rawOutput, 128)); + output.WriteString(value); + output.Flush(); + + CodedInputReader input = new CodedInputReader(ReadOnlySequenceFactory.CreateWithContent(rawOutput.WrittenSpan.ToArray())); + Assert.AreEqual(value, input.ReadString()); + } + + protected override void AssertWriteBytes(ByteString value) + { + ArrayBufferWriter rawOutput = new ArrayBufferWriter(1024); + // Limit the max span size to force bytes to be written in multiple parts + CodedOutputWriter output = new CodedOutputWriter(new MaxSizeHintBufferWriter(rawOutput, 128)); + output.WriteBytes(value); + output.Flush(); + + CodedInputReader input = new CodedInputReader(ReadOnlySequenceFactory.CreateWithContent(rawOutput.WrittenSpan.ToArray())); + Assert.AreEqual(value, input.ReadBytes()); + } + + protected override void AssertWriteFloat(byte[] data, float value) + { + ArrayBufferWriter rawOutput = new ArrayBufferWriter(1024); + CodedOutputWriter output = new CodedOutputWriter(rawOutput); + output.WriteFloat(value); + output.Flush(); + + Assert.AreEqual(data, rawOutput.WrittenSpan.ToArray()); + } + + protected override void AssertWriteDouble(byte[] data, double value) + { + ArrayBufferWriter rawOutput = new ArrayBufferWriter(1024); + CodedOutputWriter output = new CodedOutputWriter(rawOutput); + output.WriteDouble(value); + output.Flush(); + + Assert.AreEqual(data, rawOutput.WrittenSpan.ToArray()); + } + + protected override void AssertWriteRawTag(byte[] data, int value) + { + ArrayBufferWriter rawOutput = new ArrayBufferWriter(1024); + CodedOutputWriter output = new CodedOutputWriter(rawOutput); + + switch (data.Length) + { + case 1: + output.WriteRawTag(data[0]); + break; + case 2: + output.WriteRawTag(data[0], data[1]); + break; + case 3: + output.WriteRawTag(data[0], data[1], data[2]); + break; + case 4: + output.WriteRawTag(data[0], data[1], data[2], data[3]); + break; + case 5: + output.WriteRawTag(data[0], data[1], data[2], data[3], data[4]); + break; + default: + throw new ArgumentException(); + } + + output.Flush(); + + CodedInputReader input = new CodedInputReader(new ReadOnlySequence(rawOutput.WrittenSpan.ToArray())); + Assert.AreEqual(value, input.ReadTag()); + } + } +} +#endif \ No newline at end of file diff --git a/csharp/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs b/csharp/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs index 527c7d404c46..fb337b1619c6 100644 --- a/csharp/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs +++ b/csharp/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs @@ -31,12 +31,16 @@ #endregion using System; +using System.Buffers; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.IO; using System.Linq; using System.Text; +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY +using Google.Protobuf.Buffers; +#endif using Google.Protobuf.TestProtos; using Google.Protobuf.WellKnownTypes; using NUnit.Framework; @@ -382,7 +386,7 @@ public void AddEntriesFrom_String() } [Test] - public void AddEntriesFrom_Message() + public void AddEntriesFrom_CodedInputStream_Message() { var message1 = new ForeignMessage { C = 2000 }; var message2 = new ForeignMessage { C = -250 }; @@ -405,6 +409,31 @@ public void AddEntriesFrom_Message() Assert.IsTrue(input.IsAtEnd); } +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + [Test] + public void AddEntriesFrom_CodedInputReader_Message() + { + var message1 = new ForeignMessage { C = 2000 }; + var message2 = new ForeignMessage { C = -250 }; + + uint tag = WireFormat.MakeTag(10, WireFormat.WireType.LengthDelimited); + var bufferWriter = new ArrayBufferWriter(); + var output = new CodedOutputWriter(bufferWriter); + output.WriteTag(tag); + output.WriteMessage(message1); + output.WriteTag(tag); + output.WriteMessage(message2); + output.Flush(); + + var field = new RepeatedField(); + var input = new CodedInputReader(new ReadOnlySequence(bufferWriter.WrittenSpan.ToArray())); + input.AssertNextTag(tag); + field.AddEntriesFrom(ref input, FieldCodec.ForMessage(tag, ForeignMessage.Parser)); + CollectionAssert.AreEqual(new[] { message1, message2 }, field); + Assert.IsTrue(input.IsAtEnd); + } +#endif + [Test] public void WriteTo_PackedInt32() { @@ -469,7 +498,7 @@ public void WriteTo_String() } [Test] - public void WriteTo_Message() + public void WriteTo_CodedInputStream_Message() { var message1 = new ForeignMessage { C = 20 }; var message2 = new ForeignMessage { C = 25 }; @@ -489,6 +518,28 @@ public void WriteTo_Message() Assert.IsTrue(input.IsAtEnd); } +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + [Test] + public void WriteTo_CodedInputReader_Message() + { + var message1 = new ForeignMessage { C = 20 }; + var message2 = new ForeignMessage { C = 25 }; + uint tag = WireFormat.MakeTag(10, WireFormat.WireType.LengthDelimited); + var field = new RepeatedField { message1, message2 }; + var bufferWriter = new ArrayBufferWriter(); + var output = new CodedOutputWriter(bufferWriter); + field.WriteTo(ref output, FieldCodec.ForMessage(tag, ForeignMessage.Parser)); + output.Flush(); + + var input = new CodedInputReader(new ReadOnlySequence(bufferWriter.WrittenSpan.ToArray())); + input.AssertNextTag(tag); + Assert.AreEqual(message1, input.ReadMessage(ForeignMessage.Parser)); + input.AssertNextTag(tag); + Assert.AreEqual(message2, input.ReadMessage(ForeignMessage.Parser)); + Assert.IsTrue(input.IsAtEnd); + } +#endif + [Test] public void CalculateSize_VariableSizeNonPacked() { diff --git a/csharp/src/Google.Protobuf.Test/ExtensionSetTest.cs b/csharp/src/Google.Protobuf.Test/ExtensionSetTest.cs index 33dc50430d07..3f15b9743858 100644 --- a/csharp/src/Google.Protobuf.Test/ExtensionSetTest.cs +++ b/csharp/src/Google.Protobuf.Test/ExtensionSetTest.cs @@ -34,12 +34,14 @@ public void TestMergeCodedInput() message.SetExtension(OptionalBoolExtension, true); var serialized = message.ToByteArray(); - var other = TestAllExtensions.Parser - .WithExtensionRegistry(new ExtensionRegistry() { OptionalBoolExtension }) - .ParseFrom(serialized); - - Assert.AreEqual(message, other); - Assert.AreEqual(message.CalculateSize(), other.CalculateSize()); + MessageParsingHelpers.AssertReadingMessage( + TestAllExtensions.Parser.WithExtensionRegistry(new ExtensionRegistry() { OptionalBoolExtension }), + serialized, + other => + { + Assert.AreEqual(message, other); + Assert.AreEqual(message.CalculateSize(), other.CalculateSize()); + }); } [Test] diff --git a/csharp/src/Google.Protobuf.Test/GeneratedMessageTest.Proto2.cs b/csharp/src/Google.Protobuf.Test/GeneratedMessageTest.Proto2.cs index 718c3edcb80e..5f90c94cce6d 100644 --- a/csharp/src/Google.Protobuf.Test/GeneratedMessageTest.Proto2.cs +++ b/csharp/src/Google.Protobuf.Test/GeneratedMessageTest.Proto2.cs @@ -269,8 +269,8 @@ public void RequiredFields() [Test] public void RequiredFieldsNoThrow() { - Assert.DoesNotThrow(() => TestRequired.Parser.ParseFrom(new byte[0])); - Assert.DoesNotThrow(() => (TestRequired.Parser as MessageParser).ParseFrom(new byte[0])); + Assert.DoesNotThrow(() => MessageParsingHelpers.AssertReadingMessage(TestRequired.Parser, new byte[0], m => { })); + Assert.DoesNotThrow(() => MessageParsingHelpers.AssertReadingMessage(TestRequired.Parser as MessageParser, new byte[0], m => { })); } [Test] @@ -344,9 +344,7 @@ public void RoundTrip_Groups() } }; - byte[] bytes = message.ToByteArray(); - TestAllTypes parsed = Proto2.TestAllTypes.Parser.ParseFrom(bytes); - Assert.AreEqual(message, parsed); + MessageParsingHelpers.AssertRoundtrip(Proto2.TestAllTypes.Parser, message); } [Test] @@ -361,9 +359,9 @@ public void RoundTrip_ExtensionGroups() new RepeatedGroup_extension { A = 30 } }); - byte[] bytes = message.ToByteArray(); - TestAllExtensions extendable_parsed = TestAllExtensions.Parser.WithExtensionRegistry(new ExtensionRegistry() { UnittestExtensions.OptionalGroupExtension, UnittestExtensions.RepeatedGroupExtension }).ParseFrom(bytes); - Assert.AreEqual(message, extendable_parsed); + MessageParsingHelpers.AssertRoundtrip( + TestAllExtensions.Parser.WithExtensionRegistry(new ExtensionRegistry() { UnittestExtensions.OptionalGroupExtension, UnittestExtensions.RepeatedGroupExtension }), + message); } [Test] @@ -372,9 +370,9 @@ public void RoundTrip_NestedExtensionGroup() var message = new TestGroupExtension(); message.SetExtension(TestNestedExtension.Extensions.OptionalGroupExtension, new TestNestedExtension.Types.OptionalGroup_extension { A = 10 }); - byte[] bytes = message.ToByteArray(); - TestGroupExtension extendable_parsed = TestGroupExtension.Parser.WithExtensionRegistry(new ExtensionRegistry() { TestNestedExtension.Extensions.OptionalGroupExtension }).ParseFrom(bytes); - Assert.AreEqual(message, extendable_parsed); + MessageParsingHelpers.AssertRoundtrip( + TestGroupExtension.Parser.WithExtensionRegistry(new ExtensionRegistry() { TestNestedExtension.Extensions.OptionalGroupExtension }), + message); } } } diff --git a/csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs b/csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs index 103df7dd2fef..53ca3e4837c9 100644 --- a/csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs +++ b/csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs @@ -131,8 +131,8 @@ public void RoundTrip_Empty() // Without setting any values, there's nothing to write. byte[] bytes = message.ToByteArray(); Assert.AreEqual(0, bytes.Length); - TestAllTypes parsed = TestAllTypes.Parser.ParseFrom(bytes); - Assert.AreEqual(message, parsed); + + MessageParsingHelpers.AssertRoundtrip(TestAllTypes.Parser, message); } [Test] @@ -164,9 +164,7 @@ public void RoundTrip_SingleValues() SingleUint64 = ulong.MaxValue }; - byte[] bytes = message.ToByteArray(); - TestAllTypes parsed = TestAllTypes.Parser.ParseFrom(bytes); - Assert.AreEqual(message, parsed); + MessageParsingHelpers.AssertRoundtrip(TestAllTypes.Parser, message); } [Test] @@ -198,9 +196,7 @@ public void RoundTrip_RepeatedValues() RepeatedUint64 = { ulong.MaxValue, uint.MinValue } }; - byte[] bytes = message.ToByteArray(); - TestAllTypes parsed = TestAllTypes.Parser.ParseFrom(bytes); - Assert.AreEqual(message, parsed); + MessageParsingHelpers.AssertRoundtrip(TestAllTypes.Parser, message); } // Note that not every map within map_unittest_proto3 is used. They all go through very @@ -230,9 +226,7 @@ public void RoundTrip_Maps() } }; - byte[] bytes = message.ToByteArray(); - TestMap parsed = TestMap.Parser.ParseFrom(bytes); - Assert.AreEqual(message, parsed); + MessageParsingHelpers.AssertRoundtrip(TestMap.Parser, message); } [Test] @@ -246,9 +240,14 @@ public void MapWithEmptyEntry() byte[] bytes = message.ToByteArray(); Assert.AreEqual(2, bytes.Length); // Tag for field entry (1 byte), length of entry (0; 1 byte) - var parsed = TestMap.Parser.ParseFrom(bytes); - Assert.AreEqual(1, parsed.MapInt32Bytes.Count); - Assert.AreEqual(ByteString.Empty, parsed.MapInt32Bytes[0]); + MessageParsingHelpers.AssertReadingMessage( + TestMap.Parser, + bytes, + parsed=> + { + Assert.AreEqual(1, parsed.MapInt32Bytes.Count); + Assert.AreEqual(ByteString.Empty, parsed.MapInt32Bytes[0]); + }); } [Test] @@ -265,8 +264,13 @@ public void MapWithOnlyValue() output.WriteMessage(nestedMessage); output.Flush(); - var parsed = TestMap.Parser.ParseFrom(memoryStream.ToArray()); - Assert.AreEqual(nestedMessage, parsed.MapInt32ForeignMessage[0]); + MessageParsingHelpers.AssertReadingMessage( + TestMap.Parser, + memoryStream.ToArray(), + parsed => + { + Assert.AreEqual(nestedMessage, parsed.MapInt32ForeignMessage[0]); + }); } [Test] @@ -282,8 +286,13 @@ public void MapWithOnlyKey_PrimitiveValue() output.WriteInt32(key); output.Flush(); - var parsed = TestMap.Parser.ParseFrom(memoryStream.ToArray()); - Assert.AreEqual(0.0, parsed.MapInt32Double[key]); + MessageParsingHelpers.AssertReadingMessage( + TestMap.Parser, + memoryStream.ToArray(), + parsed => + { + Assert.AreEqual(0.0, parsed.MapInt32Double[key]); + }); } [Test] @@ -299,8 +308,13 @@ public void MapWithOnlyKey_MessageValue() output.WriteInt32(key); output.Flush(); - var parsed = TestMap.Parser.ParseFrom(memoryStream.ToArray()); - Assert.AreEqual(new ForeignMessage(), parsed.MapInt32ForeignMessage[key]); + MessageParsingHelpers.AssertReadingMessage( + TestMap.Parser, + memoryStream.ToArray(), + parsed => + { + Assert.AreEqual(new ForeignMessage(), parsed.MapInt32ForeignMessage[key]); + }); } [Test] @@ -327,8 +341,13 @@ public void MapIgnoresExtraFieldsWithinEntryMessages() output.WriteInt32(extra); output.Flush(); - var parsed = TestMap.Parser.ParseFrom(memoryStream.ToArray()); - Assert.AreEqual(value, parsed.MapInt32Int32[key]); + MessageParsingHelpers.AssertReadingMessage( + TestMap.Parser, + memoryStream.ToArray(), + parsed => + { + Assert.AreEqual(value, parsed.MapInt32Int32[key]); + }); } [Test] @@ -351,8 +370,13 @@ public void MapFieldOrderIsIrrelevant() output.WriteInt32(key); output.Flush(); - var parsed = TestMap.Parser.ParseFrom(memoryStream.ToArray()); - Assert.AreEqual(value, parsed.MapInt32Int32[key]); + MessageParsingHelpers.AssertReadingMessage( + TestMap.Parser, + memoryStream.ToArray(), + parsed => + { + Assert.AreEqual(value, parsed.MapInt32Int32[key]); + }); } [Test] @@ -397,13 +421,19 @@ public void MapNonContiguousEntries() output.WriteInt32(value3); output.Flush(); - var parsed = TestMap.Parser.ParseFrom(memoryStream.ToArray()); - var expected = new TestMap - { - MapInt32Int32 = { { key1, value1 }, { key3, value3 } }, - MapStringString = { { key2, value2 } } - }; - Assert.AreEqual(expected, parsed); + + MessageParsingHelpers.AssertReadingMessage( + TestMap.Parser, + memoryStream.ToArray(), + parsed => + { + var expected = new TestMap + { + MapInt32Int32 = { { key1, value1 }, { key3, value3 } }, + MapStringString = { { key2, value2 } } + }; + Assert.AreEqual(expected, parsed); + }); } [Test] @@ -433,8 +463,13 @@ public void DuplicateKeys_LastEntryWins() output.WriteInt32(value2); output.Flush(); - var parsed = TestMap.Parser.ParseFrom(memoryStream.ToArray()); - Assert.AreEqual(value2, parsed.MapInt32Int32[key]); + MessageParsingHelpers.AssertReadingMessage( + TestMap.Parser, + memoryStream.ToArray(), + parsed => + { + Assert.AreEqual(value2, parsed.MapInt32Int32[key]); + }); } [Test] @@ -619,9 +654,10 @@ public void OneofSerialization_NonDefaultValue() var bytes = message.ToByteArray(); Assert.AreEqual(3, bytes.Length); // 2 bytes for the tag + 1 for the value - no string! - var message2 = TestAllTypes.Parser.ParseFrom(bytes); - Assert.AreEqual(message, message2); - Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofUint32, message2.OneofFieldCase); + MessageParsingHelpers.AssertRoundtrip(TestAllTypes.Parser, message, parsedMessage => + { + Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofUint32, parsedMessage.OneofFieldCase); + }); } [Test] @@ -633,9 +669,10 @@ public void OneofSerialization_DefaultValue() var bytes = message.ToByteArray(); Assert.AreEqual(3, bytes.Length); // 2 bytes for the tag + 1 for the value - it's still serialized - var message2 = TestAllTypes.Parser.ParseFrom(bytes); - Assert.AreEqual(message, message2); - Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofUint32, message2.OneofFieldCase); + MessageParsingHelpers.AssertRoundtrip(TestAllTypes.Parser, message, parsedMessage => + { + Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofUint32, parsedMessage.OneofFieldCase); + }); } [Test] @@ -651,10 +688,14 @@ public void DiscardUnknownFields_RealDataStillRead() message.WriteTo(output); output.Flush(); - stream.Position = 0; - var parsed = TestAllTypes.Parser.ParseFrom(stream); - // TODO(jieluo): Add test back when DiscardUnknownFields API is supported. - // Assert.AreEqual(message, parsed); + MessageParsingHelpers.AssertReadingMessage( + TestAllTypes.Parser, + stream.ToArray(), + parsed => + { + // TODO(jieluo): Add test back when DiscardUnknownFields API is supported. + // Assert.AreEqual(message, parsed); + }); } [Test] @@ -662,9 +703,15 @@ public void DiscardUnknownFields_AllTypes() { // Simple way of ensuring we can skip all kinds of fields. var data = SampleMessages.CreateFullTestAllTypes().ToByteArray(); - var empty = Empty.Parser.ParseFrom(data); - // TODO(jieluo): Add test back when DiscardUnknownFields API is supported. - // Assert.AreNotEqual(new Empty(), empty); + + MessageParsingHelpers.AssertReadingMessage( + Empty.Parser, + data, + parsed => + { + // TODO(jieluo): Add test back when DiscardUnknownFields API is supported. + // Assert.AreNotEqual(new Empty(), empty); + }); } // This was originally seen as a conformance test failure. @@ -674,7 +721,69 @@ public void TruncatedMessageFieldThrows() // 130, 3 is the message tag // 1 is the data length - but there's no data. var data = new byte[] { 130, 3, 1 }; - Assert.Throws(() => TestAllTypes.Parser.ParseFrom(data)); + MessageParsingHelpers.AssertReadingMessageThrows(TestAllTypes.Parser, data); + } + + [Test] + public void ParsingNestedMessageFailsIfOverLimit() + { + // when parsing length delimited byteString, parser must recognize it's over limit. + AssertReadingNestedMessageWithWrongLengthThrows(new TestAllTypes { SingleBytes = ByteString.CopyFrom(1, 2, 3, 4) }, -1, 10); + + // when parsing varint, parser must recognize it's over limit but hasn't yet finished reading the entire varint + AssertReadingNestedMessageWithWrongLengthThrows(new TestAllTypes { SingleInt64 = 123456789 }, -1, 10); + + // when parsing length delimited byteString, parser must recognize it's over limit. + AssertReadingNestedMessageWithWrongLengthThrows(new TestAllTypes { SingleString = "test" }, -1, 10); + + // when reading the fixed64 value, parser must recognize it's over limit + AssertReadingNestedMessageWithWrongLengthThrows(new TestAllTypes { SingleDouble = 1e-9 }, -1, 10); + + // when reading the fixed32 value, parser must recognize it's over limit + AssertReadingNestedMessageWithWrongLengthThrows(new TestAllTypes { SingleDouble = 1e-3 }, -1, 10); + + // packed repeated value + AssertReadingNestedMessageWithWrongLengthThrows(new TestAllTypes { RepeatedInt64 = { 1, 2, 3, 4 } }, -1, 10); + + // repeated string (non-packed) + AssertReadingNestedMessageWithWrongLengthThrows(new TestAllTypes { RepeatedString = { "abc", "def" } }, -1, 10); + + // TODO(jtattermusch): test for start and end group too? + + // TODO(jtattermusch): what if even the tag/length of the nested message is over the limit? + } + + private void AssertReadingNestedMessageWithWrongLengthThrows(TestAllTypes nestedMsg, int lengthModifier, int paddingMessageCount) + { + // construct a NestedTestAllTypes message with a nested message + // as a payload, followed by some padding. Tweak the serialized + // form of the message so that for payload, the length delimiter + // is set incorrectly. That will result it nested message's + // limit being too small and should result in parsing + // error. The padding is there to make sure we're actually testing + // the nested message limit rather than hitting the end of the buffer. + // var msg = new NestedTestAllTypes + // { + // Payload = nestedMsg, // our payload + // RepeatedChild = { new NestedTestAllTypes(), ... } // the padding + // }; + var stream = new MemoryStream(); + var output = new CodedOutputStream(stream); + output.WriteTag(2, WireFormat.WireType.LengthDelimited); // tag for "payload" field + output.WriteLength(nestedMsg.CalculateSize() + lengthModifier); // size of "payload" field, but artifically made incorrect + output.WriteRawBytes(nestedMsg.ToByteArray()); // write raw data of payload message + // write padding messages to make sure we don't approach the end of the buffer + for (int i = 0; i < paddingMessageCount; i++) + { + output.WriteTag(3, WireFormat.WireType.LengthDelimited); // "repeated_child" field + output.WriteMessage(new NestedTestAllTypes()); + } + output.Flush(); + + // TODO(jtattermusch): check that with unmodified length delimiter, message can be parsed ok? + //MessageParsingHelpers.AssertReadingMessage(NestedTestAllTypes.Parser, data, (msg) => { }); + + MessageParsingHelpers.AssertReadingMessageThrows(NestedTestAllTypes.Parser, stream.ToArray()); } /// @@ -694,8 +803,7 @@ public void ExtraEndGroupThrows() output.Flush(); - stream.Position = 0; - Assert.Throws(() => TestAllTypes.Parser.ParseFrom(stream)); + MessageParsingHelpers.AssertReadingMessageThrows(TestAllTypes.Parser, stream.ToArray()); } [Test] diff --git a/csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj b/csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj index 1a7953d6b786..900bd7738d85 100644 --- a/csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj +++ b/csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj @@ -19,6 +19,10 @@ + + $(DefineConstants);GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + + diff --git a/csharp/src/Google.Protobuf.Test/JsonParserTest.cs b/csharp/src/Google.Protobuf.Test/JsonParserTest.cs index a6cf04ab7af2..b8d94ed8be99 100644 --- a/csharp/src/Google.Protobuf.Test/JsonParserTest.cs +++ b/csharp/src/Google.Protobuf.Test/JsonParserTest.cs @@ -549,9 +549,13 @@ public void NumberToDouble_Valid(string jsonValue, double expectedParsedValue) } [Test] +#if !NETCOREAPP3_0 + // .NET Core 3.0 returns infinity + // https://github.com/dotnet/docs/issues/14705 [TestCase("1.7977e308")] [TestCase("-1.7977e308")] [TestCase("1e309")] +#endif [TestCase("1,0")] [TestCase("1.0.0")] [TestCase("+1")] diff --git a/csharp/src/Google.Protobuf.Test/JsonTokenizerTest.cs b/csharp/src/Google.Protobuf.Test/JsonTokenizerTest.cs index df43effd4ff0..4504086d4d25 100644 --- a/csharp/src/Google.Protobuf.Test/JsonTokenizerTest.cs +++ b/csharp/src/Google.Protobuf.Test/JsonTokenizerTest.cs @@ -199,8 +199,12 @@ public void NumberValue(string json, double expectedValue) [TestCase("1e-")] [TestCase("--")] [TestCase("--1")] +#if !NETCOREAPP3_0 + // .NET Core 3.0 returns infinity + // https://github.com/dotnet/docs/issues/14705 [TestCase("-1.7977e308")] [TestCase("1.7977e308")] +#endif public void InvalidNumberValue(string json) { AssertThrowsAfter(json); diff --git a/csharp/src/Google.Protobuf.Test/MessageParsingHelpers.cs b/csharp/src/Google.Protobuf.Test/MessageParsingHelpers.cs new file mode 100644 index 000000000000..3b66d8827cd8 --- /dev/null +++ b/csharp/src/Google.Protobuf.Test/MessageParsingHelpers.cs @@ -0,0 +1,145 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2015 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using NUnit.Framework; +using System; +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY +using Google.Protobuf.Buffers; +#endif +using System.Buffers; + +namespace Google.Protobuf +{ + public static class MessageParsingHelpers + { + public static void AssertWritingMessage(MessageParser parser, T message, byte[] expectedData) where T : IMessage + { + var bytes = message.ToByteArray(); + +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + var bufferMessage = (IBufferMessage)message; + var bufferWriter = new ArrayBufferWriter(); + var output = new CodedOutputWriter(bufferWriter); + bufferMessage.WriteTo(ref output); + output.Flush(); + + Assert.AreEqual(expectedData, bufferWriter.WrittenMemory.ToArray()); +#endif + Assert.AreEqual(expectedData, bytes); + } + + public static void AssertReadingMessage(MessageParser parser, byte[] bytes, Action assert) where T : IMessage + { + var parsedStream = parser.ParseFrom(bytes); + +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + // Load content as single segment + var parsedBuffer = parser.ParseFrom(new ReadOnlySequence(bytes)); + assert(parsedBuffer); + + // Load content as multiple segments + parsedBuffer = parser.ParseFrom(ReadOnlySequenceFactory.CreateWithContent(bytes)); + assert(parsedBuffer); +#endif + assert(parsedStream); + } + + public static void AssertReadingMessage(MessageParser parser, byte[] bytes, Action assert) + { + var parsedStream = parser.ParseFrom(bytes); + +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + // Load content as single segment + var parsedBuffer = parser.ParseFrom(new ReadOnlySequence(bytes)); + assert(parsedBuffer); + + // Load content as multiple segments + parsedBuffer = parser.ParseFrom(ReadOnlySequenceFactory.CreateWithContent(bytes)); + assert(parsedBuffer); +#endif + assert(parsedStream); + } + + public static void AssertReadingMessageThrows(MessageParser parser, byte[] bytes) + where TMessage : IMessage + where TException : Exception + { + Assert.Throws(() => parser.ParseFrom(bytes)); + +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + Assert.Throws(() => parser.ParseFrom(new ReadOnlySequence(bytes))); +#endif + } + + public static void AssertMergingMessage(MessageParser parser, Func prepareMessage, byte[] bytes, Action assert) where T : IMessage + { + var streamMergeMessage = prepareMessage(); + streamMergeMessage.MergeFrom(bytes); + +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + var bufferMergeMessage = (IBufferMessage)prepareMessage(); + var reader = new CodedInputReader(new ReadOnlySequence(bytes)); + bufferMergeMessage.MergeFrom(ref reader); + assert((T)bufferMergeMessage); +#endif + assert(streamMergeMessage); + } + + public static void AssertRoundtrip(MessageParser parser, T message, Action additionalAssert = null) where T : IMessage + { + var bytes = message.ToByteArray(); + +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + var bufferMessage = (IBufferMessage)message; + var bufferWriter = new ArrayBufferWriter(); + var output = new CodedOutputWriter(bufferWriter); + bufferMessage.WriteTo(ref output); + output.Flush(); + + // Load content as single segment + var parsedBuffer = parser.ParseFrom(new ReadOnlySequence(bufferWriter.WrittenMemory)); + Assert.AreEqual(message, parsedBuffer); + additionalAssert?.Invoke(parsedBuffer); + + // Load content as multiple segments + parsedBuffer = parser.ParseFrom(ReadOnlySequenceFactory.CreateWithContent(bufferWriter.WrittenMemory.ToArray())); + Assert.AreEqual(message, parsedBuffer); + additionalAssert?.Invoke(parsedBuffer); +#endif + + var parsedStream = parser.ParseFrom(bytes); + + Assert.AreEqual(message, parsedStream); + additionalAssert?.Invoke(parsedStream); + } + } +} diff --git a/csharp/src/Google.Protobuf.Test/UnknownFieldSetTest.cs b/csharp/src/Google.Protobuf.Test/UnknownFieldSetTest.cs index 886937d70620..17de0d8f1283 100644 --- a/csharp/src/Google.Protobuf.Test/UnknownFieldSetTest.cs +++ b/csharp/src/Google.Protobuf.Test/UnknownFieldSetTest.cs @@ -161,10 +161,10 @@ public void TestDiscardUnknownFields(IMessage message) MessageParser discardingParser2 = retainingParser2.WithDiscardUnknownFields(true); // Test parse from byte[] - assertFull(retainingParser1.ParseFrom(data)); - assertFull(retainingParser2.ParseFrom(data)); - assertEmpty(discardingParser1.ParseFrom(data)); - assertEmpty(discardingParser2.ParseFrom(data)); + MessageParsingHelpers.AssertReadingMessage(retainingParser1, data, m => assertFull(m)); + MessageParsingHelpers.AssertReadingMessage(retainingParser2, data, m => assertFull(m)); + MessageParsingHelpers.AssertReadingMessage(discardingParser1, data, m => assertEmpty(m)); + MessageParsingHelpers.AssertReadingMessage(discardingParser2, data, m => assertEmpty(m)); // Test parse from byte[] with offset assertFull(retainingParser1.ParseFrom(data, 0, data.Length)); @@ -197,10 +197,20 @@ public void TestReadInvalidWireTypeThrowsInvalidProtocolBufferException() output.Flush(); ms.Position = 0; - CodedInputStream input = new CodedInputStream(ms); - Assert.AreEqual(tag, input.ReadTag()); + CodedInputStream inputStream = new CodedInputStream(ms); + Assert.AreEqual(tag, inputStream.ReadTag()); + Assert.Throws(() => UnknownFieldSet.MergeFieldFrom(null, inputStream)); - Assert.Throws(() => UnknownFieldSet.MergeFieldFrom(null, input)); +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + ms.Position = 0; + + Assert.Throws(() => + { + CodedInputReader inputReader = new CodedInputReader(new System.Buffers.ReadOnlySequence(ms.ToArray())); + Assert.AreEqual(tag, inputReader.ReadTag()); + UnknownFieldSet.MergeFieldFrom(null, ref inputReader); + }); +#endif } } } diff --git a/csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs b/csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs index 4a425f79aa84..7802066830bc 100644 --- a/csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs +++ b/csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs @@ -71,18 +71,18 @@ public void NonDefaultSingleValues() Uint64Field = 4 }; - var bytes = message.ToByteArray(); - var parsed = TestWellKnownTypes.Parser.ParseFrom(bytes); - - Assert.AreEqual("x", parsed.StringField); - Assert.AreEqual(ByteString.CopyFrom(1, 2, 3), parsed.BytesField); - Assert.AreEqual(true, parsed.BoolField); - Assert.AreEqual(12.5f, parsed.FloatField); - Assert.AreEqual(12.25d, parsed.DoubleField); - Assert.AreEqual(1, parsed.Int32Field); - Assert.AreEqual(2L, parsed.Int64Field); - Assert.AreEqual(3U, parsed.Uint32Field); - Assert.AreEqual(4UL, parsed.Uint64Field); + MessageParsingHelpers.AssertRoundtrip(TestWellKnownTypes.Parser, message, parsed => + { + Assert.AreEqual("x", parsed.StringField); + Assert.AreEqual(ByteString.CopyFrom(1, 2, 3), parsed.BytesField); + Assert.AreEqual(true, parsed.BoolField); + Assert.AreEqual(12.5f, parsed.FloatField); + Assert.AreEqual(12.25d, parsed.DoubleField); + Assert.AreEqual(1, parsed.Int32Field); + Assert.AreEqual(2L, parsed.Int64Field); + Assert.AreEqual(3U, parsed.Uint32Field); + Assert.AreEqual(4UL, parsed.Uint64Field); + }); } [Test] @@ -101,18 +101,18 @@ public void NonNullDefaultIsPreservedThroughSerialization() Uint64Field = 0 }; - var bytes = message.ToByteArray(); - var parsed = TestWellKnownTypes.Parser.ParseFrom(bytes); - - Assert.AreEqual("", parsed.StringField); - Assert.AreEqual(ByteString.Empty, parsed.BytesField); - Assert.AreEqual(false, parsed.BoolField); - Assert.AreEqual(0f, parsed.FloatField); - Assert.AreEqual(0d, parsed.DoubleField); - Assert.AreEqual(0, parsed.Int32Field); - Assert.AreEqual(0L, parsed.Int64Field); - Assert.AreEqual(0U, parsed.Uint32Field); - Assert.AreEqual(0UL, parsed.Uint64Field); + MessageParsingHelpers.AssertRoundtrip(TestWellKnownTypes.Parser, message, parsed => + { + Assert.AreEqual("", parsed.StringField); + Assert.AreEqual(ByteString.Empty, parsed.BytesField); + Assert.AreEqual(false, parsed.BoolField); + Assert.AreEqual(0f, parsed.FloatField); + Assert.AreEqual(0d, parsed.DoubleField); + Assert.AreEqual(0, parsed.Int32Field); + Assert.AreEqual(0L, parsed.Int64Field); + Assert.AreEqual(0U, parsed.Uint32Field); + Assert.AreEqual(0UL, parsed.Uint64Field); + }); } [Test] @@ -140,12 +140,11 @@ public void RepeatedWrappersSerializeDeserialize() Uint32Field = { uint.MaxValue, uint.MinValue, 0U }, Uint64Field = { ulong.MaxValue, ulong.MinValue, 0UL }, }; - var bytes = message.ToByteArray(); - var parsed = RepeatedWellKnownTypes.Parser.ParseFrom(bytes); - Assert.AreEqual(message, parsed); // Just to test a single value for sanity... Assert.AreEqual("Second", message.StringField[1]); + + MessageParsingHelpers.AssertRoundtrip(RepeatedWellKnownTypes.Parser, message); } [Test] @@ -168,8 +167,7 @@ public void RepeatedWrappersBinaryFormat() var expectedBytes = rawOutput.ToArray(); var message = new RepeatedWellKnownTypes { Int32Field = { 5, 0 } }; - var actualBytes = message.ToByteArray(); - Assert.AreEqual(expectedBytes, actualBytes); + MessageParsingHelpers.AssertWritingMessage(RepeatedWellKnownTypes.Parser, message, expectedBytes); } [Test] @@ -194,12 +192,10 @@ public void MapWrappersSerializeDeserialize() Uint64Field = { { 18, ulong.MaxValue }, { 19, ulong.MinValue }, { 20, 0UL } }, }; - var bytes = message.ToByteArray(); - var parsed = MapWellKnownTypes.Parser.ParseFrom(bytes); - - Assert.AreEqual(message, parsed); // Just to test a single value for sanity... Assert.AreEqual("Second", message.StringField[12]); + + MessageParsingHelpers.AssertRoundtrip(MapWellKnownTypes.Parser, message); } [Test] @@ -288,10 +284,10 @@ public void Oneof() private void AssertOneofRoundTrip(OneofWellKnownTypes message) { // Normal roundtrip, but explicitly checking the case... - var bytes = message.ToByteArray(); - var parsed = OneofWellKnownTypes.Parser.ParseFrom(bytes); - Assert.AreEqual(message, parsed); - Assert.AreEqual(message.OneofFieldCase, parsed.OneofFieldCase); + MessageParsingHelpers.AssertRoundtrip(OneofWellKnownTypes.Parser, message, parsed => + { + Assert.AreEqual(message.OneofFieldCase, parsed.OneofFieldCase); + }); } [Test] @@ -306,15 +302,25 @@ private void AssertOneofRoundTrip(OneofWellKnownTypes message) [TestCase(null, null, null)] public void Merging(string original, string merged, string expected) { - var originalMessage = new TestWellKnownTypes { StringField = original }; var mergingMessage = new TestWellKnownTypes { StringField = merged }; - originalMessage.MergeFrom(mergingMessage); - Assert.AreEqual(expected, originalMessage.StringField); - // Try it using MergeFrom(CodedInputStream) too... - originalMessage = new TestWellKnownTypes { StringField = original }; - originalMessage.MergeFrom(mergingMessage.ToByteArray()); - Assert.AreEqual(expected, originalMessage.StringField); + MessageParsingHelpers.AssertMergingMessage( + TestWellKnownTypes.Parser, + () => + { + var originalMessage = new TestWellKnownTypes { StringField = original }; + originalMessage.MergeFrom(mergingMessage); + Assert.AreEqual(expected, originalMessage.StringField); + + // Try it using MergeFrom(CodedInputStream) too... + originalMessage = new TestWellKnownTypes { StringField = original }; + originalMessage.MergeFrom(mergingMessage.ToByteArray()); + Assert.AreEqual(expected, originalMessage.StringField); + + return originalMessage; + }, + mergingMessage.ToByteArray(), + mergedMessage => Assert.AreEqual(expected, mergedMessage.StringField)); } // Merging is odd with wrapper types, due to the way that default values aren't emitted in @@ -324,8 +330,6 @@ public void Merging(string original, string merged, string expected) [Test] public void MergingStreamExplicitValue() { - var message = new TestWellKnownTypes { Int32Field = 5 }; - // Create a byte array which has the data of an Int32Value explicitly containing a value of 0. // This wouldn't normally happen. byte[] bytes; @@ -342,25 +346,35 @@ public void MergingStreamExplicitValue() bytes = stream.ToArray(); } - message.MergeFrom(bytes); - // A normal implementation would have 0 now, as the explicit default would have been overwritten the 5. - // With the FieldCodec for Nullable, we can't tell the difference between an implicit 0 and an explicit 0. - Assert.AreEqual(5, message.Int32Field); + MessageParsingHelpers.AssertMergingMessage( + TestWellKnownTypes.Parser, + () => new TestWellKnownTypes { Int32Field = 5 }, + bytes, + mergedMessage => + { + // A normal implementation would have 0 now, as the explicit default would have been overwritten the 5. + // With the FieldCodec for Nullable, we can't tell the difference between an implicit 0 and an explicit 0. + Assert.AreEqual(5, mergedMessage.Int32Field); + }); } [Test] public void MergingStreamNoValue() { - var message = new TestWellKnownTypes { Int32Field = 5 }; - // Create a byte array which an Int32 field, but with no value. var bytes = new TestWellKnownTypes { Int32Field = 0 }.ToByteArray(); Assert.AreEqual(2, bytes.Length); // The tag for Int32Field is a single byte, then a byte indicating a 0-length message. - message.MergeFrom(bytes); - // The "implicit" 0 did *not* overwrite the value. - // (This is the correct behaviour.) - Assert.AreEqual(5, message.Int32Field); + MessageParsingHelpers.AssertMergingMessage( + TestWellKnownTypes.Parser, + () => new TestWellKnownTypes { Int32Field = 5 }, + bytes, + mergedMessage => + { + // The "implicit" 0 did *not* overwrite the value. + // (This is the correct behaviour.) + Assert.AreEqual(5, mergedMessage.Int32Field); + }); } // All permutations of origin/merging value being null, zero (default) or non-default. @@ -406,8 +420,10 @@ public void UnknownFieldInWrapperInt32FastPath() Assert.AreEqual(8, stream.Length); // tag (1 byte) + length (1 byte) + message (6 bytes) stream.Position = 0; - var message = TestWellKnownTypes.Parser.ParseFrom(stream); - Assert.AreEqual(65536, message.Int32Field); + MessageParsingHelpers.AssertReadingMessage( + TestWellKnownTypes.Parser, + stream.ToArray(), + message => Assert.AreEqual(65536, message.Int32Field)); } [Test] @@ -431,8 +447,10 @@ public void UnknownFieldInWrapperInt32SlowPath() Assert.Less(stream.Length, 8); // tag (1 byte) + length (1 byte) + message stream.Position = 0; - var message = TestWellKnownTypes.Parser.ParseFrom(stream); - Assert.AreEqual(6, message.Int32Field); + MessageParsingHelpers.AssertReadingMessage( + TestWellKnownTypes.Parser, + stream.ToArray(), + message => Assert.AreEqual(6, message.Int32Field)); } [Test] @@ -456,8 +474,10 @@ public void UnknownFieldInWrapperInt64FastPath() Assert.AreEqual(13, stream.Length); // tag (1 byte) + length (1 byte) + message (11 bytes) stream.Position = 0; - var message = TestWellKnownTypes.Parser.ParseFrom(stream); - Assert.AreEqual(0xfffffffffffffL, message.Int64Field); + MessageParsingHelpers.AssertReadingMessage( + TestWellKnownTypes.Parser, + stream.ToArray(), + message => Assert.AreEqual(0xfffffffffffffL, message.Int64Field)); } [Test] @@ -481,8 +501,10 @@ public void UnknownFieldInWrapperInt64SlowPath() Assert.Less(stream.Length, 12); // tag (1 byte) + length (1 byte) + message stream.Position = 0; - var message = TestWellKnownTypes.Parser.ParseFrom(stream); - Assert.AreEqual(6L, message.Int64Field); + MessageParsingHelpers.AssertReadingMessage( + TestWellKnownTypes.Parser, + stream.ToArray(), + message => Assert.AreEqual(6L, message.Int64Field)); } [Test] diff --git a/csharp/src/Google.Protobuf.Test/testprotos.pb b/csharp/src/Google.Protobuf.Test/testprotos.pb index d00db7fdeb76..40523b972f88 100644 Binary files a/csharp/src/Google.Protobuf.Test/testprotos.pb and b/csharp/src/Google.Protobuf.Test/testprotos.pb differ diff --git a/csharp/src/Google.Protobuf/ByteString.cs b/csharp/src/Google.Protobuf/ByteString.cs index 3eb00e5bb5c7..56a1e5cd5485 100644 --- a/csharp/src/Google.Protobuf/ByteString.cs +++ b/csharp/src/Google.Protobuf/ByteString.cs @@ -34,6 +34,7 @@ using System.Collections; using System.Collections.Generic; using System.IO; +using System.Security; using System.Text; #if !NET35 using System.Threading; @@ -115,7 +116,11 @@ public bool IsEmpty /// Provides read-only access to the data of this . /// No data is copied so this is the most efficient way of accessing. /// - public ReadOnlySpan Span => new ReadOnlySpan(bytes); + public ReadOnlySpan Span + { + [SecuritySafeCritical] + get { return new ReadOnlySpan(bytes); } + } #endif /// diff --git a/csharp/src/Google.Protobuf/CodedInputReader.cs b/csharp/src/Google.Protobuf/CodedInputReader.cs new file mode 100644 index 000000000000..51a64cf45b8f --- /dev/null +++ b/csharp/src/Google.Protobuf/CodedInputReader.cs @@ -0,0 +1,1339 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY +using System; +using System.Buffers; +using System.Buffers.Binary; +using System.Collections.Generic; +using System.IO; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Security; +using System.Text; +using Google.Protobuf.Collections; + +namespace Google.Protobuf +{ + /// + /// Reads and decodes protocol message fields. + /// Note: experimental API that can change or be removed without any prior notice. + /// + /// + /// + /// This class is generally used by generated code to read appropriate + /// primitives from the input. It effectively encapsulates the lowest + /// levels of protocol buffer format. + /// + /// + /// Repeated fields and map fields are not handled by this class; use + /// and to serialize such fields. + /// + /// + [SecuritySafeCritical] + public ref struct CodedInputReader + { + internal const int DefaultRecursionLimit = 100; + + private SequenceReader reader; + private uint lastTag; + private int recursionDepth; + private int currentLimit; + private Decoder decoder; + + private readonly int recursionLimit; + + + /// + /// Creates a new CodedInputReader reading data from the given . + /// + public CodedInputReader(ReadOnlySequence input) : this(input, DefaultRecursionLimit) + { + } + + internal CodedInputReader(ReadOnlySequence input, int recursionLimit) + { + this.reader = new SequenceReader(input); + this.lastTag = 0; + this.recursionDepth = 0; + this.recursionLimit = recursionLimit; + this.currentLimit = (int)this.reader.Length; + this.decoder = null; + this.DiscardUnknownFields = false; + this.ExtensionRegistry = null; + } + + /// + /// The total number of bytes processed by the reader. + /// + public long Position => reader.Consumed; + + /// + /// Returns true if the reader has reached the end of the input. This is the + /// case if either the end of the underlying input source has been reached or + /// the reader has reached a limit created using PushLimit. + /// + public bool IsAtEnd => reader.End; + + /// + /// Returns the last tag read, or 0 if no tags have been read or we've read beyond + /// the end of the input. + /// + internal uint LastTag { get { return lastTag; } } + + /// + /// Internal-only property; when set to true, unknown fields will be discarded while parsing. + /// + internal bool DiscardUnknownFields { get; set; } + + /// + /// Internal-only property; provides extension identifiers to compatible messages while parsing. + /// + internal ExtensionRegistry ExtensionRegistry { get; set; } + + /// + /// Creates a with the specified recursion limits, reading + /// from the input. + /// + /// + /// This method exists separately from the constructor to reduce the number of constructor overloads. + /// It is likely to be used considerably less frequently than the constructors, as the default limits + /// are suitable for most use cases. + /// + /// The input to read from + /// The maximum recursion depth to allow while reading. + /// A CodedInputReader reading from with the specified limits. + public static CodedInputReader CreateWithLimits(ReadOnlySequence input, int recursionLimit) + { + return new CodedInputReader(input, recursionLimit); + } + + #region Reading of tags etc + + /// + /// Peeks at the next field tag. This is like calling , but the + /// tag is not consumed. (So a subsequent call to will return the + /// same value.) + /// + public uint PeekTag() + { + uint previousTag = lastTag; + long consumed = reader.Consumed; + + uint tag = ReadTag(); + + long rewindCount = reader.Consumed - consumed; + if (rewindCount > 0) + { + reader.Rewind(rewindCount); + } + lastTag = previousTag; + + return tag; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + private static void ThrowInvalidTagException() + { + throw InvalidProtocolBufferException.InvalidTag(); + } + + /// + /// Reads a field tag, returning the tag of 0 for "end of input". + /// + /// + /// If this method returns 0, it doesn't necessarily mean the end of all + /// the data in this CodedInputReader; it may be the end of the logical input + /// for an embedded message, for example. + /// + /// The next field tag, or 0 for end of input. (0 is never a valid tag.) + public uint ReadTag() + { + if (ReachedLimit) + { + lastTag = 0; + return 0; + } + + // Optimize for common case of a 2 byte tag that is in the current span + var current = LimitedUnreadSpan; + if (current.Length >= 2) + { + int tmp = current[0]; + if (tmp < 128) + { + lastTag = (uint)tmp; + reader.Advance(1); + } + else + { + int result = tmp & 0x7f; + if ((tmp = current[1]) < 128) + { + result |= tmp << 7; + lastTag = (uint)result; + reader.Advance(2); + } + else + { + // Nope, go the potentially slow route. + lastTag = ReadRawVarint32(); + } + } + } + else + { + if (IsAtEnd) + { + lastTag = 0; + return 0; + } + + lastTag = ReadRawVarint32(); + } + + if (WireFormat.GetTagFieldNumber(lastTag) == 0) + { + // If we actually read a tag with a field of 0, that's not a valid tag. + ThrowInvalidTagException(); + } + + return lastTag; + } + + /// + /// Skips the data for the field with the tag we've just read. + /// This should be called directly after , when + /// the caller wishes to skip an unknown field. + /// + /// + /// This method throws if the last-read tag was an end-group tag. + /// If a caller wishes to skip a group, they should skip the whole group, by calling this method after reading the + /// start-group tag. This behavior allows callers to call this method on any field they don't understand, correctly + /// resulting in an error if an end-group tag has not been paired with an earlier start-group tag. + /// + /// The last tag was an end-group tag + /// The last read operation read to the end of the logical input + public void SkipLastField() + { + if (lastTag == 0) + { + throw new InvalidOperationException("SkipLastField cannot be called at the end of a input"); + } + switch (WireFormat.GetTagWireType(lastTag)) + { + case WireFormat.WireType.StartGroup: + SkipGroup(lastTag); + break; + case WireFormat.WireType.EndGroup: + throw new InvalidProtocolBufferException( + "SkipLastField called on an end-group tag, indicating that the corresponding start-group was missing"); + case WireFormat.WireType.Fixed32: + ReadFixed32(); + break; + case WireFormat.WireType.Fixed64: + ReadFixed64(); + break; + case WireFormat.WireType.LengthDelimited: + var length = ReadLength(); + SkipRawBytes(length); + break; + case WireFormat.WireType.Varint: + ReadRawVarint32(); + break; + } + } + + private void SkipRawBytes(int length) + { + if (length < 0) + { + throw InvalidProtocolBufferException.NegativeSize(); + } + + CheckRequestedDataAvailable(length); + + reader.Advance(length); + } + + /// + /// Skip a group. + /// + internal void SkipGroup(uint startGroupTag) + { + // Note: Currently we expect this to be the way that groups are read. We could put the recursion + // depth changes into the ReadTag method instead, potentially... + recursionDepth++; + if (recursionDepth >= recursionLimit) + { + throw InvalidProtocolBufferException.RecursionLimitExceeded(); + } + uint tag; + while (true) + { + tag = ReadTag(); + if (tag == 0) + { + throw InvalidProtocolBufferException.TruncatedMessage(); + } + // Can't call SkipLastField for this case- that would throw. + if (WireFormat.GetTagWireType(tag) == WireFormat.WireType.EndGroup) + { + break; + } + // This recursion will allow us to handle nested groups. + SkipLastField(); + } + int startField = WireFormat.GetTagFieldNumber(startGroupTag); + int endField = WireFormat.GetTagFieldNumber(tag); + if (startField != endField) + { + throw new InvalidProtocolBufferException( + $"Mismatched end-group tag. Started with field {startField}; ended with field {endField}"); + } + recursionDepth--; + } + + /// + /// Reads a double field from the input. + /// + public double ReadDouble() + { + return BitConverter.Int64BitsToDouble((long)ReadRawLittleEndian64()); + } + + /// + /// Reads a float field from the input. + /// + public float ReadFloat() + { + const int length = sizeof(float); + + ReadOnlySpan current = LimitedUnreadSpan; + if (BitConverter.IsLittleEndian && current.Length >= length) + { + // Fast path. All data is in the current span and we're little endian architecture. + reader.Advance(length); + + // ReadUnaligned uses processor architecture for endianness. Content is little endian and + // IsLittleEndian has been checked so this is safe to call. + return Unsafe.ReadUnaligned(ref MemoryMarshal.GetReference(current)); + } + else + { + return ReadFloatSlow(); + } + } + + private unsafe float ReadFloatSlow() + { + const int length = sizeof(float); + + byte* buffer = stackalloc byte[length]; + Span tempSpan = new Span(buffer, length); + + CopyToSlow(tempSpan); + reader.Advance(length); + + // Content is little endian. Reverse if needed to match endianness of architecture. + if (!BitConverter.IsLittleEndian) + { + tempSpan.Reverse(); + } + + // ReadUnaligned uses processor architecture for endianness. Content is little endian and + // IsLittleEndian has been checked so this is safe to call. + return Unsafe.ReadUnaligned(ref MemoryMarshal.GetReference(tempSpan)); + } + + /// + /// Reads a uint64 field from the input. + /// + public ulong ReadUInt64() + { + return ReadRawVarint64(); + } + + /// + /// Reads an int64 field from the input. + /// + public long ReadInt64() + { + return (long)ReadRawVarint64(); + } + + /// + /// Reads an int32 field from the input. + /// + public int ReadInt32() + { + return (int)ReadRawVarint32(); + } + + /// + /// Reads a fixed64 field from the input. + /// + public ulong ReadFixed64() + { + return ReadRawLittleEndian64(); + } + + /// + /// Reads a fixed32 field from the input. + /// + public uint ReadFixed32() + { + return ReadRawLittleEndian32(); + } + + /// + /// Reads a bool field from the input. + /// + public bool ReadBool() + { + return ReadRawVarint64() != 0; + } + + /// + /// Reads a string field from the input. + /// + public string ReadString() + { + int length = ReadLength(); + + if (length == 0) + { + return string.Empty; + } + + if (length < 0) + { + throw InvalidProtocolBufferException.NegativeSize(); + } + +#if GOOGLE_PROTOBUF_SUPPORT_FAST_STRING + ReadOnlySpan unreadSpan = LimitedUnreadSpan; + if (unreadSpan.Length >= length) + { + // Fast path: all bytes to decode appear in the same span. + ReadOnlySpan data = unreadSpan.Slice(0, length); + + string value; + unsafe + { + fixed (byte* sourceBytes = &MemoryMarshal.GetReference(data)) + { + value = CodedOutputStream.Utf8Encoding.GetString(sourceBytes, length); + } + } + + reader.Advance(length); + return value; + } +#endif + + return ReadStringSlow(length); + } + + /// + /// Reads a string assuming that it is spread across multiple spans in the . + /// + /// The length of the string to be decoded, in bytes. + /// The decoded string. + private string ReadStringSlow(int byteLength) + { + CheckRequestedDataAvailable(byteLength); + + if (decoder == null) + { + decoder = CodedOutputStream.Utf8Encoding.GetDecoder(); + } + + // We need to decode bytes incrementally across multiple spans. + int maxCharLength = CodedOutputStream.Utf8Encoding.GetMaxCharCount(byteLength); + char[] charArray = ArrayPool.Shared.Rent(maxCharLength); + + try + { + int remainingByteLength = byteLength; + int initializedChars = 0; + while (remainingByteLength > 0) + { + var unreadSpan = LimitedUnreadSpan; + int bytesRead = Math.Min(remainingByteLength, unreadSpan.Length); + remainingByteLength -= bytesRead; + bool flush = remainingByteLength == 0; + + unsafe + { + fixed (byte* pUnreadSpan = &MemoryMarshal.GetReference(unreadSpan)) + fixed (char* pCharArray = &charArray[initializedChars]) + { + initializedChars += decoder.GetChars(pUnreadSpan, bytesRead, pCharArray, charArray.Length - initializedChars, flush); + } + + reader.Advance(bytesRead); + } + } + + string value = new string(charArray, 0, initializedChars); + return value; + } + finally + { + ArrayPool.Shared.Return(charArray); + } + } + + /// + /// Reads an embedded message field value from the input. + /// + public void ReadMessage(IBufferMessage builder) + { + int length = ReadLength(); + if (recursionDepth >= recursionLimit) + { + throw InvalidProtocolBufferException.RecursionLimitExceeded(); + } + int oldLimit = PushLimit(length); + ++recursionDepth; + builder.MergeFrom(ref this); + CheckReadEndOfInputTag(); + // Check that we've read exactly as much data as expected. + if (!ReachedLimit) + { + throw InvalidProtocolBufferException.TruncatedMessage(); + } + --recursionDepth; + PopLimit(oldLimit); + } + + /// + /// Reads an embedded group field from the input. + /// + public void ReadGroup(IBufferMessage builder) + { + if (recursionDepth >= recursionLimit) + { + throw InvalidProtocolBufferException.RecursionLimitExceeded(); + } + ++recursionDepth; + builder.MergeFrom(ref this); + --recursionDepth; + } + + /// + /// Reads a bytes field value from the input. + /// + public ByteString ReadBytes() + { + int length = ReadLength(); + + if (length == 0) + { + return ByteString.Empty; + } + + if (length < 0) + { + throw InvalidProtocolBufferException.NegativeSize(); + } + + CheckRequestedDataAvailable(length); + + // Avoid creating a copy of Sequence if data is on current span + var unreadSpan = LimitedUnreadSpan; + var data = (unreadSpan.Length >= length) + ? unreadSpan.Slice(0, length).ToArray() + : reader.Sequence.Slice(reader.Position, length).ToArray(); + + reader.Advance(length); + + return ByteString.AttachBytes(data); + } + + /// + /// Reads a uint32 field value from the input. + /// + public uint ReadUInt32() + { + return ReadRawVarint32(); + } + + /// + /// Reads an enum field value from the input. + /// + public int ReadEnum() + { + // Currently just a pass-through, but it's nice to separate it logically from WriteInt32. + return (int)ReadRawVarint32(); + } + + /// + /// Reads an sfixed32 field value from the input. + /// + public int ReadSFixed32() + { + return (int)ReadRawLittleEndian32(); + } + + /// + /// Reads an sfixed64 field value from the input. + /// + public long ReadSFixed64() + { + return (long)ReadRawLittleEndian64(); + } + + /// + /// Reads an sint32 field value from the input. + /// + public int ReadSInt32() + { + return CodedInputStream.DecodeZigZag32(ReadRawVarint32()); + } + + /// + /// Reads an sint64 field value from the input. + /// + public long ReadSInt64() + { + return CodedInputStream.DecodeZigZag64(ReadRawVarint64()); + } + + /// + /// Reads a length for length-delimited data. + /// + /// + /// This is internally just reading a varint, but this method exists + /// to make the calling code clearer. + /// + public int ReadLength() + { + return (int)ReadRawVarint32(); + } + + /// + /// Peeks at the next tag in the input. If it matches , + /// the tag is consumed and the method returns true; otherwise, the + /// input is left in the original position and the method returns false. + /// + public bool MaybeConsumeTag(uint tag) + { + uint previousTag = lastTag; + long consumed = reader.Consumed; + + uint newTag = ReadTag(); + if (newTag == tag) + { + // Match so consume tag + return true; + } + + // No match so rewind + long rewindCount = reader.Consumed - consumed; + if (rewindCount > 0) + { + reader.Rewind(rewindCount); + } + lastTag = previousTag; + + return false; + } + + internal static float? ReadFloatWrapperLittleEndian(ref CodedInputReader input) + { + // length:1 + tag:1 + value:4 = 6 bytes + const int wrapperLength = 6; + + var remaining = input.LimitedUnreadSpan; + if (remaining.Length >= wrapperLength) + { + // The entire wrapper message is already contained in `buffer`. + int length = remaining[0]; + if (length == 0) + { + input.reader.Advance(1); + return 0F; + } + // tag:1 + value:4 = length of 5 bytes + // field=1, type=32-bit = tag of 13 + if (length != wrapperLength - 1 || remaining[1] != 13) + { + return ReadFloatWrapperSlow(ref input); + } + // ReadUnaligned uses processor architecture for endianness. Content is little endian and + // IsLittleEndian has been checked so this is safe to call. + var result = Unsafe.ReadUnaligned(ref MemoryMarshal.GetReference(remaining.Slice(2))); + input.reader.Advance(wrapperLength); + return result; + } + else + { + return ReadFloatWrapperSlow(ref input); + } + } + + internal static float? ReadFloatWrapperSlow(ref CodedInputReader input) + { + int length = input.ReadLength(); + if (length == 0) + { + return 0F; + } + long finalBufferPos = input.reader.Consumed + length; + float result = 0F; + do + { + // field=1, type=32-bit = tag of 13 + if (input.ReadTag() == 13) + { + result = input.ReadFloat(); + } + else + { + input.SkipLastField(); + } + } + while (input.reader.Consumed < finalBufferPos); + return result; + } + + internal static double? ReadDoubleWrapperLittleEndian(ref CodedInputReader input) + { + // length:1 + tag:1 + value:8 = 10 bytes + const int wrapperLength = 10; + + var remaining = input.LimitedUnreadSpan; + if (remaining.Length >= wrapperLength) + { + // The entire wrapper message is already contained in `buffer`. + int length = remaining[0]; + if (length == 0) + { + input.reader.Advance(1); + return 0D; + } + // tag:1 + value:8 = length of 9 bytes + // field=1, type=64-bit = tag of 9 + if (length != wrapperLength - 1 || remaining[1] != 9) + { + return ReadDoubleWrapperSlow(ref input); + } + // ReadUnaligned uses processor architecture for endianness. Content is little endian and + // IsLittleEndian has been checked so this is safe to call. + var result = Unsafe.ReadUnaligned(ref MemoryMarshal.GetReference(remaining.Slice(2))); + input.reader.Advance(wrapperLength); + return result; + } + else + { + return ReadDoubleWrapperSlow(ref input); + } + } + + internal static double? ReadDoubleWrapperSlow(ref CodedInputReader input) + { + int length = input.ReadLength(); + if (length == 0) + { + return 0D; + } + long finalBufferPos = input.reader.Consumed + length; + double result = 0D; + do + { + // field=1, type=64-bit = tag of 9 + if (input.ReadTag() == 9) + { + result = input.ReadDouble(); + } + else + { + input.SkipLastField(); + } + } + while (input.reader.Consumed < finalBufferPos); + return result; + } + + internal static bool? ReadBoolWrapper(ref CodedInputReader input) + { + return ReadUInt64Wrapper(ref input) != 0; + } + + internal static uint? ReadUInt32Wrapper(ref CodedInputReader input) + { + // length:1 + tag:1 + value:5(varint32-max) = 7 bytes + const int wrapperLength = 7; + + var remaining = input.LimitedUnreadSpan; + if (remaining.Length >= wrapperLength) + { + // The entire wrapper message is already contained in `buffer`. + int length = remaining[0]; + if (length == 0) + { + input.reader.Advance(1); + return 0; + } + // Length will always fit in a single byte. + if (length >= 128) + { + return ReadUInt32WrapperSlow(ref input); + } + long finalBufferPos = input.reader.Consumed + length + 1; + // field=1, type=varint = tag of 8 + if (remaining[1] != 8) + { + return ReadUInt32WrapperSlow(ref input); + } + long pos0 = input.reader.Consumed; + input.reader.Advance(2); + var result = input.ReadUInt32(); + // Verify this message only contained a single field. + if (input.reader.Consumed != finalBufferPos) + { + input.reader.Rewind(input.reader.Consumed - pos0); + return ReadUInt32WrapperSlow(ref input); + } + return result; + } + else + { + return ReadUInt32WrapperSlow(ref input); + } + } + + private static uint? ReadUInt32WrapperSlow(ref CodedInputReader input) + { + int length = input.ReadLength(); + if (length == 0) + { + return 0; + } + long finalBufferPos = input.reader.Consumed + length; + uint result = 0; + do + { + // field=1, type=varint = tag of 8 + if (input.ReadTag() == 8) + { + result = input.ReadUInt32(); + } + else + { + input.SkipLastField(); + } + } + while (input.reader.Consumed < finalBufferPos); + return result; + } + + internal static int? ReadInt32Wrapper(ref CodedInputReader input) + { + return (int?)ReadUInt32Wrapper(ref input); + } + + internal static ulong? ReadUInt64Wrapper(ref CodedInputReader input) + { + // field=1, type=varint = tag of 8 + const int expectedTag = 8; + // length:1 + tag:1 + value:10(varint64-max) = 12 bytes + const int wrapperLength = 12; + + var remaining = input.LimitedUnreadSpan; + if (remaining.Length >= wrapperLength) + { + // The entire wrapper message is already contained in `buffer`. + int length = remaining[0]; + if (length == 0) + { + input.reader.Advance(1); + return 0; + } + // Length will always fit in a single byte. + if (length >= 128) + { + return ReadUInt64WrapperSlow(ref input); + } + long finalBufferPos = input.reader.Consumed + length + 1; + if (remaining[1] != expectedTag) + { + return ReadUInt64WrapperSlow(ref input); + } + long pos0 = input.reader.Consumed; + input.reader.Advance(2); + var result = input.ReadUInt64(); + // Verify this message only contained a single field. + if (input.reader.Consumed != finalBufferPos) + { + input.reader.Rewind(input.reader.Consumed - pos0); + return ReadUInt64WrapperSlow(ref input); + } + return result; + } + else + { + return ReadUInt64WrapperSlow(ref input); + } + } + + internal static ulong? ReadUInt64WrapperSlow(ref CodedInputReader input) + { + // field=1, type=varint = tag of 8 + const int expectedTag = 8; + + int length = input.ReadLength(); + if (length == 0) + { + return 0L; + } + long finalBufferPos = input.reader.Consumed + length; + ulong result = 0L; + do + { + if (input.ReadTag() == expectedTag) + { + result = input.ReadUInt64(); + } + else + { + input.SkipLastField(); + } + } + while (input.reader.Consumed < finalBufferPos); + return result; + } + + internal static long? ReadInt64Wrapper(ref CodedInputReader input) + { + return (long?)ReadUInt64Wrapper(ref input); + } + + #endregion + + #region Underlying reading primitives + + /// + /// Same code as ReadRawVarint32, but read each byte from reader individually + /// + private uint SlowReadRawVarint32() + { + byte value = ReadByteSlow(); + int tmp = value; + if (tmp < 128) + { + return (uint)tmp; + } + int result = tmp & 0x7f; + value = ReadByteSlow(); + tmp = value; + if (tmp < 128) + { + result |= tmp << 7; + } + else + { + result |= (tmp & 0x7f) << 7; + value = ReadByteSlow(); + tmp = value; + if (tmp < 128) + { + result |= tmp << 14; + } + else + { + result |= (tmp & 0x7f) << 14; + value = ReadByteSlow(); + tmp = value; + if (tmp < 128) + { + result |= tmp << 21; + } + else + { + result |= (tmp & 0x7f) << 21; + value = ReadByteSlow(); + tmp = value; + result |= tmp << 28; + if (tmp >= 128) + { + // Discard upper 32 bits. + // Note that this has to use ReadByteSlow() as we only ensure we've + // got at least 5 bytes at the start of the method. This lets us + // use the fast path in more cases, and we rarely hit this section of code. + for (int i = 0; i < 5; i++) + { + value = ReadByteSlow(); + tmp = value; + if (tmp < 128) + { + return (uint)result; + } + } + throw InvalidProtocolBufferException.MalformedVarint(); + } + } + } + } + return (uint)result; + } + + /// + /// Reads a raw Varint from the input. If larger than 32 bits, discard the upper bits. + /// This method is optimised for the case where we've got lots of data in the buffer. + /// That means we can check the size just once, then just read directly from the buffer + /// without constant rechecking of the buffer length. + /// + internal uint ReadRawVarint32() + { + var current = LimitedUnreadSpan; + + if (current.Length < 5) + { + return SlowReadRawVarint32(); + } + + int bufferPos = 0; + int tmp = current[bufferPos++]; + if (tmp < 128) + { + reader.Advance(bufferPos); + return (uint)tmp; + } + int result = tmp & 0x7f; + if ((tmp = current[bufferPos++]) < 128) + { + result |= tmp << 7; + } + else + { + result |= (tmp & 0x7f) << 7; + if ((tmp = current[bufferPos++]) < 128) + { + result |= tmp << 14; + } + else + { + result |= (tmp & 0x7f) << 14; + if ((tmp = current[bufferPos++]) < 128) + { + result |= tmp << 21; + } + else + { + result |= (tmp & 0x7f) << 21; + result |= (tmp = current[bufferPos++]) << 28; + if (tmp >= 128) + { + reader.Advance(bufferPos); + + // Discard upper 32 bits. + // Note that this has to use ReadByteSlow() as we only ensure we've + // got at least 5 bytes at the start of the method. This lets us + // use the fast path in more cases, and we rarely hit this section of code. + for (int i = 0; i < 5; i++) + { + var value = ReadByteSlow(); + tmp = value; + if (tmp < 128) + { + return (uint)result; + } + } + throw InvalidProtocolBufferException.MalformedVarint(); + } + } + } + } + reader.Advance(bufferPos); + return (uint)result; + } + + /// + /// Same code as ReadRawVarint64, but read each byte from reader individually + /// + private ulong SlowReadRawVarint64() + { + int shift = 0; + ulong result = 0; + while (shift < 64) + { + byte b = ReadByteSlow(); + result |= (ulong)(b & 0x7F) << shift; + if ((b & 0x80) == 0) + { + return result; + } + shift += 7; + } + throw InvalidProtocolBufferException.MalformedVarint(); + } + + /// + /// Reads a raw varint from the input. + /// + internal ulong ReadRawVarint64() + { + var current = LimitedUnreadSpan; + + if (current.Length < 10) + { + return SlowReadRawVarint64(); + } + + int bufferPos = 0; + ulong result = current[bufferPos++]; + if (result < 128) + { + reader.Advance(bufferPos); + return result; + } + result &= 0x7f; + int shift = 7; + do + { + byte b = current[bufferPos++]; + result |= (ulong)(b & 0x7F) << shift; + if (b < 0x80) + { + reader.Advance(bufferPos); + return result; + } + shift += 7; + } + while (shift < 64); + + throw InvalidProtocolBufferException.MalformedVarint(); + } + + /// + /// Reads a 32-bit little-endian integer from the input. + /// + internal uint ReadRawLittleEndian32() + { + const int length = 4; + + ReadOnlySpan current = LimitedUnreadSpan; + if (current.Length >= length) + { + // Fast path. All data is in the current span. + reader.Advance(length); + + return BinaryPrimitives.ReadUInt32LittleEndian(current); + } + else + { + return ReadRawLittleEndian32Slow(); + } + } + + private unsafe uint ReadRawLittleEndian32Slow() + { + const int length = 4; + + byte* buffer = stackalloc byte[length]; + Span tempSpan = new Span(buffer, length); + + CopyToSlow(tempSpan); + reader.Advance(length); + + return BinaryPrimitives.ReadUInt32LittleEndian(tempSpan); + } + + /// + /// Reads a 64-bit little-endian integer from the input. + /// + internal unsafe ulong ReadRawLittleEndian64() + { + const int length = 8; + + ReadOnlySpan current = LimitedUnreadSpan; + if (current.Length >= length) + { + // Fast path. All data is in the current span. + reader.Advance(length); + + return BinaryPrimitives.ReadUInt64LittleEndian(current); + } + else + { + return ReadRawLittleEndian64Slow(); + } + } + + private unsafe ulong ReadRawLittleEndian64Slow() + { + const int length = 8; + + byte* buffer = stackalloc byte[length]; + Span tempSpan = new Span(buffer, length); + + CopyToSlow(tempSpan); + reader.Advance(length); + + return BinaryPrimitives.ReadUInt64LittleEndian(tempSpan); + } + #endregion + + /// + /// Sets currentLimit to (current position) + byteLimit. This is called + /// when descending into a length-delimited embedded message. The previous + /// limit is returned. + /// + /// The old limit. + internal int PushLimit(int byteLimit) + { + if (byteLimit < 0) + { + throw InvalidProtocolBufferException.NegativeSize(); + } + + byteLimit += (int)reader.Consumed; + int oldLimit = currentLimit; + if (byteLimit > oldLimit) + { + throw InvalidProtocolBufferException.TruncatedMessage(); + } + currentLimit = byteLimit; + + return oldLimit; + } + + /// + /// Discards the current limit, returning the previous limit. + /// + internal void PopLimit(int oldLimit) + { + currentLimit = oldLimit; + } + + /// + /// Returns whether or not all the data before the limit has been read. + /// + /// + internal bool ReachedLimit + { + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get + { + return reader.Consumed >= currentLimit; + } + } + + /// + /// Verifies that the last call to ReadTag() returned tag 0 - in other words, + /// we've reached the end of the input when we expected to. + /// + /// The + /// tag read was not the one specified + internal void CheckReadEndOfInputTag() + { + if (lastTag != 0) + { + throw InvalidProtocolBufferException.MoreDataAvailable(); + } + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private void ThrowEndOfInputIfFalse(bool condition) + { + if (!condition) + { + ThrowEndOfInput(); + return; + } + } + + [MethodImpl(MethodImplOptions.NoInlining)] + private static void ThrowEndOfInput() + { + throw InvalidProtocolBufferException.TruncatedMessage(); + } + + [MethodImpl(MethodImplOptions.NoInlining)] + private static void ThrowTruncatedMessage() + { + throw InvalidProtocolBufferException.TruncatedMessage(); + } + + private byte ReadByteSlow() + { + ThrowEndOfInputIfFalse(reader.TryRead(out byte b)); + + if (reader.Consumed > currentLimit) + { + ThrowTruncatedMessage(); + } + + return b; + } + + private void CheckRequestedDataAvailable(int length) + { + if (length + reader.Consumed > currentLimit) + { + // Read to the end of the limit. + reader.Advance(Math.Min(currentLimit, reader.Remaining)); + // Then fail. + ThrowTruncatedMessage(); + } + if (reader.Remaining < length) + { + // Read to the end of the content. + reader.Advance(reader.Remaining); + // Then fail. + ThrowEndOfInput(); + } + } + + private void CopyToSlow(Span destination) + { + CheckRequestedDataAvailable(destination.Length); + + reader.TryCopyTo(destination); + } + + private ReadOnlySpan LimitedUnreadSpan + { + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get + { + // Get the current unread span content. This content is limited to content for the current message. + // When all the content we want to read is within the span's length then we can go down a fast path. + return reader.CurrentSpan.Slice(reader.CurrentSpanIndex, Math.Min(currentLimit, reader.CurrentSpan.Length) - reader.CurrentSpanIndex); + } + } + } +} +#endif \ No newline at end of file diff --git a/csharp/src/Google.Protobuf/CodedOutputWriter.cs b/csharp/src/Google.Protobuf/CodedOutputWriter.cs new file mode 100644 index 000000000000..db5e88f179ab --- /dev/null +++ b/csharp/src/Google.Protobuf/CodedOutputWriter.cs @@ -0,0 +1,702 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY +using System; +using System.Buffers; +using System.Buffers.Binary; +using System.IO; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Security; +using System.Text; + +namespace Google.Protobuf +{ + /// + /// Encodes and writes protocol message fields. + /// Note: experimental API that can change or be removed without any prior notice. + /// + /// + /// + /// This class is generally used by generated code to write appropriate + /// primitives to the stream. It effectively encapsulates the lowest + /// levels of protocol buffer format. Unlike some other implementations, + /// this does not include combined "write tag and value" methods. Generated + /// code knows the exact byte representations of the tags they're going to write, + /// so there's no need to re-encode them each time. Manually-written code calling + /// this class should just call one of the WriteTag overloads before each value. + /// + /// + /// Repeated fields and map fields are not handled by this class; use RepeatedField<T> + /// and MapField<TKey, TValue> to serialize such fields. + /// + /// + [SecuritySafeCritical] + public ref struct CodedOutputWriter + { + private Encoder encoder; + + /// + /// The underlying . + /// + private IBufferWriter output; + + /// + /// The cached span. + /// + private Span span; + + /// + /// The number of uncommitted bytes in the cached span. + /// + private int buffered; + + /// + /// Creates a new CodedOutputWriter that writes to the given + /// . + /// + /// The to write to. + public CodedOutputWriter(IBufferWriter writer) + { + buffered = 0; + + span = writer.GetSpan(); + + this.output = writer; + this.encoder = null; + } + + #region Writing of values (not including tags) + + /// + /// Writes a double field value, without a tag, to the stream. + /// + /// The value to write + public void WriteDouble(double value) + { + WriteRawLittleEndian64((ulong) BitConverter.DoubleToInt64Bits(value)); + } + + /// + /// Writes a float field value, without a tag, to the stream. + /// + /// The value to write + public void WriteFloat(float value) + { + const int length = sizeof(float); + + Ensure(length); + + var floatSpan = span.Slice(buffered, length); + + Unsafe.WriteUnaligned(ref MemoryMarshal.GetReference(floatSpan), value); + + if (!BitConverter.IsLittleEndian) + { + floatSpan.Reverse(); + } + + buffered += length; + } + + /// + /// Writes a uint64 field value, without a tag, to the stream. + /// + /// The value to write + public void WriteUInt64(ulong value) + { + WriteRawVarint64(value); + } + + /// + /// Writes an int64 field value, without a tag, to the stream. + /// + /// The value to write + public void WriteInt64(long value) + { + WriteRawVarint64((ulong) value); + } + + /// + /// Writes an int32 field value, without a tag, to the stream. + /// + /// The value to write + public void WriteInt32(int value) + { + if (value >= 0) + { + WriteRawVarint32((uint) value); + } + else + { + // Must sign-extend. + WriteRawVarint64((ulong) value); + } + } + + /// + /// Writes a fixed64 field value, without a tag, to the stream. + /// + /// The value to write + public void WriteFixed64(ulong value) + { + WriteRawLittleEndian64(value); + } + + /// + /// Writes a fixed32 field value, without a tag, to the stream. + /// + /// The value to write + public void WriteFixed32(uint value) + { + WriteRawLittleEndian32(value); + } + + /// + /// Writes a bool field value, without a tag, to the stream. + /// + /// The value to write + public void WriteBool(bool value) + { + WriteRawByte(value ? (byte) 1 : (byte) 0); + } + + /// + /// Writes a string field value, without a tag, to the stream. + /// The data is length-prefixed. + /// + /// The value to write + public void WriteString(string value) + { + int length = Encoding.UTF8.GetByteCount(value); + WriteLength(length); + + if (span.Length < length + buffered) + { + // String doesn't fit in the remaining buffer. + + // Refresh span with default size. + // We don't want to specify an exact size because a very large span won't be pooled. + EnsureMore(); + + if (span.Length < length + buffered) + { + // String doesn't fit in refreshed buffer. Write across multiple + WriteStringMultiBuffer(value); + } + else + { + // String now fits in refreshed buffer + WriteStringSingleBuffer(value, length); + } + } + else + { + // String fits in remaining buffer space + WriteStringSingleBuffer(value, length); + } + } + + private void WriteStringSingleBuffer(string value, int length) + { + // Can write string to a single buffer + Span buffer = span.Slice(buffered); + + if (length == value.Length) + { + // Fast path when all content is ASCII + for (int i = 0; i < length; i++) + { + buffer[i] = (byte)value[i]; + } + + buffered += length; + } + else + { + ReadOnlySpan source = value.AsSpan(); + + int bytesUsed; + + unsafe + { + fixed (char* sourceChars = &MemoryMarshal.GetReference(source)) + fixed (byte* destinationBytes = &MemoryMarshal.GetReference(buffer)) + { + bytesUsed = Encoding.UTF8.GetBytes(sourceChars, source.Length, destinationBytes, buffer.Length); + } + } + + buffered += bytesUsed; + } + } + + private void WriteStringMultiBuffer(string value) + { + // The destination byte array might not be large enough so multiple writes are sometimes required + if (encoder == null) + { + encoder = Encoding.UTF8.GetEncoder(); + } + + ReadOnlySpan source = value.AsSpan(); + int written = 0; + + while (true) + { + int bytesUsed; + int charsUsed; + + unsafe + { + fixed (char* sourceChars = &MemoryMarshal.GetReference(source)) + fixed (byte* destinationBytes = &MemoryMarshal.GetReference(span)) + { + encoder.Convert(sourceChars, source.Length, destinationBytes, span.Length, false, out charsUsed, out bytesUsed, out _); + } + } + + source = source.Slice(charsUsed); + written += bytesUsed; + + buffered += bytesUsed; + + if (source.Length == 0) + { + break; + } + + EnsureMore(); + } + } + + /// + /// Writes a message, without a tag, to the stream. + /// The data is length-prefixed. + /// + /// The value to write + public void WriteMessage(IBufferMessage value) + { + WriteLength(value.CalculateSize()); + value.WriteTo(ref this); + } + + /// + /// Writes a group, without a tag, to the stream. + /// + /// The value to write + public void WriteGroup(IBufferMessage value) + { + value.WriteTo(ref this); + } + + /// + /// Write a byte string, without a tag, to the stream. + /// The data is length-prefixed. + /// + /// The value to write + public void WriteBytes(ByteString value) + { + WriteLength(value.Length); + + Write(value.Span); + } + + /// + /// Writes a uint32 value, without a tag, to the stream. + /// + /// The value to write + public void WriteUInt32(uint value) + { + WriteRawVarint32(value); + } + + /// + /// Writes an enum value, without a tag, to the stream. + /// + /// The value to write + public void WriteEnum(int value) + { + WriteInt32(value); + } + + /// + /// Writes an sfixed32 value, without a tag, to the stream. + /// + /// The value to write. + public void WriteSFixed32(int value) + { + WriteRawLittleEndian32((uint) value); + } + + /// + /// Writes an sfixed64 value, without a tag, to the stream. + /// + /// The value to write + public void WriteSFixed64(long value) + { + WriteRawLittleEndian64((ulong) value); + } + + /// + /// Writes an sint32 value, without a tag, to the stream. + /// + /// The value to write + public void WriteSInt32(int value) + { + WriteRawVarint32(CodedOutputStream.EncodeZigZag32(value)); + } + + /// + /// Writes an sint64 value, without a tag, to the stream. + /// + /// The value to write + public void WriteSInt64(long value) + { + WriteRawVarint64(CodedOutputStream.EncodeZigZag64(value)); + } + + /// + /// Writes a length (in bytes) for length-delimited data. + /// + /// + /// This method simply writes a rawint, but exists for clarity in calling code. + /// + /// Length value, in bytes. + public void WriteLength(int length) + { + WriteRawVarint32((uint) length); + } + + #endregion + + #region Raw tag writing + /// + /// Encodes and writes a tag. + /// + /// The number of the field to write the tag for + /// The wire format type of the tag to write + public void WriteTag(int fieldNumber, WireFormat.WireType type) + { + WriteRawVarint32(WireFormat.MakeTag(fieldNumber, type)); + } + + /// + /// Writes an already-encoded tag. + /// + /// The encoded tag + public void WriteTag(uint tag) + { + WriteRawVarint32(tag); + } + + /// + /// Writes the given single-byte tag directly to the stream. + /// + /// The encoded tag + public void WriteRawTag(byte b1) + { + if (buffered > span.Length) + { + EnsureMore(1); + } + + span[buffered++] = b1; + } + + /// + /// Writes the given two-byte tag directly to the stream. + /// + /// The first byte of the encoded tag + /// The second byte of the encoded tag + public void WriteRawTag(byte b1, byte b2) + { + if (buffered + 1 > span.Length) + { + EnsureMore(2); + } + + span[buffered++] = b1; + span[buffered++] = b2; + } + + /// + /// Writes the given three-byte tag directly to the stream. + /// + /// The first byte of the encoded tag + /// The second byte of the encoded tag + /// The third byte of the encoded tag + public void WriteRawTag(byte b1, byte b2, byte b3) + { + if (buffered + 2 > span.Length) + { + EnsureMore(3); + } + + span[buffered++] = b1; + span[buffered++] = b2; + span[buffered++] = b3; + } + + /// + /// Writes the given four-byte tag directly to the stream. + /// + /// The first byte of the encoded tag + /// The second byte of the encoded tag + /// The third byte of the encoded tag + /// The fourth byte of the encoded tag + public void WriteRawTag(byte b1, byte b2, byte b3, byte b4) + { + if (buffered + 3 > span.Length) + { + EnsureMore(4); + } + + span[buffered++] = b1; + span[buffered++] = b2; + span[buffered++] = b3; + span[buffered++] = b4; + } + + /// + /// Writes the given five-byte tag directly to the stream. + /// + /// The first byte of the encoded tag + /// The second byte of the encoded tag + /// The third byte of the encoded tag + /// The fourth byte of the encoded tag + /// The fifth byte of the encoded tag + public void WriteRawTag(byte b1, byte b2, byte b3, byte b4, byte b5) + { + if (buffered + 4 > span.Length) + { + EnsureMore(5); + } + + span[buffered++] = b1; + span[buffered++] = b2; + span[buffered++] = b3; + span[buffered++] = b4; + span[buffered++] = b5; + } + #endregion + + #region Underlying writing primitives + internal void WriteRawVarint32(uint value) + { + // Optimize for the common case of a single byte value + if (value < 128 && buffered < span.Length) + { + span[buffered++] = (byte)value; + } + else + { + while (value > 127) + { + Ensure(1); + span[buffered++] = (byte)((value & 0x7F) | 0x80); + value >>= 7; + } + + Ensure(1); + span[buffered++] = (byte)value; + } + } + + internal void WriteRawVarint64(ulong value) + { + // Optimize for the common case of a single byte value + if (value < 128 && buffered < span.Length) + { + span[buffered++] = (byte)value; + } + else + { + while (value > 127) + { + Ensure(1); + span[buffered++] = (byte)((value & 0x7F) | 0x80); + value >>= 7; + } + + Ensure(1); + span[buffered++] = (byte)value; + } + } + + internal void WriteRawLittleEndian32(uint value) + { + const int length = 4; + + Ensure(length); + + BinaryPrimitives.WriteUInt32LittleEndian(span.Slice(buffered), value); + + buffered += length; + } + + internal void WriteRawLittleEndian64(ulong value) + { + const int length = 8; + + Ensure(length); + + BinaryPrimitives.WriteUInt64LittleEndian(span.Slice(buffered), value); + + buffered += length; + } + + internal void WriteRawByte(byte value) + { + if (buffered > span.Length) + { + EnsureMore(1); + } + + span[buffered++] = value; + } + + /// + /// Writes out an array of bytes. + /// + internal void WriteRawBytes(byte[] value) + { + WriteRawBytes(value, 0, value.Length); + } + + /// + /// Writes out part of an array of bytes. + /// + internal void WriteRawBytes(byte[] value, int offset, int length) + { + Write(value.AsSpan(offset, length)); + } + + #endregion + + #region Buffer + /// + /// Copies the caller's buffer into the writer. + /// + /// The buffer to copy in. + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private void Write(ReadOnlySpan source) + { + if (span.Length - buffered >= source.Length) + { + source.CopyTo(span.Slice(buffered)); + buffered += source.Length; + } + else + { + WriteMultiBuffer(source); + } + } + + /// + /// Acquires a new buffer if necessary to ensure that some given number of bytes can be written to a single buffer. + /// + /// The number of bytes that must be allocated in a single buffer. + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private void Ensure(int count = 1) + { + if (span.Length < count + buffered) + { + EnsureMore(count); + } + } + + /// + /// Gets a fresh span to write to, with an optional minimum size. + /// + /// The minimum size for the next requested buffer. + [MethodImpl(MethodImplOptions.NoInlining)] + private void EnsureMore(int count = 0) + { + // This method should only be called when the end of the current span is reached. + // We don't want it inlined because it is called infrequently and it is used by + // methods that we want to be as inlinable as possible. + if (buffered > 0) + { + Flush(); + } + + span = output.GetSpan(count); + } + + /// + /// Copies the caller's buffer into this writer, potentially across multiple buffers from the underlying writer. + /// + /// The buffer to copy into this writer. + private void WriteMultiBuffer(ReadOnlySpan source) + { + Span buffer = span.Slice(buffered); + + if (buffer.Length >= source.Length) + { + source.CopyTo(buffer); + buffered += source.Length; + } + else + { + while (source.Length > 0) + { + // Refresh span with default size. + // We don't want to specify an exact size because a very large span won't be pooled. + EnsureMore(); + + var writable = Math.Min(source.Length, span.Length); + source.Slice(0, writable).CopyTo(span); + source = source.Slice(writable); + buffered += writable; + } + } + } + + /// + /// Flush uncommited data to the output writer. + /// + public void Flush() + { + var buffered = this.buffered; + if (buffered > 0) + { + this.buffered = 0; + output.Advance(buffered); + span = default; + } + } + #endregion + } +} +#endif \ No newline at end of file diff --git a/csharp/src/Google.Protobuf/Collections/MapField.cs b/csharp/src/Google.Protobuf/Collections/MapField.cs index 1924439e5cad..ae4b5155088d 100644 --- a/csharp/src/Google.Protobuf/Collections/MapField.cs +++ b/csharp/src/Google.Protobuf/Collections/MapField.cs @@ -1,4 +1,4 @@ -#region Copyright notice and license +#region Copyright notice and license // Protocol Buffers - Google's data interchange format // Copyright 2015 Google Inc. All rights reserved. // https://developers.google.com/protocol-buffers/ @@ -33,10 +33,14 @@ using Google.Protobuf.Compatibility; using Google.Protobuf.Reflection; using System; +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY +using System.Buffers; +#endif using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; +using System.Security; namespace Google.Protobuf.Collections { @@ -51,7 +55,7 @@ namespace Google.Protobuf.Collections /// /// /// Null values are not permitted in the map, either for wrapper types or regular messages. - /// If a map is deserialized from a data stream and the value is missing from an entry, a default value + /// If a map is deserialized from a data input and the value is missing from an entry, a default value /// is created instead. For primitive types, that is the regular default value (0, the empty string and so /// on); for message types, an empty instance of the message is created, as if the map entry contained a 0-length /// encoded value for the field. @@ -411,14 +415,14 @@ public bool Equals(MapField other) } /// - /// Adds entries to the map from the given stream. + /// Adds entries to the map from the given input. /// /// - /// It is assumed that the stream is initially positioned after the tag specified by the codec. - /// This method will continue reading entries from the stream until the end is reached, or + /// It is assumed that the input is initially positioned after the tag specified by the codec. + /// This method will continue reading entries from the input until the end is reached, or /// a different tag is encountered. /// - /// Stream to read from + /// Input to read from /// Codec describing how the key/value pairs are encoded public void AddEntriesFrom(CodedInputStream input, Codec codec) { @@ -431,11 +435,34 @@ public void AddEntriesFrom(CodedInputStream input, Codec codec) } while (input.MaybeConsumeTag(codec.MapTag)); } +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY /// - /// Writes the contents of this map to the given coded output stream, using the specified codec + /// Adds entries to the map from the given input. + /// + /// + /// It is assumed that the input is initially positioned after the tag specified by the codec. + /// This method will continue reading entries from the input until the end is reached, or + /// a different tag is encountered. + /// + /// Input to read from + /// Codec describing how the key/value pairs are encoded + public void AddEntriesFrom(ref CodedInputReader input, Codec codec) + { + var adapter = new Codec.MessageAdapter(codec); + do + { + adapter.Reset(); + input.ReadMessage(adapter); + this[adapter.Key] = adapter.Value; + } while (input.MaybeConsumeTag(codec.MapTag)); + } +#endif + + /// + /// Writes the contents of this map to the given coded output, using the specified codec /// to encode each entry. /// - /// The output stream to write to. + /// The output to write to. /// The codec to use for each entry. public void WriteTo(CodedOutputStream output, Codec codec) { @@ -449,6 +476,26 @@ public void WriteTo(CodedOutputStream output, Codec codec) } } +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + /// + /// Writes the contents of this map to the given coded output, using the specified codec + /// to encode each entry. + /// + /// The output to write to. + /// The codec to use for each entry. + public void WriteTo(ref CodedOutputWriter output, Codec codec) + { + var message = new Codec.MessageAdapter(codec); + foreach (var entry in list) + { + message.Key = entry.Key; + message.Value = entry.Value; + output.WriteTag(codec.MapTag); + output.WriteMessage(message); + } + } +#endif + /// /// Calculates the size of this map based on the given entry codec. /// @@ -621,8 +668,23 @@ public Codec(FieldCodec keyCodec, FieldCodec valueCodec, uint mapT /// and it's simpler if it has direct access to all its fields. /// internal class MessageAdapter : IMessage +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + , IBufferMessage +#endif { - private static readonly byte[] ZeroLengthMessageStreamData = new byte[] { 0 }; + private static readonly byte[] ZeroLengthMessageStreamData; +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + private static readonly ReadOnlySequence ZeroLengthMessageSequence; +#endif + + [SecuritySafeCritical] + static MessageAdapter() + { + ZeroLengthMessageStreamData = new byte[] { 0 }; +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + ZeroLengthMessageSequence = new ReadOnlySequence(ZeroLengthMessageStreamData); +#endif + } private readonly Codec codec; internal TKey Key { get; set; } @@ -659,19 +721,58 @@ public void MergeFrom(CodedInputStream input) } // Corner case: a map entry with a key but no value, where the value type is a message. - // Read it as if we'd seen an input stream with no data (i.e. create a "default" message). + // Read it as if we'd seen input with no data (i.e. create a "default" message). if (Value == null) { Value = codec.valueCodec.Read(new CodedInputStream(ZeroLengthMessageStreamData)); } } +#if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [SecuritySafeCritical] + public void MergeFrom(ref CodedInputReader input) + { + uint tag; + while ((tag = input.ReadTag()) != 0) + { + if (tag == codec.keyCodec.Tag) + { + Key = codec.keyCodec.Read(ref input); + } + else if (tag == codec.valueCodec.Tag) + { + Value = codec.valueCodec.Read(ref input); + } + else + { + input.SkipLastField(); + } + } + + // Corner case: a map entry with a key but no value, where the value type is a message. + // Read it as if we'd seen input with no data (i.e. create a "default" message). + if (Value == null) + { + var reader = new CodedInputReader(ZeroLengthMessageSequence); + Value = codec.valueCodec.Read(ref reader); + } + } +#endif + public void WriteTo(CodedOutputStream output) { codec.keyCodec.WriteTagAndValue(output, Key); codec.valueCodec.WriteTagAndValue(output, Value); } +#if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + public void WriteTo(ref CodedOutputWriter output) + { + codec.keyCodec.WriteTagAndValue(ref output, Key); + codec.valueCodec.WriteTagAndValue(ref output, Value); + } +#endif + public int CalculateSize() { return codec.keyCodec.CalculateSizeWithTag(Key) + codec.valueCodec.CalculateSizeWithTag(Value); diff --git a/csharp/src/Google.Protobuf/Collections/RepeatedField.cs b/csharp/src/Google.Protobuf/Collections/RepeatedField.cs index 0e8bb617647b..3de33b817414 100644 --- a/csharp/src/Google.Protobuf/Collections/RepeatedField.cs +++ b/csharp/src/Google.Protobuf/Collections/RepeatedField.cs @@ -124,11 +124,49 @@ public void AddEntriesFrom(CodedInputStream input, FieldCodec codec) } } +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + /// + /// Adds the entries from the given input stream, decoding them with the specified codec. + /// + /// The input stream to read from. + /// The codec to use in order to read each entry. + public void AddEntriesFrom(ref CodedInputReader input, FieldCodec codec) + { + // TODO: Inline some of the Add code, so we can avoid checking the size on every + // iteration. + uint tag = input.LastTag; + var reader = codec.BufferValueReader; + // Non-nullable value types can be packed or not. + if (FieldCodec.IsPackedRepeatedField(tag)) + { + int length = input.ReadLength(); + if (length > 0) + { + int oldLimit = input.PushLimit(length); + while (!input.ReachedLimit) + { + Add(reader(ref input)); + } + input.PopLimit(oldLimit); + } + // Empty packed field. Odd, but valid - just ignore. + } + else + { + // Not packed... (possibly not packable) + do + { + Add(reader(ref input)); + } while (input.MaybeConsumeTag(tag)); + } + } +#endif + /// /// Calculates the size of this collection based on the given codec. /// /// The codec to use when encoding each field. - /// The number of bytes that would be written to a by , + /// The number of bytes that would be written to output, /// using the same codec. public int CalculateSize(FieldCodec codec) { @@ -220,6 +258,49 @@ public void WriteTo(CodedOutputStream output, FieldCodec codec) } } +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + /// + /// Writes the contents of this collection to the given , + /// encoding each value using the specified codec. + /// + /// The output stream to write to. + /// The codec to use when encoding each value. + public void WriteTo(ref CodedOutputWriter output, FieldCodec codec) + { + if (count == 0) + { + return; + } + var writer = codec.BufferValueWriter; + var tag = codec.Tag; + if (codec.PackedRepeatedField) + { + // Packed primitive type + uint size = (uint)CalculatePackedDataSize(codec); + output.WriteTag(tag); + output.WriteRawVarint32(size); + for (int i = 0; i < count; i++) + { + writer(ref output, array[i]); + } + } + else + { + // Not packed: a simple tag/value pair for each value. + // Can't use codec.WriteTagAndValue, as that omits default values. + for (int i = 0; i < count; i++) + { + output.WriteTag(tag); + writer(ref output, array[i]); + if (codec.EndTag != 0) + { + output.WriteTag(codec.EndTag); + } + } + } + } +#endif + /// /// Gets and sets the capacity of the RepeatedField's internal array. WHen set, the internal array is reallocated to the given capacity. /// The new value is less than Count -or- when Count is less than 0. @@ -579,7 +660,7 @@ public override string ToString() } } - #region Explicit interface implementation for IList and ICollection. +#region Explicit interface implementation for IList and ICollection. bool IList.IsFixedSize => false; void ICollection.CopyTo(Array array, int index) @@ -630,6 +711,6 @@ void IList.Remove(object value) } Remove((T)value); } - #endregion +#endregion } } diff --git a/csharp/src/Google.Protobuf/ExtensionRegistry.cs b/csharp/src/Google.Protobuf/ExtensionRegistry.cs index d3d7ebdc5dd6..e72314b22c29 100644 --- a/csharp/src/Google.Protobuf/ExtensionRegistry.cs +++ b/csharp/src/Google.Protobuf/ExtensionRegistry.cs @@ -80,9 +80,9 @@ private ExtensionRegistry(IDictionary, Extension> collection /// bool ICollection.IsReadOnly => false; - internal bool ContainsInputField(CodedInputStream stream, Type target, out Extension extension) + internal bool ContainsInputField(uint lastTag, Type target, out Extension extension) { - return extensions.TryGetValue(new ObjectIntPair(target, WireFormat.GetTagFieldNumber(stream.LastTag)), out extension); + return extensions.TryGetValue(new ObjectIntPair(target, WireFormat.GetTagFieldNumber(lastTag)), out extension); } /// diff --git a/csharp/src/Google.Protobuf/ExtensionSet.cs b/csharp/src/Google.Protobuf/ExtensionSet.cs index d1bbf6910247..09f70419d98f 100644 --- a/csharp/src/Google.Protobuf/ExtensionSet.cs +++ b/csharp/src/Google.Protobuf/ExtensionSet.cs @@ -1,4 +1,4 @@ -#region Copyright notice and license +#region Copyright notice and license // Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. // https://developers.google.com/protocol-buffers/ @@ -192,7 +192,7 @@ public static class ExtensionSet extensionValue.MergeFrom(stream); return true; } - else if (stream.ExtensionRegistry != null && stream.ExtensionRegistry.ContainsInputField(stream, typeof(TTarget), out extension)) + else if (stream.ExtensionRegistry != null && stream.ExtensionRegistry.ContainsInputField(stream.LastTag, typeof(TTarget), out extension)) { IExtensionValue value = extension.CreateValue(); value.MergeFrom(stream); @@ -206,6 +206,37 @@ public static class ExtensionSet } } +#if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + /// + /// Tries to merge a field from the coded input, returning true if the field was merged. + /// If the set is null or the field was not otherwise merged, this returns false. + /// + public static bool TryMergeFieldFrom(ref ExtensionSet set, ref CodedInputReader input) where TTarget : IExtendableMessage + { + Extension extension; + int lastFieldNumber = WireFormat.GetTagFieldNumber(input.LastTag); + + IExtensionValue extensionValue; + if (set != null && set.ValuesByNumber.TryGetValue(lastFieldNumber, out extensionValue)) + { + extensionValue.MergeFrom(ref input); + return true; + } + else if (input.ExtensionRegistry != null && input.ExtensionRegistry.ContainsInputField(input.LastTag, typeof(TTarget), out extension)) + { + IExtensionValue value = extension.CreateValue(); + value.MergeFrom(ref input); + set = (set ?? new ExtensionSet()); + set.ValuesByNumber.Add(extension.FieldNumber, value); + return true; + } + else + { + return false; + } + } +#endif + /// /// Merges the second set into the first set, creating a new instance if first is null /// @@ -333,6 +364,19 @@ public void WriteTo(CodedOutputStream stream) } } +#if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + /// + /// Writes the extension values in this set to the output stream + /// + public void WriteTo(ref CodedOutputWriter output) + { + foreach (var value in ValuesByNumber.Values) + { + value.WriteTo(ref output); + } + } +#endif + internal bool IsInitialized() { return ValuesByNumber.Values.All(v => v.IsInitialized()); diff --git a/csharp/src/Google.Protobuf/ExtensionValue.cs b/csharp/src/Google.Protobuf/ExtensionValue.cs index 6ee737a7b0c9..550bea3aeaf7 100644 --- a/csharp/src/Google.Protobuf/ExtensionValue.cs +++ b/csharp/src/Google.Protobuf/ExtensionValue.cs @@ -38,9 +38,15 @@ namespace Google.Protobuf { internal interface IExtensionValue : IEquatable, IDeepCloneable { - void MergeFrom(CodedInputStream input); + void MergeFrom(CodedInputStream input); +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + void MergeFrom(ref CodedInputReader input); +#endif void MergeFrom(IExtensionValue value); - void WriteTo(CodedOutputStream output); + void WriteTo(CodedOutputStream output); +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + void WriteTo(ref CodedOutputWriter output); +#endif int CalculateSize(); bool IsInitialized(); } @@ -94,8 +100,15 @@ public override int GetHashCode() public void MergeFrom(CodedInputStream input) { codec.ValueMerger(input, ref field); - } - + } + +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + public void MergeFrom(ref CodedInputReader input) + { + codec.BufferValueMerger(ref input, ref field); + } +#endif + public void MergeFrom(IExtensionValue value) { if (value is ExtensionValue) @@ -113,8 +126,20 @@ public void WriteTo(CodedOutputStream output) { output.WriteTag(codec.EndTag); } - } - + } + +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + public void WriteTo(ref CodedOutputWriter output) + { + output.WriteTag(codec.Tag); + codec.BufferValueWriter(ref output, field); + if (codec.EndTag != 0) + { + output.WriteTag(codec.EndTag); + } + } +#endif + public T GetValue() => field; public void SetValue(T value) @@ -132,7 +157,7 @@ public bool IsInitialized() { return true; } - } + } } internal sealed class RepeatedExtensionValue : IExtensionValue @@ -183,7 +208,14 @@ public override int GetHashCode() public void MergeFrom(CodedInputStream input) { field.AddEntriesFrom(input, codec); - } + } + +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + public void MergeFrom(ref CodedInputReader input) + { + field.AddEntriesFrom(ref input, codec); + } +#endif public void MergeFrom(IExtensionValue value) { @@ -196,7 +228,14 @@ public void MergeFrom(IExtensionValue value) public void WriteTo(CodedOutputStream output) { field.WriteTo(output, codec); + } + +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + public void WriteTo(ref CodedOutputWriter output) + { + field.WriteTo(ref output, codec); } +#endif public RepeatedField GetValue() => field; @@ -219,6 +258,6 @@ public bool IsInitialized() } return true; - } + } } } diff --git a/csharp/src/Google.Protobuf/FieldCodec.cs b/csharp/src/Google.Protobuf/FieldCodec.cs index 1971261649a0..a09cf59b62b4 100644 --- a/csharp/src/Google.Protobuf/FieldCodec.cs +++ b/csharp/src/Google.Protobuf/FieldCodec.cs @@ -218,7 +218,16 @@ public static FieldCodec ForEnum(uint tag, Func toInt32, FuncA codec for the given tag. public static FieldCodec ForString(uint tag, string defaultValue) { - return new FieldCodec(input => input.ReadString(), (output, value) => output.WriteString(value), CodedOutputStream.ComputeStringSize, tag, defaultValue); + return new FieldCodec( + input => input.ReadString(), + (output, value) => output.WriteString(value), +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + (ref CodedInputReader input) => input.ReadString(), + (ref CodedOutputWriter output, string value) => output.WriteString(value), +#endif + CodedOutputStream.ComputeStringSize, + tag, + defaultValue); } /// @@ -229,7 +238,16 @@ public static FieldCodec ForString(uint tag, string defaultValue) /// A codec for the given tag. public static FieldCodec ForBytes(uint tag, ByteString defaultValue) { - return new FieldCodec(input => input.ReadBytes(), (output, value) => output.WriteBytes(value), CodedOutputStream.ComputeBytesSize, tag, defaultValue); + return new FieldCodec( + input => input.ReadBytes(), + (output, value) => output.WriteBytes(value), +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + (ref CodedInputReader input) => input.ReadBytes(), + (ref CodedOutputWriter output, ByteString value) => output.WriteBytes(value), +#endif + CodedOutputStream.ComputeBytesSize, + tag, + defaultValue); } /// @@ -240,7 +258,16 @@ public static FieldCodec ForBytes(uint tag, ByteString defaultValue) /// A codec for the given tag. public static FieldCodec ForBool(uint tag, bool defaultValue) { - return new FieldCodec(input => input.ReadBool(), (output, value) => output.WriteBool(value), CodedOutputStream.BoolSize, tag, defaultValue); + return new FieldCodec( + input => input.ReadBool(), + (output, value) => output.WriteBool(value), +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + (ref CodedInputReader input) => input.ReadBool(), + (ref CodedOutputWriter output, bool value) => output.WriteBool(value), +#endif + CodedOutputStream.BoolSize, + tag, + defaultValue); } /// @@ -251,7 +278,16 @@ public static FieldCodec ForBool(uint tag, bool defaultValue) /// A codec for the given tag. public static FieldCodec ForInt32(uint tag, int defaultValue) { - return new FieldCodec(input => input.ReadInt32(), (output, value) => output.WriteInt32(value), CodedOutputStream.ComputeInt32Size, tag, defaultValue); + return new FieldCodec( + input => input.ReadInt32(), + (output, value) => output.WriteInt32(value), +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + (ref CodedInputReader input) => input.ReadInt32(), + (ref CodedOutputWriter output, int value) => output.WriteInt32(value), +#endif + CodedOutputStream.ComputeInt32Size, + tag, + defaultValue); } /// @@ -262,7 +298,16 @@ public static FieldCodec ForInt32(uint tag, int defaultValue) /// A codec for the given tag. public static FieldCodec ForSInt32(uint tag, int defaultValue) { - return new FieldCodec(input => input.ReadSInt32(), (output, value) => output.WriteSInt32(value), CodedOutputStream.ComputeSInt32Size, tag, defaultValue); + return new FieldCodec( + input => input.ReadSInt32(), + (output, value) => output.WriteSInt32(value), +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + (ref CodedInputReader input) => input.ReadSInt32(), + (ref CodedOutputWriter output, int value) => output.WriteSInt32(value), +#endif + CodedOutputStream.ComputeSInt32Size, + tag, + defaultValue); } /// @@ -273,7 +318,16 @@ public static FieldCodec ForSInt32(uint tag, int defaultValue) /// A codec for the given tag. public static FieldCodec ForFixed32(uint tag, uint defaultValue) { - return new FieldCodec(input => input.ReadFixed32(), (output, value) => output.WriteFixed32(value), 4, tag, defaultValue); + return new FieldCodec( + input => input.ReadFixed32(), + (output, value) => output.WriteFixed32(value), +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + (ref CodedInputReader input) => input.ReadFixed32(), + (ref CodedOutputWriter output, uint value) => output.WriteFixed32(value), +#endif + 4, + tag, + defaultValue); } /// @@ -284,7 +338,16 @@ public static FieldCodec ForFixed32(uint tag, uint defaultValue) /// A codec for the given tag. public static FieldCodec ForSFixed32(uint tag, int defaultValue) { - return new FieldCodec(input => input.ReadSFixed32(), (output, value) => output.WriteSFixed32(value), 4, tag, defaultValue); + return new FieldCodec( + input => input.ReadSFixed32(), + (output, value) => output.WriteSFixed32(value), +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + (ref CodedInputReader input) => input.ReadSFixed32(), + (ref CodedOutputWriter output, int value) => output.WriteSFixed32(value), +#endif + 4, + tag, + defaultValue); } /// @@ -295,7 +358,16 @@ public static FieldCodec ForSFixed32(uint tag, int defaultValue) /// A codec for the given tag. public static FieldCodec ForUInt32(uint tag, uint defaultValue) { - return new FieldCodec(input => input.ReadUInt32(), (output, value) => output.WriteUInt32(value), CodedOutputStream.ComputeUInt32Size, tag, defaultValue); + return new FieldCodec( + input => input.ReadUInt32(), + (output, value) => output.WriteUInt32(value), +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + (ref CodedInputReader input) => input.ReadUInt32(), + (ref CodedOutputWriter output, uint value) => output.WriteUInt32(value), +#endif + CodedOutputStream.ComputeUInt32Size, + tag, + defaultValue); } /// @@ -306,7 +378,16 @@ public static FieldCodec ForUInt32(uint tag, uint defaultValue) /// A codec for the given tag. public static FieldCodec ForInt64(uint tag, long defaultValue) { - return new FieldCodec(input => input.ReadInt64(), (output, value) => output.WriteInt64(value), CodedOutputStream.ComputeInt64Size, tag, defaultValue); + return new FieldCodec( + input => input.ReadInt64(), + (output, value) => output.WriteInt64(value), +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + (ref CodedInputReader input) => input.ReadInt64(), + (ref CodedOutputWriter output, long value) => output.WriteInt64(value), +#endif + CodedOutputStream.ComputeInt64Size, + tag, + defaultValue); } /// @@ -317,7 +398,16 @@ public static FieldCodec ForInt64(uint tag, long defaultValue) /// A codec for the given tag. public static FieldCodec ForSInt64(uint tag, long defaultValue) { - return new FieldCodec(input => input.ReadSInt64(), (output, value) => output.WriteSInt64(value), CodedOutputStream.ComputeSInt64Size, tag, defaultValue); + return new FieldCodec( + input => input.ReadSInt64(), + (output, value) => output.WriteSInt64(value), +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + (ref CodedInputReader input) => input.ReadSInt64(), + (ref CodedOutputWriter output, long value) => output.WriteSInt64(value), +#endif + CodedOutputStream.ComputeSInt64Size, + tag, + defaultValue); } /// @@ -328,7 +418,16 @@ public static FieldCodec ForSInt64(uint tag, long defaultValue) /// A codec for the given tag. public static FieldCodec ForFixed64(uint tag, ulong defaultValue) { - return new FieldCodec(input => input.ReadFixed64(), (output, value) => output.WriteFixed64(value), 8, tag, defaultValue); + return new FieldCodec( + input => input.ReadFixed64(), + (output, value) => output.WriteFixed64(value), +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + (ref CodedInputReader input) => input.ReadFixed64(), + (ref CodedOutputWriter output, ulong value) => output.WriteFixed64(value), +#endif + 8, + tag, + defaultValue); } /// @@ -339,7 +438,16 @@ public static FieldCodec ForFixed64(uint tag, ulong defaultValue) /// A codec for the given tag. public static FieldCodec ForSFixed64(uint tag, long defaultValue) { - return new FieldCodec(input => input.ReadSFixed64(), (output, value) => output.WriteSFixed64(value), 8, tag, defaultValue); + return new FieldCodec( + input => input.ReadSFixed64(), + (output, value) => output.WriteSFixed64(value), +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + (ref CodedInputReader input) => input.ReadSFixed64(), + (ref CodedOutputWriter output, long value) => output.WriteSFixed64(value), +#endif + 8, + tag, + defaultValue); } /// @@ -350,7 +458,16 @@ public static FieldCodec ForSFixed64(uint tag, long defaultValue) /// A codec for the given tag. public static FieldCodec ForUInt64(uint tag, ulong defaultValue) { - return new FieldCodec(input => input.ReadUInt64(), (output, value) => output.WriteUInt64(value), CodedOutputStream.ComputeUInt64Size, tag, defaultValue); + return new FieldCodec( + input => input.ReadUInt64(), + (output, value) => output.WriteUInt64(value), +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + (ref CodedInputReader input) => input.ReadUInt64(), + (ref CodedOutputWriter output, ulong value) => output.WriteUInt64(value), +#endif + CodedOutputStream.ComputeUInt64Size, + tag, + defaultValue); } /// @@ -361,7 +478,16 @@ public static FieldCodec ForUInt64(uint tag, ulong defaultValue) /// A codec for the given tag. public static FieldCodec ForFloat(uint tag, float defaultValue) { - return new FieldCodec(input => input.ReadFloat(), (output, value) => output.WriteFloat(value), CodedOutputStream.FloatSize, tag, defaultValue); + return new FieldCodec( + input => input.ReadFloat(), + (output, value) => output.WriteFloat(value), +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + (ref CodedInputReader input) => input.ReadFloat(), + (ref CodedOutputWriter output, float value) => output.WriteFloat(value), +#endif + CodedOutputStream.FloatSize, + tag, + defaultValue); } /// @@ -372,7 +498,16 @@ public static FieldCodec ForFloat(uint tag, float defaultValue) /// A codec for the given tag. public static FieldCodec ForDouble(uint tag, double defaultValue) { - return new FieldCodec(input => input.ReadDouble(), (output, value) => output.WriteDouble(value), CodedOutputStream.DoubleSize, tag, defaultValue); + return new FieldCodec( + input => input.ReadDouble(), + (output, value) => output.WriteDouble(value), +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + (ref CodedInputReader input) => input.ReadDouble(), + (ref CodedOutputWriter output, double value) => output.WriteDouble(value), +#endif + CodedOutputStream.DoubleSize, + tag, + defaultValue); } // Enums are tricky. We can probably use expression trees to build these delegates automatically, @@ -388,9 +523,13 @@ public static FieldCodec ForDouble(uint tag, double defaultValue) /// A codec for the given tag. public static FieldCodec ForEnum(uint tag, Func toInt32, Func fromInt32, T defaultValue) { - return new FieldCodec(input => fromInt32( - input.ReadEnum()), + return new FieldCodec( + input => fromInt32(input.ReadEnum()), (output, value) => output.WriteEnum(toInt32(value)), +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + (ref CodedInputReader input) => fromInt32(input.ReadEnum()), + (ref CodedOutputWriter output, T value) => output.WriteEnum(toInt32(value)), +#endif value => CodedOutputStream.ComputeEnumSize(toInt32(value)), tag, defaultValue); } @@ -403,14 +542,14 @@ public static FieldCodec ForEnum(uint tag, Func toInt32, Func ForMessage(uint tag, MessageParser parser) where T : class, IMessage { return new FieldCodec( - input => - { - T message = parser.CreateTemplate(); - input.ReadMessage(message); - return message; + input => + { + T message = parser.CreateTemplate(); + input.ReadMessage(message); + return message; }, (output, value) => output.WriteMessage(value), - (CodedInputStream i, ref T v) => + (CodedInputStream i, ref T v) => { if (v == null) { @@ -434,7 +573,46 @@ public static FieldCodec ForEnum(uint tag, Func toInt32, Func + { + T message = parser.CreateTemplate(); + + if (message is IBufferMessage m) + { + input.ReadMessage(m); + return message; + } + + throw new NotSupportedException(nameof(T) + " doesn't implement " + nameof(IBufferMessage)); + }, + (ref CodedOutputWriter output, T value) => + { + if (value is IBufferMessage m) + { + output.WriteMessage(m); + return; + } + + throw new NotSupportedException(nameof(T) + " doesn't implement " + nameof(IBufferMessage)); + }, + (ref CodedInputReader i, ref T v) => + { + if (v == null) + { + v = parser.CreateTemplate(); + } + + if (v is IBufferMessage m) + { + i.ReadMessage(m); + return; + } + + throw new NotSupportedException(nameof(T) + " doesn't implement " + nameof(IBufferMessage)); + }, +#endif message => CodedOutputStream.ComputeMessageSize(message), tag); } @@ -454,8 +632,8 @@ public static FieldCodec ForEnum(uint tag, Func toInt32, Func output.WriteGroup(value), - (CodedInputStream i, ref T v) => + (output, value) => output.WriteGroup(value), + (CodedInputStream i, ref T v) => { if (v == null) { @@ -480,6 +658,45 @@ public static FieldCodec ForEnum(uint tag, Func toInt32, Func + { + T message = parser.CreateTemplate(); + + if (message is IBufferMessage m) + { + input.ReadGroup(m); + return message; + } + + throw new NotSupportedException(nameof(T) + " doesn't implement " + nameof(IBufferMessage)); + }, + (ref CodedOutputWriter output, T value) => + { + if (value is IBufferMessage m) + { + output.WriteGroup(m); + return; + } + + throw new NotSupportedException(nameof(T) + " doesn't implement " + nameof(IBufferMessage)); + }, + (ref CodedInputReader i, ref T v) => + { + if (v == null) + { + v = parser.CreateTemplate(); + } + + if (v is IBufferMessage m) + { + i.ReadGroup(m); + return; + } + + throw new NotSupportedException(nameof(T) + " doesn't implement " + nameof(IBufferMessage)); + }, +#endif message => CodedOutputStream.ComputeGroupSize(message), startTag, endTag); } @@ -494,6 +711,11 @@ public static FieldCodec ForEnum(uint tag, Func toInt32, Func WrapperCodecs.Write(output, value, nestedCodec), (CodedInputStream i, ref T v) => v = WrapperCodecs.Read(i, nestedCodec), (ref T v, T v2) => { v = v2; return v == null; }, +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + (ref CodedInputReader input) => WrapperCodecs.Read(ref input, nestedCodec), + (ref CodedOutputWriter output, T value) => WrapperCodecs.Write(ref output, value, nestedCodec), + (ref CodedInputReader i, ref T v) => v = WrapperCodecs.Read(ref i, nestedCodec), +#endif value => WrapperCodecs.CalculateSize(value, nestedCodec), tag, 0, null); // Default value for the wrapper @@ -507,10 +729,15 @@ public static FieldCodec ForEnum(uint tag, Func toInt32, Func(); return new FieldCodec( - WrapperCodecs.GetReader(), + WrapperCodecs.GetStreamReader(), (output, value) => WrapperCodecs.Write(output, value.Value, nestedCodec), (CodedInputStream i, ref T? v) => v = WrapperCodecs.Read(i, nestedCodec), (ref T? v, T? v2) => { if (v2.HasValue) { v = v2; } return v.HasValue; }, +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + WrapperCodecs.GetBufferReader(), + (ref CodedOutputWriter output, T? value) => WrapperCodecs.Write(ref output, value.Value, nestedCodec), + (ref CodedInputReader i, ref T? v) => v = WrapperCodecs.Read(ref i, nestedCodec), +#endif value => value == null ? 0 : WrapperCodecs.CalculateSize(value.Value, nestedCodec), tag, 0, null); // Default value for the wrapper @@ -539,7 +766,7 @@ private static class WrapperCodecs { typeof(ByteString), ForBytes(WireFormat.MakeTag(WrappersReflection.WrapperValueFieldNumber, WireFormat.WireType.LengthDelimited)) } }; - private static readonly Dictionary Readers = new Dictionary + private static readonly Dictionary StreamReaders = new Dictionary { // TODO: Provide more optimized readers. { typeof(bool), (Func)CodedInputStream.ReadBoolWrapper }, @@ -558,6 +785,27 @@ private static class WrapperCodecs { typeof(ByteString), null }, }; +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + private static readonly Dictionary BufferReaders = new Dictionary + { + // TODO: Provide more optimized readers. + { typeof(bool), (BufferReader)CodedInputReader.ReadBoolWrapper }, + { typeof(int), (BufferReader)CodedInputReader.ReadInt32Wrapper }, + { typeof(long), (BufferReader)CodedInputReader.ReadInt64Wrapper }, + { typeof(uint), (BufferReader)CodedInputReader.ReadUInt32Wrapper }, + { typeof(ulong), (BufferReader)CodedInputReader.ReadUInt64Wrapper }, + { typeof(float), BitConverter.IsLittleEndian ? + (BufferReader)CodedInputReader.ReadFloatWrapperLittleEndian : + (BufferReader)CodedInputReader.ReadFloatWrapperSlow }, + { typeof(double), BitConverter.IsLittleEndian ? + (BufferReader)CodedInputReader.ReadDoubleWrapperLittleEndian : + (BufferReader)CodedInputReader.ReadDoubleWrapperSlow }, + // `string` and `ByteString` less performance-sensitive. Do not implement for now. + { typeof(string), null }, + { typeof(ByteString), null }, + }; +#endif + /// /// Returns a field codec which effectively wraps a value of type T in a message. /// @@ -572,10 +820,10 @@ internal static FieldCodec GetCodec() return (FieldCodec) value; } - internal static Func GetReader() where T : struct + internal static Func GetStreamReader() where T : struct { object value; - if (!Readers.TryGetValue(typeof(T), out value)) + if (!StreamReaders.TryGetValue(typeof(T), out value)) { throw new InvalidOperationException("Invalid type argument requested for wrapper reader: " + typeof(T)); } @@ -589,6 +837,25 @@ internal static FieldCodec GetCodec() return (Func)value; } +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + internal static BufferReader GetBufferReader() where T : struct + { + object value; + if (!BufferReaders.TryGetValue(typeof(T), out value)) + { + throw new InvalidOperationException("Invalid type argument requested for wrapper reader: " + typeof(T)); + } + if (value == null) + { + // Return default unoptimized reader for the wrapper type. + var nestedCoded = GetCodec(); + return (ref CodedInputReader input) => Read(ref input, nestedCoded); + } + // Return optimized read for the wrapper type. + return (BufferReader)value; + } +#endif + internal static T Read(CodedInputStream input, FieldCodec codec) { int length = input.ReadLength(); @@ -620,6 +887,39 @@ internal static void Write(CodedOutputStream output, T value, FieldCodec c codec.WriteTagAndValue(output, value); } +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + internal static T Read(ref CodedInputReader input, FieldCodec codec) + { + int length = input.ReadLength(); + int oldLimit = input.PushLimit(length); + + uint tag; + T value = codec.DefaultValue; + while ((tag = input.ReadTag()) != 0) + { + if (tag == codec.Tag) + { + value = codec.Read(ref input); + } + else + { + input.SkipLastField(); + } + + } + input.CheckReadEndOfInputTag(); + input.PopLimit(oldLimit); + + return value; + } + + internal static void Write(ref CodedOutputWriter output, T value, FieldCodec codec) + { + output.WriteLength(codec.CalculateSizeWithTag(value)); + codec.WriteTagAndValue(ref output, value); + } +#endif + internal static int CalculateSize(T value, FieldCodec codec) { int fieldLength = codec.CalculateSizeWithTag(value); @@ -628,6 +928,12 @@ internal static int CalculateSize(T value, FieldCodec codec) } } +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + internal delegate void BufferWriter(ref CodedOutputWriter writer, TValue value); + internal delegate TValue BufferReader(ref CodedInputReader reader); + internal delegate void BufferInputMerger(ref CodedInputReader input, ref TValue value); +#endif + /// /// /// An encode/decode pair for a single field. This effectively encapsulates @@ -683,6 +989,13 @@ static FieldCodec() /// internal Action ValueWriter { get; } +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + /// + /// Returns a delegate to write a value (unconditionally) to a coded output writer. + /// + internal BufferWriter BufferValueWriter { get; } +#endif + /// /// Returns the size calculator for just a value. /// @@ -694,12 +1007,28 @@ static FieldCodec() /// internal Func ValueReader { get; } +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + /// + /// Returns a delegate to read a value from a coded input reader. It is assumed that + /// the reader is already positioned on the appropriate tag. + /// + internal BufferReader BufferValueReader { get; } +#endif + /// /// Returns a delegate to merge a value from a coded input stream. /// It is assumed that the stream is already positioned on the appropriate tag /// internal InputMerger ValueMerger { get; } +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + /// + /// Returns a delegate to merge a value from a coded input stream. + /// It is assumed that the stream is already positioned on the appropriate tag + /// + internal BufferInputMerger BufferValueMerger { get; } +#endif + /// /// Returns a delegate to merge two values together. /// @@ -741,9 +1070,22 @@ static FieldCodec() internal FieldCodec( Func reader, Action writer, +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + BufferReader bufferReader, + BufferWriter bufferWriter, +#endif int fixedSize, uint tag, - T defaultValue) : this(reader, writer, _ => fixedSize, tag, defaultValue) + T defaultValue) : this( + reader, + writer, +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + bufferReader, + bufferWriter, +#endif + _ => fixedSize, + tag, + defaultValue) { FixedSize = fixedSize; } @@ -751,9 +1093,26 @@ static FieldCodec() internal FieldCodec( Func reader, Action writer, +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + BufferReader bufferReader, + BufferWriter bufferWriter, +#endif Func sizeCalculator, uint tag, - T defaultValue) : this(reader, writer, (CodedInputStream i, ref T v) => v = reader(i), (ref T v, T v2) => { v = v2; return true; }, sizeCalculator, tag, 0, defaultValue) + T defaultValue) : this( + reader, + writer, + (CodedInputStream i, ref T v) => v = reader(i), + (ref T v, T v2) => { v = v2; return true; }, +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + bufferReader, + bufferWriter, + (ref CodedInputReader i, ref T v) => v = bufferReader(ref i), +#endif + sizeCalculator, + tag, + 0, + defaultValue) { } @@ -762,9 +1121,27 @@ static FieldCodec() Action writer, InputMerger inputMerger, ValuesMerger valuesMerger, +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + BufferReader bufferReader, + BufferWriter bufferWriter, + BufferInputMerger bufferInputMerger, +#endif Func sizeCalculator, uint tag, - uint endTag = 0) : this(reader, writer, inputMerger, valuesMerger, sizeCalculator, tag, endTag, DefaultDefault) + uint endTag = 0) : this( + reader, + writer, + inputMerger, + valuesMerger, +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + bufferReader, + bufferWriter, + bufferInputMerger, +#endif + sizeCalculator, + tag, + endTag, + DefaultDefault) { } @@ -773,6 +1150,11 @@ static FieldCodec() Action writer, InputMerger inputMerger, ValuesMerger valuesMerger, +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + BufferReader bufferReader, + BufferWriter bufferWriter, + BufferInputMerger bufferInputMerger, +#endif Func sizeCalculator, uint tag, uint endTag, @@ -782,6 +1164,11 @@ static FieldCodec() ValueWriter = writer; ValueMerger = inputMerger; FieldMerger = valuesMerger; +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + BufferValueReader = bufferReader; + BufferValueWriter = bufferWriter; + BufferValueMerger = bufferInputMerger; +#endif ValueSizeCalculator = sizeCalculator; FixedSize = 0; Tag = tag; @@ -810,6 +1197,24 @@ public void WriteTagAndValue(CodedOutputStream output, T value) } } +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + /// + /// Write a tag and the given value, *if* the value is not the default. + /// + public void WriteTagAndValue(ref CodedOutputWriter output, T value) + { + if (!IsDefault(value)) + { + output.WriteTag(Tag); + BufferValueWriter(ref output, value); + if (EndTag != 0) + { + output.WriteTag(EndTag); + } + } + } +#endif + /// /// Reads a value of the codec type from the given . /// @@ -817,6 +1222,15 @@ public void WriteTagAndValue(CodedOutputStream output, T value) /// The value read from the stream. public T Read(CodedInputStream input) => ValueReader(input); +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + /// + /// Reads a value of the codec type from the given . + /// + /// The input stream to read from. + /// The value read from the stream. + public T Read(ref CodedInputReader input) => BufferValueReader(ref input); +#endif + /// /// Calculates the size required to write the given value, with a tag, /// if the value is not the default. diff --git a/csharp/src/Google.Protobuf/Google.Protobuf.csproj b/csharp/src/Google.Protobuf/Google.Protobuf.csproj index e8e33e27e6ff..90393ff7941b 100644 --- a/csharp/src/Google.Protobuf/Google.Protobuf.csproj +++ b/csharp/src/Google.Protobuf/Google.Protobuf.csproj @@ -22,8 +22,22 @@ $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb - + $(DefineConstants);GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + + 7.2 + True + + + + $(DefineConstants);GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + + + + $(DefineConstants);GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY;GOOGLE_PROTOBUF_SUPPORT_FAST_STRING + + 7.2 + True @@ -31,6 +45,11 @@ + + + + + diff --git a/csharp/src/Google.Protobuf/IBufferMessage.cs b/csharp/src/Google.Protobuf/IBufferMessage.cs new file mode 100644 index 000000000000..0fd9973fcb47 --- /dev/null +++ b/csharp/src/Google.Protobuf/IBufferMessage.cs @@ -0,0 +1,57 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +namespace Google.Protobuf +{ +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + /// + /// Interface for a Protocol Buffers message, supporting + /// and + /// serialization operations. + /// + public interface IBufferMessage : IMessage + { + /// + /// Merges the data from the specified with the current message. + /// + /// See the user guide for precise merge semantics. + /// to read data from. Must not be null. + void MergeFrom(ref CodedInputReader input); + + /// + /// Writes the data to the given . + /// + /// to write the data to. Must not be null. + void WriteTo(ref CodedOutputWriter output); + } +#endif +} diff --git a/csharp/src/Google.Protobuf/IMessage.cs b/csharp/src/Google.Protobuf/IMessage.cs index d089f9463985..cf22872121ab 100644 --- a/csharp/src/Google.Protobuf/IMessage.cs +++ b/csharp/src/Google.Protobuf/IMessage.cs @@ -45,7 +45,7 @@ public interface IMessage /// Merges the data from the specified coded input stream with the current message. /// /// See the user guide for precise merge semantics. - /// + /// Coded input stream to read data from. Must not be null. void MergeFrom(CodedInputStream input); /// diff --git a/csharp/src/Google.Protobuf/MessageExtensions.cs b/csharp/src/Google.Protobuf/MessageExtensions.cs index 06e0980ec2b1..5fa93d2de8c9 100644 --- a/csharp/src/Google.Protobuf/MessageExtensions.cs +++ b/csharp/src/Google.Protobuf/MessageExtensions.cs @@ -31,9 +31,13 @@ #endregion using Google.Protobuf.Reflection; +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY +using System.Buffers; +#endif using System.Collections; using System.IO; using System.Linq; +using System.Security; namespace Google.Protobuf { @@ -237,6 +241,27 @@ internal static void MergeFrom(this IMessage message, ByteString data, bool disc input.CheckReadEndOfStreamTag(); } +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + [SecuritySafeCritical] + internal static void MergeFrom(this IMessage message, ReadOnlySequence data, bool discardUnknownFields, ExtensionRegistry registry) + { + ProtoPreconditions.CheckNotNull(message, "message"); + + if (message is IBufferMessage bufferMessage) + { + CodedInputReader input = new CodedInputReader(data); + input.DiscardUnknownFields = discardUnknownFields; + input.ExtensionRegistry = registry; + bufferMessage.MergeFrom(ref input); + input.CheckReadEndOfInputTag(); + } + else + { + message.MergeFrom(data.ToArray(), discardUnknownFields, registry); + } + } +#endif + internal static void MergeFrom(this IMessage message, Stream input, bool discardUnknownFields, ExtensionRegistry registry) { ProtoPreconditions.CheckNotNull(message, "message"); diff --git a/csharp/src/Google.Protobuf/MessageParser.cs b/csharp/src/Google.Protobuf/MessageParser.cs index 06d0f1059c7a..ed8a5db4ea76 100644 --- a/csharp/src/Google.Protobuf/MessageParser.cs +++ b/csharp/src/Google.Protobuf/MessageParser.cs @@ -31,7 +31,11 @@ #endregion using System; +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY +using System.Buffers; +#endif using System.IO; +using System.Security; namespace Google.Protobuf { @@ -155,6 +159,33 @@ public IMessage ParseJson(string json) return message; } +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + /// + /// Parses a message from the given sequence. + /// + /// The data to parse. + /// The parsed message. + [SecuritySafeCritical] + public IMessage ParseFrom(ReadOnlySequence data) + { + IMessage message = factory(); + message.MergeFrom(data, DiscardUnknownFields, Extensions); + return message; + } + + /// + /// Parses a message from the given coded input stream. + /// + /// The stream to parse. + /// The parsed message. + public IMessage ParseFrom(ref CodedInputReader input) + { + IMessage message = factory(); + MergeFrom(message, ref input); + return message; + } +#endif + // TODO: When we're using a C# 7.1 compiler, make this private protected. internal void MergeFrom(IMessage message, CodedInputStream codedInput) { @@ -170,6 +201,29 @@ internal void MergeFrom(IMessage message, CodedInputStream codedInput) } } +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + // TODO: When we're using a C# 7.1 compiler, make this private protected. + internal void MergeFrom(IMessage message, ref CodedInputReader codedInput) + { + IBufferMessage bufferMessage = message as IBufferMessage; + if (bufferMessage == null) + { + throw new InvalidOperationException("Message does not support CodedInputReader."); + } + + bool originalDiscard = codedInput.DiscardUnknownFields; + try + { + codedInput.DiscardUnknownFields = DiscardUnknownFields; + bufferMessage.MergeFrom(ref codedInput); + } + finally + { + codedInput.DiscardUnknownFields = originalDiscard; + } + } +#endif + /// /// Creates a new message parser which optionally discards unknown fields when parsing. /// @@ -315,6 +369,33 @@ public new T ParseFrom(CodedInputStream input) return message; } +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + /// + /// Parses a message from the given sequence. + /// + /// The data to parse. + /// The parsed message. + [SecuritySafeCritical] + public new T ParseFrom(ReadOnlySequence data) + { + T message = factory(); + message.MergeFrom(data, DiscardUnknownFields, Extensions); + return message; + } + + /// + /// Parses a message from the given coded input stream. + /// + /// The stream to parse. + /// The parsed message. + public new T ParseFrom(ref CodedInputReader input) + { + T message = factory(); + MergeFrom(message, ref input); + return message; + } +#endif + /// /// Parses a message from the given JSON. /// diff --git a/csharp/src/Google.Protobuf/Reflection/Descriptor.cs b/csharp/src/Google.Protobuf/Reflection/Descriptor.cs index 59c260018c04..9d94b4146fa8 100644 --- a/csharp/src/Google.Protobuf/Reflection/Descriptor.cs +++ b/csharp/src/Google.Protobuf/Reflection/Descriptor.cs @@ -193,7 +193,11 @@ public static partial class DescriptorReflection { /// The protocol compiler can output a FileDescriptorSet containing the .proto /// files it parses. /// - public sealed partial class FileDescriptorSet : pb::IMessage { + public sealed partial class FileDescriptorSet : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FileDescriptorSet()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -277,6 +281,17 @@ public sealed partial class FileDescriptorSet : pb::IMessage } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + file_.WriteTo(ref output, _repeated_file_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -312,12 +327,35 @@ public sealed partial class FileDescriptorSet : pb::IMessage } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + file_.AddEntriesFrom(ref input, _repeated_file_codec); + break; + } + } + } + } + #endif + } /// /// Describes a complete .proto file. /// - public sealed partial class FileDescriptorProto : pb::IMessage { + public sealed partial class FileDescriptorProto : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FileDescriptorProto()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -660,6 +698,43 @@ public sealed partial class FileDescriptorProto : pb::IMessage /// Describes a message type. /// - public sealed partial class DescriptorProto : pb::IMessage { + public sealed partial class DescriptorProto : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new DescriptorProto()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1044,6 +1194,32 @@ public sealed partial class DescriptorProto : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasName) { + output.WriteRawTag(10); + output.WriteString(Name); + } + field_.WriteTo(ref output, _repeated_field_codec); + nestedType_.WriteTo(ref output, _repeated_nestedType_codec); + enumType_.WriteTo(ref output, _repeated_enumType_codec); + extensionRange_.WriteTo(ref output, _repeated_extensionRange_codec); + extension_.WriteTo(ref output, _repeated_extension_codec); + if (HasOptions) { + output.WriteRawTag(58); + output.WriteMessage(Options); + } + oneofDecl_.WriteTo(ref output, _repeated_oneofDecl_codec); + reservedRange_.WriteTo(ref output, _repeated_reservedRange_codec); + reservedName_.WriteTo(ref output, _repeated_reservedName_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -1147,11 +1323,73 @@ public sealed partial class DescriptorProto : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + Name = input.ReadString(); + break; + } + case 18: { + field_.AddEntriesFrom(ref input, _repeated_field_codec); + break; + } + case 26: { + nestedType_.AddEntriesFrom(ref input, _repeated_nestedType_codec); + break; + } + case 34: { + enumType_.AddEntriesFrom(ref input, _repeated_enumType_codec); + break; + } + case 42: { + extensionRange_.AddEntriesFrom(ref input, _repeated_extensionRange_codec); + break; + } + case 50: { + extension_.AddEntriesFrom(ref input, _repeated_extension_codec); + break; + } + case 58: { + if (!HasOptions) { + Options = new global::Google.Protobuf.Reflection.MessageOptions(); + } + input.ReadMessage(Options); + break; + } + case 66: { + oneofDecl_.AddEntriesFrom(ref input, _repeated_oneofDecl_codec); + break; + } + case 74: { + reservedRange_.AddEntriesFrom(ref input, _repeated_reservedRange_codec); + break; + } + case 82: { + reservedName_.AddEntriesFrom(ref input, _repeated_reservedName_codec); + break; + } + } + } + } + #endif + #region Nested types /// Container for nested types declared in the DescriptorProto message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - public sealed partial class ExtensionRange : pb::IMessage { + public sealed partial class ExtensionRange : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ExtensionRange()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -1319,6 +1557,28 @@ public sealed partial class ExtensionRange : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasStart) { + output.WriteRawTag(8); + output.WriteInt32(Start); + } + if (HasEnd) { + output.WriteRawTag(16); + output.WriteInt32(End); + } + if (HasOptions) { + output.WriteRawTag(26); + output.WriteMessage(Options); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -1384,6 +1644,36 @@ public sealed partial class ExtensionRange : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + Start = input.ReadInt32(); + break; + } + case 16: { + End = input.ReadInt32(); + break; + } + case 26: { + if (!HasOptions) { + Options = new global::Google.Protobuf.Reflection.ExtensionRangeOptions(); + } + input.ReadMessage(Options); + break; + } + } + } + } + #endif + } /// @@ -1391,7 +1681,11 @@ public sealed partial class ExtensionRange : pb::IMessage { /// fields or extension ranges in the same message. Reserved ranges may /// not overlap. /// - public sealed partial class ReservedRange : pb::IMessage { + public sealed partial class ReservedRange : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ReservedRange()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -1531,6 +1825,24 @@ public sealed partial class ReservedRange : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasStart) { + output.WriteRawTag(8); + output.WriteInt32(Start); + } + if (HasEnd) { + output.WriteRawTag(16); + output.WriteInt32(End); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -1580,6 +1892,29 @@ public sealed partial class ReservedRange : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + Start = input.ReadInt32(); + break; + } + case 16: { + End = input.ReadInt32(); + break; + } + } + } + } + #endif + } } @@ -1587,7 +1922,11 @@ public sealed partial class ReservedRange : pb::IMessage { } - public sealed partial class ExtensionRangeOptions : pb::IExtendableMessage { + public sealed partial class ExtensionRangeOptions : pb::IExtendableMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ExtensionRangeOptions()); private pb::UnknownFieldSet _unknownFields; internal pb::ExtensionSet _extensions; @@ -1686,6 +2025,20 @@ public sealed partial class ExtensionRangeOptions : pb::IExtendableMessage(pb::Extension extension) { - return pb::ExtensionSet.Get(ref _extensions, extension); - } - public pbc::RepeatedField GetExtension(pb::RepeatedExtension extension) { - return pb::ExtensionSet.Get(ref _extensions, extension); + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, ref input)) { + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + } + break; + case 7994: { + uninterpretedOption_.AddEntriesFrom(ref input, _repeated_uninterpretedOption_codec); + break; + } + } + } + } + #endif + + public TValue GetExtension(pb::Extension extension) { + return pb::ExtensionSet.Get(ref _extensions, extension); + } + public pbc::RepeatedField GetExtension(pb::RepeatedExtension extension) { + return pb::ExtensionSet.Get(ref _extensions, extension); } public pbc::RepeatedField GetOrInitializeExtension(pb::RepeatedExtension extension) { return pb::ExtensionSet.GetOrInitialize(ref _extensions, extension); @@ -1754,7 +2128,11 @@ public sealed partial class ExtensionRangeOptions : pb::IExtendableMessage /// Describes a field within a message. /// - public sealed partial class FieldDescriptorProto : pb::IMessage { + public sealed partial class FieldDescriptorProto : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FieldDescriptorProto()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -2160,6 +2538,56 @@ public sealed partial class FieldDescriptorProto : pb::IMessageContainer for nested types declared in the FieldDescriptorProto message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -2367,7 +2853,11 @@ public enum Label { /// /// Describes a oneof. /// - public sealed partial class OneofDescriptorProto : pb::IMessage { + public sealed partial class OneofDescriptorProto : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new OneofDescriptorProto()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -2495,6 +2985,24 @@ public sealed partial class OneofDescriptorProto : pb::IMessage /// Describes an enum type. /// - public sealed partial class EnumDescriptorProto : pb::IMessage { + public sealed partial class EnumDescriptorProto : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new EnumDescriptorProto()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -2734,6 +3272,27 @@ public sealed partial class EnumDescriptorProto : pb::IMessageContainer for nested types declared in the EnumDescriptorProto message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -2819,7 +3416,11 @@ public static partial class Types { /// is inclusive such that it can appropriately represent the entire int32 /// domain. /// - public sealed partial class EnumReservedRange : pb::IMessage { + public sealed partial class EnumReservedRange : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new EnumReservedRange()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -2959,6 +3560,24 @@ public sealed partial class EnumReservedRange : pb::IMessage } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasStart) { + output.WriteRawTag(8); + output.WriteInt32(Start); + } + if (HasEnd) { + output.WriteRawTag(16); + output.WriteInt32(End); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -3008,6 +3627,29 @@ public sealed partial class EnumReservedRange : pb::IMessage } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + Start = input.ReadInt32(); + break; + } + case 16: { + End = input.ReadInt32(); + break; + } + } + } + } + #endif + } } @@ -3018,7 +3660,11 @@ public sealed partial class EnumReservedRange : pb::IMessage /// /// Describes a value within an enum. /// - public sealed partial class EnumValueDescriptorProto : pb::IMessage { + public sealed partial class EnumValueDescriptorProto : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new EnumValueDescriptorProto()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -3179,6 +3825,28 @@ public sealed partial class EnumValueDescriptorProto : pb::IMessage /// Describes a service. /// - public sealed partial class ServiceDescriptorProto : pb::IMessage { + public sealed partial class ServiceDescriptorProto : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ServiceDescriptorProto()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -3391,6 +4093,25 @@ public sealed partial class ServiceDescriptorProto : pb::IMessage /// Describes a method of a service. /// - public sealed partial class MethodDescriptorProto : pb::IMessage { + public sealed partial class MethodDescriptorProto : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MethodDescriptorProto()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -3689,7 +4444,40 @@ public sealed partial class MethodDescriptorProto : pb::IMessage { + public sealed partial class FileOptions : pb::IExtendableMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FileOptions()); private pb::UnknownFieldSet _unknownFields; internal pb::ExtensionSet _extensions; @@ -4624,6 +5459,100 @@ public sealed partial class FileOptions : pb::IExtendableMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasJavaPackage) { + output.WriteRawTag(10); + output.WriteString(JavaPackage); + } + if (HasJavaOuterClassname) { + output.WriteRawTag(66); + output.WriteString(JavaOuterClassname); + } + if (HasOptimizeFor) { + output.WriteRawTag(72); + output.WriteEnum((int) OptimizeFor); + } + if (HasJavaMultipleFiles) { + output.WriteRawTag(80); + output.WriteBool(JavaMultipleFiles); + } + if (HasGoPackage) { + output.WriteRawTag(90); + output.WriteString(GoPackage); + } + if (HasCcGenericServices) { + output.WriteRawTag(128, 1); + output.WriteBool(CcGenericServices); + } + if (HasJavaGenericServices) { + output.WriteRawTag(136, 1); + output.WriteBool(JavaGenericServices); + } + if (HasPyGenericServices) { + output.WriteRawTag(144, 1); + output.WriteBool(PyGenericServices); + } + if (HasJavaGenerateEqualsAndHash) { + output.WriteRawTag(160, 1); + output.WriteBool(JavaGenerateEqualsAndHash); + } + if (HasDeprecated) { + output.WriteRawTag(184, 1); + output.WriteBool(Deprecated); + } + if (HasJavaStringCheckUtf8) { + output.WriteRawTag(216, 1); + output.WriteBool(JavaStringCheckUtf8); + } + if (HasCcEnableArenas) { + output.WriteRawTag(248, 1); + output.WriteBool(CcEnableArenas); + } + if (HasObjcClassPrefix) { + output.WriteRawTag(162, 2); + output.WriteString(ObjcClassPrefix); + } + if (HasCsharpNamespace) { + output.WriteRawTag(170, 2); + output.WriteString(CsharpNamespace); + } + if (HasSwiftPrefix) { + output.WriteRawTag(186, 2); + output.WriteString(SwiftPrefix); + } + if (HasPhpClassPrefix) { + output.WriteRawTag(194, 2); + output.WriteString(PhpClassPrefix); + } + if (HasPhpNamespace) { + output.WriteRawTag(202, 2); + output.WriteString(PhpNamespace); + } + if (HasPhpGenericServices) { + output.WriteRawTag(208, 2); + output.WriteBool(PhpGenericServices); + } + if (HasPhpMetadataNamespace) { + output.WriteRawTag(226, 2); + output.WriteString(PhpMetadataNamespace); + } + if (HasRubyPackage) { + output.WriteRawTag(234, 2); + output.WriteString(RubyPackage); + } + uninterpretedOption_.WriteTo(ref output, _repeated_uninterpretedOption_codec); + if (_extensions != null) { + _extensions.WriteTo(ref output); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -4865,6 +5794,107 @@ public sealed partial class FileOptions : pb::IExtendableMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, ref input)) { + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + } + break; + case 10: { + JavaPackage = input.ReadString(); + break; + } + case 66: { + JavaOuterClassname = input.ReadString(); + break; + } + case 72: { + OptimizeFor = (global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode) input.ReadEnum(); + break; + } + case 80: { + JavaMultipleFiles = input.ReadBool(); + break; + } + case 90: { + GoPackage = input.ReadString(); + break; + } + case 128: { + CcGenericServices = input.ReadBool(); + break; + } + case 136: { + JavaGenericServices = input.ReadBool(); + break; + } + case 144: { + PyGenericServices = input.ReadBool(); + break; + } + case 160: { + JavaGenerateEqualsAndHash = input.ReadBool(); + break; + } + case 184: { + Deprecated = input.ReadBool(); + break; + } + case 216: { + JavaStringCheckUtf8 = input.ReadBool(); + break; + } + case 248: { + CcEnableArenas = input.ReadBool(); + break; + } + case 290: { + ObjcClassPrefix = input.ReadString(); + break; + } + case 298: { + CsharpNamespace = input.ReadString(); + break; + } + case 314: { + SwiftPrefix = input.ReadString(); + break; + } + case 322: { + PhpClassPrefix = input.ReadString(); + break; + } + case 330: { + PhpNamespace = input.ReadString(); + break; + } + case 336: { + PhpGenericServices = input.ReadBool(); + break; + } + case 354: { + PhpMetadataNamespace = input.ReadString(); + break; + } + case 362: { + RubyPackage = input.ReadString(); + break; + } + case 7994: { + uninterpretedOption_.AddEntriesFrom(ref input, _repeated_uninterpretedOption_codec); + break; + } + } + } + } + #endif + public TValue GetExtension(pb::Extension extension) { return pb::ExtensionSet.Get(ref _extensions, extension); } @@ -4914,7 +5944,11 @@ public enum OptimizeMode { } - public sealed partial class MessageOptions : pb::IExtendableMessage { + public sealed partial class MessageOptions : pb::IExtendableMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MessageOptions()); private pb::UnknownFieldSet _unknownFields; internal pb::ExtensionSet _extensions; @@ -5156,18 +6190,47 @@ public sealed partial class MessageOptions : pb::IExtendableMessage(pb::Extension extension) { return pb::ExtensionSet.Get(ref _extensions, extension); } @@ -5298,7 +6399,11 @@ public sealed partial class MessageOptions : pb::IExtendableMessage { + public sealed partial class FieldOptions : pb::IExtendableMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FieldOptions()); private pb::UnknownFieldSet _unknownFields; internal pb::ExtensionSet _extensions; @@ -5649,6 +6754,44 @@ public sealed partial class FieldOptions : pb::IExtendableMessage } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasCtype) { + output.WriteRawTag(8); + output.WriteEnum((int) Ctype); + } + if (HasPacked) { + output.WriteRawTag(16); + output.WriteBool(Packed); + } + if (HasDeprecated) { + output.WriteRawTag(24); + output.WriteBool(Deprecated); + } + if (HasLazy) { + output.WriteRawTag(40); + output.WriteBool(Lazy); + } + if (HasJstype) { + output.WriteRawTag(48); + output.WriteEnum((int) Jstype); + } + if (HasWeak) { + output.WriteRawTag(80); + output.WriteBool(Weak); + } + uninterpretedOption_.WriteTo(ref output, _repeated_uninterpretedOption_codec); + if (_extensions != null) { + _extensions.WriteTo(ref output); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -5750,6 +6893,51 @@ public sealed partial class FieldOptions : pb::IExtendableMessage } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, ref input)) { + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + } + break; + case 8: { + Ctype = (global::Google.Protobuf.Reflection.FieldOptions.Types.CType) input.ReadEnum(); + break; + } + case 16: { + Packed = input.ReadBool(); + break; + } + case 24: { + Deprecated = input.ReadBool(); + break; + } + case 40: { + Lazy = input.ReadBool(); + break; + } + case 48: { + Jstype = (global::Google.Protobuf.Reflection.FieldOptions.Types.JSType) input.ReadEnum(); + break; + } + case 80: { + Weak = input.ReadBool(); + break; + } + case 7994: { + uninterpretedOption_.AddEntriesFrom(ref input, _repeated_uninterpretedOption_codec); + break; + } + } + } + } + #endif + public TValue GetExtension(pb::Extension extension) { return pb::ExtensionSet.Get(ref _extensions, extension); } @@ -5805,7 +6993,11 @@ public enum JSType { } - public sealed partial class OneofOptions : pb::IExtendableMessage { + public sealed partial class OneofOptions : pb::IExtendableMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new OneofOptions()); private pb::UnknownFieldSet _unknownFields; internal pb::ExtensionSet _extensions; @@ -5904,6 +7096,20 @@ public sealed partial class OneofOptions : pb::IExtendableMessage } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + uninterpretedOption_.WriteTo(ref output, _repeated_uninterpretedOption_codec); + if (_extensions != null) { + _extensions.WriteTo(ref output); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -5945,6 +7151,27 @@ public sealed partial class OneofOptions : pb::IExtendableMessage } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, ref input)) { + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + } + break; + case 7994: { + uninterpretedOption_.AddEntriesFrom(ref input, _repeated_uninterpretedOption_codec); + break; + } + } + } + } + #endif + public TValue GetExtension(pb::Extension extension) { return pb::ExtensionSet.Get(ref _extensions, extension); } @@ -5969,7 +7196,11 @@ public sealed partial class OneofOptions : pb::IExtendableMessage } - public sealed partial class EnumOptions : pb::IExtendableMessage { + public sealed partial class EnumOptions : pb::IExtendableMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new EnumOptions()); private pb::UnknownFieldSet _unknownFields; internal pb::ExtensionSet _extensions; @@ -6142,6 +7373,28 @@ public sealed partial class EnumOptions : pb::IExtendableMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasAllowAlias) { + output.WriteRawTag(16); + output.WriteBool(AllowAlias); + } + if (HasDeprecated) { + output.WriteRawTag(24); + output.WriteBool(Deprecated); + } + uninterpretedOption_.WriteTo(ref output, _repeated_uninterpretedOption_codec); + if (_extensions != null) { + _extensions.WriteTo(ref output); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -6203,6 +7456,35 @@ public sealed partial class EnumOptions : pb::IExtendableMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, ref input)) { + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + } + break; + case 16: { + AllowAlias = input.ReadBool(); + break; + } + case 24: { + Deprecated = input.ReadBool(); + break; + } + case 7994: { + uninterpretedOption_.AddEntriesFrom(ref input, _repeated_uninterpretedOption_codec); + break; + } + } + } + } + #endif + public TValue GetExtension(pb::Extension extension) { return pb::ExtensionSet.Get(ref _extensions, extension); } @@ -6227,7 +7509,11 @@ public sealed partial class EnumOptions : pb::IExtendableMessage { } - public sealed partial class EnumValueOptions : pb::IExtendableMessage { + public sealed partial class EnumValueOptions : pb::IExtendableMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new EnumValueOptions()); private pb::UnknownFieldSet _unknownFields; internal pb::ExtensionSet _extensions; @@ -6365,6 +7651,24 @@ public sealed partial class EnumValueOptions : pb::IExtendableMessage(pb::Extension extension) { return pb::ExtensionSet.Get(ref _extensions, extension); } @@ -6440,7 +7769,11 @@ public sealed partial class EnumValueOptions : pb::IExtendableMessage { + public sealed partial class ServiceOptions : pb::IExtendableMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ServiceOptions()); private pb::UnknownFieldSet _unknownFields; internal pb::ExtensionSet _extensions; @@ -6578,6 +7911,24 @@ public sealed partial class ServiceOptions : pb::IExtendableMessage(pb::Extension extension) { return pb::ExtensionSet.Get(ref _extensions, extension); } @@ -6653,7 +8029,11 @@ public sealed partial class ServiceOptions : pb::IExtendableMessage { + public sealed partial class MethodOptions : pb::IExtendableMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MethodOptions()); private pb::UnknownFieldSet _unknownFields; internal pb::ExtensionSet _extensions; @@ -6813,14 +8193,36 @@ public sealed partial class MethodOptions : pb::IExtendableMessage(pb::Extension extension) { return pb::ExtensionSet.Get(ref _extensions, extension); } @@ -6939,7 +8370,11 @@ public enum IdempotencyLevel { /// or produced by Descriptor::CopyTo()) will never have UninterpretedOptions /// in them. /// - public sealed partial class UninterpretedOption : pb::IMessage { + public sealed partial class UninterpretedOption : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new UninterpretedOption()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -7212,6 +8647,41 @@ public sealed partial class UninterpretedOption : pb::IMessageContainer for nested types declared in the UninterpretedOption message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -7318,7 +8831,11 @@ public static partial class Types { /// E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents /// "foo.(bar.baz).qux". /// - public sealed partial class NamePart : pb::IMessage { + public sealed partial class NamePart : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NamePart()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -7451,6 +8968,24 @@ public sealed partial class NamePart : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (HasNamePart_) { + output.WriteRawTag(10); + output.WriteString(NamePart_); + } + if (HasIsExtension) { + output.WriteRawTag(16); + output.WriteBool(IsExtension); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -7500,6 +9035,29 @@ public sealed partial class NamePart : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + NamePart_ = input.ReadString(); + break; + } + case 16: { + IsExtension = input.ReadBool(); + break; + } + } + } + } + #endif + } } @@ -7511,7 +9069,11 @@ public sealed partial class NamePart : pb::IMessage { /// Encapsulates information about the original source file from which a /// FileDescriptorProto was generated. /// - public sealed partial class SourceCodeInfo : pb::IMessage { + public sealed partial class SourceCodeInfo : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new SourceCodeInfo()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -7640,6 +9202,17 @@ public sealed partial class SourceCodeInfo : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + location_.WriteTo(ref output, _repeated_location_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -7675,11 +9248,34 @@ public sealed partial class SourceCodeInfo : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + location_.AddEntriesFrom(ref input, _repeated_location_codec); + break; + } + } + } + } + #endif + #region Nested types /// Container for nested types declared in the SourceCodeInfo message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - public sealed partial class Location : pb::IMessage { + public sealed partial class Location : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Location()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -7932,6 +9528,27 @@ public sealed partial class Location : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + path_.WriteTo(ref output, _repeated_path_codec); + span_.WriteTo(ref output, _repeated_span_codec); + if (HasLeadingComments) { + output.WriteRawTag(26); + output.WriteString(LeadingComments); + } + if (HasTrailingComments) { + output.WriteRawTag(34); + output.WriteString(TrailingComments); + } + leadingDetachedComments_.WriteTo(ref output, _repeated_leadingDetachedComments_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -8001,6 +9618,43 @@ public sealed partial class Location : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: + case 8: { + path_.AddEntriesFrom(ref input, _repeated_path_codec); + break; + } + case 18: + case 16: { + span_.AddEntriesFrom(ref input, _repeated_span_codec); + break; + } + case 26: { + LeadingComments = input.ReadString(); + break; + } + case 34: { + TrailingComments = input.ReadString(); + break; + } + case 50: { + leadingDetachedComments_.AddEntriesFrom(ref input, _repeated_leadingDetachedComments_codec); + break; + } + } + } + } + #endif + } } @@ -8013,7 +9667,11 @@ public sealed partial class Location : pb::IMessage { /// file. A GeneratedCodeInfo message is associated with only one generated /// source file, but may contain references to different source .proto files. /// - public sealed partial class GeneratedCodeInfo : pb::IMessage { + public sealed partial class GeneratedCodeInfo : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new GeneratedCodeInfo()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -8101,6 +9759,17 @@ public sealed partial class GeneratedCodeInfo : pb::IMessage } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + annotation_.WriteTo(ref output, _repeated_annotation_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -8136,11 +9805,34 @@ public sealed partial class GeneratedCodeInfo : pb::IMessage } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + annotation_.AddEntriesFrom(ref input, _repeated_annotation_codec); + break; + } + } + } + } + #endif + #region Nested types /// Container for nested types declared in the GeneratedCodeInfo message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static partial class Types { - public sealed partial class Annotation : pb::IMessage { + public sealed partial class Annotation : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Annotation()); private pb::UnknownFieldSet _unknownFields; private int _hasBits0; @@ -8334,6 +10026,29 @@ public sealed partial class Annotation : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + path_.WriteTo(ref output, _repeated_path_codec); + if (HasSourceFile) { + output.WriteRawTag(18); + output.WriteString(SourceFile); + } + if (HasBegin) { + output.WriteRawTag(24); + output.WriteInt32(Begin); + } + if (HasEnd) { + output.WriteRawTag(32); + output.WriteInt32(End); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -8400,6 +10115,38 @@ public sealed partial class Annotation : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: + case 8: { + path_.AddEntriesFrom(ref input, _repeated_path_codec); + break; + } + case 18: { + SourceFile = input.ReadString(); + break; + } + case 24: { + Begin = input.ReadInt32(); + break; + } + case 32: { + End = input.ReadInt32(); + break; + } + } + } + } + #endif + } } diff --git a/csharp/src/Google.Protobuf/SequenceReader.cs b/csharp/src/Google.Protobuf/SequenceReader.cs new file mode 100644 index 000000000000..55f386794091 --- /dev/null +++ b/csharp/src/Google.Protobuf/SequenceReader.cs @@ -0,0 +1,417 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY +using System; +using System.Buffers; +using System.Collections.Generic; +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Security; +using System.Text; +using System.Threading; + +namespace Google.Protobuf +{ + /// + /// SequenceReader is originally from corefx, and has been contributed to Protobuf + /// https://github.com/dotnet/runtime/blob/071da4c41aa808c949a773b92dca6f88de9d11f3/src/libraries/System.Memory/src/System/Buffers/SequenceReader.cs + /// + [SecuritySafeCritical] + internal ref partial struct SequenceReader where T : IEquatable + { + private SequencePosition _currentPosition; + private SequencePosition _nextPosition; + private bool _moreData; + private long _length; + + /// + /// Create a over the given . + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public SequenceReader(ReadOnlySequence sequence) + { + CurrentSpanIndex = 0; + Consumed = 0; + Sequence = sequence; + _currentPosition = sequence.Start; + _length = -1; + + var first = sequence.First.Span; + _nextPosition = sequence.GetPosition(first.Length); + CurrentSpan = first; + _moreData = first.Length > 0; + + if (!_moreData && !sequence.IsSingleSegment) + { + _moreData = true; + GetNextSpan(); + } + } + + /// + /// True when there is no more data in the . + /// + public bool End => !_moreData; + + /// + /// The underlying for the reader. + /// + public ReadOnlySequence Sequence { get; } + + /// + /// The current position in the . + /// + public SequencePosition Position + => Sequence.GetPosition(CurrentSpanIndex, _currentPosition); + + /// + /// The current segment in the as a span. + /// + public ReadOnlySpan CurrentSpan { get; private set; } + + /// + /// The index in the . + /// + public int CurrentSpanIndex { get; private set; } + + /// + /// The unread portion of the . + /// + public ReadOnlySpan UnreadSpan + { + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get => CurrentSpan.Slice(CurrentSpanIndex); + } + + /// + /// The total number of 's processed by the reader. + /// + public long Consumed { get; private set; } + + /// + /// Remaining 's in the reader's . + /// + public long Remaining => Length - Consumed; + + /// + /// Count of in the reader's . + /// + public long Length + { + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get + { + if (_length < 0) + { + // Cache the length + _length = Sequence.Length; + } + return _length; + } + } + + /// + /// Peeks at the next value without advancing the reader. + /// + /// The next value or default if at the end. + /// False if at the end of the reader. + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public bool TryPeek(out T value) + { + if (_moreData) + { + value = CurrentSpan[CurrentSpanIndex]; + return true; + } + else + { + value = default; + return false; + } + } + + /// + /// Read the next value and advance the reader. + /// + /// The next value or default if at the end. + /// False if at the end of the reader. + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public bool TryRead(out T value) + { + if (End) + { + value = default; + return false; + } + + value = CurrentSpan[CurrentSpanIndex]; + CurrentSpanIndex++; + Consumed++; + + if (CurrentSpanIndex >= CurrentSpan.Length) + { + GetNextSpan(); + } + + return true; + } + + /// + /// Move the reader back the specified number of items. + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public void Rewind(long count) + { + if (count < 0) + { + throw new ArgumentOutOfRangeException(nameof(count)); + } + + Consumed -= count; + + if (CurrentSpanIndex >= count) + { + CurrentSpanIndex -= (int)count; + _moreData = true; + } + else + { + // Current segment doesn't have enough data, scan backward through segments + RetreatToPreviousSpan(Consumed); + } + } + + [MethodImpl(MethodImplOptions.NoInlining)] + private void RetreatToPreviousSpan(long consumed) + { + ResetReader(); + Advance(consumed); + } + + private void ResetReader() + { + CurrentSpanIndex = 0; + Consumed = 0; + _currentPosition = Sequence.Start; + _nextPosition = _currentPosition; + + if (Sequence.TryGet(ref _nextPosition, out ReadOnlyMemory memory, advance: true)) + { + _moreData = true; + + if (memory.Length == 0) + { + CurrentSpan = default; + // No data in the first span, move to one with data + GetNextSpan(); + } + else + { + CurrentSpan = memory.Span; + } + } + else + { + // No data in any spans and at end of sequence + _moreData = false; + CurrentSpan = default; + } + } + + /// + /// Get the next segment with available data, if any. + /// + private void GetNextSpan() + { + if (!Sequence.IsSingleSegment) + { + SequencePosition previousNextPosition = _nextPosition; + while (Sequence.TryGet(ref _nextPosition, out ReadOnlyMemory memory, advance: true)) + { + _currentPosition = previousNextPosition; + if (memory.Length > 0) + { + CurrentSpan = memory.Span; + CurrentSpanIndex = 0; + return; + } + else + { + CurrentSpan = default; + CurrentSpanIndex = 0; + previousNextPosition = _nextPosition; + } + } + } + _moreData = false; + } + + /// + /// Move the reader ahead the specified number of items. + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public void Advance(long count) + { + const long TooBigOrNegative = unchecked((long)0xFFFFFFFF80000000); + if ((count & TooBigOrNegative) == 0 && CurrentSpan.Length - CurrentSpanIndex > (int)count) + { + CurrentSpanIndex += (int)count; + Consumed += count; + } + else + { + // Can't satisfy from the current span + AdvanceToNextSpan(count); + } + } + + /// + /// Unchecked helper to avoid unnecessary checks where you know count is valid. + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + internal void AdvanceCurrentSpan(long count) + { + Debug.Assert(count >= 0); + + Consumed += count; + CurrentSpanIndex += (int)count; + if (CurrentSpanIndex >= CurrentSpan.Length) + GetNextSpan(); + } + + /// + /// Only call this helper if you know that you are advancing in the current span + /// with valid count and there is no need to fetch the next one. + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + internal void AdvanceWithinSpan(long count) + { + Debug.Assert(count >= 0); + + Consumed += count; + CurrentSpanIndex += (int)count; + + Debug.Assert(CurrentSpanIndex < CurrentSpan.Length); + } + + private void AdvanceToNextSpan(long count) + { + if (count < 0) + { + throw new ArgumentOutOfRangeException(nameof(count)); + } + + Consumed += count; + while (_moreData) + { + int remaining = CurrentSpan.Length - CurrentSpanIndex; + + if (remaining > count) + { + CurrentSpanIndex += (int)count; + count = 0; + break; + } + + // As there may not be any further segments we need to + // push the current index to the end of the span. + CurrentSpanIndex += remaining; + count -= remaining; + Debug.Assert(count >= 0); + + GetNextSpan(); + + if (count == 0) + { + break; + } + } + + if (count != 0) + { + // Not enough data left- adjust for where we actually ended and throw + Consumed -= count; + throw new ArgumentOutOfRangeException(nameof(count)); + } + } + + /// + /// Copies data from the current to the given span. + /// + /// Destination to copy to. + /// True if there is enough data to copy to the . + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public bool TryCopyTo(Span destination) + { + ReadOnlySpan firstSpan = UnreadSpan; + if (firstSpan.Length >= destination.Length) + { + firstSpan.Slice(0, destination.Length).CopyTo(destination); + return true; + } + + return TryCopyMultisegment(destination); + } + + internal bool TryCopyMultisegment(Span destination) + { + if (Remaining < destination.Length) + return false; + + ReadOnlySpan firstSpan = UnreadSpan; + Debug.Assert(firstSpan.Length < destination.Length); + firstSpan.CopyTo(destination); + int copied = firstSpan.Length; + + SequencePosition next = _nextPosition; + while (Sequence.TryGet(ref next, out ReadOnlyMemory nextSegment, true)) + { + if (nextSegment.Length > 0) + { + ReadOnlySpan nextSpan = nextSegment.Span; + int toCopy = Math.Min(nextSpan.Length, destination.Length - copied); + nextSpan.Slice(0, toCopy).CopyTo(destination.Slice(copied)); + copied += toCopy; + if (copied >= destination.Length) + { + break; + } + } + } + + return true; + } + } +} +#endif \ No newline at end of file diff --git a/csharp/src/Google.Protobuf/UnknownField.cs b/csharp/src/Google.Protobuf/UnknownField.cs index e3ce0e86efce..e206f472e16a 100644 --- a/csharp/src/Google.Protobuf/UnknownField.cs +++ b/csharp/src/Google.Protobuf/UnknownField.cs @@ -147,6 +147,59 @@ internal void WriteTo(int fieldNumber, CodedOutputStream output) } } +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + /// + /// Serializes the field, including the field number, and writes it to + /// + /// + /// The unknown field number. + /// The CodedOutputWriter to write to. + internal void WriteTo(int fieldNumber, ref CodedOutputWriter output) + { + if (varintList != null) + { + foreach (ulong value in varintList) + { + output.WriteTag(fieldNumber, WireFormat.WireType.Varint); + output.WriteUInt64(value); + } + } + if (fixed32List != null) + { + foreach (uint value in fixed32List) + { + output.WriteTag(fieldNumber, WireFormat.WireType.Fixed32); + output.WriteFixed32(value); + } + } + if (fixed64List != null) + { + foreach (ulong value in fixed64List) + { + output.WriteTag(fieldNumber, WireFormat.WireType.Fixed64); + output.WriteFixed64(value); + } + } + if (lengthDelimitedList != null) + { + foreach (ByteString value in lengthDelimitedList) + { + output.WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited); + output.WriteBytes(value); + } + } + if (groupList != null) + { + foreach (UnknownFieldSet value in groupList) + { + output.WriteTag(fieldNumber, WireFormat.WireType.StartGroup); + value.WriteTo(ref output); + output.WriteTag(fieldNumber, WireFormat.WireType.EndGroup); + } + } + } +#endif + /// /// Computes the number of bytes required to encode this field, including field /// number. diff --git a/csharp/src/Google.Protobuf/UnknownFieldSet.cs b/csharp/src/Google.Protobuf/UnknownFieldSet.cs index d136cf1e6572..97bd1d1c4306 100644 --- a/csharp/src/Google.Protobuf/UnknownFieldSet.cs +++ b/csharp/src/Google.Protobuf/UnknownFieldSet.cs @@ -75,7 +75,20 @@ public void WriteTo(CodedOutputStream output) { entry.Value.WriteTo(entry.Key, output); } - } + } + +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + /// + /// Serializes the set and writes it to . + /// + public void WriteTo(ref CodedOutputWriter output) + { + foreach (KeyValuePair entry in fields) + { + entry.Value.WriteTo(entry.Key, ref output); + } + } +#endif /// /// Gets the number of bytes required to encode this set. @@ -231,7 +244,65 @@ private bool MergeFieldFrom(CodedInputStream input) default: throw InvalidProtocolBufferException.InvalidWireType(); } - } + } + +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + /// + /// Parse a single field from and merge it + /// into this set. + /// + /// The coded input reader containing the field + /// false if the tag is an "end group" tag, true otherwise + private bool MergeFieldFrom(ref CodedInputReader input) + { + uint tag = input.LastTag; + int number = WireFormat.GetTagFieldNumber(tag); + switch (WireFormat.GetTagWireType(tag)) + { + case WireFormat.WireType.Varint: + { + ulong uint64 = input.ReadUInt64(); + GetOrAddField(number).AddVarint(uint64); + return true; + } + case WireFormat.WireType.Fixed32: + { + uint uint32 = input.ReadFixed32(); + GetOrAddField(number).AddFixed32(uint32); + return true; + } + case WireFormat.WireType.Fixed64: + { + ulong uint64 = input.ReadFixed64(); + GetOrAddField(number).AddFixed64(uint64); + return true; + } + case WireFormat.WireType.LengthDelimited: + { + ByteString bytes = input.ReadBytes(); + GetOrAddField(number).AddLengthDelimited(bytes); + return true; + } + case WireFormat.WireType.StartGroup: + { + uint endTag = WireFormat.MakeTag(number, WireFormat.WireType.EndGroup); + UnknownFieldSet set = new UnknownFieldSet(); + while (input.ReadTag() != endTag) + { + set.MergeFieldFrom(ref input); + } + GetOrAddField(number).AddGroup(set); + return true; + } + case WireFormat.WireType.EndGroup: + { + return false; + } + default: + throw InvalidProtocolBufferException.InvalidWireType(); + } + } +#endif /// /// Create a new UnknownFieldSet if unknownFields is null. @@ -260,6 +331,36 @@ private bool MergeFieldFrom(CodedInputStream input) } return unknownFields; } + +#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY + /// + /// Create a new UnknownFieldSet if unknownFields is null. + /// Parse a single field from and merge it + /// into unknownFields. If is configured to discard unknown fields, + /// will be returned as-is and the field will be skipped. + /// + /// The UnknownFieldSet which need to be merged + /// The coded input reader containing the field + /// The merged UnknownFieldSet + public static UnknownFieldSet MergeFieldFrom(UnknownFieldSet unknownFields, + ref CodedInputReader input) + { + if (input.DiscardUnknownFields) + { + input.SkipLastField(); + return unknownFields; + } + if (unknownFields == null) + { + unknownFields = new UnknownFieldSet(); + } + if (!unknownFields.MergeFieldFrom(ref input)) + { + throw new InvalidProtocolBufferException("Merge an unknown field of end-group tag, indicating that the corresponding start-group was missing."); // match the old code-gen + } + return unknownFields; + } +#endif /// /// Merges the fields from into this set. diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs index 09e0e29f0de9..01c49939d1ce 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs @@ -119,7 +119,11 @@ public static partial class AnyReflection { /// "value": "1.212s" /// } /// - public sealed partial class Any : pb::IMessage { + public sealed partial class Any : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Any()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -257,6 +261,24 @@ public sealed partial class Any : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (TypeUrl.Length != 0) { + output.WriteRawTag(10); + output.WriteString(TypeUrl); + } + if (Value.Length != 0) { + output.WriteRawTag(18); + output.WriteBytes(Value); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -306,6 +328,29 @@ public sealed partial class Any : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + TypeUrl = input.ReadString(); + break; + } + case 18: { + Value = input.ReadBytes(); + break; + } + } + } + } + #endif + } #endregion diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs index 06a990591940..de0f0b947407 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs @@ -64,7 +64,11 @@ public static partial class ApiReflection { /// this message itself. See https://cloud.google.com/apis/design/glossary for /// detailed terminology. /// - public sealed partial class Api : pb::IMessage { + public sealed partial class Api : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Api()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -289,6 +293,35 @@ public sealed partial class Api : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (Name.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Name); + } + methods_.WriteTo(ref output, _repeated_methods_codec); + options_.WriteTo(ref output, _repeated_options_codec); + if (Version.Length != 0) { + output.WriteRawTag(34); + output.WriteString(Version); + } + if (sourceContext_ != null) { + output.WriteRawTag(42); + output.WriteMessage(SourceContext); + } + mixins_.WriteTo(ref output, _repeated_mixins_codec); + if (Syntax != global::Google.Protobuf.WellKnownTypes.Syntax.Proto2) { + output.WriteRawTag(56); + output.WriteEnum((int) Syntax); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -382,12 +415,62 @@ public sealed partial class Api : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + Name = input.ReadString(); + break; + } + case 18: { + methods_.AddEntriesFrom(ref input, _repeated_methods_codec); + break; + } + case 26: { + options_.AddEntriesFrom(ref input, _repeated_options_codec); + break; + } + case 34: { + Version = input.ReadString(); + break; + } + case 42: { + if (sourceContext_ == null) { + SourceContext = new global::Google.Protobuf.WellKnownTypes.SourceContext(); + } + input.ReadMessage(SourceContext); + break; + } + case 50: { + mixins_.AddEntriesFrom(ref input, _repeated_mixins_codec); + break; + } + case 56: { + Syntax = (global::Google.Protobuf.WellKnownTypes.Syntax) input.ReadEnum(); + break; + } + } + } + } + #endif + } /// /// Method represents a method of an API interface. /// - public sealed partial class Method : pb::IMessage { + public sealed partial class Method : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Method()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -600,6 +683,41 @@ public sealed partial class Method : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (Name.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Name); + } + if (RequestTypeUrl.Length != 0) { + output.WriteRawTag(18); + output.WriteString(RequestTypeUrl); + } + if (RequestStreaming != false) { + output.WriteRawTag(24); + output.WriteBool(RequestStreaming); + } + if (ResponseTypeUrl.Length != 0) { + output.WriteRawTag(34); + output.WriteString(ResponseTypeUrl); + } + if (ResponseStreaming != false) { + output.WriteRawTag(40); + output.WriteBool(ResponseStreaming); + } + options_.WriteTo(ref output, _repeated_options_codec); + if (Syntax != global::Google.Protobuf.WellKnownTypes.Syntax.Proto2) { + output.WriteRawTag(56); + output.WriteEnum((int) Syntax); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -695,6 +813,49 @@ public sealed partial class Method : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + Name = input.ReadString(); + break; + } + case 18: { + RequestTypeUrl = input.ReadString(); + break; + } + case 24: { + RequestStreaming = input.ReadBool(); + break; + } + case 34: { + ResponseTypeUrl = input.ReadString(); + break; + } + case 40: { + ResponseStreaming = input.ReadBool(); + break; + } + case 50: { + options_.AddEntriesFrom(ref input, _repeated_options_codec); + break; + } + case 56: { + Syntax = (global::Google.Protobuf.WellKnownTypes.Syntax) input.ReadEnum(); + break; + } + } + } + } + #endif + } /// @@ -777,7 +938,11 @@ public sealed partial class Method : pb::IMessage { /// ... /// } /// - public sealed partial class Mixin : pb::IMessage { + public sealed partial class Mixin : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Mixin()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -890,6 +1055,24 @@ public sealed partial class Mixin : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (Name.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Name); + } + if (Root.Length != 0) { + output.WriteRawTag(18); + output.WriteString(Root); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -939,6 +1122,29 @@ public sealed partial class Mixin : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + Name = input.ReadString(); + break; + } + case 18: { + Root = input.ReadString(); + break; + } + } + } + } + #endif + } #endregion diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs index f0078c4dd4e0..f5afe09d9300 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs @@ -100,7 +100,11 @@ public static partial class DurationReflection { /// be expressed in JSON format as "3.000000001s", and 3 seconds and 1 /// microsecond should be expressed in JSON format as "3.000001s". /// - public sealed partial class Duration : pb::IMessage { + public sealed partial class Duration : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Duration()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -219,6 +223,24 @@ public sealed partial class Duration : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (Seconds != 0L) { + output.WriteRawTag(8); + output.WriteInt64(Seconds); + } + if (Nanos != 0) { + output.WriteRawTag(16); + output.WriteInt32(Nanos); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -268,6 +290,29 @@ public sealed partial class Duration : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + Seconds = input.ReadInt64(); + break; + } + case 16: { + Nanos = input.ReadInt32(); + break; + } + } + } + } + #endif + } #endregion diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs index fa435cd23edf..d2c70e3d07fb 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs @@ -50,7 +50,11 @@ public static partial class EmptyReflection { /// /// The JSON representation for `Empty` is empty JSON object `{}`. /// - public sealed partial class Empty : pb::IMessage { + public sealed partial class Empty : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Empty()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -120,6 +124,16 @@ public sealed partial class Empty : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -149,6 +163,21 @@ public sealed partial class Empty : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + } + } + } + #endif + } #endregion diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs b/csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs index 00e1e9faa453..9f096d2208f6 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs @@ -240,7 +240,11 @@ public static partial class FieldMaskReflection { /// request should verify the included field paths, and return an /// `INVALID_ARGUMENT` error if any path is unmappable. /// - public sealed partial class FieldMask : pb::IMessage { + public sealed partial class FieldMask : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FieldMask()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -327,6 +331,17 @@ public sealed partial class FieldMask : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + paths_.WriteTo(ref output, _repeated_paths_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -362,6 +377,25 @@ public sealed partial class FieldMask : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + paths_.AddEntriesFrom(ref input, _repeated_paths_codec); + break; + } + } + } + } + #endif + } #endregion diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs b/csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs index d7076196e0fd..7db9b941c33d 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs @@ -44,7 +44,11 @@ public static partial class SourceContextReflection { /// `SourceContext` represents information about the source of a /// protobuf element, like the file in which it is defined. /// - public sealed partial class SourceContext : pb::IMessage { + public sealed partial class SourceContext : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new SourceContext()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -136,6 +140,20 @@ public sealed partial class SourceContext : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (FileName.Length != 0) { + output.WriteRawTag(10); + output.WriteString(FileName); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -175,6 +193,25 @@ public sealed partial class SourceContext : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + FileName = input.ReadString(); + break; + } + } + } + } + #endif + } #endregion diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs index b1dbe239cc9c..4d3b9cd3c2c5 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs @@ -77,7 +77,11 @@ public enum NullValue { /// /// The JSON representation for `Struct` is JSON object. /// - public sealed partial class Struct : pb::IMessage { + public sealed partial class Struct : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Struct()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -164,6 +168,17 @@ public sealed partial class Struct : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + fields_.WriteTo(ref output, _map_fields_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -199,6 +214,25 @@ public sealed partial class Struct : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + fields_.AddEntriesFrom(ref input, _map_fields_codec); + break; + } + } + } + } + #endif + } /// @@ -209,7 +243,11 @@ public sealed partial class Struct : pb::IMessage { /// /// The JSON representation for `Value` is JSON value. /// - public sealed partial class Value : pb::IMessage { + public sealed partial class Value : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Value()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -445,6 +483,40 @@ public enum KindOneofCase { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (kindCase_ == KindOneofCase.NullValue) { + output.WriteRawTag(8); + output.WriteEnum((int) NullValue); + } + if (kindCase_ == KindOneofCase.NumberValue) { + output.WriteRawTag(17); + output.WriteDouble(NumberValue); + } + if (kindCase_ == KindOneofCase.StringValue) { + output.WriteRawTag(26); + output.WriteString(StringValue); + } + if (kindCase_ == KindOneofCase.BoolValue) { + output.WriteRawTag(32); + output.WriteBool(BoolValue); + } + if (kindCase_ == KindOneofCase.StructValue) { + output.WriteRawTag(42); + output.WriteMessage(StructValue); + } + if (kindCase_ == KindOneofCase.ListValue) { + output.WriteRawTag(50); + output.WriteMessage(ListValue); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -554,6 +626,56 @@ public enum KindOneofCase { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + kind_ = input.ReadEnum(); + kindCase_ = KindOneofCase.NullValue; + break; + } + case 17: { + NumberValue = input.ReadDouble(); + break; + } + case 26: { + StringValue = input.ReadString(); + break; + } + case 32: { + BoolValue = input.ReadBool(); + break; + } + case 42: { + global::Google.Protobuf.WellKnownTypes.Struct subBuilder = new global::Google.Protobuf.WellKnownTypes.Struct(); + if (kindCase_ == KindOneofCase.StructValue) { + subBuilder.MergeFrom(StructValue); + } + input.ReadMessage(subBuilder); + StructValue = subBuilder; + break; + } + case 50: { + global::Google.Protobuf.WellKnownTypes.ListValue subBuilder = new global::Google.Protobuf.WellKnownTypes.ListValue(); + if (kindCase_ == KindOneofCase.ListValue) { + subBuilder.MergeFrom(ListValue); + } + input.ReadMessage(subBuilder); + ListValue = subBuilder; + break; + } + } + } + } + #endif + } /// @@ -561,7 +683,11 @@ public enum KindOneofCase { /// /// The JSON representation for `ListValue` is JSON array. /// - public sealed partial class ListValue : pb::IMessage { + public sealed partial class ListValue : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ListValue()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -648,6 +774,17 @@ public sealed partial class ListValue : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + values_.WriteTo(ref output, _repeated_values_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -683,6 +820,25 @@ public sealed partial class ListValue : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + values_.AddEntriesFrom(ref input, _repeated_values_codec); + break; + } + } + } + } + #endif + } #endregion diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs index 12f4812af37f..27a9c960fe5f 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs @@ -123,7 +123,11 @@ public static partial class TimestampReflection { /// http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D /// ) to obtain a formatter capable of generating timestamps in this format. /// - public sealed partial class Timestamp : pb::IMessage { + public sealed partial class Timestamp : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Timestamp()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -240,6 +244,24 @@ public sealed partial class Timestamp : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (Seconds != 0L) { + output.WriteRawTag(8); + output.WriteInt64(Seconds); + } + if (Nanos != 0) { + output.WriteRawTag(16); + output.WriteInt32(Nanos); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -289,6 +311,29 @@ public sealed partial class Timestamp : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + Seconds = input.ReadInt64(); + break; + } + case 16: { + Nanos = input.ReadInt32(); + break; + } + } + } + } + #endif + } #endregion diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs index bfd4b8ec8221..4e6ce45ebf45 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs @@ -94,7 +94,11 @@ public enum Syntax { /// /// A protocol buffer message type. /// - public sealed partial class Type : pb::IMessage { + public sealed partial class Type : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Type()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -278,6 +282,31 @@ public sealed partial class Type : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (Name.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Name); + } + fields_.WriteTo(ref output, _repeated_fields_codec); + oneofs_.WriteTo(ref output, _repeated_oneofs_codec); + options_.WriteTo(ref output, _repeated_options_codec); + if (sourceContext_ != null) { + output.WriteRawTag(42); + output.WriteMessage(SourceContext); + } + if (Syntax != global::Google.Protobuf.WellKnownTypes.Syntax.Proto2) { + output.WriteRawTag(48); + output.WriteEnum((int) Syntax); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -361,12 +390,58 @@ public sealed partial class Type : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + Name = input.ReadString(); + break; + } + case 18: { + fields_.AddEntriesFrom(ref input, _repeated_fields_codec); + break; + } + case 26: { + oneofs_.AddEntriesFrom(ref input, _repeated_oneofs_codec); + break; + } + case 34: { + options_.AddEntriesFrom(ref input, _repeated_options_codec); + break; + } + case 42: { + if (sourceContext_ == null) { + SourceContext = new global::Google.Protobuf.WellKnownTypes.SourceContext(); + } + input.ReadMessage(SourceContext); + break; + } + case 48: { + Syntax = (global::Google.Protobuf.WellKnownTypes.Syntax) input.ReadEnum(); + break; + } + } + } + } + #endif + } /// /// A single field of a message type. /// - public sealed partial class Field : pb::IMessage { + public sealed partial class Field : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Field()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -644,6 +719,53 @@ public sealed partial class Field : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (Kind != global::Google.Protobuf.WellKnownTypes.Field.Types.Kind.TypeUnknown) { + output.WriteRawTag(8); + output.WriteEnum((int) Kind); + } + if (Cardinality != global::Google.Protobuf.WellKnownTypes.Field.Types.Cardinality.Unknown) { + output.WriteRawTag(16); + output.WriteEnum((int) Cardinality); + } + if (Number != 0) { + output.WriteRawTag(24); + output.WriteInt32(Number); + } + if (Name.Length != 0) { + output.WriteRawTag(34); + output.WriteString(Name); + } + if (TypeUrl.Length != 0) { + output.WriteRawTag(50); + output.WriteString(TypeUrl); + } + if (OneofIndex != 0) { + output.WriteRawTag(56); + output.WriteInt32(OneofIndex); + } + if (Packed != false) { + output.WriteRawTag(64); + output.WriteBool(Packed); + } + options_.WriteTo(ref output, _repeated_options_codec); + if (JsonName.Length != 0) { + output.WriteRawTag(82); + output.WriteString(JsonName); + } + if (DefaultValue.Length != 0) { + output.WriteRawTag(90); + output.WriteString(DefaultValue); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -769,6 +891,61 @@ public sealed partial class Field : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + Kind = (global::Google.Protobuf.WellKnownTypes.Field.Types.Kind) input.ReadEnum(); + break; + } + case 16: { + Cardinality = (global::Google.Protobuf.WellKnownTypes.Field.Types.Cardinality) input.ReadEnum(); + break; + } + case 24: { + Number = input.ReadInt32(); + break; + } + case 34: { + Name = input.ReadString(); + break; + } + case 50: { + TypeUrl = input.ReadString(); + break; + } + case 56: { + OneofIndex = input.ReadInt32(); + break; + } + case 64: { + Packed = input.ReadBool(); + break; + } + case 74: { + options_.AddEntriesFrom(ref input, _repeated_options_codec); + break; + } + case 82: { + JsonName = input.ReadString(); + break; + } + case 90: { + DefaultValue = input.ReadString(); + break; + } + } + } + } + #endif + #region Nested types /// Container for nested types declared in the Field message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -885,7 +1062,11 @@ public enum Cardinality { /// /// Enum type definition. /// - public sealed partial class Enum : pb::IMessage { + public sealed partial class Enum : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Enum()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1052,6 +1233,30 @@ public sealed partial class Enum : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (Name.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Name); + } + enumvalue_.WriteTo(ref output, _repeated_enumvalue_codec); + options_.WriteTo(ref output, _repeated_options_codec); + if (sourceContext_ != null) { + output.WriteRawTag(34); + output.WriteMessage(SourceContext); + } + if (Syntax != global::Google.Protobuf.WellKnownTypes.Syntax.Proto2) { + output.WriteRawTag(40); + output.WriteEnum((int) Syntax); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -1129,12 +1334,54 @@ public sealed partial class Enum : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + Name = input.ReadString(); + break; + } + case 18: { + enumvalue_.AddEntriesFrom(ref input, _repeated_enumvalue_codec); + break; + } + case 26: { + options_.AddEntriesFrom(ref input, _repeated_options_codec); + break; + } + case 34: { + if (sourceContext_ == null) { + SourceContext = new global::Google.Protobuf.WellKnownTypes.SourceContext(); + } + input.ReadMessage(SourceContext); + break; + } + case 40: { + Syntax = (global::Google.Protobuf.WellKnownTypes.Syntax) input.ReadEnum(); + break; + } + } + } + } + #endif + } /// /// Enum value definition. /// - public sealed partial class EnumValue : pb::IMessage { + public sealed partial class EnumValue : pb::IMessage + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + , pb::IBufferMessage + #endif + { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new EnumValue()); private pb::UnknownFieldSet _unknownFields; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1263,6 +1510,25 @@ public sealed partial class EnumValue : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(ref pb::CodedOutputWriter output) { + if (Name.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Name); + } + if (Number != 0) { + output.WriteRawTag(16); + output.WriteInt32(Number); + } + options_.WriteTo(ref output, _repeated_options_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; @@ -1318,13 +1584,44 @@ public sealed partial class EnumValue : pb::IMessage { } } + + #if !GOOGLE_PROTOBUF_DISABLE_BUFFER_SERIALIZATION + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ref pb::CodedInputReader input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + Name = input.ReadString(); + break; + } + case 16: { + Number = input.ReadInt32(); + break; + } + case 26: { + options_.AddEntriesFrom(ref input, _repeated_options_codec); + break; + } + } + } + } + #endif + } /// /// A protocol buffer option, which can be attached to a message, field, /// enumeration, etc. /// - public sealed partial class Option : pb::IMessage