From f52426827e4d5e8da7d205af538799740b5199b9 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Fri, 5 Jun 2015 20:44:05 +0100 Subject: First stab at new proto3-only code generator --- src/Makefile.am | 6 +- src/google/protobuf/compiler/csharp/csharp_enum.cc | 2 +- .../protobuf/compiler/csharp/csharp_enum_field.cc | 49 +- .../protobuf/compiler/csharp/csharp_extension.cc | 184 ----- .../protobuf/compiler/csharp/csharp_extension.h | 78 -- .../protobuf/compiler/csharp/csharp_field_base.cc | 37 +- .../protobuf/compiler/csharp/csharp_field_base.h | 5 - .../protobuf/compiler/csharp/csharp_message.cc | 855 ++++----------------- .../protobuf/compiler/csharp/csharp_message.h | 14 +- .../compiler/csharp/csharp_message_field.cc | 231 +----- .../compiler/csharp/csharp_message_field.h | 6 - .../compiler/csharp/csharp_primitive_field.cc | 177 +---- .../compiler/csharp/csharp_primitive_field.h | 9 +- .../compiler/csharp/csharp_repeated_enum_field.cc | 131 +--- .../compiler/csharp/csharp_repeated_enum_field.h | 6 +- .../csharp/csharp_repeated_message_field.cc | 120 +-- .../csharp/csharp_repeated_message_field.h | 4 - .../csharp/csharp_repeated_primitive_field.cc | 119 +-- .../csharp/csharp_repeated_primitive_field.h | 4 - .../csharp/csharp_source_generator_base.cc | 8 - .../compiler/csharp/csharp_source_generator_base.h | 17 - .../compiler/csharp/csharp_umbrella_class.cc | 88 +-- .../compiler/csharp/csharp_umbrella_class.h | 7 - .../protobuf/compiler/csharp/csharp_writer.cc | 136 ---- .../protobuf/compiler/csharp/csharp_writer.h | 93 --- vsprojects/libprotoc.vcproj | 4 - 26 files changed, 295 insertions(+), 2095 deletions(-) delete mode 100644 src/google/protobuf/compiler/csharp/csharp_extension.cc delete mode 100644 src/google/protobuf/compiler/csharp/csharp_extension.h delete mode 100644 src/google/protobuf/compiler/csharp/csharp_writer.cc delete mode 100644 src/google/protobuf/compiler/csharp/csharp_writer.h diff --git a/src/Makefile.am b/src/Makefile.am index 33894dc1..0dc18916 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -369,8 +369,6 @@ libprotoc_la_SOURCES = \ google/protobuf/compiler/csharp/csharp_enum.h \ google/protobuf/compiler/csharp/csharp_enum_field.cc \ google/protobuf/compiler/csharp/csharp_enum_field.h \ - google/protobuf/compiler/csharp/csharp_extension.cc \ - google/protobuf/compiler/csharp/csharp_extension.h \ google/protobuf/compiler/csharp/csharp_field_base.cc \ google/protobuf/compiler/csharp/csharp_field_base.h \ google/protobuf/compiler/csharp/csharp_generator.cc \ @@ -391,9 +389,7 @@ libprotoc_la_SOURCES = \ google/protobuf/compiler/csharp/csharp_source_generator_base.cc \ google/protobuf/compiler/csharp/csharp_source_generator_base.h \ google/protobuf/compiler/csharp/csharp_umbrella_class.cc \ - google/protobuf/compiler/csharp/csharp_umbrella_class.h \ - google/protobuf/compiler/csharp/csharp_writer.cc \ - google/protobuf/compiler/csharp/csharp_writer.h + google/protobuf/compiler/csharp/csharp_umbrella_class.h bin_PROGRAMS = protoc protoc_LDADD = $(PTHREAD_LIBS) libprotobuf.la libprotoc.la diff --git a/src/google/protobuf/compiler/csharp/csharp_enum.cc b/src/google/protobuf/compiler/csharp/csharp_enum.cc index 0e8f9836..d511bba3 100644 --- a/src/google/protobuf/compiler/csharp/csharp_enum.cc +++ b/src/google/protobuf/compiler/csharp/csharp_enum.cc @@ -58,7 +58,7 @@ EnumGenerator::~EnumGenerator() { void EnumGenerator::Generate(io::Printer* printer) { WriteGeneratedCodeAttributes(printer); - printer->Print("$access_level$ enum $name$ {\n", + printer->Print("$access_level$ enum $name$ : long {\n", "access_level", class_access_level(), "name", descriptor_->name()); printer->Indent(); diff --git a/src/google/protobuf/compiler/csharp/csharp_enum_field.cc b/src/google/protobuf/compiler/csharp/csharp_enum_field.cc index 51a95b9f..8865702d 100644 --- a/src/google/protobuf/compiler/csharp/csharp_enum_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_enum_field.cc @@ -55,36 +55,22 @@ EnumFieldGenerator::~EnumFieldGenerator() { void EnumFieldGenerator::GenerateParsingCode(io::Printer* printer) { printer->Print(variables_, - "object unknown;\n" - "if(input.ReadEnum(ref result.$name$_, out unknown)) {\n"); - if (SupportFieldPresence(descriptor_->file())) { - printer->Print(variables_, - " result.has$property_name$ = true;\n"); - } - printer->Print("} else if(unknown is int) {\n"); - if (!use_lite_runtime()) { - printer->Print(variables_, - " if (unknownFields == null) {\n" // First unknown field - create builder now - " unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);\n" - " }\n" - " unknownFields.MergeVarintField($number$, (ulong)(int)unknown);\n"); - } - printer->Print("}\n"); + "input.ReadEnum(ref $name$_);\n"); } void EnumFieldGenerator::GenerateSerializationCode(io::Printer* printer) { printer->Print(variables_, - "if ($has_property_check$) {\n" - " output.WriteEnum($number$, field_names[$field_ordinal$], (int) $property_name$, $property_name$);\n" - "}\n"); + "if ($has_property_check$) {\n" + " output.WriteEnum($number$, fieldNames[$field_ordinal$], (long) $property_name$, $property_name$);\n" + "}\n"); } void EnumFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) { printer->Print( - variables_, - "if ($has_property_check$) {\n" - " size += pb::CodedOutputStream.ComputeEnumSize($number$, (int) $property_name$);\n" - "}\n"); + variables_, + "if ($has_property_check$) {\n" + " size += pb::CodedOutputStream.ComputeEnumSize($number$, (long) $property_name$);\n" + "}\n"); } EnumOneofFieldGenerator::EnumOneofFieldGenerator(const FieldDescriptor* descriptor, @@ -96,30 +82,21 @@ EnumOneofFieldGenerator::~EnumOneofFieldGenerator() { } void EnumOneofFieldGenerator::GenerateParsingCode(io::Printer* printer) { + // TODO(jonskeet): What about if we read the default value? printer->Print( variables_, - "object unknown;\n" "$type_name$ enumValue = $default_value$;\n" - "if(input.ReadEnum(ref enumValue, out unknown)) {\n" + "if(input.ReadEnum(ref enumValue)) {\n" " result.$oneof_name$_ = enumValue;\n" " result.$oneof_name$Case_ = $oneof_property_name$OneofCase.$property_name$;\n" - "} else if(unknown is int) {\n"); - if (!use_lite_runtime()) { - printer->Print( - variables_, - " if (unknownFields == null) {\n" // First unknown field - create builder now - " unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);\n" - " }\n" - " unknownFields.MergeVarintField($number$, (ulong)(int)unknown);\n"); - } - printer->Print("}\n"); + "}\n"); } void EnumOneofFieldGenerator::GenerateSerializationCode(io::Printer* printer) { printer->Print( variables_, "if ($has_property_check$) {\n" - " output.WriteEnum($number$, field_names[$field_ordinal$], (int) $property_name$, $property_name$);\n" + " output.WriteEnum($number$, fieldNames[$field_ordinal$], (long) $property_name$, $property_name$);\n" "}\n"); } @@ -127,7 +104,7 @@ void EnumOneofFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) { printer->Print( variables_, "if ($has_property_check$) {\n" - " size += pb::CodedOutputStream.ComputeEnumSize($number$, (int) $property_name$);\n" + " size += pb::CodedOutputStream.ComputeEnumSize($number$, (long) $property_name$);\n" "}\n"); } diff --git a/src/google/protobuf/compiler/csharp/csharp_extension.cc b/src/google/protobuf/compiler/csharp/csharp_extension.cc deleted file mode 100644 index 8b665ae4..00000000 --- a/src/google/protobuf/compiler/csharp/csharp_extension.cc +++ /dev/null @@ -1,184 +0,0 @@ -// 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. - -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -using google::protobuf::internal::scoped_ptr; - -namespace google { -namespace protobuf { -namespace compiler { -namespace csharp { - -ExtensionGenerator::ExtensionGenerator(const FieldDescriptor* descriptor) - : FieldGeneratorBase(descriptor, 0) { - if (descriptor_->extension_scope()) { - variables_["scope"] = GetClassName(descriptor_->extension_scope()); - } else { - variables_["scope"] = GetFullUmbrellaClassName(descriptor_->file()); - } - variables_["extends"] = GetClassName(descriptor_->containing_type()); - variables_["capitalized_type_name"] = capitalized_type_name(); - variables_["full_name"] = descriptor_->full_name(); - variables_["access_level"] = class_access_level(); - variables_["index"] = SimpleItoa(descriptor_->index()); - variables_["property_name"] = property_name(); - variables_["type_name"] = type_name(); - if (use_lite_runtime()) { - variables_["generated_extension"] = descriptor_->is_repeated() ? - "GeneratedRepeatExtensionLite" : "GeneratedExtensionLite"; - } else { - variables_["generated_extension"] = descriptor_->is_repeated() ? - "GeneratedRepeatExtension" : "GeneratedExtension"; - } -} - -ExtensionGenerator::~ExtensionGenerator() { -} - -void ExtensionGenerator::Generate(io::Printer* printer) { - printer->Print( - "public const int $constant_name$ = $number$;\n", - "constant_name", GetFieldConstantName(descriptor_), - "number", SimpleItoa(descriptor_->number())); - - if (use_lite_runtime()) { - // TODO(jtattermusch): include the following check - //if (Descriptor.MappedType == MappedType.Message && Descriptor.MessageType.Options.MessageSetWireFormat) - //{ - // throw new ArgumentException( - // "option message_set_wire_format = true; is not supported in Lite runtime extensions."); - //} - - printer->Print( - variables_, - "$access_level$ static pb::$generated_extension$<$extends$, $type_name$> $property_name$;\n"); - } else if (descriptor_->is_repeated()) { - printer->Print( - variables_, - "$access_level$ static pb::GeneratedExtensionBase> $property_name$;\n"); - } else { - printer->Print( - variables_, - "$access_level$ static pb::GeneratedExtensionBase<$type_name$> $property_name$;\n"); - } -} - -void ExtensionGenerator::GenerateStaticVariableInitializers(io::Printer* printer) { - if (use_lite_runtime()) { - printer->Print( - variables_, - "$scope$.$property_name$ = \n"); - printer->Indent(); - printer->Print( - variables_, - "new pb::$generated_extension$<$extends$, $type_name$>(\n"); - printer->Indent(); - printer->Print( - variables_, - "\"$full_name$\",\n" - "$extends$.DefaultInstance,\n"); - if (!descriptor_->is_repeated()) { - std::string default_val; - if (descriptor_->has_default_value()) { - default_val = default_value(); - } else { - default_val = is_nullable_type() ? "null" : ("default(" + type_name() + ")"); - } - printer->Print("$default_val$,\n", "default_val", default_val); - } - printer->Print( - "$message_val$,\n", - "message_val", - (GetCSharpType(descriptor_->type()) == CSHARPTYPE_MESSAGE) ? - type_name() + ".DefaultInstance" : "null"); - printer->Print( - "$enum_val$,\n", - "enum_val", - (GetCSharpType(descriptor_->type()) == CSHARPTYPE_ENUM) ? - "new EnumLiteMap<" + type_name() + ">()" : "null"); - printer->Print( - variables_, - "$scope$.$property_name$FieldNumber,\n" - "pbd::FieldType.$capitalized_type_name$"); - if (descriptor_->is_repeated()) { - printer->Print( - ",\n" - "$is_packed$", - "is_packed", descriptor_->is_packed() ? "true" : "false"); - } - printer->Outdent(); - printer->Print(");\n"); - printer->Outdent(); - } - else if (descriptor_->is_repeated()) - { - printer->Print( - variables_, - "$scope$.$property_name$ = pb::GeneratedRepeatExtension<$type_name$>.CreateInstance($scope$.Descriptor.Extensions[$index$]);\n"); - } - else - { - printer->Print( - variables_, - "$scope$.$property_name$ = pb::GeneratedSingleExtension<$type_name$>.CreateInstance($scope$.Descriptor.Extensions[$index$]);\n"); - } -} - -void ExtensionGenerator::GenerateExtensionRegistrationCode(io::Printer* printer) { - printer->Print( - variables_, - "registry.Add($scope$.$property_name$);\n"); -} - -void ExtensionGenerator::WriteHash(io::Printer* printer) { -} - -void ExtensionGenerator::WriteEquals(io::Printer* printer) { -} - -void ExtensionGenerator::WriteToString(io::Printer* printer) { -} - -} // namespace csharp -} // namespace compiler -} // namespace protobuf -} // namespace google diff --git a/src/google/protobuf/compiler/csharp/csharp_extension.h b/src/google/protobuf/compiler/csharp/csharp_extension.h deleted file mode 100644 index f251a21c..00000000 --- a/src/google/protobuf/compiler/csharp/csharp_extension.h +++ /dev/null @@ -1,78 +0,0 @@ -// 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. - -#ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_EXTENSION_H__ -#define GOOGLE_PROTOBUF_COMPILER_CSHARP_EXTENSION_H__ - -#include - -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { -namespace csharp { - -class ExtensionGenerator : public FieldGeneratorBase { - public: - ExtensionGenerator(const FieldDescriptor* descriptor); - ~ExtensionGenerator(); - - void GenerateStaticVariableInitializers(io::Printer* printer); - void GenerateExtensionRegistrationCode(io::Printer* printer); - void Generate(io::Printer* printer); - - virtual void WriteHash(io::Printer* printer); - virtual void WriteEquals(io::Printer* printer); - virtual void WriteToString(io::Printer* printer); - - virtual void GenerateMembers(io::Printer* printer) {}; - virtual void GenerateBuilderMembers(io::Printer* printer) {}; - virtual void GenerateMergingCode(io::Printer* printer) {}; - virtual void GenerateBuildingCode(io::Printer* printer) {}; - virtual void GenerateParsingCode(io::Printer* printer) {}; - virtual void GenerateSerializationCode(io::Printer* printer) {}; - virtual void GenerateSerializedSizeCode(io::Printer* printer) {}; - - private: - std::string scope_; - std::string extends_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ExtensionGenerator); -}; - -} // namespace csharp -} // namespace compiler -} // namespace protobuf -} // namespace google - -#endif // GOOGLE_PROTOBUF_COMPILER_CSHARP_EXTENSION_H__ - diff --git a/src/google/protobuf/compiler/csharp/csharp_field_base.cc b/src/google/protobuf/compiler/csharp/csharp_field_base.cc index c3ce426b..367e54c2 100644 --- a/src/google/protobuf/compiler/csharp/csharp_field_base.cc +++ b/src/google/protobuf/compiler/csharp/csharp_field_base.cc @@ -263,37 +263,13 @@ bool AllPrintableAscii(const std::string& text) { } std::string FieldGeneratorBase::GetStringDefaultValueInternal() { - if (!descriptor_->has_default_value()) { - return "\"\""; - } - if (AllPrintableAscii(descriptor_->default_value_string())) { - // All chars are ASCII and printable. In this case we only - // need to escape quotes and backslashes. - std::string temp = descriptor_->default_value_string(); - temp = StringReplace(temp, "\\", "\\\\", true); - temp = StringReplace(temp, "'", "\\'", true); - temp = StringReplace(temp, "\"", "\\\"", true); - return "\"" + temp + "\""; - } - if (use_lite_runtime()) { - return "pb::ByteString.FromBase64(\"" - + StringToBase64(descriptor_->default_value_string()) - + "\").ToStringUtf8()"; - } - return "(string) " + GetClassName(descriptor_->containing_type()) - + ".Descriptor.Fields[" + SimpleItoa(descriptor_->index()) - + "].DefaultValue"; + // No other default values needed for proto3... + return "\"\""; } std::string FieldGeneratorBase::GetBytesDefaultValueInternal() { - if (!descriptor_->has_default_value()) { - return "pb::ByteString.Empty"; - } - if (use_lite_runtime()) { - return "pb::ByteString.FromBase64(\"" + StringToBase64(descriptor_->default_value_string()) + "\")"; - } - return "(pb::ByteString) "+ GetClassName(descriptor_->containing_type()) + - ".Descriptor.Fields[" + SimpleItoa(descriptor_->index()) + "].DefaultValue"; + // No other default values needed for proto3... + return "pb::ByteString.Empty"; } std::string FieldGeneratorBase::default_value() { @@ -365,11 +341,6 @@ std::string FieldGeneratorBase::number() { return SimpleItoa(descriptor_->number()); } -std::string FieldGeneratorBase::message_or_group() { - return - (descriptor_->type() == FieldDescriptor::TYPE_GROUP) ? "Group" : "Message"; -} - std::string FieldGeneratorBase::capitalized_type_name() { switch (descriptor_->type()) { case FieldDescriptor::TYPE_ENUM: diff --git a/src/google/protobuf/compiler/csharp/csharp_field_base.h b/src/google/protobuf/compiler/csharp/csharp_field_base.h index b1570587..1b044a49 100644 --- a/src/google/protobuf/compiler/csharp/csharp_field_base.h +++ b/src/google/protobuf/compiler/csharp/csharp_field_base.h @@ -42,17 +42,13 @@ namespace protobuf { namespace compiler { namespace csharp { -class Writer; - class FieldGeneratorBase : public SourceGeneratorBase { public: FieldGeneratorBase(const FieldDescriptor* descriptor, int fieldOrdinal); ~FieldGeneratorBase(); virtual void GenerateMembers(io::Printer* printer) = 0; - virtual void GenerateBuilderMembers(io::Printer* printer) = 0; virtual void GenerateMergingCode(io::Printer* printer) = 0; - virtual void GenerateBuildingCode(io::Printer* printer) = 0; virtual void GenerateParsingCode(io::Printer* printer) = 0; virtual void GenerateSerializationCode(io::Printer* printer) = 0; virtual void GenerateSerializedSizeCode(io::Printer* printer) = 0; @@ -82,7 +78,6 @@ class FieldGeneratorBase : public SourceGeneratorBase { bool is_nullable_type(); std::string default_value(); std::string number(); - std::string message_or_group(); std::string capitalized_type_name(); std::string field_ordinal(); diff --git a/src/google/protobuf/compiler/csharp/csharp_message.cc b/src/google/protobuf/compiler/csharp/csharp_message.cc index 66b87110..1defcf94 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message.cc @@ -43,7 +43,6 @@ #include #include -#include #include #include #include @@ -106,7 +105,7 @@ std::string GetUniqueFileScopeIdentifier(const Descriptor* descriptor) { } void MessageGenerator::GenerateStaticVariables(io::Printer* printer) { - // Because descriptor.proto (Google.ProtocolBuffers.DescriptorProtos) is + // Because descriptor.proto (Google.Protobuf.DescriptorProtos) is // used in the construction of descriptors, we have a tricky bootstrapping // problem. To help control static initialization order, we make sure all // descriptors and other static data that depends on them are members of @@ -115,14 +114,12 @@ void MessageGenerator::GenerateStaticVariables(io::Printer* printer) { std::string identifier = GetUniqueFileScopeIdentifier(descriptor_); - if (!use_lite_runtime()) { - // The descriptor for this type. - printer->Print( - "internal static pbd::MessageDescriptor internal__$identifier$__Descriptor;\n" - "internal static pb::FieldAccess.FieldAccessorTable<$full_class_name$, $full_class_name$.Builder> internal__$identifier$__FieldAccessorTable;\n", - "identifier", GetUniqueFileScopeIdentifier(descriptor_), - "full_class_name", full_class_name()); - } + // The descriptor for this type. + printer->Print( + "internal static pbd::MessageDescriptor internal__$identifier$__Descriptor;\n" + "internal static pb::FieldAccess.FieldAccessorTable<$full_class_name$> internal__$identifier$__FieldAccessorTable;\n", + "identifier", GetUniqueFileScopeIdentifier(descriptor_), + "full_class_name", full_class_name()); for (int i = 0; i < descriptor_->nested_type_count(); i++) { MessageGenerator messageGenerator(descriptor_->nested_type(i)); @@ -139,139 +136,106 @@ void MessageGenerator::GenerateStaticVariableInitializers(io::Printer* printer) vars["parent"] = GetUniqueFileScopeIdentifier( descriptor_->containing_type()); } - if (!use_lite_runtime()) { - printer->Print(vars, "internal__$identifier$__Descriptor = "); + printer->Print(vars, "internal__$identifier$__Descriptor = "); - if (!descriptor_->containing_type()) { - printer->Print(vars, "Descriptor.MessageTypes[$index$];\n"); - } else { - printer->Print(vars, "internal__$parent$__Descriptor.NestedTypes[$index$];\n"); - } + if (!descriptor_->containing_type()) { + printer->Print(vars, "Descriptor.MessageTypes[$index$];\n"); + } else { + printer->Print(vars, "internal__$parent$__Descriptor.NestedTypes[$index$];\n"); + } - printer->Print( - vars, - "internal__$identifier$__FieldAccessorTable = \n" - " new pb::FieldAccess.FieldAccessorTable<$full_class_name$, $full_class_name$.Builder>(internal__$identifier$__Descriptor,\n"); - printer->Print(" new string[] { "); - for (int i = 0; i < descriptor_->field_count(); i++) { - printer->Print("\"$property_name$\", ", - "property_name", GetPropertyName(descriptor_->field(i))); - } - for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { - printer->Print("\"$oneof_name$\", ", - "oneof_name", - UnderscoresToCamelCase(descriptor_->oneof_decl(i)->name(), true)); - } - printer->Print("});\n"); + printer->Print( + vars, + "internal__$identifier$__FieldAccessorTable = \n" + " new pb::FieldAccess.FieldAccessorTable<$full_class_name$>(internal__$identifier$__Descriptor,\n"); + printer->Print(" new string[] { "); + for (int i = 0; i < descriptor_->field_count(); i++) { + printer->Print("\"$property_name$\", ", + "property_name", GetPropertyName(descriptor_->field(i))); + } + for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { + printer->Print("\"$oneof_name$\", ", + "oneof_name", + UnderscoresToCamelCase(descriptor_->oneof_decl(i)->name(), true)); } + printer->Print("});\n"); // Generate static member initializers for all nested types. for (int i = 0; i < descriptor_->nested_type_count(); i++) { MessageGenerator messageGenerator(descriptor_->nested_type(i)); messageGenerator.GenerateStaticVariableInitializers(printer); } - - for (int i = 0; i < descriptor_->extension_count(); i++) { - ExtensionGenerator extensionGenerator(descriptor_->extension(i)); - extensionGenerator.GenerateStaticVariableInitializers(printer); - } } void MessageGenerator::Generate(io::Printer* printer) { map vars; vars["class_name"] = class_name(); vars["access_level"] = class_access_level(); - vars["extendable_or_generated"] = descriptor_->extension_range_count() > 0 ? - "Extendable" : "Generated"; - vars["suffix"] = runtime_suffix(); vars["umbrella_class_name"] = GetFullUmbrellaClassName(descriptor_->file()); vars["identifier"] = GetUniqueFileScopeIdentifier(descriptor_); printer->Print( - "[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\n"); + "[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\n"); WriteGeneratedCodeAttributes(printer); printer->Print( vars, - "$access_level$ sealed partial class $class_name$ : pb::$extendable_or_generated$Message$suffix$<$class_name$, $class_name$.Builder> {\n"); + "$access_level$ sealed partial class $class_name$ : pb::IMessage<$class_name$> {\n"); printer->Indent(); - printer->Print( - vars, - "private $class_name$() { }\n" // Private ctor. - // Must call MakeReadOnly() to make sure all lists are made read-only - "private static readonly $class_name$ defaultInstance = new $class_name$().MakeReadOnly();\n"); - if (optimize_speed()) { - printer->Print( - "private static readonly string[] _$name$FieldNames = " - "new string[] { $slash$$field_names$$slash$ };\n", - "name", UnderscoresToCamelCase(class_name(), false), - "field_names", JoinStrings(field_names(), "\", \""), + // All static fields and properties + printer->Print( + "private static readonly string[] _fieldNames = " + "new string[] { $slash$$field_names$$slash$ };\n", + "field_names", JoinStrings(field_names(), "\", \""), "slash", field_names().size() > 0 ? "\"" : ""); - std::vector tags; - for (int i = 0; i < field_names().size(); i++) { - uint32 tag = internal::WireFormat::MakeTag( - descriptor_->FindFieldByName(field_names()[i])); - tags.push_back(SimpleItoa(tag)); - } - printer->Print( - "private static readonly uint[] _$name$FieldTags = new uint[] { $tags$ };\n", - "name", UnderscoresToCamelCase(class_name(), false), - "tags", JoinStrings(tags, ", ")); + std::vector tags; + for (int i = 0; i < field_names().size(); i++) { + uint32 tag = internal::WireFormat::MakeTag( + descriptor_->FindFieldByName(field_names()[i])); + tags.push_back(SimpleItoa(tag)); } + printer->Print( + "private static readonly uint[] _fieldTags = new uint[] { $tags$ };\n", + "tags", JoinStrings(tags, ", ")); + printer->Print( vars, - "public static $class_name$ DefaultInstance {\n" - " get { return defaultInstance; }\n" + "public static pbd::MessageDescriptor Descriptor {\n" + " get { return $umbrella_class_name$.internal__$identifier$__Descriptor; }\n" "}\n" "\n" - "public override $class_name$ DefaultInstanceForType {\n" - " get { return DefaultInstance; }\n" + "protected override pb::FieldAccess.FieldAccessorTable<$class_name$> InternalFieldAccessors {\n" + " get { return $umbrella_class_name$.internal__$identifier$__FieldAccessorTable; }\n" "}\n" - "\n" - "protected override $class_name$ ThisMessage {\n" - " get { return this; }\n" - "}\n\n"); + "\n"); - if (!use_lite_runtime()) { - printer->Print( - vars, - "public static pbd::MessageDescriptor Descriptor {\n" - " get { return $umbrella_class_name$.internal__$identifier$__Descriptor; }\n" - "}\n" - "\n" - "protected override pb::FieldAccess.FieldAccessorTable<$class_name$, $class_name$.Builder> InternalFieldAccessors {\n" - " get { return $umbrella_class_name$.internal__$identifier$__FieldAccessorTable; }\n" - "}\n" - "\n"); - } + // Constructors + printer->Print( + vars, + "public $class_name$() { }\n"); // Public parameterless ctor. - // Extensions don't need to go in an extra nested type - for (int i = 0; i < descriptor_->extension_count(); i++) { - ExtensionGenerator extensionGenerator(descriptor_->extension(i)); - extensionGenerator.Generate(printer); - } + printer->Print( + vars, + "public $class_name$($class_name$ other) {\n" + " MergeWith(other);\n" + "}\n"); // Merge ctor. - if (descriptor_->enum_type_count() + descriptor_->nested_type_count() > 0) { - printer->Print("#region Nested types\n" - "[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\n"); - WriteGeneratedCodeAttributes(printer); - printer->Print("public static partial class Types {\n"); - printer->Indent(); - for (int i = 0; i < descriptor_->enum_type_count(); i++) { - EnumGenerator enumGenerator(descriptor_->enum_type(i)); - enumGenerator.Generate(printer); - } - for (int i = 0; i < descriptor_->nested_type_count(); i++) { - MessageGenerator messageGenerator(descriptor_->nested_type(i)); - messageGenerator.Generate(printer); - } - printer->Outdent(); - printer->Print("}\n" - "#endregion\n" - "\n"); + // Fields/properties + for (int i = 0; i < descriptor_->field_count(); i++) { + const FieldDescriptor* fieldDescriptor = descriptor_->field(i); + + // Rats: we lose the debug comment here :( + printer->Print( + "public const int $field_constant_name$ = $index$;\n", + "field_constant_name", GetFieldConstantName(fieldDescriptor), + "index", SimpleItoa(fieldDescriptor->number())); + scoped_ptr generator( + CreateFieldGeneratorInternal(fieldDescriptor)); + generator->GenerateMembers(printer); + printer->Print("\n"); } - // oneof + // oneof properties for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { vars["name"] = UnderscoresToCamelCase(descriptor_->oneof_decl(i)->name(), false); vars["property_name"] = UnderscoresToCamelCase(descriptor_->oneof_decl(i)->name(), true); @@ -280,13 +244,13 @@ void MessageGenerator::Generate(io::Printer* printer) { "private object $name$_;\n" "public enum $property_name$OneofCase {\n"); printer->Indent(); + printer->Print("None = 0,\n"); for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) { const FieldDescriptor* field = descriptor_->oneof_decl(i)->field(j); printer->Print("$field_property_name$ = $index$,\n", "field_property_name", GetPropertyName(field), "index", SimpleItoa(field->number())); } - printer->Print("None = 0,\n"); printer->Outdent(); printer->Print("}\n"); printer->Print( @@ -294,243 +258,78 @@ void MessageGenerator::Generate(io::Printer* printer) { "private $property_name$OneofCase $name$Case_ = $property_name$OneofCase.None;\n" "public $property_name$OneofCase $property_name$Case {\n" " get { return $name$Case_; }\n" + "}\n\n" + "private Clear$property_name$() {;\n" + " $name$Case_ = $property_name$OneofCase.None;" + " $name$_ = null;" "}\n\n"); } - // Fields - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldDescriptor* fieldDescriptor = descriptor_->field(i); + // TODO(jonskeet): Map properties - // Rats: we lose the debug comment here :( - printer->Print( - "public const int $field_constant_name$ = $index$;\n", - "field_constant_name", GetFieldConstantName(fieldDescriptor), - "index", SimpleItoa(fieldDescriptor->number())); - scoped_ptr generator( - CreateFieldGeneratorInternal(fieldDescriptor)); - generator->GenerateMembers(printer); - printer->Print("\n"); - } + // Standard methods + GenerateMessageSerializationMethods(printer); + GenerateMergingMethods(printer); - if (optimize_speed()) { - if (SupportFieldPresence(descriptor_->file())) { - GenerateIsInitialized(printer); + // Nested messages and enums + if (descriptor_->enum_type_count() + descriptor_->nested_type_count() > 0) { + printer->Print("#region Nested types\n" + "[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\n"); + WriteGeneratedCodeAttributes(printer); + printer->Print("public static partial class Types {\n"); + printer->Indent(); + for (int i = 0; i < descriptor_->enum_type_count(); i++) { + EnumGenerator enumGenerator(descriptor_->enum_type(i)); + enumGenerator.Generate(printer); } - GenerateMessageSerializationMethods(printer); - } - if (use_lite_runtime()) { - GenerateLiteRuntimeMethods(printer); - } - - GenerateParseFromMethods(printer); - GenerateBuilder(printer); - - // Force the static initialization code for the file to run, since it may - // initialize static variables declared in this class. - printer->Print(vars, "static $class_name$() {\n"); - // We call object.ReferenceEquals() just to make it a valid statement on its own. - // Another option would be GetType(), but that causes problems in DescriptorProtoFile, - // where the bootstrapping is somewhat recursive - type initializers call - // each other, effectively. We temporarily see Descriptor as null. - printer->Print( - vars, - " object.ReferenceEquals($umbrella_class_name$.Descriptor, null);\n" - "}\n"); - - printer->Outdent(); - printer->Print("}\n"); - printer->Print("\n"); - -} - -void MessageGenerator::GenerateLiteRuntimeMethods(io::Printer* printer) { - map vars; - vars["class_name"] = class_name(); - - bool callbase = descriptor_->extension_range_count() > 0; - printer->Print("#region Lite runtime methods\n" - "public override int GetHashCode() {\n"); - printer->Indent(); - printer->Print("int hash = GetType().GetHashCode();\n"); - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldDescriptor* field = descriptor_->field(i); - if (field->containing_oneof() == NULL) { - scoped_ptr generator( - CreateFieldGeneratorInternal(field)); - generator->WriteHash(printer); + for (int i = 0; i < descriptor_->nested_type_count(); i++) { + MessageGenerator messageGenerator(descriptor_->nested_type(i)); + messageGenerator.Generate(printer); } - } - for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { - string name = UnderscoresToCamelCase(descriptor_->oneof_decl(i)->name(), false); - string property_name = UnderscoresToCamelCase(descriptor_->oneof_decl(i)->name(), true); - printer->Print( - "if ($name$Case_ != $property_name$OneofCase.None) {\n" - " hash ^= $name$_.GetHashCode();\n" - "}\n", - "name", UnderscoresToCamelCase(descriptor_->oneof_decl(i)->name(), false), - "property_name", - UnderscoresToCamelCase(descriptor_->oneof_decl(i)->name(), true)); - } - if (callbase) { - printer->Print("hash ^= base.GetHashCode();\n"); - } - printer->Print("return hash;\n"); - printer->Outdent(); - printer->Print("}\n"); - printer->Print("\n"); - - printer->Print("public override bool Equals(object obj) {\n"); - printer->Indent(); - printer->Print( - vars, - "$class_name$ other = obj as $class_name$;\n" - "if (other == null) return false;\n"); - for (int i = 0; i < descriptor_->field_count(); i++) { - scoped_ptr generator( - CreateFieldGeneratorInternal(descriptor_->field(i))); - generator->WriteEquals(printer); - } - if (callbase) { - printer->Print("if (!base.Equals(other)) return false;\n"); - } - printer->Print("return true;\n"); - printer->Outdent(); - printer->Print("}\n"); - printer->Print("\n"); - - printer->Print( - "public override void PrintTo(global::System.IO.TextWriter writer) {\n"); - printer->Indent(); - - for (int i = 0; i < fields_by_number().size(); i++) { - scoped_ptr generator( - CreateFieldGeneratorInternal(fields_by_number()[i])); - generator->WriteToString(printer); + printer->Outdent(); + printer->Print("}\n" + "#endregion\n" + "\n"); } - if (callbase) { - printer->Print("base.PrintTo(writer);\n"); - } printer->Outdent(); printer->Print("}\n"); - printer->Print("#endregion\n"); printer->Print("\n"); -} -bool CompareExtensionRangesStart(const Descriptor::ExtensionRange* r1, - const Descriptor::ExtensionRange* r2) { - return r1->start < r2->start; } void MessageGenerator::GenerateMessageSerializationMethods(io::Printer* printer) { - std::vector extension_ranges_sorted; - for (int i = 0; i < descriptor_->extension_range_count(); i++) { - extension_ranges_sorted.push_back(descriptor_->extension_range(i)); - } - std::sort(extension_ranges_sorted.begin(), extension_ranges_sorted.end(), - CompareExtensionRangesStart); - printer->Print( - "public override void WriteTo(pb::ICodedOutputStream output) {\n"); + "public void WriteTo(pb::ICodedOutputStream output) {\n"); printer->Indent(); - // Make sure we've computed the serialized length, so that packed fields are generated correctly. - printer->Print("CalcSerializedSize();\n" - "string[] field_names = _$class_name$FieldNames;\n", - "class_name", UnderscoresToCamelCase(class_name(), false)); - if (descriptor_->extension_range_count()) { - printer->Print( - "pb::ExtendableMessage$runtime_suffix$<$class_name$, $class_name$.Builder>.ExtensionWriter extensionWriter = CreateExtensionWriter(this);\n", - "class_name", class_name(), - "runtime_suffix", runtime_suffix()); - } - - // Merge the fields and the extension ranges, both sorted by field number. - for (int i = 0, j = 0; - i < fields_by_number().size() || j < extension_ranges_sorted.size();) { - if (i == fields_by_number().size()) { - GenerateSerializeOneExtensionRange(printer, extension_ranges_sorted[j++]); - } else if (j == extension_ranges_sorted.size()) { - GenerateSerializeOneField(printer, fields_by_number()[i++]); - } else if (fields_by_number()[i]->number() - < extension_ranges_sorted[j]->start) { - GenerateSerializeOneField(printer, fields_by_number()[i++]); - } else { - GenerateSerializeOneExtensionRange(printer, extension_ranges_sorted[j++]); - } - } + printer->Print("string[] fieldNames = _fieldNames;\n"); - if (!use_lite_runtime()) { - if (descriptor_->options().message_set_wire_format()) - { - printer->Print("UnknownFields.WriteAsMessageSetTo(output);\n"); - } else { - printer->Print("UnknownFields.WriteTo(output);\n"); - } + // Serialize all the fields + for (int i = 0; i < fields_by_number().size(); i++) { + scoped_ptr generator( + CreateFieldGeneratorInternal(fields_by_number()[i])); + generator->GenerateSerializationCode(printer); } + // TODO(jonskeet): Memoize size of frozen messages? printer->Outdent(); printer->Print( "}\n" "\n" - "private int memoizedSerializedSize = -1;\n" - "public override int SerializedSize {\n"); + "public int CalculateSerializedSize() {\n"); printer->Indent(); - printer->Print("get {\n"); - printer->Indent(); - printer->Print( - "int size = memoizedSerializedSize;\n" - "if (size != -1) return size;\n" - "return CalcSerializedSize();\n"); - printer->Outdent(); - printer->Print("}\n"); - printer->Outdent(); - printer->Print("}\n"); - printer->Print("\n"); - - printer->Print("private int CalcSerializedSize() {\n"); - printer->Indent(); - printer->Print( - "int size = memoizedSerializedSize;\n" - "if (size != -1) return size;\n" - "\n" - "size = 0;\n"); + printer->Print("int size = 0;\n"); for (int i = 0; i < descriptor_->field_count(); i++) { scoped_ptr generator( CreateFieldGeneratorInternal(descriptor_->field(i))); generator->GenerateSerializedSizeCode(printer); } - if (descriptor_->extension_range_count() > 0) { - printer->Print("size += ExtensionsSerializedSize;\n"); - } - - if (!use_lite_runtime()) { - if (descriptor_->options().message_set_wire_format()) { - printer->Print("size += UnknownFields.SerializedSizeAsMessageSet;\n"); - } else { - printer->Print("size += UnknownFields.SerializedSize;\n"); - } - } - printer->Print( - "memoizedSerializedSize = size;\n" - "return size;\n"); + printer->Print("return size;\n"); printer->Outdent(); printer->Print("}\n"); } -void MessageGenerator::GenerateSerializeOneField( - io::Printer* printer, const FieldDescriptor* fieldDescriptor) { - scoped_ptr generator( - CreateFieldGeneratorInternal(fieldDescriptor)); - generator->GenerateSerializationCode(printer); -} - -void MessageGenerator::GenerateSerializeOneExtensionRange( - io::Printer* printer, const Descriptor::ExtensionRange* extensionRange) { - printer->Print("extensionWriter.WriteUntil($range_end$, output);\n", - "range_end", SimpleItoa(extensionRange->end)); -} - -void MessageGenerator::GenerateParseFromMethods(io::Printer* printer) { +void MessageGenerator::GenerateMergingMethods(io::Printer* printer) { // Note: These are separate from GenerateMessageSerializationMethods() // because they need to be generated even for messages that are optimized // for code size. @@ -539,339 +338,72 @@ void MessageGenerator::GenerateParseFromMethods(io::Printer* printer) { printer->Print( vars, - "public static $class_name$ ParseFrom(pb::ByteString data) {\n" - " return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed();\n" - "}\n" - "public static $class_name$ ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) {\n" - " return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();\n" - "}\n" - "public static $class_name$ ParseFrom(byte[] data) {\n" - " return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed();\n" - "}\n" - "public static $class_name$ ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) {\n" - " return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();\n" - "}\n" - "public static $class_name$ ParseFrom(global::System.IO.Stream input) {\n" - " return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed();\n" - "}\n" - "public static $class_name$ ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) {\n" - " return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();\n" - "}\n" - "public static $class_name$ ParseDelimitedFrom(global::System.IO.Stream input) {\n" - " return CreateBuilder().MergeDelimitedFrom(input).BuildParsed();\n" - "}\n" - "public static $class_name$ ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) {\n" - " return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed();\n" - "}\n" - "public static $class_name$ ParseFrom(pb::ICodedInputStream input) {\n" - " return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed();\n" - "}\n" - "public static $class_name$ ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {\n" - " return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();\n" - "}\n"); -} - -void MessageGenerator::GenerateBuilder(io::Printer* printer) { - map vars; - vars["class_name"] = class_name(); - vars["access_level"] = class_access_level(); - vars["extendable_or_generated"] = descriptor_->extension_range_count() > 0 ? - "Extendable" : "Generated"; - vars["suffix"] = runtime_suffix(); - - printer->Print(vars, "private $class_name$ MakeReadOnly() {\n"); - printer->Indent(); - for (int i = 0; i < descriptor_->field_count(); i++) { - scoped_ptr generator( - CreateFieldGeneratorInternal(descriptor_->field(i))); - generator->GenerateBuildingCode(printer); - } - printer->Print("return this;\n"); - printer->Outdent(); - printer->Print("}\n\n"); - - printer->Print( - vars, - "public static Builder CreateBuilder() { return new Builder(); }\n" - "public override Builder ToBuilder() { return CreateBuilder(this); }\n" - "public override Builder CreateBuilderForType() { return new Builder(); }\n" - "public static Builder CreateBuilder($class_name$ prototype) {\n" - " return new Builder(prototype);\n" - "}\n" - "\n" - "[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\n"); - WriteGeneratedCodeAttributes(printer); - printer->Print( - vars, - "$access_level$ sealed partial class Builder : pb::$extendable_or_generated$Builder$suffix$<$class_name$, Builder> {\n"); + "public void MergeWith($class_name$ other) {\n"); printer->Indent(); printer->Print( - "protected override Builder ThisBuilder {\n" - " get { return this; }\n" + "if (other == null) {\n" + " return;\n" "}\n"); - GenerateCommonBuilderMethods(printer); - if (optimize_speed()) { - GenerateBuilderParsingMethods(printer); - } + // TODO(jonskeet): Maps? + // Merge non-oneof fields for (int i = 0; i < descriptor_->field_count(); i++) { - scoped_ptr generator( - CreateFieldGeneratorInternal(descriptor_->field(i))); - printer->Print("\n"); - // No field comment :( - generator->GenerateBuilderMembers(printer); - } - - // oneof - for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { - printer->Print("\n"); - string name = UnderscoresToCamelCase(descriptor_->oneof_decl(i)->name(), false); - string property_name = UnderscoresToCamelCase(descriptor_->oneof_decl(i)->name(), true); - printer->Print( - "public $property_name$OneofCase $property_name$Case {\n" - " get { return result.$name$Case_; }\n" - "}\n" - "public Builder Clear$property_name$() {\n" - " PrepareBuilder();\n" - " result.$name$_ = null;\n" - " result.$name$Case_ = $property_name$OneofCase.None;\n" - " return this;\n" - "}\n", - "name", UnderscoresToCamelCase(descriptor_->oneof_decl(i)->name(), false), - "property_name", - UnderscoresToCamelCase(descriptor_->oneof_decl(i)->name(), true)); - } - - printer->Outdent(); - printer->Print("}\n"); -} - -void MessageGenerator::GenerateCommonBuilderMethods(io::Printer* printer) { - map vars; - vars["class_name"] = class_name(); - vars["full_class_name"] = full_class_name(); - vars["suffix"] = runtime_suffix(); - - printer->Print( - vars, - //default constructor - "public Builder() {\n" - //Durring static initialization of message, DefaultInstance is expected to return null. - " result = DefaultInstance;\n" - " resultIsReadOnly = true;\n" - "}\n" - //clone constructor - "internal Builder($class_name$ cloneFrom) {\n" - " result = cloneFrom;\n" - " resultIsReadOnly = true;\n" - "}\n" - "\n" - "private bool resultIsReadOnly;\n" - "private $class_name$ result;\n" - "\n" - "private $class_name$ PrepareBuilder() {\n" - " if (resultIsReadOnly) {\n" - " $class_name$ original = result;\n" - " result = new $class_name$();\n" - " resultIsReadOnly = false;\n" - " MergeFrom(original);\n" - " }\n" - " return result;\n" - "}\n" - "\n" - "public override bool IsInitialized {\n" - " get { return result.IsInitialized; }\n" - "}\n" - "\n" - "protected override $class_name$ MessageBeingBuilt {\n" - " get { return PrepareBuilder(); }\n" - "}\n" - "\n"); - //Not actually expecting that DefaultInstance would ever be null here; however, we will ensure it does not break - printer->Print( - "public override Builder Clear() {\n" - " result = DefaultInstance;\n" - " resultIsReadOnly = true;\n" - " return this;\n" - "}\n" - "\n" - "public override Builder Clone() {\n" - " if (resultIsReadOnly) {\n" - " return new Builder(result);\n" - " } else {\n" - " return new Builder().MergeFrom(result);\n" - " }\n" - "}\n" - "\n"); - if (!use_lite_runtime()) { - printer->Print( - vars, - "public override pbd::MessageDescriptor DescriptorForType {\n" - " get { return $full_class_name$.Descriptor; }\n" - "}\n\n"); + if (!descriptor_->field(i)->containing_oneof()) { + scoped_ptr generator( + CreateFieldGeneratorInternal(descriptor_->field(i))); + generator->GenerateMergingCode(printer); + } } - printer->Print( - vars, - "public override $class_name$ DefaultInstanceForType {\n" - " get { return $full_class_name$.DefaultInstance; }\n" - "}\n\n"); - - printer->Print( - vars, - "public override $class_name$ BuildPartial() {\n" - " if (resultIsReadOnly) {\n" - " return result;\n" - " }\n" - " resultIsReadOnly = true;\n" - " return result.MakeReadOnly();\n" - "}\n\n"); - - if (optimize_speed()) { - printer->Print( - vars, - "public override Builder MergeFrom(pb::IMessage$suffix$ other) {\n" - " if (other is $class_name$) {\n" - " return MergeFrom(($class_name$) other);\n" - " } else {\n" - " base.MergeFrom(other);\n" - " return this;\n" - " }\n" - "}\n\n"); - - printer->Print(vars,"public override Builder MergeFrom($class_name$ other) {\n"); - // Optimization: If other is the default instance, we know none of its - // fields are set so we can skip the merge. + // Merge oneof fields + for (int i = 0; i < descriptor_->oneof_decl_count(); ++i) { + vars["name"] = UnderscoresToCamelCase(descriptor_->oneof_decl(i)->name(), false); + vars["property_name"] = UnderscoresToCamelCase(descriptor_->oneof_decl(i)->name(), true); + printer->Print(vars, "switch (other.$property_name$Case) {\n"); printer->Indent(); - printer->Print( - vars, - "if (other == $full_class_name$.DefaultInstance) return this;\n" - "PrepareBuilder();\n"); - for (int i = 0; i < descriptor_->field_count(); i++) { - if (!descriptor_->field(i)->containing_oneof()) { - scoped_ptr generator( - CreateFieldGeneratorInternal(descriptor_->field(i))); - generator->GenerateMergingCode(printer); - } - } - - // Merge oneof fields - for (int i = 0; i < descriptor_->oneof_decl_count(); ++i) { - vars["name"] = UnderscoresToCamelCase(descriptor_->oneof_decl(i)->name(), false); - vars["property_name"] = UnderscoresToCamelCase(descriptor_->oneof_decl(i)->name(), true); - printer->Print(vars, "switch (other.$property_name$Case) {\n"); - printer->Indent(); - for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) { - const FieldDescriptor* field = descriptor_->oneof_decl(i)->field(j); - vars["field_property_name"] = GetPropertyName(field); - printer->Print( - vars, - "case $property_name$OneofCase.$field_property_name$: {\n"); - if (field->type() == FieldDescriptor::TYPE_GROUP || - field->type() == FieldDescriptor::TYPE_MESSAGE) { - printer->Print( - vars, - " Merge$field_property_name$(other.$field_property_name$);\n"); - } else { - printer->Print( - vars, - " Set$field_property_name$(other.$field_property_name$);\n"); - } - printer->Print(" break;\n"); - printer->Print("}\n"); - } - printer->Print(vars, "case $property_name$OneofCase.None: { break; }\n"); - printer->Outdent(); - printer->Print("}\n"); - } - - // if message type has extensions - if (descriptor_->extension_range_count() > 0) { - printer->Print(" this.MergeExtensionFields(other);\n"); - } - if (!use_lite_runtime()) { - printer->Print("this.MergeUnknownFields(other.UnknownFields);\n"); + for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) { + const FieldDescriptor* field = descriptor_->oneof_decl(i)->field(j); + vars["field_property_name"] = GetPropertyName(field); + printer->Print( + vars, + "case $property_name$OneofCase.$field_property_name$:\n" + " $field_property_name$ = other.$field_property_name$;\n" + " break;\n"); } - printer->Print("return this;\n"); printer->Outdent(); printer->Print("}\n\n"); } - -} - -void MessageGenerator::GenerateBuilderParsingMethods(io::Printer* printer) { - printer->Print( - "public override Builder MergeFrom(pb::ICodedInputStream input) {\n" - " return MergeFrom(input, pb::ExtensionRegistry.Empty);\n" - "}\n\n"); - - printer->Print( - "public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {\n"); + printer->Outdent(); + printer->Print("}\n\n"); + printer->Print("public void MergeFrom(pb::ICodedInputStream input) {\n"); printer->Indent(); - printer->Print("PrepareBuilder();\n"); - if (!use_lite_runtime()) { - printer->Print("pb::UnknownFieldSet.Builder unknownFields = null;\n"); - } printer->Print( "uint tag;\n" - "string field_name;\n" - "while (input.ReadTag(out tag, out field_name)) {\n"); + "string fieldName;\n" + "while (input.ReadTag(out tag, out fieldName)) {\n" + " if (tag == 0 && fieldName != null) {"); printer->Indent(); - printer->Print("if(tag == 0 && field_name != null) {\n"); printer->Indent(); - //if you change from StringComparer.Ordinal, the array sort in FieldNames { get; } must also change - printer->Print( - "int field_ordinal = global::System.Array.BinarySearch(_$camel_class_name$FieldNames, field_name, global::System.StringComparer.Ordinal);\n" - "if(field_ordinal >= 0)\n" - " tag = _$camel_class_name$FieldTags[field_ordinal];\n" - "else {\n", - "camel_class_name", UnderscoresToCamelCase(class_name(), false)); - if (!use_lite_runtime()) { - printer->Print( - " if (unknownFields == null) {\n" // First unknown field - create builder now - " unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);\n" - " }\n"); - } printer->Print( - " ParseUnknownField(input, $prefix$extensionRegistry, tag, field_name);\n", - "prefix", use_lite_runtime() ? "" : "unknownFields, "); - printer->Print(" continue;\n"); - printer->Print("}\n"); - printer->Outdent(); - printer->Print("}\n"); - - printer->Print("switch (tag) {\n"); + "int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.String.String.Ordinal);\n" + "if (fieldOrdinal >= 0) {\n" + " tag = _fieldTags[fieldOrdinal];\n" + "}\n" + "switch(tag) {\n"); printer->Indent(); printer->Print( "case 0: {\n" // 0 signals EOF / limit reached " throw pb::InvalidProtocolBufferException.InvalidTag();\n" "}\n" - "default: {\n" - " if (pb::WireFormat.IsEndGroupTag(tag)) {\n"); - if (!use_lite_runtime()) { - printer->Print( - " if (unknownFields != null) {\n" - " this.UnknownFields = unknownFields.Build();\n" - " }\n"); - } - printer->Print( - " return this;\n" // it's an endgroup tag - " }\n"); - if (!use_lite_runtime()) { - printer->Print( - " if (unknownFields == null) {\n" // First unknown field - create builder now - " unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);\n" - " }\n"); - } - printer->Print( - " ParseUnknownField(input, $prefix$extensionRegistry, tag, field_name);\n", - "prefix", use_lite_runtime() ? "" : "unknownFields, "); - printer->Print(" break;\n"); - printer->Print("}\n"); - + "default:\n" + " if (pb::WireFormat.IsEndGroupTag(tag)) {\n" + " return;\n" + " }\n" + " break;"); // Note: we're ignoring unknown fields here. for (int i = 0; i < fields_by_number().size(); i++) { const FieldDescriptor* field = fields_by_number()[i]; internal::WireFormatLite::WireType wt = internal::WireFormat::WireTypeForFieldType(field->type()); uint32 tag = internal::WireFormatLite::MakeTag(field->number(), wt); + // TODO(jonskeet): Understand what this is trying to do if (field->is_repeated() && (wt == internal::WireFormatLite::WIRETYPE_VARINT || wt == internal::WireFormatLite::WIRETYPE_FIXED32 @@ -894,95 +426,14 @@ void MessageGenerator::GenerateBuilderParsingMethods(io::Printer* printer) { printer->Outdent(); printer->Print("}\n"); } - - printer->Outdent(); - printer->Print("}\n"); printer->Outdent(); - printer->Print("}\n"); - printer->Print("\n"); - if (!use_lite_runtime()) { - printer->Print( - "if (unknownFields != null) {\n" - " this.UnknownFields = unknownFields.Build();\n" - "}\n"); - } - printer->Print("return this;\n"); + printer->Print("}\n"); // switch printer->Outdent(); - printer->Print("}\n\n"); -} - -void MessageGenerator::GenerateIsInitialized(io::Printer* printer) { - printer->Print("public override bool IsInitialized {\n"); - printer->Indent(); - printer->Print("get {\n"); - printer->Indent(); - - // Check that all required fields in this message are set. - // TODO(kenton): We can optimize this when we switch to putting all the - // "has" fields into a single bitfield. - for (int i = 0; i < descriptor_->field_count(); i++) { - if (descriptor_->field(i)->is_required()) { - printer->Print("if (!has$property_name$) return false;\n", - "property_name", GetPropertyName(descriptor_->field(i))); - } - } - - // Now check that all embedded messages are initialized. - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldDescriptor* field = descriptor_->field(i); - - if (field->type() != FieldDescriptor::TYPE_MESSAGE || - !HasRequiredFields(field->message_type())) - { - continue; - } - // TODO(jtattermusch): shouldn't we use GetPropertyName here? - string propertyName = UnderscoresToPascalCase(GetFieldName(field)); - if (field->is_repeated()) - { - printer->Print( - "foreach ($class_name$ element in $property_name$List) {\n" - " if (!element.IsInitialized) return false;\n" - "}\n", - "class_name", GetClassName(field->message_type()), - "property_name", propertyName); - } - else if (field->is_optional()) - { - printer->Print( - "if (Has$property_name$) {\n" - " if (!$property_name$.IsInitialized) return false;\n" - "}\n", - "property_name", propertyName); - } - else - { - printer->Print( - "if (!$property_name$.IsInitialized) return false;\n", - "property_name", propertyName); - } - } - - if (descriptor_->extension_range_count() > 0) { - printer->Print("if (!ExtensionsAreInitialized) return false;\n"); - } - printer->Print("return true;\n"); + printer->Print("}\n"); // if printer->Outdent(); - printer->Print("}\n"); + printer->Print("}\n"); // while printer->Outdent(); - printer->Print("}\n"); - printer->Print("\n"); -} - -void MessageGenerator::GenerateExtensionRegistrationCode(io::Printer* printer) { - for (int i = 0; i < descriptor_->extension_count(); i++) { - ExtensionGenerator extensionGenerator(descriptor_->extension(i)); - extensionGenerator.GenerateExtensionRegistrationCode(printer); - } - for (int i = 0; i < descriptor_->nested_type_count(); i++) { - MessageGenerator messageGenerator(descriptor_->nested_type(i)); - messageGenerator.GenerateExtensionRegistrationCode(printer); - } + printer->Print("}\n\n"); // method } int MessageGenerator::GetFieldOrdinal(const FieldDescriptor* descriptor) { diff --git a/src/google/protobuf/compiler/csharp/csharp_message.h b/src/google/protobuf/compiler/csharp/csharp_message.h index ebe58618..f5f41c73 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message.h +++ b/src/google/protobuf/compiler/csharp/csharp_message.h @@ -43,7 +43,6 @@ namespace protobuf { namespace compiler { namespace csharp { -class Writer; class FieldGeneratorBase; class MessageGenerator : public SourceGeneratorBase { @@ -53,7 +52,6 @@ class MessageGenerator : public SourceGeneratorBase { void GenerateStaticVariables(io::Printer* printer); void GenerateStaticVariableInitializers(io::Printer* printer); - void GenerateExtensionRegistrationCode(io::Printer* printer); void Generate(io::Printer* printer); private: @@ -61,17 +59,8 @@ class MessageGenerator : public SourceGeneratorBase { std::vector field_names_; std::vector fields_by_number_; - void GenerateLiteRuntimeMethods(io::Printer* printer); void GenerateMessageSerializationMethods(io::Printer* printer); - void GenerateSerializeOneField(io::Printer* printer, - const FieldDescriptor* fieldDescriptor); - void GenerateSerializeOneExtensionRange( - io::Printer* printer, const Descriptor::ExtensionRange* extendsionRange); - void GenerateParseFromMethods(io::Printer* printer); - void GenerateBuilder(io::Printer* printer); - void GenerateCommonBuilderMethods(io::Printer* printer); - void GenerateBuilderParsingMethods(io::Printer* printer); - void GenerateIsInitialized(io::Printer* printer); + void GenerateMergingMethods(io::Printer* printer); int GetFieldOrdinal(const FieldDescriptor* descriptor); FieldGeneratorBase* CreateFieldGeneratorInternal( @@ -95,4 +84,3 @@ class MessageGenerator : public SourceGeneratorBase { } // namespace google #endif // GOOGLE_PROTOBUF_COMPILER_CSHARP_MESSAGE_H__ - diff --git a/src/google/protobuf/compiler/csharp/csharp_message_field.cc b/src/google/protobuf/compiler/csharp/csharp_message_field.cc index 50eb9df6..90aa201b 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message_field.cc @@ -49,8 +49,8 @@ namespace csharp { MessageFieldGenerator::MessageFieldGenerator(const FieldDescriptor* descriptor, int fieldOrdinal) : FieldGeneratorBase(descriptor, fieldOrdinal) { - variables_["has_property_check"] = "has" + property_name(); - variables_["message_or_group"] = message_or_group(); + variables_["has_property_check"] = property_name() + "_ != null"; + variables_["has_not_property_check"] = property_name() + "_ == null"; } MessageFieldGenerator::~MessageFieldGenerator() { @@ -60,125 +60,42 @@ MessageFieldGenerator::~MessageFieldGenerator() { void MessageFieldGenerator::GenerateMembers(io::Printer* printer) { printer->Print( variables_, - "private bool has$property_name$;\n" "private $type_name$ $name$_;\n"); AddDeprecatedFlag(printer); - printer->Print( - variables_, - "public bool Has$property_name$ {\n" - " get { return has$property_name$; }\n" - "}\n"); - AddDeprecatedFlag(printer); printer->Print( variables_, "public $type_name$ $property_name$ {\n" - " get { return $name$_ ?? $default_value$; }\n" - "}\n"); -} - -void MessageFieldGenerator::GenerateBuilderMembers(io::Printer* printer) { - AddDeprecatedFlag(printer); - printer->Print( - variables_, - "public bool Has$property_name$ {\n" - " get { return result.has$property_name$; }\n" - "}\n"); - AddDeprecatedFlag(printer); - printer->Print( - variables_, - "public $type_name$ $property_name$ {\n" - " get { return result.$property_name$; }\n" - " set { Set$property_name$(value); }\n" - "}\n"); - AddDeprecatedFlag(printer); - printer->Print( - variables_, - "public Builder Set$property_name$($type_name$ value) {\n"); - AddNullCheck(printer); - printer->Print( - variables_, - " PrepareBuilder();\n" - " result.has$property_name$ = true;\n" - " result.$name$_ = value;\n" - " return this;\n" - "}\n"); - AddDeprecatedFlag(printer); - printer->Print( - variables_, - "public Builder Set$property_name$($type_name$.Builder builderForValue) {\n"); - AddNullCheck(printer, "builderForValue"); - printer->Print( - variables_, - " PrepareBuilder();\n" - " result.has$property_name$ = true;\n" - " result.$name$_ = builderForValue.Build();\n" - " return this;\n" - "}\n"); - AddDeprecatedFlag(printer); - printer->Print( - variables_, - "public Builder Merge$property_name$($type_name$ value) {\n"); - AddNullCheck(printer); - printer->Print( - variables_, - " PrepareBuilder();\n" - " if (result.has$property_name$ &&\n" - " result.$name$_ != $default_value$) {\n" - " result.$name$_ = $type_name$.CreateBuilder(result.$name$_).MergeFrom(value).BuildPartial();\n" - " } else {\n" - " result.$name$_ = value;\n" - " }\n" - " result.has$property_name$ = true;\n" - " return this;\n" - "}\n"); - AddDeprecatedFlag(printer); - printer->Print( - variables_, - "public Builder Clear$property_name$() {\n" - " PrepareBuilder();\n" - " result.has$property_name$ = false;\n" - " result.$name$_ = null;\n" - " return this;\n" + " get { return $name$_; }\n" + " set { return $name$_ = value; }\n" "}\n"); } void MessageFieldGenerator::GenerateMergingCode(io::Printer* printer) { printer->Print( variables_, - "if (other.Has$property_name$) {\n" - " Merge$property_name$(other.$property_name$);\n" + "if (other.$has_property_check$) {\n" + " if ($has_not_property_check) {\n" + " $name$_ = new $type_name$();\n" + " }\n" + " $property_name$.MergeWith(other.$property_name);\n" "}\n"); } -void MessageFieldGenerator::GenerateBuildingCode(io::Printer* printer) { - // Nothing to do for singular fields -} - void MessageFieldGenerator::GenerateParsingCode(io::Printer* printer) { printer->Print( variables_, - "$type_name$.Builder subBuilder = $type_name$.CreateBuilder();\n" - "if (result.has$property_name$) {\n" - " subBuilder.MergeFrom($property_name$);\n" - "}\n"); - - if (descriptor_->type() == FieldDescriptor::TYPE_GROUP) { - printer->Print( - variables_, - "input.ReadGroup($number$, subBuilder, extensionRegistry);\n"); - } else { - printer->Print("input.ReadMessage(subBuilder, extensionRegistry);\n"); - } - printer->Print( - variables_, - "$property_name$ = subBuilder.BuildPartial();\n"); + "if ($has_not_property_check) {\n" + " $name$_ = new $type_name$();\n" + "}\n" + "input.ReadMessage($name$_);\n"); // No need to support TYPE_GROUP... } void MessageFieldGenerator::GenerateSerializationCode(io::Printer* printer) { + // TODO(jonskeet): Why are we using array access instead of a literal here? printer->Print( variables_, "if ($has_property_check$) {\n" - " output.Write$message_or_group$($number$, field_names[$field_ordinal$], $property_name$);\n" + " output.WriteMessage($number$, fieldNames[$field_ordinal$], $property_name$);\n" "}\n"); } @@ -186,19 +103,19 @@ void MessageFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) { printer->Print( variables_, "if ($has_property_check$) {\n" - " size += pb::CodedOutputStream.Compute$message_or_group$Size($number$, $property_name$);\n" + " size += pb::CodedOutputStream.ComputeMessageSize($number$, $property_name$);\n" "}\n"); } void MessageFieldGenerator::WriteHash(io::Printer* printer) { printer->Print( variables_, - "if (has$property_name$) hash ^= $name$_.GetHashCode();\n"); + "if ($has_property_check$) hash ^= $name$_.GetHashCode();\n"); } void MessageFieldGenerator::WriteEquals(io::Printer* printer) { printer->Print( variables_, - "if (has$property_name$ != other.has$property_name$ || (has$property_name$ && !$name$_.Equals(other.$name$_))) return false;\n"); + "if (!object.Equals($property_name$_, other.$property_name$_)) return false;\n"); } void MessageFieldGenerator::WriteToString(io::Printer* printer) { variables_["field_name"] = GetFieldName(descriptor_); @@ -218,118 +135,30 @@ MessageOneofFieldGenerator::~MessageOneofFieldGenerator() { } void MessageOneofFieldGenerator::GenerateMembers(io::Printer* printer) { - if (SupportFieldPresence(descriptor_->file())) { - AddDeprecatedFlag(printer); - printer->Print( - variables_, - "public bool Has$property_name$ {\n" - " get { return $has_property_check$; }\n" - "}\n"); - } AddDeprecatedFlag(printer); printer->Print( variables_, "public $type_name$ $property_name$ {\n" - " get { return $has_property_check$ ? ($type_name$) $oneof_name$_ : $default_value$; }\n" - "}\n"); -} - -void MessageOneofFieldGenerator::GenerateBuilderMembers(io::Printer* printer) { - if (SupportFieldPresence(descriptor_->file())) { - AddDeprecatedFlag(printer); - printer->Print( - variables_, - "public bool Has$property_name$ {\n" - " get { return result.$has_property_check$; }\n" - "}\n"); - } - AddDeprecatedFlag(printer); - printer->Print( - variables_, - "public $type_name$ $property_name$ {\n" - " get { return result.$has_property_check$ ? ($type_name$) result.$oneof_name$_ : $default_value$; }\n" - " set { Set$property_name$(value); }\n" - "}\n"); - AddDeprecatedFlag(printer); - printer->Print( - variables_, - "public Builder Set$property_name$($type_name$ value) {\n"); - AddNullCheck(printer); - printer->Print( - variables_, - " PrepareBuilder();\n" - " result.$oneof_name$Case_ = $oneof_property_name$OneofCase.$property_name$;\n" - " result.$oneof_name$_ = value;\n" - " return this;\n" - "}\n"); - AddDeprecatedFlag(printer); - printer->Print( - variables_, - "public Builder Set$property_name$($type_name$.Builder builderForValue) {\n"); - AddNullCheck(printer, "builderForValue"); - printer->Print( - variables_, - " PrepareBuilder();\n" - " result.$oneof_name$Case_ = $oneof_property_name$OneofCase.$property_name$;\n" - " result.$oneof_name$_ = builderForValue.Build();\n" - " return this;\n" - "}\n"); - AddDeprecatedFlag(printer); - printer->Print( - variables_, - "public Builder Merge$property_name$($type_name$ value) {\n"); - AddNullCheck(printer); - printer->Print( - variables_, - " PrepareBuilder();\n" - " if (result.$has_property_check$ &&\n" - " result.$property_name$ != $default_value$) {\n" - " result.$oneof_name$_ = $type_name$.CreateBuilder(result.$property_name$).MergeFrom(value).BuildPartial();\n" - " } else {\n" - " result.$oneof_name$_ = value;\n" - " }\n" - " result.$oneof_name$Case_ = $oneof_property_name$OneofCase.$property_name$;\n" - " return this;\n" - "}\n"); - AddDeprecatedFlag(printer); - printer->Print( - variables_, - "public Builder Clear$property_name$() {\n" - " if (result.$has_property_check$) {\n" - " PrepareBuilder();\n" - " result.$oneof_name$Case_ = $oneof_property_name$OneofCase.None;\n" - " result.$oneof_name$_ = null;\n" - " }\n" - " return this;\n" + " get { return $has_property_check$ ? ($type_name$) $oneof_name$_ : null; }\n" + " set { \n" + " $name$_ = value;" + " $oneof_name$Case_ = value == null ? $oneof_property_name$Case.None : $oneof_property_name$Case.$property_name$; }\n" + " } \n" "}\n"); } void MessageOneofFieldGenerator::GenerateParsingCode(io::Printer* printer) { + // TODO(jonskeet): We may be able to do better than this printer->Print( variables_, - "$type_name$.Builder subBuilder = $type_name$.CreateBuilder();\n" - "if (result.$has_property_check$) {\n" - " subBuilder.MergeFrom($property_name$);\n" - "}\n"); - - if (descriptor_->type() == FieldDescriptor::TYPE_GROUP) { - printer->Print( - variables_, - "input.ReadGroup($number$, subBuilder, extensionRegistry);\n"); - } else { - printer->Print("input.ReadMessage(subBuilder, extensionRegistry);\n"); - } - printer->Print( - variables_, - "result.$oneof_name$_ = subBuilder.BuildPartial();\n" - "result.$oneof_name$Case_ = $oneof_property_name$OneofCase.$property_name$;\n"); + "$type_name$ subBuilder = new type_name$();\n" + "if ($has_property_check$) {\n" + " subBuilder.MergeWith($property_name$);\n" + "}\n" + "input.ReadMessage(subBuilder);\n" // No support of TYPE_GROUP + "$oneof_property_name$ = subBuilder;\n"); } -void MessageOneofFieldGenerator::WriteEquals(io::Printer* printer) { - printer->Print( - variables_, - "if (!$property_name$.Equals(other.$property_name$)) return false;\n"); -} void MessageOneofFieldGenerator::WriteToString(io::Printer* printer) { printer->Print( variables_, diff --git a/src/google/protobuf/compiler/csharp/csharp_message_field.h b/src/google/protobuf/compiler/csharp/csharp_message_field.h index d820908c..02053b4f 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message_field.h +++ b/src/google/protobuf/compiler/csharp/csharp_message_field.h @@ -41,17 +41,13 @@ namespace protobuf { namespace compiler { namespace csharp { -class Writer; - class MessageFieldGenerator : public FieldGeneratorBase { public: MessageFieldGenerator(const FieldDescriptor* descriptor, int fieldOrdinal); ~MessageFieldGenerator(); virtual void GenerateMembers(io::Printer* printer); - virtual void GenerateBuilderMembers(io::Printer* printer); virtual void GenerateMergingCode(io::Printer* printer); - virtual void GenerateBuildingCode(io::Printer* printer); virtual void GenerateParsingCode(io::Printer* printer); virtual void GenerateSerializationCode(io::Printer* printer); virtual void GenerateSerializedSizeCode(io::Printer* printer); @@ -70,8 +66,6 @@ class MessageOneofFieldGenerator : public MessageFieldGenerator { ~MessageOneofFieldGenerator(); virtual void GenerateMembers(io::Printer* printer); - virtual void GenerateBuilderMembers(io::Printer* printer); - virtual void WriteEquals(io::Printer* printer); virtual void WriteToString(io::Printer* printer); virtual void GenerateParsingCode(io::Printer* printer); diff --git a/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc b/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc index 652eb6b9..bc4858fc 100644 --- a/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc @@ -49,82 +49,37 @@ namespace csharp { PrimitiveFieldGenerator::PrimitiveFieldGenerator( const FieldDescriptor* descriptor, int fieldOrdinal) : FieldGeneratorBase(descriptor, fieldOrdinal) { + // TODO(jonskeet): Make this cleaner... + is_value_type = descriptor->type() != FieldDescriptor::TYPE_STRING + && descriptor->type() != FieldDescriptor::TYPE_BYTES; } PrimitiveFieldGenerator::~PrimitiveFieldGenerator() { - } void PrimitiveFieldGenerator::GenerateMembers(io::Printer* printer) { - if (SupportFieldPresence(descriptor_->file())) { - printer->Print(variables_, "private bool has$property_name$;\n"); - } + // TODO(jonskeet): Work out whether we want to prevent the fields from ever being + // null, or whether we just handle it, in the cases of bytes and string. + // (Basically, should null-handling code be in the getter or the setter?) printer->Print( variables_, "private $type_name$ $name_def_message$;\n"); AddDeprecatedFlag(printer); - if (SupportFieldPresence(descriptor_->file())) { - printer->Print( - variables_, - "public bool Has$property_name$ {\n" - " get { return has$property_name$; }\n" - "}\n"); - } - AddPublicMemberAttributes(printer); printer->Print( variables_, "public $type_name$ $property_name$ {\n" - " get { return $name$_; }\n" - "}\n"); -} - -void PrimitiveFieldGenerator::GenerateBuilderMembers(io::Printer* printer) { - AddDeprecatedFlag(printer); - if (SupportFieldPresence(descriptor_->file())) { - printer->Print( - variables_, - "public bool Has$property_name$ {\n" - " get { return result.has$property_name$; }\n" - "}\n"); - } - AddPublicMemberAttributes(printer); - printer->Print( - variables_, - "public $type_name$ $property_name$ {\n" - " get { return result.$property_name$; }\n" - " set { Set$property_name$(value); }\n" - "}\n"); - AddPublicMemberAttributes(printer); - printer->Print( - variables_, - "public Builder Set$property_name$($type_name$ value) {\n"); - AddNullCheck(printer); - printer->Print(" PrepareBuilder();\n"); - if (SupportFieldPresence(descriptor_->file())) { + " get { return $name$_; }\n"); + if (is_value_type) { printer->Print( variables_, - " result.has$property_name$ = true;\n"); - } - printer->Print( - variables_, - " result.$name$_ = value;\n" - " return this;\n" - "}\n"); - AddDeprecatedFlag(printer); - printer->Print( - variables_, - "public Builder Clear$property_name$() {\n" - " PrepareBuilder();\n"); - if (SupportFieldPresence(descriptor_->file())) { + " set { $name$_ = value; }\n"); + + } else { printer->Print( variables_, - " result.has$property_name$ = false;\n"); + " set { $name$_ = value ?? $default_value$; }\n"); } - printer->Print( - variables_, - " result.$name$_ = $default_value$;\n" - " return this;\n" - "}\n"); + printer->Print("}\n\n"); } void PrimitiveFieldGenerator::GenerateMergingCode(io::Printer* printer) { @@ -135,27 +90,17 @@ void PrimitiveFieldGenerator::GenerateMergingCode(io::Printer* printer) { "}\n"); } -void PrimitiveFieldGenerator::GenerateBuildingCode(io::Printer* printer) { - // Nothing to do here for primitive types -} - void PrimitiveFieldGenerator::GenerateParsingCode(io::Printer* printer) { - if (SupportFieldPresence(descriptor_->file())) { - printer->Print( - variables_, - "result.has$property_name$ = input.Read$capitalized_type_name$(ref result.$name$_);\n"); - } else { - printer->Print( - variables_, - "input.Read$capitalized_type_name$(ref result.$name$_);\n"); - } + printer->Print( + variables_, + "input.Read$capitalized_type_name$(ref result.$name$_);\n"); } void PrimitiveFieldGenerator::GenerateSerializationCode(io::Printer* printer) { printer->Print( variables_, "if ($has_property_check$) {\n" - " output.Write$capitalized_type_name$($number$, field_names[$field_ordinal$], $property_name$);\n" + " output.Write$capitalized_type_name$($number$, fieldNames[$field_ordinal$], $property_name$);\n" "}\n"); } @@ -171,24 +116,18 @@ void PrimitiveFieldGenerator::WriteHash(io::Printer* printer) { printer->Print( variables_, "if ($has_property_check$) {\n" - " hash ^= $name$_.GetHashCode();\n" + " hash ^= $property_name$.GetHashCode();\n" "}\n"); } void PrimitiveFieldGenerator::WriteEquals(io::Printer* printer) { - if (SupportFieldPresence(descriptor_->file())) { - printer->Print( - variables_, - "if (has$property_name$ != other.has$property_name$ || (has$property_name$ && !$name$_.Equals(other.$name$_))) return false;\n"); - } else { - printer->Print( - variables_, - "if (!$name$_.Equals(other.$name$_)) return false;\n"); - } + printer->Print( + variables_, + "if ($property_name$ != other.$property_name$) return false;\n"); } void PrimitiveFieldGenerator::WriteToString(io::Printer* printer) { printer->Print( variables_, - "PrintField(\"$descriptor_name$\", $has_property_check$, $name$_, writer);\n"); + "PrintField(\"$descriptor_name$\", $has_property_check$, $property_name$, writer);\n"); } PrimitiveOneofFieldGenerator::PrimitiveOneofFieldGenerator( @@ -201,79 +140,43 @@ PrimitiveOneofFieldGenerator::~PrimitiveOneofFieldGenerator() { } void PrimitiveOneofFieldGenerator::GenerateMembers(io::Printer* printer) { + // TODO(jonskeet): What should foo.OneofIntField = 0; do? Clear the oneof? + // Currently foo.OneOfStringField = null will clear the oneof, but foo.OneOfStringField = "" won't. Ick. AddDeprecatedFlag(printer); - if (SupportFieldPresence(descriptor_->file())) { - printer->Print( - variables_, - "public bool Has$property_name$ {\n" - " get { return $has_property_check$; }\n" - "}\n"); - } - AddPublicMemberAttributes(printer); printer->Print( variables_, "public $type_name$ $property_name$ {\n" " get { return $has_property_check$ ? ($type_name$) $oneof_name$_ : $default_value$; }\n" - "}\n"); -} - -void PrimitiveOneofFieldGenerator::GenerateBuilderMembers(io::Printer* printer) { - AddDeprecatedFlag(printer); - if (SupportFieldPresence(descriptor_->file())) { + " set {"); + if (is_value_type) { + printer->Print( + variables_, + " $oneof_name$_ = value;\n" + " $oneof_name$Case_ = $oneof_property_name$Case.$property_name$;\n"); + } else { + printer->Print( + variables_, + " $oneof_name$_ = value ?? $default_value$;\n" + " $oneof_name$Case_ = value == null ? $oneof_property_name$Case.None : $oneof_property_name$Case.$property_name$;\n"); + } printer->Print( - variables_, - "public bool Has$property_name$ {\n" - " get { return result.$has_property_check$; }\n" + " }\n" "}\n"); - } - AddPublicMemberAttributes(printer); - printer->Print( - variables_, - "public $type_name$ $property_name$ {\n" - " get { return result.$has_property_check$ ? ($type_name$) result.$oneof_name$_ : $default_value$; }\n" - " set { Set$property_name$(value); }\n" - "}\n"); - AddPublicMemberAttributes(printer); - printer->Print( - variables_, - "public Builder Set$property_name$($type_name$ value) {\n"); - AddNullCheck(printer); - printer->Print( - variables_, - " PrepareBuilder();\n" - " result.$oneof_name$_ = value;\n" - " result.$oneof_name$Case_ = $oneof_property_name$OneofCase.$property_name$;\n" - " return this;\n" - "}\n"); - AddDeprecatedFlag(printer); - printer->Print( - variables_, - "public Builder Clear$property_name$() {\n" - " PrepareBuilder();\n" - " if (result.$has_property_check$) {\n" - " result.$oneof_name$Case_ = $oneof_property_name$OneofCase.None;\n" - " }\n" - " return this;\n" - "}\n"); } -void PrimitiveOneofFieldGenerator::WriteEquals(io::Printer* printer) { - printer->Print( - variables_, - "if (!$property_name$.Equals(other.$property_name$)) return false;\n"); -} void PrimitiveOneofFieldGenerator::WriteToString(io::Printer* printer) { printer->Print(variables_, "PrintField(\"$descriptor_name$\", $has_property_check$, $oneof_name$_, writer);\n"); } void PrimitiveOneofFieldGenerator::GenerateParsingCode(io::Printer* printer) { + // TODO(jonskeet): What if the value we read is the default value for the type? printer->Print( variables_, "$type_name$ value = $default_value$;\n" "if (input.Read$capitalized_type_name$(ref value)) {\n" - " result.$oneof_name$_ = value;\n" - " result.$oneof_name$Case_ = $oneof_property_name$OneofCase.$property_name$;\n" + " $oneof_name$_ = value;\n" + " $oneof_name$Case_ = $oneof_property_name$OneofCase.$property_name$;\n" "}\n"); } diff --git a/src/google/protobuf/compiler/csharp/csharp_primitive_field.h b/src/google/protobuf/compiler/csharp/csharp_primitive_field.h index 8a2d5020..d6672b6c 100644 --- a/src/google/protobuf/compiler/csharp/csharp_primitive_field.h +++ b/src/google/protobuf/compiler/csharp/csharp_primitive_field.h @@ -41,17 +41,13 @@ namespace protobuf { namespace compiler { namespace csharp { -class Writer; - class PrimitiveFieldGenerator : public FieldGeneratorBase { public: PrimitiveFieldGenerator(const FieldDescriptor* descriptor, int fieldOrdinal); ~PrimitiveFieldGenerator(); virtual void GenerateMembers(io::Printer* printer); - virtual void GenerateBuilderMembers(io::Printer* printer); virtual void GenerateMergingCode(io::Printer* printer); - virtual void GenerateBuildingCode(io::Printer* printer); virtual void GenerateParsingCode(io::Printer* printer); virtual void GenerateSerializationCode(io::Printer* printer); virtual void GenerateSerializedSizeCode(io::Printer* printer); @@ -60,6 +56,9 @@ class PrimitiveFieldGenerator : public FieldGeneratorBase { virtual void WriteEquals(io::Printer* printer); virtual void WriteToString(io::Printer* printer); + protected: + bool is_value_type; + private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(PrimitiveFieldGenerator); }; @@ -70,8 +69,6 @@ class PrimitiveOneofFieldGenerator : public PrimitiveFieldGenerator { ~PrimitiveOneofFieldGenerator(); virtual void GenerateMembers(io::Printer* printer); - virtual void GenerateBuilderMembers(io::Printer* printer); - virtual void WriteEquals(io::Printer* printer); virtual void WriteToString(io::Printer* printer); virtual void GenerateParsingCode(io::Printer* printer); diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc b/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc index f5ebcfb1..f5d5a126 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc @@ -56,141 +56,46 @@ RepeatedEnumFieldGenerator::~RepeatedEnumFieldGenerator() { } void RepeatedEnumFieldGenerator::GenerateMembers(io::Printer* printer) { - if (descriptor_->is_packed() && optimize_speed()) { - printer->Print(variables_, "private int $name$MemoizedSerializedSize;\n"); - } - printer->Print(variables_, - "private pbc::PopsicleList<$type_name$> $name$_ = new pbc::PopsicleList<$type_name$>();\n"); - AddDeprecatedFlag(printer); - printer->Print( - variables_, - "public scg::IList<$type_name$> $property_name$List {\n" - " get { return pbc::Lists.AsReadOnly($name$_); }\n" - "}\n"); - - // TODO(jonskeet): Redundant API calls? Possibly - include for portability though. Maybe create an option. - AddDeprecatedFlag(printer); - printer->Print( - variables_, - "public int $property_name$Count {\n" - " get { return $name$_.Count; }\n" - "}\n"); - - AddDeprecatedFlag(printer); - printer->Print( - variables_, - "public $type_name$ Get$property_name$(int index) {\n" - " return $name$_[index];\n" - "}\n"); -} - -void RepeatedEnumFieldGenerator::GenerateBuilderMembers(io::Printer* printer) { - // Note: We can return the original list here, because we make it unmodifiable when we build - // We return it via IPopsicleList so that collection initializers work more pleasantly. - AddDeprecatedFlag(printer); - printer->Print( - variables_, - "public pbc::IPopsicleList<$type_name$> $property_name$List {\n" - " get { return PrepareBuilder().$name$_; }\n" - "}\n"); - AddDeprecatedFlag(printer); - printer->Print( - variables_, - "public int $property_name$Count {\n" - " get { return result.$property_name$Count; }\n" - "}\n"); - AddDeprecatedFlag(printer); - printer->Print( - variables_, - "public $type_name$ Get$property_name$(int index) {\n" - " return result.Get$property_name$(index);\n" - "}\n"); - AddDeprecatedFlag(printer); - printer->Print( - variables_, - "public Builder Set$property_name$(int index, $type_name$ value) {\n"); - printer->Print( - variables_, - " PrepareBuilder();\n" - " result.$name$_[index] = value;\n" - " return this;\n" - "}\n"); - AddDeprecatedFlag(printer); printer->Print(variables_, - "public Builder Add$property_name$($type_name$ value) {\n"); - printer->Print( - variables_, - " PrepareBuilder();\n" - " result.$name$_.Add(value);\n" - " return this;\n" - "}\n"); - AddDeprecatedFlag(printer); - printer->Print( - variables_, - "public Builder AddRange$property_name$(scg::IEnumerable<$type_name$> values) {\n" - " PrepareBuilder();\n" - " result.$name$_.Add(values);\n" - " return this;\n" - "}\n"); + "private readonly pbc::RepeatedField<$type_name$> $name$_ = new pbc::RepeatedField<$type_name$>();\n"); AddDeprecatedFlag(printer); printer->Print( variables_, - "public Builder Clear$property_name$() {\n" - " PrepareBuilder();\n" - " result.$name$_.Clear();\n" - " return this;\n" + "public pbc::RepeatedField<$type_name$> $property_name$ {\n" + " get { return $name$_; }\n" "}\n"); } void RepeatedEnumFieldGenerator::GenerateMergingCode(io::Printer* printer) { printer->Print( variables_, - "if (other.$name$_.Count != 0) {\n" - " result.$name$_.Add(other.$name$_);\n" - "}\n"); -} - -void RepeatedEnumFieldGenerator::GenerateBuildingCode(io::Printer* printer) { - printer->Print(variables_, "$name$_.MakeReadOnly();\n"); + "$name$_.Add(other.$name$_);\n"); } void RepeatedEnumFieldGenerator::GenerateParsingCode(io::Printer* printer) { printer->Print( variables_, - "scg::ICollection unknownItems;\n" - "input.ReadEnumArray<$type_name$>(tag, field_name, result.$name$_, out unknownItems);\n"); - if (!use_lite_runtime()) { - printer->Print( - variables_, - "if (unknownItems != null) {\n" - " if (unknownFields == null) {\n" - " unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);\n" - " }\n" - " foreach (object rawValue in unknownItems)\n" - " if (rawValue is int)\n" - " unknownFields.MergeVarintField($number$, (ulong)(int)rawValue);\n" - "}\n"); - } + "input.ReadEnumArray<$type_name$>(tag, fieldName, result.$name$_);\n"); } void RepeatedEnumFieldGenerator::GenerateSerializationCode(io::Printer* printer) { - printer->Print(variables_, "if ($name$_.Count > 0) {\n"); - printer->Indent(); + // TODO(jonskeet): Originally, this checked for Count > 0 first. + // The Write* call should make that cheap though - no need to generate it every time. if (descriptor_->is_packed()) { printer->Print( variables_, - "output.WritePackedEnumArray($number$, field_names[$field_ordinal$], $name$MemoizedSerializedSize, $name$_);\n"); + "output.WritePackedEnumArray($number$, fieldNames[$field_ordinal$], $name$_);\n"); } else { printer->Print(variables_, - "output.WriteEnumArray($number$, field_names[$field_ordinal$], $name$_);\n"); + "output.WriteEnumArray($number$, fieldNames[$field_ordinal$], $name$_);\n"); } - printer->Outdent(); printer->Print("}\n"); } void RepeatedEnumFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) { printer->Print("{\n"); printer->Indent(); + // TODO(jonskeet): Move all this code into CodedOutputStream? It's a lot to repeat everywhere... printer->Print( variables_, "int dataSize = 0;\n" @@ -199,7 +104,7 @@ void RepeatedEnumFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer printer->Print( variables_, "foreach ($type_name$ element in $name$_) {\n" - " dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element);\n" + " dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((long) element);\n" "}\n" "size += dataSize;\n"); int tagSize = internal::WireFormat::TagSize(descriptor_->number(), descriptor_->type()); @@ -215,11 +120,6 @@ void RepeatedEnumFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer } printer->Outdent(); printer->Print("}\n"); - // cache the data size for packed fields. - if (descriptor_->is_packed()) { - printer->Print(variables_, - "$name$MemoizedSerializedSize = dataSize;\n"); - } printer->Outdent(); printer->Print("}\n"); } @@ -227,16 +127,15 @@ void RepeatedEnumFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer void RepeatedEnumFieldGenerator::WriteHash(io::Printer* printer) { printer->Print( variables_, - "foreach($type_name$ i in $name$_)\n" - " hash ^= i.GetHashCode();\n"); + "foreach($type_name$ i in $name$_) {\n" + " hash ^= i.GetHashCode();\n" + "}\n"); } void RepeatedEnumFieldGenerator::WriteEquals(io::Printer* printer) { printer->Print( variables_, - "if($name$_.Count != other.$name$_.Count) return false;\n" - "for(int ix=0; ix < $name$_.Count; ix++)\n" - " if(!$name$_[ix].Equals(other.$name$_[ix])) return false;\n"); + "if(!$name$_.Equals(other.$name$)) return false;\n"); } void RepeatedEnumFieldGenerator::WriteToString(io::Printer* printer) { diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.h b/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.h index 68c3d6c9..92f265c5 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.h +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.h @@ -41,17 +41,15 @@ namespace protobuf { namespace compiler { namespace csharp { -class Writer; - +// TODO(jonskeet): Refactor repeated field support; all the implementations are *really* similar. We +// should probably have a RepeatedFieldGeneratorBase. class RepeatedEnumFieldGenerator : public FieldGeneratorBase { public: RepeatedEnumFieldGenerator(const FieldDescriptor* descriptor, int fieldOrdinal); ~RepeatedEnumFieldGenerator(); virtual void GenerateMembers(io::Printer* printer); - virtual void GenerateBuilderMembers(io::Printer* printer); virtual void GenerateMergingCode(io::Printer* printer); - virtual void GenerateBuildingCode(io::Printer* printer); virtual void GenerateParsingCode(io::Printer* printer); virtual void GenerateSerializationCode(io::Printer* printer); virtual void GenerateSerializedSizeCode(io::Printer* printer); diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc b/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc index 2ae1d579..2a6a01f5 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc @@ -48,7 +48,6 @@ namespace csharp { RepeatedMessageFieldGenerator::RepeatedMessageFieldGenerator( const FieldDescriptor* descriptor, int fieldOrdinal) : FieldGeneratorBase(descriptor, fieldOrdinal) { - variables_["message_or_group"] = message_or_group(); } RepeatedMessageFieldGenerator::~RepeatedMessageFieldGenerator() { @@ -58,11 +57,11 @@ RepeatedMessageFieldGenerator::~RepeatedMessageFieldGenerator() { void RepeatedMessageFieldGenerator::GenerateMembers(io::Printer* printer) { printer->Print( variables_, - "private pbc::PopsicleList<$type_name$> $name$_ = new pbc::PopsicleList<$type_name$>();\n"); + "private readonly pbc::RepeatedField<$type_name$> $name$_ = new pbc::RepeatedField<$type_name$>();\n"); AddDeprecatedFlag(printer); printer->Print( variables_, - "public scg::IList<$type_name$> $property_name$List {\n" + "public pbc::RepeatedField<$type_name$> $property_name$ {\n" " get { return $name$_; }\n" "}\n"); @@ -82,137 +81,46 @@ void RepeatedMessageFieldGenerator::GenerateMembers(io::Printer* printer) { "}\n"); } -void RepeatedMessageFieldGenerator::GenerateBuilderMembers(io::Printer* printer) { - // Note: We can return the original list here, because we make it unmodifiable when we build - // We return it via IPopsicleList so that collection initializers work more pleasantly. - AddDeprecatedFlag(printer); - printer->Print( - variables_, - "public pbc::IPopsicleList<$type_name$> $property_name$List {\n" - " get { return PrepareBuilder().$name$_; }\n" - "}\n"); - AddDeprecatedFlag(printer); - printer->Print( - variables_, - "public int $property_name$Count {\n" - " get { return result.$property_name$Count; }\n" - "}\n"); - AddDeprecatedFlag(printer); - printer->Print( - variables_, - "public $type_name$ Get$property_name$(int index) {\n" - " return result.Get$property_name$(index);\n" - "}\n"); - AddDeprecatedFlag(printer); - printer->Print( - variables_, - "public Builder Set$property_name$(int index, $type_name$ value) {\n"); - AddNullCheck(printer); - printer->Print( - variables_, - " PrepareBuilder();\n" - " result.$name$_[index] = value;\n" - " return this;\n" - "}\n"); - // Extra overload for builder (just on messages) - AddDeprecatedFlag(printer); - printer->Print( - variables_, - "public Builder Set$property_name$(int index, $type_name$.Builder builderForValue) {\n"); - AddNullCheck(printer, "builderForValue"); - printer->Print( - variables_, - " PrepareBuilder();\n" - " result.$name$_[index] = builderForValue.Build();\n" - " return this;\n" - "}\n"); - AddDeprecatedFlag(printer); - printer->Print( - variables_, - "public Builder Add$property_name$($type_name$ value) {\n"); - AddNullCheck(printer); - printer->Print( - variables_, - " PrepareBuilder();\n" - " result.$name$_.Add(value);\n" - " return this;\n" - "}\n"); - // Extra overload for builder (just on messages) - AddDeprecatedFlag(printer); - printer->Print( - variables_, - "public Builder Add$property_name$($type_name$.Builder builderForValue) {\n"); - AddNullCheck(printer, "builderForValue"); - printer->Print( - variables_, - " PrepareBuilder();\n" - " result.$name$_.Add(builderForValue.Build());\n" - " return this;\n" - "}\n"); - AddDeprecatedFlag(printer); - printer->Print( - variables_, - "public Builder AddRange$property_name$(scg::IEnumerable<$type_name$> values) {\n" - " PrepareBuilder();\n" - " result.$name$_.Add(values);\n" - " return this;\n" - "}\n"); - AddDeprecatedFlag(printer); - printer->Print( - variables_, - "public Builder Clear$property_name$() {\n" - " PrepareBuilder();\n" - " result.$name$_.Clear();\n" - " return this;\n" - "}\n"); -} - void RepeatedMessageFieldGenerator::GenerateMergingCode(io::Printer* printer) { printer->Print( variables_, - "if (other.$name$_.Count != 0) {\n" - " result.$name$_.Add(other.$name$_);\n" - "}\n"); -} - -void RepeatedMessageFieldGenerator::GenerateBuildingCode(io::Printer* printer) { - printer->Print(variables_, "$name$_.MakeReadOnly();\n"); + "$name$_.Add(other.$name$_);\n"); } void RepeatedMessageFieldGenerator::GenerateParsingCode(io::Printer* printer) { printer->Print( variables_, - "input.Read$message_or_group$Array(tag, field_name, result.$name$_, $type_name$.DefaultInstance, extensionRegistry);\n"); + "input.ReadMessageArray(tag, fieldName, $name$_);\n"); } void RepeatedMessageFieldGenerator::GenerateSerializationCode(io::Printer* printer) { + // TODO(jonskeet): Originally, this checked for Count > 0 first. + // The Write* call should make that cheap though - no need to generate it every time. printer->Print( variables_, - "if ($name$_.Count > 0) {\n" - " output.Write$message_or_group$Array($number$, field_names[$field_ordinal$], $name$_);\n" - "}\n"); + "output.WriteMessageArray($number$, fieldNames[$field_ordinal$], $name$_);\n"); } void RepeatedMessageFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) { + // TODO(jonskeet): Put this into CodedOutputStream. printer->Print( variables_, - "foreach ($type_name$ element in $property_name$List) {\n" - " size += pb::CodedOutputStream.Compute$message_or_group$Size($number$, element);\n" + "foreach ($type_name$ element in $property_name$) {\n" + " size += pb::CodedOutputStream.ComputeMessageSize($number$, element);\n" "}\n"); } void RepeatedMessageFieldGenerator::WriteHash(io::Printer* printer) { printer->Print( variables_, - "foreach($type_name$ i in $name$_)\n" - " hash ^= i.GetHashCode();\n"); + "foreach($type_name$ i in $name$_) {\n" + " hash ^= i.GetHashCode();\n" + "}\n"); } void RepeatedMessageFieldGenerator::WriteEquals(io::Printer* printer) { printer->Print( variables_, - "if($name$_.Count != other.$name$_.Count) return false;\n" - "for(int ix=0; ix < $name$_.Count; ix++)\n" - " if(!$name$_[ix].Equals(other.$name$_[ix])) return false;\n"); + "if(!$name$_.Equals(other.$name$)) return false;\n"); } void RepeatedMessageFieldGenerator::WriteToString(io::Printer* printer) { variables_["field_name"] = GetFieldName(descriptor_); diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.h b/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.h index 9db76939..b8582800 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.h +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.h @@ -41,17 +41,13 @@ namespace protobuf { namespace compiler { namespace csharp { -class Writer; - class RepeatedMessageFieldGenerator : public FieldGeneratorBase { public: RepeatedMessageFieldGenerator(const FieldDescriptor* descriptor, int fieldOrdinal); ~RepeatedMessageFieldGenerator(); virtual void GenerateMembers(io::Printer* printer); - virtual void GenerateBuilderMembers(io::Printer* printer); virtual void GenerateMergingCode(io::Printer* printer); - virtual void GenerateBuildingCode(io::Printer* printer); virtual void GenerateParsingCode(io::Printer* printer); virtual void GenerateSerializationCode(io::Printer* printer); virtual void GenerateSerializedSizeCode(io::Printer* printer); diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc b/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc index e27458bb..2001b849 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc @@ -56,129 +56,43 @@ RepeatedPrimitiveFieldGenerator::~RepeatedPrimitiveFieldGenerator() { } void RepeatedPrimitiveFieldGenerator::GenerateMembers(io::Printer* printer) { - if (descriptor_->is_packed() && optimize_speed()) { - printer->Print(variables_, "private int $name$MemoizedSerializedSize;\n"); - } printer->Print(variables_, - "private pbc::PopsicleList<$type_name$> $name$_ = new pbc::PopsicleList<$type_name$>();\n"); - AddPublicMemberAttributes(printer); - printer->Print( - variables_, - "public scg::IList<$type_name$> $property_name$List {\n" - " get { return pbc::Lists.AsReadOnly($name$_); }\n" - "}\n"); - - // TODO(jonskeet): Redundant API calls? Possibly - include for portability though. Maybe create an option. + "private readonly pbc::RepeatedField<$type_name$> $name$_ = new pbc::RepeatedField<$type_name$>();\n"); AddDeprecatedFlag(printer); printer->Print( variables_, - "public int $property_name$Count {\n" - " get { return $name$_.Count; }\n" - "}\n"); - - AddPublicMemberAttributes(printer); - printer->Print( - variables_, - "public $type_name$ Get$property_name$(int index) {\n" - " return $name$_[index];\n" - "}\n"); -} - -void RepeatedPrimitiveFieldGenerator::GenerateBuilderMembers(io::Printer* printer) { - // Note: We can return the original list here, because we make it unmodifiable when we build - // We return it via IPopsicleList so that collection initializers work more pleasantly. - AddPublicMemberAttributes(printer); - printer->Print( - variables_, - "public pbc::IPopsicleList<$type_name$> $property_name$List {\n" - " get { return PrepareBuilder().$name$_; }\n" - "}\n"); - AddDeprecatedFlag(printer); - printer->Print( - variables_, - "public int $property_name$Count {\n" - " get { return result.$property_name$Count; }\n" - "}\n"); - AddPublicMemberAttributes(printer); - printer->Print( - variables_, - "public $type_name$ Get$property_name$(int index) {\n" - " return result.Get$property_name$(index);\n" - "}\n"); - AddPublicMemberAttributes(printer); - printer->Print( - variables_, - "public Builder Set$property_name$(int index, $type_name$ value) {\n"); - AddNullCheck(printer); - printer->Print( - variables_, - " PrepareBuilder();\n" - " result.$name$_[index] = value;\n" - " return this;\n" - "}\n"); - AddPublicMemberAttributes(printer); - printer->Print( - variables_, - "public Builder Add$property_name$($type_name$ value) {\n"); - AddNullCheck(printer); - printer->Print( - variables_, - " PrepareBuilder();\n" - " result.$name$_.Add(value);\n" - " return this;\n" - "}\n"); - AddPublicMemberAttributes(printer); - printer->Print( - variables_, - "public Builder AddRange$property_name$(scg::IEnumerable<$type_name$> values) {\n" - " PrepareBuilder();\n" - " result.$name$_.Add(values);\n" - " return this;\n" - "}\n"); - AddDeprecatedFlag(printer); - printer->Print( - variables_, - "public Builder Clear$property_name$() {\n" - " PrepareBuilder();\n" - " result.$name$_.Clear();\n" - " return this;\n" + "public pbc::RepeatedField<$type_name$> $property_name$ {\n" + " get { return $name$_; }\n" "}\n"); } void RepeatedPrimitiveFieldGenerator::GenerateMergingCode(io::Printer* printer) { printer->Print( variables_, - "if (other.$name$_.Count != 0) {\n" - " result.$name$_.Add(other.$name$_);\n" - "}\n"); -} - -void RepeatedPrimitiveFieldGenerator::GenerateBuildingCode(io::Printer* printer) { - printer->Print(variables_, "$name$_.MakeReadOnly();\n"); + "$name$_.Add(other.$name$_);\n"); } void RepeatedPrimitiveFieldGenerator::GenerateParsingCode(io::Printer* printer) { printer->Print(variables_, - "input.Read$capitalized_type_name$Array(tag, field_name, result.$name$_);\n"); + "input.Read$capitalized_type_name$Array(tag, fieldName, $name$_);\n"); } void RepeatedPrimitiveFieldGenerator::GenerateSerializationCode( io::Printer* printer) { - printer->Print(variables_, "if ($name$_.Count > 0) {\n"); - printer->Indent(); + // TODO(jonskeet): Originally, this checked for Count > 0 first. + // The Write* call should make that cheap though - no need to generate it every time. if (descriptor_->is_packed()) { printer->Print(variables_, - "output.WritePacked$capitalized_type_name$Array($number$, field_names[$field_ordinal$], $name$MemoizedSerializedSize, $name$_);\n"); + "output.WritePacked$capitalized_type_name$Array($number$, fieldNames[$field_ordinal$], $name$_);\n"); } else { printer->Print(variables_, - "output.Write$capitalized_type_name$Array($number$, field_names[$field_ordinal$], $name$_);\n"); + "output.Write$capitalized_type_name$Array($number$, fieldNames[$field_ordinal$], $name$_);\n"); } - printer->Outdent(); - printer->Print("}\n"); } void RepeatedPrimitiveFieldGenerator::GenerateSerializedSizeCode( io::Printer* printer) { + // TODO(jonskeet): Get rid of most of this - move it into the runtime. printer->Print("{\n"); printer->Indent(); printer->Print("int dataSize = 0;\n"); @@ -207,10 +121,6 @@ void RepeatedPrimitiveFieldGenerator::GenerateSerializedSizeCode( "size += $tag_size$ * $name$_.Count;\n", "tag_size", SimpleItoa(tagSize), "name", name()); } - // cache the data size for packed fields. - if (descriptor_->is_packed()) { - printer->Print(variables_, "$name$MemoizedSerializedSize = dataSize;\n"); - } printer->Outdent(); printer->Print("}\n"); } @@ -218,15 +128,14 @@ void RepeatedPrimitiveFieldGenerator::GenerateSerializedSizeCode( void RepeatedPrimitiveFieldGenerator::WriteHash(io::Printer* printer) { printer->Print( variables_, - "foreach($type_name$ i in $name$_)\n" - " hash ^= i.GetHashCode();\n"); + "foreach($type_name$ i in $name$_)\n {" + " hash ^= i.GetHashCode();\n" + "}\n"); } void RepeatedPrimitiveFieldGenerator::WriteEquals(io::Printer* printer) { printer->Print( variables_, - "if($name$_.Count != other.$name$_.Count) return false;\n" - "for(int ix=0; ix < $name$_.Count; ix++)\n" - " if(!$name$_[ix].Equals(other.$name$_[ix])) return false;\n"); + "if(!$name$_.Equals(other.$name$)) return false;\n"); } void RepeatedPrimitiveFieldGenerator::WriteToString(io::Printer* printer) { printer->Print(variables_, diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h b/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h index 50af9dda..29d437d7 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h @@ -41,17 +41,13 @@ namespace protobuf { namespace compiler { namespace csharp { -class Writer; - class RepeatedPrimitiveFieldGenerator : public FieldGeneratorBase { public: RepeatedPrimitiveFieldGenerator(const FieldDescriptor* descriptor, int fieldOrdinal); ~RepeatedPrimitiveFieldGenerator(); virtual void GenerateMembers(io::Printer* printer); - virtual void GenerateBuilderMembers(io::Printer* printer); virtual void GenerateMergingCode(io::Printer* printer); - virtual void GenerateBuildingCode(io::Printer* printer); virtual void GenerateParsingCode(io::Printer* printer); virtual void GenerateSerializationCode(io::Printer* printer); virtual void GenerateSerializedSizeCode(io::Printer* printer); diff --git a/src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc b/src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc index c52f6092..c666c820 100644 --- a/src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc +++ b/src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc @@ -47,14 +47,6 @@ namespace csharp { SourceGeneratorBase::SourceGeneratorBase(const FileDescriptor* descriptor) : descriptor_(descriptor) { - optimizeSize_ = (descriptor->options().optimize_for() - == FileOptions::CODE_SIZE); - optimizeSpeed_ = (descriptor->options().optimize_for() == FileOptions::SPEED); - useLiteRuntime_ = (descriptor->options().optimize_for() - == FileOptions::LITE_RUNTIME); - - optimizeSpeed_ |= useLiteRuntime_; - runtimeSuffix_ = useLiteRuntime_ ? "Lite" : ""; } SourceGeneratorBase::~SourceGeneratorBase() { diff --git a/src/google/protobuf/compiler/csharp/csharp_source_generator_base.h b/src/google/protobuf/compiler/csharp/csharp_source_generator_base.h index 61c19511..6caef171 100644 --- a/src/google/protobuf/compiler/csharp/csharp_source_generator_base.h +++ b/src/google/protobuf/compiler/csharp/csharp_source_generator_base.h @@ -47,27 +47,10 @@ class SourceGeneratorBase { std::string class_access_level(); - bool optimize_size() { - return optimizeSize_; - } - bool optimize_speed() { - return optimizeSpeed_; - } - bool use_lite_runtime() { - return useLiteRuntime_; - } - std::string runtime_suffix() { - return runtimeSuffix_; - } - void WriteGeneratedCodeAttributes(io::Printer* printer); private: const FileDescriptor* descriptor_; - bool optimizeSize_; - bool optimizeSpeed_; - bool useLiteRuntime_; - std::string runtimeSuffix_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(SourceGeneratorBase); }; diff --git a/src/google/protobuf/compiler/csharp/csharp_umbrella_class.cc b/src/google/protobuf/compiler/csharp/csharp_umbrella_class.cc index b14bf5e8..03a3b8df 100644 --- a/src/google/protobuf/compiler/csharp/csharp_umbrella_class.cc +++ b/src/google/protobuf/compiler/csharp/csharp_umbrella_class.cc @@ -39,7 +39,6 @@ #include #include -#include #include #include @@ -61,18 +60,6 @@ UmbrellaClassGenerator::~UmbrellaClassGenerator() { void UmbrellaClassGenerator::Generate(io::Printer* printer) { WriteIntroduction(printer); - WriteExtensionRegistration(printer); - - // write children: Extensions - if (file_->extension_count() > 0) { - printer->Print("#region Extensions\n"); - for (int i = 0; i < file_->extension_count(); i++) { - ExtensionGenerator extensionGenerator(file_->extension(i)); - extensionGenerator.Generate(printer); - } - printer->Print("#endregion\n"); - printer->Print("\n"); - } printer->Print("#region Static variables\n"); for (int i = 0; i < file_->message_type_count(); i++) { @@ -80,11 +67,7 @@ void UmbrellaClassGenerator::Generate(io::Printer* printer) { messageGenerator.GenerateStaticVariables(printer); } printer->Print("#endregion\n"); - if (!use_lite_runtime()) { - WriteDescriptor(printer); - } else { - WriteLiteExtensions(printer); - } + WriteDescriptor(printer); // Close the class declaration. printer->Outdent(); printer->Print("}\n"); @@ -134,9 +117,9 @@ void UmbrellaClassGenerator::WriteIntroduction(io::Printer* printer) { "#pragma warning disable 1591, 0612, 3021\n" "#region Designer generated code\n" "\n" - "using pb = global::Google.ProtocolBuffers;\n" - "using pbc = global::Google.ProtocolBuffers.Collections;\n" - "using pbd = global::Google.ProtocolBuffers.Descriptors;\n" + "using pb = global::Google.Protobuf;\n" + "using pbc = global::Google.Protobuf.Collections;\n" + "using pbd = global::Google.Protobuf.Descriptors;\n" "using scg = global::System.Collections.Generic;\n", "file_name", file_->name()); @@ -165,24 +148,6 @@ void UmbrellaClassGenerator::WriteIntroduction(io::Printer* printer) { printer->Indent(); } -void UmbrellaClassGenerator::WriteExtensionRegistration(io::Printer* printer) { - printer->Print( - "#region Extension registration\n" - "public static void RegisterAllExtensions(pb::ExtensionRegistry registry) {\n"); - printer->Indent(); - for (int i = 0; i < file_->extension_count(); i++) { - ExtensionGenerator extensionGenerator(file_->extension(i)); - extensionGenerator.GenerateExtensionRegistrationCode(printer); - } - for (int i = 0; i < file_->message_type_count(); i++) { - MessageGenerator messageGenerator(file_->message_type(i)); - messageGenerator.GenerateExtensionRegistrationCode(printer); - } - printer->Outdent(); - printer->Print("}\n"); - printer->Print("#endregion\n"); -} - void UmbrellaClassGenerator::WriteDescriptor(io::Printer* printer) { printer->Print( "#region Descriptor\n" @@ -219,25 +184,7 @@ void UmbrellaClassGenerator::WriteDescriptor(io::Printer* printer) { MessageGenerator messageGenerator(file_->message_type(i)); messageGenerator.GenerateStaticVariableInitializers(printer); } - for (int i = 0; i < file_->extension_count(); i++) { - ExtensionGenerator extensionGenerator(file_->extension(i)); - extensionGenerator.GenerateStaticVariableInitializers(printer); - } - if (uses_extensions()) { - // Must construct an ExtensionRegistry containing all possible extensions - // and return it. - printer->Print( - "pb::ExtensionRegistry registry = pb::ExtensionRegistry.CreateInstance();\n"); - printer->Print("RegisterAllExtensions(registry);\n"); - for (int i = 0; i < file_->dependency_count(); i++) { - printer->Print("$dependency$.RegisterAllExtensions(registry);\n", - "dependency", GetFullUmbrellaClassName(file_->dependency(i))); - } - printer->Print("return registry;\n"); - } else { - printer->Print("return null;\n"); - } printer->Outdent(); printer->Print("};\n"); @@ -258,33 +205,6 @@ void UmbrellaClassGenerator::WriteDescriptor(io::Printer* printer) { printer->Print("#endregion\n\n"); } -void UmbrellaClassGenerator::WriteLiteExtensions(io::Printer* printer) { - printer->Print( - "#region Extensions\n" - "internal static readonly object Descriptor;\n" - "static $umbrella_class_name$() {\n", - "umbrella_class_name", umbrellaClassname_); - printer->Indent(); - printer->Print("Descriptor = null;\n"); - for (int i = 0; i < file_->message_type_count(); i++) { - MessageGenerator messageGenerator(file_->message_type(i)); - messageGenerator.GenerateStaticVariableInitializers(printer); - } - for (int i = 0; i < file_->extension_count(); i++) { - ExtensionGenerator extensionGenerator(file_->extension(i)); - extensionGenerator.GenerateStaticVariableInitializers(printer); - } - printer->Outdent(); - printer->Print("}\n"); - printer->Print("#endregion\n\n"); -} - -bool UmbrellaClassGenerator::uses_extensions() { - // TODO(jtattermusch): implement recursive descent that looks for extensions. - // For now, we conservatively assume that extensions are used. - return true; -} - } // namespace csharp } // namespace compiler } // namespace protobuf diff --git a/src/google/protobuf/compiler/csharp/csharp_umbrella_class.h b/src/google/protobuf/compiler/csharp/csharp_umbrella_class.h index 83e1f347..f7533d2d 100644 --- a/src/google/protobuf/compiler/csharp/csharp_umbrella_class.h +++ b/src/google/protobuf/compiler/csharp/csharp_umbrella_class.h @@ -41,8 +41,6 @@ namespace protobuf { namespace compiler { namespace csharp { -class Writer; - class UmbrellaClassGenerator : public SourceGeneratorBase { public: UmbrellaClassGenerator(const FileDescriptor* file); @@ -58,11 +56,7 @@ class UmbrellaClassGenerator : public SourceGeneratorBase { std::string umbrellaNamespace_; void WriteIntroduction(io::Printer* printer); - void WriteExtensionRegistration(io::Printer* printer); void WriteDescriptor(io::Printer* printer); - void WriteLiteExtensions(io::Printer* printer); - - bool uses_extensions(); GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(UmbrellaClassGenerator); }; @@ -73,4 +67,3 @@ class UmbrellaClassGenerator : public SourceGeneratorBase { } // namespace google #endif // GOOGLE_PROTOBUF_COMPILER_CSHARP_UMBRELLA_CLASS_H__ - diff --git a/src/google/protobuf/compiler/csharp/csharp_writer.cc b/src/google/protobuf/compiler/csharp/csharp_writer.cc deleted file mode 100644 index 2bcafde5..00000000 --- a/src/google/protobuf/compiler/csharp/csharp_writer.cc +++ /dev/null @@ -1,136 +0,0 @@ -// 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. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { -namespace csharp { - -Writer::Writer(google::protobuf::io::Printer* printer) - : printer_(printer), - newline_("\n") { - // TODO(jtattermusch): make newline customizable. -} - -Writer::~Writer() { -} - -void Writer::Indent() { - printer_->Indent(); -} - -void Writer::Outdent() { - printer_->Outdent(); -} - -void Writer::Write(const char* text) { - printer_->Print(text); -} - -void Writer::Write(const char* text, const string& value0) { - printer_->Print(text, "0", value0); -} - -void Writer::Write(const char* text, const string& value0, - const string& value1) { - printer_->Print(text, "0", value0, "1", value1); -} - -void Writer::Write(const char* text, const string& value0, const string& value1, - const string& value2) { - printer_->Print(text, "0", value0, "1", value1, "2", value2); -} - -void Writer::Write(const char* text, const string& value0, const string& value1, - const string& value2, const string& value3) { - printer_->Print(text, "0", value0, "1", value1, "2", value2, "3", value3); -} - -void Writer::WriteLine() { - printer_->Print(newline_); -} - -void Writer::WriteLine(const char* text) { - Write(text); - WriteLine(); -} - -void Writer::WriteLine(const char* text, const string& value0) { - Write(text, value0); - WriteLine(); -} - -void Writer::WriteLine(const char* text, const string& value0, - const string& value1) { - Write(text, value0, value1); - WriteLine(); -} - -void Writer::WriteLine(const char* text, const string& value0, - const string& value1, const string& value2) { - Write(text, value0, value1, value2); - WriteLine(); -} - -void Writer::WriteLine(const char* text, const string& value0, - const string& value1, const string& value2, - const string& value3) { - Write(text, value0, value1, value2, value3); - WriteLine(); -} - -} // namespace java -} // namespace compiler -} // namespace protobuf -} // namespace google diff --git a/src/google/protobuf/compiler/csharp/csharp_writer.h b/src/google/protobuf/compiler/csharp/csharp_writer.h deleted file mode 100644 index 26c59b31..00000000 --- a/src/google/protobuf/compiler/csharp/csharp_writer.h +++ /dev/null @@ -1,93 +0,0 @@ -// 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. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_WRITER_H__ -#define GOOGLE_PROTOBUF_COMPILER_CSHARP_WRITER_H__ - -#include -#include -#include -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { -namespace csharp { - -// Simple wrapper around Printer that supports customizable line endings -// and number-based variables (e.g. $0$). -class Writer { - public: - Writer(io::Printer* printer); - ~Writer(); - - void Indent(); - void Outdent(); - - void Write(const char* text); - - void Write(const char* text, const string& value0); - - void Write(const char* text, const string& value0, const string& value1); - - void Write(const char* text, const string& value0, const string& value1, - const string& value2); - - void Write(const char* text, const string& value0, const string& value1, - const string& value2, const string& value3); - - void WriteLine(); - - void WriteLine(const char* text); - - void WriteLine(const char* text, const string& value0); - - void WriteLine(const char* text, const string& value0, const string& value1); - - void WriteLine(const char* text, const string& value0, const string& value1, - const string& value2); - - void WriteLine(const char* text, const string& value0, const string& value1, - const string& value2, const string& value3); - private: - io::Printer* printer_; - const char* newline_; -}; - -} // namespace csharp -} // namespace compiler -} // namespace protobuf -} // namespace google -#endif // GOOGLE_PROTOBUF_COMPILER_CSHARP_WRITER_H__ diff --git a/vsprojects/libprotoc.vcproj b/vsprojects/libprotoc.vcproj index 515a6096..c530ef0a 100644 --- a/vsprojects/libprotoc.vcproj +++ b/vsprojects/libprotoc.vcproj @@ -169,7 +169,6 @@ - @@ -181,7 +180,6 @@ - @@ -269,7 +267,6 @@ - @@ -281,7 +278,6 @@ - -- cgit v1.2.3 From e38294a62d7f37c0661273a9a26fda16d557423f Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Tue, 9 Jun 2015 19:30:44 +0100 Subject: First pass at the mutable API. Quite a bit more to do - in particular, it's pretty slow right now. --- csharp/protos/extest/unittest_issues.proto | 86 +- .../ProtocolBuffers.Test/AbstractMessageTest.cs | 548 - csharp/src/ProtocolBuffers.Test/ByteStringTest.cs | 2 +- .../ProtocolBuffers.Test/CodedInputStreamTest.cs | 64 +- .../ProtocolBuffers.Test/CodedOutputStreamTest.cs | 23 +- .../Collections/PopsicleListTest.cs | 125 - .../Compatibility/BinaryCompatibilityTests.cs | 18 - .../Compatibility/CompatibilityTests.cs | 227 - .../Compatibility/DictionaryCompatibilityTests.cs | 35 - .../Compatibility/JsonCompatibilityTests.cs | 43 - .../Compatibility/TestResources.cs | 38 - .../Compatibility/TextCompatibilityTests.cs | 35 - .../Compatibility/XmlCompatibilityTests.cs | 45 - .../Compatibility/google_message1.dat | Bin 228 -> 0 bytes .../Compatibility/google_message2.dat | Bin 84570 -> 0 bytes .../ProtocolBuffers.Test/DeprecatedMemberTest.cs | 82 +- csharp/src/ProtocolBuffers.Test/DescriptorsTest.cs | 152 +- .../src/ProtocolBuffers.Test/DynamicMessageTest.cs | 276 - .../ProtocolBuffers.Test/ExtendableMessageTest.cs | 200 - .../src/ProtocolBuffers.Test/FieldPresenceTest.cs | 198 - .../ProtocolBuffers.Test/GeneratedBuilderTest.cs | 102 - .../ProtocolBuffers.Test/GeneratedMessageTest.cs | 911 +- csharp/src/ProtocolBuffers.Test/IssuesTest.cs | 10 +- .../MessageStreamIteratorTest.cs | 90 - .../MessageStreamWriterTest.cs | 78 - csharp/src/ProtocolBuffers.Test/MessageTest.cs | 344 - csharp/src/ProtocolBuffers.Test/MessageUtilTest.cs | 82 - csharp/src/ProtocolBuffers.Test/NameHelpersTest.cs | 81 - .../ProtocolBuffers.Test.csproj | 62 +- .../src/ProtocolBuffers.Test/ReflectionTester.cs | 1033 - .../src/ProtocolBuffers.Test/RepeatedFieldTest.cs | 50 + .../ProtocolBuffers.Test/ReusableBuilderTest.cs | 166 - csharp/src/ProtocolBuffers.Test/TestCornerCases.cs | 22 +- .../ProtocolBuffers.Test/TestMimeMessageFormats.cs | 277 - .../ProtocolBuffers.Test/TestProtos/GoogleSize.cs | 4547 --- .../ProtocolBuffers.Test/TestProtos/GoogleSpeed.cs | 6612 ---- .../ProtocolBuffers.Test/TestProtos/Unittest.cs | 33878 ----------------- .../TestProtos/UnittestCustomOptions.cs | 7543 ---- .../TestProtos/UnittestDropUnknownFields.cs | 732 - .../TestProtos/UnittestEnormousDescriptor.cs | 36189 ------------------- .../TestProtos/UnittestExtrasXmltest.cs | 2277 -- .../TestProtos/UnittestImport.cs | 347 - .../TestProtos/UnittestImportProto3.cs | 165 + .../TestProtos/UnittestImportPublic.cs | 333 - .../TestProtos/UnittestImportPublicProto3.cs | 150 + .../TestProtos/UnittestIssues.cs | 2571 +- .../TestProtos/UnittestMset.cs | 1824 - .../TestProtos/UnittestNoFieldPresence.cs | 3876 -- .../TestProtos/UnittestOptimizeFor.cs | 738 - .../TestProtos/UnittestProto3.cs | 6060 ++++ .../TestProtos/UnknownEnumTest.cs | 809 - .../TestReaderForUrlEncoded.cs | 83 - csharp/src/ProtocolBuffers.Test/TestResources.cs | 301 - csharp/src/ProtocolBuffers.Test/TestUtil.cs | 1862 - .../ProtocolBuffers.Test/TestWriterFormatJson.cs | 498 - .../ProtocolBuffers.Test/TestWriterFormatXml.cs | 468 - csharp/src/ProtocolBuffers.Test/TextFormatTest.cs | 560 - .../ProtocolBuffers.Test/UnknownFieldSetTest.cs | 431 - csharp/src/ProtocolBuffers.Test/WireFormatTest.cs | 255 +- csharp/src/ProtocolBuffers/AbstractBuilder.cs | 274 - csharp/src/ProtocolBuffers/AbstractBuilderLite.cs | 264 - csharp/src/ProtocolBuffers/AbstractMessage.cs | 293 - csharp/src/ProtocolBuffers/AbstractMessageLite.cs | 140 - csharp/src/ProtocolBuffers/ByteArray.cs | 2 +- csharp/src/ProtocolBuffers/ByteString.cs | 20 +- csharp/src/ProtocolBuffers/CodedInputStream.cs | 163 +- .../CodedOutputStream.ComputeSize.cs | 71 +- csharp/src/ProtocolBuffers/CodedOutputStream.cs | 338 +- .../ProtocolBuffers/Collections/Dictionaries.cs | 2 +- .../src/ProtocolBuffers/Collections/Enumerables.cs | 2 +- .../ProtocolBuffers/Collections/IPopsicleList.cs | 58 - csharp/src/ProtocolBuffers/Collections/Lists.cs | 2 +- .../ProtocolBuffers/Collections/PopsicleList.cs | 208 - .../Collections/ReadOnlyDictionary.cs | 2 +- .../ProtocolBuffers/Collections/RepeatedField.cs | 168 + .../Collections/RepeatedFieldExtensions.cs | 47 + csharp/src/ProtocolBuffers/Delegates.cs | 54 - .../DescriptorProtos/DescriptorProtoFile.cs | 12724 ++----- .../DescriptorProtos/IDescriptorProto.cs | 2 +- .../DescriptorProtos/PartialClasses.cs | 2 +- .../ProtocolBuffers/Descriptors/DescriptorBase.cs | 5 +- .../ProtocolBuffers/Descriptors/DescriptorPool.cs | 4 +- .../ProtocolBuffers/Descriptors/DescriptorUtil.cs | 4 +- .../Descriptors/DescriptorValidationException.cs | 13 +- .../ProtocolBuffers/Descriptors/EnumDescriptor.cs | 31 +- .../Descriptors/EnumValueDescriptor.cs | 7 +- .../ProtocolBuffers/Descriptors/FieldDescriptor.cs | 223 +- .../Descriptors/FieldMappingAttribute.cs | 4 +- .../src/ProtocolBuffers/Descriptors/FieldType.cs | 2 +- .../ProtocolBuffers/Descriptors/FileDescriptor.cs | 55 +- .../src/ProtocolBuffers/Descriptors/IDescriptor.cs | 4 +- .../Descriptors/IndexedDescriptorBase.cs | 4 +- .../src/ProtocolBuffers/Descriptors/MappedType.cs | 2 +- .../Descriptors/MessageDescriptor.cs | 30 +- .../Descriptors/MethodDescriptor.cs | 4 +- .../ProtocolBuffers/Descriptors/OneofDescriptor.cs | 4 +- .../Descriptors/PackageDescriptor.cs | 2 +- .../Descriptors/ServiceDescriptor.cs | 8 +- csharp/src/ProtocolBuffers/DynamicMessage.cs | 624 - csharp/src/ProtocolBuffers/EnumHelper.cs | 85 + csharp/src/ProtocolBuffers/EnumLite.cs | 234 - csharp/src/ProtocolBuffers/ExtendableBuilder.cs | 212 - .../src/ProtocolBuffers/ExtendableBuilderLite.cs | 345 - csharp/src/ProtocolBuffers/ExtendableMessage.cs | 274 - .../src/ProtocolBuffers/ExtendableMessageLite.cs | 221 - csharp/src/ProtocolBuffers/ExtensionInfo.cs | 88 - csharp/src/ProtocolBuffers/ExtensionRegistry.cs | 215 - .../src/ProtocolBuffers/ExtensionRegistryLite.cs | 232 - csharp/src/ProtocolBuffers/Extensions.cs | 70 + .../FieldAccess/FieldAccessorBase.cs | 38 + .../FieldAccess/FieldAccessorTable.cs | 104 +- .../ProtocolBuffers/FieldAccess/IFieldAccessor.cs | 59 +- .../ProtocolBuffers/FieldAccess/OneofAccessor.cs | 13 +- .../ProtocolBuffers/FieldAccess/ReflectionUtil.cs | 57 +- .../FieldAccess/RepeatedEnumAccessor.cs | 83 - .../FieldAccess/RepeatedFieldAccessor.cs | 37 + .../FieldAccess/RepeatedMessageAccessor.cs | 97 - .../FieldAccess/RepeatedPrimitiveAccessor.cs | 158 - .../FieldAccess/SingleEnumAccessor.cs | 75 - .../FieldAccess/SingleFieldAccessor.cs | 89 + .../FieldAccess/SingleMessageAccessor.cs | 91 - .../FieldAccess/SinglePrimitiveAccessor.cs | 162 - csharp/src/ProtocolBuffers/FieldSet.cs | 632 - csharp/src/ProtocolBuffers/FrameworkPortability.cs | 2 +- csharp/src/ProtocolBuffers/GeneratedBuilder.cs | 230 - csharp/src/ProtocolBuffers/GeneratedBuilderLite.cs | 100 - .../src/ProtocolBuffers/GeneratedExtensionBase.cs | 185 - .../src/ProtocolBuffers/GeneratedExtensionLite.cs | 354 - csharp/src/ProtocolBuffers/GeneratedMessage.cs | 191 - csharp/src/ProtocolBuffers/GeneratedMessageLite.cs | 182 - .../ProtocolBuffers/GeneratedRepeatExtension.cs | 88 - .../ProtocolBuffers/GeneratedSingleExtension.cs | 65 - csharp/src/ProtocolBuffers/IBuilder.cs | 323 - csharp/src/ProtocolBuffers/IBuilderLite.cs | 213 - csharp/src/ProtocolBuffers/ICodedInputStream.cs | 50 +- csharp/src/ProtocolBuffers/ICodedOutputStream.cs | 103 +- csharp/src/ProtocolBuffers/IMessage.cs | 216 +- csharp/src/ProtocolBuffers/IMessageLite.cs | 188 - .../InvalidProtocolBufferException.cs | 2 +- csharp/src/ProtocolBuffers/LimitedInputStream.cs | 78 + csharp/src/ProtocolBuffers/MessageParser.cs | 57 + .../src/ProtocolBuffers/MessageStreamIterator.cs | 170 - csharp/src/ProtocolBuffers/MessageStreamWriter.cs | 70 - csharp/src/ProtocolBuffers/MessageUtil.cs | 109 - csharp/src/ProtocolBuffers/NameHelpers.cs | 140 - csharp/src/ProtocolBuffers/ProtocolBuffers.csproj | 61 +- csharp/src/ProtocolBuffers/SortedList.cs | 167 - csharp/src/ProtocolBuffers/TextFormat.cs | 893 - csharp/src/ProtocolBuffers/TextGenerator.cs | 2 +- csharp/src/ProtocolBuffers/TextTokenizer.cs | 501 - csharp/src/ProtocolBuffers/ThrowHelper.cs | 2 +- .../UninitializedMessageException.cs | 208 - csharp/src/ProtocolBuffers/UnknownField.cs | 415 - csharp/src/ProtocolBuffers/UnknownFieldSet.cs | 1061 - csharp/src/ProtocolBuffers/WireFormat.cs | 4 +- .../protobuf/compiler/csharp/csharp_enum_field.cc | 8 +- .../protobuf/compiler/csharp/csharp_field_base.cc | 19 +- .../protobuf/compiler/csharp/csharp_message.cc | 99 +- .../protobuf/compiler/csharp/csharp_message.h | 1 + .../compiler/csharp/csharp_message_field.cc | 30 +- .../compiler/csharp/csharp_primitive_field.cc | 16 +- .../compiler/csharp/csharp_repeated_enum_field.cc | 25 +- .../csharp/csharp_repeated_message_field.cc | 27 +- .../csharp/csharp_repeated_primitive_field.cc | 10 +- src/google/protobuf/descriptor.proto | 2 +- src/google/protobuf/unittest_import_proto3.proto | 68 + .../protobuf/unittest_import_public_proto3.proto | 42 + src/google/protobuf/unittest_proto3.proto | 388 + 168 files changed, 11868 insertions(+), 133448 deletions(-) delete mode 100644 csharp/src/ProtocolBuffers.Test/AbstractMessageTest.cs delete mode 100644 csharp/src/ProtocolBuffers.Test/Collections/PopsicleListTest.cs delete mode 100644 csharp/src/ProtocolBuffers.Test/Compatibility/BinaryCompatibilityTests.cs delete mode 100644 csharp/src/ProtocolBuffers.Test/Compatibility/CompatibilityTests.cs delete mode 100644 csharp/src/ProtocolBuffers.Test/Compatibility/DictionaryCompatibilityTests.cs delete mode 100644 csharp/src/ProtocolBuffers.Test/Compatibility/JsonCompatibilityTests.cs delete mode 100644 csharp/src/ProtocolBuffers.Test/Compatibility/TestResources.cs delete mode 100644 csharp/src/ProtocolBuffers.Test/Compatibility/TextCompatibilityTests.cs delete mode 100644 csharp/src/ProtocolBuffers.Test/Compatibility/XmlCompatibilityTests.cs delete mode 100644 csharp/src/ProtocolBuffers.Test/Compatibility/google_message1.dat delete mode 100644 csharp/src/ProtocolBuffers.Test/Compatibility/google_message2.dat delete mode 100644 csharp/src/ProtocolBuffers.Test/DynamicMessageTest.cs delete mode 100644 csharp/src/ProtocolBuffers.Test/ExtendableMessageTest.cs delete mode 100644 csharp/src/ProtocolBuffers.Test/FieldPresenceTest.cs delete mode 100644 csharp/src/ProtocolBuffers.Test/GeneratedBuilderTest.cs delete mode 100644 csharp/src/ProtocolBuffers.Test/MessageStreamIteratorTest.cs delete mode 100644 csharp/src/ProtocolBuffers.Test/MessageStreamWriterTest.cs delete mode 100644 csharp/src/ProtocolBuffers.Test/MessageTest.cs delete mode 100644 csharp/src/ProtocolBuffers.Test/MessageUtilTest.cs delete mode 100644 csharp/src/ProtocolBuffers.Test/NameHelpersTest.cs delete mode 100644 csharp/src/ProtocolBuffers.Test/ReflectionTester.cs create mode 100644 csharp/src/ProtocolBuffers.Test/RepeatedFieldTest.cs delete mode 100644 csharp/src/ProtocolBuffers.Test/ReusableBuilderTest.cs delete mode 100644 csharp/src/ProtocolBuffers.Test/TestMimeMessageFormats.cs delete mode 100644 csharp/src/ProtocolBuffers.Test/TestProtos/GoogleSize.cs delete mode 100644 csharp/src/ProtocolBuffers.Test/TestProtos/GoogleSpeed.cs delete mode 100644 csharp/src/ProtocolBuffers.Test/TestProtos/Unittest.cs delete mode 100644 csharp/src/ProtocolBuffers.Test/TestProtos/UnittestCustomOptions.cs delete mode 100644 csharp/src/ProtocolBuffers.Test/TestProtos/UnittestDropUnknownFields.cs delete mode 100644 csharp/src/ProtocolBuffers.Test/TestProtos/UnittestEnormousDescriptor.cs delete mode 100644 csharp/src/ProtocolBuffers.Test/TestProtos/UnittestExtrasXmltest.cs delete mode 100644 csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImport.cs create mode 100644 csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportProto3.cs delete mode 100644 csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportPublic.cs create mode 100644 csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportPublicProto3.cs delete mode 100644 csharp/src/ProtocolBuffers.Test/TestProtos/UnittestMset.cs delete mode 100644 csharp/src/ProtocolBuffers.Test/TestProtos/UnittestNoFieldPresence.cs delete mode 100644 csharp/src/ProtocolBuffers.Test/TestProtos/UnittestOptimizeFor.cs create mode 100644 csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs delete mode 100644 csharp/src/ProtocolBuffers.Test/TestProtos/UnknownEnumTest.cs delete mode 100644 csharp/src/ProtocolBuffers.Test/TestReaderForUrlEncoded.cs delete mode 100644 csharp/src/ProtocolBuffers.Test/TestResources.cs delete mode 100644 csharp/src/ProtocolBuffers.Test/TestUtil.cs delete mode 100644 csharp/src/ProtocolBuffers.Test/TestWriterFormatJson.cs delete mode 100644 csharp/src/ProtocolBuffers.Test/TestWriterFormatXml.cs delete mode 100644 csharp/src/ProtocolBuffers.Test/TextFormatTest.cs delete mode 100644 csharp/src/ProtocolBuffers.Test/UnknownFieldSetTest.cs delete mode 100644 csharp/src/ProtocolBuffers/AbstractBuilder.cs delete mode 100644 csharp/src/ProtocolBuffers/AbstractBuilderLite.cs delete mode 100644 csharp/src/ProtocolBuffers/AbstractMessage.cs delete mode 100644 csharp/src/ProtocolBuffers/AbstractMessageLite.cs delete mode 100644 csharp/src/ProtocolBuffers/Collections/IPopsicleList.cs delete mode 100644 csharp/src/ProtocolBuffers/Collections/PopsicleList.cs create mode 100644 csharp/src/ProtocolBuffers/Collections/RepeatedField.cs create mode 100644 csharp/src/ProtocolBuffers/Collections/RepeatedFieldExtensions.cs delete mode 100644 csharp/src/ProtocolBuffers/Delegates.cs delete mode 100644 csharp/src/ProtocolBuffers/DynamicMessage.cs create mode 100644 csharp/src/ProtocolBuffers/EnumHelper.cs delete mode 100644 csharp/src/ProtocolBuffers/EnumLite.cs delete mode 100644 csharp/src/ProtocolBuffers/ExtendableBuilder.cs delete mode 100644 csharp/src/ProtocolBuffers/ExtendableBuilderLite.cs delete mode 100644 csharp/src/ProtocolBuffers/ExtendableMessage.cs delete mode 100644 csharp/src/ProtocolBuffers/ExtendableMessageLite.cs delete mode 100644 csharp/src/ProtocolBuffers/ExtensionInfo.cs delete mode 100644 csharp/src/ProtocolBuffers/ExtensionRegistry.cs delete mode 100644 csharp/src/ProtocolBuffers/ExtensionRegistryLite.cs create mode 100644 csharp/src/ProtocolBuffers/Extensions.cs create mode 100644 csharp/src/ProtocolBuffers/FieldAccess/FieldAccessorBase.cs delete mode 100644 csharp/src/ProtocolBuffers/FieldAccess/RepeatedEnumAccessor.cs create mode 100644 csharp/src/ProtocolBuffers/FieldAccess/RepeatedFieldAccessor.cs delete mode 100644 csharp/src/ProtocolBuffers/FieldAccess/RepeatedMessageAccessor.cs delete mode 100644 csharp/src/ProtocolBuffers/FieldAccess/RepeatedPrimitiveAccessor.cs delete mode 100644 csharp/src/ProtocolBuffers/FieldAccess/SingleEnumAccessor.cs create mode 100644 csharp/src/ProtocolBuffers/FieldAccess/SingleFieldAccessor.cs delete mode 100644 csharp/src/ProtocolBuffers/FieldAccess/SingleMessageAccessor.cs delete mode 100644 csharp/src/ProtocolBuffers/FieldAccess/SinglePrimitiveAccessor.cs delete mode 100644 csharp/src/ProtocolBuffers/FieldSet.cs delete mode 100644 csharp/src/ProtocolBuffers/GeneratedBuilder.cs delete mode 100644 csharp/src/ProtocolBuffers/GeneratedBuilderLite.cs delete mode 100644 csharp/src/ProtocolBuffers/GeneratedExtensionBase.cs delete mode 100644 csharp/src/ProtocolBuffers/GeneratedExtensionLite.cs delete mode 100644 csharp/src/ProtocolBuffers/GeneratedMessage.cs delete mode 100644 csharp/src/ProtocolBuffers/GeneratedMessageLite.cs delete mode 100644 csharp/src/ProtocolBuffers/GeneratedRepeatExtension.cs delete mode 100644 csharp/src/ProtocolBuffers/GeneratedSingleExtension.cs delete mode 100644 csharp/src/ProtocolBuffers/IBuilder.cs delete mode 100644 csharp/src/ProtocolBuffers/IBuilderLite.cs delete mode 100644 csharp/src/ProtocolBuffers/IMessageLite.cs create mode 100644 csharp/src/ProtocolBuffers/LimitedInputStream.cs create mode 100644 csharp/src/ProtocolBuffers/MessageParser.cs delete mode 100644 csharp/src/ProtocolBuffers/MessageStreamIterator.cs delete mode 100644 csharp/src/ProtocolBuffers/MessageStreamWriter.cs delete mode 100644 csharp/src/ProtocolBuffers/MessageUtil.cs delete mode 100644 csharp/src/ProtocolBuffers/NameHelpers.cs delete mode 100644 csharp/src/ProtocolBuffers/SortedList.cs delete mode 100644 csharp/src/ProtocolBuffers/TextFormat.cs delete mode 100644 csharp/src/ProtocolBuffers/TextTokenizer.cs delete mode 100644 csharp/src/ProtocolBuffers/UninitializedMessageException.cs delete mode 100644 csharp/src/ProtocolBuffers/UnknownField.cs delete mode 100644 csharp/src/ProtocolBuffers/UnknownFieldSet.cs create mode 100644 src/google/protobuf/unittest_import_proto3.proto create mode 100644 src/google/protobuf/unittest_import_public_proto3.proto create mode 100644 src/google/protobuf/unittest_proto3.proto diff --git a/csharp/protos/extest/unittest_issues.proto b/csharp/protos/extest/unittest_issues.proto index 97249dff..c123acf1 100644 --- a/csharp/protos/extest/unittest_issues.proto +++ b/csharp/protos/extest/unittest_issues.proto @@ -1,4 +1,4 @@ -syntax = "proto2"; +syntax = "proto3"; // These proto descriptors have at one time been reported as an issue or defect. // They are kept here to replicate the issue, and continue to verify the fix. @@ -9,65 +9,6 @@ option csharp_namespace = "UnitTest.Issues.TestProtos"; package unittest_issues; option optimize_for = SPEED; -// The following is a representative set of features -/* -enum EnumOptions { - ONE = 0; - TWO = 1; - THREE = 2; -} - -message TestBasicChild -{ - repeated EnumOptions options = 3; - optional bytes binary = 4; -} - -message TestBasicNoFields { -} - -message TestBasicRescursive { - optional TestBasicRescursive child = 1; -} - -message TestBasicMessage { - - optional int64 number = 6; - repeated int32 numbers = 2; - optional string text = 3; - repeated string textlines = 700; - optional bool valid = 5; - - optional TestBasicChild child = 1; - repeated group Children = 401 - { - repeated EnumOptions options = 3; - optional bytes binary = 4; - } - - extensions 100 to 199; -} - -message TestBasicExtension { - required int32 number = 1; -} - -extend TestBasicMessage { - optional EnumOptions extension_enum = 101; - optional string extension_text = 102; - repeated int32 extension_number = 103 [packed = true]; - optional TestBasicExtension extension_message = 199; -} - -// Issue for non-qualified type reference in new services generation -option (google.protobuf.csharp_file_options).service_generator_type = IRPCDISPATCH; - -service TestGenericService { - rpc Foo(TestBasicNoFields) returns (TestBasicMessage); - rpc Bar(TestBasicNoFields) returns (TestBasicMessage); -} -*/ - // Old issue 13: http://code.google.com/p/protobuf-csharp-port/issues/detail?id=13 // New issue 309: https://github.com/google/protobuf/issues/309 @@ -90,27 +31,17 @@ service TestGenericService { // optional int32 _01 = 1; // } -// Issue 28: Circular message dependencies result in null defaults for DefaultInstance - -message MyMessageAReferenceB { - required MyMessageBReferenceA value = 1; -} - -message MyMessageBReferenceA { - required MyMessageAReferenceB value = 1; -} - // issue 19 - negative enum values enum NegativeEnum { + NEGATIVE_ENUM_ZERO = 0; FiveBelow = -5; MinusOne = -1; - Zero = 0; } message NegativeEnumMessage { - optional NegativeEnum value = 1; - repeated NegativeEnum values = 2; + NegativeEnum value = 1; + repeated NegativeEnum values = 2 [packed = false]; repeated NegativeEnum packed_values = 3 [packed=true]; } @@ -121,21 +52,22 @@ message DeprecatedChild { } enum DeprecatedEnum { + DEPRECATED_ZERO = 0; one = 1; } message DeprecatedFieldsMessage { - optional int32 PrimitiveValue = 1 [deprecated = true]; + int32 PrimitiveValue = 1 [deprecated = true]; repeated int32 PrimitiveArray = 2 [deprecated = true]; - optional DeprecatedChild MessageValue = 3 [deprecated = true]; + DeprecatedChild MessageValue = 3 [deprecated = true]; repeated DeprecatedChild MessageArray = 4 [deprecated = true]; - optional DeprecatedEnum EnumValue = 5 [deprecated = true]; + DeprecatedEnum EnumValue = 5 [deprecated = true]; repeated DeprecatedEnum EnumArray = 6 [deprecated = true]; } // Issue 45: http://code.google.com/p/protobuf-csharp-port/issues/detail?id=45 message ItemField { - optional int32 item = 1; + int32 item = 1; } diff --git a/csharp/src/ProtocolBuffers.Test/AbstractMessageTest.cs b/csharp/src/ProtocolBuffers.Test/AbstractMessageTest.cs deleted file mode 100644 index 8118808b..00000000 --- a/csharp/src/ProtocolBuffers.Test/AbstractMessageTest.cs +++ /dev/null @@ -1,548 +0,0 @@ -#region Copyright notice and license - -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/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.Collections.Generic; -using System.IO; -using Google.ProtocolBuffers.Descriptors; -using Google.ProtocolBuffers.TestProtos; -using NUnit.Framework; - -namespace Google.ProtocolBuffers -{ - public class AbstractMessageTest - { - [Test] - public void Clear() - { - AbstractMessageWrapper message = - new AbstractMessageWrapper.Builder(TestAllTypes.CreateBuilder(TestUtil.GetAllSet())).Clear().Build(); - TestUtil.AssertClear((TestAllTypes) message.WrappedMessage); - } - - [Test] - public void Copy() - { - AbstractMessageWrapper message = - new AbstractMessageWrapper.Builder(TestAllTypes.CreateBuilder()).MergeFrom(TestUtil.GetAllSet()).Build(); - TestUtil.AssertAllFieldsSet((TestAllTypes) message.WrappedMessage); - } - - [Test] - public void CreateAndBuild() - { - TestAllTypes.CreateBuilder() - .Build(); - } - - [Test] - public void SerializedSize() - { - TestAllTypes message = TestUtil.GetAllSet(); - IMessage abstractMessage = new AbstractMessageWrapper(TestUtil.GetAllSet()); - - Assert.AreEqual(message.SerializedSize, abstractMessage.SerializedSize); - } - - [Test] - public void Serialization() - { - IMessage abstractMessage = new AbstractMessageWrapper(TestUtil.GetAllSet()); - TestUtil.AssertAllFieldsSet(TestAllTypes.ParseFrom(abstractMessage.ToByteString())); - Assert.AreEqual(TestUtil.GetAllSet().ToByteString(), abstractMessage.ToByteString()); - } - - [Test] - public void Parsing() - { - IBuilder builder = new AbstractMessageWrapper.Builder(TestAllTypes.CreateBuilder()); - AbstractMessageWrapper message = - (AbstractMessageWrapper) builder.WeakMergeFrom(TestUtil.GetAllSet().ToByteString()).WeakBuild(); - TestUtil.AssertAllFieldsSet((TestAllTypes) message.WrappedMessage); - } - - [Test] - public void PackedSerialization() - { - IMessage abstractMessage = new AbstractMessageWrapper(TestUtil.GetPackedSet()); - TestUtil.AssertPackedFieldsSet(TestPackedTypes.ParseFrom(abstractMessage.ToByteString())); - Assert.AreEqual(TestUtil.GetPackedSet().ToByteString(), abstractMessage.ToByteString()); - } - - [Test] - public void PackedParsing() - { - AbstractMessageWrapper.Builder builder = new AbstractMessageWrapper.Builder(TestPackedTypes.CreateBuilder()); - AbstractMessageWrapper message = builder.MergeFrom(TestUtil.GetPackedSet().ToByteString()).Build(); - TestUtil.AssertPackedFieldsSet((TestPackedTypes)message.WrappedMessage); - } - - [Test] - public void UnpackedParsingOfPackedInput() - { - byte[] bytes = TestUtil.GetPackedSet().ToByteArray(); - TestUnpackedTypes message = TestUnpackedTypes.ParseFrom(bytes); - TestUtil.AssertUnpackedFieldsSet(message); - } - - [Test] - public void PackedParsingOfUnpackedInput() - { - byte[] bytes = TestUnpackedTypes.ParseFrom(TestUtil.GetPackedSet().ToByteArray()).ToByteArray(); - TestPackedTypes message = TestPackedTypes.ParseFrom(bytes); - TestUtil.AssertPackedFieldsSet(message); - } - - [Test] - public void UnpackedParsingOfPackedInputExtensions() - { - byte[] bytes = TestUtil.GetPackedSet().ToByteArray(); - ExtensionRegistry registry = ExtensionRegistry.CreateInstance(); - Unittest.RegisterAllExtensions(registry); - UnittestImport.RegisterAllExtensions(registry); - TestUnpackedExtensions message = TestUnpackedExtensions.ParseFrom(bytes, registry); - TestUtil.AssertUnpackedExtensionsSet(message); - } - - [Test] - public void PackedParsingOfUnpackedInputExtensions() - { - byte[] bytes = TestUnpackedTypes.ParseFrom(TestUtil.GetPackedSet().ToByteArray()).ToByteArray(); - ExtensionRegistry registry = ExtensionRegistry.CreateInstance(); - Unittest.RegisterAllExtensions(registry); - TestPackedExtensions message = TestPackedExtensions.ParseFrom(bytes, registry); - TestUtil.AssertPackedExtensionsSet(message); - } - - [Test] - public void OptimizedForSize() - { - // We're mostly only Checking that this class was compiled successfully. - TestOptimizedForSize message = TestOptimizedForSize.CreateBuilder().SetI(1).Build(); - message = TestOptimizedForSize.ParseFrom(message.ToByteString()); - Assert.AreEqual(2, message.SerializedSize); - } - - // ----------------------------------------------------------------- - // Tests for isInitialized(). - - private static readonly TestRequired TestRequiredUninitialized = TestRequired.DefaultInstance; - - private static readonly TestRequired TestRequiredInitialized = - TestRequired.CreateBuilder().SetA(1).SetB(2).SetC(3).Build(); - - [Test] - public void IsInitialized() - { - TestRequired.Builder builder = TestRequired.CreateBuilder(); - AbstractMessageWrapper.Builder abstractBuilder = new AbstractMessageWrapper.Builder(builder); - - Assert.IsFalse(abstractBuilder.IsInitialized); - builder.A = 1; - Assert.IsFalse(abstractBuilder.IsInitialized); - builder.B = 1; - Assert.IsFalse(abstractBuilder.IsInitialized); - builder.C = 1; - Assert.IsTrue(abstractBuilder.IsInitialized); - } - - [Test] - public void ForeignIsInitialized() - { - TestRequiredForeign.Builder builder = TestRequiredForeign.CreateBuilder(); - AbstractMessageWrapper.Builder abstractBuilder = new AbstractMessageWrapper.Builder(builder); - - Assert.IsTrue(abstractBuilder.IsInitialized); - - builder.SetOptionalMessage(TestRequiredUninitialized); - Assert.IsFalse(abstractBuilder.IsInitialized); - - builder.SetOptionalMessage(TestRequiredInitialized); - Assert.IsTrue(abstractBuilder.IsInitialized); - - builder.AddRepeatedMessage(TestRequiredUninitialized); - Assert.IsFalse(abstractBuilder.IsInitialized); - - builder.SetRepeatedMessage(0, TestRequiredInitialized); - Assert.IsTrue(abstractBuilder.IsInitialized); - } - - // ----------------------------------------------------------------- - // Tests for mergeFrom - - private static readonly TestAllTypes MergeSource = TestAllTypes.CreateBuilder() - .SetOptionalInt32(1) - .SetOptionalString("foo") - .SetOptionalForeignMessage(ForeignMessage.DefaultInstance) - .AddRepeatedString("bar") - .Build(); - - private static readonly TestAllTypes MergeDest = TestAllTypes.CreateBuilder() - .SetOptionalInt64(2) - .SetOptionalString("baz") - .SetOptionalForeignMessage(ForeignMessage.CreateBuilder().SetC(3).Build()) - .AddRepeatedString("qux") - .Build(); - - private const string MergeResultText = "optional_int32: 1\n" + - "optional_int64: 2\n" + - "optional_string: \"foo\"\n" + - "optional_foreign_message {\n" + - " c: 3\n" + - "}\n" + - "repeated_string: \"qux\"\n" + - "repeated_string: \"bar\"\n"; - - [Test] - public void MergeFrom() - { - AbstractMessageWrapper result = (AbstractMessageWrapper) - new AbstractMessageWrapper.Builder(TestAllTypes.CreateBuilder(MergeDest)) - .MergeFrom(MergeSource) - .Build(); - - Assert.AreEqual(MergeResultText, result.ToString()); - } - - // ----------------------------------------------------------------- - // Tests for equals and hashCode - - [Test] - public void EqualsAndHashCode() - { - TestAllTypes a = TestUtil.GetAllSet(); - TestAllTypes b = TestAllTypes.CreateBuilder().Build(); - TestAllTypes c = TestAllTypes.CreateBuilder(b).AddRepeatedString("x").Build(); - TestAllTypes d = TestAllTypes.CreateBuilder(c).AddRepeatedString("y").Build(); - TestAllExtensions e = TestUtil.GetAllExtensionsSet(); - TestAllExtensions f = TestAllExtensions.CreateBuilder(e) - .AddExtension(Unittest.RepeatedInt32Extension, 999).Build(); - - CheckEqualsIsConsistent(a); - CheckEqualsIsConsistent(b); - CheckEqualsIsConsistent(c); - CheckEqualsIsConsistent(d); - CheckEqualsIsConsistent(e); - CheckEqualsIsConsistent(f); - - CheckNotEqual(a, b); - CheckNotEqual(a, c); - CheckNotEqual(a, d); - CheckNotEqual(a, e); - CheckNotEqual(a, f); - - CheckNotEqual(b, c); - CheckNotEqual(b, d); - CheckNotEqual(b, e); - CheckNotEqual(b, f); - - CheckNotEqual(c, d); - CheckNotEqual(c, e); - CheckNotEqual(c, f); - - CheckNotEqual(d, e); - CheckNotEqual(d, f); - - CheckNotEqual(e, f); - - // Deserializing into the TestEmptyMessage such that every field is an UnknownFieldSet.Field - TestEmptyMessage eUnknownFields = TestEmptyMessage.ParseFrom(e.ToByteArray()); - TestEmptyMessage fUnknownFields = TestEmptyMessage.ParseFrom(f.ToByteArray()); - CheckNotEqual(eUnknownFields, fUnknownFields); - CheckEqualsIsConsistent(eUnknownFields); - CheckEqualsIsConsistent(fUnknownFields); - - // Subseqent reconstitutions should be identical - TestEmptyMessage eUnknownFields2 = TestEmptyMessage.ParseFrom(e.ToByteArray()); - CheckEqualsIsConsistent(eUnknownFields, eUnknownFields2); - } - - /// - /// Asserts that the given protos are equal and have the same hash code. - /// - private static void CheckEqualsIsConsistent(IMessage message) - { - // Object should be equal to itself. - Assert.AreEqual(message, message); - - // Object should be equal to a dynamic copy of itself. - DynamicMessage dynamic = DynamicMessage.CreateBuilder(message).Build(); - CheckEqualsIsConsistent(message, dynamic); - } - - /// - /// Asserts that the given protos are equal and have the same hash code. - /// - private static void CheckEqualsIsConsistent(IMessage message1, IMessage message2) - { - // Not using Assert.AreEqual as that checks for type equality, which isn't - // what we want bearing in mind the dynamic message checks. - Assert.IsTrue(message1.Equals(message2)); - Assert.IsTrue(message2.Equals(message1)); - Assert.AreEqual(message2.GetHashCode(), message1.GetHashCode()); - } - - /// - /// Asserts that the given protos are not equal and have different hash codes. - /// - /// - /// It's valid for non-equal objects to have the same hash code, so - /// this test is stricter than it needs to be. However, this should happen - /// relatively rarely. (If this test fails, it's probably still due to a bug.) - /// - private static void CheckNotEqual(IMessage m1, IMessage m2) - { - String equalsError = string.Format("{0} should not be equal to {1}", m1, m2); - Assert.IsFalse(m1.Equals(m2), equalsError); - Assert.IsFalse(m2.Equals(m1), equalsError); - - Assert.IsFalse(m1.GetHashCode() == m2.GetHashCode(), - string.Format("{0} should have a different hash code from {1}", m1, m2)); - } - - /// - /// Extends AbstractMessage and wraps some other message object. The methods - /// of the Message interface which aren't explicitly implemented by - /// AbstractMessage are forwarded to the wrapped object. This allows us to - /// test that AbstractMessage's implementations work even if the wrapped - /// object does not use them. - /// - private class AbstractMessageWrapper : AbstractMessage - { - private readonly IMessage wrappedMessage; - - public IMessage WrappedMessage - { - get { return wrappedMessage; } - } - - public AbstractMessageWrapper(IMessage wrappedMessage) - { - this.wrappedMessage = wrappedMessage; - } - - public override MessageDescriptor DescriptorForType - { - get { return wrappedMessage.DescriptorForType; } - } - - public override AbstractMessageWrapper DefaultInstanceForType - { - get { return new AbstractMessageWrapper(wrappedMessage.WeakDefaultInstanceForType); } - } - - public override IDictionary AllFields - { - get { return wrappedMessage.AllFields; } - } - - public override bool HasField(FieldDescriptor field) - { - return wrappedMessage.HasField(field); - } - - public override bool HasOneof(OneofDescriptor oneof) - { - return wrappedMessage.HasOneof(oneof); - } - - public override FieldDescriptor OneofFieldDescriptor(OneofDescriptor oneof) - { - return wrappedMessage.OneofFieldDescriptor(oneof); - } - - public override object this[FieldDescriptor field] - { - get { return wrappedMessage[field]; } - } - - public override object this[FieldDescriptor field, int index] - { - get { return wrappedMessage[field, index]; } - } - - public override int GetRepeatedFieldCount(FieldDescriptor field) - { - return wrappedMessage.GetRepeatedFieldCount(field); - } - - public override UnknownFieldSet UnknownFields - { - get { return wrappedMessage.UnknownFields; } - } - - public override Builder CreateBuilderForType() - { - return new Builder(wrappedMessage.WeakCreateBuilderForType()); - } - - public override Builder ToBuilder() - { - return new Builder(wrappedMessage.WeakToBuilder()); - } - - internal class Builder : AbstractBuilder - { - private readonly IBuilder wrappedBuilder; - - protected override Builder ThisBuilder - { - get { return this; } - } - - internal Builder(IBuilder wrappedBuilder) - { - this.wrappedBuilder = wrappedBuilder; - } - - public override Builder MergeFrom(AbstractMessageWrapper other) - { - wrappedBuilder.WeakMergeFrom(other.wrappedMessage); - return this; - } - - public override bool IsInitialized - { - get { return wrappedBuilder.IsInitialized; } - } - - public override IDictionary AllFields - { - get { return wrappedBuilder.AllFields; } - } - - public override object this[FieldDescriptor field] - { - get { return wrappedBuilder[field]; } - set { wrappedBuilder[field] = value; } - } - - public override MessageDescriptor DescriptorForType - { - get { return wrappedBuilder.DescriptorForType; } - } - - public override int GetRepeatedFieldCount(FieldDescriptor field) - { - return wrappedBuilder.GetRepeatedFieldCount(field); - } - - public override object this[FieldDescriptor field, int index] - { - get { return wrappedBuilder[field, index]; } - set { wrappedBuilder[field, index] = value; } - } - - public override bool HasField(FieldDescriptor field) - { - return wrappedBuilder.HasField(field); - } - - public override bool HasOneof(OneofDescriptor oneof) - { - return wrappedBuilder.HasOneof(oneof); - } - - public override FieldDescriptor OneofFieldDescriptor(OneofDescriptor oneof) - { - return wrappedBuilder.OneofFieldDescriptor(oneof); - } - - public override UnknownFieldSet UnknownFields - { - get { return wrappedBuilder.UnknownFields; } - set { wrappedBuilder.UnknownFields = value; } - } - - public override AbstractMessageWrapper Build() - { - return new AbstractMessageWrapper(wrappedBuilder.WeakBuild()); - } - - public override AbstractMessageWrapper BuildPartial() - { - return new AbstractMessageWrapper(wrappedBuilder.WeakBuildPartial()); - } - - public override Builder Clone() - { - return new Builder(wrappedBuilder.WeakClone()); - } - - public override AbstractMessageWrapper DefaultInstanceForType - { - get { return new AbstractMessageWrapper(wrappedBuilder.WeakDefaultInstanceForType); } - } - - public override Builder ClearField(FieldDescriptor field) - { - wrappedBuilder.WeakClearField(field); - return this; - } - - public override Builder ClearOneof(OneofDescriptor oneof) - { - wrappedBuilder.WeakClearOneof(oneof); - return this; - } - - public override Builder AddRepeatedField(FieldDescriptor field, object value) - { - wrappedBuilder.WeakAddRepeatedField(field, value); - return this; - } - - public override IBuilder CreateBuilderForField(FieldDescriptor field) - { - wrappedBuilder.CreateBuilderForField(field); - return this; - } - - public override Builder MergeFrom(IMessage other) - { - wrappedBuilder.WeakMergeFrom(other); - return this; - } - - public override Builder MergeFrom(ICodedInputStream input, ExtensionRegistry extensionRegistry) - { - wrappedBuilder.WeakMergeFrom(input, extensionRegistry); - return this; - } - } - } - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers.Test/ByteStringTest.cs b/csharp/src/ProtocolBuffers.Test/ByteStringTest.cs index e4f7bd9e..0edd149b 100644 --- a/csharp/src/ProtocolBuffers.Test/ByteStringTest.cs +++ b/csharp/src/ProtocolBuffers.Test/ByteStringTest.cs @@ -38,7 +38,7 @@ using System; using System.Text; using NUnit.Framework; -namespace Google.ProtocolBuffers +namespace Google.Protobuf { public class ByteStringTest { diff --git a/csharp/src/ProtocolBuffers.Test/CodedInputStreamTest.cs b/csharp/src/ProtocolBuffers.Test/CodedInputStreamTest.cs index 9bb8ba27..57650049 100644 --- a/csharp/src/ProtocolBuffers.Test/CodedInputStreamTest.cs +++ b/csharp/src/ProtocolBuffers.Test/CodedInputStreamTest.cs @@ -37,11 +37,12 @@ using System; using System.Collections.Generic; using System.IO; -using Google.ProtocolBuffers.Descriptors; -using Google.ProtocolBuffers.TestProtos; +using Google.Protobuf.Collections; +using Google.Protobuf.Descriptors; +using Google.Protobuf.TestProtos; using NUnit.Framework; -namespace Google.ProtocolBuffers +namespace Google.Protobuf { public class CodedInputStreamTest { @@ -231,7 +232,7 @@ namespace Google.ProtocolBuffers Assert.AreEqual(0x7FFFFFFFFFFFFFFFL, CodedInputStream.DecodeZigZag64(0xFFFFFFFFFFFFFFFEL)); Assert.AreEqual(unchecked((long) 0x8000000000000000L), CodedInputStream.DecodeZigZag64(0xFFFFFFFFFFFFFFFFL)); } - + /* [Test] public void ReadWholeMessage() { @@ -273,7 +274,7 @@ namespace Google.ProtocolBuffers unknownFields.MergeFieldFrom(tag, input1); input2.SkipField(); } - } + }*/ /// /// Test that a bug in SkipRawBytes has been fixed: if the skip @@ -290,7 +291,7 @@ namespace Google.ProtocolBuffers input.PopLimit(limit); Assert.AreEqual(2, input.ReadRawByte()); } - + /* public void ReadHugeBlob() { // Allocate and initialize a 1MB blob. @@ -318,7 +319,7 @@ namespace Google.ProtocolBuffers .SetOptionalBytes(TestUtil.GetAllSet().OptionalBytes) .Build(); TestUtil.AssertAllFieldsSet(message3); - } + }*/ [Test] public void ReadMaliciouslyLargeBlob() @@ -348,12 +349,11 @@ namespace Google.ProtocolBuffers { if (depth == 0) { - return TestRecursiveMessage.CreateBuilder().SetI(5).Build(); + return new TestRecursiveMessage { I = 5 }; } else { - return TestRecursiveMessage.CreateBuilder() - .SetA(MakeRecursiveMessage(depth - 1)).Build(); + return new TestRecursiveMessage { A = MakeRecursiveMessage(depth - 1) }; } } @@ -361,12 +361,12 @@ namespace Google.ProtocolBuffers { if (depth == 0) { - Assert.IsFalse(message.HasA); + Assert.IsNull(message.A); Assert.AreEqual(5, message.I); } else { - Assert.IsTrue(message.HasA); + Assert.IsNotNull(message.A); AssertMessageDepth(message.A, depth - 1); } } @@ -377,15 +377,16 @@ namespace Google.ProtocolBuffers ByteString data64 = MakeRecursiveMessage(64).ToByteString(); ByteString data65 = MakeRecursiveMessage(65).ToByteString(); - AssertMessageDepth(TestRecursiveMessage.ParseFrom(data64), 64); + AssertMessageDepth(TestRecursiveMessage.Parser.ParseFrom(data64), 64); - Assert.Throws(() => TestRecursiveMessage.ParseFrom(data65)); + Assert.Throws(() => TestRecursiveMessage.Parser.ParseFrom(data65)); CodedInputStream input = data64.CreateCodedInput(); input.SetRecursionLimit(8); - Assert.Throws(() => TestRecursiveMessage.ParseFrom(input)); + Assert.Throws(() => TestRecursiveMessage.Parser.ParseFrom(input)); } + /* [Test] public void SizeLimit() { @@ -396,7 +397,7 @@ namespace Google.ProtocolBuffers input.SetSizeLimit(16); Assert.Throws(() => TestAllTypes.ParseFrom(input)); - } + }*/ [Test] public void ResetSizeCounter() @@ -465,17 +466,16 @@ namespace Google.ProtocolBuffers } } - enum TestNegEnum { None = 0, Value = -2 } + enum TestNegEnum : long { None = 0, Value = -2 } [Test] public void TestNegativeEnum() { byte[] bytes = new byte[10] { 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01 }; CodedInputStream input = CodedInputStream.CreateInstance(bytes); - object unk; TestNegEnum val = TestNegEnum.None; - Assert.IsTrue(input.ReadEnum(ref val, out unk)); + Assert.IsTrue(input.ReadEnum(ref val)); Assert.IsTrue(input.IsAtEnd); Assert.AreEqual(TestNegEnum.Value, val); } @@ -487,7 +487,7 @@ namespace Google.ProtocolBuffers int msgSize = 1 + 1 + arraySize; byte[] bytes = new byte[msgSize]; CodedOutputStream output = CodedOutputStream.CreateInstance(bytes); - output.WritePackedInt32Array(8, "", arraySize, new int[] { 0, -1, -2, -3, -4, -5 }); + output.WritePackedInt32Array(8, "", new RepeatedField { 0, -1, -2, -3, -4, -5 }); Assert.AreEqual(0, output.SpaceLeft); @@ -497,15 +497,12 @@ namespace Google.ProtocolBuffers Assert.IsTrue(input.ReadTag(out tag, out name)); List values = new List(); - ICollection unk; - input.ReadEnumArray(tag, name, values, out unk); + input.ReadEnumArray(tag, name, values); - Assert.AreEqual(2, values.Count); + Assert.AreEqual(6, values.Count); Assert.AreEqual(TestNegEnum.None, values[0]); - Assert.AreEqual(TestNegEnum.Value, values[1]); - - Assert.NotNull(unk); - Assert.AreEqual(4, unk.Count); + Assert.AreEqual(TestNegEnum.Value, values[2]); + // TODO(jonskeet): Test unknown value preservation } [Test] @@ -515,7 +512,7 @@ namespace Google.ProtocolBuffers int msgSize = arraySize; byte[] bytes = new byte[msgSize]; CodedOutputStream output = CodedOutputStream.CreateInstance(bytes); - output.WriteInt32Array(8, "", new int[] { 0, -1, -2, -3, -4, -5 }); + output.WriteInt32Array(8, "", new RepeatedField { 0, -1, -2, -3, -4, -5 }); Assert.AreEqual(0, output.SpaceLeft); @@ -525,15 +522,12 @@ namespace Google.ProtocolBuffers Assert.IsTrue(input.ReadTag(out tag, out name)); List values = new List(); - ICollection unk; - input.ReadEnumArray(tag, name, values, out unk); + input.ReadEnumArray(tag, name, values); - Assert.AreEqual(2, values.Count); + Assert.AreEqual(6, values.Count); Assert.AreEqual(TestNegEnum.None, values[0]); - Assert.AreEqual(TestNegEnum.Value, values[1]); - - Assert.NotNull(unk); - Assert.AreEqual(4, unk.Count); + Assert.AreEqual(TestNegEnum.Value, values[2]); + // TODO(jonskeet): Test unknown value preservation } //Issue 71: CodedInputStream.ReadBytes go to slow path unnecessarily diff --git a/csharp/src/ProtocolBuffers.Test/CodedOutputStreamTest.cs b/csharp/src/ProtocolBuffers.Test/CodedOutputStreamTest.cs index 4d5b8302..df80b3af 100644 --- a/csharp/src/ProtocolBuffers.Test/CodedOutputStreamTest.cs +++ b/csharp/src/ProtocolBuffers.Test/CodedOutputStreamTest.cs @@ -37,10 +37,10 @@ using System; using System.Collections.Generic; using System.IO; -using Google.ProtocolBuffers.TestProtos; +using Google.Protobuf.Collections; using NUnit.Framework; -namespace Google.ProtocolBuffers +namespace Google.Protobuf { public class CodedOutputStreamTest { @@ -195,6 +195,7 @@ namespace Google.ProtocolBuffers 0x9abcdef012345678UL); } + /* [Test] public void WriteWholeMessage() { @@ -228,6 +229,7 @@ namespace Google.ProtocolBuffers TestUtil.AssertEqualBytes(TestUtil.GetGoldenPackedFieldsMessage().ToByteArray(), rawBytes); } + */ [Test] public void EncodeZigZag32() @@ -294,25 +296,27 @@ namespace Google.ProtocolBuffers public void TestNegativeEnumNoTag() { Assert.AreEqual(10, CodedOutputStream.ComputeInt32SizeNoTag(-2)); - Assert.AreEqual(10, CodedOutputStream.ComputeEnumSizeNoTag(-2)); + Assert.AreEqual(10, CodedOutputStream.ComputeEnumSizeNoTag(TestNegEnum.Value)); byte[] bytes = new byte[10]; CodedOutputStream output = CodedOutputStream.CreateInstance(bytes); - output.WriteEnumNoTag(-2); + output.WriteEnumNoTag(TestNegEnum.Value); Assert.AreEqual(0, output.SpaceLeft); Assert.AreEqual("FE-FF-FF-FF-FF-FF-FF-FF-FF-01", BitConverter.ToString(bytes)); } + enum TestNegEnum : long { None = 0, Value = -2 } + [Test] public void TestNegativeEnumWithTag() { Assert.AreEqual(11, CodedOutputStream.ComputeInt32Size(8, -2)); - Assert.AreEqual(11, CodedOutputStream.ComputeEnumSize(8, -2)); + Assert.AreEqual(11, CodedOutputStream.ComputeEnumSize(8, TestNegEnum.Value)); byte[] bytes = new byte[11]; CodedOutputStream output = CodedOutputStream.CreateInstance(bytes); - output.WriteEnum(8, "", -2, -2); + output.WriteEnum(8, "", TestNegEnum.Value); Assert.AreEqual(0, output.SpaceLeft); //fyi, 0x40 == 0x08 << 3 + 0, field num + wire format shift @@ -326,7 +330,8 @@ namespace Google.ProtocolBuffers int msgSize = 1 + 1 + arraySize; byte[] bytes = new byte[msgSize]; CodedOutputStream output = CodedOutputStream.CreateInstance(bytes); - output.WritePackedEnumArray(8, "", arraySize, new int[] { 0, -1, -2, -3, -4, -5 }); + output.WritePackedEnumArray(8, "", new RepeatedField { + 0, (TestNegEnum) (-1), TestNegEnum.Value, (TestNegEnum) (-3), (TestNegEnum) (-4), (TestNegEnum) (-5) }); Assert.AreEqual(0, output.SpaceLeft); @@ -350,8 +355,8 @@ namespace Google.ProtocolBuffers int msgSize = arraySize; byte[] bytes = new byte[msgSize]; CodedOutputStream output = CodedOutputStream.CreateInstance(bytes); - output.WriteEnumArray(8, "", new int[] { 0, -1, -2, -3, -4, -5 }); - + output.WriteEnumArray(8, "", new RepeatedField { + 0, (TestNegEnum) (-1), TestNegEnum.Value, (TestNegEnum) (-3), (TestNegEnum) (-4), (TestNegEnum) (-5) }); Assert.AreEqual(0, output.SpaceLeft); CodedInputStream input = CodedInputStream.CreateInstance(bytes); diff --git a/csharp/src/ProtocolBuffers.Test/Collections/PopsicleListTest.cs b/csharp/src/ProtocolBuffers.Test/Collections/PopsicleListTest.cs deleted file mode 100644 index f336a84b..00000000 --- a/csharp/src/ProtocolBuffers.Test/Collections/PopsicleListTest.cs +++ /dev/null @@ -1,125 +0,0 @@ -#region Copyright notice and license - -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/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.Collections.Generic; -using NUnit.Framework; - -namespace Google.ProtocolBuffers.Collections -{ - public class PopsicleListTest - { - [Test] - public void MutatingOperationsOnFrozenList() - { - PopsicleList list = new PopsicleList(); - list.MakeReadOnly(); - Assert.Throws(() => list.Add("")); - Assert.Throws(() => list.Clear()); - Assert.Throws(() => list.Insert(0, "")); - Assert.Throws(() => list.Remove("")); - Assert.Throws(() => list.RemoveAt(0)); - Assert.Throws(() => list.Add(new[] { "", "" })); - } - - [Test] - public void NonMutatingOperationsOnFrozenList() - { - PopsicleList list = new PopsicleList(); - list.MakeReadOnly(); - Assert.IsFalse(list.Contains("")); - Assert.AreEqual(0, list.Count); - list.CopyTo(new string[5], 0); - list.GetEnumerator(); - Assert.AreEqual(-1, list.IndexOf("")); - Assert.IsTrue(list.IsReadOnly); - } - - [Test] - public void MutatingOperationsOnFluidList() - { - PopsicleList list = new PopsicleList(); - list.Add(""); - list.Clear(); - list.Insert(0, ""); - list.Remove(""); - list.Add("x"); // Just to make the next call valid - list.RemoveAt(0); - } - - [Test] - public void NonMutatingOperationsOnFluidList() - { - PopsicleList list = new PopsicleList(); - Assert.IsFalse(list.Contains("")); - Assert.AreEqual(0, list.Count); - list.CopyTo(new string[5], 0); - list.GetEnumerator(); - Assert.AreEqual(-1, list.IndexOf("")); - Assert.IsFalse(list.IsReadOnly); - } - - [Test] - public void DoesNotAddNullEnumerable() - { - PopsicleList list = new PopsicleList(); - Assert.Throws(() => list.Add((IEnumerable) null)); - } - - [Test] - public void DoesNotAddRangeWithNull() - { - PopsicleList list = new PopsicleList(); - // TODO(jonskeet): Change to ArgumentException? The argument isn't null... - Assert.Throws(() => list.Add(new[] {"a", "b", null})); - } - - [Test] - public void DoesNotAddNull() - { - PopsicleList list = new PopsicleList(); - Assert.Throws(() => list.Add((string) null)); - } - - [Test] - public void DoesNotSetNull() - { - PopsicleList list = new PopsicleList(); - list.Add("a"); - Assert.Throws(() => list[0] = null); - } - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers.Test/Compatibility/BinaryCompatibilityTests.cs b/csharp/src/ProtocolBuffers.Test/Compatibility/BinaryCompatibilityTests.cs deleted file mode 100644 index 30d257ad..00000000 --- a/csharp/src/ProtocolBuffers.Test/Compatibility/BinaryCompatibilityTests.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; - -namespace Google.ProtocolBuffers.Compatibility -{ - public class BinaryCompatibilityTests : CompatibilityTests - { - protected override object SerializeMessage(TMessage message) - { - byte[] bresult = message.ToByteArray(); - return Convert.ToBase64String(bresult); - } - - protected override TBuilder DeserializeMessage(object message, TBuilder builder, ExtensionRegistry registry) - { - return builder.MergeFrom((byte[])Convert.FromBase64String((string)message), registry); - } - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers.Test/Compatibility/CompatibilityTests.cs b/csharp/src/ProtocolBuffers.Test/Compatibility/CompatibilityTests.cs deleted file mode 100644 index a050827e..00000000 --- a/csharp/src/ProtocolBuffers.Test/Compatibility/CompatibilityTests.cs +++ /dev/null @@ -1,227 +0,0 @@ -using System; -using Google.ProtocolBuffers.TestProtos; -using NUnit.Framework; - - -namespace Google.ProtocolBuffers.Compatibility -{ - /// - /// This abstract base implements several tests to ensure that well-known messages can be written - /// and read to/from various formats without losing data. Implementations override the two serialization - /// methods to provide the tests with the means to read and write for a given format. - /// - public abstract class CompatibilityTests - { - protected abstract object SerializeMessage(TMessage message) - where TMessage : IMessageLite - where TBuilder : IBuilderLite; - - protected abstract TBuilder DeserializeMessage(object message, TBuilder builder, ExtensionRegistry registry) - where TMessage : IMessageLite - where TBuilder : IBuilderLite; - - protected virtual void AssertOutputEquals(object lhs, object rhs) - { - Assert.AreEqual(lhs, rhs); - } - - [Test] - public virtual void RoundTripWithEmptyChildMessageSize() - { - SizeMessage1 msg = SizeMessage1.CreateBuilder() - .SetField100(100) - .SetField15(SizeMessage1SubMessage.DefaultInstance) - .BuildPartial(); - byte[] contents = msg.ToByteArray(); - object content = SerializeMessage(msg); - - SizeMessage1 copy = DeserializeMessage(content, SizeMessage1.CreateBuilder(), ExtensionRegistry.Empty).BuildPartial(); - - Assert.AreEqual(msg, copy); - AssertOutputEquals(content, SerializeMessage(copy)); - Assert.AreEqual(Convert.ToBase64String(contents), Convert.ToBase64String(copy.ToByteArray())); - } - - [Test] - public virtual void RoundTripWithEmptyChildMessageSpeed() - { - SpeedMessage1 msg = SpeedMessage1.CreateBuilder() - .SetField100(100) - .SetField15(SpeedMessage1SubMessage.DefaultInstance) - .BuildPartial(); - byte[] contents = msg.ToByteArray(); - object content = SerializeMessage(msg); - - SpeedMessage1 copy = DeserializeMessage(content, SpeedMessage1.CreateBuilder(), ExtensionRegistry.Empty).BuildPartial(); - - Assert.AreEqual(msg, copy); - AssertOutputEquals(content, SerializeMessage(copy)); - Assert.AreEqual(Convert.ToBase64String(contents), Convert.ToBase64String(copy.ToByteArray())); - } - - [Test] - public virtual void RoundTripMessage1OptimizeSize() - { - SizeMessage1 msg = SizeMessage1.CreateBuilder().MergeFrom(TestResources.google_message1).Build(); - object content = SerializeMessage(msg); - - SizeMessage1 copy = DeserializeMessage(content, SizeMessage1.CreateBuilder(), ExtensionRegistry.Empty).Build(); - - Assert.AreEqual(msg, copy); - AssertOutputEquals(content, SerializeMessage(copy)); - Assert.AreEqual(Convert.ToBase64String(TestResources.google_message1), Convert.ToBase64String(copy.ToByteArray())); - } - - [Test] - public virtual void RoundTripMessage2OptimizeSize() - { - SizeMessage2 msg = SizeMessage2.CreateBuilder().MergeFrom(TestResources.google_message2).Build(); - object content = SerializeMessage(msg); - - SizeMessage2 copy = DeserializeMessage(content, SizeMessage2.CreateBuilder(), ExtensionRegistry.Empty).Build(); - - Assert.AreEqual(msg, copy); - AssertOutputEquals(content, SerializeMessage(copy)); - Assert.AreEqual(Convert.ToBase64String(TestResources.google_message2), Convert.ToBase64String(copy.ToByteArray())); - } - - [Test] - public virtual void RoundTripMessage1OptimizeSpeed() - { - SpeedMessage1 msg = SpeedMessage1.CreateBuilder().MergeFrom(TestResources.google_message1).Build(); - object content = SerializeMessage(msg); - - SpeedMessage1 copy = DeserializeMessage(content, SpeedMessage1.CreateBuilder(), ExtensionRegistry.Empty).Build(); - - Assert.AreEqual(msg, copy); - AssertOutputEquals(content, SerializeMessage(copy)); - Assert.AreEqual(Convert.ToBase64String(TestResources.google_message1), Convert.ToBase64String(copy.ToByteArray())); - } - - [Test] - public virtual void RoundTripMessage2OptimizeSpeed() - { - SpeedMessage2 msg = SpeedMessage2.CreateBuilder().MergeFrom(TestResources.google_message2).Build(); - object content = SerializeMessage(msg); - - SpeedMessage2 copy = DeserializeMessage(content, SpeedMessage2.CreateBuilder(), ExtensionRegistry.Empty).Build(); - - Assert.AreEqual(msg, copy); - AssertOutputEquals(content, SerializeMessage(copy)); - Assert.AreEqual(Convert.ToBase64String(TestResources.google_message2), Convert.ToBase64String(copy.ToByteArray())); - } - - #region Test message builders - - protected static TestAllTypes.Builder AddAllTypes(TestAllTypes.Builder builder) - { - return builder.SetOptionalInt32(1001) - .SetOptionalInt64(1001) - .SetOptionalUint32(1001) - .SetOptionalUint64(1001) - .SetOptionalSint32(-1001) - .SetOptionalSint64(-1001) - .SetOptionalFixed32(1001) - .SetOptionalFixed64(1001) - .SetOptionalSfixed32(-1001) - .SetOptionalSfixed64(-1001) - .SetOptionalFloat(1001.1001f) - .SetOptionalDouble(1001.1001) - .SetOptionalBool(true) - .SetOptionalString("this is a string value") - .SetOptionalBytes(ByteString.CopyFromUtf8("this is an array of bytes")) - .SetOptionalGroup(new TestAllTypes.Types.OptionalGroup.Builder().SetA(1001)) - .SetOptionalNestedMessage(new TestAllTypes.Types.NestedMessage.Builder().SetBb(1001)) - .SetOptionalNestedEnum(TestAllTypes.Types.NestedEnum.FOO) - ; - } - - protected static TestAllTypes.Builder AddRepeatedTypes(TestAllTypes.Builder builder, int size) - { - //repeated values - for (int i = 0; i < size; i++) - builder.AddRepeatedInt32(1001 + i) - .AddRepeatedInt64(1001) - .AddRepeatedUint32(1001) - .AddRepeatedUint64(1001) - .AddRepeatedSint32(-1001) - .AddRepeatedSint64(-1001) - .AddRepeatedFixed32(1001) - .AddRepeatedFixed64(1001) - .AddRepeatedSfixed32(-1001) - .AddRepeatedSfixed64(-1001) - .AddRepeatedFloat(1001.1001f) - .AddRepeatedDouble(1001.1001) - .AddRepeatedBool(true) - .AddRepeatedString("this is a string value") - .AddRepeatedBytes(ByteString.CopyFromUtf8("this is an array of bytes")) - .AddRepeatedGroup(new TestAllTypes.Types.RepeatedGroup.Builder().SetA(1001)) - .AddRepeatedNestedMessage(new TestAllTypes.Types.NestedMessage.Builder().SetBb(1001)) - .AddRepeatedNestedEnum(TestAllTypes.Types.NestedEnum.FOO) - ; - return builder; - } - - protected static TestPackedTypes.Builder AddPackedTypes(TestPackedTypes.Builder builder, int size) - { - for(int i=0; i < size; i++ ) - builder.AddPackedInt32(1001) - .AddPackedInt64(1001) - .AddPackedUint32(1001) - .AddPackedUint64(1001) - .AddPackedSint32(-1001) - .AddPackedSint64(-1001) - .AddPackedFixed32(1001) - .AddPackedFixed64(1001) - .AddPackedSfixed32(-1001) - .AddPackedSfixed64(-1001) - .AddPackedFloat(1001.1001f) - .AddPackedDouble(1001.1001) - .AddPackedBool(true) - .AddPackedEnum(ForeignEnum.FOREIGN_FOO) - ; - return builder; - } - - #endregion - - [Test] - public void TestRoundTripAllTypes() - { - TestAllTypes msg = AddAllTypes(new TestAllTypes.Builder()).Build(); - object content = SerializeMessage(msg); - - TestAllTypes copy = DeserializeMessage(content, TestAllTypes.CreateBuilder(), ExtensionRegistry.Empty).Build(); - - Assert.AreEqual(msg, copy); - AssertOutputEquals(content, SerializeMessage(copy)); - Assert.AreEqual(Convert.ToBase64String(msg.ToByteArray()), Convert.ToBase64String(copy.ToByteArray())); - } - - [Test] - public void TestRoundTripRepeatedTypes() - { - TestAllTypes msg = AddRepeatedTypes(new TestAllTypes.Builder(), 5).Build(); - object content = SerializeMessage(msg); - - TestAllTypes copy = DeserializeMessage(content, TestAllTypes.CreateBuilder(), ExtensionRegistry.Empty).Build(); - - Assert.AreEqual(msg, copy); - AssertOutputEquals(content, SerializeMessage(copy)); - Assert.AreEqual(Convert.ToBase64String(msg.ToByteArray()), Convert.ToBase64String(copy.ToByteArray())); - } - - [Test] - public void TestRoundTripPackedTypes() - { - TestPackedTypes msg = AddPackedTypes(new TestPackedTypes.Builder(), 5).Build(); - object content = SerializeMessage(msg); - - TestPackedTypes copy = DeserializeMessage(content, TestPackedTypes.CreateBuilder(), ExtensionRegistry.Empty).Build(); - - Assert.AreEqual(msg, copy); - AssertOutputEquals(content, SerializeMessage(copy)); - Assert.AreEqual(Convert.ToBase64String(msg.ToByteArray()), Convert.ToBase64String(copy.ToByteArray())); - } - } -} diff --git a/csharp/src/ProtocolBuffers.Test/Compatibility/DictionaryCompatibilityTests.cs b/csharp/src/ProtocolBuffers.Test/Compatibility/DictionaryCompatibilityTests.cs deleted file mode 100644 index 299bb1a6..00000000 --- a/csharp/src/ProtocolBuffers.Test/Compatibility/DictionaryCompatibilityTests.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.Collections.Generic; -using Google.ProtocolBuffers.Serialization; -using NUnit.Framework; - -namespace Google.ProtocolBuffers.Compatibility -{ - [TestFixture] - public class DictionaryCompatibilityTests : CompatibilityTests - { - protected override object SerializeMessage(TMessage message) - { - DictionaryWriter writer = new DictionaryWriter(); - writer.WriteMessage(message); - return writer.ToDictionary(); - } - - protected override TBuilder DeserializeMessage(object message, TBuilder builder, ExtensionRegistry registry) - { - new DictionaryReader((IDictionary)message).Merge(builder); - return builder; - } - - protected override void AssertOutputEquals(object lhs, object rhs) - { - IDictionary left = (IDictionary)lhs; - IDictionary right = (IDictionary)rhs; - - Assert.AreEqual( - String.Join(",", new List(left.Keys).ToArray()), - String.Join(",", new List(right.Keys).ToArray()) - ); - } - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers.Test/Compatibility/JsonCompatibilityTests.cs b/csharp/src/ProtocolBuffers.Test/Compatibility/JsonCompatibilityTests.cs deleted file mode 100644 index a1e0ed33..00000000 --- a/csharp/src/ProtocolBuffers.Test/Compatibility/JsonCompatibilityTests.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System.IO; -using Google.ProtocolBuffers.Serialization; -using NUnit.Framework; - -namespace Google.ProtocolBuffers.Compatibility -{ - [TestFixture] - public class JsonCompatibilityTests : CompatibilityTests - { - protected override object SerializeMessage(TMessage message) - { - StringWriter sw = new StringWriter(); - JsonFormatWriter.CreateInstance(sw) - .WriteMessage(message); - return sw.ToString(); - } - - protected override TBuilder DeserializeMessage(object message, TBuilder builder, ExtensionRegistry registry) - { - JsonFormatReader.CreateInstance((string)message).Merge(builder); - return builder; - } - } - - [TestFixture] - public class JsonCompatibilityFormattedTests : CompatibilityTests - { - protected override object SerializeMessage(TMessage message) - { - StringWriter sw = new StringWriter(); - JsonFormatWriter.CreateInstance(sw) - .Formatted() - .WriteMessage(message); - return sw.ToString(); - } - - protected override TBuilder DeserializeMessage(object message, TBuilder builder, ExtensionRegistry registry) - { - JsonFormatReader.CreateInstance((string)message).Merge(builder); - return builder; - } - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers.Test/Compatibility/TestResources.cs b/csharp/src/ProtocolBuffers.Test/Compatibility/TestResources.cs deleted file mode 100644 index 2282d61f..00000000 --- a/csharp/src/ProtocolBuffers.Test/Compatibility/TestResources.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System.IO; -using NUnit.Framework; - -namespace Google.ProtocolBuffers.Compatibility -{ - static class TestResources - { - public static byte[] google_message1 - { - get - { - Stream resource = typeof(TestResources).Assembly.GetManifestResourceStream( - typeof(TestResources).Namespace + ".google_message1.dat"); - - Assert.NotNull(resource); - - byte[] bytes = new byte[resource.Length]; - int amtRead = resource.Read(bytes, 0, bytes.Length); - Assert.AreEqual(bytes.Length, amtRead); - return bytes; - } - } - public static byte[] google_message2 - { - get - { - Stream resource = typeof(TestResources).Assembly.GetManifestResourceStream( - typeof(TestResources).Namespace + ".google_message2.dat"); - - Assert.NotNull(resource); - byte[] bytes = new byte[resource.Length]; - int amtRead = resource.Read(bytes, 0, bytes.Length); - Assert.AreEqual(bytes.Length, amtRead); - return bytes; - } - } - } -} diff --git a/csharp/src/ProtocolBuffers.Test/Compatibility/TextCompatibilityTests.cs b/csharp/src/ProtocolBuffers.Test/Compatibility/TextCompatibilityTests.cs deleted file mode 100644 index 89d6e260..00000000 --- a/csharp/src/ProtocolBuffers.Test/Compatibility/TextCompatibilityTests.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.IO; -using NUnit.Framework; - -namespace Google.ProtocolBuffers.Compatibility -{ - [TestFixture] - public class TextCompatibilityTests : CompatibilityTests - { - protected override object SerializeMessage(TMessage message) - { - StringWriter text = new StringWriter(); - message.PrintTo(text); - return text.ToString(); - } - - protected override TBuilder DeserializeMessage(object message, TBuilder builder, ExtensionRegistry registry) - { - TextFormat.Merge(new StringReader((string)message), registry, (IBuilder)builder); - return builder; - } - //This test can take a very long time to run. - [Test] - public override void RoundTripMessage2OptimizeSize() - { - //base.RoundTripMessage2OptimizeSize(); - } - - //This test can take a very long time to run. - [Test] - public override void RoundTripMessage2OptimizeSpeed() - { - //base.RoundTripMessage2OptimizeSpeed(); - } - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers.Test/Compatibility/XmlCompatibilityTests.cs b/csharp/src/ProtocolBuffers.Test/Compatibility/XmlCompatibilityTests.cs deleted file mode 100644 index 91d40d83..00000000 --- a/csharp/src/ProtocolBuffers.Test/Compatibility/XmlCompatibilityTests.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System.IO; -using System.Xml; -using Google.ProtocolBuffers.Serialization; -using NUnit.Framework; - -namespace Google.ProtocolBuffers.Compatibility -{ - [TestFixture] - public class XmlCompatibilityTests : CompatibilityTests - { - protected override object SerializeMessage(TMessage message) - { - StringWriter text = new StringWriter(); - XmlFormatWriter writer = XmlFormatWriter.CreateInstance(text); - writer.WriteMessage("root", message); - return text.ToString(); - } - - protected override TBuilder DeserializeMessage(object message, TBuilder builder, ExtensionRegistry registry) - { - XmlFormatReader reader = XmlFormatReader.CreateInstance((string)message); - return reader.Merge("root", builder, registry); - } - } - - [TestFixture] - public class XmlCompatibilityFormattedTests : CompatibilityTests - { - protected override object SerializeMessage(TMessage message) - { - StringWriter text = new StringWriter(); - XmlWriter xwtr = XmlWriter.Create(text, new XmlWriterSettings { Indent = true, IndentChars = " " }); - - XmlFormatWriter writer = XmlFormatWriter.CreateInstance(xwtr).SetOptions(XmlWriterOptions.OutputNestedArrays); - writer.WriteMessage("root", message); - return text.ToString(); - } - - protected override TBuilder DeserializeMessage(object message, TBuilder builder, ExtensionRegistry registry) - { - XmlFormatReader reader = XmlFormatReader.CreateInstance((string)message).SetOptions(XmlReaderOptions.ReadNestedArrays); - return reader.Merge("root", builder, registry); - } - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers.Test/Compatibility/google_message1.dat b/csharp/src/ProtocolBuffers.Test/Compatibility/google_message1.dat deleted file mode 100644 index bc0f064c..00000000 Binary files a/csharp/src/ProtocolBuffers.Test/Compatibility/google_message1.dat and /dev/null differ diff --git a/csharp/src/ProtocolBuffers.Test/Compatibility/google_message2.dat b/csharp/src/ProtocolBuffers.Test/Compatibility/google_message2.dat deleted file mode 100644 index 06c09441..00000000 Binary files a/csharp/src/ProtocolBuffers.Test/Compatibility/google_message2.dat and /dev/null differ diff --git a/csharp/src/ProtocolBuffers.Test/DeprecatedMemberTest.cs b/csharp/src/ProtocolBuffers.Test/DeprecatedMemberTest.cs index db64d37a..c962df54 100644 --- a/csharp/src/ProtocolBuffers.Test/DeprecatedMemberTest.cs +++ b/csharp/src/ProtocolBuffers.Test/DeprecatedMemberTest.cs @@ -1,9 +1,9 @@ using System; using System.Reflection; -using UnitTest.Issues.TestProtos; +using Google.Protobuf.TestProtos; using NUnit.Framework; -namespace Google.ProtocolBuffers +namespace Google.Protobuf { public class DeprecatedMemberTest { @@ -16,84 +16,8 @@ namespace Google.ProtocolBuffers [Test] public void TestDepreatedPrimitiveValue() { - AssertIsDeprecated(typeof(DeprecatedFieldsMessage).GetProperty("HasPrimitiveValue")); - AssertIsDeprecated(typeof(DeprecatedFieldsMessage).GetProperty("PrimitiveValue")); - - AssertIsDeprecated(typeof(DeprecatedFieldsMessage.Builder).GetProperty("HasPrimitiveValue")); - AssertIsDeprecated(typeof(DeprecatedFieldsMessage.Builder).GetProperty("PrimitiveValue")); - AssertIsDeprecated(typeof(DeprecatedFieldsMessage.Builder).GetMethod("ClearPrimitiveValue")); - AssertIsDeprecated(typeof(DeprecatedFieldsMessage.Builder).GetMethod("SetPrimitiveValue")); - } - [Test] - public void TestDepreatedPrimitiveArray() - { - AssertIsDeprecated(typeof(DeprecatedFieldsMessage).GetProperty("PrimitiveArrayList")); - AssertIsDeprecated(typeof(DeprecatedFieldsMessage).GetProperty("PrimitiveArrayCount")); - AssertIsDeprecated(typeof(DeprecatedFieldsMessage).GetMethod("GetPrimitiveArray")); - - AssertIsDeprecated(typeof(DeprecatedFieldsMessage.Builder).GetProperty("PrimitiveArrayList")); - AssertIsDeprecated(typeof(DeprecatedFieldsMessage.Builder).GetProperty("PrimitiveArrayCount")); - AssertIsDeprecated(typeof(DeprecatedFieldsMessage.Builder).GetMethod("GetPrimitiveArray")); - AssertIsDeprecated(typeof(DeprecatedFieldsMessage.Builder).GetMethod("SetPrimitiveArray")); - AssertIsDeprecated(typeof(DeprecatedFieldsMessage.Builder).GetMethod("AddPrimitiveArray")); - AssertIsDeprecated(typeof(DeprecatedFieldsMessage.Builder).GetMethod("AddRangePrimitiveArray")); - AssertIsDeprecated(typeof(DeprecatedFieldsMessage.Builder).GetMethod("ClearPrimitiveArray")); - } - [Test] - public void TestDepreatedMessageValue() - { - AssertIsDeprecated(typeof(DeprecatedFieldsMessage).GetProperty("HasMessageValue")); - AssertIsDeprecated(typeof(DeprecatedFieldsMessage).GetProperty("MessageValue")); - - AssertIsDeprecated(typeof(DeprecatedFieldsMessage.Builder).GetProperty("HasMessageValue")); - AssertIsDeprecated(typeof(DeprecatedFieldsMessage.Builder).GetProperty("MessageValue")); - AssertIsDeprecated(typeof(DeprecatedFieldsMessage.Builder).GetMethod("MergeMessageValue")); - AssertIsDeprecated(typeof(DeprecatedFieldsMessage.Builder).GetMethod("ClearMessageValue")); - AssertIsDeprecated(typeof(DeprecatedFieldsMessage.Builder).GetMethod("SetMessageValue", new[] { typeof(DeprecatedChild) })); - AssertIsDeprecated(typeof(DeprecatedFieldsMessage.Builder).GetMethod("SetMessageValue", new[] { typeof(DeprecatedChild.Builder) })); - } - [Test] - public void TestDepreatedMessageArray() - { - AssertIsDeprecated(typeof(DeprecatedFieldsMessage).GetProperty("MessageArrayList")); - AssertIsDeprecated(typeof(DeprecatedFieldsMessage).GetProperty("MessageArrayCount")); - AssertIsDeprecated(typeof(DeprecatedFieldsMessage).GetMethod("GetMessageArray")); - - AssertIsDeprecated(typeof(DeprecatedFieldsMessage.Builder).GetProperty("MessageArrayList")); - AssertIsDeprecated(typeof(DeprecatedFieldsMessage.Builder).GetProperty("MessageArrayCount")); - AssertIsDeprecated(typeof(DeprecatedFieldsMessage.Builder).GetMethod("GetMessageArray")); - AssertIsDeprecated(typeof(DeprecatedFieldsMessage.Builder).GetMethod("SetMessageArray", new[] { typeof(int), typeof(DeprecatedChild) })); - AssertIsDeprecated(typeof(DeprecatedFieldsMessage.Builder).GetMethod("SetMessageArray", new[] { typeof(int), typeof(DeprecatedChild.Builder) })); - AssertIsDeprecated(typeof(DeprecatedFieldsMessage.Builder).GetMethod("AddMessageArray", new[] { typeof(DeprecatedChild) })); - AssertIsDeprecated(typeof(DeprecatedFieldsMessage.Builder).GetMethod("AddMessageArray", new[] { typeof(DeprecatedChild.Builder) })); - AssertIsDeprecated(typeof(DeprecatedFieldsMessage.Builder).GetMethod("AddRangeMessageArray")); - AssertIsDeprecated(typeof(DeprecatedFieldsMessage.Builder).GetMethod("ClearMessageArray")); - } - [Test] - public void TestDepreatedEnumValue() - { - AssertIsDeprecated(typeof(DeprecatedFieldsMessage).GetProperty("HasEnumValue")); - AssertIsDeprecated(typeof(DeprecatedFieldsMessage).GetProperty("EnumValue")); - - AssertIsDeprecated(typeof(DeprecatedFieldsMessage.Builder).GetProperty("HasEnumValue")); - AssertIsDeprecated(typeof(DeprecatedFieldsMessage.Builder).GetProperty("EnumValue")); - AssertIsDeprecated(typeof(DeprecatedFieldsMessage.Builder).GetMethod("ClearEnumValue")); - AssertIsDeprecated(typeof(DeprecatedFieldsMessage.Builder).GetMethod("SetEnumValue")); + AssertIsDeprecated(typeof(TestDeprecatedFields).GetProperty("DeprecatedInt32")); } - [Test] - public void TestDepreatedEnumArray() - { - AssertIsDeprecated(typeof(DeprecatedFieldsMessage).GetProperty("EnumArrayList")); - AssertIsDeprecated(typeof(DeprecatedFieldsMessage).GetProperty("EnumArrayCount")); - AssertIsDeprecated(typeof(DeprecatedFieldsMessage).GetMethod("GetEnumArray")); - AssertIsDeprecated(typeof(DeprecatedFieldsMessage.Builder).GetProperty("EnumArrayList")); - AssertIsDeprecated(typeof(DeprecatedFieldsMessage.Builder).GetProperty("EnumArrayCount")); - AssertIsDeprecated(typeof(DeprecatedFieldsMessage.Builder).GetMethod("GetEnumArray")); - AssertIsDeprecated(typeof(DeprecatedFieldsMessage.Builder).GetMethod("SetEnumArray")); - AssertIsDeprecated(typeof(DeprecatedFieldsMessage.Builder).GetMethod("AddEnumArray")); - AssertIsDeprecated(typeof(DeprecatedFieldsMessage.Builder).GetMethod("AddRangeEnumArray")); - AssertIsDeprecated(typeof(DeprecatedFieldsMessage.Builder).GetMethod("ClearEnumArray")); - } } } diff --git a/csharp/src/ProtocolBuffers.Test/DescriptorsTest.cs b/csharp/src/ProtocolBuffers.Test/DescriptorsTest.cs index 3c26f441..8c01e16a 100644 --- a/csharp/src/ProtocolBuffers.Test/DescriptorsTest.cs +++ b/csharp/src/ProtocolBuffers.Test/DescriptorsTest.cs @@ -34,11 +34,11 @@ #endregion -using Google.ProtocolBuffers.Descriptors; -using Google.ProtocolBuffers.TestProtos; +using Google.Protobuf.Descriptors; +using Google.Protobuf.TestProtos; using NUnit.Framework; -namespace Google.ProtocolBuffers +namespace Google.Protobuf { /// /// Tests for descriptors. (Not in its own namespace or broken up into individual classes as the @@ -49,21 +49,21 @@ namespace Google.ProtocolBuffers [Test] public void FileDescriptor() { - FileDescriptor file = Unittest.Descriptor; + FileDescriptor file = UnittestProto3.Descriptor; - Assert.AreEqual("google/protobuf/unittest.proto", file.Name); + Assert.AreEqual("google/protobuf/unittest_proto3.proto", file.Name); Assert.AreEqual("protobuf_unittest", file.Package); Assert.AreEqual("UnittestProto", file.Options.JavaOuterClassname); - Assert.AreEqual("google/protobuf/unittest.proto", file.Proto.Name); + Assert.AreEqual("google/protobuf/unittest_proto3.proto", file.Proto.Name); // unittest.proto doesn't have any public imports, but unittest_import.proto does. Assert.AreEqual(0, file.PublicDependencies.Count); - Assert.AreEqual(1, UnittestImport.Descriptor.PublicDependencies.Count); - Assert.AreEqual(UnittestImportPublic.Descriptor, UnittestImport.Descriptor.PublicDependencies[0]); + Assert.AreEqual(1, UnittestImportProto3.Descriptor.PublicDependencies.Count); + Assert.AreEqual(UnittestImportPublicProto3.Descriptor, UnittestImportProto3.Descriptor.PublicDependencies[0]); Assert.AreEqual(1, file.Dependencies.Count); - Assert.AreEqual(UnittestImport.Descriptor, file.Dependencies[0]); + Assert.AreEqual(UnittestImportProto3.Descriptor, file.Dependencies[0]); MessageDescriptor messageType = TestAllTypes.Descriptor; Assert.AreEqual(messageType, file.MessageTypes[0]); @@ -78,23 +78,12 @@ namespace Google.ProtocolBuffers Assert.AreEqual(file.EnumTypes[0], file.FindTypeByName("ForeignEnum")); Assert.Null(file.FindTypeByName("NoSuchType")); Assert.Null(file.FindTypeByName("protobuf_unittest.ForeignEnum")); - Assert.AreEqual(1, UnittestImport.Descriptor.EnumTypes.Count); - Assert.AreEqual("ImportEnum", UnittestImport.Descriptor.EnumTypes[0].Name); + Assert.AreEqual(1, UnittestImportProto3.Descriptor.EnumTypes.Count); + Assert.AreEqual("ImportEnum", UnittestImportProto3.Descriptor.EnumTypes[0].Name); for (int i = 0; i < file.EnumTypes.Count; i++) { Assert.AreEqual(i, file.EnumTypes[i].Index); } - - FieldDescriptor extension = Unittest.OptionalInt32Extension.Descriptor; - Assert.AreEqual(extension, file.Extensions[0]); - Assert.AreEqual(extension, file.FindTypeByName("optional_int32_extension")); - Assert.Null(file.FindTypeByName("no_such_ext")); - Assert.Null(file.FindTypeByName("protobuf_unittest.optional_int32_extension")); - Assert.AreEqual(0, UnittestImport.Descriptor.Extensions.Count); - for (int i = 0; i < file.Extensions.Count; i++) - { - Assert.AreEqual(i, file.Extensions[i].Index); - } } [Test] @@ -105,19 +94,20 @@ namespace Google.ProtocolBuffers Assert.AreEqual("TestAllTypes", messageType.Name); Assert.AreEqual("protobuf_unittest.TestAllTypes", messageType.FullName); - Assert.AreEqual(Unittest.Descriptor, messageType.File); - Assert.Null(messageType.ContainingType); - Assert.AreEqual(DescriptorProtos.MessageOptions.DefaultInstance, messageType.Options); - Assert.AreEqual("TestAllTypes", messageType.Proto.Name); + Assert.AreEqual(UnittestProto3.Descriptor, messageType.File); + Assert.IsNull(messageType.ContainingType); + Assert.IsNull(messageType.Options); + + Assert.AreEqual("TestAllTypes", messageType.Name); Assert.AreEqual("NestedMessage", nestedType.Name); Assert.AreEqual("protobuf_unittest.TestAllTypes.NestedMessage", nestedType.FullName); - Assert.AreEqual(Unittest.Descriptor, nestedType.File); + Assert.AreEqual(UnittestProto3.Descriptor, nestedType.File); Assert.AreEqual(messageType, nestedType.ContainingType); FieldDescriptor field = messageType.Fields[0]; - Assert.AreEqual("optional_int32", field.Name); - Assert.AreEqual(field, messageType.FindDescriptor("optional_int32")); + Assert.AreEqual("single_int32", field.Name); + Assert.AreEqual(field, messageType.FindDescriptor("single_int32")); Assert.Null(messageType.FindDescriptor("no_such_field")); Assert.AreEqual(field, messageType.FindFieldByNumber(1)); Assert.Null(messageType.FindFieldByNumber(571283)); @@ -146,115 +136,66 @@ namespace Google.ProtocolBuffers public void FieldDescriptor() { MessageDescriptor messageType = TestAllTypes.Descriptor; - FieldDescriptor primitiveField = messageType.FindDescriptor("optional_int32"); - FieldDescriptor enumField = messageType.FindDescriptor("optional_nested_enum"); - FieldDescriptor messageField = messageType.FindDescriptor("optional_foreign_message"); - FieldDescriptor cordField = messageType.FindDescriptor("optional_cord"); - FieldDescriptor extension = Unittest.OptionalInt32Extension.Descriptor; - FieldDescriptor nestedExtension = TestRequired.Single.Descriptor; + FieldDescriptor primitiveField = messageType.FindDescriptor("single_int32"); + FieldDescriptor enumField = messageType.FindDescriptor("single_nested_enum"); + FieldDescriptor messageField = messageType.FindDescriptor("single_foreign_message"); - Assert.AreEqual("optional_int32", primitiveField.Name); - Assert.AreEqual("protobuf_unittest.TestAllTypes.optional_int32", + Assert.AreEqual("single_int32", primitiveField.Name); + Assert.AreEqual("protobuf_unittest.TestAllTypes.single_int32", primitiveField.FullName); Assert.AreEqual(1, primitiveField.FieldNumber); Assert.AreEqual(messageType, primitiveField.ContainingType); - Assert.AreEqual(Unittest.Descriptor, primitiveField.File); + Assert.AreEqual(UnittestProto3.Descriptor, primitiveField.File); Assert.AreEqual(FieldType.Int32, primitiveField.FieldType); Assert.AreEqual(MappedType.Int32, primitiveField.MappedType); - Assert.AreEqual(DescriptorProtos.FieldOptions.DefaultInstance, primitiveField.Options); - Assert.IsFalse(primitiveField.IsExtension); - Assert.AreEqual("optional_int32", primitiveField.Proto.Name); - - Assert.AreEqual("optional_nested_enum", enumField.Name); + Assert.IsNull(primitiveField.Options); + + Assert.AreEqual("single_nested_enum", enumField.Name); Assert.AreEqual(FieldType.Enum, enumField.FieldType); Assert.AreEqual(MappedType.Enum, enumField.MappedType); // Assert.AreEqual(TestAllTypes.Types.NestedEnum.DescriptorProtoFile, enumField.EnumType); - Assert.AreEqual("optional_foreign_message", messageField.Name); + Assert.AreEqual("single_foreign_message", messageField.Name); Assert.AreEqual(FieldType.Message, messageField.FieldType); Assert.AreEqual(MappedType.Message, messageField.MappedType); Assert.AreEqual(ForeignMessage.Descriptor, messageField.MessageType); - - Assert.AreEqual("optional_cord", cordField.Name); - Assert.AreEqual(FieldType.String, cordField.FieldType); - Assert.AreEqual(MappedType.String, cordField.MappedType); - Assert.AreEqual(DescriptorProtos.FieldOptions.Types.CType.CORD, cordField.Options.Ctype); - - Assert.AreEqual("optional_int32_extension", extension.Name); - Assert.AreEqual("protobuf_unittest.optional_int32_extension", extension.FullName); - Assert.AreEqual(1, extension.FieldNumber); - Assert.AreEqual(TestAllExtensions.Descriptor, extension.ContainingType); - Assert.AreEqual(Unittest.Descriptor, extension.File); - Assert.AreEqual(FieldType.Int32, extension.FieldType); - Assert.AreEqual(MappedType.Int32, extension.MappedType); - Assert.AreEqual(DescriptorProtos.FieldOptions.DefaultInstance, - extension.Options); - Assert.IsTrue(extension.IsExtension); - Assert.AreEqual(null, extension.ExtensionScope); - Assert.AreEqual("optional_int32_extension", extension.Proto.Name); - - Assert.AreEqual("single", nestedExtension.Name); - Assert.AreEqual("protobuf_unittest.TestRequired.single", - nestedExtension.FullName); - Assert.AreEqual(TestRequired.Descriptor, - nestedExtension.ExtensionScope); } [Test] public void FieldDescriptorLabel() { - FieldDescriptor requiredField = - TestRequired.Descriptor.FindDescriptor("a"); - FieldDescriptor optionalField = - TestAllTypes.Descriptor.FindDescriptor("optional_int32"); + FieldDescriptor singleField = + TestAllTypes.Descriptor.FindDescriptor("single_int32"); FieldDescriptor repeatedField = TestAllTypes.Descriptor.FindDescriptor("repeated_int32"); - Assert.IsTrue(requiredField.IsRequired); - Assert.IsFalse(requiredField.IsRepeated); - Assert.IsFalse(optionalField.IsRequired); - Assert.IsFalse(optionalField.IsRepeated); + Assert.IsFalse(singleField.IsRequired); + Assert.IsFalse(singleField.IsRepeated); Assert.IsFalse(repeatedField.IsRequired); Assert.IsTrue(repeatedField.IsRepeated); } - [Test] - public void FieldDescriptorDefault() - { - MessageDescriptor d = TestAllTypes.Descriptor; - Assert.IsFalse(d.FindDescriptor("optional_int32").HasDefaultValue); - Assert.AreEqual(0, d.FindDescriptor("optional_int32").DefaultValue); - Assert.IsTrue(d.FindDescriptor("default_int32").HasDefaultValue); - Assert.AreEqual(41, d.FindDescriptor("default_int32").DefaultValue); - - d = TestExtremeDefaultValues.Descriptor; - Assert.AreEqual(TestExtremeDefaultValues.DefaultInstance.EscapedBytes, - d.FindDescriptor("escaped_bytes").DefaultValue); - Assert.AreEqual(uint.MaxValue, d.FindDescriptor("large_uint32").DefaultValue); - Assert.AreEqual(ulong.MaxValue, d.FindDescriptor("large_uint64").DefaultValue); - } [Test] public void EnumDescriptor() { // Note: this test is a bit different to the Java version because there's no static way of getting to the descriptor - EnumDescriptor enumType = Unittest.Descriptor.FindTypeByName("ForeignEnum"); + EnumDescriptor enumType = UnittestProto3.Descriptor.FindTypeByName("ForeignEnum"); EnumDescriptor nestedType = TestAllTypes.Descriptor.FindDescriptor("NestedEnum"); Assert.AreEqual("ForeignEnum", enumType.Name); Assert.AreEqual("protobuf_unittest.ForeignEnum", enumType.FullName); - Assert.AreEqual(Unittest.Descriptor, enumType.File); + Assert.AreEqual(UnittestProto3.Descriptor, enumType.File); Assert.Null(enumType.ContainingType); - Assert.AreEqual(DescriptorProtos.EnumOptions.DefaultInstance, - enumType.Options); + Assert.Null(enumType.Options); Assert.AreEqual("NestedEnum", nestedType.Name); Assert.AreEqual("protobuf_unittest.TestAllTypes.NestedEnum", nestedType.FullName); - Assert.AreEqual(Unittest.Descriptor, nestedType.File); + Assert.AreEqual(UnittestProto3.Descriptor, nestedType.File); Assert.AreEqual(TestAllTypes.Descriptor, nestedType.ContainingType); EnumValueDescriptor value = enumType.FindValueByName("FOREIGN_FOO"); - Assert.AreEqual(value, enumType.Values[0]); + Assert.AreEqual(value, enumType.Values[1]); Assert.AreEqual("FOREIGN_FOO", value.Name); Assert.AreEqual(4, value.Number); Assert.AreEqual((int) ForeignEnum.FOREIGN_FOO, value.Number); @@ -265,22 +206,5 @@ namespace Google.ProtocolBuffers Assert.AreEqual(i, enumType.Values[i].Index); } } - - - [Test] - public void CustomOptions() - { - MessageDescriptor descriptor = TestMessageWithCustomOptions.Descriptor; - Assert.IsTrue(descriptor.Options.HasExtension(UnittestCustomOptions.MessageOpt1)); - Assert.AreEqual(-56, descriptor.Options.GetExtension(UnittestCustomOptions.MessageOpt1)); - - - FieldDescriptor field = descriptor.FindFieldByName("field1"); - Assert.NotNull(field); - - Assert.IsTrue(field.Options.HasExtension(UnittestCustomOptions.FieldOpt1)); - Assert.AreEqual(8765432109uL, field.Options.GetExtension(UnittestCustomOptions.FieldOpt1)); - - } } } \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers.Test/DynamicMessageTest.cs b/csharp/src/ProtocolBuffers.Test/DynamicMessageTest.cs deleted file mode 100644 index f60db213..00000000 --- a/csharp/src/ProtocolBuffers.Test/DynamicMessageTest.cs +++ /dev/null @@ -1,276 +0,0 @@ -#region Copyright notice and license - -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/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.Collections.Generic; -using Google.ProtocolBuffers.Descriptors; -using Google.ProtocolBuffers.TestProtos; -using NUnit.Framework; - -namespace Google.ProtocolBuffers -{ - public class DynamicMessageTest - { - private ReflectionTester reflectionTester; - private ReflectionTester extensionsReflectionTester; - private ReflectionTester packedReflectionTester; - - public DynamicMessageTest() - { - reflectionTester = ReflectionTester.CreateTestAllTypesInstance(); - extensionsReflectionTester = ReflectionTester.CreateTestAllExtensionsInstance(); - packedReflectionTester = ReflectionTester.CreateTestPackedTypesInstance(); - } - - [Test] - public void DynamicMessageAccessors() - { - IBuilder builder = DynamicMessage.CreateBuilder(TestAllTypes.Descriptor); - reflectionTester.SetAllFieldsViaReflection(builder); - IMessage message = builder.WeakBuild(); - reflectionTester.AssertAllFieldsSetViaReflection(message); - } - - [Test] - public void DoubleBuildError() - { - DynamicMessage.Builder builder = DynamicMessage.CreateBuilder(TestAllTypes.Descriptor); - builder.Build(); - Assert.Throws(() => builder.Build()); - } - - [Test] - public void DynamicMessageSettersRejectNull() - { - IBuilder builder = DynamicMessage.CreateBuilder(TestAllTypes.Descriptor); - reflectionTester.AssertReflectionSettersRejectNull(builder); - } - - [Test] - public void DynamicMessageExtensionAccessors() - { - // We don't need to extensively test DynamicMessage's handling of - // extensions because, frankly, it doesn't do anything special with them. - // It treats them just like any other fields. - IBuilder builder = DynamicMessage.CreateBuilder(TestAllExtensions.Descriptor); - extensionsReflectionTester.SetAllFieldsViaReflection(builder); - IMessage message = builder.WeakBuild(); - extensionsReflectionTester.AssertAllFieldsSetViaReflection(message); - } - - [Test] - public void DynamicMessageExtensionSettersRejectNull() - { - IBuilder builder = DynamicMessage.CreateBuilder(TestAllExtensions.Descriptor); - extensionsReflectionTester.AssertReflectionSettersRejectNull(builder); - } - - [Test] - public void DynamicMessageRepeatedSetters() - { - IBuilder builder = DynamicMessage.CreateBuilder(TestAllTypes.Descriptor); - reflectionTester.SetAllFieldsViaReflection(builder); - reflectionTester.ModifyRepeatedFieldsViaReflection(builder); - IMessage message = builder.WeakBuild(); - reflectionTester.AssertRepeatedFieldsModifiedViaReflection(message); - } - - [Test] - public void DynamicMessageRepeatedSettersRejectNull() - { - IBuilder builder = DynamicMessage.CreateBuilder(TestAllTypes.Descriptor); - reflectionTester.AssertReflectionRepeatedSettersRejectNull(builder); - } - - [Test] - public void DynamicMessageDefaults() - { - reflectionTester.AssertClearViaReflection(DynamicMessage.GetDefaultInstance(TestAllTypes.Descriptor)); - reflectionTester.AssertClearViaReflection(DynamicMessage.CreateBuilder(TestAllTypes.Descriptor).Build()); - } - - [Test] - public void DynamicMessageSerializedSize() - { - TestAllTypes message = TestUtil.GetAllSet(); - - IBuilder dynamicBuilder = DynamicMessage.CreateBuilder(TestAllTypes.Descriptor); - reflectionTester.SetAllFieldsViaReflection(dynamicBuilder); - IMessage dynamicMessage = dynamicBuilder.WeakBuild(); - - Assert.AreEqual(message.SerializedSize, dynamicMessage.SerializedSize); - } - - [Test] - public void DynamicMessageSerialization() - { - IBuilder builder = DynamicMessage.CreateBuilder(TestAllTypes.Descriptor); - reflectionTester.SetAllFieldsViaReflection(builder); - IMessage message = builder.WeakBuild(); - - ByteString rawBytes = message.ToByteString(); - TestAllTypes message2 = TestAllTypes.ParseFrom(rawBytes); - - TestUtil.AssertAllFieldsSet(message2); - - // In fact, the serialized forms should be exactly the same, byte-for-byte. - Assert.AreEqual(TestUtil.GetAllSet().ToByteString(), rawBytes); - } - - [Test] - public void DynamicMessageParsing() - { - TestAllTypes.Builder builder = TestAllTypes.CreateBuilder(); - TestUtil.SetAllFields(builder); - TestAllTypes message = builder.Build(); - - ByteString rawBytes = message.ToByteString(); - - IMessage message2 = DynamicMessage.ParseFrom(TestAllTypes.Descriptor, rawBytes); - reflectionTester.AssertAllFieldsSetViaReflection(message2); - } - - [Test] - public void DynamicMessagePackedSerialization() - { - IBuilder builder = DynamicMessage.CreateBuilder(TestPackedTypes.Descriptor); - packedReflectionTester.SetPackedFieldsViaReflection(builder); - IMessage message = builder.WeakBuild(); - - ByteString rawBytes = message.ToByteString(); - TestPackedTypes message2 = TestPackedTypes.ParseFrom(rawBytes); - - TestUtil.AssertPackedFieldsSet(message2); - - // In fact, the serialized forms should be exactly the same, byte-for-byte. - Assert.AreEqual(TestUtil.GetPackedSet().ToByteString(), rawBytes); - } - - [Test] - public void DynamicMessagePackedParsing() - { - TestPackedTypes.Builder builder = TestPackedTypes.CreateBuilder(); - TestUtil.SetPackedFields(builder); - TestPackedTypes message = builder.Build(); - - ByteString rawBytes = message.ToByteString(); - - IMessage message2 = DynamicMessage.ParseFrom(TestPackedTypes.Descriptor, rawBytes); - packedReflectionTester.AssertPackedFieldsSetViaReflection(message2); - } - - [Test] - public void DynamicMessageCopy() - { - TestAllTypes.Builder builder = TestAllTypes.CreateBuilder(); - TestUtil.SetAllFields(builder); - TestAllTypes message = builder.Build(); - - DynamicMessage copy = DynamicMessage.CreateBuilder(message).Build(); - reflectionTester.AssertAllFieldsSetViaReflection(copy); - - // Oneof - FieldDescriptor bytesField = - TestAllTypes.Descriptor.FindFieldByName("oneof_bytes"); - FieldDescriptor uint32Field = - TestAllTypes.Descriptor.FindFieldByName("oneof_uint32"); - Assert.True(copy.HasField(bytesField)); - Assert.False(copy.HasField(uint32Field)); - - DynamicMessage.Builder dynamicBuilder = DynamicMessage.CreateBuilder(message); - dynamicBuilder[uint32Field] = 123U; - DynamicMessage copy2 = dynamicBuilder.Build(); - Assert.IsFalse(copy2.HasField(bytesField)); - Assert.IsTrue(copy2.HasField(uint32Field)); - Assert.AreEqual(123U, copy2[uint32Field]); - } - - [Test] - public void ToBuilder() - { - DynamicMessage.Builder builder = - DynamicMessage.CreateBuilder(TestAllTypes.Descriptor); - reflectionTester.SetAllFieldsViaReflection(builder); - int unknownFieldNum = 9; - ulong unknownFieldVal = 90; - builder.SetUnknownFields(UnknownFieldSet.CreateBuilder() - .AddField(unknownFieldNum, - UnknownField.CreateBuilder().AddVarint(unknownFieldVal).Build()) - .Build()); - DynamicMessage message = builder.Build(); - - DynamicMessage derived = message.ToBuilder().Build(); - reflectionTester.AssertAllFieldsSetViaReflection(derived); - - IList values = derived.UnknownFields.FieldDictionary[unknownFieldNum].VarintList; - Assert.AreEqual(1, values.Count); - Assert.AreEqual(unknownFieldVal, values[0]); - } - - [Test] - public void DynamicOneofMessage() - { - DynamicMessage.Builder builder = - DynamicMessage.CreateBuilder(TestAllTypes.Descriptor); - OneofDescriptor oneof = TestAllTypes.Descriptor.Oneofs[0]; - Assert.False(builder.HasOneof(oneof)); - Assert.AreSame(null, builder.OneofFieldDescriptor(oneof)); - - reflectionTester.SetAllFieldsViaReflection(builder); - Assert.True(builder.HasOneof(oneof)); - FieldDescriptor field = oneof.Field(3); - Assert.AreSame(field, builder.OneofFieldDescriptor(oneof)); - Assert.AreEqual(TestUtil.ToBytes("604"), builder[field]); - - DynamicMessage message = builder.BuildPartial(); - Assert.IsTrue(message.HasOneof(oneof)); - - DynamicMessage.Builder mergedBuilder = - DynamicMessage.CreateBuilder(TestAllTypes.Descriptor); - FieldDescriptor mergedField = oneof.Field(0); - mergedBuilder[mergedField] = 123U; - Assert.IsTrue(mergedBuilder.HasField(mergedField)); - mergedBuilder.MergeFrom(message); - Assert.IsTrue(mergedBuilder.HasField(field)); - Assert.IsFalse(mergedBuilder.HasField(mergedField)); - - mergedBuilder.ClearOneof(oneof); - Assert.AreSame(null, mergedBuilder.OneofFieldDescriptor(oneof)); - message = mergedBuilder.Build(); - Assert.AreSame(null, message.OneofFieldDescriptor(oneof)); - } - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers.Test/ExtendableMessageTest.cs b/csharp/src/ProtocolBuffers.Test/ExtendableMessageTest.cs deleted file mode 100644 index 2aaf39c8..00000000 --- a/csharp/src/ProtocolBuffers.Test/ExtendableMessageTest.cs +++ /dev/null @@ -1,200 +0,0 @@ -#region Copyright notice and license - -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/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 Google.ProtocolBuffers.TestProtos; -using NUnit.Framework; - -namespace Google.ProtocolBuffers -{ - public class ExtendableMessageTest - { - [Test] - public void ExtensionWriterInvalidExtension() - { - Assert.Throws(() => - TestPackedExtensions.CreateBuilder()[Unittest.OptionalForeignMessageExtension.Descriptor] = - ForeignMessage.DefaultInstance); - } - - [Test] - public void ExtensionWriterTest() - { - TestAllExtensions.Builder builder = TestAllExtensions.CreateBuilder() - .SetExtension(Unittest.DefaultBoolExtension, true) - .SetExtension(Unittest.DefaultBytesExtension, ByteString.CopyFromUtf8("123")) - .SetExtension(Unittest.DefaultCordExtension, "123") - .SetExtension(Unittest.DefaultDoubleExtension, 123) - .SetExtension(Unittest.DefaultFixed32Extension, 123u) - .SetExtension(Unittest.DefaultFixed64Extension, 123u) - .SetExtension(Unittest.DefaultFloatExtension, 123) - .SetExtension(Unittest.DefaultForeignEnumExtension, ForeignEnum.FOREIGN_BAZ) - .SetExtension(Unittest.DefaultImportEnumExtension, ImportEnum.IMPORT_BAZ) - .SetExtension(Unittest.DefaultInt32Extension, 123) - .SetExtension(Unittest.DefaultInt64Extension, 123) - .SetExtension(Unittest.DefaultNestedEnumExtension, TestAllTypes.Types.NestedEnum.FOO) - .SetExtension(Unittest.DefaultSfixed32Extension, 123) - .SetExtension(Unittest.DefaultSfixed64Extension, 123) - .SetExtension(Unittest.DefaultSint32Extension, 123) - .SetExtension(Unittest.DefaultSint64Extension, 123) - .SetExtension(Unittest.DefaultStringExtension, "123") - .SetExtension(Unittest.DefaultStringPieceExtension, "123") - .SetExtension(Unittest.DefaultUint32Extension, 123u) - .SetExtension(Unittest.DefaultUint64Extension, 123u) - //Optional - .SetExtension(Unittest.OptionalBoolExtension, true) - .SetExtension(Unittest.OptionalBytesExtension, ByteString.CopyFromUtf8("123")) - .SetExtension(Unittest.OptionalCordExtension, "123") - .SetExtension(Unittest.OptionalDoubleExtension, 123) - .SetExtension(Unittest.OptionalFixed32Extension, 123u) - .SetExtension(Unittest.OptionalFixed64Extension, 123u) - .SetExtension(Unittest.OptionalFloatExtension, 123) - .SetExtension(Unittest.OptionalForeignEnumExtension, ForeignEnum.FOREIGN_BAZ) - .SetExtension(Unittest.OptionalImportEnumExtension, ImportEnum.IMPORT_BAZ) - .SetExtension(Unittest.OptionalInt32Extension, 123) - .SetExtension(Unittest.OptionalInt64Extension, 123) - .SetExtension(Unittest.OptionalNestedEnumExtension, TestAllTypes.Types.NestedEnum.FOO) - .SetExtension(Unittest.OptionalSfixed32Extension, 123) - .SetExtension(Unittest.OptionalSfixed64Extension, 123) - .SetExtension(Unittest.OptionalSint32Extension, 123) - .SetExtension(Unittest.OptionalSint64Extension, 123) - .SetExtension(Unittest.OptionalStringExtension, "123") - .SetExtension(Unittest.OptionalStringPieceExtension, "123") - .SetExtension(Unittest.OptionalUint32Extension, 123u) - .SetExtension(Unittest.OptionalUint64Extension, 123u) - //Repeated - .AddExtension(Unittest.RepeatedBoolExtension, true) - .AddExtension(Unittest.RepeatedBytesExtension, ByteString.CopyFromUtf8("123")) - .AddExtension(Unittest.RepeatedCordExtension, "123") - .AddExtension(Unittest.RepeatedDoubleExtension, 123) - .AddExtension(Unittest.RepeatedFixed32Extension, 123u) - .AddExtension(Unittest.RepeatedFixed64Extension, 123u) - .AddExtension(Unittest.RepeatedFloatExtension, 123) - .AddExtension(Unittest.RepeatedForeignEnumExtension, ForeignEnum.FOREIGN_BAZ) - .AddExtension(Unittest.RepeatedImportEnumExtension, ImportEnum.IMPORT_BAZ) - .AddExtension(Unittest.RepeatedInt32Extension, 123) - .AddExtension(Unittest.RepeatedInt64Extension, 123) - .AddExtension(Unittest.RepeatedNestedEnumExtension, TestAllTypes.Types.NestedEnum.FOO) - .AddExtension(Unittest.RepeatedSfixed32Extension, 123) - .AddExtension(Unittest.RepeatedSfixed64Extension, 123) - .AddExtension(Unittest.RepeatedSint32Extension, 123) - .AddExtension(Unittest.RepeatedSint64Extension, 123) - .AddExtension(Unittest.RepeatedStringExtension, "123") - .AddExtension(Unittest.RepeatedStringPieceExtension, "123") - .AddExtension(Unittest.RepeatedUint32Extension, 123u) - .AddExtension(Unittest.RepeatedUint64Extension, 123u) - ; - TestAllExtensions msg = builder.Build(); - - ExtensionRegistry registry = ExtensionRegistry.CreateInstance(); - Unittest.RegisterAllExtensions(registry); - - TestAllExtensions.Builder copyBuilder = TestAllExtensions.CreateBuilder().MergeFrom(msg.ToByteArray(), - registry); - TestAllExtensions copy = copyBuilder.Build(); - - Assert.AreEqual(msg.ToByteArray(), copy.ToByteArray()); - - Assert.AreEqual(true, copy.GetExtension(Unittest.DefaultBoolExtension)); - Assert.AreEqual(ByteString.CopyFromUtf8("123"), copy.GetExtension(Unittest.DefaultBytesExtension)); - Assert.AreEqual("123", copy.GetExtension(Unittest.DefaultCordExtension)); - Assert.AreEqual(123, copy.GetExtension(Unittest.DefaultDoubleExtension)); - Assert.AreEqual(123u, copy.GetExtension(Unittest.DefaultFixed32Extension)); - Assert.AreEqual(123u, copy.GetExtension(Unittest.DefaultFixed64Extension)); - Assert.AreEqual(123, copy.GetExtension(Unittest.DefaultFloatExtension)); - Assert.AreEqual(ForeignEnum.FOREIGN_BAZ, copy.GetExtension(Unittest.DefaultForeignEnumExtension)); - Assert.AreEqual(ImportEnum.IMPORT_BAZ, copy.GetExtension(Unittest.DefaultImportEnumExtension)); - Assert.AreEqual(123, copy.GetExtension(Unittest.DefaultInt32Extension)); - Assert.AreEqual(123, copy.GetExtension(Unittest.DefaultInt64Extension)); - Assert.AreEqual(TestAllTypes.Types.NestedEnum.FOO, - copy.GetExtension(Unittest.DefaultNestedEnumExtension)); - Assert.AreEqual(123, copy.GetExtension(Unittest.DefaultSfixed32Extension)); - Assert.AreEqual(123, copy.GetExtension(Unittest.DefaultSfixed64Extension)); - Assert.AreEqual(123, copy.GetExtension(Unittest.DefaultSint32Extension)); - Assert.AreEqual(123, copy.GetExtension(Unittest.DefaultSint64Extension)); - Assert.AreEqual("123", copy.GetExtension(Unittest.DefaultStringExtension)); - Assert.AreEqual("123", copy.GetExtension(Unittest.DefaultStringPieceExtension)); - Assert.AreEqual(123u, copy.GetExtension(Unittest.DefaultUint32Extension)); - Assert.AreEqual(123u, copy.GetExtension(Unittest.DefaultUint64Extension)); - - Assert.AreEqual(true, copy.GetExtension(Unittest.OptionalBoolExtension)); - Assert.AreEqual(ByteString.CopyFromUtf8("123"), copy.GetExtension(Unittest.OptionalBytesExtension)); - Assert.AreEqual("123", copy.GetExtension(Unittest.OptionalCordExtension)); - Assert.AreEqual(123, copy.GetExtension(Unittest.OptionalDoubleExtension)); - Assert.AreEqual(123u, copy.GetExtension(Unittest.OptionalFixed32Extension)); - Assert.AreEqual(123u, copy.GetExtension(Unittest.OptionalFixed64Extension)); - Assert.AreEqual(123, copy.GetExtension(Unittest.OptionalFloatExtension)); - Assert.AreEqual(ForeignEnum.FOREIGN_BAZ, copy.GetExtension(Unittest.OptionalForeignEnumExtension)); - Assert.AreEqual(ImportEnum.IMPORT_BAZ, copy.GetExtension(Unittest.OptionalImportEnumExtension)); - Assert.AreEqual(123, copy.GetExtension(Unittest.OptionalInt32Extension)); - Assert.AreEqual(123, copy.GetExtension(Unittest.OptionalInt64Extension)); - Assert.AreEqual(TestAllTypes.Types.NestedEnum.FOO, - copy.GetExtension(Unittest.OptionalNestedEnumExtension)); - Assert.AreEqual(123, copy.GetExtension(Unittest.OptionalSfixed32Extension)); - Assert.AreEqual(123, copy.GetExtension(Unittest.OptionalSfixed64Extension)); - Assert.AreEqual(123, copy.GetExtension(Unittest.OptionalSint32Extension)); - Assert.AreEqual(123, copy.GetExtension(Unittest.OptionalSint64Extension)); - Assert.AreEqual("123", copy.GetExtension(Unittest.OptionalStringExtension)); - Assert.AreEqual("123", copy.GetExtension(Unittest.OptionalStringPieceExtension)); - Assert.AreEqual(123u, copy.GetExtension(Unittest.OptionalUint32Extension)); - Assert.AreEqual(123u, copy.GetExtension(Unittest.OptionalUint64Extension)); - - Assert.AreEqual(true, copy.GetExtension(Unittest.RepeatedBoolExtension, 0)); - Assert.AreEqual(ByteString.CopyFromUtf8("123"), - copy.GetExtension(Unittest.RepeatedBytesExtension, 0)); - Assert.AreEqual("123", copy.GetExtension(Unittest.RepeatedCordExtension, 0)); - Assert.AreEqual(123, copy.GetExtension(Unittest.RepeatedDoubleExtension, 0)); - Assert.AreEqual(123u, copy.GetExtension(Unittest.RepeatedFixed32Extension, 0)); - Assert.AreEqual(123u, copy.GetExtension(Unittest.RepeatedFixed64Extension, 0)); - Assert.AreEqual(123, copy.GetExtension(Unittest.RepeatedFloatExtension, 0)); - Assert.AreEqual(ForeignEnum.FOREIGN_BAZ, - copy.GetExtension(Unittest.RepeatedForeignEnumExtension, 0)); - Assert.AreEqual(ImportEnum.IMPORT_BAZ, copy.GetExtension(Unittest.RepeatedImportEnumExtension, 0)); - Assert.AreEqual(123, copy.GetExtension(Unittest.RepeatedInt32Extension, 0)); - Assert.AreEqual(123, copy.GetExtension(Unittest.RepeatedInt64Extension, 0)); - Assert.AreEqual(TestAllTypes.Types.NestedEnum.FOO, - copy.GetExtension(Unittest.RepeatedNestedEnumExtension, 0)); - Assert.AreEqual(123, copy.GetExtension(Unittest.RepeatedSfixed32Extension, 0)); - Assert.AreEqual(123, copy.GetExtension(Unittest.RepeatedSfixed64Extension, 0)); - Assert.AreEqual(123, copy.GetExtension(Unittest.RepeatedSint32Extension, 0)); - Assert.AreEqual(123, copy.GetExtension(Unittest.RepeatedSint64Extension, 0)); - Assert.AreEqual("123", copy.GetExtension(Unittest.RepeatedStringExtension, 0)); - Assert.AreEqual("123", copy.GetExtension(Unittest.RepeatedStringPieceExtension, 0)); - Assert.AreEqual(123u, copy.GetExtension(Unittest.RepeatedUint32Extension, 0)); - Assert.AreEqual(123u, copy.GetExtension(Unittest.RepeatedUint64Extension, 0)); - } - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers.Test/FieldPresenceTest.cs b/csharp/src/ProtocolBuffers.Test/FieldPresenceTest.cs deleted file mode 100644 index 66214221..00000000 --- a/csharp/src/ProtocolBuffers.Test/FieldPresenceTest.cs +++ /dev/null @@ -1,198 +0,0 @@ -#region Copyright notice and license - -// Protocol Buffers - Google's data interchange format -// Copyright 2015 Google Inc. All rights reserved. -// Author: jieluo@google.com (Jie Luo) -// -// 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 -// 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 Google.ProtocolBuffers.Descriptors; -using Google.ProtocolBuffers.TestProtos.Proto3; -using NUnit.Framework; - -namespace Google.ProtocolBuffers -{ - public class FieldPresenceTest - { - private void CheckHasMethodRemoved(Type proto2Type, Type proto3Type, string name) - { - Assert.NotNull(proto2Type.GetProperty(name)); - Assert.NotNull(proto2Type.GetProperty("Has" + name)); - Assert.NotNull(proto3Type.GetProperty(name)); - Assert.Null(proto3Type.GetProperty("Has" + name)); - } - - [Test] - public void TestHasMethod() - { - // Optional non-message fields don't have HasFoo method generated - Type proto2Type = typeof(Google.ProtocolBuffers.TestProtos.TestAllTypes); - Type proto3Type = typeof(TestAllTypes); - CheckHasMethodRemoved(proto2Type, proto3Type, "OptionalInt32"); - CheckHasMethodRemoved(proto2Type, proto3Type, "OptionalString"); - CheckHasMethodRemoved(proto2Type, proto3Type, "OptionalBytes"); - CheckHasMethodRemoved(proto2Type, proto3Type, "OptionalNestedEnum"); - - Type proto2BuilderType = typeof(Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder); - Type proto3BuilderType = typeof(TestAllTypes.Builder); - CheckHasMethodRemoved(proto2BuilderType, proto3BuilderType, "OptionalInt32"); - CheckHasMethodRemoved(proto2BuilderType, proto3BuilderType, "OptionalString"); - CheckHasMethodRemoved(proto2BuilderType, proto3BuilderType, "OptionalBytes"); - CheckHasMethodRemoved(proto2BuilderType, proto3BuilderType, "OptionalNestedEnum"); - - // message fields still have the HasFoo method generated - Assert.IsFalse(TestAllTypes.CreateBuilder().Build().HasOptionalNestedMessage); - Assert.IsFalse(TestAllTypes.CreateBuilder().HasOptionalNestedMessage); - - // oneof fields don't have the HasFoo method (even for message types) - CheckHasMethodRemoved(proto2Type, proto3Type, "OneofUint32"); - CheckHasMethodRemoved(proto2Type, proto3Type, "OneofString"); - CheckHasMethodRemoved(proto2Type, proto3Type, "OneofNestedMessage"); - - CheckHasMethodRemoved(proto2BuilderType, proto3BuilderType, "OneofUint32"); - CheckHasMethodRemoved(proto2BuilderType, proto3BuilderType, "OneofString"); - CheckHasMethodRemoved(proto2BuilderType, proto3BuilderType, "OneofNestedMessage"); - } - - [Test] - public void TestFieldPresence() - { - // Optional non-message fields set to their default value are treated the same - // way as not set. - - // Serialization will ignore such fields. - TestAllTypes.Builder builder = TestAllTypes.CreateBuilder(); - builder.SetOptionalInt32(0); - builder.SetOptionalString(""); - builder.SetOptionalBytes(ByteString.Empty); - builder.SetOptionalNestedEnum(TestAllTypes.Types.NestedEnum.FOO); - TestAllTypes message = builder.Build(); - Assert.AreEqual(0, message.SerializedSize); - - // Test merge - TestAllTypes.Builder a = TestAllTypes.CreateBuilder(); - a.SetOptionalInt32(1); - a.SetOptionalString("x"); - a.SetOptionalBytes(ByteString.CopyFromUtf8("y")); - a.SetOptionalNestedEnum(TestAllTypes.Types.NestedEnum.BAR); - a.MergeFrom(message); - TestAllTypes messageA = a.Build(); - Assert.AreEqual(1, messageA.OptionalInt32); - Assert.AreEqual("x", messageA.OptionalString); - Assert.AreEqual(ByteString.CopyFromUtf8("y"), messageA.OptionalBytes); - Assert.AreEqual(TestAllTypes.Types.NestedEnum.BAR, messageA.OptionalNestedEnum); - - // equals/hashCode should produce the same results - TestAllTypes empty = TestAllTypes.CreateBuilder().Build(); - Assert.IsTrue(empty.Equals(message)); - Assert.IsTrue(message.Equals(empty)); - Assert.AreEqual(empty.GetHashCode(), message.GetHashCode()); - } - - [Test] - public void TestFieldPresenceReflection() - { - MessageDescriptor descriptor = TestAllTypes.Descriptor; - FieldDescriptor optionalInt32Field = descriptor.FindFieldByName("optional_int32"); - FieldDescriptor optionalStringField = descriptor.FindFieldByName("optional_string"); - FieldDescriptor optionalBytesField = descriptor.FindFieldByName("optional_bytes"); - FieldDescriptor optionalNestedEnumField = descriptor.FindFieldByName("optional_nested_enum"); - FieldDescriptor oneofUint32Field = descriptor.FindFieldByName("oneof_uint32"); - - TestAllTypes message = TestAllTypes.CreateBuilder().Build(); - Assert.IsFalse(message.HasField(optionalInt32Field)); - Assert.IsFalse(message.HasField(optionalStringField)); - Assert.IsFalse(message.HasField(optionalBytesField)); - Assert.IsFalse(message.HasField(optionalNestedEnumField)); - - // Set to default value is seen as not present for optional fields. - // Set to default value is seen as present for oneof fields. - message = TestAllTypes.CreateBuilder() - .SetOptionalInt32(0) - .SetOptionalString("") - .SetOptionalBytes(ByteString.Empty) - .SetOptionalNestedEnum(TestAllTypes.Types.NestedEnum.FOO) - .SetOneofUint32(0U) - .Build(); - Assert.IsFalse(message.HasField(optionalInt32Field)); - Assert.IsFalse(message.HasField(optionalStringField)); - Assert.IsFalse(message.HasField(optionalBytesField)); - Assert.IsFalse(message.HasField(optionalNestedEnumField)); - Assert.IsTrue(message.HasField(oneofUint32Field)); - Assert.AreEqual(1, message.AllFields.Count); - - // Set to non-defalut value is seen as present - message = TestAllTypes.CreateBuilder() - .SetOptionalInt32(1) - .SetOptionalString("x") - .SetOptionalBytes(ByteString.CopyFromUtf8("y")) - .SetOptionalNestedEnum(TestAllTypes.Types.NestedEnum.BAR) - .Build(); - Assert.IsTrue(message.HasField(optionalInt32Field)); - Assert.IsTrue(message.HasField(optionalStringField)); - Assert.IsTrue(message.HasField(optionalBytesField)); - Assert.IsTrue(message.HasField(optionalNestedEnumField)); - Assert.AreEqual(4, message.AllFields.Count); - } - - [Test] - public void TestMessageField() - { - TestAllTypes.Builder builder = TestAllTypes.CreateBuilder(); - Assert.IsFalse(builder.HasOptionalNestedMessage); - Assert.IsFalse(builder.Build().HasOptionalNestedMessage); - - // Unlike non-message fields, if we set default value to message field, the field - // shoule be seem as present. - builder.SetOptionalNestedMessage(TestAllTypes.Types.NestedMessage.DefaultInstance); - Assert.IsTrue(builder.HasOptionalNestedMessage); - Assert.IsTrue(builder.Build().HasOptionalNestedMessage); - } - - [Test] - public void TestSerializeAndParse() - { - TestAllTypes.Builder builder = TestAllTypes.CreateBuilder(); - builder.SetOptionalInt32(1234); - builder.SetOptionalString("hello"); - builder.SetOptionalNestedMessage(TestAllTypes.Types.NestedMessage.DefaultInstance); - builder.SetOneofUint32(0U); - ByteString data = builder.Build().ToByteString(); - - TestAllTypes message = TestAllTypes.ParseFrom(data); - Assert.AreEqual(1234, message.OptionalInt32); - Assert.AreEqual("hello", message.OptionalString); - Assert.AreEqual(ByteString.Empty, message.OptionalBytes); - Assert.AreEqual(TestAllTypes.Types.NestedEnum.FOO, message.OptionalNestedEnum); - Assert.IsTrue(message.HasOptionalNestedMessage); - Assert.AreEqual(0, message.OptionalNestedMessage.Bb); - Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofUint32, message.OneofFieldCase); - } - } -} diff --git a/csharp/src/ProtocolBuffers.Test/GeneratedBuilderTest.cs b/csharp/src/ProtocolBuffers.Test/GeneratedBuilderTest.cs deleted file mode 100644 index 257f5001..00000000 --- a/csharp/src/ProtocolBuffers.Test/GeneratedBuilderTest.cs +++ /dev/null @@ -1,102 +0,0 @@ -using System; -using System.Collections.Generic; -using Google.ProtocolBuffers.TestProtos; -using NUnit.Framework; - -namespace Google.ProtocolBuffers -{ - public class GeneratedBuilderTest - { - class OneTimeEnumerator : IEnumerable - { - readonly T _item; - bool _enumerated; - public OneTimeEnumerator(T item) - { - _item = item; - } - public IEnumerator GetEnumerator() - { - Assert.IsFalse(_enumerated); - _enumerated = true; - yield return _item; - } - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } - } - - [Test] - public void DoesNotEnumerateTwiceForMessageList() - { - TestAllTypes.Builder b = new TestAllTypes.Builder(); - b.AddRangeRepeatedForeignMessage(new OneTimeEnumerator(ForeignMessage.DefaultInstance)); - } - - [Test] - public void DoesNotEnumerateTwiceForPrimitiveList() - { - TestAllTypes.Builder b = new TestAllTypes.Builder(); - b.AddRangeRepeatedInt32(new OneTimeEnumerator(1)); - } - - [Test] - public void DoesNotEnumerateTwiceForStringList() - { - TestAllTypes.Builder b = new TestAllTypes.Builder(); - b.AddRangeRepeatedString(new OneTimeEnumerator("test")); - } - - [Test] - public void DoesNotEnumerateTwiceForEnumList() - { - TestAllTypes.Builder b = new TestAllTypes.Builder(); - b.AddRangeRepeatedForeignEnum(new OneTimeEnumerator(ForeignEnum.FOREIGN_BAR)); - } - - [Test] - public void DoesNotAddNullToMessageListByAddRange() - { - TestAllTypes.Builder b = new TestAllTypes.Builder(); - Assert.Throws(() => b.AddRangeRepeatedForeignMessage(new ForeignMessage[] { null })); - } - - [Test] - public void DoesNotAddNullToMessageListByAdd() - { - TestAllTypes.Builder b = new TestAllTypes.Builder(); - Assert.Throws(() => b.AddRepeatedForeignMessage((ForeignMessage)null)); - } - - [Test] - public void DoesNotAddNullToMessageListBySet() - { - TestAllTypes.Builder b = new TestAllTypes.Builder(); - b.AddRepeatedForeignMessage(ForeignMessage.DefaultInstance); - Assert.Throws(() => b.SetRepeatedForeignMessage(0, (ForeignMessage)null)); - } - - [Test] - public void DoesNotAddNullToStringListByAddRange() - { - TestAllTypes.Builder b = new TestAllTypes.Builder(); - Assert.Throws(() => b.AddRangeRepeatedString(new String[] { null })); - } - - [Test] - public void DoesNotAddNullToStringListByAdd() - { - TestAllTypes.Builder b = new TestAllTypes.Builder(); - Assert.Throws(() => b.AddRepeatedString(null)); - } - - [Test] - public void DoesNotAddNullToStringListBySet() - { - TestAllTypes.Builder b = new TestAllTypes.Builder(); - b.AddRepeatedString("one"); - Assert.Throws(() => b.SetRepeatedString(0, null)); - } - } -} diff --git a/csharp/src/ProtocolBuffers.Test/GeneratedMessageTest.cs b/csharp/src/ProtocolBuffers.Test/GeneratedMessageTest.cs index 4f669449..c5564060 100644 --- a/csharp/src/ProtocolBuffers.Test/GeneratedMessageTest.cs +++ b/csharp/src/ProtocolBuffers.Test/GeneratedMessageTest.cs @@ -1,776 +1,153 @@ -#region Copyright notice and license - -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/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; using System.Collections.Generic; -using Google.ProtocolBuffers.Descriptors; -using Google.ProtocolBuffers.Collections; -using Google.ProtocolBuffers.TestProtos; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Google.Protobuf.TestProtos; using NUnit.Framework; -namespace Google.ProtocolBuffers +namespace Google.Protobuf { + /// + /// Tests around the generated TestAllTypes message. + /// public class GeneratedMessageTest { - private readonly ReflectionTester reflectionTester; - private readonly ReflectionTester extensionsReflectionTester; - - public GeneratedMessageTest() - { - reflectionTester = ReflectionTester.CreateTestAllTypesInstance(); - extensionsReflectionTester = ReflectionTester.CreateTestAllExtensionsInstance(); - } - - [Test] - public void RepeatedAddPrimitiveBeforeBuild() - { - TestAllTypes message = new TestAllTypes.Builder {RepeatedInt32List = {1, 2, 3}}.Build(); - TestUtil.AssertEqual(new int[] {1, 2, 3}, message.RepeatedInt32List); - } - - [Test] - public void AddPrimitiveFailsAfterBuild() - { - TestAllTypes.Builder builder = new TestAllTypes.Builder(); - IList list = builder.RepeatedInt32List; - list.Add(1); // Fine - builder.Build(); - - Assert.Throws(() => list.Add(2)); - } - - [Test] - public void RepeatedAddMessageBeforeBuild() - { - TestAllTypes message = new TestAllTypes.Builder - { - RepeatedNestedMessageList = - {new TestAllTypes.Types.NestedMessage.Builder {Bb = 10}.Build()} - }.Build(); - Assert.AreEqual(1, message.RepeatedNestedMessageCount); - Assert.AreEqual(10, message.RepeatedNestedMessageList[0].Bb); - } - - [Test] - public void AddMessageFailsAfterBuild() - { - TestAllTypes.Builder builder = new TestAllTypes.Builder(); - IList list = builder.RepeatedNestedMessageList; - builder.Build(); - - Assert.Throws(() => list.Add(new TestAllTypes.Types.NestedMessage.Builder { Bb = 10 }.Build())); - } - - [Test] - public void DefaultInstance() - { - Assert.AreSame(TestAllTypes.DefaultInstance, TestAllTypes.DefaultInstance.DefaultInstanceForType); - Assert.AreSame(TestAllTypes.DefaultInstance, TestAllTypes.CreateBuilder().DefaultInstanceForType); - } - - [Test] - public void Accessors() - { - TestAllTypes.Builder builder = TestAllTypes.CreateBuilder(); - TestUtil.SetAllFields(builder); - TestAllTypes message = builder.Build(); - TestUtil.AssertAllFieldsSet(message); - } - - [Test] - public void SettersRejectNull() - { - TestAllTypes.Builder builder = TestAllTypes.CreateBuilder(); - Assert.Throws(() => builder.SetOptionalString(null)); - Assert.Throws(() => builder.SetOptionalBytes(null)); - Assert.Throws( - () => builder.SetOptionalNestedMessage((TestAllTypes.Types.NestedMessage) null)); - Assert.Throws( - () => builder.SetOptionalNestedMessage((TestAllTypes.Types.NestedMessage.Builder) null)); - Assert.Throws(() => builder.AddRepeatedString(null)); - Assert.Throws(() => builder.AddRepeatedBytes(null)); - Assert.Throws( - () => builder.AddRepeatedNestedMessage((TestAllTypes.Types.NestedMessage) null)); - Assert.Throws( - () => builder.AddRepeatedNestedMessage((TestAllTypes.Types.NestedMessage.Builder) null)); - } - - [Test] - public void RepeatedSetters() - { - TestAllTypes.Builder builder = TestAllTypes.CreateBuilder(); - TestUtil.SetAllFields(builder); - TestUtil.ModifyRepeatedFields(builder); - TestAllTypes message = builder.Build(); - TestUtil.AssertRepeatedFieldsModified(message); - } - - [Test] - public void RepeatedAppend() - { - TestAllTypes.Builder builder = TestAllTypes.CreateBuilder(); - - builder.AddRangeRepeatedInt32(new int[] {1, 2, 3, 4}); - builder.AddRangeRepeatedForeignEnum((new ForeignEnum[] {ForeignEnum.FOREIGN_BAZ})); - - ForeignMessage foreignMessage = ForeignMessage.CreateBuilder().SetC(12).Build(); - builder.AddRangeRepeatedForeignMessage(new ForeignMessage[] {foreignMessage}); - - TestAllTypes message = builder.Build(); - TestUtil.AssertEqual(message.RepeatedInt32List, new int[] {1, 2, 3, 4}); - TestUtil.AssertEqual(message.RepeatedForeignEnumList, new ForeignEnum[] {ForeignEnum.FOREIGN_BAZ}); - Assert.AreEqual(1, message.RepeatedForeignMessageCount); - Assert.AreEqual(12, message.GetRepeatedForeignMessage(0).C); - } - - [Test] - public void RepeatedAppendRejectsNull() - { - TestAllTypes.Builder builder = TestAllTypes.CreateBuilder(); - - ForeignMessage foreignMessage = ForeignMessage.CreateBuilder().SetC(12).Build(); - Assert.Throws( - () => builder.AddRangeRepeatedForeignMessage(new[] {foreignMessage, null})); - Assert.Throws(() => builder.AddRangeRepeatedForeignMessage(null)); - Assert.Throws(() => builder.AddRangeRepeatedForeignEnum(null)); - Assert.Throws(() => builder.AddRangeRepeatedString(new[] {"one", null})); - Assert.Throws( - () => builder.AddRangeRepeatedBytes(new[] {TestUtil.ToBytes("one"), null})); - } - - [Test] - public void SettingForeignMessageUsingBuilder() - { - TestAllTypes message = TestAllTypes.CreateBuilder() - // Pass builder for foreign message instance. - .SetOptionalForeignMessage(ForeignMessage.CreateBuilder().SetC(123)) - .Build(); - TestAllTypes expectedMessage = TestAllTypes.CreateBuilder() - // Create expected version passing foreign message instance explicitly. - .SetOptionalForeignMessage(ForeignMessage.CreateBuilder().SetC(123).Build()) - .Build(); - Assert.AreEqual(expectedMessage, message); - } - - [Test] - public void SettingRepeatedForeignMessageUsingBuilder() - { - TestAllTypes message = TestAllTypes.CreateBuilder() - // Pass builder for foreign message instance. - .AddRepeatedForeignMessage(ForeignMessage.CreateBuilder().SetC(456)) - .Build(); - TestAllTypes expectedMessage = TestAllTypes.CreateBuilder() - // Create expected version passing foreign message instance explicitly. - .AddRepeatedForeignMessage(ForeignMessage.CreateBuilder().SetC(456).Build()) - .Build(); - Assert.AreEqual(expectedMessage, message); - } - - [Test] - public void SettingRepeatedValuesUsingRangeInCollectionInitializer() - { - int[] values = {1, 2, 3}; - TestAllTypes message = new TestAllTypes.Builder - { - RepeatedSint32List = {values} - }.Build(); - Assert.IsTrue(Lists.Equals(values, message.RepeatedSint32List)); - } - - [Test] - public void SettingRepeatedValuesUsingIndividualValuesInCollectionInitializer() - { - TestAllTypes message = new TestAllTypes.Builder - { - RepeatedSint32List = {6, 7} - }.Build(); - Assert.IsTrue(Lists.Equals(new int[] {6, 7}, message.RepeatedSint32List)); - } - - [Test] - public void Defaults() - { - TestUtil.AssertClear(TestAllTypes.DefaultInstance); - TestUtil.AssertClear(TestAllTypes.CreateBuilder().Build()); - - Assert.AreEqual("\u1234", TestExtremeDefaultValues.DefaultInstance.Utf8String); - } - - [Test] - public void ReflectionGetters() - { - TestAllTypes.Builder builder = TestAllTypes.CreateBuilder(); - TestUtil.SetAllFields(builder); - TestAllTypes message = builder.Build(); - reflectionTester.AssertAllFieldsSetViaReflection(message); - } - - [Test] - public void ReflectionSetters() - { - TestAllTypes.Builder builder = TestAllTypes.CreateBuilder(); - reflectionTester.SetAllFieldsViaReflection(builder); - TestAllTypes message = builder.Build(); - TestUtil.AssertAllFieldsSet(message); - } - - [Test] - public void ReflectionClear() - { - TestAllTypes.Builder builder = TestAllTypes.CreateBuilder(); - reflectionTester.SetAllFieldsViaReflection(builder); - reflectionTester.ClearAllFieldsViaReflection(builder); - TestAllTypes message = builder.Build(); - TestUtil.AssertClear(message); - } - - [Test] - public void ReflectionSettersRejectNull() - { - TestAllTypes.Builder builder = TestAllTypes.CreateBuilder(); - reflectionTester.AssertReflectionSettersRejectNull(builder); - } - - [Test] - public void ReflectionRepeatedSetters() - { - TestAllTypes.Builder builder = TestAllTypes.CreateBuilder(); - reflectionTester.SetAllFieldsViaReflection(builder); - reflectionTester.ModifyRepeatedFieldsViaReflection(builder); - TestAllTypes message = builder.Build(); - TestUtil.AssertRepeatedFieldsModified(message); - } - - [Test] - public void TestReflectionRepeatedSettersRejectNull() - { - TestAllTypes.Builder builder = TestAllTypes.CreateBuilder(); - reflectionTester.AssertReflectionRepeatedSettersRejectNull(builder); - } - - [Test] - public void ReflectionDefaults() - { - TestUtil.TestInMultipleCultures(() => - { - reflectionTester.AssertClearViaReflection( - TestAllTypes.DefaultInstance); - reflectionTester.AssertClearViaReflection( - TestAllTypes.CreateBuilder().Build()); - }); - } - - [Test] - public void ReflectionGetOneof() - { - TestAllTypes.Builder builder = TestAllTypes.CreateBuilder(); - reflectionTester.SetAllFieldsViaReflection(builder); - Descriptors.OneofDescriptor oneof = TestAllTypes.Descriptor.Oneofs[0]; - Descriptors.FieldDescriptor field = TestAllTypes.Descriptor.FindFieldByName("oneof_bytes"); - Assert.AreSame(field, builder.OneofFieldDescriptor(oneof)); - } - - [Test] - public void ReflectionClearOneof() - { - TestAllTypes.Builder builder = TestAllTypes.CreateBuilder(); - reflectionTester.SetAllFieldsViaReflection(builder); - OneofDescriptor oneof = TestAllTypes.Descriptor.Oneofs[0]; - FieldDescriptor field = TestAllTypes.Descriptor.FindFieldByName("oneof_bytes"); - - Assert.IsTrue(builder.HasOneof(oneof)); - Assert.IsTrue(builder.HasField(field)); - builder.ClearOneof(oneof); - Assert.IsFalse(builder.HasOneof(oneof)); - Assert.IsFalse(builder.HasField(field)); - } - - // ================================================================= - // Extensions. - - [Test] - public void ExtensionAccessors() - { - TestAllExtensions.Builder builder = TestAllExtensions.CreateBuilder(); - TestUtil.SetAllExtensions(builder); - TestAllExtensions message = builder.Build(); - TestUtil.AssertAllExtensionsSet(message); - } - - [Test] - public void ExtensionRepeatedSetters() - { - TestAllExtensions.Builder builder = TestAllExtensions.CreateBuilder(); - TestUtil.SetAllExtensions(builder); - TestUtil.ModifyRepeatedExtensions(builder); - TestAllExtensions message = builder.Build(); - TestUtil.AssertRepeatedExtensionsModified(message); - } - - [Test] - public void ExtensionDefaults() - { - TestUtil.AssertExtensionsClear(TestAllExtensions.DefaultInstance); - TestUtil.AssertExtensionsClear(TestAllExtensions.CreateBuilder().Build()); - } - - [Test] - public void ExtensionReflectionGetters() - { - TestAllExtensions.Builder builder = TestAllExtensions.CreateBuilder(); - TestUtil.SetAllExtensions(builder); - TestAllExtensions message = builder.Build(); - extensionsReflectionTester.AssertAllFieldsSetViaReflection(message); - } - - [Test] - public void ExtensionReflectionSetters() - { - TestAllExtensions.Builder builder = TestAllExtensions.CreateBuilder(); - extensionsReflectionTester.SetAllFieldsViaReflection(builder); - TestAllExtensions message = builder.Build(); - TestUtil.AssertAllExtensionsSet(message); - } - [Test] - public void ExtensionReflectionSettersRejectNull() - { - TestAllExtensions.Builder builder = TestAllExtensions.CreateBuilder(); - extensionsReflectionTester.AssertReflectionSettersRejectNull(builder); - } - - [Test] - public void ExtensionReflectionRepeatedSetters() - { - TestAllExtensions.Builder builder = TestAllExtensions.CreateBuilder(); - extensionsReflectionTester.SetAllFieldsViaReflection(builder); - extensionsReflectionTester.ModifyRepeatedFieldsViaReflection(builder); - TestAllExtensions message = builder.Build(); - TestUtil.AssertRepeatedExtensionsModified(message); - } - - [Test] - public void ExtensionReflectionRepeatedSettersRejectNull() - { - TestAllExtensions.Builder builder = TestAllExtensions.CreateBuilder(); - extensionsReflectionTester.AssertReflectionRepeatedSettersRejectNull(builder); - } - - [Test] - public void ExtensionReflectionDefaults() - { - TestUtil.TestInMultipleCultures(() => - { - extensionsReflectionTester.AssertClearViaReflection( - TestAllExtensions.DefaultInstance); - extensionsReflectionTester.AssertClearViaReflection( - TestAllExtensions.CreateBuilder().Build()); - }); - } - - [Test] - public void ClearExtension() - { - // ClearExtension() is not actually used in TestUtil, so try it manually. - Assert.IsFalse(TestAllExtensions.CreateBuilder() - .SetExtension(Unittest.OptionalInt32Extension, 1) - .ClearExtension(Unittest.OptionalInt32Extension) - .HasExtension(Unittest.OptionalInt32Extension)); - Assert.AreEqual(0, TestAllExtensions.CreateBuilder() - .AddExtension(Unittest.RepeatedInt32Extension, 1) - .ClearExtension(Unittest.RepeatedInt32Extension) - .GetExtensionCount(Unittest.RepeatedInt32Extension)); - } - - [Test] - public void ExtensionMergeFrom() - { - TestAllExtensions original = TestAllExtensions.CreateBuilder() - .SetExtension(Unittest.OptionalInt32Extension, 1).Build(); - TestAllExtensions merged = - TestAllExtensions.CreateBuilder().MergeFrom(original).Build(); - Assert.IsTrue((merged.HasExtension(Unittest.OptionalInt32Extension))); - Assert.AreEqual(1, (int) merged.GetExtension(Unittest.OptionalInt32Extension)); - } - - /* Removed multiple files option for the moment - [Test] - public void MultipleFilesOption() { - // We mostly just want to check that things compile. - MessageWithNoOuter message = MessageWithNoOuter.CreateBuilder() - .SetNested(MessageWithNoOuter.Types.NestedMessage.CreateBuilder().SetI(1)) - .AddForeign(TestAllTypes.CreateBuilder().SetOptionalInt32(1)) - .SetNestedEnum(MessageWithNoOuter.Types.NestedEnum.BAZ) - .SetForeignEnum(EnumWithNoOuter.BAR) - .Build(); - Assert.AreEqual(message, MessageWithNoOuter.ParseFrom(message.ToByteString())); - - Assert.AreEqual(MultiFileProto.DescriptorProtoFile, MessageWithNoOuter.DescriptorProtoFile.File); - - FieldDescriptor field = MessageWithNoOuter.DescriptorProtoFile.FindDescriptor("foreign_enum"); - Assert.AreEqual(MultiFileProto.DescriptorProtoFile.FindTypeByName("EnumWithNoOuter") - .FindValueByNumber((int)EnumWithNoOuter.BAR), message[field]); - - Assert.AreEqual(MultiFileProto.DescriptorProtoFile, ServiceWithNoOuter.DescriptorProtoFile.File); - - Assert.IsFalse(TestAllExtensions.DefaultInstance.HasExtension(MultiFileProto.ExtensionWithOuter)); - }*/ - - [Test] - public void OptionalFieldWithRequiredSubfieldsOptimizedForSize() - { - TestOptionalOptimizedForSize message = TestOptionalOptimizedForSize.DefaultInstance; - Assert.IsTrue(message.IsInitialized); - - message = TestOptionalOptimizedForSize.CreateBuilder().SetO( - TestRequiredOptimizedForSize.CreateBuilder().BuildPartial() - ).BuildPartial(); - Assert.IsFalse(message.IsInitialized); - - message = TestOptionalOptimizedForSize.CreateBuilder().SetO( - TestRequiredOptimizedForSize.CreateBuilder().SetX(5).BuildPartial() - ).BuildPartial(); - Assert.IsTrue(message.IsInitialized); - } - - [Test] - public void OptimizedForSizeMergeUsesAllFieldsFromTarget() - { - TestOptimizedForSize withFieldSet = new TestOptimizedForSize.Builder {I = 10}.Build(); - TestOptimizedForSize.Builder builder = new TestOptimizedForSize.Builder(); - builder.MergeFrom(withFieldSet); - TestOptimizedForSize built = builder.Build(); - Assert.AreEqual(10, built.I); - } - - [Test] - public void UninitializedExtensionInOptimizedForSizeMakesMessageUninitialized() - { - TestOptimizedForSize.Builder builder = new TestOptimizedForSize.Builder(); - builder.SetExtension(TestOptimizedForSize.TestExtension2, - new TestRequiredOptimizedForSize.Builder().BuildPartial()); - Assert.IsFalse(builder.IsInitialized); - Assert.IsFalse(builder.BuildPartial().IsInitialized); - - builder = new TestOptimizedForSize.Builder(); - builder.SetExtension(TestOptimizedForSize.TestExtension2, - new TestRequiredOptimizedForSize.Builder {X = 10}.BuildPartial()); - Assert.IsTrue(builder.IsInitialized); - Assert.IsTrue(builder.BuildPartial().IsInitialized); - } - - [Test] - public void ToBuilder() - { - TestAllTypes.Builder builder = TestAllTypes.CreateBuilder(); - TestUtil.SetAllFields(builder); - TestAllTypes message = builder.Build(); - TestUtil.AssertAllFieldsSet(message.ToBuilder().Build()); - } - - [Test] - public void FieldConstantValues() - { - Assert.AreEqual(TestAllTypes.Types.NestedMessage.BbFieldNumber, 1); - Assert.AreEqual(TestAllTypes.OptionalInt32FieldNumber, 1); - Assert.AreEqual(TestAllTypes.OptionalGroupFieldNumber, 16); - Assert.AreEqual(TestAllTypes.OptionalNestedMessageFieldNumber, 18); - Assert.AreEqual(TestAllTypes.OptionalNestedEnumFieldNumber, 21); - Assert.AreEqual(TestAllTypes.RepeatedInt32FieldNumber, 31); - Assert.AreEqual(TestAllTypes.RepeatedGroupFieldNumber, 46); - Assert.AreEqual(TestAllTypes.RepeatedNestedMessageFieldNumber, 48); - Assert.AreEqual(TestAllTypes.RepeatedNestedEnumFieldNumber, 51); - } - - [Test] - public void ExtensionConstantValues() - { - Assert.AreEqual(TestRequired.SingleFieldNumber, 1000); - Assert.AreEqual(TestRequired.MultiFieldNumber, 1001); - Assert.AreEqual(Unittest.OptionalInt32ExtensionFieldNumber, 1); - Assert.AreEqual(Unittest.OptionalGroupExtensionFieldNumber, 16); - Assert.AreEqual(Unittest.OptionalNestedMessageExtensionFieldNumber, 18); - Assert.AreEqual(Unittest.OptionalNestedEnumExtensionFieldNumber, 21); - Assert.AreEqual(Unittest.RepeatedInt32ExtensionFieldNumber, 31); - Assert.AreEqual(Unittest.RepeatedGroupExtensionFieldNumber, 46); - Assert.AreEqual(Unittest.RepeatedNestedMessageExtensionFieldNumber, 48); - Assert.AreEqual(Unittest.RepeatedNestedEnumExtensionFieldNumber, 51); - } - - [Test] - public void EmptyPackedValue() - { - TestPackedTypes empty = new TestPackedTypes.Builder().Build(); - Assert.AreEqual(0, empty.SerializedSize); - } - - // oneof tests - [Test] - public void TestOneofEnumCase() - { - TestOneof2 message = TestOneof2.CreateBuilder() - .SetFooInt(123).SetFooString("foo").SetFooCord("bar").Build(); - TestUtil.AssertAtMostOneFieldSetOneof(message); - } - - [Test] - public void TestClearOneof() - { - TestOneof2.Builder builder = TestOneof2.CreateBuilder().SetFooInt(123); - Assert.AreEqual(TestOneof2.FooOneofCase.FooInt, builder.FooCase); - builder.ClearFoo(); - Assert.AreEqual(TestOneof2.FooOneofCase.None, builder.FooCase); - } - - [Test] - public void TestSetOneofClearsOthers() - { - TestOneof2.Builder builder = TestOneof2.CreateBuilder(); - TestOneof2 message = - builder.SetFooInt(123).SetFooString("foo").Build(); - Assert.IsTrue(message.HasFooString); - TestUtil.AssertAtMostOneFieldSetOneof(message); - - message = builder.SetFooCord("bar").Build(); - Assert.IsTrue(message.HasFooCord); - TestUtil.AssertAtMostOneFieldSetOneof(message); - - message = builder.SetFooStringPiece("baz").Build(); - Assert.IsTrue(message.HasFooStringPiece); - TestUtil.AssertAtMostOneFieldSetOneof(message); - - message = builder.SetFooBytes(TestUtil.ToBytes("qux")).Build(); - Assert.IsTrue(message.HasFooBytes); - TestUtil.AssertAtMostOneFieldSetOneof(message); - - message = builder.SetFooEnum(TestOneof2.Types.NestedEnum.FOO).Build(); - Assert.IsTrue(message.HasFooEnum); - TestUtil.AssertAtMostOneFieldSetOneof(message); - - message = builder.SetFooMessage( - TestOneof2.Types.NestedMessage.CreateBuilder().SetQuxInt(234).Build()).Build(); - Assert.IsTrue(message.HasFooMessage); - TestUtil.AssertAtMostOneFieldSetOneof(message); - - message = builder.SetFooInt(123).Build(); - Assert.IsTrue(message.HasFooInt); - TestUtil.AssertAtMostOneFieldSetOneof(message); - } - - [Test] - public void TestOneofTypes_Primitive() - { - TestOneof2.Builder builder = TestOneof2.CreateBuilder(); - Assert.AreEqual(builder.FooInt, 0); - Assert.IsFalse(builder.HasFooInt); - Assert.IsTrue(builder.SetFooInt(123).HasFooInt); - Assert.AreEqual(builder.FooInt, 123); - TestOneof2 message = builder.BuildPartial(); - Assert.IsTrue(message.HasFooInt); - Assert.AreEqual(message.FooInt, 123); - - Assert.IsFalse(builder.ClearFooInt().HasFooInt); - TestOneof2 message2 = builder.Build(); - Assert.IsFalse(message2.HasFooInt); - Assert.AreEqual(message2.FooInt, 0); - } - - [Test] - public void TestOneofTypes_Enum() - { - TestOneof2.Builder builder = TestOneof2.CreateBuilder(); - Assert.AreEqual(builder.FooEnum, TestOneof2.Types.NestedEnum.FOO); - Assert.IsTrue(builder.SetFooEnum(TestOneof2.Types.NestedEnum.BAR).HasFooEnum); - Assert.AreEqual(builder.FooEnum, TestOneof2.Types.NestedEnum.BAR); - TestOneof2 message = builder.BuildPartial(); - Assert.IsTrue(message.HasFooEnum); - Assert.AreEqual(message.FooEnum, TestOneof2.Types.NestedEnum.BAR); - - Assert.IsFalse(builder.ClearFooEnum().HasFooEnum); - TestOneof2 message2 = builder.Build(); - Assert.IsFalse(message2.HasFooEnum); - Assert.AreEqual(message2.FooEnum, TestOneof2.Types.NestedEnum.FOO); - } - - [Test] - public void TestOneofTypes_String() - { - TestOneof2.Builder builder = TestOneof2.CreateBuilder(); - Assert.AreEqual(builder.FooString, ""); - Assert.IsTrue(builder.SetFooString("foo").HasFooString); - Assert.AreEqual(builder.FooString, "foo"); - TestOneof2 message = builder.BuildPartial(); - Assert.IsTrue(message.HasFooString); - Assert.AreEqual(message.FooString, "foo"); - - Assert.IsFalse(builder.ClearFooString().HasFooString); - TestOneof2 message2 = builder.Build(); - Assert.IsFalse(message2.HasFooString); - Assert.AreEqual(message2.FooString, ""); - - builder.SetFooInt(123); - Assert.AreEqual(builder.FooString, ""); - Assert.AreEqual(builder.FooInt, 123); - message = builder.Build(); - Assert.AreEqual(message.FooString, ""); - Assert.AreEqual(message.FooInt, 123); - } - - [Test] - public void TestOneofTypes_Message() - { - TestOneof2.Builder builder = TestOneof2.CreateBuilder(); - Assert.AreEqual(builder.FooMessage.QuxInt, 0); - builder.SetFooMessage(TestOneof2.Types.NestedMessage.CreateBuilder().SetQuxInt(234).Build()); - Assert.IsTrue(builder.HasFooMessage); - Assert.AreEqual(builder.FooMessage.QuxInt, 234); - TestOneof2 message = builder.BuildPartial(); - Assert.IsTrue(message.HasFooMessage); - Assert.AreEqual(message.FooMessage.QuxInt, 234); - - Assert.IsFalse(builder.ClearFooMessage().HasFooMessage); - message = builder.Build(); - Assert.IsFalse(message.HasFooMessage); - Assert.AreEqual(message.FooMessage.QuxInt, 0); - - builder = TestOneof2.CreateBuilder(); - Assert.IsFalse(builder.HasFooMessage); - builder.SetFooMessage(TestOneof2.Types.NestedMessage.CreateBuilder().SetQuxInt(123)); - Assert.IsTrue(builder.HasFooMessage); - Assert.AreEqual(builder.FooMessage.QuxInt, 123); - message = builder.Build(); - Assert.IsTrue(message.HasFooMessage); - Assert.AreEqual(message.FooMessage.QuxInt, 123); - } - - [Test] - public void TestOneofMerge_Primitive() - { - TestOneof2.Builder builder = TestOneof2.CreateBuilder(); - TestOneof2 message = builder.SetFooInt(123).Build(); - TestOneof2 message2 = TestOneof2.CreateBuilder().MergeFrom(message).Build(); - Assert.IsTrue(message2.HasFooInt); - Assert.AreEqual(message2.FooInt, 123); - } - - [Test] - public void TestOneofMerge_String() - { - TestOneof2.Builder builder = TestOneof2.CreateBuilder(); - TestOneof2 message = builder.SetFooString("foo").Build(); - TestOneof2 message2 = TestOneof2.CreateBuilder().MergeFrom(message).Build(); - Assert.IsTrue(message2.HasFooString); - Assert.AreEqual(message2.FooString, "foo"); - } - - [Test] - public void TestOneofMerge_Enum() - { - TestOneof2.Builder builder = TestOneof2.CreateBuilder(); - TestOneof2 message = builder.SetFooEnum(TestOneof2.Types.NestedEnum.BAR).Build(); - TestOneof2 message2 = TestOneof2.CreateBuilder().MergeFrom(message).Build(); - Assert.IsTrue(message2.HasFooEnum); - Assert.AreEqual(message2.FooEnum, TestOneof2.Types.NestedEnum.BAR); - } - - public void TestOneofMerge_message() - { - TestOneof2.Builder builder = TestOneof2.CreateBuilder(); - TestOneof2 message = builder.SetFooMessage( - TestOneof2.Types.NestedMessage.CreateBuilder().SetQuxInt(234).Build()).Build(); - TestOneof2 message2 = TestOneof2.CreateBuilder().MergeFrom(message).Build(); - Assert.IsTrue(message2.HasFooMessage); - Assert.AreEqual(message2.FooMessage.QuxInt, 234); - } - - [Test] - public void TestOneofMergeMixed() - { - TestOneof2.Builder builder = TestOneof2.CreateBuilder(); - TestOneof2 message = builder.SetFooEnum(TestOneof2.Types.NestedEnum.BAR).Build(); - TestOneof2 message2 = - TestOneof2.CreateBuilder().SetFooString("foo").MergeFrom(message).Build(); - Assert.IsFalse(message2.HasFooString); - Assert.IsTrue(message2.HasFooEnum); - Assert.AreEqual(message2.FooEnum, TestOneof2.Types.NestedEnum.BAR); - } - - [Test] - public void TestOneofSerialization_Primitive() - { - TestOneof2.Builder builder = TestOneof2.CreateBuilder(); - TestOneof2 message = builder.SetFooInt(123).Build(); - ByteString serialized = message.ToByteString(); - TestOneof2 message2 = TestOneof2.ParseFrom(serialized); - Assert.IsTrue(message2.HasFooInt); - Assert.AreEqual(message2.FooInt, 123); - } - - [Test] - public void TestOneofSerialization_String() - { - TestOneof2.Builder builder = TestOneof2.CreateBuilder(); - TestOneof2 message = builder.SetFooString("foo").Build(); - ByteString serialized = message.ToByteString(); - TestOneof2 message2 = TestOneof2.ParseFrom(serialized); - Assert.IsTrue(message2.HasFooString); - Assert.AreEqual(message2.FooString, "foo"); - } - - [Test] - public void TestOneofSerialization_Enum() - { - TestOneof2.Builder builder = TestOneof2.CreateBuilder(); - TestOneof2 message = builder.SetFooEnum(TestOneof2.Types.NestedEnum.BAR).Build(); - ByteString serialized = message.ToByteString(); - TestOneof2 message2 = TestOneof2.ParseFrom(serialized); - Assert.IsTrue(message2.HasFooEnum); - Assert.AreEqual(message2.FooEnum, TestOneof2.Types.NestedEnum.BAR); - } - - [Test] - public void TestOneofSerialization_Message() - { - TestOneof2.Builder builder = TestOneof2.CreateBuilder(); - TestOneof2 message = builder.SetFooMessage( - TestOneof2.Types.NestedMessage.CreateBuilder().SetQuxInt(234).Build()).Build(); - ByteString serialized = message.ToByteString(); - TestOneof2 message2 = TestOneof2.ParseFrom(serialized); - Assert.IsTrue(message2.HasFooMessage); - Assert.AreEqual(message2.FooMessage.QuxInt, 234); + public void DefaultValues() + { + // Single fields + var message = new TestAllTypes(); + Assert.AreEqual(false, message.SingleBool); + Assert.AreEqual(ByteString.Empty, message.SingleBytes); + Assert.AreEqual(0.0, message.SingleDouble); + Assert.AreEqual(0, message.SingleFixed32); + Assert.AreEqual(0L, message.SingleFixed64); + Assert.AreEqual(0.0f, message.SingleFloat); + Assert.AreEqual(ForeignEnum.FOREIGN_UNSPECIFIED, message.SingleForeignEnum); + Assert.IsNull(message.SingleForeignMessage); + Assert.AreEqual(ImportEnum.IMPORT_ENUM_UNSPECIFIED, message.SingleImportEnum); + Assert.IsNull(message.SingleImportMessage); + Assert.AreEqual(0, message.SingleInt32); + Assert.AreEqual(0L, message.SingleInt64); + Assert.AreEqual(TestAllTypes.Types.NestedEnum.NESTED_ENUM_UNSPECIFIED, message.SingleNestedEnum); + Assert.IsNull(message.SingleNestedMessage); + Assert.IsNull(message.SinglePublicImportMessage); + Assert.AreEqual(0, message.SingleSfixed32); + Assert.AreEqual(0L, message.SingleSfixed64); + Assert.AreEqual(0, message.SingleSint32); + Assert.AreEqual(0L, message.SingleSint64); + Assert.AreEqual("", message.SingleString); + Assert.AreEqual(0U, message.SingleUint32); + Assert.AreEqual(0UL, message.SingleUint64); + + // Repeated fields + Assert.AreEqual(0, message.RepeatedBool.Count); + Assert.AreEqual(0, message.RepeatedBytes.Count); + Assert.AreEqual(0, message.RepeatedDouble.Count); + Assert.AreEqual(0, message.RepeatedFixed32.Count); + Assert.AreEqual(0, message.RepeatedFixed64.Count); + Assert.AreEqual(0, message.RepeatedFloat.Count); + Assert.AreEqual(0, message.RepeatedForeignEnum.Count); + Assert.AreEqual(0, message.RepeatedForeignMessage.Count); + Assert.AreEqual(0, message.RepeatedImportEnum.Count); + Assert.AreEqual(0, message.RepeatedImportMessage.Count); + Assert.AreEqual(0, message.RepeatedNestedEnum.Count); + Assert.AreEqual(0, message.RepeatedNestedMessage.Count); + Assert.AreEqual(0, message.RepeatedPublicImportMessage.Count); + Assert.AreEqual(0, message.RepeatedSfixed32.Count); + Assert.AreEqual(0, message.RepeatedSfixed64.Count); + Assert.AreEqual(0, message.RepeatedSint32.Count); + Assert.AreEqual(0, message.RepeatedSint64.Count); + Assert.AreEqual(0, message.RepeatedString.Count); + Assert.AreEqual(0, message.RepeatedUint32.Count); + Assert.AreEqual(0, message.RepeatedUint64.Count); + + // Oneof fields + Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.None, message.OneofFieldCase); + Assert.AreEqual(0, message.OneofUint32); + Assert.AreEqual("", message.OneofString); + Assert.AreEqual(ByteString.Empty, message.OneofBytes); + Assert.IsNull(message.OneofNestedMessage); + } + + [Test] + public void RoundTrip_Empty() + { + var message = new TestAllTypes(); + // 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); + } + + [Test] + public void RoundTrip_SingleValues() + { + var message = new TestAllTypes + { + SingleBool = true, + SingleBytes = ByteString.CopyFrom(new byte[] { 1, 2, 3, 4 }), + SingleDouble = 23.5, + SingleFixed32 = 23, + SingleFixed64 = 1234567890123, + SingleFloat = 12.25f, + SingleForeignEnum = ForeignEnum.FOREIGN_BAR, + SingleForeignMessage = new ForeignMessage { C = 10 }, + SingleImportEnum = ImportEnum.IMPORT_BAZ, + SingleImportMessage = new ImportMessage { D = 20 }, + SingleInt32 = 100, + SingleInt64 = 3210987654321, + SingleNestedEnum = TestAllTypes.Types.NestedEnum.FOO, + SingleNestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 35 }, + SinglePublicImportMessage = new PublicImportMessage { E = 54 }, + SingleSfixed32 = -123, + SingleSfixed64 = -12345678901234, + SingleSint32 = -456, + SingleSint64 = -12345678901235, + SingleString = "test", + SingleUint32 = uint.MaxValue, + SingleUint64 = ulong.MaxValue + }; + + byte[] bytes = message.ToByteArray(); + TestAllTypes parsed = TestAllTypes.Parser.ParseFrom(bytes); + Assert.AreEqual(message, parsed); + } + + [Test] + public void RoundTrip_RepeatedValues() + { + var message = new TestAllTypes + { + RepeatedBool = { true, false }, + RepeatedBytes = { ByteString.CopyFrom(new byte[] { 1, 2, 3, 4 }), ByteString.CopyFrom(new byte[] { 5, 6 }) }, + RepeatedDouble = { -12.25, 23.5 }, + RepeatedFixed32 = { uint.MaxValue, 23 }, + RepeatedFixed64 = { ulong.MaxValue, 1234567890123 }, + RepeatedFloat = { 100f, 12.25f }, + RepeatedForeignEnum = { ForeignEnum.FOREIGN_FOO, ForeignEnum.FOREIGN_BAR }, + RepeatedForeignMessage = { new ForeignMessage(), new ForeignMessage { C = 10 } }, + RepeatedImportEnum = { ImportEnum.IMPORT_BAZ, ImportEnum.IMPORT_ENUM_UNSPECIFIED }, + RepeatedImportMessage = { new ImportMessage { D = 20 }, new ImportMessage { D = 25 } }, + RepeatedInt32 = { 100, 200 }, + RepeatedInt64 = { 3210987654321, long.MaxValue }, + RepeatedNestedEnum = { TestAllTypes.Types.NestedEnum.FOO, TestAllTypes.Types.NestedEnum.NEG }, + RepeatedNestedMessage = { new TestAllTypes.Types.NestedMessage { Bb = 35 }, new TestAllTypes.Types.NestedMessage { Bb = 10 } }, + RepeatedPublicImportMessage = { new PublicImportMessage { E = 54 }, new PublicImportMessage { E = -1 } }, + RepeatedSfixed32 = { -123, 123 }, + RepeatedSfixed64 = { -12345678901234, 12345678901234 }, + RepeatedSint32 = { -456, 100 }, + RepeatedSint64 = { -12345678901235, 123 }, + RepeatedString = { "foo", "bar" }, + RepeatedUint32 = { uint.MaxValue, uint.MinValue }, + RepeatedUint64 = { ulong.MaxValue, uint.MinValue } + }; + + byte[] bytes = message.ToByteArray(); + TestAllTypes parsed = TestAllTypes.Parser.ParseFrom(bytes); + Assert.AreEqual(message, parsed); } } -} \ No newline at end of file +} diff --git a/csharp/src/ProtocolBuffers.Test/IssuesTest.cs b/csharp/src/ProtocolBuffers.Test/IssuesTest.cs index ce7e5f09..87960aab 100644 --- a/csharp/src/ProtocolBuffers.Test/IssuesTest.cs +++ b/csharp/src/ProtocolBuffers.Test/IssuesTest.cs @@ -34,13 +34,12 @@ #endregion - -using Google.ProtocolBuffers.Descriptors; +using Google.Protobuf.Descriptors; using UnitTest.Issues.TestProtos; using NUnit.Framework; -namespace Google.ProtocolBuffers +namespace Google.Protobuf { /// /// Tests for issues which aren't easily compartmentalized into other unit tests. @@ -51,10 +50,11 @@ namespace Google.ProtocolBuffers [Test] public void FieldCalledItem() { - ItemField message = new ItemField.Builder { Item = 3 }.Build(); + ItemField message = new ItemField { Item = 3 }; FieldDescriptor field = ItemField.Descriptor.FindFieldByName("item"); Assert.NotNull(field); - Assert.AreEqual(3, (int)message[field]); + // TODO(jonskeet): Reflection... + // Assert.AreEqual(3, (int)message[field]); } } } diff --git a/csharp/src/ProtocolBuffers.Test/MessageStreamIteratorTest.cs b/csharp/src/ProtocolBuffers.Test/MessageStreamIteratorTest.cs deleted file mode 100644 index 4754ce60..00000000 --- a/csharp/src/ProtocolBuffers.Test/MessageStreamIteratorTest.cs +++ /dev/null @@ -1,90 +0,0 @@ -#region Copyright notice and license - -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/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.Collections.Generic; -using System.IO; -using Google.ProtocolBuffers.TestProtos; -using NUnit.Framework; -using NestedMessage = Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage; - -namespace Google.ProtocolBuffers -{ - public class MessageStreamIteratorTest - { - [Test] - public void ThreeMessagesInMemory() - { - MemoryStream stream = new MemoryStream(MessageStreamWriterTest.ThreeMessageData); - IEnumerable iterator = MessageStreamIterator.FromStreamProvider(() => stream); - List messages = new List(iterator); - - Assert.AreEqual(3, messages.Count); - Assert.AreEqual(5, messages[0].Bb); - Assert.AreEqual(1500, messages[1].Bb); - Assert.IsFalse(messages[2].HasBb); - } - - [Test] - public void ManyMessagesShouldNotTriggerSizeAlert() - { - int messageSize = TestUtil.GetAllSet().SerializedSize; - // Enough messages to trigger the alert unless we've reset the size - // Note that currently we need to make this big enough to copy two whole buffers, - // as otherwise when we refill the buffer the second type, the alert triggers instantly. - int correctCount = (CodedInputStream.BufferSize*2)/messageSize + 1; - using (MemoryStream stream = new MemoryStream()) - { - MessageStreamWriter writer = new MessageStreamWriter(stream); - for (int i = 0; i < correctCount; i++) - { - writer.Write(TestUtil.GetAllSet()); - } - writer.Flush(); - - stream.Position = 0; - - int count = 0; - foreach (var message in MessageStreamIterator.FromStreamProvider(() => stream) - .WithSizeLimit(CodedInputStream.BufferSize*2)) - { - count++; - TestUtil.AssertAllFieldsSet(message); - } - Assert.AreEqual(correctCount, count); - } - } - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers.Test/MessageStreamWriterTest.cs b/csharp/src/ProtocolBuffers.Test/MessageStreamWriterTest.cs deleted file mode 100644 index 030804ee..00000000 --- a/csharp/src/ProtocolBuffers.Test/MessageStreamWriterTest.cs +++ /dev/null @@ -1,78 +0,0 @@ -#region Copyright notice and license - -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/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.IO; -using NUnit.Framework; -using NestedMessage = Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage; - -namespace Google.ProtocolBuffers -{ - public class MessageStreamWriterTest - { - internal static readonly byte[] ThreeMessageData = new byte[] - { - (1 << 3) | 2, 2, - // Field 1, 2 bytes long (first message) - (1 << 3) | 0, 5, // Field 1, value 5 - (1 << 3) | 2, 3, - // Field 1, 3 bytes long (second message) - (1 << 3) | 0, (1500 & 0x7f) | 0x80, 1500 >> 7, - // Field 1, value 1500 - (1 << 3) | 2, 0, // Field 1, no data (third message) - }; - - [Test] - public void ThreeMessages() - { - NestedMessage message1 = new NestedMessage.Builder {Bb = 5}.Build(); - NestedMessage message2 = new NestedMessage.Builder {Bb = 1500}.Build(); - NestedMessage message3 = new NestedMessage.Builder().Build(); - - byte[] data; - using (MemoryStream stream = new MemoryStream()) - { - MessageStreamWriter writer = new MessageStreamWriter(stream); - writer.Write(message1); - writer.Write(message2); - writer.Write(message3); - writer.Flush(); - data = stream.ToArray(); - } - - TestUtil.AssertEqualBytes(ThreeMessageData, data); - } - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers.Test/MessageTest.cs b/csharp/src/ProtocolBuffers.Test/MessageTest.cs deleted file mode 100644 index e746c01a..00000000 --- a/csharp/src/ProtocolBuffers.Test/MessageTest.cs +++ /dev/null @@ -1,344 +0,0 @@ -#region Copyright notice and license - -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/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.IO; -using Google.ProtocolBuffers.Descriptors; -using Google.ProtocolBuffers.TestProtos; -using NUnit.Framework; - -namespace Google.ProtocolBuffers -{ - /// - /// Miscellaneous tests for message operations that apply to both - /// generated and dynamic messages. - /// - public class MessageTest - { - // ================================================================= - // Message-merging tests. - - private static readonly TestAllTypes MergeSource = new TestAllTypes.Builder - { - OptionalInt32 = 1, - OptionalString = "foo", - OptionalForeignMessage = - ForeignMessage.DefaultInstance, - }.AddRepeatedString("bar").Build(); - - private static readonly TestAllTypes MergeDest = new TestAllTypes.Builder - { - OptionalInt64 = 2, - OptionalString = "baz", - OptionalForeignMessage = - new ForeignMessage.Builder {C = 3}.Build(), - }.AddRepeatedString("qux").Build(); - - private const string MergeResultText = - "optional_int32: 1\n" + - "optional_int64: 2\n" + - "optional_string: \"foo\"\n" + - "optional_foreign_message {\n" + - " c: 3\n" + - "}\n" + - "repeated_string: \"qux\"\n" + - "repeated_string: \"bar\"\n"; - - [Test] - public void MergeFrom() - { - TestAllTypes result = TestAllTypes.CreateBuilder(MergeDest).MergeFrom(MergeSource).Build(); - - Assert.AreEqual(MergeResultText, result.ToString()); - } - - /// - /// Test merging a DynamicMessage into a GeneratedMessage. - /// As long as they have the same descriptor, this should work, but it is an - /// entirely different code path. - /// - [Test] - public void MergeFromDynamic() - { - TestAllTypes result = (TestAllTypes) TestAllTypes.CreateBuilder(MergeDest) - .MergeFrom(DynamicMessage.CreateBuilder(MergeSource).Build()) - .Build(); - - Assert.AreEqual(MergeResultText, result.ToString()); - } - - /// - /// Test merging two DynamicMessages. - /// - [Test] - public void DynamicMergeFrom() - { - DynamicMessage result = (DynamicMessage) DynamicMessage.CreateBuilder(MergeDest) - .MergeFrom( - (DynamicMessage) - DynamicMessage.CreateBuilder(MergeSource).Build()) - .Build(); - - Assert.AreEqual(MergeResultText, result.ToString()); - } - - // ================================================================= - // Required-field-related tests. - - private static readonly TestRequired TestRequiredUninitialized = TestRequired.DefaultInstance; - - private static readonly TestRequired TestRequiredInitialized = new TestRequired.Builder - { - A = 1, - B = 2, - C = 3 - }.Build(); - - [Test] - public void Initialization() - { - TestRequired.Builder builder = TestRequired.CreateBuilder(); - - Assert.IsFalse(builder.IsInitialized); - builder.A = 1; - Assert.IsFalse(builder.IsInitialized); - builder.B = 1; - Assert.IsFalse(builder.IsInitialized); - builder.C = 1; - Assert.IsTrue(builder.IsInitialized); - } - - [Test] - public void UninitializedBuilderToString() - { - TestRequired.Builder builder = TestRequired.CreateBuilder().SetA(1); - Assert.AreEqual("a: 1\n", builder.ToString()); - } - - [Test] - public void RequiredForeign() - { - TestRequiredForeign.Builder builder = TestRequiredForeign.CreateBuilder(); - - Assert.IsTrue(builder.IsInitialized); - - builder.SetOptionalMessage(TestRequiredUninitialized); - Assert.IsFalse(builder.IsInitialized); - - builder.SetOptionalMessage(TestRequiredInitialized); - Assert.IsTrue(builder.IsInitialized); - - builder.AddRepeatedMessage(TestRequiredUninitialized); - Assert.IsFalse(builder.IsInitialized); - - builder.SetRepeatedMessage(0, TestRequiredInitialized); - Assert.IsTrue(builder.IsInitialized); - } - - [Test] - public void RequiredExtension() - { - TestAllExtensions.Builder builder = TestAllExtensions.CreateBuilder(); - - Assert.IsTrue(builder.IsInitialized); - - builder.SetExtension(TestRequired.Single, TestRequiredUninitialized); - Assert.IsFalse(builder.IsInitialized); - - builder.SetExtension(TestRequired.Single, TestRequiredInitialized); - Assert.IsTrue(builder.IsInitialized); - - builder.AddExtension(TestRequired.Multi, TestRequiredUninitialized); - Assert.IsFalse(builder.IsInitialized); - - builder.SetExtension(TestRequired.Multi, 0, TestRequiredInitialized); - Assert.IsTrue(builder.IsInitialized); - } - - [Test] - public void RequiredDynamic() - { - MessageDescriptor descriptor = TestRequired.Descriptor; - DynamicMessage.Builder builder = DynamicMessage.CreateBuilder(descriptor); - - Assert.IsFalse(builder.IsInitialized); - builder[descriptor.FindDescriptor("a")] = 1; - Assert.IsFalse(builder.IsInitialized); - builder[descriptor.FindDescriptor("b")] = 1; - Assert.IsFalse(builder.IsInitialized); - builder[descriptor.FindDescriptor("c")] = 1; - Assert.IsTrue(builder.IsInitialized); - } - - [Test] - public void RequiredDynamicForeign() - { - MessageDescriptor descriptor = TestRequiredForeign.Descriptor; - DynamicMessage.Builder builder = DynamicMessage.CreateBuilder(descriptor); - - Assert.IsTrue(builder.IsInitialized); - - builder[descriptor.FindDescriptor("optional_message")] = TestRequiredUninitialized; - Assert.IsFalse(builder.IsInitialized); - - builder[descriptor.FindDescriptor("optional_message")] = TestRequiredInitialized; - Assert.IsTrue(builder.IsInitialized); - - builder.AddRepeatedField(descriptor.FindDescriptor("repeated_message"), - TestRequiredUninitialized); - Assert.IsFalse(builder.IsInitialized); - - builder.SetRepeatedField(descriptor.FindDescriptor("repeated_message"), 0, - TestRequiredInitialized); - Assert.IsTrue(builder.IsInitialized); - } - - [Test] - public void UninitializedException() - { - var e = Assert.Throws(() => TestRequired.CreateBuilder().Build()); - Assert.AreEqual("Message missing required fields: a, b, c", e.Message); - } - - [Test] - public void BuildPartial() - { - // We're mostly testing that no exception is thrown. - TestRequired message = TestRequired.CreateBuilder().BuildPartial(); - Assert.IsFalse(message.IsInitialized); - } - - [Test] - public void NestedUninitializedException() - { - var e = Assert.Throws(() => TestRequiredForeign.CreateBuilder() - .SetOptionalMessage(TestRequiredUninitialized) - .AddRepeatedMessage(TestRequiredUninitialized) - .AddRepeatedMessage(TestRequiredUninitialized) - .Build()); - Assert.AreEqual( - "Message missing required fields: " + - "optional_message.a, " + - "optional_message.b, " + - "optional_message.c, " + - "repeated_message[0].a, " + - "repeated_message[0].b, " + - "repeated_message[0].c, " + - "repeated_message[1].a, " + - "repeated_message[1].b, " + - "repeated_message[1].c", - e.Message); - } - - [Test] - public void BuildNestedPartial() - { - // We're mostly testing that no exception is thrown. - TestRequiredForeign message = - TestRequiredForeign.CreateBuilder() - .SetOptionalMessage(TestRequiredUninitialized) - .AddRepeatedMessage(TestRequiredUninitialized) - .AddRepeatedMessage(TestRequiredUninitialized) - .BuildPartial(); - Assert.IsFalse(message.IsInitialized); - } - - [Test] - public void ParseUninitialized() - { - var e = Assert.Throws(() => TestRequired.ParseFrom(ByteString.Empty)); - Assert.AreEqual("Message missing required fields: a, b, c", e.Message); - } - - [Test] - public void ParseNestedUnititialized() - { - ByteString data = - TestRequiredForeign.CreateBuilder() - .SetOptionalMessage(TestRequiredUninitialized) - .AddRepeatedMessage(TestRequiredUninitialized) - .AddRepeatedMessage(TestRequiredUninitialized) - .BuildPartial().ToByteString(); - - var e = Assert.Throws(() => TestRequiredForeign.ParseFrom(data)); - Assert.AreEqual( - "Message missing required fields: " + - "optional_message.a, " + - "optional_message.b, " + - "optional_message.c, " + - "repeated_message[0].a, " + - "repeated_message[0].b, " + - "repeated_message[0].c, " + - "repeated_message[1].a, " + - "repeated_message[1].b, " + - "repeated_message[1].c", - e.Message); - } - - [Test] - public void DynamicUninitializedException() - { - var e = Assert.Throws(() => DynamicMessage.CreateBuilder(TestRequired.Descriptor).Build()); - Assert.AreEqual("Message missing required fields: a, b, c", e.Message); - } - - [Test] - public void DynamicBuildPartial() - { - // We're mostly testing that no exception is thrown. - DynamicMessage message = DynamicMessage.CreateBuilder(TestRequired.Descriptor).BuildPartial(); - Assert.IsFalse(message.Initialized); - } - - [Test] - public void DynamicParseUnititialized() - { - MessageDescriptor descriptor = TestRequired.Descriptor; - var e = Assert.Throws(() => DynamicMessage.ParseFrom(descriptor, ByteString.Empty)); - Assert.AreEqual("Message missing required fields: a, b, c", e.Message); - } - - [Test] - public void PackedTypesWrittenDirectlyToStream() - { - TestPackedTypes message = new TestPackedTypes.Builder {PackedInt32List = {0, 1, 2}}.Build(); - MemoryStream stream = new MemoryStream(); - message.WriteTo(stream); - stream.Position = 0; - TestPackedTypes readMessage = TestPackedTypes.ParseFrom(stream); - Assert.AreEqual(message, readMessage); - } - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers.Test/MessageUtilTest.cs b/csharp/src/ProtocolBuffers.Test/MessageUtilTest.cs deleted file mode 100644 index 72909660..00000000 --- a/csharp/src/ProtocolBuffers.Test/MessageUtilTest.cs +++ /dev/null @@ -1,82 +0,0 @@ -#region Copyright notice and license - -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/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 Google.ProtocolBuffers.TestProtos; -using NUnit.Framework; - -namespace Google.ProtocolBuffers -{ - public class MessageUtilTest - { - [Test] - public void NullTypeName() - { - Assert.Throws(() => MessageUtil.GetDefaultMessage((string) null)); - } - - [Test] - public void InvalidTypeName() - { - Assert.Throws(() => MessageUtil.GetDefaultMessage("invalidtypename")); - } - - [Test] - public void ValidTypeName() - { - Assert.AreSame(TestAllTypes.DefaultInstance, - MessageUtil.GetDefaultMessage(typeof(TestAllTypes).AssemblyQualifiedName)); - } - - [Test] - public void NullType() - { - Assert.Throws(() => MessageUtil.GetDefaultMessage((Type)null)); - } - - [Test] - public void NonMessageType() - { - Assert.Throws(() => MessageUtil.GetDefaultMessage(typeof(string))); - } - - [Test] - public void ValidType() - { - Assert.AreSame(TestAllTypes.DefaultInstance, MessageUtil.GetDefaultMessage(typeof(TestAllTypes))); - } - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers.Test/NameHelpersTest.cs b/csharp/src/ProtocolBuffers.Test/NameHelpersTest.cs deleted file mode 100644 index edd3ccd9..00000000 --- a/csharp/src/ProtocolBuffers.Test/NameHelpersTest.cs +++ /dev/null @@ -1,81 +0,0 @@ -#region Copyright notice and license - -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/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 NUnit.Framework; - -namespace Google.ProtocolBuffers -{ - public class NameHelpersTest - { - [Test] - public void UnderscoresToPascalCase() - { - Assert.AreEqual("FooBar", NameHelpers.UnderscoresToPascalCase("Foo_bar")); - Assert.AreEqual("FooBar", NameHelpers.UnderscoresToPascalCase("foo_bar")); - Assert.AreEqual("Foo0Bar", NameHelpers.UnderscoresToPascalCase("Foo0bar")); - Assert.AreEqual("FooBar", NameHelpers.UnderscoresToPascalCase("Foo_+_Bar")); - - Assert.AreEqual("Bar", NameHelpers.UnderscoresToPascalCase("__+bar")); - Assert.AreEqual("Bar", NameHelpers.UnderscoresToPascalCase("bar_")); - Assert.AreEqual("_0Bar", NameHelpers.UnderscoresToPascalCase("_0bar")); - Assert.AreEqual("_1Bar", NameHelpers.UnderscoresToPascalCase("_1_bar")); - } - - [Test] - public void UnderscoresToCamelCase() - { - Assert.AreEqual("fooBar", NameHelpers.UnderscoresToCamelCase("Foo_bar")); - Assert.AreEqual("fooBar", NameHelpers.UnderscoresToCamelCase("foo_bar")); - Assert.AreEqual("foo0Bar", NameHelpers.UnderscoresToCamelCase("Foo0bar")); - Assert.AreEqual("fooBar", NameHelpers.UnderscoresToCamelCase("Foo_+_Bar")); - - Assert.AreEqual("bar", NameHelpers.UnderscoresToCamelCase("__+bar")); - Assert.AreEqual("bar", NameHelpers.UnderscoresToCamelCase("bar_")); - Assert.AreEqual("_0Bar", NameHelpers.UnderscoresToCamelCase("_0bar")); - Assert.AreEqual("_1Bar", NameHelpers.UnderscoresToCamelCase("_1_bar")); - } - - [Test] - public void StripSuffix() - { - string text = "FooBar"; - Assert.IsFalse(NameHelpers.StripSuffix(ref text, "Foo")); - Assert.AreEqual("FooBar", text); - Assert.IsTrue(NameHelpers.StripSuffix(ref text, "Bar")); - Assert.AreEqual("Foo", text); - } - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj b/csharp/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj index b4c562d1..31095a5b 100644 --- a/csharp/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj +++ b/csharp/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj @@ -8,8 +8,8 @@ {DD01ED24-3750-4567-9A23-1DB676A15610} Library Properties - Google.ProtocolBuffers - Google.ProtocolBuffers.Test + Google.Protobuf + Google.Protobuf.Test v4.5 512 true @@ -71,79 +71,37 @@ - - - - - - - - - - - - - - - - - - - + + + + - - - - - - + - - - - - - - - - - - - - - - - - - - {231391AF-449C-4a39-986C-AD7F270F4750} - ProtocolBuffers.Serialization - {6908BDCE-D925-43F3-94AC-A531E6DF2591} ProtocolBuffers - - - - + + + - + \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/SortedList.cs b/csharp/src/ProtocolBuffers/SortedList.cs deleted file mode 100644 index 2dd7da92..00000000 --- a/csharp/src/ProtocolBuffers/SortedList.cs +++ /dev/null @@ -1,167 +0,0 @@ -#region Copyright notice and license - -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/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 - -#if NOSORTEDLIST -using System.Collections; -using System.Collections.Generic; - -namespace Google.ProtocolBuffers -{ - /// - /// Dictionary implementation which always yields keys in sorted order. - /// This is not particularly efficient: it wraps a normal dictionary - /// for most operations, but sorts by key when either iterating or - /// fetching the Keys/Values properties. - /// - internal sealed class SortedList : IDictionary - { - private readonly IDictionary wrapped = new Dictionary(); - - public SortedList() - { - } - - public SortedList(IDictionary dictionary) - { - foreach (KeyValuePair entry in dictionary) - { - Add(entry.Key, entry.Value); - } - } - - public void Add(TKey key, TValue value) - { - wrapped.Add(key, value); - } - - public bool ContainsKey(TKey key) - { - return wrapped.ContainsKey(key); - } - - public ICollection Keys - { - get - { - List keys = new List(wrapped.Count); - foreach (var pair in this) - { - keys.Add(pair.Key); - } - return keys; - } - } - - public bool Remove(TKey key) - { - return wrapped.Remove(key); - } - - public bool TryGetValue(TKey key, out TValue value) - { - return wrapped.TryGetValue(key, out value); - } - - public ICollection Values - { - get - { - List values = new List(wrapped.Count); - foreach (var pair in this) - { - values.Add(pair.Value); - } - return values; - } - } - - public TValue this[TKey key] - { - get { return wrapped[key]; } - set { wrapped[key] = value; } - } - - public void Add(KeyValuePair item) - { - wrapped.Add(item); - } - - public void Clear() - { - wrapped.Clear(); - } - - public bool Contains(KeyValuePair item) - { - return wrapped.Contains(item); - } - - public void CopyTo(KeyValuePair[] array, int arrayIndex) - { - wrapped.CopyTo(array, arrayIndex); - } - - public int Count - { - get { return wrapped.Count; } - } - - public bool IsReadOnly - { - get { return wrapped.IsReadOnly; } - } - - public bool Remove(KeyValuePair item) - { - return wrapped.Remove(item); - } - - public IEnumerator> GetEnumerator() - { - IComparer comparer = Comparer.Default; - var list = new List>(wrapped); - list.Sort((x, y) => comparer.Compare(x.Key, y.Key)); - return list.GetEnumerator(); - } - - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } - } -} - -#endif \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/TextFormat.cs b/csharp/src/ProtocolBuffers/TextFormat.cs deleted file mode 100644 index 6a9180f3..00000000 --- a/csharp/src/ProtocolBuffers/TextFormat.cs +++ /dev/null @@ -1,893 +0,0 @@ -#region Copyright notice and license - -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/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.Collections; -using System.Collections.Generic; -using System.Globalization; -using System.IO; -using System.Text; -using Google.ProtocolBuffers.Descriptors; - -namespace Google.ProtocolBuffers -{ - /// - /// Provides ASCII text formatting support for messages. - /// TODO(jonskeet): Support for alternative line endings. - /// (Easy to print, via TextGenerator. Not sure about parsing.) - /// - public static class TextFormat - { - /// - /// Outputs a textual representation of the Protocol Message supplied into - /// the parameter output. - /// - public static void Print(IMessage message, TextWriter output) - { - TextGenerator generator = new TextGenerator(output, "\n"); - Print(message, generator); - } - - /// - /// Outputs a textual representation of the Protocol Message builder supplied into - /// the parameter output. - /// - public static void Print(IBuilder builder, TextWriter output) - { - TextGenerator generator = new TextGenerator(output, "\n"); - Print(builder, generator); - } - - /// - /// Outputs a textual representation of to . - /// - public static void Print(UnknownFieldSet fields, TextWriter output) - { - TextGenerator generator = new TextGenerator(output, "\n"); - PrintUnknownFields(fields, generator); - } - - public static string PrintToString(IMessage message) - { - StringWriter text = new StringWriter(); - Print(message, text); - return text.ToString(); - } - - public static string PrintToString(IBuilder builder) - { - StringWriter text = new StringWriter(); - Print(builder, text); - return text.ToString(); - } - - public static string PrintToString(UnknownFieldSet fields) - { - StringWriter text = new StringWriter(); - Print(fields, text); - return text.ToString(); - } - - private static void Print(IMessage message, TextGenerator generator) - { - foreach (KeyValuePair entry in message.AllFields) - { - PrintField(entry.Key, entry.Value, generator); - } - PrintUnknownFields(message.UnknownFields, generator); - } - - private static void Print(IBuilder message, TextGenerator generator) - { - foreach (KeyValuePair entry in message.AllFields) - { - PrintField(entry.Key, entry.Value, generator); - } - PrintUnknownFields(message.UnknownFields, generator); - } - - internal static void PrintField(FieldDescriptor field, object value, TextGenerator generator) - { - if (field.IsRepeated) - { - // Repeated field. Print each element. - foreach (object element in (IEnumerable) value) - { - PrintSingleField(field, element, generator); - } - } - else - { - PrintSingleField(field, value, generator); - } - } - - private static void PrintSingleField(FieldDescriptor field, Object value, TextGenerator generator) - { - if (field.IsExtension) - { - generator.Print("["); - // We special-case MessageSet elements for compatibility with proto1. - if (field.ContainingType.Options.MessageSetWireFormat - && field.FieldType == FieldType.Message - && field.IsOptional - // object equality (TODO(jonskeet): Work out what this comment means!) - && field.ExtensionScope == field.MessageType) - { - generator.Print(field.MessageType.FullName); - } - else - { - generator.Print(field.FullName); - } - generator.Print("]"); - } - else - { - if (field.FieldType == FieldType.Group) - { - // Groups must be serialized with their original capitalization. - generator.Print(field.MessageType.Name); - } - else - { - generator.Print(field.Name); - } - } - - if (field.MappedType == MappedType.Message) - { - generator.Print(" {\n"); - generator.Indent(); - } - else - { - generator.Print(": "); - } - - PrintFieldValue(field, value, generator); - - if (field.MappedType == MappedType.Message) - { - generator.Outdent(); - generator.Print("}"); - } - generator.Print("\n"); - } - - private static void PrintFieldValue(FieldDescriptor field, object value, TextGenerator generator) - { - switch (field.FieldType) - { - // The Float and Double types must specify the "r" format to preserve their precision, otherwise, - // the double to/from string will trim the precision to 6 places. As with other numeric formats - // below, always use the invariant culture so it's predictable. - case FieldType.Float: - generator.Print(((float)value).ToString("r", FrameworkPortability.InvariantCulture)); - break; - case FieldType.Double: - generator.Print(((double)value).ToString("r", FrameworkPortability.InvariantCulture)); - break; - - case FieldType.Int32: - case FieldType.Int64: - case FieldType.SInt32: - case FieldType.SInt64: - case FieldType.SFixed32: - case FieldType.SFixed64: - case FieldType.UInt32: - case FieldType.UInt64: - case FieldType.Fixed32: - case FieldType.Fixed64: - // The simple Object.ToString converts using the current culture. - // We want to always use the invariant culture so it's predictable. - generator.Print(((IConvertible)value).ToString(FrameworkPortability.InvariantCulture)); - break; - case FieldType.Bool: - // Explicitly use the Java true/false - generator.Print((bool) value ? "true" : "false"); - break; - - case FieldType.String: - generator.Print("\""); - generator.Print(EscapeText((string) value)); - generator.Print("\""); - break; - - case FieldType.Bytes: - { - generator.Print("\""); - generator.Print(EscapeBytes((ByteString) value)); - generator.Print("\""); - break; - } - - case FieldType.Enum: - { - if (value is IEnumLite && !(value is EnumValueDescriptor)) - { - throw new NotSupportedException("Lite enumerations are not supported."); - } - generator.Print(((EnumValueDescriptor) value).Name); - break; - } - - case FieldType.Message: - case FieldType.Group: - if (value is IMessageLite && !(value is IMessage)) - { - throw new NotSupportedException("Lite messages are not supported."); - } - Print((IMessage) value, generator); - break; - } - } - - private static void PrintUnknownFields(UnknownFieldSet unknownFields, TextGenerator generator) - { - foreach (KeyValuePair entry in unknownFields.FieldDictionary) - { - String prefix = entry.Key.ToString() + ": "; - UnknownField field = entry.Value; - - foreach (ulong value in field.VarintList) - { - generator.Print(prefix); - generator.Print(value.ToString()); - generator.Print("\n"); - } - foreach (uint value in field.Fixed32List) - { - generator.Print(prefix); - generator.Print(string.Format("0x{0:x8}", value)); - generator.Print("\n"); - } - foreach (ulong value in field.Fixed64List) - { - generator.Print(prefix); - generator.Print(string.Format("0x{0:x16}", value)); - generator.Print("\n"); - } - foreach (ByteString value in field.LengthDelimitedList) - { - generator.Print(entry.Key.ToString()); - generator.Print(": \""); - generator.Print(EscapeBytes(value)); - generator.Print("\"\n"); - } - foreach (UnknownFieldSet value in field.GroupList) - { - generator.Print(entry.Key.ToString()); - generator.Print(" {\n"); - generator.Indent(); - PrintUnknownFields(value, generator); - generator.Outdent(); - generator.Print("}\n"); - } - } - } - - public static ulong ParseUInt64(string text) - { - return (ulong) ParseInteger(text, false, true); - } - - public static long ParseInt64(string text) - { - return ParseInteger(text, true, true); - } - - public static uint ParseUInt32(string text) - { - return (uint) ParseInteger(text, false, false); - } - - public static int ParseInt32(string text) - { - return (int) ParseInteger(text, true, false); - } - - public static float ParseFloat(string text) - { - switch (text) - { - case "-inf": - case "-infinity": - case "-inff": - case "-infinityf": - return float.NegativeInfinity; - case "inf": - case "infinity": - case "inff": - case "infinityf": - return float.PositiveInfinity; - case "nan": - case "nanf": - return float.NaN; - default: - return float.Parse(text, FrameworkPortability.InvariantCulture); - } - } - - public static double ParseDouble(string text) - { - switch (text) - { - case "-inf": - case "-infinity": - return double.NegativeInfinity; - case "inf": - case "infinity": - return double.PositiveInfinity; - case "nan": - return double.NaN; - default: - return double.Parse(text, FrameworkPortability.InvariantCulture); - } - } - - /// - /// Parses an integer in hex (leading 0x), decimal (no prefix) or octal (leading 0). - /// Only a negative sign is permitted, and it must come before the radix indicator. - /// - private static long ParseInteger(string text, bool isSigned, bool isLong) - { - string original = text; - bool negative = false; - if (text.StartsWith("-")) - { - if (!isSigned) - { - throw new FormatException("Number must be positive: " + original); - } - negative = true; - text = text.Substring(1); - } - - int radix = 10; - if (text.StartsWith("0x")) - { - radix = 16; - text = text.Substring(2); - } - else if (text.StartsWith("0")) - { - radix = 8; - } - - ulong result; - try - { - // Workaround for https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=278448 - // We should be able to use Convert.ToUInt64 for all cases. - result = radix == 10 ? ulong.Parse(text) : Convert.ToUInt64(text, radix); - } - catch (OverflowException) - { - // Convert OverflowException to FormatException so there's a single exception type this method can throw. - string numberDescription = string.Format("{0}-bit {1}signed integer", isLong ? 64 : 32, - isSigned ? "" : "un"); - throw new FormatException("Number out of range for " + numberDescription + ": " + original); - } - - if (negative) - { - ulong max = isLong ? 0x8000000000000000UL : 0x80000000L; - if (result > max) - { - string numberDescription = string.Format("{0}-bit signed integer", isLong ? 64 : 32); - throw new FormatException("Number out of range for " + numberDescription + ": " + original); - } - return -((long) result); - } - else - { - ulong max = isSigned - ? (isLong ? (ulong) long.MaxValue : int.MaxValue) - : (isLong ? ulong.MaxValue : uint.MaxValue); - if (result > max) - { - string numberDescription = string.Format("{0}-bit {1}signed integer", isLong ? 64 : 32, - isSigned ? "" : "un"); - throw new FormatException("Number out of range for " + numberDescription + ": " + original); - } - return (long) result; - } - } - - /// - /// Tests a character to see if it's an octal digit. - /// - private static bool IsOctal(char c) - { - return '0' <= c && c <= '7'; - } - - /// - /// Tests a character to see if it's a hex digit. - /// - private static bool IsHex(char c) - { - return ('0' <= c && c <= '9') || - ('a' <= c && c <= 'f') || - ('A' <= c && c <= 'F'); - } - - /// - /// Interprets a character as a digit (in any base up to 36) and returns the - /// numeric value. - /// - private static int ParseDigit(char c) - { - if ('0' <= c && c <= '9') - { - return c - '0'; - } - else if ('a' <= c && c <= 'z') - { - return c - 'a' + 10; - } - else - { - return c - 'A' + 10; - } - } - - /// - /// Unescapes a text string as escaped using . - /// Two-digit hex escapes (starting with "\x" are also recognised. - /// - public static string UnescapeText(string input) - { - return UnescapeBytes(input).ToStringUtf8(); - } - - /// - /// Like but escapes a text string. - /// The string is first encoded as UTF-8, then each byte escaped individually. - /// The returned value is guaranteed to be entirely ASCII. - /// - public static string EscapeText(string input) - { - return EscapeBytes(ByteString.CopyFromUtf8(input)); - } - - /// - /// Escapes bytes in the format used in protocol buffer text format, which - /// is the same as the format used for C string literals. All bytes - /// that are not printable 7-bit ASCII characters are escaped, as well as - /// backslash, single-quote, and double-quote characters. Characters for - /// which no defined short-hand escape sequence is defined will be escaped - /// using 3-digit octal sequences. - /// The returned value is guaranteed to be entirely ASCII. - /// - public static String EscapeBytes(ByteString input) - { - StringBuilder builder = new StringBuilder(input.Length); - foreach (byte b in input) - { - switch (b) - { - // C# does not use \a or \v - case 0x07: - builder.Append("\\a"); - break; - case (byte) '\b': - builder.Append("\\b"); - break; - case (byte) '\f': - builder.Append("\\f"); - break; - case (byte) '\n': - builder.Append("\\n"); - break; - case (byte) '\r': - builder.Append("\\r"); - break; - case (byte) '\t': - builder.Append("\\t"); - break; - case 0x0b: - builder.Append("\\v"); - break; - case (byte) '\\': - builder.Append("\\\\"); - break; - case (byte) '\'': - builder.Append("\\\'"); - break; - case (byte) '"': - builder.Append("\\\""); - break; - default: - if (b >= 0x20 && b < 128) - { - builder.Append((char) b); - } - else - { - builder.Append('\\'); - builder.Append((char) ('0' + ((b >> 6) & 3))); - builder.Append((char) ('0' + ((b >> 3) & 7))); - builder.Append((char) ('0' + (b & 7))); - } - break; - } - } - return builder.ToString(); - } - - /// - /// Performs string unescaping from C style (octal, hex, form feeds, tab etc) into a byte string. - /// - public static ByteString UnescapeBytes(string input) - { - byte[] result = new byte[input.Length]; - int pos = 0; - for (int i = 0; i < input.Length; i++) - { - char c = input[i]; - if (c > 127 || c < 32) - { - throw new FormatException("Escaped string must only contain ASCII"); - } - if (c != '\\') - { - result[pos++] = (byte) c; - continue; - } - if (i + 1 >= input.Length) - { - throw new FormatException("Invalid escape sequence: '\\' at end of string."); - } - - i++; - c = input[i]; - if (c >= '0' && c <= '7') - { - // Octal escape. - int code = ParseDigit(c); - if (i + 1 < input.Length && IsOctal(input[i + 1])) - { - i++; - code = code*8 + ParseDigit(input[i]); - } - if (i + 1 < input.Length && IsOctal(input[i + 1])) - { - i++; - code = code*8 + ParseDigit(input[i]); - } - result[pos++] = (byte) code; - } - else - { - switch (c) - { - case 'a': - result[pos++] = 0x07; - break; - case 'b': - result[pos++] = (byte) '\b'; - break; - case 'f': - result[pos++] = (byte) '\f'; - break; - case 'n': - result[pos++] = (byte) '\n'; - break; - case 'r': - result[pos++] = (byte) '\r'; - break; - case 't': - result[pos++] = (byte) '\t'; - break; - case 'v': - result[pos++] = 0x0b; - break; - case '\\': - result[pos++] = (byte) '\\'; - break; - case '\'': - result[pos++] = (byte) '\''; - break; - case '"': - result[pos++] = (byte) '\"'; - break; - - case 'x': - // hex escape - int code; - if (i + 1 < input.Length && IsHex(input[i + 1])) - { - i++; - code = ParseDigit(input[i]); - } - else - { - throw new FormatException("Invalid escape sequence: '\\x' with no digits"); - } - if (i + 1 < input.Length && IsHex(input[i + 1])) - { - ++i; - code = code*16 + ParseDigit(input[i]); - } - result[pos++] = (byte) code; - break; - - default: - throw new FormatException("Invalid escape sequence: '\\" + c + "'"); - } - } - } - - return ByteString.CopyFrom(result, 0, pos); - } - - public static void Merge(string text, IBuilder builder) - { - Merge(text, ExtensionRegistry.Empty, builder); - } - - public static void Merge(TextReader reader, IBuilder builder) - { - Merge(reader, ExtensionRegistry.Empty, builder); - } - - public static void Merge(TextReader reader, ExtensionRegistry registry, IBuilder builder) - { - Merge(reader.ReadToEnd(), registry, builder); - } - - public static void Merge(string text, ExtensionRegistry registry, IBuilder builder) - { - TextTokenizer tokenizer = new TextTokenizer(text); - - while (!tokenizer.AtEnd) - { - MergeField(tokenizer, registry, builder); - } - } - - /// - /// Parses a single field from the specified tokenizer and merges it into - /// the builder. - /// - private static void MergeField(TextTokenizer tokenizer, ExtensionRegistry extensionRegistry, - IBuilder builder) - { - FieldDescriptor field; - MessageDescriptor type = builder.DescriptorForType; - ExtensionInfo extension = null; - - if (tokenizer.TryConsume("[")) - { - // An extension. - StringBuilder name = new StringBuilder(tokenizer.ConsumeIdentifier()); - while (tokenizer.TryConsume(".")) - { - name.Append("."); - name.Append(tokenizer.ConsumeIdentifier()); - } - - extension = extensionRegistry.FindByName(type, name.ToString()); - - if (extension == null) - { - throw tokenizer.CreateFormatExceptionPreviousToken("Extension \"" + name + - "\" not found in the ExtensionRegistry."); - } - else if (extension.Descriptor.ContainingType != type) - { - throw tokenizer.CreateFormatExceptionPreviousToken("Extension \"" + name + - "\" does not extend message type \"" + - type.FullName + "\"."); - } - - tokenizer.Consume("]"); - - field = extension.Descriptor; - } - else - { - String name = tokenizer.ConsumeIdentifier(); - field = type.FindDescriptor(name); - - // Group names are expected to be capitalized as they appear in the - // .proto file, which actually matches their type names, not their field - // names. - if (field == null) - { - // Explicitly specify the invariant culture so that this code does not break when - // executing in Turkey. - String lowerName = name.ToLowerInvariant(); - field = type.FindDescriptor(lowerName); - // If the case-insensitive match worked but the field is NOT a group, - // TODO(jonskeet): What? Java comment ends here! - if (field != null && field.FieldType != FieldType.Group) - { - field = null; - } - } - // Again, special-case group names as described above. - if (field != null && field.FieldType == FieldType.Group && field.MessageType.Name != name) - { - field = null; - } - - if (field == null) - { - throw tokenizer.CreateFormatExceptionPreviousToken( - "Message type \"" + type.FullName + "\" has no field named \"" + name + "\"."); - } - } - - object value = null; - - if (field.MappedType == MappedType.Message) - { - tokenizer.TryConsume(":"); // optional - - String endToken; - if (tokenizer.TryConsume("<")) - { - endToken = ">"; - } - else - { - tokenizer.Consume("{"); - endToken = "}"; - } - - IBuilder subBuilder; - if (extension == null) - { - subBuilder = builder.CreateBuilderForField(field); - } - else - { - subBuilder = extension.DefaultInstance.WeakCreateBuilderForType() as IBuilder; - if (subBuilder == null) - { - throw new NotSupportedException("Lite messages are not supported."); - } - } - - while (!tokenizer.TryConsume(endToken)) - { - if (tokenizer.AtEnd) - { - throw tokenizer.CreateFormatException("Expected \"" + endToken + "\"."); - } - MergeField(tokenizer, extensionRegistry, subBuilder); - } - - value = subBuilder.WeakBuild(); - } - else - { - tokenizer.Consume(":"); - - switch (field.FieldType) - { - case FieldType.Int32: - case FieldType.SInt32: - case FieldType.SFixed32: - value = tokenizer.ConsumeInt32(); - break; - - case FieldType.Int64: - case FieldType.SInt64: - case FieldType.SFixed64: - value = tokenizer.ConsumeInt64(); - break; - - case FieldType.UInt32: - case FieldType.Fixed32: - value = tokenizer.ConsumeUInt32(); - break; - - case FieldType.UInt64: - case FieldType.Fixed64: - value = tokenizer.ConsumeUInt64(); - break; - - case FieldType.Float: - value = tokenizer.ConsumeFloat(); - break; - - case FieldType.Double: - value = tokenizer.ConsumeDouble(); - break; - - case FieldType.Bool: - value = tokenizer.ConsumeBoolean(); - break; - - case FieldType.String: - value = tokenizer.ConsumeString(); - break; - - case FieldType.Bytes: - value = tokenizer.ConsumeByteString(); - break; - - case FieldType.Enum: - { - EnumDescriptor enumType = field.EnumType; - - if (tokenizer.LookingAtInteger()) - { - int number = tokenizer.ConsumeInt32(); - value = enumType.FindValueByNumber(number); - if (value == null) - { - throw tokenizer.CreateFormatExceptionPreviousToken( - "Enum type \"" + enumType.FullName + - "\" has no value with number " + number + "."); - } - } - else - { - String id = tokenizer.ConsumeIdentifier(); - value = enumType.FindValueByName(id); - if (value == null) - { - throw tokenizer.CreateFormatExceptionPreviousToken( - "Enum type \"" + enumType.FullName + - "\" has no value named \"" + id + "\"."); - } - } - - break; - } - - case FieldType.Message: - case FieldType.Group: - throw new InvalidOperationException("Can't get here."); - } - } - - if (field.IsRepeated) - { - builder.WeakAddRepeatedField(field, value); - } - else - { - builder.SetField(field, value); - } - } - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/TextGenerator.cs b/csharp/src/ProtocolBuffers/TextGenerator.cs index 30cbf0fd..80910ba1 100644 --- a/csharp/src/ProtocolBuffers/TextGenerator.cs +++ b/csharp/src/ProtocolBuffers/TextGenerator.cs @@ -38,7 +38,7 @@ using System; using System.IO; using System.Text; -namespace Google.ProtocolBuffers +namespace Google.Protobuf { /// /// Helper class to control indentation. Used for TextFormat and by ProtoGen. diff --git a/csharp/src/ProtocolBuffers/TextTokenizer.cs b/csharp/src/ProtocolBuffers/TextTokenizer.cs deleted file mode 100644 index 5bb27fd0..00000000 --- a/csharp/src/ProtocolBuffers/TextTokenizer.cs +++ /dev/null @@ -1,501 +0,0 @@ -#region Copyright notice and license - -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/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.Globalization; -using System.Text.RegularExpressions; - -namespace Google.ProtocolBuffers -{ - /// - /// Represents a stream of tokens parsed from a string. - /// - internal sealed class TextTokenizer - { - private readonly string text; - private string currentToken; - - /// - /// The character index within the text to perform the next regex match at. - /// - private int matchPos = 0; - - /// - /// The character index within the text at which the current token begins. - /// - private int pos = 0; - - /// - /// The line number of the current token. - /// - private int line = 0; - - /// - /// The column number of the current token. - /// - private int column = 0; - - /// - /// The line number of the previous token. - /// - private int previousLine = 0; - - /// - /// The column number of the previous token. - /// - private int previousColumn = 0; - - // Note: atomic groups used to mimic possessive quantifiers in Java in both of these regexes - internal static readonly Regex WhitespaceAndCommentPattern = new Regex("\\G(?>(\\s|(#.*$))+)", - FrameworkPortability. - CompiledRegexWhereAvailable | - RegexOptions.Multiline); - - private static readonly Regex TokenPattern = new Regex( - "\\G[a-zA-Z_](?>[0-9a-zA-Z_+-]*)|" + // an identifier - "\\G[0-9+-](?>[0-9a-zA-Z_.+-]*)|" + // a number - "\\G\"(?>([^\"\\\n\\\\]|\\\\.)*)(\"|\\\\?$)|" + // a double-quoted string - "\\G\'(?>([^\"\\\n\\\\]|\\\\.)*)(\'|\\\\?$)", // a single-quoted string - FrameworkPortability.CompiledRegexWhereAvailable | RegexOptions.Multiline); - - private static readonly Regex DoubleInfinity = new Regex("^-?inf(inity)?$", - FrameworkPortability.CompiledRegexWhereAvailable | - RegexOptions.IgnoreCase); - - private static readonly Regex FloatInfinity = new Regex("^-?inf(inity)?f?$", - FrameworkPortability.CompiledRegexWhereAvailable | - RegexOptions.IgnoreCase); - - private static readonly Regex FloatNan = new Regex("^nanf?$", - FrameworkPortability.CompiledRegexWhereAvailable | - RegexOptions.IgnoreCase); - - /** Construct a tokenizer that parses tokens from the given text. */ - - public TextTokenizer(string text) - { - this.text = text; - SkipWhitespace(); - NextToken(); - } - - /// - /// Are we at the end of the input? - /// - public bool AtEnd - { - get { return currentToken.Length == 0; } - } - - /// - /// Advances to the next token. - /// - public void NextToken() - { - previousLine = line; - previousColumn = column; - - // Advance the line counter to the current position. - while (pos < matchPos) - { - if (text[pos] == '\n') - { - ++line; - column = 0; - } - else - { - ++column; - } - ++pos; - } - - // Match the next token. - if (matchPos == text.Length) - { - // EOF - currentToken = ""; - } - else - { - Match match = TokenPattern.Match(text, matchPos); - if (match.Success) - { - currentToken = match.Value; - matchPos += match.Length; - } - else - { - // Take one character. - currentToken = text[matchPos].ToString(); - matchPos++; - } - - SkipWhitespace(); - } - } - - /// - /// Skip over any whitespace so that matchPos starts at the next token. - /// - private void SkipWhitespace() - { - Match match = WhitespaceAndCommentPattern.Match(text, matchPos); - if (match.Success) - { - matchPos += match.Length; - } - } - - /// - /// If the next token exactly matches the given token, consume it and return - /// true. Otherwise, return false without doing anything. - /// - public bool TryConsume(string token) - { - if (currentToken == token) - { - NextToken(); - return true; - } - return false; - } - - /* - * If the next token exactly matches {@code token}, consume it. Otherwise, - * throw a {@link ParseException}. - */ - - /// - /// If the next token exactly matches the specified one, consume it. - /// Otherwise, throw a FormatException. - /// - /// - public void Consume(string token) - { - if (!TryConsume(token)) - { - throw CreateFormatException("Expected \"" + token + "\"."); - } - } - - /// - /// Returns true if the next token is an integer, but does not consume it. - /// - public bool LookingAtInteger() - { - if (currentToken.Length == 0) - { - return false; - } - - char c = currentToken[0]; - return ('0' <= c && c <= '9') || c == '-' || c == '+'; - } - - /// - /// If the next token is an identifier, consume it and return its value. - /// Otherwise, throw a FormatException. - /// - public string ConsumeIdentifier() - { - foreach (char c in currentToken) - { - if (('a' <= c && c <= 'z') || - ('A' <= c && c <= 'Z') || - ('0' <= c && c <= '9') || - (c == '_') || (c == '.')) - { - // OK - } - else - { - throw CreateFormatException("Expected identifier."); - } - } - - string result = currentToken; - NextToken(); - return result; - } - - /// - /// If the next token is a 32-bit signed integer, consume it and return its - /// value. Otherwise, throw a FormatException. - /// - public int ConsumeInt32() - { - try - { - int result = TextFormat.ParseInt32(currentToken); - NextToken(); - return result; - } - catch (FormatException e) - { - throw CreateIntegerParseException(e); - } - } - - /// - /// If the next token is a 32-bit unsigned integer, consume it and return its - /// value. Otherwise, throw a FormatException. - /// - public uint ConsumeUInt32() - { - try - { - uint result = TextFormat.ParseUInt32(currentToken); - NextToken(); - return result; - } - catch (FormatException e) - { - throw CreateIntegerParseException(e); - } - } - - /// - /// If the next token is a 64-bit signed integer, consume it and return its - /// value. Otherwise, throw a FormatException. - /// - public long ConsumeInt64() - { - try - { - long result = TextFormat.ParseInt64(currentToken); - NextToken(); - return result; - } - catch (FormatException e) - { - throw CreateIntegerParseException(e); - } - } - - /// - /// If the next token is a 64-bit unsigned integer, consume it and return its - /// value. Otherwise, throw a FormatException. - /// - public ulong ConsumeUInt64() - { - try - { - ulong result = TextFormat.ParseUInt64(currentToken); - NextToken(); - return result; - } - catch (FormatException e) - { - throw CreateIntegerParseException(e); - } - } - - /// - /// If the next token is a double, consume it and return its value. - /// Otherwise, throw a FormatException. - /// - public double ConsumeDouble() - { - // We need to parse infinity and nan separately because - // double.Parse() does not accept "inf", "infinity", or "nan". - if (DoubleInfinity.IsMatch(currentToken)) - { - bool negative = currentToken.StartsWith("-"); - NextToken(); - return negative ? double.NegativeInfinity : double.PositiveInfinity; - } - if (currentToken.Equals("nan", StringComparison.OrdinalIgnoreCase)) - { - NextToken(); - return Double.NaN; - } - - try - { - double result = double.Parse(currentToken, FrameworkPortability.InvariantCulture); - NextToken(); - return result; - } - catch (FormatException e) - { - throw CreateFloatParseException(e); - } - catch (OverflowException e) - { - throw CreateFloatParseException(e); - } - } - - /// - /// If the next token is a float, consume it and return its value. - /// Otherwise, throw a FormatException. - /// - public float ConsumeFloat() - { - // We need to parse infinity and nan separately because - // Float.parseFloat() does not accept "inf", "infinity", or "nan". - if (FloatInfinity.IsMatch(currentToken)) - { - bool negative = currentToken.StartsWith("-"); - NextToken(); - return negative ? float.NegativeInfinity : float.PositiveInfinity; - } - if (FloatNan.IsMatch(currentToken)) - { - NextToken(); - return float.NaN; - } - - if (currentToken.EndsWith("f")) - { - currentToken = currentToken.TrimEnd('f'); - } - - try - { - float result = float.Parse(currentToken, FrameworkPortability.InvariantCulture); - NextToken(); - return result; - } - catch (FormatException e) - { - throw CreateFloatParseException(e); - } - catch (OverflowException e) - { - throw CreateFloatParseException(e); - } - } - - /// - /// If the next token is a Boolean, consume it and return its value. - /// Otherwise, throw a FormatException. - /// - public bool ConsumeBoolean() - { - if (currentToken == "true") - { - NextToken(); - return true; - } - if (currentToken == "false") - { - NextToken(); - return false; - } - throw CreateFormatException("Expected \"true\" or \"false\"."); - } - - /// - /// If the next token is a string, consume it and return its (unescaped) value. - /// Otherwise, throw a FormatException. - /// - public string ConsumeString() - { - return ConsumeByteString().ToStringUtf8(); - } - - /// - /// If the next token is a string, consume it, unescape it as a - /// ByteString and return it. Otherwise, throw a FormatException. - /// - public ByteString ConsumeByteString() - { - char quote = currentToken.Length > 0 ? currentToken[0] : '\0'; - if (quote != '\"' && quote != '\'') - { - throw CreateFormatException("Expected string."); - } - - if (currentToken.Length < 2 || - currentToken[currentToken.Length - 1] != quote) - { - throw CreateFormatException("String missing ending quote."); - } - - try - { - string escaped = currentToken.Substring(1, currentToken.Length - 2); - ByteString result = TextFormat.UnescapeBytes(escaped); - NextToken(); - return result; - } - catch (FormatException e) - { - throw CreateFormatException(e.Message); - } - } - - /// - /// Returns a format exception with the current line and column numbers - /// in the description, suitable for throwing. - /// - public FormatException CreateFormatException(string description) - { - // Note: People generally prefer one-based line and column numbers. - return new FormatException((line + 1) + ":" + (column + 1) + ": " + description); - } - - /// - /// Returns a format exception with the line and column numbers of the - /// previous token in the description, suitable for throwing. - /// - public FormatException CreateFormatExceptionPreviousToken(string description) - { - // Note: People generally prefer one-based line and column numbers. - return new FormatException((previousLine + 1) + ":" + (previousColumn + 1) + ": " + description); - } - - /// - /// Constructs an appropriate FormatException for the given existing exception - /// when trying to parse an integer. - /// - private FormatException CreateIntegerParseException(FormatException e) - { - return CreateFormatException("Couldn't parse integer: " + e.Message); - } - - /// - /// Constructs an appropriate FormatException for the given existing exception - /// when trying to parse a float or double. - /// - private FormatException CreateFloatParseException(Exception e) - { - return CreateFormatException("Couldn't parse number: " + e.Message); - } - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/ThrowHelper.cs b/csharp/src/ProtocolBuffers/ThrowHelper.cs index 69e5f569..097b5032 100644 --- a/csharp/src/ProtocolBuffers/ThrowHelper.cs +++ b/csharp/src/ProtocolBuffers/ThrowHelper.cs @@ -37,7 +37,7 @@ using System; using System.Collections.Generic; -namespace Google.ProtocolBuffers +namespace Google.Protobuf { /// /// Helper methods for throwing exceptions diff --git a/csharp/src/ProtocolBuffers/UninitializedMessageException.cs b/csharp/src/ProtocolBuffers/UninitializedMessageException.cs deleted file mode 100644 index 9e4f856e..00000000 --- a/csharp/src/ProtocolBuffers/UninitializedMessageException.cs +++ /dev/null @@ -1,208 +0,0 @@ -#region Copyright notice and license - -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/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.Collections; -using System.Collections.Generic; -using System.Text; - -#if !LITE -using Google.ProtocolBuffers.Collections; -using Google.ProtocolBuffers.Descriptors; - -#endif - -namespace Google.ProtocolBuffers -{ - /// - /// TODO(jonskeet): Write summary text. - /// - public sealed class UninitializedMessageException : Exception - { - private readonly IList missingFields; - - private UninitializedMessageException(IList missingFields) - : base(BuildDescription(missingFields)) - { - this.missingFields = new List(missingFields); - } - - /// - /// Returns a read-only list of human-readable names of - /// required fields missing from this message. Each name - /// is a full path to a field, e.g. "foo.bar[5].baz" - /// - public IList MissingFields - { - get { return missingFields; } - } - - /// - /// Converts this exception into an InvalidProtocolBufferException. - /// When a parsed message is missing required fields, this should be thrown - /// instead of UninitializedMessageException. - /// - public InvalidProtocolBufferException AsInvalidProtocolBufferException() - { - return new InvalidProtocolBufferException(Message); - } - - /// - /// Constructs the description string for a given list of missing fields. - /// - private static string BuildDescription(IEnumerable missingFields) - { - StringBuilder description = new StringBuilder("Message missing required fields: "); - bool first = true; - foreach (string field in missingFields) - { - if (first) - { - first = false; - } - else - { - description.Append(", "); - } - description.Append(field); - } - return description.ToString(); - } - - /// - /// For Lite exceptions that do not known how to enumerate missing fields - /// - public UninitializedMessageException(IMessageLite message) - : base(String.Format("Message {0} is missing required fields", message.GetType())) - { - missingFields = new List(); - } - -#if !LITE - public UninitializedMessageException(IMessage message) - : this(FindMissingFields(message)) - { - } - - /// - /// Returns a list of the full "paths" of missing required - /// fields in the specified message. - /// - private static IList FindMissingFields(IMessage message) - { - List results = new List(); - FindMissingFields(message, "", results); - return results; - } - - /// - /// Recursive helper implementing FindMissingFields. - /// - private static void FindMissingFields(IMessage message, String prefix, List results) - { - foreach (FieldDescriptor field in message.DescriptorForType.Fields) - { - if (field.IsRequired && !message.HasField(field)) - { - results.Add(prefix + field.Name); - } - } - - foreach (KeyValuePair entry in message.AllFields) - { - FieldDescriptor field = entry.Key; - object value = entry.Value; - - if (field.MappedType == MappedType.Message) - { - if (field.IsRepeated) - { - int i = 0; - foreach (object element in (IEnumerable) value) - { - if (element is IMessage) - { - FindMissingFields((IMessage) element, SubMessagePrefix(prefix, field, i++), results); - } - else - { - results.Add(prefix + field.Name); - } - } - } - else - { - if (message.HasField(field)) - { - if (value is IMessage) - { - FindMissingFields((IMessage) value, SubMessagePrefix(prefix, field, -1), results); - } - else - { - results.Add(prefix + field.Name); - } - } - } - } - } - } - - private static String SubMessagePrefix(String prefix, FieldDescriptor field, int index) - { - StringBuilder result = new StringBuilder(prefix); - if (field.IsExtension) - { - result.Append('(') - .Append(field.FullName) - .Append(')'); - } - else - { - result.Append(field.Name); - } - if (index != -1) - { - result.Append('[') - .Append(index) - .Append(']'); - } - result.Append('.'); - return result.ToString(); - } -#endif - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/UnknownField.cs b/csharp/src/ProtocolBuffers/UnknownField.cs deleted file mode 100644 index 7650b9df..00000000 --- a/csharp/src/ProtocolBuffers/UnknownField.cs +++ /dev/null @@ -1,415 +0,0 @@ -#region Copyright notice and license - -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/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.Collections.Generic; -using System.Collections.ObjectModel; -using Google.ProtocolBuffers.Collections; - -namespace Google.ProtocolBuffers -{ - /// - /// Represents a single field in an UnknownFieldSet. - /// - /// An UnknownField consists of five lists of values. The lists correspond - /// to the five "wire types" used in the protocol buffer binary format. - /// The wire type of each field can be determined from the encoded form alone, - /// without knowing the field's declared type. So, we are able to parse - /// unknown values at least this far and separate them. Normally, only one - /// of the five lists will contain any values, since it is impossible to - /// define a valid message type that declares two different types for the - /// same field number. However, the code is designed to allow for the case - /// where the same unknown field number is encountered using multiple different - /// wire types. - /// - /// UnknownField is an immutable class. To construct one, you must use an - /// UnknownField.Builder. - /// - public sealed class UnknownField - { - public const string UnknownFieldName = "unknown_field"; - private static readonly UnknownField defaultInstance = CreateBuilder().Build(); - private readonly ReadOnlyCollection varintList; - private readonly ReadOnlyCollection fixed32List; - private readonly ReadOnlyCollection fixed64List; - private readonly ReadOnlyCollection lengthDelimitedList; - private readonly ReadOnlyCollection groupList; - - private UnknownField(ReadOnlyCollection varintList, - ReadOnlyCollection fixed32List, - ReadOnlyCollection fixed64List, - ReadOnlyCollection lengthDelimitedList, - ReadOnlyCollection groupList) - { - this.varintList = varintList; - this.fixed32List = fixed32List; - this.fixed64List = fixed64List; - this.lengthDelimitedList = lengthDelimitedList; - this.groupList = groupList; - } - - public static UnknownField DefaultInstance - { - get { return defaultInstance; } - } - - /// - /// The list of varint values for this field. - /// - public IList VarintList - { - get { return varintList; } - } - - /// - /// The list of fixed32 values for this field. - /// - public IList Fixed32List - { - get { return fixed32List; } - } - - /// - /// The list of fixed64 values for this field. - /// - public IList Fixed64List - { - get { return fixed64List; } - } - - /// - /// The list of length-delimited values for this field. - /// - public IList LengthDelimitedList - { - get { return lengthDelimitedList; } - } - - /// - /// The list of embedded group values for this field. These - /// are represented using UnknownFieldSets rather than Messages - /// since the group's type is presumably unknown. - /// - public IList GroupList - { - get { return groupList; } - } - - public override bool Equals(object other) - { - if (ReferenceEquals(this, other)) - { - return true; - } - UnknownField otherField = other as UnknownField; - return otherField != null - && Lists.Equals(varintList, otherField.varintList) - && Lists.Equals(fixed32List, otherField.fixed32List) - && Lists.Equals(fixed64List, otherField.fixed64List) - && Lists.Equals(lengthDelimitedList, otherField.lengthDelimitedList) - && Lists.Equals(groupList, otherField.groupList); - } - - public override int GetHashCode() - { - int hash = 43; - hash = hash*47 + Lists.GetHashCode(varintList); - hash = hash*47 + Lists.GetHashCode(fixed32List); - hash = hash*47 + Lists.GetHashCode(fixed64List); - hash = hash*47 + Lists.GetHashCode(lengthDelimitedList); - hash = hash*47 + Lists.GetHashCode(groupList); - return hash; - } - - /// - /// Constructs a new Builder. - /// - public static Builder CreateBuilder() - { - return new Builder(); - } - - /// - /// Constructs a new Builder and initializes it to a copy of . - /// - public static Builder CreateBuilder(UnknownField copyFrom) - { - return new Builder().MergeFrom(copyFrom); - } - - /// - /// Serializes the field, including the field number, and writes it to - /// . - /// - public void WriteTo(int fieldNumber, ICodedOutputStream output) - { - foreach (ulong value in varintList) - { - output.WriteUnknownField(fieldNumber, WireFormat.WireType.Varint, value); - } - foreach (uint value in fixed32List) - { - output.WriteUnknownField(fieldNumber, WireFormat.WireType.Fixed32, value); - } - foreach (ulong value in fixed64List) - { - output.WriteUnknownField(fieldNumber, WireFormat.WireType.Fixed64, value); - } - foreach (ByteString value in lengthDelimitedList) - { - output.WriteUnknownBytes(fieldNumber, value); - } - foreach (UnknownFieldSet value in groupList) - { -#pragma warning disable 0612 - output.WriteUnknownGroup(fieldNumber, value); -#pragma warning restore 0612 - } - } - - /// - /// Computes the number of bytes required to encode this field, including field - /// number. - /// - public int GetSerializedSize(int fieldNumber) - { - int result = 0; - foreach (ulong value in varintList) - { - result += CodedOutputStream.ComputeUInt64Size(fieldNumber, value); - } - foreach (uint value in fixed32List) - { - result += CodedOutputStream.ComputeFixed32Size(fieldNumber, value); - } - foreach (ulong value in fixed64List) - { - result += CodedOutputStream.ComputeFixed64Size(fieldNumber, value); - } - foreach (ByteString value in lengthDelimitedList) - { - result += CodedOutputStream.ComputeBytesSize(fieldNumber, value); - } - foreach (UnknownFieldSet value in groupList) - { -#pragma warning disable 0612 - result += CodedOutputStream.ComputeUnknownGroupSize(fieldNumber, value); -#pragma warning restore 0612 - } - return result; - } - - /// - /// Serializes the length-delimited values of the field, including field - /// number, and writes them to using the MessageSet wire format. - /// - /// - /// - public void WriteAsMessageSetExtensionTo(int fieldNumber, ICodedOutputStream output) - { - foreach (ByteString value in lengthDelimitedList) - { - output.WriteMessageSetExtension(fieldNumber, UnknownFieldName, value); - } - } - - /// - /// Get the number of bytes required to encode this field, incuding field number, - /// using the MessageSet wire format. - /// - public int GetSerializedSizeAsMessageSetExtension(int fieldNumber) - { - int result = 0; - foreach (ByteString value in lengthDelimitedList) - { - result += CodedOutputStream.ComputeRawMessageSetExtensionSize(fieldNumber, value); - } - return result; - } - - /// - /// Used to build instances of UnknownField. - /// - public sealed class Builder - { - private List varintList; - private List fixed32List; - private List fixed64List; - private List lengthDelimitedList; - private List groupList; - - /// - /// Builds the field. After building, the builder is reset to an empty - /// state. (This is actually easier than making it unusable.) - /// - public UnknownField Build() - { - return new UnknownField(MakeReadOnly(ref varintList), - MakeReadOnly(ref fixed32List), - MakeReadOnly(ref fixed64List), - MakeReadOnly(ref lengthDelimitedList), - MakeReadOnly(ref groupList)); - } - - /// - /// Merge the values in into this field. For each list - /// of values, 's values are append to the ones in this - /// field. - /// - public Builder MergeFrom(UnknownField other) - { - varintList = AddAll(varintList, other.VarintList); - fixed32List = AddAll(fixed32List, other.Fixed32List); - fixed64List = AddAll(fixed64List, other.Fixed64List); - lengthDelimitedList = AddAll(lengthDelimitedList, other.LengthDelimitedList); - groupList = AddAll(groupList, other.GroupList); - return this; - } - - /// - /// Returns a new list containing all of the given specified values from - /// both the and lists. - /// If is null and is empty, - /// null is returned. Otherwise, either a new list is created (if - /// is null) or the elements of are added to . - /// - private static List AddAll(List current, IList extras) - { - if (extras.Count == 0) - { - return current; - } - if (current == null) - { - current = new List(extras); - } - else - { - current.AddRange(extras); - } - return current; - } - - /// - /// Clears the contents of this builder. - /// - public Builder Clear() - { - varintList = null; - fixed32List = null; - fixed64List = null; - lengthDelimitedList = null; - groupList = null; - return this; - } - - /// - /// Adds a varint value. - /// - public Builder AddVarint(ulong value) - { - varintList = Add(varintList, value); - return this; - } - - /// - /// Adds a fixed32 value. - /// - public Builder AddFixed32(uint value) - { - fixed32List = Add(fixed32List, value); - return this; - } - - /// - /// Adds a fixed64 value. - /// - public Builder AddFixed64(ulong value) - { - fixed64List = Add(fixed64List, value); - return this; - } - - /// - /// Adds a length-delimited value. - /// - public Builder AddLengthDelimited(ByteString value) - { - lengthDelimitedList = Add(lengthDelimitedList, value); - return this; - } - - /// - /// Adds an embedded group. - /// - /// - /// - public Builder AddGroup(UnknownFieldSet value) - { - groupList = Add(groupList, value); - return this; - } - - /// - /// Adds to the , creating - /// a new list if is null. The list is returned - either - /// the original reference or the new list. - /// - private static List Add(List list, T value) - { - if (list == null) - { - list = new List(); - } - list.Add(value); - return list; - } - - /// - /// Returns a read-only version of the given IList, and clears - /// the field used for . If the value - /// is null, an empty list is produced using Lists.Empty. - /// - /// - private static ReadOnlyCollection MakeReadOnly(ref List list) - { - ReadOnlyCollection ret = list == null ? Lists.Empty : new ReadOnlyCollection(list); - list = null; - return ret; - } - } - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/UnknownFieldSet.cs b/csharp/src/ProtocolBuffers/UnknownFieldSet.cs deleted file mode 100644 index d5d0675d..00000000 --- a/csharp/src/ProtocolBuffers/UnknownFieldSet.cs +++ /dev/null @@ -1,1061 +0,0 @@ -#region Copyright notice and license - -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/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.Collections.Generic; -using System.IO; -using Google.ProtocolBuffers.Collections; -using Google.ProtocolBuffers.Descriptors; - -namespace Google.ProtocolBuffers -{ - /// - /// Used to keep track of fields which were seen when parsing a protocol message - /// but whose field numbers or types are unrecognized. This most frequently - /// occurs when new fields are added to a message type and then messages containing - /// those fields are read by old software that was built before the new types were - /// added. - /// - /// Every message contains an UnknownFieldSet. - /// - /// Most users will never need to use this class directly. - /// - public sealed partial class UnknownFieldSet : IMessageLite - { - private static readonly UnknownFieldSet defaultInstance = - new UnknownFieldSet(new Dictionary()); - - private readonly IDictionary fields; - - private UnknownFieldSet(IDictionary fields) - { - this.fields = fields; - } - - /// - /// Creates a new unknown field set builder. - /// - public static Builder CreateBuilder() - { - return new Builder(); - } - - /// - /// Creates a new unknown field set builder - /// and initialize it from . - /// - public static Builder CreateBuilder(UnknownFieldSet original) - { - return new Builder().MergeFrom(original); - } - - public static UnknownFieldSet DefaultInstance - { - get { return defaultInstance; } - } - - /// - /// Returns a read-only view of the mapping from field numbers to values. - /// - public IDictionary FieldDictionary - { - get { return Dictionaries.AsReadOnly(fields); } - } - - /// - /// Checks whether or not the given field number is present in the set. - /// - public bool HasField(int field) - { - return fields.ContainsKey(field); - } - - /// - /// Fetches a field by number, returning an empty field if not present. - /// Never returns null. - /// - public UnknownField this[int number] - { - get - { - UnknownField ret; - if (!fields.TryGetValue(number, out ret)) - { - ret = UnknownField.DefaultInstance; - } - return ret; - } - } - - /// - /// Serializes the set and writes it to . - /// - public void WriteTo(ICodedOutputStream output) - { - // Avoid creating enumerator for the most common code path. - if (fields.Count > 0) - { - foreach (KeyValuePair entry in fields) - { - entry.Value.WriteTo(entry.Key, output); - } - } - } - - /// - /// Gets the number of bytes required to encode this set. - /// - public int SerializedSize - { - get - { - // Avoid creating enumerator for the most common code path. - if (fields.Count == 0) - { - return 0; - } - - int result = 0; - foreach (KeyValuePair entry in fields) - { - result += entry.Value.GetSerializedSize(entry.Key); - } - return result; - } - } - - /// - /// Converts the set to a string in protocol buffer text format. This - /// is just a trivial wrapper around TextFormat.PrintToString. - /// - public override String ToString() - { - return TextFormat.PrintToString(this); - } - - /// - /// Converts the set to a string in protocol buffer text format. This - /// is just a trivial wrapper around TextFormat.PrintToString. - /// - public void PrintTo(TextWriter writer) - { - TextFormat.Print(this, writer); - } - - /// - /// Serializes the message to a ByteString and returns it. This is - /// just a trivial wrapper around WriteTo(ICodedOutputStream). - /// - /// - public ByteString ToByteString() - { - ByteString.CodedBuilder codedBuilder = new ByteString.CodedBuilder(SerializedSize); - WriteTo(codedBuilder.CodedOutput); - return codedBuilder.Build(); - } - - /// - /// Serializes the message to a byte array and returns it. This is - /// just a trivial wrapper around WriteTo(ICodedOutputStream). - /// - /// - public byte[] ToByteArray() - { - byte[] data = new byte[SerializedSize]; - CodedOutputStream output = CodedOutputStream.CreateInstance(data); - WriteTo(output); - output.CheckNoSpaceLeft(); - return data; - } - - /// - /// Serializes the message and writes it to . This is - /// just a trivial wrapper around WriteTo(ICodedOutputStream). - /// - /// - public void WriteTo(Stream output) - { - CodedOutputStream codedOutput = CodedOutputStream.CreateInstance(output); - WriteTo(codedOutput); - codedOutput.Flush(); - } - - /// - /// Serializes the set and writes it to using - /// the MessageSet wire format. - /// - public void WriteAsMessageSetTo(ICodedOutputStream output) - { - // Avoid creating enumerator for the most common code path. - if (fields.Count > 0) - { - foreach (KeyValuePair entry in fields) - { - entry.Value.WriteAsMessageSetExtensionTo(entry.Key, output); - } - } - } - - /// - /// Gets the number of bytes required to encode this set using the MessageSet - /// wire format. - /// - public int SerializedSizeAsMessageSet - { - get - { - // Avoid creating enumerator for the most common code path. - if (fields.Count == 0) - { - return 0; - } - - int result = 0; - foreach (KeyValuePair entry in fields) - { - result += entry.Value.GetSerializedSizeAsMessageSetExtension(entry.Key); - } - return result; - } - } - - public override bool Equals(object other) - { - if (ReferenceEquals(this, other)) - { - return true; - } - UnknownFieldSet otherSet = other as UnknownFieldSet; - return otherSet != null && Dictionaries.Equals(fields, otherSet.fields); - } - - public override int GetHashCode() - { - return Dictionaries.GetHashCode(fields); - } - - /// - /// Parses an UnknownFieldSet from the given input. - /// - public static UnknownFieldSet ParseFrom(ICodedInputStream input) - { - return CreateBuilder().MergeFrom(input).Build(); - } - - /// - /// Parses an UnknownFieldSet from the given data. - /// - public static UnknownFieldSet ParseFrom(ByteString data) - { - return CreateBuilder().MergeFrom(data).Build(); - } - - /// - /// Parses an UnknownFieldSet from the given data. - /// - public static UnknownFieldSet ParseFrom(byte[] data) - { - return CreateBuilder().MergeFrom(data).Build(); - } - - /// - /// Parses an UnknownFieldSet from the given input. - /// - public static UnknownFieldSet ParseFrom(Stream input) - { - return CreateBuilder().MergeFrom(input).Build(); - } - - #region IMessageLite Members - - public bool IsInitialized - { - get { return fields != null; } - } - - public void WriteDelimitedTo(Stream output) - { - CodedOutputStream codedOutput = CodedOutputStream.CreateInstance(output); - codedOutput.WriteRawVarint32((uint) SerializedSize); - WriteTo(codedOutput); - codedOutput.Flush(); - } - - public IBuilderLite WeakCreateBuilderForType() - { - return new Builder(); - } - - public IBuilderLite WeakToBuilder() - { - return new Builder(fields); - } - - public IMessageLite WeakDefaultInstanceForType - { - get { return defaultInstance; } - } - - #endregion - - /// - /// Builder for UnknownFieldSets. - /// - public sealed partial class Builder : IBuilderLite - { - /// - /// Mapping from number to field. Note that by using a SortedList we ensure - /// that the fields will be serialized in ascending order. - /// - private IDictionary fields; - - // Optimization: We keep around a builder for the last field that was - // modified so that we can efficiently add to it multiple times in a - // row (important when parsing an unknown repeated field). - private int lastFieldNumber; - private UnknownField.Builder lastField; - - internal Builder() - { - fields = new SortedDictionary(); - } - - internal Builder(IDictionary dictionary) - { - fields = new SortedDictionary(dictionary); - } - - /// - /// Returns a field builder for the specified field number, including any values - /// which already exist. - /// - private UnknownField.Builder GetFieldBuilder(int number) - { - if (lastField != null) - { - if (number == lastFieldNumber) - { - return lastField; - } - // Note: AddField() will reset lastField and lastFieldNumber. - AddField(lastFieldNumber, lastField.Build()); - } - if (number == 0) - { - return null; - } - - lastField = UnknownField.CreateBuilder(); - UnknownField existing; - if (fields.TryGetValue(number, out existing)) - { - lastField.MergeFrom(existing); - } - lastFieldNumber = number; - return lastField; - } - - /// - /// Build the UnknownFieldSet and return it. Once this method has been called, - /// this instance will no longer be usable. Calling any method after this - /// will throw a NullReferenceException. - /// - public UnknownFieldSet Build() - { - GetFieldBuilder(0); // Force lastField to be built. - UnknownFieldSet result = fields.Count == 0 ? DefaultInstance : new UnknownFieldSet(fields); - fields = null; - return result; - } - - /// - /// Adds a field to the set. If a field with the same number already exists, it - /// is replaced. - /// - public Builder AddField(int number, UnknownField field) - { - if (number == 0) - { - throw new ArgumentOutOfRangeException("number", "Zero is not a valid field number."); - } - if (lastField != null && lastFieldNumber == number) - { - // Discard this. - lastField = null; - lastFieldNumber = 0; - } - fields[number] = field; - return this; - } - - /// - /// Resets the builder to an empty set. - /// - public Builder Clear() - { - fields.Clear(); - lastFieldNumber = 0; - lastField = null; - return this; - } - - /// - /// Parse an entire message from and merge - /// its fields into this set. - /// - public Builder MergeFrom(ICodedInputStream input) - { - uint tag; - string name; - while (input.ReadTag(out tag, out name)) - { - if (tag == 0) - { - if (input.SkipField()) - { - continue; //can't merge unknown without field tag - } - break; - } - - if (!MergeFieldFrom(tag, input)) - { - break; - } - } - return this; - } - - /// - /// Parse a single field from and merge it - /// into this set. - /// - /// The field's tag number, which was already parsed. - /// The coded input stream containing the field - /// false if the tag is an "end group" tag, true otherwise - public bool MergeFieldFrom(uint tag, ICodedInputStream input) - { - if (tag == 0) - { - input.SkipField(); - return true; - } - - int number = WireFormat.GetTagFieldNumber(tag); - switch (WireFormat.GetTagWireType(tag)) - { - case WireFormat.WireType.Varint: - { - ulong uint64 = 0; - if (input.ReadUInt64(ref uint64)) - { - GetFieldBuilder(number).AddVarint(uint64); - } - return true; - } - case WireFormat.WireType.Fixed32: - { - uint uint32 = 0; - if (input.ReadFixed32(ref uint32)) - { - GetFieldBuilder(number).AddFixed32(uint32); - } - return true; - } - case WireFormat.WireType.Fixed64: - { - ulong uint64 = 0; - if (input.ReadFixed64(ref uint64)) - { - GetFieldBuilder(number).AddFixed64(uint64); - } - return true; - } - case WireFormat.WireType.LengthDelimited: - { - ByteString bytes = null; - if (input.ReadBytes(ref bytes)) - { - GetFieldBuilder(number).AddLengthDelimited(bytes); - } - return true; - } - case WireFormat.WireType.StartGroup: - { - Builder subBuilder = CreateBuilder(); -#pragma warning disable 0612 - input.ReadUnknownGroup(number, subBuilder); -#pragma warning restore 0612 - GetFieldBuilder(number).AddGroup(subBuilder.Build()); - return true; - } - case WireFormat.WireType.EndGroup: - return false; - default: - throw InvalidProtocolBufferException.InvalidWireType(); - } - } - - /// - /// Parses as an UnknownFieldSet and merge it - /// with the set being built. This is just a small wrapper around - /// MergeFrom(ICodedInputStream). - /// - public Builder MergeFrom(Stream input) - { - CodedInputStream codedInput = CodedInputStream.CreateInstance(input); - MergeFrom(codedInput); - codedInput.CheckLastTagWas(0); - return this; - } - - /// - /// Parses as an UnknownFieldSet and merge it - /// with the set being built. This is just a small wrapper around - /// MergeFrom(ICodedInputStream). - /// - public Builder MergeFrom(ByteString data) - { - CodedInputStream input = data.CreateCodedInput(); - MergeFrom(input); - input.CheckLastTagWas(0); - return this; - } - - /// - /// Parses as an UnknownFieldSet and merge it - /// with the set being built. This is just a small wrapper around - /// MergeFrom(ICodedInputStream). - /// - public Builder MergeFrom(byte[] data) - { - CodedInputStream input = CodedInputStream.CreateInstance(data); - MergeFrom(input); - input.CheckLastTagWas(0); - return this; - } - - /// - /// Convenience method for merging a new field containing a single varint - /// value. This is used in particular when an unknown enum value is - /// encountered. - /// - public Builder MergeVarintField(int number, ulong value) - { - if (number == 0) - { - throw new ArgumentOutOfRangeException("number", "Zero is not a valid field number."); - } - GetFieldBuilder(number).AddVarint(value); - return this; - } - - /// - /// Merges the fields from into this set. - /// If a field number exists in both sets, the values in - /// will be appended to the values in this set. - /// - public Builder MergeFrom(UnknownFieldSet other) - { - if (other != DefaultInstance) - { - foreach (KeyValuePair entry in other.fields) - { - MergeField(entry.Key, entry.Value); - } - } - return this; - } - - /// - /// Checks if the given field number is present in the set. - /// - public bool HasField(int number) - { - if (number == 0) - { - throw new ArgumentOutOfRangeException("number", "Zero is not a valid field number."); - } - return number == lastFieldNumber || fields.ContainsKey(number); - } - - /// - /// Adds a field to the unknown field set. If a field with the same - /// number already exists, the two are merged. - /// - public Builder MergeField(int number, UnknownField field) - { - if (number == 0) - { - throw new ArgumentOutOfRangeException("number", "Zero is not a valid field number."); - } - if (HasField(number)) - { - GetFieldBuilder(number).MergeFrom(field); - } - else - { - // Optimization: We could call getFieldBuilder(number).mergeFrom(field) - // in this case, but that would create a copy of the Field object. - // We'd rather reuse the one passed to us, so call AddField() instead. - AddField(number, field); - } - return this; - } - - internal void MergeFrom(ICodedInputStream input, ExtensionRegistry extensionRegistry, IBuilder builder) - { - uint tag; - string name; - while (input.ReadTag(out tag, out name)) - { - if (tag == 0 && name != null) - { - FieldDescriptor fieldByName = builder.DescriptorForType.FindFieldByName(name); - if (fieldByName != null) - { - tag = WireFormat.MakeTag(fieldByName); - } - else - { - ExtensionInfo extension = extensionRegistry.FindByName(builder.DescriptorForType, name); - if (extension != null) - { - tag = WireFormat.MakeTag(extension.Descriptor); - } - } - } - if (tag == 0) - { - if (input.SkipField()) - { - continue; //can't merge unknown without field tag - } - break; - } - - if (!MergeFieldFrom(input, extensionRegistry, builder, tag, name)) - { - // end group tag - break; - } - } - } - - /// - /// Like - /// but parses a single field. - /// - /// The input to read the field from - /// Registry to use when an extension field is encountered - /// Builder to merge field into, if it's a known field - /// The tag, which should already have been read from the input - /// true unless the tag is an end-group tag - internal bool MergeFieldFrom(ICodedInputStream input, - ExtensionRegistry extensionRegistry, IBuilder builder, uint tag, - string fieldName) - { - if (tag == 0 && fieldName != null) - { - FieldDescriptor fieldByName = builder.DescriptorForType.FindFieldByName(fieldName); - if (fieldByName != null) - { - tag = WireFormat.MakeTag(fieldByName); - } - else - { - ExtensionInfo extension = extensionRegistry.FindByName(builder.DescriptorForType, fieldName); - if (extension != null) - { - tag = WireFormat.MakeTag(extension.Descriptor); - } - } - } - - MessageDescriptor type = builder.DescriptorForType; - if (type.Options.MessageSetWireFormat && tag == WireFormat.MessageSetTag.ItemStart) - { - MergeMessageSetExtensionFromCodedStream(input, extensionRegistry, builder); - return true; - } - - WireFormat.WireType wireType = WireFormat.GetTagWireType(tag); - int fieldNumber = WireFormat.GetTagFieldNumber(tag); - - FieldDescriptor field; - IMessageLite defaultFieldInstance = null; - - if (type.IsExtensionNumber(fieldNumber)) - { - ExtensionInfo extension = extensionRegistry[type, fieldNumber]; - if (extension == null) - { - field = null; - } - else - { - field = extension.Descriptor; - defaultFieldInstance = extension.DefaultInstance; - } - } - else - { - field = type.FindFieldByNumber(fieldNumber); - } - - // Unknown field or wrong wire type. Skip. - if (field == null) - { - return MergeFieldFrom(tag, input); - } - if (wireType != WireFormat.GetWireType(field)) - { - WireFormat.WireType expectedType = WireFormat.GetWireType(field.FieldType); - if (wireType == expectedType) - { - //Allowed as of 2.3, this is unpacked data for a packed array - } - else if (field.IsRepeated && wireType == WireFormat.WireType.LengthDelimited && - (expectedType == WireFormat.WireType.Varint || expectedType == WireFormat.WireType.Fixed32 || - expectedType == WireFormat.WireType.Fixed64)) - { - //Allowed as of 2.3, this is packed data for an unpacked array - } - else - { - return MergeFieldFrom(tag, input); - } - } - - switch (field.FieldType) - { - case FieldType.Group: - case FieldType.Message: - { - IBuilderLite subBuilder = (defaultFieldInstance != null) - ? defaultFieldInstance.WeakCreateBuilderForType() - : builder.CreateBuilderForField(field); - if (!field.IsRepeated) - { - subBuilder.WeakMergeFrom((IMessageLite) builder[field]); - if (field.FieldType == FieldType.Group) - { - input.ReadGroup(field.FieldNumber, subBuilder, extensionRegistry); - } - else - { - input.ReadMessage(subBuilder, extensionRegistry); - } - builder[field] = subBuilder.WeakBuild(); - } - else - { - List list = new List(); - if (field.FieldType == FieldType.Group) - { - input.ReadGroupArray(tag, fieldName, list, subBuilder.WeakDefaultInstanceForType, - extensionRegistry); - } - else - { - input.ReadMessageArray(tag, fieldName, list, subBuilder.WeakDefaultInstanceForType, - extensionRegistry); - } - - foreach (IMessageLite m in list) - { - builder.WeakAddRepeatedField(field, m); - } - return true; - } - break; - } - case FieldType.Enum: - { - if (!field.IsRepeated) - { - object unknown; - IEnumLite value = null; - if (input.ReadEnum(ref value, out unknown, field.EnumType)) - { - builder[field] = value; - } - else if (unknown is int) - { - MergeVarintField(fieldNumber, (ulong) (int) unknown); - } - } - else - { - ICollection unknown; - List list = new List(); - input.ReadEnumArray(tag, fieldName, list, out unknown, field.EnumType); - - foreach (IEnumLite en in list) - { - builder.WeakAddRepeatedField(field, en); - } - - if (unknown != null) - { - foreach (object oval in unknown) - { - if (oval is int) - { - MergeVarintField(fieldNumber, (ulong) (int) oval); - } - } - } - } - break; - } - default: - { - if (!field.IsRepeated) - { - object value = null; - if (input.ReadPrimitiveField(field.FieldType, ref value)) - { - builder[field] = value; - } - } - else - { - List list = new List(); - input.ReadPrimitiveArray(field.FieldType, tag, fieldName, list); - foreach (object oval in list) - { - builder.WeakAddRepeatedField(field, oval); - } - } - break; - } - } - return true; - } - - /// - /// Called by MergeFieldFrom to parse a MessageSet extension. - /// - private void MergeMessageSetExtensionFromCodedStream(ICodedInputStream input, - ExtensionRegistry extensionRegistry, IBuilder builder) - { - MessageDescriptor type = builder.DescriptorForType; - - // The wire format for MessageSet is: - // message MessageSet { - // repeated group Item = 1 { - // required int32 typeId = 2; - // required bytes message = 3; - // } - // } - // "typeId" is the extension's field number. The extension can only be - // a message type, where "message" contains the encoded bytes of that - // message. - // - // In practice, we will probably never see a MessageSet item in which - // the message appears before the type ID, or where either field does not - // appear exactly once. However, in theory such cases are valid, so we - // should be prepared to accept them. - - int typeId = 0; - ByteString rawBytes = null; // If we encounter "message" before "typeId" - IBuilderLite subBuilder = null; - FieldDescriptor field = null; - - uint lastTag = WireFormat.MessageSetTag.ItemStart; - uint tag; - string name; - while (input.ReadTag(out tag, out name)) - { - if (tag == 0 && name != null) - { - if (name == "type_id") - { - tag = WireFormat.MessageSetTag.TypeID; - } - else if (name == "message") - { - tag = WireFormat.MessageSetTag.Message; - } - } - if (tag == 0) - { - if (input.SkipField()) - { - continue; //can't merge unknown without field tag - } - break; - } - - lastTag = tag; - if (tag == WireFormat.MessageSetTag.TypeID) - { - typeId = 0; - // Zero is not a valid type ID. - if (input.ReadInt32(ref typeId) && typeId != 0) - { - ExtensionInfo extension = extensionRegistry[type, typeId]; - if (extension != null) - { - field = extension.Descriptor; - subBuilder = extension.DefaultInstance.WeakCreateBuilderForType(); - IMessageLite originalMessage = (IMessageLite) builder[field]; - if (originalMessage != null) - { - subBuilder.WeakMergeFrom(originalMessage); - } - if (rawBytes != null) - { - // We already encountered the message. Parse it now. - // TODO(jonskeet): Check this is okay. It's subtly different from the Java, as it doesn't create an input stream from rawBytes. - // In fact, why don't we just call MergeFrom(rawBytes)? And what about the extension registry? - subBuilder.WeakMergeFrom(rawBytes.CreateCodedInput()); - rawBytes = null; - } - } - else - { - // Unknown extension number. If we already saw data, put it - // in rawBytes. - if (rawBytes != null) - { - MergeField(typeId, UnknownField.CreateBuilder().AddLengthDelimited(rawBytes).Build()); - rawBytes = null; - } - } - } - } - else if (tag == WireFormat.MessageSetTag.Message) - { - if (subBuilder != null) - { - // We already know the type, so we can parse directly from the input - // with no copying. Hooray! - input.ReadMessage(subBuilder, extensionRegistry); - } - else if (input.ReadBytes(ref rawBytes)) - { - if (typeId != 0) - { - // We don't know how to parse this. Ignore it. - MergeField(typeId, - UnknownField.CreateBuilder().AddLengthDelimited(rawBytes).Build()); - } - } - } - else - { - // Unknown tag. Skip it. - if (!input.SkipField()) - { - break; // end of group - } - } - } - - if (lastTag != WireFormat.MessageSetTag.ItemEnd) - { - throw InvalidProtocolBufferException.InvalidEndTag(); - } - - if (subBuilder != null) - { - builder[field] = subBuilder.WeakBuild(); - } - } - - #region IBuilderLite Members - - bool IBuilderLite.IsInitialized - { - get { return fields != null; } - } - - IBuilderLite IBuilderLite.WeakClear() - { - return Clear(); - } - - IBuilderLite IBuilderLite.WeakMergeFrom(IMessageLite message) - { - return MergeFrom((UnknownFieldSet) message); - } - - IBuilderLite IBuilderLite.WeakMergeFrom(ByteString data) - { - return MergeFrom(data); - } - - IBuilderLite IBuilderLite.WeakMergeFrom(ByteString data, ExtensionRegistry registry) - { - return MergeFrom(data); - } - - IBuilderLite IBuilderLite.WeakMergeFrom(ICodedInputStream input) - { - return MergeFrom(input); - } - - IBuilderLite IBuilderLite.WeakMergeFrom(ICodedInputStream input, ExtensionRegistry registry) - { - return MergeFrom(input); - } - - IMessageLite IBuilderLite.WeakBuild() - { - return Build(); - } - - IMessageLite IBuilderLite.WeakBuildPartial() - { - return Build(); - } - - IBuilderLite IBuilderLite.WeakClone() - { - return Build().WeakToBuilder(); - } - - IMessageLite IBuilderLite.WeakDefaultInstanceForType - { - get { return DefaultInstance; } - } - - #endregion - } - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/WireFormat.cs b/csharp/src/ProtocolBuffers/WireFormat.cs index b9daa328..87f7c358 100644 --- a/csharp/src/ProtocolBuffers/WireFormat.cs +++ b/csharp/src/ProtocolBuffers/WireFormat.cs @@ -35,9 +35,9 @@ #endregion using System; -using Google.ProtocolBuffers.Descriptors; +using Google.Protobuf.Descriptors; -namespace Google.ProtocolBuffers +namespace Google.Protobuf { /// /// This class is used internally by the Protocol Buffer Library and generated diff --git a/src/google/protobuf/compiler/csharp/csharp_enum_field.cc b/src/google/protobuf/compiler/csharp/csharp_enum_field.cc index 8865702d..ee9d6a1d 100644 --- a/src/google/protobuf/compiler/csharp/csharp_enum_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_enum_field.cc @@ -61,7 +61,7 @@ void EnumFieldGenerator::GenerateParsingCode(io::Printer* printer) { void EnumFieldGenerator::GenerateSerializationCode(io::Printer* printer) { printer->Print(variables_, "if ($has_property_check$) {\n" - " output.WriteEnum($number$, fieldNames[$field_ordinal$], (long) $property_name$, $property_name$);\n" + " output.WriteEnum($number$, fieldNames[$field_ordinal$], $property_name$);\n" "}\n"); } @@ -69,7 +69,7 @@ void EnumFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) { printer->Print( variables_, "if ($has_property_check$) {\n" - " size += pb::CodedOutputStream.ComputeEnumSize($number$, (long) $property_name$);\n" + " size += pb::CodedOutputStream.ComputeEnumSize($number$, $property_name$);\n" "}\n"); } @@ -87,8 +87,8 @@ void EnumOneofFieldGenerator::GenerateParsingCode(io::Printer* printer) { variables_, "$type_name$ enumValue = $default_value$;\n" "if(input.ReadEnum(ref enumValue)) {\n" - " result.$oneof_name$_ = enumValue;\n" - " result.$oneof_name$Case_ = $oneof_property_name$OneofCase.$property_name$;\n" + " $oneof_name$_ = enumValue;\n" + " $oneof_name$Case_ = $oneof_property_name$OneofCase.$property_name$;\n" "}\n"); } diff --git a/src/google/protobuf/compiler/csharp/csharp_field_base.cc b/src/google/protobuf/compiler/csharp/csharp_field_base.cc index 367e54c2..ec0d51ca 100644 --- a/src/google/protobuf/compiler/csharp/csharp_field_base.cc +++ b/src/google/protobuf/compiler/csharp/csharp_field_base.cc @@ -38,6 +38,7 @@ #include #include #include +#include #include #include @@ -51,6 +52,11 @@ namespace csharp { void FieldGeneratorBase::SetCommonFieldVariables( map* variables) { + // Note: this will be valid even though the tag emitted for packed and unpacked versions of + // repeated fields varies by wire format. The wire format is encoded in the bottom 3 bits, which + // never effects the tag size. + int tagSize = internal::WireFormat::TagSize(descriptor_->number(), descriptor_->type()); + (*variables)["tag_size"] = SimpleItoa(tagSize); (*variables)["property_name"] = property_name(); (*variables)["type_name"] = type_name(); (*variables)["name"] = name(); @@ -65,15 +71,10 @@ void FieldGeneratorBase::SetCommonFieldVariables( (*variables)["capitalized_type_name"] = capitalized_type_name(); (*variables)["number"] = number(); (*variables)["field_ordinal"] = field_ordinal(); - if (SupportFieldPresence(descriptor_->file())) { - (*variables)["has_property_check"] = "has" + (*variables)["property_name"]; - (*variables)["other_has_property_check"] = "other.Has" + (*variables)["property_name"]; - } else { - (*variables)["has_property_check"] = - (*variables)["property_name"] + " != " + (*variables)["default_value"]; - (*variables)["other_has_property_check"] = "other." + - (*variables)["property_name"] + " != " + (*variables)["default_value"]; - } + (*variables)["has_property_check"] = + (*variables)["property_name"] + " != " + (*variables)["default_value"]; + (*variables)["other_has_property_check"] = "other." + + (*variables)["property_name"] + " != " + (*variables)["default_value"]; } void FieldGeneratorBase::SetCommonOneofFieldVariables( diff --git a/src/google/protobuf/compiler/csharp/csharp_message.cc b/src/google/protobuf/compiler/csharp/csharp_message.cc index 1defcf94..b5929bcd 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message.cc @@ -179,10 +179,14 @@ void MessageGenerator::Generate(io::Printer* printer) { WriteGeneratedCodeAttributes(printer); printer->Print( vars, - "$access_level$ sealed partial class $class_name$ : pb::IMessage<$class_name$> {\n"); + "$access_level$ sealed partial class $class_name$ : pb::IMessage<$class_name$>, global::System.IEquatable<$class_name$> {\n"); printer->Indent(); // All static fields and properties + printer->Print( + vars, + "private static readonly pb::MessageParser<$class_name$> _parser = new pb::MessageParser<$class_name$>(() => new $class_name$());\n" + "public static pb::MessageParser<$class_name$> Parser { get { return _parser; } }\n\n"); printer->Print( "private static readonly string[] _fieldNames = " "new string[] { $slash$$field_names$$slash$ };\n", @@ -204,7 +208,7 @@ void MessageGenerator::Generate(io::Printer* printer) { " get { return $umbrella_class_name$.internal__$identifier$__Descriptor; }\n" "}\n" "\n" - "protected override pb::FieldAccess.FieldAccessorTable<$class_name$> InternalFieldAccessors {\n" + "public pb::FieldAccess.FieldAccessorTable<$class_name$> Fields {\n" " get { return $umbrella_class_name$.internal__$identifier$__FieldAccessorTable; }\n" "}\n" "\n"); @@ -217,7 +221,7 @@ void MessageGenerator::Generate(io::Printer* printer) { printer->Print( vars, "public $class_name$($class_name$ other) {\n" - " MergeWith(other);\n" + " MergeFrom(other);\n" "}\n"); // Merge ctor. // Fields/properties @@ -259,15 +263,16 @@ void MessageGenerator::Generate(io::Printer* printer) { "public $property_name$OneofCase $property_name$Case {\n" " get { return $name$Case_; }\n" "}\n\n" - "private Clear$property_name$() {;\n" - " $name$Case_ = $property_name$OneofCase.None;" - " $name$_ = null;" + "public void Clear$property_name$() {\n" + " $name$Case_ = $property_name$OneofCase.None;\n" + " $name$_ = null;\n" "}\n\n"); } // TODO(jonskeet): Map properties // Standard methods + GenerateFrameworkMethods(printer); GenerateMessageSerializationMethods(printer); GenerateMergingMethods(printer); @@ -298,6 +303,51 @@ void MessageGenerator::Generate(io::Printer* printer) { } +void MessageGenerator::GenerateFrameworkMethods(io::Printer* printer) { + map vars; + vars["class_name"] = class_name(); + + // Equality + printer->Print( + vars, + "public override bool Equals(object other) {\n" + " return Equals(other as $class_name$);\n" + "}\n\n" + "public bool Equals($class_name$ other) {\n" + " if (ReferenceEquals(other, null)) {\n" + " return false;\n" + " }\n" + " if (ReferenceEquals(other, this)) {\n" + " return true;\n" + " }\n"); + printer->Indent(); + for (int i = 0; i < descriptor_->field_count(); i++) { + scoped_ptr generator( + CreateFieldGeneratorInternal(descriptor_->field(i))); + generator->WriteEquals(printer); + } + printer->Outdent(); + printer->Print( + " return true;\n" + "}\n\n"); + + // GetHashCode + printer->Print( + "public override int GetHashCode() {\n" + " int hash = 0;\n"); + printer->Indent(); + for (int i = 0; i < descriptor_->field_count(); i++) { + scoped_ptr generator( + CreateFieldGeneratorInternal(descriptor_->field(i))); + generator->WriteHash(printer); + } + printer->Print("return hash;\n"); + printer->Outdent(); + printer->Print("}\n\n"); + + // TODO(jonskeet): ToString. +} + void MessageGenerator::GenerateMessageSerializationMethods(io::Printer* printer) { printer->Print( "public void WriteTo(pb::ICodedOutputStream output) {\n"); @@ -316,7 +366,7 @@ void MessageGenerator::GenerateMessageSerializationMethods(io::Printer* printer) printer->Print( "}\n" "\n" - "public int CalculateSerializedSize() {\n"); + "public int CalculateSize() {\n"); printer->Indent(); printer->Print("int size = 0;\n"); for (int i = 0; i < descriptor_->field_count(); i++) { @@ -338,7 +388,7 @@ void MessageGenerator::GenerateMergingMethods(io::Printer* printer) { printer->Print( vars, - "public void MergeWith($class_name$ other) {\n"); + "public void MergeFrom($class_name$ other) {\n"); printer->Indent(); printer->Print( "if (other == null) {\n" @@ -378,39 +428,38 @@ void MessageGenerator::GenerateMergingMethods(io::Printer* printer) { printer->Print( "uint tag;\n" "string fieldName;\n" - "while (input.ReadTag(out tag, out fieldName)) {\n" - " if (tag == 0 && fieldName != null) {"); - printer->Indent(); + "while (input.ReadTag(out tag, out fieldName)) {\n"); printer->Indent(); printer->Print( - "int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.String.String.Ordinal);\n" - "if (fieldOrdinal >= 0) {\n" - " tag = _fieldTags[fieldOrdinal];\n" + "if (tag == 0 && fieldName != null) {\n" + " int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal);\n" + " if (fieldOrdinal >= 0) {\n" + " tag = _fieldTags[fieldOrdinal];\n" + " }\n" "}\n" "switch(tag) {\n"); printer->Indent(); printer->Print( - "case 0: {\n" // 0 signals EOF / limit reached + "case 0:\n" // 0 signals EOF / limit reached " throw pb::InvalidProtocolBufferException.InvalidTag();\n" - "}\n" "default:\n" " if (pb::WireFormat.IsEndGroupTag(tag)) {\n" " return;\n" " }\n" - " break;"); // Note: we're ignoring unknown fields here. + " break;\n"); // Note: we're ignoring unknown fields here. for (int i = 0; i < fields_by_number().size(); i++) { const FieldDescriptor* field = fields_by_number()[i]; internal::WireFormatLite::WireType wt = internal::WireFormat::WireTypeForFieldType(field->type()); uint32 tag = internal::WireFormatLite::MakeTag(field->number(), wt); - // TODO(jonskeet): Understand what this is trying to do - if (field->is_repeated() - && (wt == internal::WireFormatLite::WIRETYPE_VARINT - || wt == internal::WireFormatLite::WIRETYPE_FIXED32 - || wt == internal::WireFormatLite::WIRETYPE_FIXED64)) { + // Handle both packed and unpacked repeated fields with the same Read*Array call; + // the two generated cases are the packed and unpacked tags. + // TODO(jonskeet): Check that is_packable is equivalent to is_repeated && wt in { VARINT, FIXED32, FIXED64 }. + // It looks like it is... + if (field->is_packable()) { printer->Print( - "case $number$:\n", - "number", + "case $packed_tag$:\n", + "packed_tag", SimpleItoa( internal::WireFormatLite::MakeTag( field->number(), @@ -429,8 +478,6 @@ void MessageGenerator::GenerateMergingMethods(io::Printer* printer) { printer->Outdent(); printer->Print("}\n"); // switch printer->Outdent(); - printer->Print("}\n"); // if - printer->Outdent(); printer->Print("}\n"); // while printer->Outdent(); printer->Print("}\n\n"); // method diff --git a/src/google/protobuf/compiler/csharp/csharp_message.h b/src/google/protobuf/compiler/csharp/csharp_message.h index f5f41c73..eb90ce67 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message.h +++ b/src/google/protobuf/compiler/csharp/csharp_message.h @@ -50,6 +50,7 @@ class MessageGenerator : public SourceGeneratorBase { MessageGenerator(const Descriptor* descriptor); ~MessageGenerator(); + void GenerateFrameworkMethods(io::Printer* printer); void GenerateStaticVariables(io::Printer* printer); void GenerateStaticVariableInitializers(io::Printer* printer); void Generate(io::Printer* printer); diff --git a/src/google/protobuf/compiler/csharp/csharp_message_field.cc b/src/google/protobuf/compiler/csharp/csharp_message_field.cc index 90aa201b..4b7ac88f 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message_field.cc @@ -49,8 +49,8 @@ namespace csharp { MessageFieldGenerator::MessageFieldGenerator(const FieldDescriptor* descriptor, int fieldOrdinal) : FieldGeneratorBase(descriptor, fieldOrdinal) { - variables_["has_property_check"] = property_name() + "_ != null"; - variables_["has_not_property_check"] = property_name() + "_ == null"; + variables_["has_property_check"] = name() + "_ != null"; + variables_["has_not_property_check"] = name() + "_ == null"; } MessageFieldGenerator::~MessageFieldGenerator() { @@ -66,7 +66,7 @@ void MessageFieldGenerator::GenerateMembers(io::Printer* printer) { variables_, "public $type_name$ $property_name$ {\n" " get { return $name$_; }\n" - " set { return $name$_ = value; }\n" + " set { $name$_ = value; }\n" "}\n"); } @@ -74,17 +74,17 @@ void MessageFieldGenerator::GenerateMergingCode(io::Printer* printer) { printer->Print( variables_, "if (other.$has_property_check$) {\n" - " if ($has_not_property_check) {\n" + " if ($has_not_property_check$) {\n" " $name$_ = new $type_name$();\n" " }\n" - " $property_name$.MergeWith(other.$property_name);\n" + " $property_name$.MergeFrom(other.$property_name$);\n" "}\n"); } void MessageFieldGenerator::GenerateParsingCode(io::Printer* printer) { printer->Print( variables_, - "if ($has_not_property_check) {\n" + "if ($has_not_property_check$) {\n" " $name$_ = new $type_name$();\n" "}\n" "input.ReadMessage($name$_);\n"); // No need to support TYPE_GROUP... @@ -110,12 +110,12 @@ void MessageFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) { void MessageFieldGenerator::WriteHash(io::Printer* printer) { printer->Print( variables_, - "if ($has_property_check$) hash ^= $name$_.GetHashCode();\n"); + "if ($has_property_check$) hash ^= $property_name$.GetHashCode();\n"); } void MessageFieldGenerator::WriteEquals(io::Printer* printer) { printer->Print( variables_, - "if (!object.Equals($property_name$_, other.$property_name$_)) return false;\n"); + "if (!object.Equals($property_name$, other.$property_name$)) return false;"); } void MessageFieldGenerator::WriteToString(io::Printer* printer) { variables_["field_name"] = GetFieldName(descriptor_); @@ -140,10 +140,10 @@ void MessageOneofFieldGenerator::GenerateMembers(io::Printer* printer) { variables_, "public $type_name$ $property_name$ {\n" " get { return $has_property_check$ ? ($type_name$) $oneof_name$_ : null; }\n" - " set { \n" - " $name$_ = value;" - " $oneof_name$Case_ = value == null ? $oneof_property_name$Case.None : $oneof_property_name$Case.$property_name$; }\n" - " } \n" + " set {\n" + " $oneof_name$_ = value;\n" + " $oneof_name$Case_ = value == null ? $oneof_property_name$OneofCase.None : $oneof_property_name$OneofCase.$property_name$;\n" + " }\n" "}\n"); } @@ -151,12 +151,12 @@ void MessageOneofFieldGenerator::GenerateParsingCode(io::Printer* printer) { // TODO(jonskeet): We may be able to do better than this printer->Print( variables_, - "$type_name$ subBuilder = new type_name$();\n" + "$type_name$ subBuilder = new $type_name$();\n" "if ($has_property_check$) {\n" - " subBuilder.MergeWith($property_name$);\n" + " subBuilder.MergeFrom($property_name$);\n" "}\n" "input.ReadMessage(subBuilder);\n" // No support of TYPE_GROUP - "$oneof_property_name$ = subBuilder;\n"); + "$property_name$ = subBuilder;\n"); } void MessageOneofFieldGenerator::WriteToString(io::Printer* printer) { diff --git a/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc b/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc index bc4858fc..f2b66a00 100644 --- a/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc @@ -93,7 +93,7 @@ void PrimitiveFieldGenerator::GenerateMergingCode(io::Printer* printer) { void PrimitiveFieldGenerator::GenerateParsingCode(io::Printer* printer) { printer->Print( variables_, - "input.Read$capitalized_type_name$(ref result.$name$_);\n"); + "input.Read$capitalized_type_name$(ref $name$_);\n"); } void PrimitiveFieldGenerator::GenerateSerializationCode(io::Printer* printer) { @@ -115,9 +115,7 @@ void PrimitiveFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) { void PrimitiveFieldGenerator::WriteHash(io::Printer* printer) { printer->Print( variables_, - "if ($has_property_check$) {\n" - " hash ^= $property_name$.GetHashCode();\n" - "}\n"); + "if ($has_property_check$) hash ^= $property_name$.GetHashCode();\n"); } void PrimitiveFieldGenerator::WriteEquals(io::Printer* printer) { printer->Print( @@ -147,17 +145,17 @@ void PrimitiveOneofFieldGenerator::GenerateMembers(io::Printer* printer) { variables_, "public $type_name$ $property_name$ {\n" " get { return $has_property_check$ ? ($type_name$) $oneof_name$_ : $default_value$; }\n" - " set {"); + " set {\n"); if (is_value_type) { printer->Print( variables_, - " $oneof_name$_ = value;\n" - " $oneof_name$Case_ = $oneof_property_name$Case.$property_name$;\n"); + " $oneof_name$_ = value;\n" + " $oneof_name$Case_ = $oneof_property_name$OneofCase.$property_name$;\n"); } else { printer->Print( variables_, - " $oneof_name$_ = value ?? $default_value$;\n" - " $oneof_name$Case_ = value == null ? $oneof_property_name$Case.None : $oneof_property_name$Case.$property_name$;\n"); + " $oneof_name$_ = value ?? $default_value$;\n" + " $oneof_name$Case_ = value == null ? $oneof_property_name$OneofCase.None : $oneof_property_name$OneofCase.$property_name$;\n"); } printer->Print( " }\n" diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc b/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc index f5d5a126..ebbbf3be 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc @@ -49,6 +49,7 @@ namespace csharp { RepeatedEnumFieldGenerator::RepeatedEnumFieldGenerator( const FieldDescriptor* descriptor, int fieldOrdinal) : FieldGeneratorBase(descriptor, fieldOrdinal) { + variables_["packed"] = descriptor->is_packed() ? "Packed" : ""; } RepeatedEnumFieldGenerator::~RepeatedEnumFieldGenerator() { @@ -75,27 +76,21 @@ void RepeatedEnumFieldGenerator::GenerateMergingCode(io::Printer* printer) { void RepeatedEnumFieldGenerator::GenerateParsingCode(io::Printer* printer) { printer->Print( variables_, - "input.ReadEnumArray<$type_name$>(tag, fieldName, result.$name$_);\n"); + "input.ReadEnumArray<$type_name$>(tag, fieldName, $name$_);\n"); } void RepeatedEnumFieldGenerator::GenerateSerializationCode(io::Printer* printer) { // TODO(jonskeet): Originally, this checked for Count > 0 first. // The Write* call should make that cheap though - no need to generate it every time. - if (descriptor_->is_packed()) { - printer->Print( - variables_, - "output.WritePackedEnumArray($number$, fieldNames[$field_ordinal$], $name$_);\n"); - } else { - printer->Print(variables_, - "output.WriteEnumArray($number$, fieldNames[$field_ordinal$], $name$_);\n"); - } - printer->Print("}\n"); + printer->Print( + variables_, + "output.Write$packed$EnumArray($number$, fieldNames[$field_ordinal$], $name$_);\n"); } void RepeatedEnumFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) { + // TODO(jonskeet): Move all this code into CodedOutputStream? It's a lot to repeat everywhere... printer->Print("{\n"); printer->Indent(); - // TODO(jonskeet): Move all this code into CodedOutputStream? It's a lot to repeat everywhere... printer->Print( variables_, "int dataSize = 0;\n" @@ -104,7 +99,7 @@ void RepeatedEnumFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer printer->Print( variables_, "foreach ($type_name$ element in $name$_) {\n" - " dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((long) element);\n" + " dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag(element);\n" "}\n" "size += dataSize;\n"); int tagSize = internal::WireFormat::TagSize(descriptor_->number(), descriptor_->type()); @@ -127,15 +122,13 @@ void RepeatedEnumFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer void RepeatedEnumFieldGenerator::WriteHash(io::Printer* printer) { printer->Print( variables_, - "foreach($type_name$ i in $name$_) {\n" - " hash ^= i.GetHashCode();\n" - "}\n"); + "hash ^= $name$_.GetHashCode();\n"); } void RepeatedEnumFieldGenerator::WriteEquals(io::Printer* printer) { printer->Print( variables_, - "if(!$name$_.Equals(other.$name$)) return false;\n"); + "if(!$name$_.Equals(other.$name$_)) return false;\n"); } void RepeatedEnumFieldGenerator::WriteToString(io::Printer* printer) { diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc b/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc index 2a6a01f5..963f841e 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc @@ -64,21 +64,6 @@ void RepeatedMessageFieldGenerator::GenerateMembers(io::Printer* printer) { "public pbc::RepeatedField<$type_name$> $property_name$ {\n" " get { return $name$_; }\n" "}\n"); - - // TODO(jonskeet): Redundant API calls? Possibly - include for portability though. Maybe create an option. - AddDeprecatedFlag(printer); - printer->Print( - variables_, - "public int $property_name$Count {\n" - " get { return $name$_.Count; }\n" - "}\n"); - - AddDeprecatedFlag(printer); - printer->Print( - variables_, - "public $type_name$ Get$property_name$(int index) {\n" - " return $name$_[index];\n" - "}\n"); } void RepeatedMessageFieldGenerator::GenerateMergingCode(io::Printer* printer) { @@ -90,7 +75,7 @@ void RepeatedMessageFieldGenerator::GenerateMergingCode(io::Printer* printer) { void RepeatedMessageFieldGenerator::GenerateParsingCode(io::Printer* printer) { printer->Print( variables_, - "input.ReadMessageArray(tag, fieldName, $name$_);\n"); + "input.ReadMessageArray(tag, fieldName, $name$_, $type_name$.Parser);\n"); } void RepeatedMessageFieldGenerator::GenerateSerializationCode(io::Printer* printer) { @@ -105,7 +90,7 @@ void RepeatedMessageFieldGenerator::GenerateSerializedSizeCode(io::Printer* prin // TODO(jonskeet): Put this into CodedOutputStream. printer->Print( variables_, - "foreach ($type_name$ element in $property_name$) {\n" + "foreach ($type_name$ element in $name$_) {\n" " size += pb::CodedOutputStream.ComputeMessageSize($number$, element);\n" "}\n"); } @@ -113,15 +98,15 @@ void RepeatedMessageFieldGenerator::GenerateSerializedSizeCode(io::Printer* prin void RepeatedMessageFieldGenerator::WriteHash(io::Printer* printer) { printer->Print( variables_, - "foreach($type_name$ i in $name$_) {\n" - " hash ^= i.GetHashCode();\n" - "}\n"); + "hash ^= $name$_.GetHashCode();\n"); } + void RepeatedMessageFieldGenerator::WriteEquals(io::Printer* printer) { printer->Print( variables_, - "if(!$name$_.Equals(other.$name$)) return false;\n"); + "if(!$name$_.Equals(other.$name$_)) return false;\n"); } + void RepeatedMessageFieldGenerator::WriteToString(io::Printer* printer) { variables_["field_name"] = GetFieldName(descriptor_); printer->Print( diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc b/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc index 2001b849..0a91c3c6 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc @@ -92,7 +92,7 @@ void RepeatedPrimitiveFieldGenerator::GenerateSerializationCode( void RepeatedPrimitiveFieldGenerator::GenerateSerializedSizeCode( io::Printer* printer) { - // TODO(jonskeet): Get rid of most of this - move it into the runtime. + // TODO(jonskeet): Do this in the runtime if possible. It's a pain, but it must be feasible... printer->Print("{\n"); printer->Indent(); printer->Print("int dataSize = 0;\n"); @@ -100,7 +100,7 @@ void RepeatedPrimitiveFieldGenerator::GenerateSerializedSizeCode( if (fixedSize == -1) { printer->Print( variables_, - "foreach ($type_name$ element in $property_name$List) {\n" + "foreach ($type_name$ element in $name$_) {\n" " dataSize += pb::CodedOutputStream.Compute$capitalized_type_name$SizeNoTag(element);\n" "}\n"); } else { @@ -128,14 +128,12 @@ void RepeatedPrimitiveFieldGenerator::GenerateSerializedSizeCode( void RepeatedPrimitiveFieldGenerator::WriteHash(io::Printer* printer) { printer->Print( variables_, - "foreach($type_name$ i in $name$_)\n {" - " hash ^= i.GetHashCode();\n" - "}\n"); + "hash ^= $name$_.GetHashCode();\n"); } void RepeatedPrimitiveFieldGenerator::WriteEquals(io::Printer* printer) { printer->Print( variables_, - "if(!$name$_.Equals(other.$name$)) return false;\n"); + "if(!$name$_.Equals(other.$name$_)) return false;\n"); } void RepeatedPrimitiveFieldGenerator::WriteToString(io::Printer* printer) { printer->Print(variables_, diff --git a/src/google/protobuf/descriptor.proto b/src/google/protobuf/descriptor.proto index 20a60080..97741b6a 100644 --- a/src/google/protobuf/descriptor.proto +++ b/src/google/protobuf/descriptor.proto @@ -42,7 +42,7 @@ syntax = "proto2"; package google.protobuf; option java_package = "com.google.protobuf"; option java_outer_classname = "DescriptorProtos"; -option csharp_namespace = "Google.ProtocolBuffers.DescriptorProtos"; +option csharp_namespace = "Google.Protobuf.DescriptorProtos"; option objc_class_prefix = "GPB"; // descriptor.proto must be optimized for speed because reflection-based diff --git a/src/google/protobuf/unittest_import_proto3.proto b/src/google/protobuf/unittest_import_proto3.proto new file mode 100644 index 00000000..59673eaf --- /dev/null +++ b/src/google/protobuf/unittest_import_proto3.proto @@ -0,0 +1,68 @@ +// 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. + +// Author: kenton@google.com (Kenton Varda) +// Based on original Protocol Buffers design by +// Sanjay Ghemawat, Jeff Dean, and others. +// +// A proto file which is imported by unittest_proto3.proto to test importing. + +syntax = "proto3"; + +// We don't put this in a package within proto2 because we need to make sure +// that the generated code doesn't depend on being in the proto2 namespace. +// In test_util.h we do +// "using namespace unittest_import = protobuf_unittest_import". +package protobuf_unittest_import; + +option optimize_for = SPEED; +option cc_enable_arenas = true; + +// Exercise the java_package option. +option java_package = "com.google.protobuf.test"; +option csharp_namespace = "Google.Protobuf.TestProtos"; + +// Do not set a java_outer_classname here to verify that Proto2 works without +// one. + +// Test public import +import public "google/protobuf/unittest_import_public_proto3.proto"; + +message ImportMessage { + int32 d = 1; +} + +enum ImportEnum { + IMPORT_ENUM_UNSPECIFIED = 0; + IMPORT_FOO = 7; + IMPORT_BAR = 8; + IMPORT_BAZ = 9; +} + diff --git a/src/google/protobuf/unittest_import_public_proto3.proto b/src/google/protobuf/unittest_import_public_proto3.proto new file mode 100644 index 00000000..d6f11e28 --- /dev/null +++ b/src/google/protobuf/unittest_import_public_proto3.proto @@ -0,0 +1,42 @@ +// 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. + +// Author: liujisi@google.com (Pherl Liu) + +syntax = "proto3"; + +package protobuf_unittest_import; + +option java_package = "com.google.protobuf.test"; +option csharp_namespace = "Google.Protobuf.TestProtos"; + +message PublicImportMessage { + int32 e = 1; +} diff --git a/src/google/protobuf/unittest_proto3.proto b/src/google/protobuf/unittest_proto3.proto new file mode 100644 index 00000000..f59d2178 --- /dev/null +++ b/src/google/protobuf/unittest_proto3.proto @@ -0,0 +1,388 @@ +// 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. + +// Author: kenton@google.com (Kenton Varda) +// Based on original Protocol Buffers design by +// Sanjay Ghemawat, Jeff Dean, and others. +// +// A proto file we will use for unit testing. + +syntax = "proto3"; + +// Some generic_services option(s) added automatically. +// See: http://go/proto2-generic-services-default +option cc_generic_services = true; // auto-added +option java_generic_services = true; // auto-added +option py_generic_services = true; // auto-added +option cc_enable_arenas = true; +option csharp_namespace = "Google.Protobuf.TestProtos"; + +import "google/protobuf/unittest_import_proto3.proto"; + +// We don't put this in a package within proto2 because we need to make sure +// that the generated code doesn't depend on being in the proto2 namespace. +// In test_util.h we do "using namespace unittest = protobuf_unittest". +package protobuf_unittest; + +// Protos optimized for SPEED use a strict superset of the generated code +// of equivalent ones optimized for CODE_SIZE, so we should optimize all our +// tests for speed unless explicitly testing code size optimization. +option optimize_for = SPEED; + +option java_outer_classname = "UnittestProto"; + +// This proto includes every type of field in both singular and repeated +// forms. +message TestAllTypes { + message NestedMessage { + // The field name "b" fails to compile in proto1 because it conflicts with + // a local variable named "b" in one of the generated methods. Doh. + // This file needs to compile in proto1 to test backwards-compatibility. + int32 bb = 1; + } + + enum NestedEnum { + NESTED_ENUM_UNSPECIFIED = 0; + FOO = 1; + BAR = 2; + BAZ = 3; + NEG = -1; // Intentionally negative. + } + + // Singular + int32 single_int32 = 1; + int64 single_int64 = 2; + uint32 single_uint32 = 3; + uint64 single_uint64 = 4; + sint32 single_sint32 = 5; + sint64 single_sint64 = 6; + fixed32 single_fixed32 = 7; + fixed64 single_fixed64 = 8; + sfixed32 single_sfixed32 = 9; + sfixed64 single_sfixed64 = 10; + float single_float = 11; + double single_double = 12; + bool single_bool = 13; + string single_string = 14; + bytes single_bytes = 15; + + NestedMessage single_nested_message = 18; + ForeignMessage single_foreign_message = 19; + protobuf_unittest_import.ImportMessage single_import_message = 20; + + NestedEnum single_nested_enum = 21; + ForeignEnum single_foreign_enum = 22; + protobuf_unittest_import.ImportEnum single_import_enum = 23; + + // Defined in unittest_import_public.proto + protobuf_unittest_import.PublicImportMessage + single_public_import_message = 26; + + // Repeated + repeated int32 repeated_int32 = 31; + repeated int64 repeated_int64 = 32; + repeated uint32 repeated_uint32 = 33; + repeated uint64 repeated_uint64 = 34; + repeated sint32 repeated_sint32 = 35; + repeated sint64 repeated_sint64 = 36; + repeated fixed32 repeated_fixed32 = 37; + repeated fixed64 repeated_fixed64 = 38; + repeated sfixed32 repeated_sfixed32 = 39; + repeated sfixed64 repeated_sfixed64 = 40; + repeated float repeated_float = 41; + repeated double repeated_double = 42; + repeated bool repeated_bool = 43; + repeated string repeated_string = 44; + repeated bytes repeated_bytes = 45; + + repeated NestedMessage repeated_nested_message = 48; + repeated ForeignMessage repeated_foreign_message = 49; + repeated protobuf_unittest_import.ImportMessage repeated_import_message = 50; + + repeated NestedEnum repeated_nested_enum = 51; + repeated ForeignEnum repeated_foreign_enum = 52; + repeated protobuf_unittest_import.ImportEnum repeated_import_enum = 53; + // Defined in unittest_import_public.proto + repeated protobuf_unittest_import.PublicImportMessage + repeated_public_import_message = 54; + + // For oneof test + oneof oneof_field { + uint32 oneof_uint32 = 111; + NestedMessage oneof_nested_message = 112; + string oneof_string = 113; + bytes oneof_bytes = 114; + } +} + +// This proto includes a recusively nested message. +message NestedTestAllTypes { + NestedTestAllTypes child = 1; + TestAllTypes payload = 2; + repeated NestedTestAllTypes repeated_child = 3; +} + +message TestDeprecatedFields { + int32 deprecated_int32 = 1 [deprecated=true]; +} + +// Define these after TestAllTypes to make sure the compiler can handle +// that. +message ForeignMessage { + int32 c = 1; +} + +enum ForeignEnum { + FOREIGN_UNSPECIFIED = 0; + FOREIGN_FOO = 4; + FOREIGN_BAR = 5; + FOREIGN_BAZ = 6; +} + +message TestReservedFields { + reserved 2, 15, 9 to 11; + reserved "bar", "baz"; +} + + +// Test that we can use NestedMessage from outside TestAllTypes. +message TestForeignNested { + TestAllTypes.NestedMessage foreign_nested = 1; +} + +// Test that really large tag numbers don't break anything. +message TestReallyLargeTagNumber { + // The largest possible tag number is 2^28 - 1, since the wire format uses + // three bits to communicate wire type. + int32 a = 1; + int32 bb = 268435455; +} + +message TestRecursiveMessage { + TestRecursiveMessage a = 1; + int32 i = 2; +} + +// Test that mutual recursion works. +message TestMutualRecursionA { + TestMutualRecursionB bb = 1; +} + +message TestMutualRecursionB { + TestMutualRecursionA a = 1; + int32 optional_int32 = 2; +} + + +// Test an enum that has multiple values with the same number. +enum TestEnumWithDupValue { + TEST_ENUM_WITH_DUP_VALUE_UNSPECIFIED = 0; + option allow_alias = true; + + FOO1 = 1; + BAR1 = 2; + BAZ = 3; + FOO2 = 1; + BAR2 = 2; +} + +// Test an enum with large, unordered values. +enum TestSparseEnum { + TEST_SPARSE_ENUM_UNSPECIFIED = 0; + SPARSE_A = 123; + SPARSE_B = 62374; + SPARSE_C = 12589234; + SPARSE_D = -15; + SPARSE_E = -53452; + // In proto3, value 0 must be the first one specified + // SPARSE_F = 0; + SPARSE_G = 2; +} + +// Test message with CamelCase field names. This violates Protocol Buffer +// standard style. +message TestCamelCaseFieldNames { + int32 PrimitiveField = 1; + string StringField = 2; + ForeignEnum EnumField = 3; + ForeignMessage MessageField = 4; + + repeated int32 RepeatedPrimitiveField = 7; + repeated string RepeatedStringField = 8; + repeated ForeignEnum RepeatedEnumField = 9; + repeated ForeignMessage RepeatedMessageField = 10; +} + + +// We list fields out of order, to ensure that we're using field number and not +// field index to determine serialization order. +message TestFieldOrderings { + string my_string = 11; + int64 my_int = 1; + float my_float = 101; + message NestedMessage { + int64 oo = 2; + // The field name "b" fails to compile in proto1 because it conflicts with + // a local variable named "b" in one of the generated methods. Doh. + // This file needs to compile in proto1 to test backwards-compatibility. + int32 bb = 1; + } + + NestedMessage single_nested_message = 200; +} + +message SparseEnumMessage { + TestSparseEnum sparse_enum = 1; +} + +// Test String and Bytes: string is for valid UTF-8 strings +message OneString { + string data = 1; +} + +message MoreString { + repeated string data = 1; +} + +message OneBytes { + bytes data = 1; +} + +message MoreBytes { + bytes data = 1; +} + +// Test int32, uint32, int64, uint64, and bool are all compatible +message Int32Message { + int32 data = 1; +} + +message Uint32Message { + uint32 data = 1; +} + +message Int64Message { + int64 data = 1; +} + +message Uint64Message { + uint64 data = 1; +} + +message BoolMessage { + bool data = 1; +} + +// Test oneofs. +message TestOneof { + oneof foo { + int32 foo_int = 1; + string foo_string = 2; + TestAllTypes foo_message = 3; + } +} + +// Test messages for packed fields + +message TestPackedTypes { + repeated int32 packed_int32 = 90 [packed = true]; + repeated int64 packed_int64 = 91 [packed = true]; + repeated uint32 packed_uint32 = 92 [packed = true]; + repeated uint64 packed_uint64 = 93 [packed = true]; + repeated sint32 packed_sint32 = 94 [packed = true]; + repeated sint64 packed_sint64 = 95 [packed = true]; + repeated fixed32 packed_fixed32 = 96 [packed = true]; + repeated fixed64 packed_fixed64 = 97 [packed = true]; + repeated sfixed32 packed_sfixed32 = 98 [packed = true]; + repeated sfixed64 packed_sfixed64 = 99 [packed = true]; + repeated float packed_float = 100 [packed = true]; + repeated double packed_double = 101 [packed = true]; + repeated bool packed_bool = 102 [packed = true]; + repeated ForeignEnum packed_enum = 103 [packed = true]; +} + +// A message with the same fields as TestPackedTypes, but without packing. Used +// to test packed <-> unpacked wire compatibility. +message TestUnpackedTypes { + repeated int32 unpacked_int32 = 90 [packed = false]; + repeated int64 unpacked_int64 = 91 [packed = false]; + repeated uint32 unpacked_uint32 = 92 [packed = false]; + repeated uint64 unpacked_uint64 = 93 [packed = false]; + repeated sint32 unpacked_sint32 = 94 [packed = false]; + repeated sint64 unpacked_sint64 = 95 [packed = false]; + repeated fixed32 unpacked_fixed32 = 96 [packed = false]; + repeated fixed64 unpacked_fixed64 = 97 [packed = false]; + repeated sfixed32 unpacked_sfixed32 = 98 [packed = false]; + repeated sfixed64 unpacked_sfixed64 = 99 [packed = false]; + repeated float unpacked_float = 100 [packed = false]; + repeated double unpacked_double = 101 [packed = false]; + repeated bool unpacked_bool = 102 [packed = false]; + repeated ForeignEnum unpacked_enum = 103 [packed = false]; +} + +message TestRepeatedScalarDifferentTagSizes { + // Parsing repeated fixed size values used to fail. This message needs to be + // used in order to get a tag of the right size; all of the repeated fields + // in TestAllTypes didn't trigger the check. + repeated fixed32 repeated_fixed32 = 12; + // Check for a varint type, just for good measure. + repeated int32 repeated_int32 = 13; + + // These have two-byte tags. + repeated fixed64 repeated_fixed64 = 2046; + repeated int64 repeated_int64 = 2047; + + // Three byte tags. + repeated float repeated_float = 262142; + repeated uint64 repeated_uint64 = 262143; +} + +message TestCommentInjectionMessage { + // */ <- This should not close the generated doc comment + string a = 1; +} + + +// Test that RPC services work. +message FooRequest {} +message FooResponse {} + +message FooClientMessage {} +message FooServerMessage{} + +service TestService { + rpc Foo(FooRequest) returns (FooResponse); + rpc Bar(BarRequest) returns (BarResponse); +} + + +message BarRequest {} +message BarResponse {} + -- cgit v1.2.3 From 954e720837be515254360cf9fdf3d9681c1bd91c Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Tue, 9 Jun 2015 19:44:24 +0100 Subject: Use expression trees to avoid boxing when converting enums. --- csharp/src/ProtocolBuffers/EnumHelper.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/csharp/src/ProtocolBuffers/EnumHelper.cs b/csharp/src/ProtocolBuffers/EnumHelper.cs index 7e76d71b..1cf18985 100644 --- a/csharp/src/ProtocolBuffers/EnumHelper.cs +++ b/csharp/src/ProtocolBuffers/EnumHelper.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Linq.Expressions; using System.Text; namespace Google.Protobuf @@ -10,6 +11,8 @@ namespace Google.Protobuf // TODO(jonskeet): For snmall enums, use something lighter-weight than a dictionary? private static readonly Dictionary _byNumber; private static readonly Dictionary _byName; + private static readonly Func toRawValue; + private static readonly Func fromRawValue; private const long UnknownValueBase = 0x100000000L; @@ -36,6 +39,13 @@ namespace Google.Protobuf { _byName[name] = (T) Enum.Parse(typeof(T), name, false); } + + ParameterExpression param1 = Expression.Parameter(typeof(T), "x"); + ParameterExpression param2 = Expression.Parameter(typeof(long), "x"); + Expression convertedParam1 = Expression.Convert(param1, typeof(long)); + Expression convertedParam2 = Expression.Convert(param2, typeof(T)); + toRawValue = Expression.Lambda>(convertedParam1, param1).Compile(); + fromRawValue = Expression.Lambda>(convertedParam2, param2).Compile(); } /// @@ -71,14 +81,12 @@ namespace Google.Protobuf private static long GetRawValue(T value) { - // TODO(jonskeet): Try using expression trees to get rid of the boxing here. - return (long)(object)value; + return toRawValue(value); } private static T FromRawValue(long value) { - // TODO(jonskeet): Try using expression trees to get rid of the boxing here. - return (T)(object)value; + return fromRawValue(value); } } -- cgit v1.2.3 From 35e4dbd51829216fd1ad85a95c01042346b63c6b Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Thu, 11 Jun 2015 14:19:30 +0100 Subject: Improve string encoding times. Cache a reference to Encoding.UTF8 - the property access is (rather surprisingly) significant. Additionally, when we detect that the string is all ASCII (due to the computed length in bytes being the length in characters), we can perform the encoding very efficiently ourselves. --- .../ProtocolBuffers/CodedOutputStream.ComputeSize.cs | 4 ++-- csharp/src/ProtocolBuffers/CodedOutputStream.cs | 18 +++++++++++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs b/csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs index 5457f79f..58475ff7 100644 --- a/csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs +++ b/csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs @@ -135,7 +135,7 @@ namespace Google.Protobuf /// public static int ComputeStringSize(int fieldNumber, String value) { - int byteArraySize = Encoding.UTF8.GetByteCount(value); + int byteArraySize = UTF8.GetByteCount(value); return ComputeTagSize(fieldNumber) + ComputeRawVarint32Size((uint) byteArraySize) + byteArraySize; @@ -323,7 +323,7 @@ namespace Google.Protobuf /// public static int ComputeStringSizeNoTag(String value) { - int byteArraySize = Encoding.UTF8.GetByteCount(value); + int byteArraySize = UTF8.GetByteCount(value); return ComputeRawVarint32Size((uint) byteArraySize) + byteArraySize; } diff --git a/csharp/src/ProtocolBuffers/CodedOutputStream.cs b/csharp/src/ProtocolBuffers/CodedOutputStream.cs index efc83d0e..c817a20b 100644 --- a/csharp/src/ProtocolBuffers/CodedOutputStream.cs +++ b/csharp/src/ProtocolBuffers/CodedOutputStream.cs @@ -58,6 +58,8 @@ namespace Google.Protobuf /// public sealed partial class CodedOutputStream : ICodedOutputStream { + private static readonly Encoding UTF8 = Encoding.UTF8; + /// /// The buffer size used by CreateInstance(Stream). /// @@ -294,16 +296,26 @@ namespace Google.Protobuf WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited); // Optimise the case where we have enough space to write // the string directly to the buffer, which should be common. - int length = Encoding.UTF8.GetByteCount(value); + int length = UTF8.GetByteCount(value); WriteRawVarint32((uint) length); if (limit - position >= length) { - Encoding.UTF8.GetBytes(value, 0, value.Length, buffer, position); + if (length == value.Length) // Must be all ASCII... + { + for (int i = 0; i < length; i++) + { + buffer[position + i] = (byte)value[i]; + } + } + else + { + UTF8.GetBytes(value, 0, value.Length, buffer, position); + } position += length; } else { - byte[] bytes = Encoding.UTF8.GetBytes(value); + byte[] bytes = UTF8.GetBytes(value); WriteRawBytes(bytes); } } -- cgit v1.2.3 From ce0e348ded9cb7e180588476ebb5a8f3e0460f4e Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Thu, 11 Jun 2015 14:32:19 +0100 Subject: Optimize WriteRawInt32 for the common case of a value < 128, which is a single byte. Aside from anything else, this will be used for all tags for fields 1-15. --- csharp/src/ProtocolBuffers/CodedOutputStream.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/csharp/src/ProtocolBuffers/CodedOutputStream.cs b/csharp/src/ProtocolBuffers/CodedOutputStream.cs index c817a20b..f55f8ca2 100644 --- a/csharp/src/ProtocolBuffers/CodedOutputStream.cs +++ b/csharp/src/ProtocolBuffers/CodedOutputStream.cs @@ -1033,6 +1033,13 @@ namespace Google.Protobuf /// public void WriteRawVarint32(uint value) { + // Optimize for the common case of a single byte value + if (value < 128 && position < limit) + { + buffer[position++] = (byte)value; + return; + } + while (value > 127 && position < limit) { buffer[position++] = (byte) ((value & 0x7F) | 0x80); -- cgit v1.2.3 From 39aaf21d5194fdc07c296847def8e7795279e041 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Thu, 11 Jun 2015 21:15:36 +0100 Subject: Reimplement enums as int values, and get rid of EnumHelper. This makes repeated fields really awkward at the moment - but when we reimplement RepeatedField to be backed by an array, we can cast the array directly... --- .../ProtocolBuffers.Test/CodedInputStreamTest.cs | 6 +- .../ProtocolBuffers.Test/CodedOutputStreamTest.cs | 10 +-- .../TestProtos/UnittestImportProto3.cs | 2 +- .../TestProtos/UnittestIssues.cs | 28 ++++--- .../TestProtos/UnittestProto3.cs | 65 ++++++++------- csharp/src/ProtocolBuffers/CodedInputStream.cs | 17 ++-- .../CodedOutputStream.ComputeSize.cs | 12 +-- csharp/src/ProtocolBuffers/CodedOutputStream.cs | 24 ++++-- .../DescriptorProtos/DescriptorProtoFile.cs | 55 +++++++------ csharp/src/ProtocolBuffers/EnumHelper.cs | 93 ---------------------- csharp/src/ProtocolBuffers/ICodedInputStream.cs | 11 +-- csharp/src/ProtocolBuffers/ICodedOutputStream.cs | 2 +- csharp/src/ProtocolBuffers/ProtocolBuffers.csproj | 1 - src/google/protobuf/compiler/csharp/csharp_enum.cc | 2 +- .../protobuf/compiler/csharp/csharp_enum_field.cc | 15 ++-- .../compiler/csharp/csharp_repeated_enum_field.cc | 2 +- 16 files changed, 137 insertions(+), 208 deletions(-) delete mode 100644 csharp/src/ProtocolBuffers/EnumHelper.cs diff --git a/csharp/src/ProtocolBuffers.Test/CodedInputStreamTest.cs b/csharp/src/ProtocolBuffers.Test/CodedInputStreamTest.cs index 57650049..aa2da330 100644 --- a/csharp/src/ProtocolBuffers.Test/CodedInputStreamTest.cs +++ b/csharp/src/ProtocolBuffers.Test/CodedInputStreamTest.cs @@ -466,18 +466,18 @@ namespace Google.Protobuf } } - enum TestNegEnum : long { None = 0, Value = -2 } + enum TestNegEnum { None = 0, Value = -2 } [Test] public void TestNegativeEnum() { byte[] bytes = new byte[10] { 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01 }; CodedInputStream input = CodedInputStream.CreateInstance(bytes); - TestNegEnum val = TestNegEnum.None; + int val = 0; Assert.IsTrue(input.ReadEnum(ref val)); Assert.IsTrue(input.IsAtEnd); - Assert.AreEqual(TestNegEnum.Value, val); + Assert.AreEqual((int) TestNegEnum.Value, val); } [Test] diff --git a/csharp/src/ProtocolBuffers.Test/CodedOutputStreamTest.cs b/csharp/src/ProtocolBuffers.Test/CodedOutputStreamTest.cs index df80b3af..fcbb7f8d 100644 --- a/csharp/src/ProtocolBuffers.Test/CodedOutputStreamTest.cs +++ b/csharp/src/ProtocolBuffers.Test/CodedOutputStreamTest.cs @@ -296,27 +296,27 @@ namespace Google.Protobuf public void TestNegativeEnumNoTag() { Assert.AreEqual(10, CodedOutputStream.ComputeInt32SizeNoTag(-2)); - Assert.AreEqual(10, CodedOutputStream.ComputeEnumSizeNoTag(TestNegEnum.Value)); + Assert.AreEqual(10, CodedOutputStream.ComputeEnumSizeNoTag((int) TestNegEnum.Value)); byte[] bytes = new byte[10]; CodedOutputStream output = CodedOutputStream.CreateInstance(bytes); - output.WriteEnumNoTag(TestNegEnum.Value); + output.WriteEnumNoTag((int) TestNegEnum.Value); Assert.AreEqual(0, output.SpaceLeft); Assert.AreEqual("FE-FF-FF-FF-FF-FF-FF-FF-FF-01", BitConverter.ToString(bytes)); } - enum TestNegEnum : long { None = 0, Value = -2 } + enum TestNegEnum { None = 0, Value = -2 } [Test] public void TestNegativeEnumWithTag() { Assert.AreEqual(11, CodedOutputStream.ComputeInt32Size(8, -2)); - Assert.AreEqual(11, CodedOutputStream.ComputeEnumSize(8, TestNegEnum.Value)); + Assert.AreEqual(11, CodedOutputStream.ComputeEnumSize(8, (int) TestNegEnum.Value)); byte[] bytes = new byte[11]; CodedOutputStream output = CodedOutputStream.CreateInstance(bytes); - output.WriteEnum(8, "", TestNegEnum.Value); + output.WriteEnum(8, "", (int) TestNegEnum.Value); Assert.AreEqual(0, output.SpaceLeft); //fyi, 0x40 == 0x08 << 3 + 0, field num + wire format shift diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportProto3.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportProto3.cs index 1eb87f05..4b62794a 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportProto3.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportProto3.cs @@ -49,7 +49,7 @@ namespace Google.Protobuf.TestProtos { } #region Enums - public enum ImportEnum : long { + public enum ImportEnum { IMPORT_ENUM_UNSPECIFIED = 0, IMPORT_FOO = 7, IMPORT_BAR = 8, diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs index fc696cf0..14ca78a4 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs @@ -75,13 +75,13 @@ namespace UnitTest.Issues.TestProtos { } #region Enums - public enum NegativeEnum : long { + public enum NegativeEnum { NEGATIVE_ENUM_ZERO = 0, FiveBelow = -5, MinusOne = -1, } - public enum DeprecatedEnum : long { + public enum DeprecatedEnum { DEPRECATED_ZERO = 0, one = 1, } @@ -156,7 +156,7 @@ namespace UnitTest.Issues.TestProtos { public void WriteTo(pb::ICodedOutputStream output) { string[] fieldNames = _fieldNames; if (Value != global::UnitTest.Issues.TestProtos.NegativeEnum.NEGATIVE_ENUM_ZERO) { - output.WriteEnum(1, fieldNames[1], Value); + output.WriteEnum(1, fieldNames[1], (int) Value); } output.WriteEnumArray(2, fieldNames[2], values_); output.WritePackedEnumArray(3, fieldNames[0], packedValues_); @@ -165,13 +165,13 @@ namespace UnitTest.Issues.TestProtos { public int CalculateSize() { int size = 0; if (Value != global::UnitTest.Issues.TestProtos.NegativeEnum.NEGATIVE_ENUM_ZERO) { - size += pb::CodedOutputStream.ComputeEnumSize(1, Value); + size += pb::CodedOutputStream.ComputeEnumSize(1, (int) Value); } { int dataSize = 0; if (values_.Count > 0) { foreach (global::UnitTest.Issues.TestProtos.NegativeEnum element in values_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag(element); + dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); } size += dataSize; size += 1 * values_.Count; @@ -181,7 +181,7 @@ namespace UnitTest.Issues.TestProtos { int dataSize = 0; if (packedValues_.Count > 0) { foreach (global::UnitTest.Issues.TestProtos.NegativeEnum element in packedValues_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag(element); + dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); } size += dataSize; size += 1; @@ -220,8 +220,9 @@ namespace UnitTest.Issues.TestProtos { } break; case 8: { - input.ReadEnum(ref value_); - break; + int tmp = 0; + input.ReadEnum(ref tmp); + value_ = (global::UnitTest.Issues.TestProtos.NegativeEnum) tmp;break; } case 18: case 16: { @@ -422,7 +423,7 @@ namespace UnitTest.Issues.TestProtos { } output.WriteMessageArray(4, fieldNames[2], messageArray_); if (EnumValue != global::UnitTest.Issues.TestProtos.DeprecatedEnum.DEPRECATED_ZERO) { - output.WriteEnum(5, fieldNames[1], EnumValue); + output.WriteEnum(5, fieldNames[1], (int) EnumValue); } output.WritePackedEnumArray(6, fieldNames[0], enumArray_); } @@ -449,13 +450,13 @@ namespace UnitTest.Issues.TestProtos { size += pb::CodedOutputStream.ComputeMessageSize(4, element); } if (EnumValue != global::UnitTest.Issues.TestProtos.DeprecatedEnum.DEPRECATED_ZERO) { - size += pb::CodedOutputStream.ComputeEnumSize(5, EnumValue); + size += pb::CodedOutputStream.ComputeEnumSize(5, (int) EnumValue); } { int dataSize = 0; if (enumArray_.Count > 0) { foreach (global::UnitTest.Issues.TestProtos.DeprecatedEnum element in enumArray_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag(element); + dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); } size += dataSize; size += 1; @@ -524,8 +525,9 @@ namespace UnitTest.Issues.TestProtos { break; } case 40: { - input.ReadEnum(ref enumValue_); - break; + int tmp = 0; + input.ReadEnum(ref tmp); + enumValue_ = (global::UnitTest.Issues.TestProtos.DeprecatedEnum) tmp;break; } case 50: case 48: { diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs index e231bb95..3e5bb8b6 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs @@ -372,14 +372,14 @@ namespace Google.Protobuf.TestProtos { } #region Enums - public enum ForeignEnum : long { + public enum ForeignEnum { FOREIGN_UNSPECIFIED = 0, FOREIGN_FOO = 4, FOREIGN_BAR = 5, FOREIGN_BAZ = 6, } - public enum TestEnumWithDupValue : long { + public enum TestEnumWithDupValue { TEST_ENUM_WITH_DUP_VALUE_UNSPECIFIED = 0, FOO1 = 1, BAR1 = 2, @@ -388,7 +388,7 @@ namespace Google.Protobuf.TestProtos { BAR2 = 2, } - public enum TestSparseEnum : long { + public enum TestSparseEnum { TEST_SPARSE_ENUM_UNSPECIFIED = 0, SPARSE_A = 123, SPARSE_B = 62374, @@ -945,13 +945,13 @@ namespace Google.Protobuf.TestProtos { output.WriteMessage(20, fieldNames[35], SingleImportMessage); } if (SingleNestedEnum != global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum.NESTED_ENUM_UNSPECIFIED) { - output.WriteEnum(21, fieldNames[38], SingleNestedEnum); + output.WriteEnum(21, fieldNames[38], (int) SingleNestedEnum); } if (SingleForeignEnum != global::Google.Protobuf.TestProtos.ForeignEnum.FOREIGN_UNSPECIFIED) { - output.WriteEnum(22, fieldNames[32], SingleForeignEnum); + output.WriteEnum(22, fieldNames[32], (int) SingleForeignEnum); } if (SingleImportEnum != global::Google.Protobuf.TestProtos.ImportEnum.IMPORT_ENUM_UNSPECIFIED) { - output.WriteEnum(23, fieldNames[34], SingleImportEnum); + output.WriteEnum(23, fieldNames[34], (int) SingleImportEnum); } if (singlePublicImportMessage_ != null) { output.WriteMessage(26, fieldNames[40], SinglePublicImportMessage); @@ -1049,13 +1049,13 @@ namespace Google.Protobuf.TestProtos { size += pb::CodedOutputStream.ComputeMessageSize(20, SingleImportMessage); } if (SingleNestedEnum != global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum.NESTED_ENUM_UNSPECIFIED) { - size += pb::CodedOutputStream.ComputeEnumSize(21, SingleNestedEnum); + size += pb::CodedOutputStream.ComputeEnumSize(21, (int) SingleNestedEnum); } if (SingleForeignEnum != global::Google.Protobuf.TestProtos.ForeignEnum.FOREIGN_UNSPECIFIED) { - size += pb::CodedOutputStream.ComputeEnumSize(22, SingleForeignEnum); + size += pb::CodedOutputStream.ComputeEnumSize(22, (int) SingleForeignEnum); } if (SingleImportEnum != global::Google.Protobuf.TestProtos.ImportEnum.IMPORT_ENUM_UNSPECIFIED) { - size += pb::CodedOutputStream.ComputeEnumSize(23, SingleImportEnum); + size += pb::CodedOutputStream.ComputeEnumSize(23, (int) SingleImportEnum); } if (singlePublicImportMessage_ != null) { size += pb::CodedOutputStream.ComputeMessageSize(26, SinglePublicImportMessage); @@ -1205,7 +1205,7 @@ namespace Google.Protobuf.TestProtos { int dataSize = 0; if (repeatedNestedEnum_.Count > 0) { foreach (global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum element in repeatedNestedEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag(element); + dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); } size += dataSize; size += 2; @@ -1216,7 +1216,7 @@ namespace Google.Protobuf.TestProtos { int dataSize = 0; if (repeatedForeignEnum_.Count > 0) { foreach (global::Google.Protobuf.TestProtos.ForeignEnum element in repeatedForeignEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag(element); + dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); } size += dataSize; size += 2; @@ -1227,7 +1227,7 @@ namespace Google.Protobuf.TestProtos { int dataSize = 0; if (repeatedImportEnum_.Count > 0) { foreach (global::Google.Protobuf.TestProtos.ImportEnum element in repeatedImportEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag(element); + dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); } size += dataSize; size += 2; @@ -1472,16 +1472,19 @@ namespace Google.Protobuf.TestProtos { break; } case 168: { - input.ReadEnum(ref singleNestedEnum_); - break; + int tmp = 0; + input.ReadEnum(ref tmp); + singleNestedEnum_ = (global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum) tmp;break; } case 176: { - input.ReadEnum(ref singleForeignEnum_); - break; + int tmp = 0; + input.ReadEnum(ref tmp); + singleForeignEnum_ = (global::Google.Protobuf.TestProtos.ForeignEnum) tmp;break; } case 184: { - input.ReadEnum(ref singleImportEnum_); - break; + int tmp = 0; + input.ReadEnum(ref tmp); + singleImportEnum_ = (global::Google.Protobuf.TestProtos.ImportEnum) tmp;break; } case 210: { if (singlePublicImportMessage_ == null) { @@ -1634,7 +1637,7 @@ namespace Google.Protobuf.TestProtos { #region Nested types [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class Types { - public enum NestedEnum : long { + public enum NestedEnum { NESTED_ENUM_UNSPECIFIED = 0, FOO = 1, BAR = 2, @@ -2865,7 +2868,7 @@ namespace Google.Protobuf.TestProtos { output.WriteString(2, fieldNames[7], StringField); } if (EnumField != global::Google.Protobuf.TestProtos.ForeignEnum.FOREIGN_UNSPECIFIED) { - output.WriteEnum(3, fieldNames[0], EnumField); + output.WriteEnum(3, fieldNames[0], (int) EnumField); } if (messageField_ != null) { output.WriteMessage(4, fieldNames[1], MessageField); @@ -2885,7 +2888,7 @@ namespace Google.Protobuf.TestProtos { size += pb::CodedOutputStream.ComputeStringSize(2, StringField); } if (EnumField != global::Google.Protobuf.TestProtos.ForeignEnum.FOREIGN_UNSPECIFIED) { - size += pb::CodedOutputStream.ComputeEnumSize(3, EnumField); + size += pb::CodedOutputStream.ComputeEnumSize(3, (int) EnumField); } if (messageField_ != null) { size += pb::CodedOutputStream.ComputeMessageSize(4, MessageField); @@ -2912,7 +2915,7 @@ namespace Google.Protobuf.TestProtos { int dataSize = 0; if (repeatedEnumField_.Count > 0) { foreach (global::Google.Protobuf.TestProtos.ForeignEnum element in repeatedEnumField_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag(element); + dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); } size += dataSize; size += 1; @@ -2976,8 +2979,9 @@ namespace Google.Protobuf.TestProtos { break; } case 24: { - input.ReadEnum(ref enumField_); - break; + int tmp = 0; + input.ReadEnum(ref tmp); + enumField_ = (global::Google.Protobuf.TestProtos.ForeignEnum) tmp;break; } case 34: { if (messageField_ == null) { @@ -3361,14 +3365,14 @@ namespace Google.Protobuf.TestProtos { public void WriteTo(pb::ICodedOutputStream output) { string[] fieldNames = _fieldNames; if (SparseEnum != global::Google.Protobuf.TestProtos.TestSparseEnum.TEST_SPARSE_ENUM_UNSPECIFIED) { - output.WriteEnum(1, fieldNames[0], SparseEnum); + output.WriteEnum(1, fieldNames[0], (int) SparseEnum); } } public int CalculateSize() { int size = 0; if (SparseEnum != global::Google.Protobuf.TestProtos.TestSparseEnum.TEST_SPARSE_ENUM_UNSPECIFIED) { - size += pb::CodedOutputStream.ComputeEnumSize(1, SparseEnum); + size += pb::CodedOutputStream.ComputeEnumSize(1, (int) SparseEnum); } return size; } @@ -3400,8 +3404,9 @@ namespace Google.Protobuf.TestProtos { } break; case 8: { - input.ReadEnum(ref sparseEnum_); - break; + int tmp = 0; + input.ReadEnum(ref tmp); + sparseEnum_ = (global::Google.Protobuf.TestProtos.TestSparseEnum) tmp;break; } } } @@ -4769,7 +4774,7 @@ namespace Google.Protobuf.TestProtos { int dataSize = 0; if (packedEnum_.Count > 0) { foreach (global::Google.Protobuf.TestProtos.ForeignEnum element in packedEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag(element); + dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); } size += dataSize; size += 2; @@ -5156,7 +5161,7 @@ namespace Google.Protobuf.TestProtos { int dataSize = 0; if (unpackedEnum_.Count > 0) { foreach (global::Google.Protobuf.TestProtos.ForeignEnum element in unpackedEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag(element); + dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); } size += dataSize; size += 2 * unpackedEnum_.Count; diff --git a/csharp/src/ProtocolBuffers/CodedInputStream.cs b/csharp/src/ProtocolBuffers/CodedInputStream.cs index 685d7702..d5cab6fd 100644 --- a/csharp/src/ProtocolBuffers/CodedInputStream.cs +++ b/csharp/src/ProtocolBuffers/CodedInputStream.cs @@ -434,11 +434,10 @@ namespace Google.Protobuf /// then the ref value is set and it returns true. Otherwise the unknown output /// value is set and this method returns false. /// - public bool ReadEnum(ref T value) - where T : struct, IComparable, IFormattable + public bool ReadEnum(ref int value) { - int number = (int) ReadRawVarint32(); - value = EnumHelper.FromInt32(number); + // Currently just a pass-through, but it's nice to separate it logically from WriteInt32. + value = (int) ReadRawVarint32(); return true; } @@ -796,7 +795,7 @@ namespace Google.Protobuf public void ReadEnumArray(uint fieldTag, string fieldName, ICollection list) where T : struct, IComparable, IFormattable { - T value = default(T); + int value = 0; WireFormat.WireType wformat = WireFormat.GetTagWireType(fieldTag); // 2.3 allows packed form even if the field is not declared packed. @@ -806,8 +805,9 @@ namespace Google.Protobuf int limit = PushLimit(length); while (!ReachedLimit) { - ReadEnum(ref value); - list.Add(value); + ReadEnum(ref value); + // TODO(jonskeet): Avoid this horrible boxing! + list.Add((T)(object)value); } PopLimit(limit); } @@ -816,7 +816,8 @@ namespace Google.Protobuf do { ReadEnum(ref value); - list.Add(value); + // TODO(jonskeet): Avoid this horrible boxing! + list.Add((T)(object) value); } while (ContinueArray(fieldTag)); } } diff --git a/csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs b/csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs index 58475ff7..96be9db5 100644 --- a/csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs +++ b/csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs @@ -196,7 +196,7 @@ namespace Google.Protobuf /// enum field, including the tag. The caller is responsible for /// converting the enum value to its numeric value. /// - public static int ComputeEnumSize(int fieldNumber, T value) where T : struct, IComparable, IFormattable + public static int ComputeEnumSize(int fieldNumber, int value) { return ComputeTagSize(fieldNumber) + ComputeEnumSizeNoTag(value); } @@ -371,10 +371,10 @@ namespace Google.Protobuf /// enum field, including the tag. The caller is responsible for /// converting the enum value to its numeric value. /// - public static int ComputeEnumSizeNoTag(T value) where T : struct, IComparable, IFormattable + public static int ComputeEnumSizeNoTag(int value) { - int serializedValue = EnumHelper.ToInt32(value); - return ComputeInt32SizeNoTag(serializedValue); + // Currently just a pass-through, but it's nice to separate it logically. + return ComputeInt32SizeNoTag(value); } /// @@ -555,7 +555,7 @@ namespace Google.Protobuf case FieldType.SInt64: return ComputeSInt64Size(fieldNumber, (long) value); case FieldType.Enum: - return ComputeEnumSize(fieldNumber, Convert.ToInt64(value)); + return ComputeEnumSize(fieldNumber, (int) value); default: throw new ArgumentOutOfRangeException("Invalid field type " + fieldType); } @@ -605,7 +605,7 @@ namespace Google.Protobuf case FieldType.SInt64: return ComputeSInt64SizeNoTag((long) value); case FieldType.Enum: - return ComputeEnumSizeNoTag(Convert.ToInt64(value)); + return ComputeEnumSizeNoTag((int) value); default: throw new ArgumentOutOfRangeException("Invalid field type " + fieldType); } diff --git a/csharp/src/ProtocolBuffers/CodedOutputStream.cs b/csharp/src/ProtocolBuffers/CodedOutputStream.cs index f55f8ca2..e3f0c700 100644 --- a/csharp/src/ProtocolBuffers/CodedOutputStream.cs +++ b/csharp/src/ProtocolBuffers/CodedOutputStream.cs @@ -37,6 +37,7 @@ using System; using System.Collections; using System.IO; +using System.Linq; using System.Text; using Google.Protobuf.Collections; using Google.Protobuf.Descriptors; @@ -350,10 +351,11 @@ namespace Google.Protobuf WriteRawVarint32(value); } - public void WriteEnum(int fieldNumber, string fieldName, T value) where T : struct, IComparable, IFormattable + public void WriteEnum(int fieldNumber, string fieldName, int value) { + // Currently just a pass-through, but it's nice to separate it logically from WriteInt32. WriteTag(fieldNumber, WireFormat.WireType.Varint); - WriteInt32NoTag(EnumHelper.ToInt32(value)); + WriteInt32NoTag(value); } public void WriteSFixed32(int fieldNumber, string fieldName, int value) @@ -595,9 +597,9 @@ namespace Google.Protobuf WriteRawVarint32(value); } - public void WriteEnumNoTag(T value) where T : struct, IComparable, IFormattable + public void WriteEnumNoTag(int value) { - WriteInt32NoTag(EnumHelper.ToInt32(value)); + WriteInt32NoTag(value); } public void WriteSFixed32NoTag(int value) @@ -774,7 +776,12 @@ namespace Google.Protobuf public void WriteEnumArray(int fieldNumber, string fieldName, RepeatedField list) where T : struct, IComparable, IFormattable { - foreach (T value in list) + if (list.Count == 0) + { + return; + } + // TODO(jonskeet): Avoid the Cast call here. Work out a better mass "T to int" conversion. + foreach (int value in list.Cast()) { WriteEnum(fieldNumber, fieldName, value); } @@ -1005,10 +1012,13 @@ namespace Google.Protobuf { return; } - uint size = list.CalculateSize(ComputeEnumSizeNoTag); + // Obviously, we'll want to get rid of this hack... + var temporaryHack = new RepeatedField(); + temporaryHack.Add(list.Cast()); + uint size = temporaryHack.CalculateSize(ComputeEnumSizeNoTag); WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited); WriteRawVarint32(size); - foreach (T value in list) + foreach (int value in temporaryHack) { WriteEnumNoTag(value); } diff --git a/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs b/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs index b18b63bf..eb96dfcf 100644 --- a/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs +++ b/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs @@ -1360,10 +1360,10 @@ namespace Google.Protobuf.DescriptorProtos { output.WriteInt32(3, fieldNames[4], Number); } if (Label != global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Label.LABEL_OPTIONAL) { - output.WriteEnum(4, fieldNames[2], Label); + output.WriteEnum(4, fieldNames[2], (int) Label); } if (Type != global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Type.TYPE_DOUBLE) { - output.WriteEnum(5, fieldNames[7], Type); + output.WriteEnum(5, fieldNames[7], (int) Type); } if (TypeName != "") { output.WriteString(6, fieldNames[8], TypeName); @@ -1388,10 +1388,10 @@ namespace Google.Protobuf.DescriptorProtos { size += pb::CodedOutputStream.ComputeInt32Size(3, Number); } if (Label != global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Label.LABEL_OPTIONAL) { - size += pb::CodedOutputStream.ComputeEnumSize(4, Label); + size += pb::CodedOutputStream.ComputeEnumSize(4, (int) Label); } if (Type != global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Type.TYPE_DOUBLE) { - size += pb::CodedOutputStream.ComputeEnumSize(5, Type); + size += pb::CodedOutputStream.ComputeEnumSize(5, (int) Type); } if (TypeName != "") { size += pb::CodedOutputStream.ComputeStringSize(6, TypeName); @@ -1477,12 +1477,14 @@ namespace Google.Protobuf.DescriptorProtos { break; } case 32: { - input.ReadEnum(ref label_); - break; + int tmp = 0; + input.ReadEnum(ref tmp); + label_ = (global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Label) tmp;break; } case 40: { - input.ReadEnum(ref type_); - break; + int tmp = 0; + input.ReadEnum(ref tmp); + type_ = (global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Type) tmp;break; } case 50: { input.ReadString(ref typeName_); @@ -1510,7 +1512,7 @@ namespace Google.Protobuf.DescriptorProtos { #region Nested types [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class Types { - public enum Type : long { + public enum Type { TYPE_DOUBLE = 1, TYPE_FLOAT = 2, TYPE_INT64 = 3, @@ -1531,7 +1533,7 @@ namespace Google.Protobuf.DescriptorProtos { TYPE_SINT64 = 18, } - public enum Label : long { + public enum Label { LABEL_OPTIONAL = 1, LABEL_REQUIRED = 2, LABEL_REPEATED = 3, @@ -2489,7 +2491,7 @@ namespace Google.Protobuf.DescriptorProtos { output.WriteString(8, fieldNames[8], JavaOuterClassname); } if (OptimizeFor != global::Google.Protobuf.DescriptorProtos.FileOptions.Types.OptimizeMode.SPEED) { - output.WriteEnum(9, fieldNames[12], OptimizeFor); + output.WriteEnum(9, fieldNames[12], (int) OptimizeFor); } if (JavaMultipleFiles != false) { output.WriteBool(10, fieldNames[7], JavaMultipleFiles); @@ -2545,7 +2547,7 @@ namespace Google.Protobuf.DescriptorProtos { size += pb::CodedOutputStream.ComputeBoolSize(27, JavaStringCheckUtf8); } if (OptimizeFor != global::Google.Protobuf.DescriptorProtos.FileOptions.Types.OptimizeMode.SPEED) { - size += pb::CodedOutputStream.ComputeEnumSize(9, OptimizeFor); + size += pb::CodedOutputStream.ComputeEnumSize(9, (int) OptimizeFor); } if (GoPackage != "") { size += pb::CodedOutputStream.ComputeStringSize(11, GoPackage); @@ -2652,8 +2654,9 @@ namespace Google.Protobuf.DescriptorProtos { break; } case 72: { - input.ReadEnum(ref optimizeFor_); - break; + int tmp = 0; + input.ReadEnum(ref tmp); + optimizeFor_ = (global::Google.Protobuf.DescriptorProtos.FileOptions.Types.OptimizeMode) tmp;break; } case 80: { input.ReadBool(ref javaMultipleFiles_); @@ -2710,7 +2713,7 @@ namespace Google.Protobuf.DescriptorProtos { #region Nested types [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class Types { - public enum OptimizeMode : long { + public enum OptimizeMode { SPEED = 1, CODE_SIZE = 2, LITE_RUNTIME = 3, @@ -3015,7 +3018,7 @@ namespace Google.Protobuf.DescriptorProtos { public void WriteTo(pb::ICodedOutputStream output) { string[] fieldNames = _fieldNames; if (Ctype != global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.CType.STRING) { - output.WriteEnum(1, fieldNames[0], Ctype); + output.WriteEnum(1, fieldNames[0], (int) Ctype); } if (Packed != false) { output.WriteBool(2, fieldNames[4], Packed); @@ -3027,7 +3030,7 @@ namespace Google.Protobuf.DescriptorProtos { output.WriteBool(5, fieldNames[3], Lazy); } if (Jstype != global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.JSType.JS_NORMAL) { - output.WriteEnum(6, fieldNames[2], Jstype); + output.WriteEnum(6, fieldNames[2], (int) Jstype); } if (Weak != false) { output.WriteBool(10, fieldNames[6], Weak); @@ -3038,13 +3041,13 @@ namespace Google.Protobuf.DescriptorProtos { public int CalculateSize() { int size = 0; if (Ctype != global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.CType.STRING) { - size += pb::CodedOutputStream.ComputeEnumSize(1, Ctype); + size += pb::CodedOutputStream.ComputeEnumSize(1, (int) Ctype); } if (Packed != false) { size += pb::CodedOutputStream.ComputeBoolSize(2, Packed); } if (Jstype != global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.JSType.JS_NORMAL) { - size += pb::CodedOutputStream.ComputeEnumSize(6, Jstype); + size += pb::CodedOutputStream.ComputeEnumSize(6, (int) Jstype); } if (Lazy != false) { size += pb::CodedOutputStream.ComputeBoolSize(5, Lazy); @@ -3104,8 +3107,9 @@ namespace Google.Protobuf.DescriptorProtos { } break; case 8: { - input.ReadEnum(ref ctype_); - break; + int tmp = 0; + input.ReadEnum(ref tmp); + ctype_ = (global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.CType) tmp;break; } case 16: { input.ReadBool(ref packed_); @@ -3120,8 +3124,9 @@ namespace Google.Protobuf.DescriptorProtos { break; } case 48: { - input.ReadEnum(ref jstype_); - break; + int tmp = 0; + input.ReadEnum(ref tmp); + jstype_ = (global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.JSType) tmp;break; } case 80: { input.ReadBool(ref weak_); @@ -3138,13 +3143,13 @@ namespace Google.Protobuf.DescriptorProtos { #region Nested types [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class Types { - public enum CType : long { + public enum CType { STRING = 0, CORD = 1, STRING_PIECE = 2, } - public enum JSType : long { + public enum JSType { JS_NORMAL = 0, JS_STRING = 1, JS_NUMBER = 2, diff --git a/csharp/src/ProtocolBuffers/EnumHelper.cs b/csharp/src/ProtocolBuffers/EnumHelper.cs deleted file mode 100644 index 1cf18985..00000000 --- a/csharp/src/ProtocolBuffers/EnumHelper.cs +++ /dev/null @@ -1,93 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Linq.Expressions; -using System.Text; - -namespace Google.Protobuf -{ - public class EnumHelper where T : struct, IComparable, IFormattable - { - // TODO(jonskeet): For snmall enums, use something lighter-weight than a dictionary? - private static readonly Dictionary _byNumber; - private static readonly Dictionary _byName; - private static readonly Func toRawValue; - private static readonly Func fromRawValue; - - private const long UnknownValueBase = 0x100000000L; - - static EnumHelper() - { - if (!typeof(T).IsEnum) - { - throw new InvalidOperationException(string.Format("{0} is not an enum type", typeof(T).FullName)); - } - if (Enum.GetUnderlyingType(typeof(T)) != typeof(long)) - { - throw new InvalidOperationException(string.Format("{0} does not have long as an underlying type", typeof(T).FullName)); - } - // It will actually be a T[], but the CLR will let us convert. - long[] array = (long[])Enum.GetValues(typeof(T)); - _byNumber = new Dictionary(array.Length); - foreach (long i in array) - { - _byNumber[(int) i] = (T)(object)i; - } - string[] names = (string[])Enum.GetNames(typeof(T)); - _byName = new Dictionary(); - foreach (var name in names) - { - _byName[name] = (T) Enum.Parse(typeof(T), name, false); - } - - ParameterExpression param1 = Expression.Parameter(typeof(T), "x"); - ParameterExpression param2 = Expression.Parameter(typeof(long), "x"); - Expression convertedParam1 = Expression.Convert(param1, typeof(long)); - Expression convertedParam2 = Expression.Convert(param2, typeof(T)); - toRawValue = Expression.Lambda>(convertedParam1, param1).Compile(); - fromRawValue = Expression.Lambda>(convertedParam2, param2).Compile(); - } - - /// - /// Converts the given 32-bit integer into a value of the enum type. - /// If the integer is a known, named value, that is returned; otherwise, - /// a value which is outside the range of 32-bit integers but which preserves - /// the original integer is returned. - /// - public static T FromInt32(int value) - { - T validValue; - return _byNumber.TryGetValue(value, out validValue) ? validValue : FromRawValue((long) value | UnknownValueBase); - } - - /// - /// Converts a value of the enum type to a 32-bit integer. This reverses - /// . - /// - public static int ToInt32(T value) - { - return (int)GetRawValue(value); - } - - public static bool IsKnownValue(T value) - { - long raw = GetRawValue(value); - if (raw >= int.MinValue && raw <= int.MaxValue) - { - return _byNumber.ContainsKey((int)raw); - } - return false; - } - - private static long GetRawValue(T value) - { - return toRawValue(value); - } - - private static T FromRawValue(long value) - { - return fromRawValue(value); - } - - } -} diff --git a/csharp/src/ProtocolBuffers/ICodedInputStream.cs b/csharp/src/ProtocolBuffers/ICodedInputStream.cs index 748589a0..d962e62b 100644 --- a/csharp/src/ProtocolBuffers/ICodedInputStream.cs +++ b/csharp/src/ProtocolBuffers/ICodedInputStream.cs @@ -146,14 +146,11 @@ namespace Google.Protobuf bool ReadUInt32(ref uint value); /// - /// Reads an enum field value from the stream. If the enum is valid for type T, - /// then the ref value is set and it returns true. Otherwise, if a value is present - /// but invalid for the proto enum, it is still set in the field as a "preserved - /// but invalid" value, and the method returns true. If no value can be read, the - /// method does not affect the parameter and returns false. + /// Reads an enum field value from the stream. This performs no checking + /// as to whether the enum value is known to the enum type as it was present + /// when the code was generated. /// - bool ReadEnum(ref T value) - where T : struct, IComparable, IFormattable; + bool ReadEnum(ref int value); /// /// Reads an sfixed32 field value from the stream. diff --git a/csharp/src/ProtocolBuffers/ICodedOutputStream.cs b/csharp/src/ProtocolBuffers/ICodedOutputStream.cs index e51c10a4..921400ac 100644 --- a/csharp/src/ProtocolBuffers/ICodedOutputStream.cs +++ b/csharp/src/ProtocolBuffers/ICodedOutputStream.cs @@ -148,7 +148,7 @@ namespace Google.Protobuf /// /// Writes an enum field value, including tag, to the stream. /// - void WriteEnum(int fieldNumber, string fieldName, T value) where T : struct, IComparable, IFormattable; + void WriteEnum(int fieldNumber, string fieldName, int value); /// /// Writes a fixed 32-bit field value, including tag, to the stream. diff --git a/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj b/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj index d15f1306..efd387a2 100644 --- a/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj +++ b/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj @@ -84,7 +84,6 @@ - diff --git a/src/google/protobuf/compiler/csharp/csharp_enum.cc b/src/google/protobuf/compiler/csharp/csharp_enum.cc index d511bba3..0e8f9836 100644 --- a/src/google/protobuf/compiler/csharp/csharp_enum.cc +++ b/src/google/protobuf/compiler/csharp/csharp_enum.cc @@ -58,7 +58,7 @@ EnumGenerator::~EnumGenerator() { void EnumGenerator::Generate(io::Printer* printer) { WriteGeneratedCodeAttributes(printer); - printer->Print("$access_level$ enum $name$ : long {\n", + printer->Print("$access_level$ enum $name$ {\n", "access_level", class_access_level(), "name", descriptor_->name()); printer->Indent(); diff --git a/src/google/protobuf/compiler/csharp/csharp_enum_field.cc b/src/google/protobuf/compiler/csharp/csharp_enum_field.cc index ee9d6a1d..3494b228 100644 --- a/src/google/protobuf/compiler/csharp/csharp_enum_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_enum_field.cc @@ -54,14 +54,17 @@ EnumFieldGenerator::~EnumFieldGenerator() { } void EnumFieldGenerator::GenerateParsingCode(io::Printer* printer) { + // TODO(jonskeet): Get rid of the temporary variable when we sanitize CodedInputStream not to use ref. printer->Print(variables_, - "input.ReadEnum(ref $name$_);\n"); + "int tmp = 0;\n" + "input.ReadEnum(ref tmp);\n" + "$name$_ = ($type_name$) tmp;"); } void EnumFieldGenerator::GenerateSerializationCode(io::Printer* printer) { printer->Print(variables_, "if ($has_property_check$) {\n" - " output.WriteEnum($number$, fieldNames[$field_ordinal$], $property_name$);\n" + " output.WriteEnum($number$, fieldNames[$field_ordinal$], (int) $property_name$);\n" "}\n"); } @@ -69,7 +72,7 @@ void EnumFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) { printer->Print( variables_, "if ($has_property_check$) {\n" - " size += pb::CodedOutputStream.ComputeEnumSize($number$, $property_name$);\n" + " size += pb::CodedOutputStream.ComputeEnumSize($number$, (int) $property_name$);\n" "}\n"); } @@ -85,7 +88,7 @@ void EnumOneofFieldGenerator::GenerateParsingCode(io::Printer* printer) { // TODO(jonskeet): What about if we read the default value? printer->Print( variables_, - "$type_name$ enumValue = $default_value$;\n" + "int enumValue = 0;\n" "if(input.ReadEnum(ref enumValue)) {\n" " $oneof_name$_ = enumValue;\n" " $oneof_name$Case_ = $oneof_property_name$OneofCase.$property_name$;\n" @@ -96,7 +99,7 @@ void EnumOneofFieldGenerator::GenerateSerializationCode(io::Printer* printer) { printer->Print( variables_, "if ($has_property_check$) {\n" - " output.WriteEnum($number$, fieldNames[$field_ordinal$], (long) $property_name$, $property_name$);\n" + " output.WriteEnum($number$, fieldNames[$field_ordinal$], (int) $property_name$);\n" "}\n"); } @@ -104,7 +107,7 @@ void EnumOneofFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) { printer->Print( variables_, "if ($has_property_check$) {\n" - " size += pb::CodedOutputStream.ComputeEnumSize($number$, (long) $property_name$);\n" + " size += pb::CodedOutputStream.ComputeEnumSize($number$, (int) $property_name$);\n" "}\n"); } diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc b/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc index ebbbf3be..937d675a 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc @@ -99,7 +99,7 @@ void RepeatedEnumFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer printer->Print( variables_, "foreach ($type_name$ element in $name$_) {\n" - " dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag(element);\n" + " dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element);\n" "}\n" "size += dataSize;\n"); int tagSize = internal::WireFormat::TagSize(descriptor_->number(), descriptor_->type()); -- cgit v1.2.3 From 96ddf01aed1a49d73a7fda50e28c431ffc977e5a Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Fri, 12 Jun 2015 09:53:12 +0100 Subject: Coded*Stream streamlining. Remove ICodedInputStream and ICodedOutputStream, and rewrite CodedInputStream and CodedOutputStream to be specific to the binary format. If we want to support text-based formats, that can be a whole different serialization mechanism. --- .../ProtocolBuffers.Test/CodedInputStreamTest.cs | 53 +- .../ProtocolBuffers.Test/CodedOutputStreamTest.cs | 43 +- .../TestProtos/UnittestImportProto3.cs | 18 +- .../TestProtos/UnittestImportPublicProto3.cs | 18 +- .../TestProtos/UnittestIssues.cs | 100 +- .../TestProtos/UnittestProto3.cs | 1000 +++++++------------- csharp/src/ProtocolBuffers/CodedInputStream.cs | 427 ++------- .../CodedOutputStream.ComputeSize.cs | 132 +-- csharp/src/ProtocolBuffers/CodedOutputStream.cs | 249 ++--- .../DescriptorProtos/DescriptorProtoFile.cs | 719 ++++++-------- csharp/src/ProtocolBuffers/Extensions.cs | 2 +- csharp/src/ProtocolBuffers/ICodedInputStream.cs | 293 ------ csharp/src/ProtocolBuffers/ICodedOutputStream.cs | 347 ------- csharp/src/ProtocolBuffers/IMessage.cs | 4 +- csharp/src/ProtocolBuffers/MessageParser.cs | 2 +- csharp/src/ProtocolBuffers/ProtocolBuffers.csproj | 2 - .../protobuf/compiler/csharp/csharp_enum_field.cc | 16 +- .../protobuf/compiler/csharp/csharp_message.cc | 17 +- .../compiler/csharp/csharp_message_field.cc | 3 +- .../compiler/csharp/csharp_primitive_field.cc | 16 +- .../compiler/csharp/csharp_repeated_enum_field.cc | 4 +- .../csharp/csharp_repeated_message_field.cc | 4 +- .../csharp/csharp_repeated_primitive_field.cc | 6 +- 23 files changed, 879 insertions(+), 2596 deletions(-) delete mode 100644 csharp/src/ProtocolBuffers/ICodedInputStream.cs delete mode 100644 csharp/src/ProtocolBuffers/ICodedOutputStream.cs diff --git a/csharp/src/ProtocolBuffers.Test/CodedInputStreamTest.cs b/csharp/src/ProtocolBuffers.Test/CodedInputStreamTest.cs index aa2da330..450662a6 100644 --- a/csharp/src/ProtocolBuffers.Test/CodedInputStreamTest.cs +++ b/csharp/src/ProtocolBuffers.Test/CodedInputStreamTest.cs @@ -336,13 +336,11 @@ namespace Google.Protobuf CodedInputStream input = CodedInputStream.CreateInstance(ms); uint testtag; - string ignore; - Assert.IsTrue(input.ReadTag(out testtag, out ignore)); + Assert.IsTrue(input.ReadTag(out testtag)); Assert.AreEqual(tag, testtag); - ByteString bytes = null; // TODO(jonskeet): Should this be ArgumentNullException instead? - Assert.Throws(() => input.ReadBytes(ref bytes)); + Assert.Throws(() => input.ReadBytes()); } private static TestRecursiveMessage MakeRecursiveMessage(int depth) @@ -435,13 +433,10 @@ namespace Google.Protobuf CodedInputStream input = CodedInputStream.CreateInstance(ms); - uint testtag; - string ignored; - - Assert.IsTrue(input.ReadTag(out testtag, out ignored)); - Assert.AreEqual(tag, testtag); - string text = null; - input.ReadString(ref text); + uint actualTag; + Assert.IsTrue(input.ReadTag(out actualTag)); + Assert.AreEqual(tag, actualTag); + string text = input.ReadString(); Assert.AreEqual('\ufffd', text[0]); } @@ -473,11 +468,8 @@ namespace Google.Protobuf { byte[] bytes = new byte[10] { 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01 }; CodedInputStream input = CodedInputStream.CreateInstance(bytes); - int val = 0; - - Assert.IsTrue(input.ReadEnum(ref val)); + Assert.AreEqual((int)TestNegEnum.Value, input.ReadEnum()); Assert.IsTrue(input.IsAtEnd); - Assert.AreEqual((int) TestNegEnum.Value, val); } [Test] @@ -487,17 +479,16 @@ namespace Google.Protobuf int msgSize = 1 + 1 + arraySize; byte[] bytes = new byte[msgSize]; CodedOutputStream output = CodedOutputStream.CreateInstance(bytes); - output.WritePackedInt32Array(8, "", new RepeatedField { 0, -1, -2, -3, -4, -5 }); + output.WritePackedInt32Array(8, new RepeatedField { 0, -1, -2, -3, -4, -5 }); Assert.AreEqual(0, output.SpaceLeft); CodedInputStream input = CodedInputStream.CreateInstance(bytes); uint tag; - string name; - Assert.IsTrue(input.ReadTag(out tag, out name)); + Assert.IsTrue(input.ReadTag(out tag)); List values = new List(); - input.ReadEnumArray(tag, name, values); + input.ReadEnumArray(tag, values); Assert.AreEqual(6, values.Count); Assert.AreEqual(TestNegEnum.None, values[0]); @@ -512,17 +503,16 @@ namespace Google.Protobuf int msgSize = arraySize; byte[] bytes = new byte[msgSize]; CodedOutputStream output = CodedOutputStream.CreateInstance(bytes); - output.WriteInt32Array(8, "", new RepeatedField { 0, -1, -2, -3, -4, -5 }); + output.WriteInt32Array(8, new RepeatedField { 0, -1, -2, -3, -4, -5 }); Assert.AreEqual(0, output.SpaceLeft); CodedInputStream input = CodedInputStream.CreateInstance(bytes); uint tag; - string name; - Assert.IsTrue(input.ReadTag(out tag, out name)); + Assert.IsTrue(input.ReadTag(out tag)); List values = new List(); - input.ReadEnumArray(tag, name, values); + input.ReadEnumArray(tag, values); Assert.AreEqual(6, values.Count); Assert.AreEqual(TestNegEnum.None, values[0]); @@ -537,26 +527,21 @@ namespace Google.Protobuf using (var ms = new MemoryStream()) { CodedOutputStream output = CodedOutputStream.CreateInstance(ms); - output.WriteField(FieldType.Bytes, 1, "bytes", ByteString.CopyFrom(new byte[100])); - output.WriteField(FieldType.Bytes, 2, "bytes", ByteString.CopyFrom(new byte[100])); + output.WriteBytes(1, ByteString.CopyFrom(new byte[100])); + output.WriteBytes(2, ByteString.CopyFrom(new byte[100])); output.Flush(); ms.Position = 0; CodedInputStream input = CodedInputStream.CreateInstance(ms, new byte[ms.Length / 2]); uint tag; - string ignore; - ByteString value; - - Assert.IsTrue(input.ReadTag(out tag, out ignore)); + Assert.IsTrue(input.ReadTag(out tag)); Assert.AreEqual(1, WireFormat.GetTagFieldNumber(tag)); - value = ByteString.Empty; - Assert.IsTrue(input.ReadBytes(ref value) && value.Length == 100); + Assert.AreEqual(100, input.ReadBytes().Length); - Assert.IsTrue(input.ReadTag(out tag, out ignore)); + Assert.IsTrue(input.ReadTag(out tag)); Assert.AreEqual(2, WireFormat.GetTagFieldNumber(tag)); - value = ByteString.Empty; - Assert.IsTrue(input.ReadBytes(ref value) && value.Length == 100); + Assert.AreEqual(100, input.ReadBytes().Length); } } } diff --git a/csharp/src/ProtocolBuffers.Test/CodedOutputStreamTest.cs b/csharp/src/ProtocolBuffers.Test/CodedOutputStreamTest.cs index fcbb7f8d..682c005a 100644 --- a/csharp/src/ProtocolBuffers.Test/CodedOutputStreamTest.cs +++ b/csharp/src/ProtocolBuffers.Test/CodedOutputStreamTest.cs @@ -316,7 +316,7 @@ namespace Google.Protobuf byte[] bytes = new byte[11]; CodedOutputStream output = CodedOutputStream.CreateInstance(bytes); - output.WriteEnum(8, "", (int) TestNegEnum.Value); + output.WriteEnum(8, (int) TestNegEnum.Value); Assert.AreEqual(0, output.SpaceLeft); //fyi, 0x40 == 0x08 << 3 + 0, field num + wire format shift @@ -330,18 +330,17 @@ namespace Google.Protobuf int msgSize = 1 + 1 + arraySize; byte[] bytes = new byte[msgSize]; CodedOutputStream output = CodedOutputStream.CreateInstance(bytes); - output.WritePackedEnumArray(8, "", new RepeatedField { + output.WritePackedEnumArray(8, new RepeatedField { 0, (TestNegEnum) (-1), TestNegEnum.Value, (TestNegEnum) (-3), (TestNegEnum) (-4), (TestNegEnum) (-5) }); Assert.AreEqual(0, output.SpaceLeft); CodedInputStream input = CodedInputStream.CreateInstance(bytes); uint tag; - string name; - Assert.IsTrue(input.ReadTag(out tag, out name)); + Assert.IsTrue(input.ReadTag(out tag)); List values = new List(); - input.ReadInt32Array(tag, name, values); + input.ReadInt32Array(tag, values); Assert.AreEqual(6, values.Count); for (int i = 0; i > -6; i--) @@ -355,17 +354,16 @@ namespace Google.Protobuf int msgSize = arraySize; byte[] bytes = new byte[msgSize]; CodedOutputStream output = CodedOutputStream.CreateInstance(bytes); - output.WriteEnumArray(8, "", new RepeatedField { + output.WriteEnumArray(8, new RepeatedField { 0, (TestNegEnum) (-1), TestNegEnum.Value, (TestNegEnum) (-3), (TestNegEnum) (-4), (TestNegEnum) (-5) }); Assert.AreEqual(0, output.SpaceLeft); CodedInputStream input = CodedInputStream.CreateInstance(bytes); uint tag; - string name; - Assert.IsTrue(input.ReadTag(out tag, out name)); + Assert.IsTrue(input.ReadTag(out tag)); List values = new List(); - input.ReadInt32Array(tag, name, values); + input.ReadInt32Array(tag, values); Assert.AreEqual(6, values.Count); for (int i = 0; i > -6; i--) @@ -425,16 +423,14 @@ namespace Google.Protobuf { CodedInputStream cin = CodedInputStream.CreateInstance(new MemoryStream(bytes), new byte[50]); uint tag; - int intValue = 0; - string ignore; Assert.AreEqual(0, cin.Position); // Field 1: - Assert.IsTrue(cin.ReadTag(out tag, out ignore) && tag >> 3 == 1); + Assert.IsTrue(cin.ReadTag(out tag) && tag >> 3 == 1); Assert.AreEqual(1, cin.Position); - Assert.IsTrue(cin.ReadInt32(ref intValue) && intValue == 500); + Assert.AreEqual(500, cin.ReadInt32()); Assert.AreEqual(3, cin.Position); //Field 2: - Assert.IsTrue(cin.ReadTag(out tag, out ignore) && tag >> 3 == 2); + Assert.IsTrue(cin.ReadTag(out tag) && tag >> 3 == 2); Assert.AreEqual(4, cin.Position); uint childlen = cin.ReadRawVarint32(); Assert.AreEqual(120u, childlen); @@ -444,30 +440,31 @@ namespace Google.Protobuf // Now we are reading child message { // Field 11: numeric value: 500 - Assert.IsTrue(cin.ReadTag(out tag, out ignore) && tag >> 3 == 11); + Assert.IsTrue(cin.ReadTag(out tag) && tag >> 3 == 11); Assert.AreEqual(6, cin.Position); - Assert.IsTrue(cin.ReadInt32(ref intValue) && intValue == 500); + Assert.AreEqual(500, cin.ReadInt32()); Assert.AreEqual(8, cin.Position); //Field 12: length delimited 120 bytes - Assert.IsTrue(cin.ReadTag(out tag, out ignore) && tag >> 3 == 12); + Assert.IsTrue(cin.ReadTag(out tag) && tag >> 3 == 12); Assert.AreEqual(9, cin.Position); - ByteString bstr = null; - Assert.IsTrue(cin.ReadBytes(ref bstr) && bstr.Length == 110 && bstr.ToByteArray()[109] == 109); + 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 - Assert.IsTrue(cin.ReadTag(out tag, out ignore) && tag >> 3 == 13); + Assert.IsTrue(cin.ReadTag(out tag) && tag >> 3 == 13); // ROK - Previously broken here, this returned 126 failing to account for bufferSizeAfterLimit Assert.AreEqual(121, cin.Position); - Assert.IsTrue(cin.ReadSFixed32(ref intValue) && intValue == 501); + Assert.AreEqual(501, cin.ReadSFixed32()); Assert.AreEqual(125, cin.Position); Assert.IsTrue(cin.IsAtEnd); } cin.PopLimit(oldlimit); Assert.AreEqual(125, cin.Position); // Field 3: fixed numeric value: 501 - Assert.IsTrue(cin.ReadTag(out tag, out ignore) && tag >> 3 == 3); + Assert.IsTrue(cin.ReadTag(out tag) && tag >> 3 == 3); Assert.AreEqual(126, cin.Position); - Assert.IsTrue(cin.ReadSFixed32(ref intValue) && intValue == 501); + Assert.AreEqual(501, cin.ReadSFixed32()); Assert.AreEqual(130, cin.Position); Assert.IsTrue(cin.IsAtEnd); } diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportProto3.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportProto3.cs index 4b62794a..1bd4e22b 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportProto3.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportProto3.cs @@ -107,10 +107,9 @@ namespace Google.Protobuf.TestProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { if (D != 0) { - output.WriteInt32(1, fieldNames[0], D); + output.WriteInt32(1, D); } } @@ -130,16 +129,9 @@ namespace Google.Protobuf.TestProtos { } } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -149,7 +141,7 @@ namespace Google.Protobuf.TestProtos { } break; case 8: { - input.ReadInt32(ref d_); + d_ = input.ReadInt32(); break; } } diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportPublicProto3.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportPublicProto3.cs index 2f7f8699..32123d53 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportPublicProto3.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportPublicProto3.cs @@ -92,10 +92,9 @@ namespace Google.Protobuf.TestProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { if (E != 0) { - output.WriteInt32(1, fieldNames[0], E); + output.WriteInt32(1, E); } } @@ -115,16 +114,9 @@ namespace Google.Protobuf.TestProtos { } } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -134,7 +126,7 @@ namespace Google.Protobuf.TestProtos { } break; case 8: { - input.ReadInt32(ref e_); + e_ = input.ReadInt32(); break; } } diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs index 14ca78a4..d8c8995b 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs @@ -153,13 +153,12 @@ namespace UnitTest.Issues.TestProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { if (Value != global::UnitTest.Issues.TestProtos.NegativeEnum.NEGATIVE_ENUM_ZERO) { - output.WriteEnum(1, fieldNames[1], (int) Value); + output.WriteEnum(1, (int) Value); } - output.WriteEnumArray(2, fieldNames[2], values_); - output.WritePackedEnumArray(3, fieldNames[0], packedValues_); + output.WriteEnumArray(2, values_); + output.WritePackedEnumArray(3, packedValues_); } public int CalculateSize() { @@ -201,16 +200,9 @@ namespace UnitTest.Issues.TestProtos { packedValues_.Add(other.packedValues_); } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -220,18 +212,17 @@ namespace UnitTest.Issues.TestProtos { } break; case 8: { - int tmp = 0; - input.ReadEnum(ref tmp); - value_ = (global::UnitTest.Issues.TestProtos.NegativeEnum) tmp;break; + value_ = (global::UnitTest.Issues.TestProtos.NegativeEnum) input.ReadEnum(); + break; } case 18: case 16: { - input.ReadEnumArray(tag, fieldName, values_); + input.ReadEnumArray(tag, values_); break; } case 26: case 24: { - input.ReadEnumArray(tag, fieldName, packedValues_); + input.ReadEnumArray(tag, packedValues_); break; } } @@ -278,8 +269,7 @@ namespace UnitTest.Issues.TestProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { } public int CalculateSize() { @@ -292,16 +282,9 @@ namespace UnitTest.Issues.TestProtos { } } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -412,20 +395,19 @@ namespace UnitTest.Issues.TestProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { if (PrimitiveValue != 0) { - output.WriteInt32(1, fieldNames[5], PrimitiveValue); + output.WriteInt32(1, PrimitiveValue); } - output.WritePackedInt32Array(2, fieldNames[4], primitiveArray_); + output.WritePackedInt32Array(2, primitiveArray_); if (messageValue_ != null) { - output.WriteMessage(3, fieldNames[3], MessageValue); + output.WriteMessage(3, MessageValue); } - output.WriteMessageArray(4, fieldNames[2], messageArray_); + output.WriteMessageArray(4, messageArray_); if (EnumValue != global::UnitTest.Issues.TestProtos.DeprecatedEnum.DEPRECATED_ZERO) { - output.WriteEnum(5, fieldNames[1], (int) EnumValue); + output.WriteEnum(5, (int) EnumValue); } - output.WritePackedEnumArray(6, fieldNames[0], enumArray_); + output.WritePackedEnumArray(6, enumArray_); } public int CalculateSize() { @@ -486,16 +468,9 @@ namespace UnitTest.Issues.TestProtos { enumArray_.Add(other.enumArray_); } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -505,12 +480,12 @@ namespace UnitTest.Issues.TestProtos { } break; case 8: { - input.ReadInt32(ref primitiveValue_); + primitiveValue_ = input.ReadInt32(); break; } case 18: case 16: { - input.ReadInt32Array(tag, fieldName, primitiveArray_); + input.ReadInt32Array(tag, primitiveArray_); break; } case 26: { @@ -521,17 +496,16 @@ namespace UnitTest.Issues.TestProtos { break; } case 34: { - input.ReadMessageArray(tag, fieldName, messageArray_, global::UnitTest.Issues.TestProtos.DeprecatedChild.Parser); + input.ReadMessageArray(tag, messageArray_, global::UnitTest.Issues.TestProtos.DeprecatedChild.Parser); break; } case 40: { - int tmp = 0; - input.ReadEnum(ref tmp); - enumValue_ = (global::UnitTest.Issues.TestProtos.DeprecatedEnum) tmp;break; + enumValue_ = (global::UnitTest.Issues.TestProtos.DeprecatedEnum) input.ReadEnum(); + break; } case 50: case 48: { - input.ReadEnumArray(tag, fieldName, enumArray_); + input.ReadEnumArray(tag, enumArray_); break; } } @@ -588,10 +562,9 @@ namespace UnitTest.Issues.TestProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { if (Item != 0) { - output.WriteInt32(1, fieldNames[0], Item); + output.WriteInt32(1, Item); } } @@ -611,16 +584,9 @@ namespace UnitTest.Issues.TestProtos { } } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -630,7 +596,7 @@ namespace UnitTest.Issues.TestProtos { } break; case 8: { - input.ReadInt32(ref item_); + item_ = input.ReadInt32(); break; } } diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs index 3e5bb8b6..4c4dabab 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs @@ -888,107 +888,106 @@ namespace Google.Protobuf.TestProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { if (SingleInt32 != 0) { - output.WriteInt32(1, fieldNames[36], SingleInt32); + output.WriteInt32(1, SingleInt32); } if (SingleInt64 != 0L) { - output.WriteInt64(2, fieldNames[37], SingleInt64); + output.WriteInt64(2, SingleInt64); } if (SingleUint32 != 0) { - output.WriteUInt32(3, fieldNames[46], SingleUint32); + output.WriteUInt32(3, SingleUint32); } if (SingleUint64 != 0UL) { - output.WriteUInt64(4, fieldNames[47], SingleUint64); + output.WriteUInt64(4, SingleUint64); } if (SingleSint32 != 0) { - output.WriteSInt32(5, fieldNames[43], SingleSint32); + output.WriteSInt32(5, SingleSint32); } if (SingleSint64 != 0L) { - output.WriteSInt64(6, fieldNames[44], SingleSint64); + output.WriteSInt64(6, SingleSint64); } if (SingleFixed32 != 0) { - output.WriteFixed32(7, fieldNames[29], SingleFixed32); + output.WriteFixed32(7, SingleFixed32); } if (SingleFixed64 != 0UL) { - output.WriteFixed64(8, fieldNames[30], SingleFixed64); + output.WriteFixed64(8, SingleFixed64); } if (SingleSfixed32 != 0) { - output.WriteSFixed32(9, fieldNames[41], SingleSfixed32); + output.WriteSFixed32(9, SingleSfixed32); } if (SingleSfixed64 != 0L) { - output.WriteSFixed64(10, fieldNames[42], SingleSfixed64); + output.WriteSFixed64(10, SingleSfixed64); } if (SingleFloat != 0F) { - output.WriteFloat(11, fieldNames[31], SingleFloat); + output.WriteFloat(11, SingleFloat); } if (SingleDouble != 0D) { - output.WriteDouble(12, fieldNames[28], SingleDouble); + output.WriteDouble(12, SingleDouble); } if (SingleBool != false) { - output.WriteBool(13, fieldNames[26], SingleBool); + output.WriteBool(13, SingleBool); } if (SingleString != "") { - output.WriteString(14, fieldNames[45], SingleString); + output.WriteString(14, SingleString); } if (SingleBytes != pb::ByteString.Empty) { - output.WriteBytes(15, fieldNames[27], SingleBytes); + output.WriteBytes(15, SingleBytes); } if (singleNestedMessage_ != null) { - output.WriteMessage(18, fieldNames[39], SingleNestedMessage); + output.WriteMessage(18, SingleNestedMessage); } if (singleForeignMessage_ != null) { - output.WriteMessage(19, fieldNames[33], SingleForeignMessage); + output.WriteMessage(19, SingleForeignMessage); } if (singleImportMessage_ != null) { - output.WriteMessage(20, fieldNames[35], SingleImportMessage); + output.WriteMessage(20, SingleImportMessage); } if (SingleNestedEnum != global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum.NESTED_ENUM_UNSPECIFIED) { - output.WriteEnum(21, fieldNames[38], (int) SingleNestedEnum); + output.WriteEnum(21, (int) SingleNestedEnum); } if (SingleForeignEnum != global::Google.Protobuf.TestProtos.ForeignEnum.FOREIGN_UNSPECIFIED) { - output.WriteEnum(22, fieldNames[32], (int) SingleForeignEnum); + output.WriteEnum(22, (int) SingleForeignEnum); } if (SingleImportEnum != global::Google.Protobuf.TestProtos.ImportEnum.IMPORT_ENUM_UNSPECIFIED) { - output.WriteEnum(23, fieldNames[34], (int) SingleImportEnum); + output.WriteEnum(23, (int) SingleImportEnum); } if (singlePublicImportMessage_ != null) { - output.WriteMessage(26, fieldNames[40], SinglePublicImportMessage); - } - output.WritePackedInt32Array(31, fieldNames[14], repeatedInt32_); - output.WritePackedInt64Array(32, fieldNames[15], repeatedInt64_); - output.WritePackedUInt32Array(33, fieldNames[24], repeatedUint32_); - output.WritePackedUInt64Array(34, fieldNames[25], repeatedUint64_); - output.WritePackedSInt32Array(35, fieldNames[21], repeatedSint32_); - output.WritePackedSInt64Array(36, fieldNames[22], repeatedSint64_); - output.WritePackedFixed32Array(37, fieldNames[7], repeatedFixed32_); - output.WritePackedFixed64Array(38, fieldNames[8], repeatedFixed64_); - output.WritePackedSFixed32Array(39, fieldNames[19], repeatedSfixed32_); - output.WritePackedSFixed64Array(40, fieldNames[20], repeatedSfixed64_); - output.WritePackedFloatArray(41, fieldNames[9], repeatedFloat_); - output.WritePackedDoubleArray(42, fieldNames[6], repeatedDouble_); - output.WritePackedBoolArray(43, fieldNames[4], repeatedBool_); - output.WriteStringArray(44, fieldNames[23], repeatedString_); - output.WriteBytesArray(45, fieldNames[5], repeatedBytes_); - output.WriteMessageArray(48, fieldNames[17], repeatedNestedMessage_); - output.WriteMessageArray(49, fieldNames[11], repeatedForeignMessage_); - output.WriteMessageArray(50, fieldNames[13], repeatedImportMessage_); - output.WritePackedEnumArray(51, fieldNames[16], repeatedNestedEnum_); - output.WritePackedEnumArray(52, fieldNames[10], repeatedForeignEnum_); - output.WritePackedEnumArray(53, fieldNames[12], repeatedImportEnum_); - output.WriteMessageArray(54, fieldNames[18], repeatedPublicImportMessage_); + output.WriteMessage(26, SinglePublicImportMessage); + } + output.WritePackedInt32Array(31, repeatedInt32_); + output.WritePackedInt64Array(32, repeatedInt64_); + output.WritePackedUInt32Array(33, repeatedUint32_); + output.WritePackedUInt64Array(34, repeatedUint64_); + output.WritePackedSInt32Array(35, repeatedSint32_); + output.WritePackedSInt64Array(36, repeatedSint64_); + output.WritePackedFixed32Array(37, repeatedFixed32_); + output.WritePackedFixed64Array(38, repeatedFixed64_); + output.WritePackedSFixed32Array(39, repeatedSfixed32_); + output.WritePackedSFixed64Array(40, repeatedSfixed64_); + output.WritePackedFloatArray(41, repeatedFloat_); + output.WritePackedDoubleArray(42, repeatedDouble_); + output.WritePackedBoolArray(43, repeatedBool_); + output.WriteStringArray(44, repeatedString_); + output.WriteBytesArray(45, repeatedBytes_); + output.WriteMessageArray(48, repeatedNestedMessage_); + output.WriteMessageArray(49, repeatedForeignMessage_); + output.WriteMessageArray(50, repeatedImportMessage_); + output.WritePackedEnumArray(51, repeatedNestedEnum_); + output.WritePackedEnumArray(52, repeatedForeignEnum_); + output.WritePackedEnumArray(53, repeatedImportEnum_); + output.WriteMessageArray(54, repeatedPublicImportMessage_); if (oneofFieldCase_ == OneofFieldOneofCase.OneofUint32) { - output.WriteUInt32(111, fieldNames[3], OneofUint32); + output.WriteUInt32(111, OneofUint32); } if (oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage) { - output.WriteMessage(112, fieldNames[1], OneofNestedMessage); + output.WriteMessage(112, OneofNestedMessage); } if (oneofFieldCase_ == OneofFieldOneofCase.OneofString) { - output.WriteString(113, fieldNames[2], OneofString); + output.WriteString(113, OneofString); } if (oneofFieldCase_ == OneofFieldOneofCase.OneofBytes) { - output.WriteBytes(114, fieldNames[0], OneofBytes); + output.WriteBytes(114, OneofBytes); } } @@ -1372,16 +1371,9 @@ namespace Google.Protobuf.TestProtos { } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -1391,63 +1383,63 @@ namespace Google.Protobuf.TestProtos { } break; case 8: { - input.ReadInt32(ref singleInt32_); + singleInt32_ = input.ReadInt32(); break; } case 16: { - input.ReadInt64(ref singleInt64_); + singleInt64_ = input.ReadInt64(); break; } case 24: { - input.ReadUInt32(ref singleUint32_); + singleUint32_ = input.ReadUInt32(); break; } case 32: { - input.ReadUInt64(ref singleUint64_); + singleUint64_ = input.ReadUInt64(); break; } case 40: { - input.ReadSInt32(ref singleSint32_); + singleSint32_ = input.ReadSInt32(); break; } case 48: { - input.ReadSInt64(ref singleSint64_); + singleSint64_ = input.ReadSInt64(); break; } case 61: { - input.ReadFixed32(ref singleFixed32_); + singleFixed32_ = input.ReadFixed32(); break; } case 65: { - input.ReadFixed64(ref singleFixed64_); + singleFixed64_ = input.ReadFixed64(); break; } case 77: { - input.ReadSFixed32(ref singleSfixed32_); + singleSfixed32_ = input.ReadSFixed32(); break; } case 81: { - input.ReadSFixed64(ref singleSfixed64_); + singleSfixed64_ = input.ReadSFixed64(); break; } case 93: { - input.ReadFloat(ref singleFloat_); + singleFloat_ = input.ReadFloat(); break; } case 97: { - input.ReadDouble(ref singleDouble_); + singleDouble_ = input.ReadDouble(); break; } case 104: { - input.ReadBool(ref singleBool_); + singleBool_ = input.ReadBool(); break; } case 114: { - input.ReadString(ref singleString_); + singleString_ = input.ReadString(); break; } case 122: { - input.ReadBytes(ref singleBytes_); + singleBytes_ = input.ReadBytes(); break; } case 146: { @@ -1472,19 +1464,16 @@ namespace Google.Protobuf.TestProtos { break; } case 168: { - int tmp = 0; - input.ReadEnum(ref tmp); - singleNestedEnum_ = (global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum) tmp;break; + singleNestedEnum_ = (global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum) input.ReadEnum(); + break; } case 176: { - int tmp = 0; - input.ReadEnum(ref tmp); - singleForeignEnum_ = (global::Google.Protobuf.TestProtos.ForeignEnum) tmp;break; + singleForeignEnum_ = (global::Google.Protobuf.TestProtos.ForeignEnum) input.ReadEnum(); + break; } case 184: { - int tmp = 0; - input.ReadEnum(ref tmp); - singleImportEnum_ = (global::Google.Protobuf.TestProtos.ImportEnum) tmp;break; + singleImportEnum_ = (global::Google.Protobuf.TestProtos.ImportEnum) input.ReadEnum(); + break; } case 210: { if (singlePublicImportMessage_ == null) { @@ -1495,114 +1484,111 @@ namespace Google.Protobuf.TestProtos { } case 250: case 248: { - input.ReadInt32Array(tag, fieldName, repeatedInt32_); + input.ReadInt32Array(tag, repeatedInt32_); break; } case 258: case 256: { - input.ReadInt64Array(tag, fieldName, repeatedInt64_); + input.ReadInt64Array(tag, repeatedInt64_); break; } case 266: case 264: { - input.ReadUInt32Array(tag, fieldName, repeatedUint32_); + input.ReadUInt32Array(tag, repeatedUint32_); break; } case 274: case 272: { - input.ReadUInt64Array(tag, fieldName, repeatedUint64_); + input.ReadUInt64Array(tag, repeatedUint64_); break; } case 282: case 280: { - input.ReadSInt32Array(tag, fieldName, repeatedSint32_); + input.ReadSInt32Array(tag, repeatedSint32_); break; } case 290: case 288: { - input.ReadSInt64Array(tag, fieldName, repeatedSint64_); + input.ReadSInt64Array(tag, repeatedSint64_); break; } case 298: case 301: { - input.ReadFixed32Array(tag, fieldName, repeatedFixed32_); + input.ReadFixed32Array(tag, repeatedFixed32_); break; } case 306: case 305: { - input.ReadFixed64Array(tag, fieldName, repeatedFixed64_); + input.ReadFixed64Array(tag, repeatedFixed64_); break; } case 314: case 317: { - input.ReadSFixed32Array(tag, fieldName, repeatedSfixed32_); + input.ReadSFixed32Array(tag, repeatedSfixed32_); break; } case 322: case 321: { - input.ReadSFixed64Array(tag, fieldName, repeatedSfixed64_); + input.ReadSFixed64Array(tag, repeatedSfixed64_); break; } case 330: case 333: { - input.ReadFloatArray(tag, fieldName, repeatedFloat_); + input.ReadFloatArray(tag, repeatedFloat_); break; } case 338: case 337: { - input.ReadDoubleArray(tag, fieldName, repeatedDouble_); + input.ReadDoubleArray(tag, repeatedDouble_); break; } case 346: case 344: { - input.ReadBoolArray(tag, fieldName, repeatedBool_); + input.ReadBoolArray(tag, repeatedBool_); break; } case 354: { - input.ReadStringArray(tag, fieldName, repeatedString_); + input.ReadStringArray(tag, repeatedString_); break; } case 362: { - input.ReadBytesArray(tag, fieldName, repeatedBytes_); + input.ReadBytesArray(tag, repeatedBytes_); break; } case 386: { - input.ReadMessageArray(tag, fieldName, repeatedNestedMessage_, global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage.Parser); + input.ReadMessageArray(tag, repeatedNestedMessage_, global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage.Parser); break; } case 394: { - input.ReadMessageArray(tag, fieldName, repeatedForeignMessage_, global::Google.Protobuf.TestProtos.ForeignMessage.Parser); + input.ReadMessageArray(tag, repeatedForeignMessage_, global::Google.Protobuf.TestProtos.ForeignMessage.Parser); break; } case 402: { - input.ReadMessageArray(tag, fieldName, repeatedImportMessage_, global::Google.Protobuf.TestProtos.ImportMessage.Parser); + input.ReadMessageArray(tag, repeatedImportMessage_, global::Google.Protobuf.TestProtos.ImportMessage.Parser); break; } case 410: case 408: { - input.ReadEnumArray(tag, fieldName, repeatedNestedEnum_); + input.ReadEnumArray(tag, repeatedNestedEnum_); break; } case 418: case 416: { - input.ReadEnumArray(tag, fieldName, repeatedForeignEnum_); + input.ReadEnumArray(tag, repeatedForeignEnum_); break; } case 426: case 424: { - input.ReadEnumArray(tag, fieldName, repeatedImportEnum_); + input.ReadEnumArray(tag, repeatedImportEnum_); break; } case 434: { - input.ReadMessageArray(tag, fieldName, repeatedPublicImportMessage_, global::Google.Protobuf.TestProtos.PublicImportMessage.Parser); + input.ReadMessageArray(tag, repeatedPublicImportMessage_, global::Google.Protobuf.TestProtos.PublicImportMessage.Parser); break; } case 888: { - uint value = 0; - if (input.ReadUInt32(ref value)) { - oneofField_ = value; - oneofFieldCase_ = OneofFieldOneofCase.OneofUint32; - } + oneofField_ = input.ReadUInt32() + ;oneofFieldCase_ = OneofFieldOneofCase.OneofUint32; break; } case 898: { @@ -1615,19 +1601,13 @@ namespace Google.Protobuf.TestProtos { break; } case 906: { - string value = ""; - if (input.ReadString(ref value)) { - oneofField_ = value; - oneofFieldCase_ = OneofFieldOneofCase.OneofString; - } + oneofField_ = input.ReadString() + ;oneofFieldCase_ = OneofFieldOneofCase.OneofString; break; } case 914: { - pb::ByteString value = pb::ByteString.Empty; - if (input.ReadBytes(ref value)) { - oneofField_ = value; - oneofFieldCase_ = OneofFieldOneofCase.OneofBytes; - } + oneofField_ = input.ReadBytes() + ;oneofFieldCase_ = OneofFieldOneofCase.OneofBytes; break; } } @@ -1693,10 +1673,9 @@ namespace Google.Protobuf.TestProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { if (Bb != 0) { - output.WriteInt32(1, fieldNames[0], Bb); + output.WriteInt32(1, Bb); } } @@ -1716,16 +1695,9 @@ namespace Google.Protobuf.TestProtos { } } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -1735,7 +1707,7 @@ namespace Google.Protobuf.TestProtos { } break; case 8: { - input.ReadInt32(ref bb_); + bb_ = input.ReadInt32(); break; } } @@ -1811,15 +1783,14 @@ namespace Google.Protobuf.TestProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { if (child_ != null) { - output.WriteMessage(1, fieldNames[0], Child); + output.WriteMessage(1, Child); } if (payload_ != null) { - output.WriteMessage(2, fieldNames[1], Payload); + output.WriteMessage(2, Payload); } - output.WriteMessageArray(3, fieldNames[2], repeatedChild_); + output.WriteMessageArray(3, repeatedChild_); } public int CalculateSize() { @@ -1854,16 +1825,9 @@ namespace Google.Protobuf.TestProtos { repeatedChild_.Add(other.repeatedChild_); } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -1887,7 +1851,7 @@ namespace Google.Protobuf.TestProtos { break; } case 26: { - input.ReadMessageArray(tag, fieldName, repeatedChild_, global::Google.Protobuf.TestProtos.NestedTestAllTypes.Parser); + input.ReadMessageArray(tag, repeatedChild_, global::Google.Protobuf.TestProtos.NestedTestAllTypes.Parser); break; } } @@ -1945,10 +1909,9 @@ namespace Google.Protobuf.TestProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { if (DeprecatedInt32 != 0) { - output.WriteInt32(1, fieldNames[0], DeprecatedInt32); + output.WriteInt32(1, DeprecatedInt32); } } @@ -1968,16 +1931,9 @@ namespace Google.Protobuf.TestProtos { } } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -1987,7 +1943,7 @@ namespace Google.Protobuf.TestProtos { } break; case 8: { - input.ReadInt32(ref deprecatedInt32_); + deprecatedInt32_ = input.ReadInt32(); break; } } @@ -2044,10 +2000,9 @@ namespace Google.Protobuf.TestProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { if (C != 0) { - output.WriteInt32(1, fieldNames[0], C); + output.WriteInt32(1, C); } } @@ -2067,16 +2022,9 @@ namespace Google.Protobuf.TestProtos { } } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -2086,7 +2034,7 @@ namespace Google.Protobuf.TestProtos { } break; case 8: { - input.ReadInt32(ref c_); + c_ = input.ReadInt32(); break; } } @@ -2133,8 +2081,7 @@ namespace Google.Protobuf.TestProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { } public int CalculateSize() { @@ -2147,16 +2094,9 @@ namespace Google.Protobuf.TestProtos { } } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -2217,10 +2157,9 @@ namespace Google.Protobuf.TestProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { if (foreignNested_ != null) { - output.WriteMessage(1, fieldNames[0], ForeignNested); + output.WriteMessage(1, ForeignNested); } } @@ -2243,16 +2182,9 @@ namespace Google.Protobuf.TestProtos { } } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -2332,13 +2264,12 @@ namespace Google.Protobuf.TestProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { if (A != 0) { - output.WriteInt32(1, fieldNames[0], A); + output.WriteInt32(1, A); } if (Bb != 0) { - output.WriteInt32(268435455, fieldNames[1], Bb); + output.WriteInt32(268435455, Bb); } } @@ -2364,16 +2295,9 @@ namespace Google.Protobuf.TestProtos { } } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -2383,11 +2307,11 @@ namespace Google.Protobuf.TestProtos { } break; case 8: { - input.ReadInt32(ref a_); + a_ = input.ReadInt32(); break; } case 2147483640: { - input.ReadInt32(ref bb_); + bb_ = input.ReadInt32(); break; } } @@ -2452,13 +2376,12 @@ namespace Google.Protobuf.TestProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { if (a_ != null) { - output.WriteMessage(1, fieldNames[0], A); + output.WriteMessage(1, A); } if (I != 0) { - output.WriteInt32(2, fieldNames[1], I); + output.WriteInt32(2, I); } } @@ -2487,16 +2410,9 @@ namespace Google.Protobuf.TestProtos { } } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -2513,7 +2429,7 @@ namespace Google.Protobuf.TestProtos { break; } case 16: { - input.ReadInt32(ref i_); + i_ = input.ReadInt32(); break; } } @@ -2568,10 +2484,9 @@ namespace Google.Protobuf.TestProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { if (bb_ != null) { - output.WriteMessage(1, fieldNames[0], Bb); + output.WriteMessage(1, Bb); } } @@ -2594,16 +2509,9 @@ namespace Google.Protobuf.TestProtos { } } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -2681,13 +2589,12 @@ namespace Google.Protobuf.TestProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { if (a_ != null) { - output.WriteMessage(1, fieldNames[0], A); + output.WriteMessage(1, A); } if (OptionalInt32 != 0) { - output.WriteInt32(2, fieldNames[1], OptionalInt32); + output.WriteInt32(2, OptionalInt32); } } @@ -2716,16 +2623,9 @@ namespace Google.Protobuf.TestProtos { } } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -2742,7 +2642,7 @@ namespace Google.Protobuf.TestProtos { break; } case 16: { - input.ReadInt32(ref optionalInt32_); + optionalInt32_ = input.ReadInt32(); break; } } @@ -2859,24 +2759,23 @@ namespace Google.Protobuf.TestProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { if (PrimitiveField != 0) { - output.WriteInt32(1, fieldNames[2], PrimitiveField); + output.WriteInt32(1, PrimitiveField); } if (StringField != "") { - output.WriteString(2, fieldNames[7], StringField); + output.WriteString(2, StringField); } if (EnumField != global::Google.Protobuf.TestProtos.ForeignEnum.FOREIGN_UNSPECIFIED) { - output.WriteEnum(3, fieldNames[0], (int) EnumField); + output.WriteEnum(3, (int) EnumField); } if (messageField_ != null) { - output.WriteMessage(4, fieldNames[1], MessageField); + output.WriteMessage(4, MessageField); } - output.WritePackedInt32Array(7, fieldNames[5], repeatedPrimitiveField_); - output.WriteStringArray(8, fieldNames[6], repeatedStringField_); - output.WritePackedEnumArray(9, fieldNames[3], repeatedEnumField_); - output.WriteMessageArray(10, fieldNames[4], repeatedMessageField_); + output.WritePackedInt32Array(7, repeatedPrimitiveField_); + output.WriteStringArray(8, repeatedStringField_); + output.WritePackedEnumArray(9, repeatedEnumField_); + output.WriteMessageArray(10, repeatedMessageField_); } public int CalculateSize() { @@ -2952,16 +2851,9 @@ namespace Google.Protobuf.TestProtos { repeatedMessageField_.Add(other.repeatedMessageField_); } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -2971,17 +2863,16 @@ namespace Google.Protobuf.TestProtos { } break; case 8: { - input.ReadInt32(ref primitiveField_); + primitiveField_ = input.ReadInt32(); break; } case 18: { - input.ReadString(ref stringField_); + stringField_ = input.ReadString(); break; } case 24: { - int tmp = 0; - input.ReadEnum(ref tmp); - enumField_ = (global::Google.Protobuf.TestProtos.ForeignEnum) tmp;break; + enumField_ = (global::Google.Protobuf.TestProtos.ForeignEnum) input.ReadEnum(); + break; } case 34: { if (messageField_ == null) { @@ -2992,20 +2883,20 @@ namespace Google.Protobuf.TestProtos { } case 58: case 56: { - input.ReadInt32Array(tag, fieldName, repeatedPrimitiveField_); + input.ReadInt32Array(tag, repeatedPrimitiveField_); break; } case 66: { - input.ReadStringArray(tag, fieldName, repeatedStringField_); + input.ReadStringArray(tag, repeatedStringField_); break; } case 74: case 72: { - input.ReadEnumArray(tag, fieldName, repeatedEnumField_); + input.ReadEnumArray(tag, repeatedEnumField_); break; } case 82: { - input.ReadMessageArray(tag, fieldName, repeatedMessageField_, global::Google.Protobuf.TestProtos.ForeignMessage.Parser); + input.ReadMessageArray(tag, repeatedMessageField_, global::Google.Protobuf.TestProtos.ForeignMessage.Parser); break; } } @@ -3090,19 +2981,18 @@ namespace Google.Protobuf.TestProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { if (MyInt != 0L) { - output.WriteInt64(1, fieldNames[1], MyInt); + output.WriteInt64(1, MyInt); } if (MyString != "") { - output.WriteString(11, fieldNames[2], MyString); + output.WriteString(11, MyString); } if (MyFloat != 0F) { - output.WriteFloat(101, fieldNames[0], MyFloat); + output.WriteFloat(101, MyFloat); } if (singleNestedMessage_ != null) { - output.WriteMessage(200, fieldNames[3], SingleNestedMessage); + output.WriteMessage(200, SingleNestedMessage); } } @@ -3143,16 +3033,9 @@ namespace Google.Protobuf.TestProtos { } } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -3162,15 +3045,15 @@ namespace Google.Protobuf.TestProtos { } break; case 8: { - input.ReadInt64(ref myInt_); + myInt_ = input.ReadInt64(); break; } case 90: { - input.ReadString(ref myString_); + myString_ = input.ReadString(); break; } case 813: { - input.ReadFloat(ref myFloat_); + myFloat_ = input.ReadFloat(); break; } case 1602: { @@ -3245,13 +3128,12 @@ namespace Google.Protobuf.TestProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { if (Bb != 0) { - output.WriteInt32(1, fieldNames[0], Bb); + output.WriteInt32(1, Bb); } if (Oo != 0L) { - output.WriteInt64(2, fieldNames[1], Oo); + output.WriteInt64(2, Oo); } } @@ -3277,16 +3159,9 @@ namespace Google.Protobuf.TestProtos { } } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -3296,11 +3171,11 @@ namespace Google.Protobuf.TestProtos { } break; case 8: { - input.ReadInt32(ref bb_); + bb_ = input.ReadInt32(); break; } case 16: { - input.ReadInt64(ref oo_); + oo_ = input.ReadInt64(); break; } } @@ -3362,10 +3237,9 @@ namespace Google.Protobuf.TestProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { if (SparseEnum != global::Google.Protobuf.TestProtos.TestSparseEnum.TEST_SPARSE_ENUM_UNSPECIFIED) { - output.WriteEnum(1, fieldNames[0], (int) SparseEnum); + output.WriteEnum(1, (int) SparseEnum); } } @@ -3385,16 +3259,9 @@ namespace Google.Protobuf.TestProtos { } } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -3404,9 +3271,8 @@ namespace Google.Protobuf.TestProtos { } break; case 8: { - int tmp = 0; - input.ReadEnum(ref tmp); - sparseEnum_ = (global::Google.Protobuf.TestProtos.TestSparseEnum) tmp;break; + sparseEnum_ = (global::Google.Protobuf.TestProtos.TestSparseEnum) input.ReadEnum(); + break; } } } @@ -3462,10 +3328,9 @@ namespace Google.Protobuf.TestProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { if (Data != "") { - output.WriteString(1, fieldNames[0], Data); + output.WriteString(1, Data); } } @@ -3485,16 +3350,9 @@ namespace Google.Protobuf.TestProtos { } } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -3504,7 +3362,7 @@ namespace Google.Protobuf.TestProtos { } break; case 10: { - input.ReadString(ref data_); + data_ = input.ReadString(); break; } } @@ -3559,9 +3417,8 @@ namespace Google.Protobuf.TestProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; - output.WriteStringArray(1, fieldNames[0], data_); + public void WriteTo(pb::CodedOutputStream output) { + output.WriteStringArray(1, data_); } public int CalculateSize() { @@ -3583,16 +3440,9 @@ namespace Google.Protobuf.TestProtos { data_.Add(other.data_); } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -3602,7 +3452,7 @@ namespace Google.Protobuf.TestProtos { } break; case 10: { - input.ReadStringArray(tag, fieldName, data_); + input.ReadStringArray(tag, data_); break; } } @@ -3659,10 +3509,9 @@ namespace Google.Protobuf.TestProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { if (Data != pb::ByteString.Empty) { - output.WriteBytes(1, fieldNames[0], Data); + output.WriteBytes(1, Data); } } @@ -3682,16 +3531,9 @@ namespace Google.Protobuf.TestProtos { } } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -3701,7 +3543,7 @@ namespace Google.Protobuf.TestProtos { } break; case 10: { - input.ReadBytes(ref data_); + data_ = input.ReadBytes(); break; } } @@ -3758,10 +3600,9 @@ namespace Google.Protobuf.TestProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { if (Data != pb::ByteString.Empty) { - output.WriteBytes(1, fieldNames[0], Data); + output.WriteBytes(1, Data); } } @@ -3781,16 +3622,9 @@ namespace Google.Protobuf.TestProtos { } } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -3800,7 +3634,7 @@ namespace Google.Protobuf.TestProtos { } break; case 10: { - input.ReadBytes(ref data_); + data_ = input.ReadBytes(); break; } } @@ -3857,10 +3691,9 @@ namespace Google.Protobuf.TestProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { if (Data != 0) { - output.WriteInt32(1, fieldNames[0], Data); + output.WriteInt32(1, Data); } } @@ -3880,16 +3713,9 @@ namespace Google.Protobuf.TestProtos { } } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -3899,7 +3725,7 @@ namespace Google.Protobuf.TestProtos { } break; case 8: { - input.ReadInt32(ref data_); + data_ = input.ReadInt32(); break; } } @@ -3956,10 +3782,9 @@ namespace Google.Protobuf.TestProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { if (Data != 0) { - output.WriteUInt32(1, fieldNames[0], Data); + output.WriteUInt32(1, Data); } } @@ -3979,16 +3804,9 @@ namespace Google.Protobuf.TestProtos { } } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -3998,7 +3816,7 @@ namespace Google.Protobuf.TestProtos { } break; case 8: { - input.ReadUInt32(ref data_); + data_ = input.ReadUInt32(); break; } } @@ -4055,10 +3873,9 @@ namespace Google.Protobuf.TestProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { if (Data != 0L) { - output.WriteInt64(1, fieldNames[0], Data); + output.WriteInt64(1, Data); } } @@ -4078,16 +3895,9 @@ namespace Google.Protobuf.TestProtos { } } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -4097,7 +3907,7 @@ namespace Google.Protobuf.TestProtos { } break; case 8: { - input.ReadInt64(ref data_); + data_ = input.ReadInt64(); break; } } @@ -4154,10 +3964,9 @@ namespace Google.Protobuf.TestProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { if (Data != 0UL) { - output.WriteUInt64(1, fieldNames[0], Data); + output.WriteUInt64(1, Data); } } @@ -4177,16 +3986,9 @@ namespace Google.Protobuf.TestProtos { } } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -4196,7 +3998,7 @@ namespace Google.Protobuf.TestProtos { } break; case 8: { - input.ReadUInt64(ref data_); + data_ = input.ReadUInt64(); break; } } @@ -4253,10 +4055,9 @@ namespace Google.Protobuf.TestProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { if (Data != false) { - output.WriteBool(1, fieldNames[0], Data); + output.WriteBool(1, Data); } } @@ -4276,16 +4077,9 @@ namespace Google.Protobuf.TestProtos { } } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -4295,7 +4089,7 @@ namespace Google.Protobuf.TestProtos { } break; case 8: { - input.ReadBool(ref data_); + data_ = input.ReadBool(); break; } } @@ -4391,16 +4185,15 @@ namespace Google.Protobuf.TestProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { if (fooCase_ == FooOneofCase.FooInt) { - output.WriteInt32(1, fieldNames[0], FooInt); + output.WriteInt32(1, FooInt); } if (fooCase_ == FooOneofCase.FooString) { - output.WriteString(2, fieldNames[2], FooString); + output.WriteString(2, FooString); } if (fooCase_ == FooOneofCase.FooMessage) { - output.WriteMessage(3, fieldNames[1], FooMessage); + output.WriteMessage(3, FooMessage); } } @@ -4435,16 +4228,9 @@ namespace Google.Protobuf.TestProtos { } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -4454,19 +4240,13 @@ namespace Google.Protobuf.TestProtos { } break; case 8: { - int value = 0; - if (input.ReadInt32(ref value)) { - foo_ = value; - fooCase_ = FooOneofCase.FooInt; - } + foo_ = input.ReadInt32() + ;fooCase_ = FooOneofCase.FooInt; break; } case 18: { - string value = ""; - if (input.ReadString(ref value)) { - foo_ = value; - fooCase_ = FooOneofCase.FooString; - } + foo_ = input.ReadString() + ;fooCase_ = FooOneofCase.FooString; break; } case 26: { @@ -4634,22 +4414,21 @@ namespace Google.Protobuf.TestProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; - output.WritePackedInt32Array(90, fieldNames[6], packedInt32_); - output.WritePackedInt64Array(91, fieldNames[7], packedInt64_); - output.WritePackedUInt32Array(92, fieldNames[12], packedUint32_); - output.WritePackedUInt64Array(93, fieldNames[13], packedUint64_); - output.WritePackedSInt32Array(94, fieldNames[10], packedSint32_); - output.WritePackedSInt64Array(95, fieldNames[11], packedSint64_); - output.WritePackedFixed32Array(96, fieldNames[3], packedFixed32_); - output.WritePackedFixed64Array(97, fieldNames[4], packedFixed64_); - output.WritePackedSFixed32Array(98, fieldNames[8], packedSfixed32_); - output.WritePackedSFixed64Array(99, fieldNames[9], packedSfixed64_); - output.WritePackedFloatArray(100, fieldNames[5], packedFloat_); - output.WritePackedDoubleArray(101, fieldNames[1], packedDouble_); - output.WritePackedBoolArray(102, fieldNames[0], packedBool_); - output.WritePackedEnumArray(103, fieldNames[2], packedEnum_); + public void WriteTo(pb::CodedOutputStream output) { + output.WritePackedInt32Array(90, packedInt32_); + output.WritePackedInt64Array(91, packedInt64_); + output.WritePackedUInt32Array(92, packedUint32_); + output.WritePackedUInt64Array(93, packedUint64_); + output.WritePackedSInt32Array(94, packedSint32_); + output.WritePackedSInt64Array(95, packedSint64_); + output.WritePackedFixed32Array(96, packedFixed32_); + output.WritePackedFixed64Array(97, packedFixed64_); + output.WritePackedSFixed32Array(98, packedSfixed32_); + output.WritePackedSFixed64Array(99, packedSfixed64_); + output.WritePackedFloatArray(100, packedFloat_); + output.WritePackedDoubleArray(101, packedDouble_); + output.WritePackedBoolArray(102, packedBool_); + output.WritePackedEnumArray(103, packedEnum_); } public int CalculateSize() { @@ -4803,16 +4582,9 @@ namespace Google.Protobuf.TestProtos { packedEnum_.Add(other.packedEnum_); } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -4823,72 +4595,72 @@ namespace Google.Protobuf.TestProtos { break; case 722: case 720: { - input.ReadInt32Array(tag, fieldName, packedInt32_); + input.ReadInt32Array(tag, packedInt32_); break; } case 730: case 728: { - input.ReadInt64Array(tag, fieldName, packedInt64_); + input.ReadInt64Array(tag, packedInt64_); break; } case 738: case 736: { - input.ReadUInt32Array(tag, fieldName, packedUint32_); + input.ReadUInt32Array(tag, packedUint32_); break; } case 746: case 744: { - input.ReadUInt64Array(tag, fieldName, packedUint64_); + input.ReadUInt64Array(tag, packedUint64_); break; } case 754: case 752: { - input.ReadSInt32Array(tag, fieldName, packedSint32_); + input.ReadSInt32Array(tag, packedSint32_); break; } case 762: case 760: { - input.ReadSInt64Array(tag, fieldName, packedSint64_); + input.ReadSInt64Array(tag, packedSint64_); break; } case 770: case 773: { - input.ReadFixed32Array(tag, fieldName, packedFixed32_); + input.ReadFixed32Array(tag, packedFixed32_); break; } case 778: case 777: { - input.ReadFixed64Array(tag, fieldName, packedFixed64_); + input.ReadFixed64Array(tag, packedFixed64_); break; } case 786: case 789: { - input.ReadSFixed32Array(tag, fieldName, packedSfixed32_); + input.ReadSFixed32Array(tag, packedSfixed32_); break; } case 794: case 793: { - input.ReadSFixed64Array(tag, fieldName, packedSfixed64_); + input.ReadSFixed64Array(tag, packedSfixed64_); break; } case 802: case 805: { - input.ReadFloatArray(tag, fieldName, packedFloat_); + input.ReadFloatArray(tag, packedFloat_); break; } case 810: case 809: { - input.ReadDoubleArray(tag, fieldName, packedDouble_); + input.ReadDoubleArray(tag, packedDouble_); break; } case 818: case 816: { - input.ReadBoolArray(tag, fieldName, packedBool_); + input.ReadBoolArray(tag, packedBool_); break; } case 826: case 824: { - input.ReadEnumArray(tag, fieldName, packedEnum_); + input.ReadEnumArray(tag, packedEnum_); break; } } @@ -5047,22 +4819,21 @@ namespace Google.Protobuf.TestProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; - output.WriteInt32Array(90, fieldNames[6], unpackedInt32_); - output.WriteInt64Array(91, fieldNames[7], unpackedInt64_); - output.WriteUInt32Array(92, fieldNames[12], unpackedUint32_); - output.WriteUInt64Array(93, fieldNames[13], unpackedUint64_); - output.WriteSInt32Array(94, fieldNames[10], unpackedSint32_); - output.WriteSInt64Array(95, fieldNames[11], unpackedSint64_); - output.WriteFixed32Array(96, fieldNames[3], unpackedFixed32_); - output.WriteFixed64Array(97, fieldNames[4], unpackedFixed64_); - output.WriteSFixed32Array(98, fieldNames[8], unpackedSfixed32_); - output.WriteSFixed64Array(99, fieldNames[9], unpackedSfixed64_); - output.WriteFloatArray(100, fieldNames[5], unpackedFloat_); - output.WriteDoubleArray(101, fieldNames[1], unpackedDouble_); - output.WriteBoolArray(102, fieldNames[0], unpackedBool_); - output.WriteEnumArray(103, fieldNames[2], unpackedEnum_); + public void WriteTo(pb::CodedOutputStream output) { + output.WriteInt32Array(90, unpackedInt32_); + output.WriteInt64Array(91, unpackedInt64_); + output.WriteUInt32Array(92, unpackedUint32_); + output.WriteUInt64Array(93, unpackedUint64_); + output.WriteSInt32Array(94, unpackedSint32_); + output.WriteSInt64Array(95, unpackedSint64_); + output.WriteFixed32Array(96, unpackedFixed32_); + output.WriteFixed64Array(97, unpackedFixed64_); + output.WriteSFixed32Array(98, unpackedSfixed32_); + output.WriteSFixed64Array(99, unpackedSfixed64_); + output.WriteFloatArray(100, unpackedFloat_); + output.WriteDoubleArray(101, unpackedDouble_); + output.WriteBoolArray(102, unpackedBool_); + output.WriteEnumArray(103, unpackedEnum_); } public int CalculateSize() { @@ -5189,16 +4960,9 @@ namespace Google.Protobuf.TestProtos { unpackedEnum_.Add(other.unpackedEnum_); } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -5209,72 +4973,72 @@ namespace Google.Protobuf.TestProtos { break; case 722: case 720: { - input.ReadInt32Array(tag, fieldName, unpackedInt32_); + input.ReadInt32Array(tag, unpackedInt32_); break; } case 730: case 728: { - input.ReadInt64Array(tag, fieldName, unpackedInt64_); + input.ReadInt64Array(tag, unpackedInt64_); break; } case 738: case 736: { - input.ReadUInt32Array(tag, fieldName, unpackedUint32_); + input.ReadUInt32Array(tag, unpackedUint32_); break; } case 746: case 744: { - input.ReadUInt64Array(tag, fieldName, unpackedUint64_); + input.ReadUInt64Array(tag, unpackedUint64_); break; } case 754: case 752: { - input.ReadSInt32Array(tag, fieldName, unpackedSint32_); + input.ReadSInt32Array(tag, unpackedSint32_); break; } case 762: case 760: { - input.ReadSInt64Array(tag, fieldName, unpackedSint64_); + input.ReadSInt64Array(tag, unpackedSint64_); break; } case 770: case 773: { - input.ReadFixed32Array(tag, fieldName, unpackedFixed32_); + input.ReadFixed32Array(tag, unpackedFixed32_); break; } case 778: case 777: { - input.ReadFixed64Array(tag, fieldName, unpackedFixed64_); + input.ReadFixed64Array(tag, unpackedFixed64_); break; } case 786: case 789: { - input.ReadSFixed32Array(tag, fieldName, unpackedSfixed32_); + input.ReadSFixed32Array(tag, unpackedSfixed32_); break; } case 794: case 793: { - input.ReadSFixed64Array(tag, fieldName, unpackedSfixed64_); + input.ReadSFixed64Array(tag, unpackedSfixed64_); break; } case 802: case 805: { - input.ReadFloatArray(tag, fieldName, unpackedFloat_); + input.ReadFloatArray(tag, unpackedFloat_); break; } case 810: case 809: { - input.ReadDoubleArray(tag, fieldName, unpackedDouble_); + input.ReadDoubleArray(tag, unpackedDouble_); break; } case 818: case 816: { - input.ReadBoolArray(tag, fieldName, unpackedBool_); + input.ReadBoolArray(tag, unpackedBool_); break; } case 826: case 824: { - input.ReadEnumArray(tag, fieldName, unpackedEnum_); + input.ReadEnumArray(tag, unpackedEnum_); break; } } @@ -5369,14 +5133,13 @@ namespace Google.Protobuf.TestProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; - output.WritePackedFixed32Array(12, fieldNames[0], repeatedFixed32_); - output.WritePackedInt32Array(13, fieldNames[3], repeatedInt32_); - output.WritePackedFixed64Array(2046, fieldNames[1], repeatedFixed64_); - output.WritePackedInt64Array(2047, fieldNames[4], repeatedInt64_); - output.WritePackedFloatArray(262142, fieldNames[2], repeatedFloat_); - output.WritePackedUInt64Array(262143, fieldNames[5], repeatedUint64_); + public void WriteTo(pb::CodedOutputStream output) { + output.WritePackedFixed32Array(12, repeatedFixed32_); + output.WritePackedInt32Array(13, repeatedInt32_); + output.WritePackedFixed64Array(2046, repeatedFixed64_); + output.WritePackedInt64Array(2047, repeatedInt64_); + output.WritePackedFloatArray(262142, repeatedFloat_); + output.WritePackedUInt64Array(262143, repeatedUint64_); } public int CalculateSize() { @@ -5449,16 +5212,9 @@ namespace Google.Protobuf.TestProtos { repeatedUint64_.Add(other.repeatedUint64_); } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -5469,32 +5225,32 @@ namespace Google.Protobuf.TestProtos { break; case 98: case 101: { - input.ReadFixed32Array(tag, fieldName, repeatedFixed32_); + input.ReadFixed32Array(tag, repeatedFixed32_); break; } case 106: case 104: { - input.ReadInt32Array(tag, fieldName, repeatedInt32_); + input.ReadInt32Array(tag, repeatedInt32_); break; } case 16370: case 16369: { - input.ReadFixed64Array(tag, fieldName, repeatedFixed64_); + input.ReadFixed64Array(tag, repeatedFixed64_); break; } case 16378: case 16376: { - input.ReadInt64Array(tag, fieldName, repeatedInt64_); + input.ReadInt64Array(tag, repeatedInt64_); break; } case 2097138: case 2097141: { - input.ReadFloatArray(tag, fieldName, repeatedFloat_); + input.ReadFloatArray(tag, repeatedFloat_); break; } case 2097146: case 2097144: { - input.ReadUInt64Array(tag, fieldName, repeatedUint64_); + input.ReadUInt64Array(tag, repeatedUint64_); break; } } @@ -5551,10 +5307,9 @@ namespace Google.Protobuf.TestProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { if (A != "") { - output.WriteString(1, fieldNames[0], A); + output.WriteString(1, A); } } @@ -5574,16 +5329,9 @@ namespace Google.Protobuf.TestProtos { } } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -5593,7 +5341,7 @@ namespace Google.Protobuf.TestProtos { } break; case 10: { - input.ReadString(ref a_); + a_ = input.ReadString(); break; } } @@ -5640,8 +5388,7 @@ namespace Google.Protobuf.TestProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { } public int CalculateSize() { @@ -5654,16 +5401,9 @@ namespace Google.Protobuf.TestProtos { } } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -5716,8 +5456,7 @@ namespace Google.Protobuf.TestProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { } public int CalculateSize() { @@ -5730,16 +5469,9 @@ namespace Google.Protobuf.TestProtos { } } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -5792,8 +5524,7 @@ namespace Google.Protobuf.TestProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { } public int CalculateSize() { @@ -5806,16 +5537,9 @@ namespace Google.Protobuf.TestProtos { } } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -5868,8 +5592,7 @@ namespace Google.Protobuf.TestProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { } public int CalculateSize() { @@ -5882,16 +5605,9 @@ namespace Google.Protobuf.TestProtos { } } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -5944,8 +5660,7 @@ namespace Google.Protobuf.TestProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { } public int CalculateSize() { @@ -5958,16 +5673,9 @@ namespace Google.Protobuf.TestProtos { } } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -6020,8 +5728,7 @@ namespace Google.Protobuf.TestProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { } public int CalculateSize() { @@ -6034,16 +5741,9 @@ namespace Google.Protobuf.TestProtos { } } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); diff --git a/csharp/src/ProtocolBuffers/CodedInputStream.cs b/csharp/src/ProtocolBuffers/CodedInputStream.cs index d5cab6fd..cb47f1c2 100644 --- a/csharp/src/ProtocolBuffers/CodedInputStream.cs +++ b/csharp/src/ProtocolBuffers/CodedInputStream.cs @@ -58,7 +58,7 @@ namespace Google.Protobuf /// TODO(jonskeet): Consider whether recursion and size limits shouldn't be readonly, /// set at construction time. /// - public sealed class CodedInputStream : ICodedInputStream + public sealed class CodedInputStream { private readonly byte[] buffer; private int bufferSize; @@ -173,10 +173,6 @@ namespace Google.Protobuf } } - - void ICodedInputStream.ReadMessageStart() { } - void ICodedInputStream.ReadMessageEnd() { } - #region Validation /// @@ -201,17 +197,16 @@ namespace Google.Protobuf /// /// Attempt to peek at the next field tag. /// - public bool PeekNextTag(out uint fieldTag, out string fieldName) + public bool PeekNextTag(out uint fieldTag) { if (hasNextTag) { - fieldName = null; fieldTag = nextTag; return true; } uint savedLast = lastTag; - hasNextTag = ReadTag(out nextTag, out fieldName); + hasNextTag = ReadTag(out nextTag); lastTag = savedLast; fieldTag = nextTag; return hasNextTag; @@ -222,12 +217,9 @@ namespace Google.Protobuf /// of the input data. /// /// The 'tag' of the field (id * 8 + wire-format) - /// Not Supported - For protobuffer streams, this parameter is always null /// true if the next fieldTag was read - public bool ReadTag(out uint fieldTag, out string fieldName) + public bool ReadTag(out uint fieldTag) { - fieldName = null; - if (hasNextTag) { fieldTag = nextTag; @@ -256,21 +248,21 @@ namespace Google.Protobuf /// /// Read a double field from the stream. /// - public bool ReadDouble(ref double value) + public double ReadDouble() { - value = FrameworkPortability.Int64ToDouble((long) ReadRawLittleEndian64()); - return true; + return FrameworkPortability.Int64ToDouble((long) ReadRawLittleEndian64()); } /// /// Read a float field from the stream. /// - public bool ReadFloat(ref float value) + public float ReadFloat() { if (BitConverter.IsLittleEndian && 4 <= bufferSize - bufferPos) { - value = BitConverter.ToSingle(buffer, bufferPos); + float ret = BitConverter.ToSingle(buffer, bufferPos); bufferPos += 4; + return ret; } else { @@ -279,76 +271,68 @@ namespace Google.Protobuf { ByteArray.Reverse(rawBytes); } - value = BitConverter.ToSingle(rawBytes, 0); + return BitConverter.ToSingle(rawBytes, 0); } - return true; } /// /// Read a uint64 field from the stream. /// - public bool ReadUInt64(ref ulong value) + public ulong ReadUInt64() { - value = ReadRawVarint64(); - return true; + return ReadRawVarint64(); } /// /// Read an int64 field from the stream. /// - public bool ReadInt64(ref long value) + public long ReadInt64() { - value = (long) ReadRawVarint64(); - return true; + return (long) ReadRawVarint64(); } /// /// Read an int32 field from the stream. /// - public bool ReadInt32(ref int value) + public int ReadInt32() { - value = (int) ReadRawVarint32(); - return true; + return (int) ReadRawVarint32(); } /// /// Read a fixed64 field from the stream. /// - public bool ReadFixed64(ref ulong value) + public ulong ReadFixed64() { - value = ReadRawLittleEndian64(); - return true; + return ReadRawLittleEndian64(); } /// /// Read a fixed32 field from the stream. /// - public bool ReadFixed32(ref uint value) + public uint ReadFixed32() { - value = ReadRawLittleEndian32(); - return true; + return ReadRawLittleEndian32(); } /// /// Read a bool field from the stream. /// - public bool ReadBool(ref bool value) + public bool ReadBool() { - value = ReadRawVarint32() != 0; - return true; + return ReadRawVarint32() != 0; } /// /// Reads a string field from the stream. /// - public bool ReadString(ref string value) + public string ReadString() { int size = (int) ReadRawVarint32(); // No need to read any data for an empty string. if (size == 0) { - value = ""; - return true; + return ""; } if (size <= bufferSize - bufferPos) { @@ -356,12 +340,10 @@ namespace Google.Protobuf // just copy directly from it. String result = Encoding.UTF8.GetString(buffer, bufferPos, size); bufferPos += size; - value = result; - return true; + return result; } // Slow path: Build a byte array first then copy it. - value = Encoding.UTF8.GetString(ReadRawBytes(size), 0, size); - return true; + return Encoding.UTF8.GetString(ReadRawBytes(size), 0, size); } /// @@ -400,7 +382,7 @@ namespace Google.Protobuf /// /// Reads a bytes field value from the stream. /// - public bool ReadBytes(ref ByteString value) + public ByteString ReadBytes() { int size = (int) ReadRawVarint32(); if (size <= bufferSize - bufferPos && size > 0) @@ -409,24 +391,21 @@ namespace Google.Protobuf // just copy directly from it. ByteString result = ByteString.CopyFrom(buffer, bufferPos, size); bufferPos += size; - value = result; - return true; + return result; } else { // Slow path: Build a byte array and attach it to a new ByteString. - value = ByteString.AttachBytes(ReadRawBytes(size)); - return true; + return ByteString.AttachBytes(ReadRawBytes(size)); } } /// /// Reads a uint32 field value from the stream. /// - public bool ReadUInt32(ref uint value) + public uint ReadUInt32() { - value = ReadRawVarint32(); - return true; + return ReadRawVarint32(); } /// @@ -434,47 +413,42 @@ namespace Google.Protobuf /// then the ref value is set and it returns true. Otherwise the unknown output /// value is set and this method returns false. /// - public bool ReadEnum(ref int value) + public int ReadEnum() { // Currently just a pass-through, but it's nice to separate it logically from WriteInt32. - value = (int) ReadRawVarint32(); - return true; + return (int) ReadRawVarint32(); } /// /// Reads an sfixed32 field value from the stream. /// - public bool ReadSFixed32(ref int value) + public int ReadSFixed32() { - value = (int) ReadRawLittleEndian32(); - return true; + return (int) ReadRawLittleEndian32(); } /// /// Reads an sfixed64 field value from the stream. /// - public bool ReadSFixed64(ref long value) + public long ReadSFixed64() { - value = (long) ReadRawLittleEndian64(); - return true; + return (long) ReadRawLittleEndian64(); } /// /// Reads an sint32 field value from the stream. /// - public bool ReadSInt32(ref int value) + public int ReadSInt32() { - value = DecodeZigZag32(ReadRawVarint32()); - return true; + return DecodeZigZag32(ReadRawVarint32()); } /// /// Reads an sint64 field value from the stream. /// - public bool ReadSInt64(ref long value) + public long ReadSInt64() { - value = DecodeZigZag64(ReadRawVarint64()); - return true; + return DecodeZigZag64(ReadRawVarint64()); } private bool BeginArray(uint fieldTag, out bool isPacked, out int oldLimit) @@ -502,9 +476,8 @@ namespace Google.Protobuf /// private bool ContinueArray(uint currentTag) { - string ignore; uint next; - if (PeekNextTag(out next, out ignore)) + if (PeekNextTag(out next)) { if (next == currentTag) { @@ -530,9 +503,8 @@ namespace Google.Protobuf return true; } - string ignore; uint next; - if (PeekNextTag(out next, out ignore)) + if (PeekNextTag(out next)) { if (next == currentTag) { @@ -543,259 +515,194 @@ namespace Google.Protobuf return false; } - public void ReadPrimitiveArray(FieldType fieldType, uint fieldTag, string fieldName, ICollection list) - { - WireFormat.WireType normal = WireFormat.GetWireType(fieldType); - WireFormat.WireType wformat = WireFormat.GetTagWireType(fieldTag); - - // 2.3 allows packed form even if the field is not declared packed. - if (normal != wformat && wformat == WireFormat.WireType.LengthDelimited) - { - int length = (int) (ReadRawVarint32() & int.MaxValue); - int limit = PushLimit(length); - while (!ReachedLimit) - { - Object value = null; - if (ReadPrimitiveField(fieldType, ref value)) - { - list.Add(value); - } - } - PopLimit(limit); - } - else - { - Object value = null; - do - { - if (ReadPrimitiveField(fieldType, ref value)) - { - list.Add(value); - } - } while (ContinueArray(fieldTag)); - } - } - - public void ReadStringArray(uint fieldTag, string fieldName, ICollection list) + public void ReadStringArray(uint fieldTag, ICollection list) { - string tmp = null; do { - ReadString(ref tmp); - list.Add(tmp); + list.Add(ReadString()); } while (ContinueArray(fieldTag)); } - public void ReadBytesArray(uint fieldTag, string fieldName, ICollection list) + public void ReadBytesArray(uint fieldTag, ICollection list) { - ByteString tmp = null; do { - ReadBytes(ref tmp); - list.Add(tmp); + list.Add(ReadBytes()); } while (ContinueArray(fieldTag)); } - public void ReadBoolArray(uint fieldTag, string fieldName, ICollection list) + public void ReadBoolArray(uint fieldTag, ICollection list) { bool isPacked; int holdLimit; if (BeginArray(fieldTag, out isPacked, out holdLimit)) { - bool tmp = false; do { - ReadBool(ref tmp); - list.Add(tmp); + list.Add(ReadBool()); } while (ContinueArray(fieldTag, isPacked, holdLimit)); } } - public void ReadInt32Array(uint fieldTag, string fieldName, ICollection list) + public void ReadInt32Array(uint fieldTag, ICollection list) { - // TODO(jonskeet): Work out how this works for non-packed values. (It doesn't look like it does...) bool isPacked; int holdLimit; if (BeginArray(fieldTag, out isPacked, out holdLimit)) { - int tmp = 0; do { - ReadInt32(ref tmp); - list.Add(tmp); + list.Add(ReadInt32()); } while (ContinueArray(fieldTag, isPacked, holdLimit)); } } - public void ReadSInt32Array(uint fieldTag, string fieldName, ICollection list) + public void ReadSInt32Array(uint fieldTag, ICollection list) { bool isPacked; int holdLimit; if (BeginArray(fieldTag, out isPacked, out holdLimit)) { - int tmp = 0; do { - ReadSInt32(ref tmp); - list.Add(tmp); + list.Add(ReadSInt32()); } while (ContinueArray(fieldTag, isPacked, holdLimit)); } } - public void ReadUInt32Array(uint fieldTag, string fieldName, ICollection list) + public void ReadUInt32Array(uint fieldTag, ICollection list) { bool isPacked; int holdLimit; if (BeginArray(fieldTag, out isPacked, out holdLimit)) { - uint tmp = 0; do { - ReadUInt32(ref tmp); - list.Add(tmp); + list.Add(ReadUInt32()); } while (ContinueArray(fieldTag, isPacked, holdLimit)); } } - public void ReadFixed32Array(uint fieldTag, string fieldName, ICollection list) + public void ReadFixed32Array(uint fieldTag, ICollection list) { bool isPacked; int holdLimit; if (BeginArray(fieldTag, out isPacked, out holdLimit)) { - uint tmp = 0; do { - ReadFixed32(ref tmp); - list.Add(tmp); + list.Add(ReadFixed32()); } while (ContinueArray(fieldTag, isPacked, holdLimit)); } } - public void ReadSFixed32Array(uint fieldTag, string fieldName, ICollection list) + public void ReadSFixed32Array(uint fieldTag, ICollection list) { bool isPacked; int holdLimit; if (BeginArray(fieldTag, out isPacked, out holdLimit)) { - int tmp = 0; do { - ReadSFixed32(ref tmp); - list.Add(tmp); + list.Add(ReadSFixed32()); } while (ContinueArray(fieldTag, isPacked, holdLimit)); } } - public void ReadInt64Array(uint fieldTag, string fieldName, ICollection list) + public void ReadInt64Array(uint fieldTag, ICollection list) { bool isPacked; int holdLimit; if (BeginArray(fieldTag, out isPacked, out holdLimit)) { - long tmp = 0; do { - ReadInt64(ref tmp); - list.Add(tmp); + list.Add(ReadInt64()); } while (ContinueArray(fieldTag, isPacked, holdLimit)); } } - public void ReadSInt64Array(uint fieldTag, string fieldName, ICollection list) + public void ReadSInt64Array(uint fieldTag, ICollection list) { bool isPacked; int holdLimit; if (BeginArray(fieldTag, out isPacked, out holdLimit)) { - long tmp = 0; do { - ReadSInt64(ref tmp); - list.Add(tmp); + list.Add(ReadSInt64()); } while (ContinueArray(fieldTag, isPacked, holdLimit)); } } - public void ReadUInt64Array(uint fieldTag, string fieldName, ICollection list) + public void ReadUInt64Array(uint fieldTag, ICollection list) { bool isPacked; int holdLimit; if (BeginArray(fieldTag, out isPacked, out holdLimit)) { - ulong tmp = 0; do { - ReadUInt64(ref tmp); - list.Add(tmp); + list.Add(ReadUInt64()); } while (ContinueArray(fieldTag, isPacked, holdLimit)); } } - public void ReadFixed64Array(uint fieldTag, string fieldName, ICollection list) + public void ReadFixed64Array(uint fieldTag, ICollection list) { bool isPacked; int holdLimit; if (BeginArray(fieldTag, out isPacked, out holdLimit)) { - ulong tmp = 0; do { - ReadFixed64(ref tmp); - list.Add(tmp); + list.Add(ReadFixed64()); } while (ContinueArray(fieldTag, isPacked, holdLimit)); } } - public void ReadSFixed64Array(uint fieldTag, string fieldName, ICollection list) + public void ReadSFixed64Array(uint fieldTag, ICollection list) { bool isPacked; int holdLimit; if (BeginArray(fieldTag, out isPacked, out holdLimit)) { - long tmp = 0; do { - ReadSFixed64(ref tmp); - list.Add(tmp); + list.Add(ReadSFixed64()); } while (ContinueArray(fieldTag, isPacked, holdLimit)); } } - public void ReadDoubleArray(uint fieldTag, string fieldName, ICollection list) + public void ReadDoubleArray(uint fieldTag, ICollection list) { bool isPacked; int holdLimit; if (BeginArray(fieldTag, out isPacked, out holdLimit)) { - double tmp = 0; do { - ReadDouble(ref tmp); - list.Add(tmp); + list.Add(ReadDouble()); } while (ContinueArray(fieldTag, isPacked, holdLimit)); } } - public void ReadFloatArray(uint fieldTag, string fieldName, ICollection list) + public void ReadFloatArray(uint fieldTag, ICollection list) { bool isPacked; int holdLimit; if (BeginArray(fieldTag, out isPacked, out holdLimit)) { - float tmp = 0; do { - ReadFloat(ref tmp); - list.Add(tmp); + list.Add(ReadFloat()); } while (ContinueArray(fieldTag, isPacked, holdLimit)); } } - public void ReadEnumArray(uint fieldTag, string fieldName, ICollection list) + public void ReadEnumArray(uint fieldTag, ICollection list) where T : struct, IComparable, IFormattable { - int value = 0; WireFormat.WireType wformat = WireFormat.GetTagWireType(fieldTag); // 2.3 allows packed form even if the field is not declared packed. @@ -805,9 +712,8 @@ namespace Google.Protobuf int limit = PushLimit(length); while (!ReachedLimit) { - ReadEnum(ref value); // TODO(jonskeet): Avoid this horrible boxing! - list.Add((T)(object)value); + list.Add((T)(object) ReadEnum()); } PopLimit(limit); } @@ -815,14 +721,12 @@ namespace Google.Protobuf { do { - ReadEnum(ref value); - // TODO(jonskeet): Avoid this horrible boxing! - list.Add((T)(object) value); + list.Add((T)(object) ReadEnum()); } while (ContinueArray(fieldTag)); } } - public void ReadMessageArray(uint fieldTag, string fieldName, ICollection list, MessageParser messageParser) + public void ReadMessageArray(uint fieldTag, ICollection list, MessageParser messageParser) where T : IMessage { do @@ -833,7 +737,7 @@ namespace Google.Protobuf } while (ContinueArray(fieldTag)); } - public void ReadGroupArray(uint fieldTag, string fieldName, ICollection list, MessageParser messageParser) + public void ReadGroupArray(uint fieldTag, ICollection list, MessageParser messageParser) where T : IMessage { do @@ -843,178 +747,6 @@ namespace Google.Protobuf list.Add(message); } while (ContinueArray(fieldTag)); } - - /// - /// Reads a field of any primitive type. Enums, groups and embedded - /// messages are not handled by this method. - /// - public bool ReadPrimitiveField(FieldType fieldType, ref object value) - { - switch (fieldType) - { - case FieldType.Double: - { - double tmp = 0; - if (ReadDouble(ref tmp)) - { - value = tmp; - return true; - } - return false; - } - case FieldType.Float: - { - float tmp = 0; - if (ReadFloat(ref tmp)) - { - value = tmp; - return true; - } - return false; - } - case FieldType.Int64: - { - long tmp = 0; - if (ReadInt64(ref tmp)) - { - value = tmp; - return true; - } - return false; - } - case FieldType.UInt64: - { - ulong tmp = 0; - if (ReadUInt64(ref tmp)) - { - value = tmp; - return true; - } - return false; - } - case FieldType.Int32: - { - int tmp = 0; - if (ReadInt32(ref tmp)) - { - value = tmp; - return true; - } - return false; - } - case FieldType.Fixed64: - { - ulong tmp = 0; - if (ReadFixed64(ref tmp)) - { - value = tmp; - return true; - } - return false; - } - case FieldType.Fixed32: - { - uint tmp = 0; - if (ReadFixed32(ref tmp)) - { - value = tmp; - return true; - } - return false; - } - case FieldType.Bool: - { - bool tmp = false; - if (ReadBool(ref tmp)) - { - value = tmp; - return true; - } - return false; - } - case FieldType.String: - { - string tmp = null; - if (ReadString(ref tmp)) - { - value = tmp; - return true; - } - return false; - } - case FieldType.Bytes: - { - ByteString tmp = null; - if (ReadBytes(ref tmp)) - { - value = tmp; - return true; - } - return false; - } - case FieldType.UInt32: - { - uint tmp = 0; - if (ReadUInt32(ref tmp)) - { - value = tmp; - return true; - } - return false; - } - case FieldType.SFixed32: - { - int tmp = 0; - if (ReadSFixed32(ref tmp)) - { - value = tmp; - return true; - } - return false; - } - case FieldType.SFixed64: - { - long tmp = 0; - if (ReadSFixed64(ref tmp)) - { - value = tmp; - return true; - } - return false; - } - case FieldType.SInt32: - { - int tmp = 0; - if (ReadSInt32(ref tmp)) - { - value = tmp; - return true; - } - return false; - } - case FieldType.SInt64: - { - long tmp = 0; - if (ReadSInt64(ref tmp)) - { - value = tmp; - return true; - } - return false; - } - case FieldType.Group: - throw new ArgumentException("ReadPrimitiveField() cannot handle nested groups."); - case FieldType.Message: - throw new ArgumentException("ReadPrimitiveField() cannot handle embedded messages."); - // We don't handle enums because we don't know what to do if the - // value is not recognized. - case FieldType.Enum: - throw new ArgumentException("ReadPrimitiveField() cannot handle enums."); - default: - throw new ArgumentOutOfRangeException("Invalid field type " + fieldType); - } - } - #endregion #region Underlying reading primitives @@ -1622,8 +1354,7 @@ namespace Google.Protobuf public void SkipMessage() { uint tag; - string name; - while (ReadTag(out tag, out name)) + while (ReadTag(out tag)) { if (!SkipField()) { diff --git a/csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs b/csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs index 96be9db5..b7629d7c 100644 --- a/csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs +++ b/csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs @@ -413,41 +413,12 @@ namespace Google.Protobuf return ComputeRawVarint64Size(EncodeZigZag64(value)); } - /* - * Compute the number of bytes that would be needed to encode a - * MessageSet extension to the stream. For historical reasons, - * the wire format differs from normal fields. - */ - - /// - /// Compute the number of bytes that would be needed to encode a - /// MessageSet extension to the stream. For historical reasons, - /// the wire format differs from normal fields. - /// - public static int ComputeMessageSetExtensionSize(int fieldNumber, IMessage value) - { - return ComputeTagSize(WireFormat.MessageSetField.Item)*2 + - ComputeUInt32Size(WireFormat.MessageSetField.TypeID, (uint) fieldNumber) + - ComputeMessageSize(WireFormat.MessageSetField.Message, value); - } - - /// - /// Compute the number of bytes that would be needed to encode an - /// unparsed MessageSet extension field to the stream. For - /// historical reasons, the wire format differs from normal fields. - /// - public static int ComputeRawMessageSetExtensionSize(int fieldNumber, ByteString value) - { - return ComputeTagSize(WireFormat.MessageSetField.Item)*2 + - ComputeUInt32Size(WireFormat.MessageSetField.TypeID, (uint) fieldNumber) + - ComputeBytesSize(WireFormat.MessageSetField.Message, value); - } - /// /// Compute the number of bytes that would be needed to encode a varint. /// public static int ComputeRawVarint32Size(uint value) { + // TODO(jonskeet): Look at optimizing this to just hard-coded comparisons. if ((value & (0xffffffff << 7)) == 0) { return 1; @@ -472,6 +443,7 @@ namespace Google.Protobuf /// public static int ComputeRawVarint64Size(ulong value) { + // TODO(jonskeet): Look at optimizing this to just hard-coded comparisons. if ((value & (0xffffffffffffffffL << 7)) == 0) { return 1; @@ -511,106 +483,6 @@ namespace Google.Protobuf return 10; } - /// - /// Compute the number of bytes that would be needed to encode a - /// field of arbitrary type, including the tag, to the stream. - /// - // TODO(jonskeet): Why do we need this? - public static int ComputeFieldSize(FieldType fieldType, int fieldNumber, Object value) - { - switch (fieldType) - { - case FieldType.Double: - return ComputeDoubleSize(fieldNumber, (double) value); - case FieldType.Float: - return ComputeFloatSize(fieldNumber, (float) value); - case FieldType.Int64: - return ComputeInt64Size(fieldNumber, (long) value); - case FieldType.UInt64: - return ComputeUInt64Size(fieldNumber, (ulong) value); - case FieldType.Int32: - return ComputeInt32Size(fieldNumber, (int) value); - case FieldType.Fixed64: - return ComputeFixed64Size(fieldNumber, (ulong) value); - case FieldType.Fixed32: - return ComputeFixed32Size(fieldNumber, (uint) value); - case FieldType.Bool: - return ComputeBoolSize(fieldNumber, (bool) value); - case FieldType.String: - return ComputeStringSize(fieldNumber, (string) value); - case FieldType.Group: - return ComputeGroupSize(fieldNumber, (IMessage) value); - case FieldType.Message: - return ComputeMessageSize(fieldNumber, (IMessage) value); - case FieldType.Bytes: - return ComputeBytesSize(fieldNumber, (ByteString) value); - case FieldType.UInt32: - return ComputeUInt32Size(fieldNumber, (uint) value); - case FieldType.SFixed32: - return ComputeSFixed32Size(fieldNumber, (int) value); - case FieldType.SFixed64: - return ComputeSFixed64Size(fieldNumber, (long) value); - case FieldType.SInt32: - return ComputeSInt32Size(fieldNumber, (int) value); - case FieldType.SInt64: - return ComputeSInt64Size(fieldNumber, (long) value); - case FieldType.Enum: - return ComputeEnumSize(fieldNumber, (int) value); - default: - throw new ArgumentOutOfRangeException("Invalid field type " + fieldType); - } - } - - /// - /// Compute the number of bytes that would be needed to encode a - /// field of arbitrary type, excluding the tag, to the stream. - /// - // TODO(jonskeet): Why do we need this? - public static int ComputeFieldSizeNoTag(FieldType fieldType, Object value) - { - switch (fieldType) - { - case FieldType.Double: - return ComputeDoubleSizeNoTag((double) value); - case FieldType.Float: - return ComputeFloatSizeNoTag((float) value); - case FieldType.Int64: - return ComputeInt64SizeNoTag((long) value); - case FieldType.UInt64: - return ComputeUInt64SizeNoTag((ulong) value); - case FieldType.Int32: - return ComputeInt32SizeNoTag((int) value); - case FieldType.Fixed64: - return ComputeFixed64SizeNoTag((ulong) value); - case FieldType.Fixed32: - return ComputeFixed32SizeNoTag((uint) value); - case FieldType.Bool: - return ComputeBoolSizeNoTag((bool) value); - case FieldType.String: - return ComputeStringSizeNoTag((string) value); - case FieldType.Group: - return ComputeGroupSizeNoTag((IMessage) value); - case FieldType.Message: - return ComputeMessageSizeNoTag((IMessage) value); - case FieldType.Bytes: - return ComputeBytesSizeNoTag((ByteString) value); - case FieldType.UInt32: - return ComputeUInt32SizeNoTag((uint) value); - case FieldType.SFixed32: - return ComputeSFixed32SizeNoTag((int) value); - case FieldType.SFixed64: - return ComputeSFixed64SizeNoTag((long) value); - case FieldType.SInt32: - return ComputeSInt32SizeNoTag((int) value); - case FieldType.SInt64: - return ComputeSInt64SizeNoTag((long) value); - case FieldType.Enum: - return ComputeEnumSizeNoTag((int) value); - default: - throw new ArgumentOutOfRangeException("Invalid field type " + fieldType); - } - } - /// /// Compute the number of bytes that would be needed to encode a tag. /// diff --git a/csharp/src/ProtocolBuffers/CodedOutputStream.cs b/csharp/src/ProtocolBuffers/CodedOutputStream.cs index e3f0c700..132f8067 100644 --- a/csharp/src/ProtocolBuffers/CodedOutputStream.cs +++ b/csharp/src/ProtocolBuffers/CodedOutputStream.cs @@ -57,7 +57,7 @@ namespace Google.Protobuf /// methods are taken from the protocol buffer type names, not .NET types. /// (Hence WriteFloat instead of WriteSingle, and WriteBool instead of WriteBoolean.) /// - public sealed partial class CodedOutputStream : ICodedOutputStream + public sealed partial class CodedOutputStream { private static readonly Encoding UTF8 = Encoding.UTF8; @@ -143,76 +143,11 @@ namespace Google.Protobuf } } - void ICodedOutputStream.WriteMessageStart() { } - void ICodedOutputStream.WriteMessageEnd() { Flush(); } - #region Writing of tags and fields - - // TODO(jonskeet): Do we need this? - public void WriteField(FieldType fieldType, int fieldNumber, string fieldName, object value) - { - switch (fieldType) - { - case FieldType.String: - WriteString(fieldNumber, fieldName, (string) value); - break; - case FieldType.Message: - WriteMessage(fieldNumber, fieldName, (IMessage) value); - break; - case FieldType.Group: - WriteGroup(fieldNumber, fieldName, (IMessage) value); - break; - case FieldType.Bytes: - WriteBytes(fieldNumber, fieldName, (ByteString) value); - break; - case FieldType.Bool: - WriteBool(fieldNumber, fieldName, (bool) value); - break; - case FieldType.Enum: - throw new NotImplementedException(); - case FieldType.Int32: - WriteInt32(fieldNumber, fieldName, (int) value); - break; - case FieldType.Int64: - WriteInt64(fieldNumber, fieldName, (long) value); - break; - case FieldType.UInt32: - WriteUInt32(fieldNumber, fieldName, (uint) value); - break; - case FieldType.UInt64: - WriteUInt64(fieldNumber, fieldName, (ulong) value); - break; - case FieldType.SInt32: - WriteSInt32(fieldNumber, fieldName, (int) value); - break; - case FieldType.SInt64: - WriteSInt64(fieldNumber, fieldName, (long) value); - break; - case FieldType.Fixed32: - WriteFixed32(fieldNumber, fieldName, (uint) value); - break; - case FieldType.Fixed64: - WriteFixed64(fieldNumber, fieldName, (ulong) value); - break; - case FieldType.SFixed32: - WriteSFixed32(fieldNumber, fieldName, (int) value); - break; - case FieldType.SFixed64: - WriteSFixed64(fieldNumber, fieldName, (long) value); - break; - case FieldType.Double: - WriteDouble(fieldNumber, fieldName, (double) value); - break; - case FieldType.Float: - WriteFloat(fieldNumber, fieldName, (float) value); - break; - } - } - /// /// Writes a double field value, including tag, to the stream. /// - public void WriteDouble(int fieldNumber, string fieldName, double value) + public void WriteDouble(int fieldNumber, double value) { WriteTag(fieldNumber, WireFormat.WireType.Fixed64); WriteDoubleNoTag(value); @@ -221,7 +156,7 @@ namespace Google.Protobuf /// /// Writes a float field value, including tag, to the stream. /// - public void WriteFloat(int fieldNumber, string fieldName, float value) + public void WriteFloat(int fieldNumber, float value) { WriteTag(fieldNumber, WireFormat.WireType.Fixed32); WriteFloatNoTag(value); @@ -230,7 +165,7 @@ namespace Google.Protobuf /// /// Writes a uint64 field value, including tag, to the stream. /// - public void WriteUInt64(int fieldNumber, string fieldName, ulong value) + public void WriteUInt64(int fieldNumber, ulong value) { WriteTag(fieldNumber, WireFormat.WireType.Varint); WriteRawVarint64(value); @@ -239,7 +174,7 @@ namespace Google.Protobuf /// /// Writes an int64 field value, including tag, to the stream. /// - public void WriteInt64(int fieldNumber, string fieldName, long value) + public void WriteInt64(int fieldNumber, long value) { WriteTag(fieldNumber, WireFormat.WireType.Varint); WriteRawVarint64((ulong) value); @@ -248,7 +183,7 @@ namespace Google.Protobuf /// /// Writes an int32 field value, including tag, to the stream. /// - public void WriteInt32(int fieldNumber, string fieldName, int value) + public void WriteInt32(int fieldNumber, int value) { WriteTag(fieldNumber, WireFormat.WireType.Varint); if (value >= 0) @@ -265,7 +200,7 @@ namespace Google.Protobuf /// /// Writes a fixed64 field value, including tag, to the stream. /// - public void WriteFixed64(int fieldNumber, string fieldName, ulong value) + public void WriteFixed64(int fieldNumber, ulong value) { WriteTag(fieldNumber, WireFormat.WireType.Fixed64); WriteRawLittleEndian64(value); @@ -274,7 +209,7 @@ namespace Google.Protobuf /// /// Writes a fixed32 field value, including tag, to the stream. /// - public void WriteFixed32(int fieldNumber, string fieldName, uint value) + public void WriteFixed32(int fieldNumber, uint value) { WriteTag(fieldNumber, WireFormat.WireType.Fixed32); WriteRawLittleEndian32(value); @@ -283,7 +218,7 @@ namespace Google.Protobuf /// /// Writes a bool field value, including tag, to the stream. /// - public void WriteBool(int fieldNumber, string fieldName, bool value) + public void WriteBool(int fieldNumber, bool value) { WriteTag(fieldNumber, WireFormat.WireType.Varint); WriteRawByte(value ? (byte) 1 : (byte) 0); @@ -292,7 +227,7 @@ namespace Google.Protobuf /// /// Writes a string field value, including tag, to the stream. /// - public void WriteString(int fieldNumber, string fieldName, string value) + public void WriteString(int fieldNumber, string value) { WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited); // Optimise the case where we have enough space to write @@ -324,80 +259,63 @@ namespace Google.Protobuf /// /// Writes a group field value, including tag, to the stream. /// - public void WriteGroup(int fieldNumber, string fieldName, IMessage value) + public void WriteGroup(int fieldNumber, IMessage value) { WriteTag(fieldNumber, WireFormat.WireType.StartGroup); value.WriteTo(this); WriteTag(fieldNumber, WireFormat.WireType.EndGroup); } - public void WriteMessage(int fieldNumber, string fieldName, IMessage value) + public void WriteMessage(int fieldNumber, IMessage value) { WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited); WriteRawVarint32((uint) value.CalculateSize()); value.WriteTo(this); } - public void WriteBytes(int fieldNumber, string fieldName, ByteString value) + public void WriteBytes(int fieldNumber, ByteString value) { WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited); WriteRawVarint32((uint) value.Length); value.WriteRawBytesTo(this); } - public void WriteUInt32(int fieldNumber, string fieldName, uint value) + public void WriteUInt32(int fieldNumber, uint value) { WriteTag(fieldNumber, WireFormat.WireType.Varint); WriteRawVarint32(value); } - public void WriteEnum(int fieldNumber, string fieldName, int value) + public void WriteEnum(int fieldNumber, int value) { // Currently just a pass-through, but it's nice to separate it logically from WriteInt32. WriteTag(fieldNumber, WireFormat.WireType.Varint); WriteInt32NoTag(value); } - public void WriteSFixed32(int fieldNumber, string fieldName, int value) + public void WriteSFixed32(int fieldNumber, int value) { WriteTag(fieldNumber, WireFormat.WireType.Fixed32); WriteRawLittleEndian32((uint) value); } - public void WriteSFixed64(int fieldNumber, string fieldName, long value) + public void WriteSFixed64(int fieldNumber, long value) { WriteTag(fieldNumber, WireFormat.WireType.Fixed64); WriteRawLittleEndian64((ulong) value); } - public void WriteSInt32(int fieldNumber, string fieldName, int value) + public void WriteSInt32(int fieldNumber, int value) { WriteTag(fieldNumber, WireFormat.WireType.Varint); WriteRawVarint32(EncodeZigZag32(value)); } - public void WriteSInt64(int fieldNumber, string fieldName, long value) + public void WriteSInt64(int fieldNumber, long value) { WriteTag(fieldNumber, WireFormat.WireType.Varint); WriteRawVarint64(EncodeZigZag64(value)); } - - public void WriteMessageSetExtension(int fieldNumber, string fieldName, IMessage value) - { - WriteTag(WireFormat.MessageSetField.Item, WireFormat.WireType.StartGroup); - WriteUInt32(WireFormat.MessageSetField.TypeID, "type_id", (uint) fieldNumber); - WriteMessage(WireFormat.MessageSetField.Message, "message", value); - WriteTag(WireFormat.MessageSetField.Item, WireFormat.WireType.EndGroup); - } - - public void WriteMessageSetExtension(int fieldNumber, string fieldName, ByteString value) - { - WriteTag(WireFormat.MessageSetField.Item, WireFormat.WireType.StartGroup); - WriteUInt32(WireFormat.MessageSetField.TypeID, "type_id", (uint) fieldNumber); - WriteBytes(WireFormat.MessageSetField.Message, "message", value); - WriteTag(WireFormat.MessageSetField.Item, WireFormat.WireType.EndGroup); - } - #endregion #region Writing of values without tags @@ -625,155 +543,145 @@ namespace Google.Protobuf #endregion #region Write array members - - // TODO(jonskeet): Remove? - public void WriteArray(FieldType fieldType, int fieldNumber, string fieldName, IEnumerable list) - { - foreach (object element in list) - { - WriteField(fieldType, fieldNumber, fieldName, element); - } - } - - public void WriteGroupArray(int fieldNumber, string fieldName, RepeatedField list) + public void WriteGroupArray(int fieldNumber, RepeatedField list) where T : IMessage { foreach (IMessage value in list) { - WriteGroup(fieldNumber, fieldName, value); + WriteGroup(fieldNumber, value); } } - public void WriteMessageArray(int fieldNumber, string fieldName, RepeatedField list) + public void WriteMessageArray(int fieldNumber, RepeatedField list) where T : IMessage { foreach (IMessage value in list) { - WriteMessage(fieldNumber, fieldName, value); + WriteMessage(fieldNumber, value); } } - public void WriteStringArray(int fieldNumber, string fieldName, RepeatedField list) + public void WriteStringArray(int fieldNumber, RepeatedField list) { foreach (var value in list) { - WriteString(fieldNumber, fieldName, value); + WriteString(fieldNumber, value); } } - public void WriteBytesArray(int fieldNumber, string fieldName, RepeatedField list) + public void WriteBytesArray(int fieldNumber, RepeatedField list) { foreach (var value in list) { - WriteBytes(fieldNumber, fieldName, value); + WriteBytes(fieldNumber, value); } } - public void WriteBoolArray(int fieldNumber, string fieldName, RepeatedField list) + public void WriteBoolArray(int fieldNumber, RepeatedField list) { foreach (var value in list) { - WriteBool(fieldNumber, fieldName, value); + WriteBool(fieldNumber, value); } } - public void WriteInt32Array(int fieldNumber, string fieldName, RepeatedField list) + public void WriteInt32Array(int fieldNumber, RepeatedField list) { foreach (var value in list) { - WriteInt32(fieldNumber, fieldName, value); + WriteInt32(fieldNumber, value); } } - public void WriteSInt32Array(int fieldNumber, string fieldName, RepeatedField list) + public void WriteSInt32Array(int fieldNumber, RepeatedField list) { foreach (var value in list) { - WriteSInt32(fieldNumber, fieldName, value); + WriteSInt32(fieldNumber, value); } } - public void WriteUInt32Array(int fieldNumber, string fieldName, RepeatedField list) + public void WriteUInt32Array(int fieldNumber, RepeatedField list) { foreach (var value in list) { - WriteUInt32(fieldNumber, fieldName, value); + WriteUInt32(fieldNumber, value); } } - public void WriteFixed32Array(int fieldNumber, string fieldName, RepeatedField list) + public void WriteFixed32Array(int fieldNumber, RepeatedField list) { foreach (var value in list) { - WriteFixed32(fieldNumber, fieldName, value); + WriteFixed32(fieldNumber, value); } } - public void WriteSFixed32Array(int fieldNumber, string fieldName, RepeatedField list) + public void WriteSFixed32Array(int fieldNumber, RepeatedField list) { foreach (var value in list) { - WriteSFixed32(fieldNumber, fieldName, value); + WriteSFixed32(fieldNumber, value); } } - public void WriteInt64Array(int fieldNumber, string fieldName, RepeatedField list) + public void WriteInt64Array(int fieldNumber, RepeatedField list) { foreach (var value in list) { - WriteInt64(fieldNumber, fieldName, value); + WriteInt64(fieldNumber, value); } } - public void WriteSInt64Array(int fieldNumber, string fieldName, RepeatedField list) + public void WriteSInt64Array(int fieldNumber, RepeatedField list) { foreach (var value in list) { - WriteSInt64(fieldNumber, fieldName, value); + WriteSInt64(fieldNumber, value); } } - public void WriteUInt64Array(int fieldNumber, string fieldName, RepeatedField list) + public void WriteUInt64Array(int fieldNumber, RepeatedField list) { foreach (var value in list) { - WriteUInt64(fieldNumber, fieldName, value); + WriteUInt64(fieldNumber, value); } } - public void WriteFixed64Array(int fieldNumber, string fieldName, RepeatedField list) + public void WriteFixed64Array(int fieldNumber, RepeatedField list) { foreach (var value in list) { - WriteFixed64(fieldNumber, fieldName, value); + WriteFixed64(fieldNumber, value); } } - public void WriteSFixed64Array(int fieldNumber, string fieldName, RepeatedField list) + public void WriteSFixed64Array(int fieldNumber, RepeatedField list) { foreach (var value in list) { - WriteSFixed64(fieldNumber, fieldName, value); + WriteSFixed64(fieldNumber, value); } } - public void WriteDoubleArray(int fieldNumber, string fieldName, RepeatedField list) + public void WriteDoubleArray(int fieldNumber, RepeatedField list) { foreach (var value in list) { - WriteDouble(fieldNumber, fieldName, value); + WriteDouble(fieldNumber, value); } } - public void WriteFloatArray(int fieldNumber, string fieldName, RepeatedField list) + public void WriteFloatArray(int fieldNumber, RepeatedField list) { foreach (var value in list) { - WriteFloat(fieldNumber, fieldName, value); + WriteFloat(fieldNumber, value); } } - public void WriteEnumArray(int fieldNumber, string fieldName, RepeatedField list) + public void WriteEnumArray(int fieldNumber, RepeatedField list) where T : struct, IComparable, IFormattable { if (list.Count == 0) @@ -783,34 +691,15 @@ namespace Google.Protobuf // TODO(jonskeet): Avoid the Cast call here. Work out a better mass "T to int" conversion. foreach (int value in list.Cast()) { - WriteEnum(fieldNumber, fieldName, value); + WriteEnum(fieldNumber, value); } } #endregion #region Write packed array members - - // TODO(jonskeet): Remove? - public void WritePackedArray(FieldType fieldType, int fieldNumber, string fieldName, IEnumerable list) - { - int calculatedSize = 0; - foreach (object element in list) - { - calculatedSize += ComputeFieldSizeNoTag(fieldType, element); - } - - WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited); - WriteRawVarint32((uint) calculatedSize); - - foreach (object element in list) - { - WriteFieldNoTag(fieldType, element); - } - } - // TODO(jonskeet): A lot of these are really inefficient, due to method group conversions. Fix! - public void WritePackedBoolArray(int fieldNumber, string fieldName, RepeatedField list) + public void WritePackedBoolArray(int fieldNumber, RepeatedField list) { if (list.Count == 0) { @@ -825,7 +714,7 @@ namespace Google.Protobuf } } - public void WritePackedInt32Array(int fieldNumber, string fieldName, RepeatedField list) + public void WritePackedInt32Array(int fieldNumber, RepeatedField list) { if (list.Count == 0) { @@ -840,7 +729,7 @@ namespace Google.Protobuf } } - public void WritePackedSInt32Array(int fieldNumber, string fieldName, RepeatedField list) + public void WritePackedSInt32Array(int fieldNumber, RepeatedField list) { if (list.Count == 0) { @@ -855,7 +744,7 @@ namespace Google.Protobuf } } - public void WritePackedUInt32Array(int fieldNumber, string fieldName, RepeatedField list) + public void WritePackedUInt32Array(int fieldNumber, RepeatedField list) { if (list.Count == 0) { @@ -870,7 +759,7 @@ namespace Google.Protobuf } } - public void WritePackedFixed32Array(int fieldNumber, string fieldName, RepeatedField list) + public void WritePackedFixed32Array(int fieldNumber, RepeatedField list) { if (list.Count == 0) { @@ -885,7 +774,7 @@ namespace Google.Protobuf } } - public void WritePackedSFixed32Array(int fieldNumber, string fieldName, RepeatedField list) + public void WritePackedSFixed32Array(int fieldNumber, RepeatedField list) { if (list.Count == 0) { @@ -900,7 +789,7 @@ namespace Google.Protobuf } } - public void WritePackedInt64Array(int fieldNumber, string fieldName, RepeatedField list) + public void WritePackedInt64Array(int fieldNumber, RepeatedField list) { if (list.Count == 0) { @@ -915,7 +804,7 @@ namespace Google.Protobuf } } - public void WritePackedSInt64Array(int fieldNumber, string fieldName, RepeatedField list) + public void WritePackedSInt64Array(int fieldNumber, RepeatedField list) { if (list.Count == 0) { @@ -930,7 +819,7 @@ namespace Google.Protobuf } } - public void WritePackedUInt64Array(int fieldNumber, string fieldName, RepeatedField list) + public void WritePackedUInt64Array(int fieldNumber, RepeatedField list) { if (list.Count == 0) { @@ -945,7 +834,7 @@ namespace Google.Protobuf } } - public void WritePackedFixed64Array(int fieldNumber, string fieldName, RepeatedField list) + public void WritePackedFixed64Array(int fieldNumber, RepeatedField list) { if (list.Count == 0) { @@ -960,7 +849,7 @@ namespace Google.Protobuf } } - public void WritePackedSFixed64Array(int fieldNumber, string fieldName, RepeatedField list) + public void WritePackedSFixed64Array(int fieldNumber, RepeatedField list) { if (list.Count == 0) { @@ -975,7 +864,7 @@ namespace Google.Protobuf } } - public void WritePackedDoubleArray(int fieldNumber, string fieldName, RepeatedField list) + public void WritePackedDoubleArray(int fieldNumber, RepeatedField list) { if (list.Count == 0) { @@ -990,7 +879,7 @@ namespace Google.Protobuf } } - public void WritePackedFloatArray(int fieldNumber, string fieldName, RepeatedField list) + public void WritePackedFloatArray(int fieldNumber, RepeatedField list) { if (list.Count == 0) { @@ -1005,7 +894,7 @@ namespace Google.Protobuf } } - public void WritePackedEnumArray(int fieldNumber, string fieldName, RepeatedField list) + public void WritePackedEnumArray(int fieldNumber, RepeatedField list) where T : struct, IComparable, IFormattable { if (list.Count == 0) diff --git a/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs b/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs index eb96dfcf..f4af4e2c 100644 --- a/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs +++ b/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs @@ -323,9 +323,8 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; - output.WriteMessageArray(1, fieldNames[0], file_); + public void WriteTo(pb::CodedOutputStream output) { + output.WriteMessageArray(1, file_); } public int CalculateSize() { @@ -342,16 +341,9 @@ namespace Google.Protobuf.DescriptorProtos { file_.Add(other.file_); } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -361,7 +353,7 @@ namespace Google.Protobuf.DescriptorProtos { } break; case 10: { - input.ReadMessageArray(tag, fieldName, file_, global::Google.Protobuf.DescriptorProtos.FileDescriptorProto.Parser); + input.ReadMessageArray(tag, file_, global::Google.Protobuf.DescriptorProtos.FileDescriptorProto.Parser); break; } } @@ -510,29 +502,28 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { if (Name != "") { - output.WriteString(1, fieldNames[4], Name); + output.WriteString(1, Name); } if (Package != "") { - output.WriteString(2, fieldNames[6], Package); + output.WriteString(2, Package); } - output.WriteStringArray(3, fieldNames[0], dependency_); - output.WriteMessageArray(4, fieldNames[3], messageType_); - output.WriteMessageArray(5, fieldNames[1], enumType_); - output.WriteMessageArray(6, fieldNames[8], service_); - output.WriteMessageArray(7, fieldNames[2], extension_); + output.WriteStringArray(3, dependency_); + output.WriteMessageArray(4, messageType_); + output.WriteMessageArray(5, enumType_); + output.WriteMessageArray(6, service_); + output.WriteMessageArray(7, extension_); if (options_ != null) { - output.WriteMessage(8, fieldNames[5], Options); + output.WriteMessage(8, Options); } if (sourceCodeInfo_ != null) { - output.WriteMessage(9, fieldNames[9], SourceCodeInfo); + output.WriteMessage(9, SourceCodeInfo); } - output.WriteInt32Array(10, fieldNames[7], publicDependency_); - output.WriteInt32Array(11, fieldNames[11], weakDependency_); + output.WriteInt32Array(10, publicDependency_); + output.WriteInt32Array(11, weakDependency_); if (Syntax != "") { - output.WriteString(12, fieldNames[10], Syntax); + output.WriteString(12, Syntax); } } @@ -625,16 +616,9 @@ namespace Google.Protobuf.DescriptorProtos { } } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -644,31 +628,31 @@ namespace Google.Protobuf.DescriptorProtos { } break; case 10: { - input.ReadString(ref name_); + name_ = input.ReadString(); break; } case 18: { - input.ReadString(ref package_); + package_ = input.ReadString(); break; } case 26: { - input.ReadStringArray(tag, fieldName, dependency_); + input.ReadStringArray(tag, dependency_); break; } case 34: { - input.ReadMessageArray(tag, fieldName, messageType_, global::Google.Protobuf.DescriptorProtos.DescriptorProto.Parser); + input.ReadMessageArray(tag, messageType_, global::Google.Protobuf.DescriptorProtos.DescriptorProto.Parser); break; } case 42: { - input.ReadMessageArray(tag, fieldName, enumType_, global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto.Parser); + input.ReadMessageArray(tag, enumType_, global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto.Parser); break; } case 50: { - input.ReadMessageArray(tag, fieldName, service_, global::Google.Protobuf.DescriptorProtos.ServiceDescriptorProto.Parser); + input.ReadMessageArray(tag, service_, global::Google.Protobuf.DescriptorProtos.ServiceDescriptorProto.Parser); break; } case 58: { - input.ReadMessageArray(tag, fieldName, extension_, global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Parser); + input.ReadMessageArray(tag, extension_, global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Parser); break; } case 66: { @@ -687,16 +671,16 @@ namespace Google.Protobuf.DescriptorProtos { } case 82: case 80: { - input.ReadInt32Array(tag, fieldName, publicDependency_); + input.ReadInt32Array(tag, publicDependency_); break; } case 90: case 88: { - input.ReadInt32Array(tag, fieldName, weakDependency_); + input.ReadInt32Array(tag, weakDependency_); break; } case 98: { - input.ReadString(ref syntax_); + syntax_ = input.ReadString(); break; } } @@ -825,22 +809,21 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { if (Name != "") { - output.WriteString(1, fieldNames[4], Name); + output.WriteString(1, Name); } - output.WriteMessageArray(2, fieldNames[3], field_); - output.WriteMessageArray(3, fieldNames[5], nestedType_); - output.WriteMessageArray(4, fieldNames[0], enumType_); - output.WriteMessageArray(5, fieldNames[2], extensionRange_); - output.WriteMessageArray(6, fieldNames[1], extension_); + output.WriteMessageArray(2, field_); + output.WriteMessageArray(3, nestedType_); + output.WriteMessageArray(4, enumType_); + output.WriteMessageArray(5, extensionRange_); + output.WriteMessageArray(6, extension_); if (options_ != null) { - output.WriteMessage(7, fieldNames[7], Options); + output.WriteMessage(7, Options); } - output.WriteMessageArray(8, fieldNames[6], oneofDecl_); - output.WriteMessageArray(9, fieldNames[9], reservedRange_); - output.WriteStringArray(10, fieldNames[8], reservedName_); + output.WriteMessageArray(8, oneofDecl_); + output.WriteMessageArray(9, reservedRange_); + output.WriteStringArray(10, reservedName_); } public int CalculateSize() { @@ -905,16 +888,9 @@ namespace Google.Protobuf.DescriptorProtos { reservedName_.Add(other.reservedName_); } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -924,27 +900,27 @@ namespace Google.Protobuf.DescriptorProtos { } break; case 10: { - input.ReadString(ref name_); + name_ = input.ReadString(); break; } case 18: { - input.ReadMessageArray(tag, fieldName, field_, global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Parser); + input.ReadMessageArray(tag, field_, global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Parser); break; } case 26: { - input.ReadMessageArray(tag, fieldName, nestedType_, global::Google.Protobuf.DescriptorProtos.DescriptorProto.Parser); + input.ReadMessageArray(tag, nestedType_, global::Google.Protobuf.DescriptorProtos.DescriptorProto.Parser); break; } case 34: { - input.ReadMessageArray(tag, fieldName, enumType_, global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto.Parser); + input.ReadMessageArray(tag, enumType_, global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto.Parser); break; } case 42: { - input.ReadMessageArray(tag, fieldName, extensionRange_, global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ExtensionRange.Parser); + input.ReadMessageArray(tag, extensionRange_, global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ExtensionRange.Parser); break; } case 50: { - input.ReadMessageArray(tag, fieldName, extension_, global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Parser); + input.ReadMessageArray(tag, extension_, global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Parser); break; } case 58: { @@ -955,15 +931,15 @@ namespace Google.Protobuf.DescriptorProtos { break; } case 66: { - input.ReadMessageArray(tag, fieldName, oneofDecl_, global::Google.Protobuf.DescriptorProtos.OneofDescriptorProto.Parser); + input.ReadMessageArray(tag, oneofDecl_, global::Google.Protobuf.DescriptorProtos.OneofDescriptorProto.Parser); break; } case 74: { - input.ReadMessageArray(tag, fieldName, reservedRange_, global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ReservedRange.Parser); + input.ReadMessageArray(tag, reservedRange_, global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ReservedRange.Parser); break; } case 82: { - input.ReadStringArray(tag, fieldName, reservedName_); + input.ReadStringArray(tag, reservedName_); break; } } @@ -1031,13 +1007,12 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { if (Start != 0) { - output.WriteInt32(1, fieldNames[1], Start); + output.WriteInt32(1, Start); } if (End != 0) { - output.WriteInt32(2, fieldNames[0], End); + output.WriteInt32(2, End); } } @@ -1063,16 +1038,9 @@ namespace Google.Protobuf.DescriptorProtos { } } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -1082,11 +1050,11 @@ namespace Google.Protobuf.DescriptorProtos { } break; case 8: { - input.ReadInt32(ref start_); + start_ = input.ReadInt32(); break; } case 16: { - input.ReadInt32(ref end_); + end_ = input.ReadInt32(); break; } } @@ -1153,13 +1121,12 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { if (Start != 0) { - output.WriteInt32(1, fieldNames[1], Start); + output.WriteInt32(1, Start); } if (End != 0) { - output.WriteInt32(2, fieldNames[0], End); + output.WriteInt32(2, End); } } @@ -1185,16 +1152,9 @@ namespace Google.Protobuf.DescriptorProtos { } } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -1204,11 +1164,11 @@ namespace Google.Protobuf.DescriptorProtos { } break; case 8: { - input.ReadInt32(ref start_); + start_ = input.ReadInt32(); break; } case 16: { - input.ReadInt32(ref end_); + end_ = input.ReadInt32(); break; } } @@ -1348,34 +1308,33 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { if (Name != "") { - output.WriteString(1, fieldNames[3], Name); + output.WriteString(1, Name); } if (Extendee != "") { - output.WriteString(2, fieldNames[1], Extendee); + output.WriteString(2, Extendee); } if (Number != 0) { - output.WriteInt32(3, fieldNames[4], Number); + output.WriteInt32(3, Number); } if (Label != global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Label.LABEL_OPTIONAL) { - output.WriteEnum(4, fieldNames[2], (int) Label); + output.WriteEnum(4, (int) Label); } if (Type != global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Type.TYPE_DOUBLE) { - output.WriteEnum(5, fieldNames[7], (int) Type); + output.WriteEnum(5, (int) Type); } if (TypeName != "") { - output.WriteString(6, fieldNames[8], TypeName); + output.WriteString(6, TypeName); } if (DefaultValue != "") { - output.WriteString(7, fieldNames[0], DefaultValue); + output.WriteString(7, DefaultValue); } if (options_ != null) { - output.WriteMessage(8, fieldNames[6], Options); + output.WriteMessage(8, Options); } if (OneofIndex != 0) { - output.WriteInt32(9, fieldNames[5], OneofIndex); + output.WriteInt32(9, OneofIndex); } } @@ -1446,16 +1405,9 @@ namespace Google.Protobuf.DescriptorProtos { } } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -1465,33 +1417,31 @@ namespace Google.Protobuf.DescriptorProtos { } break; case 10: { - input.ReadString(ref name_); + name_ = input.ReadString(); break; } case 18: { - input.ReadString(ref extendee_); + extendee_ = input.ReadString(); break; } case 24: { - input.ReadInt32(ref number_); + number_ = input.ReadInt32(); break; } case 32: { - int tmp = 0; - input.ReadEnum(ref tmp); - label_ = (global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Label) tmp;break; + label_ = (global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Label) input.ReadEnum(); + break; } case 40: { - int tmp = 0; - input.ReadEnum(ref tmp); - type_ = (global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Type) tmp;break; + type_ = (global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Type) input.ReadEnum(); + break; } case 50: { - input.ReadString(ref typeName_); + typeName_ = input.ReadString(); break; } case 58: { - input.ReadString(ref defaultValue_); + defaultValue_ = input.ReadString(); break; } case 66: { @@ -1502,7 +1452,7 @@ namespace Google.Protobuf.DescriptorProtos { break; } case 72: { - input.ReadInt32(ref oneofIndex_); + oneofIndex_ = input.ReadInt32(); break; } } @@ -1592,10 +1542,9 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { if (Name != "") { - output.WriteString(1, fieldNames[0], Name); + output.WriteString(1, Name); } } @@ -1615,16 +1564,9 @@ namespace Google.Protobuf.DescriptorProtos { } } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -1634,7 +1576,7 @@ namespace Google.Protobuf.DescriptorProtos { } break; case 10: { - input.ReadString(ref name_); + name_ = input.ReadString(); break; } } @@ -1707,14 +1649,13 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { if (Name != "") { - output.WriteString(1, fieldNames[0], Name); + output.WriteString(1, Name); } - output.WriteMessageArray(2, fieldNames[2], value_); + output.WriteMessageArray(2, value_); if (options_ != null) { - output.WriteMessage(3, fieldNames[1], Options); + output.WriteMessage(3, Options); } } @@ -1747,16 +1688,9 @@ namespace Google.Protobuf.DescriptorProtos { } } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -1766,11 +1700,11 @@ namespace Google.Protobuf.DescriptorProtos { } break; case 10: { - input.ReadString(ref name_); + name_ = input.ReadString(); break; } case 18: { - input.ReadMessageArray(tag, fieldName, value_, global::Google.Protobuf.DescriptorProtos.EnumValueDescriptorProto.Parser); + input.ReadMessageArray(tag, value_, global::Google.Protobuf.DescriptorProtos.EnumValueDescriptorProto.Parser); break; } case 26: { @@ -1852,16 +1786,15 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { if (Name != "") { - output.WriteString(1, fieldNames[0], Name); + output.WriteString(1, Name); } if (Number != 0) { - output.WriteInt32(2, fieldNames[1], Number); + output.WriteInt32(2, Number); } if (options_ != null) { - output.WriteMessage(3, fieldNames[2], Options); + output.WriteMessage(3, Options); } } @@ -1896,16 +1829,9 @@ namespace Google.Protobuf.DescriptorProtos { } } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -1915,11 +1841,11 @@ namespace Google.Protobuf.DescriptorProtos { } break; case 10: { - input.ReadString(ref name_); + name_ = input.ReadString(); break; } case 16: { - input.ReadInt32(ref number_); + number_ = input.ReadInt32(); break; } case 26: { @@ -1999,14 +1925,13 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { if (Name != "") { - output.WriteString(1, fieldNames[1], Name); + output.WriteString(1, Name); } - output.WriteMessageArray(2, fieldNames[0], method_); + output.WriteMessageArray(2, method_); if (options_ != null) { - output.WriteMessage(3, fieldNames[2], Options); + output.WriteMessage(3, Options); } } @@ -2039,16 +1964,9 @@ namespace Google.Protobuf.DescriptorProtos { } } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -2058,11 +1976,11 @@ namespace Google.Protobuf.DescriptorProtos { } break; case 10: { - input.ReadString(ref name_); + name_ = input.ReadString(); break; } case 18: { - input.ReadMessageArray(tag, fieldName, method_, global::Google.Protobuf.DescriptorProtos.MethodDescriptorProto.Parser); + input.ReadMessageArray(tag, method_, global::Google.Protobuf.DescriptorProtos.MethodDescriptorProto.Parser); break; } case 26: { @@ -2174,25 +2092,24 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { if (Name != "") { - output.WriteString(1, fieldNames[2], Name); + output.WriteString(1, Name); } if (InputType != "") { - output.WriteString(2, fieldNames[1], InputType); + output.WriteString(2, InputType); } if (OutputType != "") { - output.WriteString(3, fieldNames[4], OutputType); + output.WriteString(3, OutputType); } if (options_ != null) { - output.WriteMessage(4, fieldNames[3], Options); + output.WriteMessage(4, Options); } if (ClientStreaming != false) { - output.WriteBool(5, fieldNames[0], ClientStreaming); + output.WriteBool(5, ClientStreaming); } if (ServerStreaming != false) { - output.WriteBool(6, fieldNames[5], ServerStreaming); + output.WriteBool(6, ServerStreaming); } } @@ -2245,16 +2162,9 @@ namespace Google.Protobuf.DescriptorProtos { } } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -2264,15 +2174,15 @@ namespace Google.Protobuf.DescriptorProtos { } break; case 10: { - input.ReadString(ref name_); + name_ = input.ReadString(); break; } case 18: { - input.ReadString(ref inputType_); + inputType_ = input.ReadString(); break; } case 26: { - input.ReadString(ref outputType_); + outputType_ = input.ReadString(); break; } case 34: { @@ -2283,11 +2193,11 @@ namespace Google.Protobuf.DescriptorProtos { break; } case 40: { - input.ReadBool(ref clientStreaming_); + clientStreaming_ = input.ReadBool(); break; } case 48: { - input.ReadBool(ref serverStreaming_); + serverStreaming_ = input.ReadBool(); break; } } @@ -2482,51 +2392,50 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { if (JavaPackage != "") { - output.WriteString(1, fieldNames[9], JavaPackage); + output.WriteString(1, JavaPackage); } if (JavaOuterClassname != "") { - output.WriteString(8, fieldNames[8], JavaOuterClassname); + output.WriteString(8, JavaOuterClassname); } if (OptimizeFor != global::Google.Protobuf.DescriptorProtos.FileOptions.Types.OptimizeMode.SPEED) { - output.WriteEnum(9, fieldNames[12], (int) OptimizeFor); + output.WriteEnum(9, (int) OptimizeFor); } if (JavaMultipleFiles != false) { - output.WriteBool(10, fieldNames[7], JavaMultipleFiles); + output.WriteBool(10, JavaMultipleFiles); } if (GoPackage != "") { - output.WriteString(11, fieldNames[4], GoPackage); + output.WriteString(11, GoPackage); } if (CcGenericServices != false) { - output.WriteBool(16, fieldNames[1], CcGenericServices); + output.WriteBool(16, CcGenericServices); } if (JavaGenericServices != false) { - output.WriteBool(17, fieldNames[6], JavaGenericServices); + output.WriteBool(17, JavaGenericServices); } if (PyGenericServices != false) { - output.WriteBool(18, fieldNames[13], PyGenericServices); + output.WriteBool(18, PyGenericServices); } if (JavaGenerateEqualsAndHash != false) { - output.WriteBool(20, fieldNames[5], JavaGenerateEqualsAndHash); + output.WriteBool(20, JavaGenerateEqualsAndHash); } if (Deprecated != false) { - output.WriteBool(23, fieldNames[3], Deprecated); + output.WriteBool(23, Deprecated); } if (JavaStringCheckUtf8 != false) { - output.WriteBool(27, fieldNames[10], JavaStringCheckUtf8); + output.WriteBool(27, JavaStringCheckUtf8); } if (CcEnableArenas != false) { - output.WriteBool(31, fieldNames[0], CcEnableArenas); + output.WriteBool(31, CcEnableArenas); } if (ObjcClassPrefix != "") { - output.WriteString(36, fieldNames[11], ObjcClassPrefix); + output.WriteString(36, ObjcClassPrefix); } if (CsharpNamespace != "") { - output.WriteString(37, fieldNames[2], CsharpNamespace); + output.WriteString(37, CsharpNamespace); } - output.WriteMessageArray(999, fieldNames[14], uninterpretedOption_); + output.WriteMessageArray(999, uninterpretedOption_); } public int CalculateSize() { @@ -2627,16 +2536,9 @@ namespace Google.Protobuf.DescriptorProtos { uninterpretedOption_.Add(other.uninterpretedOption_); } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -2646,64 +2548,63 @@ namespace Google.Protobuf.DescriptorProtos { } break; case 10: { - input.ReadString(ref javaPackage_); + javaPackage_ = input.ReadString(); break; } case 66: { - input.ReadString(ref javaOuterClassname_); + javaOuterClassname_ = input.ReadString(); break; } case 72: { - int tmp = 0; - input.ReadEnum(ref tmp); - optimizeFor_ = (global::Google.Protobuf.DescriptorProtos.FileOptions.Types.OptimizeMode) tmp;break; + optimizeFor_ = (global::Google.Protobuf.DescriptorProtos.FileOptions.Types.OptimizeMode) input.ReadEnum(); + break; } case 80: { - input.ReadBool(ref javaMultipleFiles_); + javaMultipleFiles_ = input.ReadBool(); break; } case 90: { - input.ReadString(ref goPackage_); + goPackage_ = input.ReadString(); break; } case 128: { - input.ReadBool(ref ccGenericServices_); + ccGenericServices_ = input.ReadBool(); break; } case 136: { - input.ReadBool(ref javaGenericServices_); + javaGenericServices_ = input.ReadBool(); break; } case 144: { - input.ReadBool(ref pyGenericServices_); + pyGenericServices_ = input.ReadBool(); break; } case 160: { - input.ReadBool(ref javaGenerateEqualsAndHash_); + javaGenerateEqualsAndHash_ = input.ReadBool(); break; } case 184: { - input.ReadBool(ref deprecated_); + deprecated_ = input.ReadBool(); break; } case 216: { - input.ReadBool(ref javaStringCheckUtf8_); + javaStringCheckUtf8_ = input.ReadBool(); break; } case 248: { - input.ReadBool(ref ccEnableArenas_); + ccEnableArenas_ = input.ReadBool(); break; } case 290: { - input.ReadString(ref objcClassPrefix_); + objcClassPrefix_ = input.ReadString(); break; } case 298: { - input.ReadString(ref csharpNamespace_); + csharpNamespace_ = input.ReadString(); break; } case 7994: { - input.ReadMessageArray(tag, fieldName, uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); + input.ReadMessageArray(tag, uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); break; } } @@ -2810,21 +2711,20 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { if (MessageSetWireFormat != false) { - output.WriteBool(1, fieldNames[2], MessageSetWireFormat); + output.WriteBool(1, MessageSetWireFormat); } if (NoStandardDescriptorAccessor != false) { - output.WriteBool(2, fieldNames[3], NoStandardDescriptorAccessor); + output.WriteBool(2, NoStandardDescriptorAccessor); } if (Deprecated != false) { - output.WriteBool(3, fieldNames[0], Deprecated); + output.WriteBool(3, Deprecated); } if (MapEntry != false) { - output.WriteBool(7, fieldNames[1], MapEntry); + output.WriteBool(7, MapEntry); } - output.WriteMessageArray(999, fieldNames[4], uninterpretedOption_); + output.WriteMessageArray(999, uninterpretedOption_); } public int CalculateSize() { @@ -2865,16 +2765,9 @@ namespace Google.Protobuf.DescriptorProtos { uninterpretedOption_.Add(other.uninterpretedOption_); } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -2884,23 +2777,23 @@ namespace Google.Protobuf.DescriptorProtos { } break; case 8: { - input.ReadBool(ref messageSetWireFormat_); + messageSetWireFormat_ = input.ReadBool(); break; } case 16: { - input.ReadBool(ref noStandardDescriptorAccessor_); + noStandardDescriptorAccessor_ = input.ReadBool(); break; } case 24: { - input.ReadBool(ref deprecated_); + deprecated_ = input.ReadBool(); break; } case 56: { - input.ReadBool(ref mapEntry_); + mapEntry_ = input.ReadBool(); break; } case 7994: { - input.ReadMessageArray(tag, fieldName, uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); + input.ReadMessageArray(tag, uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); break; } } @@ -3015,27 +2908,26 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { if (Ctype != global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.CType.STRING) { - output.WriteEnum(1, fieldNames[0], (int) Ctype); + output.WriteEnum(1, (int) Ctype); } if (Packed != false) { - output.WriteBool(2, fieldNames[4], Packed); + output.WriteBool(2, Packed); } if (Deprecated != false) { - output.WriteBool(3, fieldNames[1], Deprecated); + output.WriteBool(3, Deprecated); } if (Lazy != false) { - output.WriteBool(5, fieldNames[3], Lazy); + output.WriteBool(5, Lazy); } if (Jstype != global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.JSType.JS_NORMAL) { - output.WriteEnum(6, fieldNames[2], (int) Jstype); + output.WriteEnum(6, (int) Jstype); } if (Weak != false) { - output.WriteBool(10, fieldNames[6], Weak); + output.WriteBool(10, Weak); } - output.WriteMessageArray(999, fieldNames[5], uninterpretedOption_); + output.WriteMessageArray(999, uninterpretedOption_); } public int CalculateSize() { @@ -3088,16 +2980,9 @@ namespace Google.Protobuf.DescriptorProtos { uninterpretedOption_.Add(other.uninterpretedOption_); } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -3107,33 +2992,31 @@ namespace Google.Protobuf.DescriptorProtos { } break; case 8: { - int tmp = 0; - input.ReadEnum(ref tmp); - ctype_ = (global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.CType) tmp;break; + ctype_ = (global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.CType) input.ReadEnum(); + break; } case 16: { - input.ReadBool(ref packed_); + packed_ = input.ReadBool(); break; } case 24: { - input.ReadBool(ref deprecated_); + deprecated_ = input.ReadBool(); break; } case 40: { - input.ReadBool(ref lazy_); + lazy_ = input.ReadBool(); break; } case 48: { - int tmp = 0; - input.ReadEnum(ref tmp); - jstype_ = (global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.JSType) tmp;break; + jstype_ = (global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.JSType) input.ReadEnum(); + break; } case 80: { - input.ReadBool(ref weak_); + weak_ = input.ReadBool(); break; } case 7994: { - input.ReadMessageArray(tag, fieldName, uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); + input.ReadMessageArray(tag, uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); break; } } @@ -3226,15 +3109,14 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { if (AllowAlias != false) { - output.WriteBool(2, fieldNames[0], AllowAlias); + output.WriteBool(2, AllowAlias); } if (Deprecated != false) { - output.WriteBool(3, fieldNames[1], Deprecated); + output.WriteBool(3, Deprecated); } - output.WriteMessageArray(999, fieldNames[2], uninterpretedOption_); + output.WriteMessageArray(999, uninterpretedOption_); } public int CalculateSize() { @@ -3263,16 +3145,9 @@ namespace Google.Protobuf.DescriptorProtos { uninterpretedOption_.Add(other.uninterpretedOption_); } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -3282,15 +3157,15 @@ namespace Google.Protobuf.DescriptorProtos { } break; case 16: { - input.ReadBool(ref allowAlias_); + allowAlias_ = input.ReadBool(); break; } case 24: { - input.ReadBool(ref deprecated_); + deprecated_ = input.ReadBool(); break; } case 7994: { - input.ReadMessageArray(tag, fieldName, uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); + input.ReadMessageArray(tag, uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); break; } } @@ -3355,12 +3230,11 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { if (Deprecated != false) { - output.WriteBool(1, fieldNames[0], Deprecated); + output.WriteBool(1, Deprecated); } - output.WriteMessageArray(999, fieldNames[1], uninterpretedOption_); + output.WriteMessageArray(999, uninterpretedOption_); } public int CalculateSize() { @@ -3383,16 +3257,9 @@ namespace Google.Protobuf.DescriptorProtos { uninterpretedOption_.Add(other.uninterpretedOption_); } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -3402,11 +3269,11 @@ namespace Google.Protobuf.DescriptorProtos { } break; case 8: { - input.ReadBool(ref deprecated_); + deprecated_ = input.ReadBool(); break; } case 7994: { - input.ReadMessageArray(tag, fieldName, uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); + input.ReadMessageArray(tag, uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); break; } } @@ -3471,12 +3338,11 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { if (Deprecated != false) { - output.WriteBool(33, fieldNames[0], Deprecated); + output.WriteBool(33, Deprecated); } - output.WriteMessageArray(999, fieldNames[1], uninterpretedOption_); + output.WriteMessageArray(999, uninterpretedOption_); } public int CalculateSize() { @@ -3499,16 +3365,9 @@ namespace Google.Protobuf.DescriptorProtos { uninterpretedOption_.Add(other.uninterpretedOption_); } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -3518,11 +3377,11 @@ namespace Google.Protobuf.DescriptorProtos { } break; case 264: { - input.ReadBool(ref deprecated_); + deprecated_ = input.ReadBool(); break; } case 7994: { - input.ReadMessageArray(tag, fieldName, uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); + input.ReadMessageArray(tag, uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); break; } } @@ -3587,12 +3446,11 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { if (Deprecated != false) { - output.WriteBool(33, fieldNames[0], Deprecated); + output.WriteBool(33, Deprecated); } - output.WriteMessageArray(999, fieldNames[1], uninterpretedOption_); + output.WriteMessageArray(999, uninterpretedOption_); } public int CalculateSize() { @@ -3615,16 +3473,9 @@ namespace Google.Protobuf.DescriptorProtos { uninterpretedOption_.Add(other.uninterpretedOption_); } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -3634,11 +3485,11 @@ namespace Google.Protobuf.DescriptorProtos { } break; case 264: { - input.ReadBool(ref deprecated_); + deprecated_ = input.ReadBool(); break; } case 7994: { - input.ReadMessageArray(tag, fieldName, uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); + input.ReadMessageArray(tag, uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); break; } } @@ -3753,26 +3604,25 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; - output.WriteMessageArray(2, fieldNames[3], name_); + public void WriteTo(pb::CodedOutputStream output) { + output.WriteMessageArray(2, name_); if (IdentifierValue != "") { - output.WriteString(3, fieldNames[2], IdentifierValue); + output.WriteString(3, IdentifierValue); } if (PositiveIntValue != 0UL) { - output.WriteUInt64(4, fieldNames[5], PositiveIntValue); + output.WriteUInt64(4, PositiveIntValue); } if (NegativeIntValue != 0L) { - output.WriteInt64(5, fieldNames[4], NegativeIntValue); + output.WriteInt64(5, NegativeIntValue); } if (DoubleValue != 0D) { - output.WriteDouble(6, fieldNames[1], DoubleValue); + output.WriteDouble(6, DoubleValue); } if (StringValue != pb::ByteString.Empty) { - output.WriteBytes(7, fieldNames[6], StringValue); + output.WriteBytes(7, StringValue); } if (AggregateValue != "") { - output.WriteString(8, fieldNames[0], AggregateValue); + output.WriteString(8, AggregateValue); } } @@ -3826,16 +3676,9 @@ namespace Google.Protobuf.DescriptorProtos { } } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -3845,31 +3688,31 @@ namespace Google.Protobuf.DescriptorProtos { } break; case 18: { - input.ReadMessageArray(tag, fieldName, name_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Types.NamePart.Parser); + input.ReadMessageArray(tag, name_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Types.NamePart.Parser); break; } case 26: { - input.ReadString(ref identifierValue_); + identifierValue_ = input.ReadString(); break; } case 32: { - input.ReadUInt64(ref positiveIntValue_); + positiveIntValue_ = input.ReadUInt64(); break; } case 40: { - input.ReadInt64(ref negativeIntValue_); + negativeIntValue_ = input.ReadInt64(); break; } case 49: { - input.ReadDouble(ref doubleValue_); + doubleValue_ = input.ReadDouble(); break; } case 58: { - input.ReadBytes(ref stringValue_); + stringValue_ = input.ReadBytes(); break; } case 66: { - input.ReadString(ref aggregateValue_); + aggregateValue_ = input.ReadString(); break; } } @@ -3937,13 +3780,12 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; + public void WriteTo(pb::CodedOutputStream output) { if (NamePart_ != "") { - output.WriteString(1, fieldNames[1], NamePart_); + output.WriteString(1, NamePart_); } if (IsExtension != false) { - output.WriteBool(2, fieldNames[0], IsExtension); + output.WriteBool(2, IsExtension); } } @@ -3969,16 +3811,9 @@ namespace Google.Protobuf.DescriptorProtos { } } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -3988,11 +3823,11 @@ namespace Google.Protobuf.DescriptorProtos { } break; case 10: { - input.ReadString(ref namePart_); + namePart_ = input.ReadString(); break; } case 16: { - input.ReadBool(ref isExtension_); + isExtension_ = input.ReadBool(); break; } } @@ -4052,9 +3887,8 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; - output.WriteMessageArray(1, fieldNames[0], location_); + public void WriteTo(pb::CodedOutputStream output) { + output.WriteMessageArray(1, location_); } public int CalculateSize() { @@ -4071,16 +3905,9 @@ namespace Google.Protobuf.DescriptorProtos { location_.Add(other.location_); } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -4090,7 +3917,7 @@ namespace Google.Protobuf.DescriptorProtos { } break; case 10: { - input.ReadMessageArray(tag, fieldName, location_, global::Google.Protobuf.DescriptorProtos.SourceCodeInfo.Types.Location.Parser); + input.ReadMessageArray(tag, location_, global::Google.Protobuf.DescriptorProtos.SourceCodeInfo.Types.Location.Parser); break; } } @@ -4182,17 +4009,16 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } - public void WriteTo(pb::ICodedOutputStream output) { - string[] fieldNames = _fieldNames; - output.WritePackedInt32Array(1, fieldNames[2], path_); - output.WritePackedInt32Array(2, fieldNames[3], span_); + public void WriteTo(pb::CodedOutputStream output) { + output.WritePackedInt32Array(1, path_); + output.WritePackedInt32Array(2, span_); if (LeadingComments != "") { - output.WriteString(3, fieldNames[0], LeadingComments); + output.WriteString(3, LeadingComments); } if (TrailingComments != "") { - output.WriteString(4, fieldNames[4], TrailingComments); + output.WriteString(4, TrailingComments); } - output.WriteStringArray(6, fieldNames[1], leadingDetachedComments_); + output.WriteStringArray(6, leadingDetachedComments_); } public int CalculateSize() { @@ -4248,16 +4074,9 @@ namespace Google.Protobuf.DescriptorProtos { leadingDetachedComments_.Add(other.leadingDetachedComments_); } - public void MergeFrom(pb::ICodedInputStream input) { + public void MergeFrom(pb::CodedInputStream input) { uint tag; - string fieldName; - while (input.ReadTag(out tag, out fieldName)) { - if (tag == 0 && fieldName != null) { - int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal); - if (fieldOrdinal >= 0) { - tag = _fieldTags[fieldOrdinal]; - } - } + while (input.ReadTag(out tag)) { switch(tag) { case 0: throw pb::InvalidProtocolBufferException.InvalidTag(); @@ -4268,24 +4087,24 @@ namespace Google.Protobuf.DescriptorProtos { break; case 10: case 8: { - input.ReadInt32Array(tag, fieldName, path_); + input.ReadInt32Array(tag, path_); break; } case 18: case 16: { - input.ReadInt32Array(tag, fieldName, span_); + input.ReadInt32Array(tag, span_); break; } case 26: { - input.ReadString(ref leadingComments_); + leadingComments_ = input.ReadString(); break; } case 34: { - input.ReadString(ref trailingComments_); + trailingComments_ = input.ReadString(); break; } case 50: { - input.ReadStringArray(tag, fieldName, leadingDetachedComments_); + input.ReadStringArray(tag, leadingDetachedComments_); break; } } diff --git a/csharp/src/ProtocolBuffers/Extensions.cs b/csharp/src/ProtocolBuffers/Extensions.cs index 29288f51..7f23057e 100644 --- a/csharp/src/ProtocolBuffers/Extensions.cs +++ b/csharp/src/ProtocolBuffers/Extensions.cs @@ -49,7 +49,7 @@ namespace Google.Protobuf codedOutput.Flush(); } - public static void WriteTo(this IMessage message, ICodedOutputStream output) + public static void WriteTo(this IMessage message, CodedOutputStream output) { message.WriteTo(output); } diff --git a/csharp/src/ProtocolBuffers/ICodedInputStream.cs b/csharp/src/ProtocolBuffers/ICodedInputStream.cs deleted file mode 100644 index d962e62b..00000000 --- a/csharp/src/ProtocolBuffers/ICodedInputStream.cs +++ /dev/null @@ -1,293 +0,0 @@ -#region Copyright notice and license - -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/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.Collections.Generic; -using Google.Protobuf.Descriptors; - -//Disable warning CS3010: CLS-compliant interfaces must have only CLS-compliant members -#pragma warning disable 3010 - -namespace Google.Protobuf -{ - public interface ICodedInputStream - { - /// - /// Reads any message initialization data expected from the input stream - /// - /// - /// This is primarily used by text formats and unnecessary for protobuffers' own - /// binary format. The API for MessageStart/End was added for consistent handling - /// of output streams regardless of the actual writer implementation. - /// - void ReadMessageStart(); - /// - /// Reads any message finalization data expected from the input stream - /// - /// - /// This is primarily used by text formats and unnecessary for protobuffers' own - /// binary format. The API for MessageStart/End was added for consistent handling - /// of output streams regardless of the actual writer implementation. - /// - void ReadMessageEnd(); - /// - /// Attempt to read a field tag, returning false if we have reached the end - /// of the input data. - /// - /// - /// - /// If fieldTag is non-zero and ReadTag returns true then the value in fieldName - /// may or may not be populated. However, if fieldTag is zero and ReadTag returns - /// true, then fieldName should be populated with a non-null field name. - /// - /// In other words if ReadTag returns true then either fieldTag will be non-zero OR - /// fieldName will be non-zero. In some cases both may be populated, however the - /// builders will always prefer the fieldTag over fieldName. - /// - /// - bool ReadTag(out uint fieldTag, out string fieldName); - - /// - /// Read a double field from the stream. - /// - bool ReadDouble(ref double value); - - /// - /// Read a float field from the stream. - /// - bool ReadFloat(ref float value); - - /// - /// Read a uint64 field from the stream. - /// - bool ReadUInt64(ref ulong value); - - /// - /// Read an int64 field from the stream. - /// - bool ReadInt64(ref long value); - - /// - /// Read an int32 field from the stream. - /// - bool ReadInt32(ref int value); - - /// - /// Read a fixed64 field from the stream. - /// - bool ReadFixed64(ref ulong value); - - /// - /// Read a fixed32 field from the stream. - /// - bool ReadFixed32(ref uint value); - - /// - /// Read a bool field from the stream. - /// - bool ReadBool(ref bool value); - - /// - /// Reads a string field from the stream. - /// - bool ReadString(ref string value); - - /// - /// Reads a group field value from the stream. - /// - void ReadGroup(int fieldNumber, IMessage message); - - /// - /// Reads an embedded message field value from the stream. - /// - void ReadMessage(IMessage message); - - /// - /// Reads a bytes field value from the stream. - /// - bool ReadBytes(ref ByteString value); - - /// - /// Reads a uint32 field value from the stream. - /// - bool ReadUInt32(ref uint value); - - /// - /// Reads an enum field value from the stream. This performs no checking - /// as to whether the enum value is known to the enum type as it was present - /// when the code was generated. - /// - bool ReadEnum(ref int value); - - /// - /// Reads an sfixed32 field value from the stream. - /// - bool ReadSFixed32(ref int value); - - /// - /// Reads an sfixed64 field value from the stream. - /// - bool ReadSFixed64(ref long value); - - /// - /// Reads an sint32 field value from the stream. - /// - bool ReadSInt32(ref int value); - - /// - /// Reads an sint64 field value from the stream. - /// - bool ReadSInt64(ref long value); - - /// - /// Reads an array of primitive values into the list, if the wire-type of fieldTag is length-prefixed and the - /// type is numeric, it will read a packed array. - /// - void ReadPrimitiveArray(FieldType fieldType, uint fieldTag, string fieldName, ICollection list); - - /// - /// Reads an array of primitive values into the list, if the wire-type of fieldTag is length-prefixed, it will - /// read a packed array. - /// - void ReadEnumArray(uint fieldTag, string fieldName, ICollection list) - where T : struct, IComparable, IFormattable; - - /// - /// Reads a set of messages using the to read individual messages. - /// - void ReadMessageArray(uint fieldTag, string fieldName, ICollection list, MessageParser parser) where T : IMessage; - - /// - /// Reads a set of messages using the as a template. - /// - void ReadGroupArray(uint fieldTag, string fieldName, ICollection list, MessageParser parser) where T : IMessage; - - /// - /// Reads a field of any primitive type. Enums, groups and embedded - /// messages are not handled by this method. - /// - bool ReadPrimitiveField(FieldType fieldType, ref object value); - - /// - /// Returns true if the stream 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 stream has reached a limit created using PushLimit. - /// - bool IsAtEnd { get; } - - /// - /// Reads and discards a single field, given its tag value. - /// - /// false if the tag is an end-group tag, in which case - /// nothing is skipped. Otherwise, returns true. - bool SkipField(); - - /// - /// Reads one or more repeated string field values from the stream. - /// - void ReadStringArray(uint fieldTag, string fieldName, ICollection list); - - /// - /// Reads one or more repeated ByteString field values from the stream. - /// - void ReadBytesArray(uint fieldTag, string fieldName, ICollection list); - - /// - /// Reads one or more repeated boolean field values from the stream. - /// - void ReadBoolArray(uint fieldTag, string fieldName, ICollection list); - - /// - /// Reads one or more repeated Int32 field values from the stream. - /// - void ReadInt32Array(uint fieldTag, string fieldName, ICollection list); - - /// - /// Reads one or more repeated SInt32 field values from the stream. - /// - void ReadSInt32Array(uint fieldTag, string fieldName, ICollection list); - - /// - /// Reads one or more repeated UInt32 field values from the stream. - /// - void ReadUInt32Array(uint fieldTag, string fieldName, ICollection list); - - /// - /// Reads one or more repeated Fixed32 field values from the stream. - /// - void ReadFixed32Array(uint fieldTag, string fieldName, ICollection list); - - /// - /// Reads one or more repeated SFixed32 field values from the stream. - /// - void ReadSFixed32Array(uint fieldTag, string fieldName, ICollection list); - - /// - /// Reads one or more repeated Int64 field values from the stream. - /// - void ReadInt64Array(uint fieldTag, string fieldName, ICollection list); - - /// - /// Reads one or more repeated SInt64 field values from the stream. - /// - void ReadSInt64Array(uint fieldTag, string fieldName, ICollection list); - - /// - /// Reads one or more repeated UInt64 field values from the stream. - /// - void ReadUInt64Array(uint fieldTag, string fieldName, ICollection list); - - /// - /// Reads one or more repeated Fixed64 field values from the stream. - /// - void ReadFixed64Array(uint fieldTag, string fieldName, ICollection list); - - /// - /// Reads one or more repeated SFixed64 field values from the stream. - /// - void ReadSFixed64Array(uint fieldTag, string fieldName, ICollection list); - - /// - /// Reads one or more repeated Double field values from the stream. - /// - void ReadDoubleArray(uint fieldTag, string fieldName, ICollection list); - - /// - /// Reads one or more repeated Float field values from the stream. - /// - void ReadFloatArray(uint fieldTag, string fieldName, ICollection list); - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/ICodedOutputStream.cs b/csharp/src/ProtocolBuffers/ICodedOutputStream.cs deleted file mode 100644 index 921400ac..00000000 --- a/csharp/src/ProtocolBuffers/ICodedOutputStream.cs +++ /dev/null @@ -1,347 +0,0 @@ -#region Copyright notice and license - -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/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.Collections; -using Google.Protobuf.Collections; -using Google.Protobuf.Descriptors; - -//Disable warning CS3010: CLS-compliant interfaces must have only CLS-compliant members -#pragma warning disable 3010 - -namespace Google.Protobuf -{ - /// - /// Provides an interface that is used write a message. Most often proto buffers are written - /// in their binary form by creating a instance via the CodedOutputStream.CreateInstance - /// static factory. - /// - public interface ICodedOutputStream - { - /// - /// Writes any message initialization data needed to the output stream - /// - /// - /// This is primarily used by text formats and unnecessary for protobuffers' own - /// binary format. The API for MessageStart/End was added for consistent handling - /// of output streams regardless of the actual writer implementation. - /// - void WriteMessageStart(); - /// - /// Writes any message finalization data needed to the output stream - /// - /// - /// This is primarily used by text formats and unnecessary for protobuffers' own - /// binary format. The API for MessageStart/End was added for consistent handling - /// of output streams regardless of the actual writer implementation. - /// - void WriteMessageEnd(); - - /// - /// Indicates that all temporary buffers be written to the final output. - /// - void Flush(); - - /// - /// Writes a field value, including tag, to the stream. - /// - void WriteField(FieldType fieldType, int fieldNumber, string fieldName, object value); - - /// - /// Writes a double field value, including tag, to the stream. - /// - void WriteDouble(int fieldNumber, string fieldName, double value); - - /// - /// Writes a float field value, including tag, to the stream. - /// - void WriteFloat(int fieldNumber, string fieldName, float value); - - /// - /// Writes a uint64 field value, including tag, to the stream. - /// - void WriteUInt64(int fieldNumber, string fieldName, ulong value); - - /// - /// Writes an int64 field value, including tag, to the stream. - /// - void WriteInt64(int fieldNumber, string fieldName, long value); - - /// - /// Writes an int32 field value, including tag, to the stream. - /// - void WriteInt32(int fieldNumber, string fieldName, int value); - - /// - /// Writes a fixed64 field value, including tag, to the stream. - /// - void WriteFixed64(int fieldNumber, string fieldName, ulong value); - - /// - /// Writes a fixed32 field value, including tag, to the stream. - /// - void WriteFixed32(int fieldNumber, string fieldName, uint value); - - /// - /// Writes a bool field value, including tag, to the stream. - /// - void WriteBool(int fieldNumber, string fieldName, bool value); - - /// - /// Writes a string field value, including tag, to the stream. - /// - void WriteString(int fieldNumber, string fieldName, string value); - - /// - /// Writes a group field value, including tag, to the stream. - /// - void WriteGroup(int fieldNumber, string fieldName, IMessage value); - - /// - /// Writes a message field value, including tag, to the stream. - /// - void WriteMessage(int fieldNumber, string fieldName, IMessage value); - - /// - /// Writes a byte array field value, including tag, to the stream. - /// - void WriteBytes(int fieldNumber, string fieldName, ByteString value); - - /// - /// Writes a UInt32 field value, including tag, to the stream. - /// - void WriteUInt32(int fieldNumber, string fieldName, uint value); - - /// - /// Writes an enum field value, including tag, to the stream. - /// - void WriteEnum(int fieldNumber, string fieldName, int value); - - /// - /// Writes a fixed 32-bit field value, including tag, to the stream. - /// - void WriteSFixed32(int fieldNumber, string fieldName, int value); - - /// - /// Writes a signed fixed 64-bit field value, including tag, to the stream. - /// - void WriteSFixed64(int fieldNumber, string fieldName, long value); - - /// - /// Writes a signed 32-bit field value, including tag, to the stream. - /// - void WriteSInt32(int fieldNumber, string fieldName, int value); - - /// - /// Writes a signed 64-bit field value, including tag, to the stream. - /// - void WriteSInt64(int fieldNumber, string fieldName, long value); - - /// - /// Writes a repeated field value, including tag(s), to the stream. - /// - void WriteArray(FieldType fieldType, int fieldNumber, string fieldName, IEnumerable list); - - /// - /// Writes a repeated group value, including tag(s), to the stream. - /// - void WriteGroupArray(int fieldNumber, string fieldName, RepeatedField list) - where T : IMessage; - - /// - /// Writes a repeated message value, including tag(s), to the stream. - /// - void WriteMessageArray(int fieldNumber, string fieldName, RepeatedField list) - where T : IMessage; - - /// - /// Writes a repeated string value, including tag(s), to the stream. - /// - void WriteStringArray(int fieldNumber, string fieldName, RepeatedField list); - - /// - /// Writes a repeated ByteString value, including tag(s), to the stream. - /// - void WriteBytesArray(int fieldNumber, string fieldName, RepeatedField list); - - /// - /// Writes a repeated boolean value, including tag(s), to the stream. - /// - void WriteBoolArray(int fieldNumber, string fieldName, RepeatedField list); - - /// - /// Writes a repeated Int32 value, including tag(s), to the stream. - /// - void WriteInt32Array(int fieldNumber, string fieldName, RepeatedField list); - - /// - /// Writes a repeated SInt32 value, including tag(s), to the stream. - /// - void WriteSInt32Array(int fieldNumber, string fieldName, RepeatedField list); - - /// - /// Writes a repeated UInt32 value, including tag(s), to the stream. - /// - void WriteUInt32Array(int fieldNumber, string fieldName, RepeatedField list); - - /// - /// Writes a repeated Fixed32 value, including tag(s), to the stream. - /// - void WriteFixed32Array(int fieldNumber, string fieldName, RepeatedField list); - - /// - /// Writes a repeated SFixed32 value, including tag(s), to the stream. - /// - void WriteSFixed32Array(int fieldNumber, string fieldName, RepeatedField list); - - /// - /// Writes a repeated Int64 value, including tag(s), to the stream. - /// - void WriteInt64Array(int fieldNumber, string fieldName, RepeatedField list); - - /// - /// Writes a repeated SInt64 value, including tag(s), to the stream. - /// - void WriteSInt64Array(int fieldNumber, string fieldName, RepeatedField list); - - /// - /// Writes a repeated UInt64 value, including tag(s), to the stream. - /// - void WriteUInt64Array(int fieldNumber, string fieldName, RepeatedField list); - - /// - /// Writes a repeated Fixed64 value, including tag(s), to the stream. - /// - void WriteFixed64Array(int fieldNumber, string fieldName, RepeatedField list); - - /// - /// Writes a repeated SFixed64 value, including tag(s), to the stream. - /// - void WriteSFixed64Array(int fieldNumber, string fieldName, RepeatedField list); - - /// - /// Writes a repeated Double value, including tag(s), to the stream. - /// - void WriteDoubleArray(int fieldNumber, string fieldName, RepeatedField list); - - /// - /// Writes a repeated Float value, including tag(s), to the stream. - /// - void WriteFloatArray(int fieldNumber, string fieldName, RepeatedField list); - - /// - /// Writes a repeated enumeration value of type T, including tag(s), to the stream. - /// - void WriteEnumArray(int fieldNumber, string fieldName, RepeatedField list) - where T : struct, IComparable, IFormattable; - - /// - /// Writes a packed repeated primitive, including tag and length, to the stream. - /// - void WritePackedArray(FieldType fieldType, int fieldNumber, string fieldName, IEnumerable list); - - /// - /// Writes a packed repeated boolean, including tag and length, to the stream. - /// - void WritePackedBoolArray(int fieldNumber, string fieldName, RepeatedField list); - - /// - /// Writes a packed repeated Int32, including tag and length, to the stream. - /// - void WritePackedInt32Array(int fieldNumber, string fieldName, RepeatedField list); - - /// - /// Writes a packed repeated SInt32, including tag and length, to the stream. - /// - void WritePackedSInt32Array(int fieldNumber, string fieldName, RepeatedField list); - - /// - /// Writes a packed repeated UInt32, including tag and length, to the stream. - /// - void WritePackedUInt32Array(int fieldNumber, string fieldName, RepeatedField list); - - /// - /// Writes a packed repeated Fixed32, including tag and length, to the stream. - /// - void WritePackedFixed32Array(int fieldNumber, string fieldName, RepeatedField list); - - /// - /// Writes a packed repeated SFixed32, including tag and length, to the stream. - /// - void WritePackedSFixed32Array(int fieldNumber, string fieldName, RepeatedField list); - - /// - /// Writes a packed repeated Int64, including tag and length, to the stream. - /// - void WritePackedInt64Array(int fieldNumber, string fieldName, RepeatedField list); - - /// - /// Writes a packed repeated SInt64, including tag and length, to the stream. - /// - void WritePackedSInt64Array(int fieldNumber, string fieldName, RepeatedField list); - - /// - /// Writes a packed repeated UInt64, including tag and length, to the stream. - /// - void WritePackedUInt64Array(int fieldNumber, string fieldName, RepeatedField list); - - /// - /// Writes a packed repeated Fixed64, including tag and length, to the stream. - /// - void WritePackedFixed64Array(int fieldNumber, string fieldName, RepeatedField list); - - /// - /// Writes a packed repeated SFixed64, including tag and length, to the stream. - /// - void WritePackedSFixed64Array(int fieldNumber, string fieldName, RepeatedField list); - - /// - /// Writes a packed repeated Double, including tag and length, to the stream. - /// - void WritePackedDoubleArray(int fieldNumber, string fieldName, RepeatedField list); - - /// - /// Writes a packed repeated Float, including tag and length, to the stream. - /// - void WritePackedFloatArray(int fieldNumber, string fieldName, RepeatedField list); - - /// - /// Writes a packed repeated enumeration of type T, including tag and length, to the stream. - /// - void WritePackedEnumArray(int fieldNumber, string fieldName, RepeatedField list) - where T : struct, IComparable, IFormattable; - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/IMessage.cs b/csharp/src/ProtocolBuffers/IMessage.cs index 4e06f6e8..55b6fc5d 100644 --- a/csharp/src/ProtocolBuffers/IMessage.cs +++ b/csharp/src/ProtocolBuffers/IMessage.cs @@ -51,8 +51,8 @@ namespace Google.Protobuf public interface IMessage { - void MergeFrom(ICodedInputStream input); - void WriteTo(ICodedOutputStream output); + void MergeFrom(CodedInputStream input); + void WriteTo(CodedOutputStream output); int CalculateSize(); } diff --git a/csharp/src/ProtocolBuffers/MessageParser.cs b/csharp/src/ProtocolBuffers/MessageParser.cs index 399a9043..722435cc 100644 --- a/csharp/src/ProtocolBuffers/MessageParser.cs +++ b/csharp/src/ProtocolBuffers/MessageParser.cs @@ -47,7 +47,7 @@ namespace Google.Protobuf return message; } - public T ParseFrom(ICodedInputStream input) + public T ParseFrom(CodedInputStream input) { T message = factory(); message.MergeFrom(input); diff --git a/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj b/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj index efd387a2..3a07e87f 100644 --- a/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj +++ b/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj @@ -93,8 +93,6 @@ - - diff --git a/src/google/protobuf/compiler/csharp/csharp_enum_field.cc b/src/google/protobuf/compiler/csharp/csharp_enum_field.cc index 3494b228..19fd50cf 100644 --- a/src/google/protobuf/compiler/csharp/csharp_enum_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_enum_field.cc @@ -54,17 +54,14 @@ EnumFieldGenerator::~EnumFieldGenerator() { } void EnumFieldGenerator::GenerateParsingCode(io::Printer* printer) { - // TODO(jonskeet): Get rid of the temporary variable when we sanitize CodedInputStream not to use ref. printer->Print(variables_, - "int tmp = 0;\n" - "input.ReadEnum(ref tmp);\n" - "$name$_ = ($type_name$) tmp;"); + "$name$_ = ($type_name$) input.ReadEnum();\n"); } void EnumFieldGenerator::GenerateSerializationCode(io::Printer* printer) { printer->Print(variables_, "if ($has_property_check$) {\n" - " output.WriteEnum($number$, fieldNames[$field_ordinal$], (int) $property_name$);\n" + " output.WriteEnum($number$, (int) $property_name$);\n" "}\n"); } @@ -88,18 +85,15 @@ void EnumOneofFieldGenerator::GenerateParsingCode(io::Printer* printer) { // TODO(jonskeet): What about if we read the default value? printer->Print( variables_, - "int enumValue = 0;\n" - "if(input.ReadEnum(ref enumValue)) {\n" - " $oneof_name$_ = enumValue;\n" - " $oneof_name$Case_ = $oneof_property_name$OneofCase.$property_name$;\n" - "}\n"); + "$oneof_name$_ = input.ReadEnum();\n" + "$oneof_name$Case_ = $oneof_property_name$OneofCase.$property_name$;\n"); } void EnumOneofFieldGenerator::GenerateSerializationCode(io::Printer* printer) { printer->Print( variables_, "if ($has_property_check$) {\n" - " output.WriteEnum($number$, fieldNames[$field_ordinal$], (int) $property_name$);\n" + " output.WriteEnum($number$, (int) $property_name$);\n" "}\n"); } diff --git a/src/google/protobuf/compiler/csharp/csharp_message.cc b/src/google/protobuf/compiler/csharp/csharp_message.cc index b5929bcd..aca68fb7 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message.cc @@ -350,9 +350,8 @@ void MessageGenerator::GenerateFrameworkMethods(io::Printer* printer) { void MessageGenerator::GenerateMessageSerializationMethods(io::Printer* printer) { printer->Print( - "public void WriteTo(pb::ICodedOutputStream output) {\n"); + "public void WriteTo(pb::CodedOutputStream output) {\n"); printer->Indent(); - printer->Print("string[] fieldNames = _fieldNames;\n"); // Serialize all the fields for (int i = 0; i < fields_by_number().size(); i++) { @@ -423,21 +422,13 @@ void MessageGenerator::GenerateMergingMethods(io::Printer* printer) { } printer->Outdent(); printer->Print("}\n\n"); - printer->Print("public void MergeFrom(pb::ICodedInputStream input) {\n"); + printer->Print("public void MergeFrom(pb::CodedInputStream input) {\n"); printer->Indent(); printer->Print( "uint tag;\n" - "string fieldName;\n" - "while (input.ReadTag(out tag, out fieldName)) {\n"); + "while (input.ReadTag(out tag)) {\n" + " switch(tag) {\n"); printer->Indent(); - printer->Print( - "if (tag == 0 && fieldName != null) {\n" - " int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal);\n" - " if (fieldOrdinal >= 0) {\n" - " tag = _fieldTags[fieldOrdinal];\n" - " }\n" - "}\n" - "switch(tag) {\n"); printer->Indent(); printer->Print( "case 0:\n" // 0 signals EOF / limit reached diff --git a/src/google/protobuf/compiler/csharp/csharp_message_field.cc b/src/google/protobuf/compiler/csharp/csharp_message_field.cc index 4b7ac88f..804a5ae2 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message_field.cc @@ -87,6 +87,7 @@ void MessageFieldGenerator::GenerateParsingCode(io::Printer* printer) { "if ($has_not_property_check$) {\n" " $name$_ = new $type_name$();\n" "}\n" + // TODO(jonskeet): Do we really need merging behaviour like this? "input.ReadMessage($name$_);\n"); // No need to support TYPE_GROUP... } @@ -95,7 +96,7 @@ void MessageFieldGenerator::GenerateSerializationCode(io::Printer* printer) { printer->Print( variables_, "if ($has_property_check$) {\n" - " output.WriteMessage($number$, fieldNames[$field_ordinal$], $property_name$);\n" + " output.WriteMessage($number$, $property_name$);\n" "}\n"); } diff --git a/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc b/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc index f2b66a00..cb7e1b5a 100644 --- a/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc @@ -73,7 +73,6 @@ void PrimitiveFieldGenerator::GenerateMembers(io::Printer* printer) { printer->Print( variables_, " set { $name$_ = value; }\n"); - } else { printer->Print( variables_, @@ -93,14 +92,14 @@ void PrimitiveFieldGenerator::GenerateMergingCode(io::Printer* printer) { void PrimitiveFieldGenerator::GenerateParsingCode(io::Printer* printer) { printer->Print( variables_, - "input.Read$capitalized_type_name$(ref $name$_);\n"); + "$name$_ = input.Read$capitalized_type_name$();\n"); } void PrimitiveFieldGenerator::GenerateSerializationCode(io::Printer* printer) { printer->Print( variables_, "if ($has_property_check$) {\n" - " output.Write$capitalized_type_name$($number$, fieldNames[$field_ordinal$], $property_name$);\n" + " output.Write$capitalized_type_name$($number$, $property_name$);\n" "}\n"); } @@ -169,13 +168,10 @@ void PrimitiveOneofFieldGenerator::WriteToString(io::Printer* printer) { void PrimitiveOneofFieldGenerator::GenerateParsingCode(io::Printer* printer) { // TODO(jonskeet): What if the value we read is the default value for the type? - printer->Print( - variables_, - "$type_name$ value = $default_value$;\n" - "if (input.Read$capitalized_type_name$(ref value)) {\n" - " $oneof_name$_ = value;\n" - " $oneof_name$Case_ = $oneof_property_name$OneofCase.$property_name$;\n" - "}\n"); + printer->Print( + variables_, + "$oneof_name$_ = input.Read$capitalized_type_name$()\n;" + "$oneof_name$Case_ = $oneof_property_name$OneofCase.$property_name$;\n"); } } // namespace csharp diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc b/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc index 937d675a..15e92ab9 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc @@ -76,7 +76,7 @@ void RepeatedEnumFieldGenerator::GenerateMergingCode(io::Printer* printer) { void RepeatedEnumFieldGenerator::GenerateParsingCode(io::Printer* printer) { printer->Print( variables_, - "input.ReadEnumArray<$type_name$>(tag, fieldName, $name$_);\n"); + "input.ReadEnumArray<$type_name$>(tag, $name$_);\n"); } void RepeatedEnumFieldGenerator::GenerateSerializationCode(io::Printer* printer) { @@ -84,7 +84,7 @@ void RepeatedEnumFieldGenerator::GenerateSerializationCode(io::Printer* printer) // The Write* call should make that cheap though - no need to generate it every time. printer->Print( variables_, - "output.Write$packed$EnumArray($number$, fieldNames[$field_ordinal$], $name$_);\n"); + "output.Write$packed$EnumArray($number$, $name$_);\n"); } void RepeatedEnumFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) { diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc b/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc index 963f841e..6228aa67 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc @@ -75,7 +75,7 @@ void RepeatedMessageFieldGenerator::GenerateMergingCode(io::Printer* printer) { void RepeatedMessageFieldGenerator::GenerateParsingCode(io::Printer* printer) { printer->Print( variables_, - "input.ReadMessageArray(tag, fieldName, $name$_, $type_name$.Parser);\n"); + "input.ReadMessageArray(tag, $name$_, $type_name$.Parser);\n"); } void RepeatedMessageFieldGenerator::GenerateSerializationCode(io::Printer* printer) { @@ -83,7 +83,7 @@ void RepeatedMessageFieldGenerator::GenerateSerializationCode(io::Printer* print // The Write* call should make that cheap though - no need to generate it every time. printer->Print( variables_, - "output.WriteMessageArray($number$, fieldNames[$field_ordinal$], $name$_);\n"); + "output.WriteMessageArray($number$, $name$_);\n"); } void RepeatedMessageFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) { diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc b/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc index 0a91c3c6..f62ea09d 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc @@ -74,7 +74,7 @@ void RepeatedPrimitiveFieldGenerator::GenerateMergingCode(io::Printer* printer) void RepeatedPrimitiveFieldGenerator::GenerateParsingCode(io::Printer* printer) { printer->Print(variables_, - "input.Read$capitalized_type_name$Array(tag, fieldName, $name$_);\n"); + "input.Read$capitalized_type_name$Array(tag, $name$_);\n"); } void RepeatedPrimitiveFieldGenerator::GenerateSerializationCode( @@ -83,10 +83,10 @@ void RepeatedPrimitiveFieldGenerator::GenerateSerializationCode( // The Write* call should make that cheap though - no need to generate it every time. if (descriptor_->is_packed()) { printer->Print(variables_, - "output.WritePacked$capitalized_type_name$Array($number$, fieldNames[$field_ordinal$], $name$_);\n"); + "output.WritePacked$capitalized_type_name$Array($number$, $name$_);\n"); } else { printer->Print(variables_, - "output.Write$capitalized_type_name$Array($number$, fieldNames[$field_ordinal$], $name$_);\n"); + "output.Write$capitalized_type_name$Array($number$, $name$_);\n"); } } -- cgit v1.2.3 From eb70bd0b6019dc957eb36e9cefb1c1e9e5a5a890 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Fri, 12 Jun 2015 09:53:44 +0100 Subject: Update the AddressBook tutorial to reflect the mutable design. --- csharp/generate_protos.sh | 44 +- csharp/src/AddressBook/AddPerson.cs | 19 +- csharp/src/AddressBook/Addressbook.cs | 1225 +++++++-------------------------- csharp/src/AddressBook/ListPeople.cs | 8 +- csharp/src/AddressBook/SampleUsage.cs | 45 +- 5 files changed, 287 insertions(+), 1054 deletions(-) diff --git a/csharp/generate_protos.sh b/csharp/generate_protos.sh index 9e89bf26..d239fcb2 100755 --- a/csharp/generate_protos.sh +++ b/csharp/generate_protos.sh @@ -42,52 +42,14 @@ $PROTOC -Isrc --csharp_out=csharp/src/ProtocolBuffers/DescriptorProtos \ src/google/protobuf/descriptor_proto_file.proto rm src/google/protobuf/descriptor_proto_file.proto - -# ProtocolBuffers.Test protos $PROTOC -Isrc --csharp_out=csharp/src/ProtocolBuffers.Test/TestProtos \ - src/google/protobuf/unittest.proto \ - src/google/protobuf/unittest_custom_options.proto \ - src/google/protobuf/unittest_drop_unknown_fields.proto \ - src/google/protobuf/unittest_enormous_descriptor.proto \ - src/google/protobuf/unittest_import.proto \ - src/google/protobuf/unittest_import_public.proto \ - src/google/protobuf/unittest_mset.proto \ - src/google/protobuf/unittest_optimize_for.proto \ - src/google/protobuf/unittest_no_field_presence.proto \ - src/google/protobuf/unknown_enum_test.proto + src/google/protobuf/unittest_proto3.proto \ + src/google/protobuf/unittest_import_proto3.proto \ + src/google/protobuf/unittest_import_public_proto3.proto $PROTOC -Icsharp/protos/extest --csharp_out=csharp/src/ProtocolBuffers.Test/TestProtos \ - csharp/protos/extest/unittest_extras_xmltest.proto \ csharp/protos/extest/unittest_issues.proto -$PROTOC -Ibenchmarks --csharp_out=csharp/src/ProtocolBuffers.Test/TestProtos \ - benchmarks/google_size.proto \ - benchmarks/google_speed.proto - -# ProtocolBuffersLite.Test protos -$PROTOC -Isrc --csharp_out=csharp/src/ProtocolBuffersLite.Test/TestProtos \ - src/google/protobuf/unittest.proto \ - src/google/protobuf/unittest_import.proto \ - src/google/protobuf/unittest_import_lite.proto \ - src/google/protobuf/unittest_import_public.proto \ - src/google/protobuf/unittest_import_public_lite.proto \ - src/google/protobuf/unittest_lite.proto \ - src/google/protobuf/unittest_lite_imports_nonlite.proto - -$PROTOC -Icsharp/protos/extest --csharp_out=csharp/src/ProtocolBuffersLite.Test/TestProtos \ - csharp/protos/extest/unittest_extras_full.proto \ - csharp/protos/extest/unittest_extras_lite.proto - -# TODO(jonskeet): Remove fixup; see issue #307 -sed -i -e 's/RepeatedFieldsGenerator\.Group/RepeatedFieldsGenerator.Types.Group/g' \ - csharp/src/ProtocolBuffers.Test/TestProtos/Unittest.cs \ - csharp/src/ProtocolBuffersLite.Test/TestProtos/Unittest.cs \ - csharp/src/ProtocolBuffersLite.Test/TestProtos/UnittestLite.cs - -# TODO(jonskeet): Remove fixup -sed -i -e 's/DescriptorProtos\.Descriptor\./DescriptorProtos.DescriptorProtoFile./g' \ - csharp/src/ProtocolBuffers.Test/TestProtos/UnittestCustomOptions.cs - # AddressBook sample protos $PROTOC -Iexamples --csharp_out=csharp/src/AddressBook \ examples/addressbook.proto diff --git a/csharp/src/AddressBook/AddPerson.cs b/csharp/src/AddressBook/AddPerson.cs index 462b0c56..630108cf 100644 --- a/csharp/src/AddressBook/AddPerson.cs +++ b/csharp/src/AddressBook/AddPerson.cs @@ -36,6 +36,7 @@ using System; using System.IO; +using Google.Protobuf; namespace Google.ProtocolBuffers.Examples.AddressBook { @@ -46,7 +47,7 @@ namespace Google.ProtocolBuffers.Examples.AddressBook /// private static Person PromptForAddress(TextReader input, TextWriter output) { - Person.Builder person = Person.CreateBuilder(); + Person person = new Person(); output.Write("Enter person ID: "); person.Id = int.Parse(input.ReadLine()); @@ -70,8 +71,7 @@ namespace Google.ProtocolBuffers.Examples.AddressBook break; } - Person.Types.PhoneNumber.Builder phoneNumber = - Person.Types.PhoneNumber.CreateBuilder().SetNumber(number); + Person.Types.PhoneNumber phoneNumber = new Person.Types.PhoneNumber { Number = number }; output.Write("Is this a mobile, home, or work phone? "); String type = input.ReadLine(); @@ -91,9 +91,9 @@ namespace Google.ProtocolBuffers.Examples.AddressBook break; } - person.AddPhone(phoneNumber); + person.Phone.Add(phoneNumber); } - return person.Build(); + return person; } /// @@ -108,27 +108,28 @@ namespace Google.ProtocolBuffers.Examples.AddressBook return -1; } - AddressBook.Builder addressBook = AddressBook.CreateBuilder(); + AddressBook addressBook; if (File.Exists(args[0])) { using (Stream file = File.OpenRead(args[0])) { - addressBook.MergeFrom(file); + addressBook = AddressBook.Parser.ParseFrom(file); } } else { Console.WriteLine("{0}: File not found. Creating a new file.", args[0]); + addressBook = new AddressBook(); } // Add an address. - addressBook.AddPerson(PromptForAddress(Console.In, Console.Out)); + addressBook.Person.Add(PromptForAddress(Console.In, Console.Out)); // Write the new address book back to disk. using (Stream output = File.OpenWrite(args[0])) { - addressBook.Build().WriteTo(output); + addressBook.WriteTo(output); } return 0; } diff --git a/csharp/src/AddressBook/Addressbook.cs b/csharp/src/AddressBook/Addressbook.cs index 58ad28ad..5b513982 100644 --- a/csharp/src/AddressBook/Addressbook.cs +++ b/csharp/src/AddressBook/Addressbook.cs @@ -3,26 +3,22 @@ #pragma warning disable 1591, 0612, 3021 #region Designer generated code -using pb = global::Google.ProtocolBuffers; -using pbc = global::Google.ProtocolBuffers.Collections; -using pbd = global::Google.ProtocolBuffers.Descriptors; +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbd = global::Google.Protobuf.Descriptors; using scg = global::System.Collections.Generic; namespace Google.ProtocolBuffers.Examples.AddressBook { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class Addressbook { - #region Extension registration - public static void RegisterAllExtensions(pb::ExtensionRegistry registry) { - } - #endregion #region Static variables internal static pbd::MessageDescriptor internal__static_tutorial_Person__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_tutorial_Person__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_tutorial_Person__FieldAccessorTable; internal static pbd::MessageDescriptor internal__static_tutorial_Person_PhoneNumber__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_tutorial_Person_PhoneNumber__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_tutorial_Person_PhoneNumber__FieldAccessorTable; internal static pbd::MessageDescriptor internal__static_tutorial_AddressBook__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_tutorial_AddressBook__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_tutorial_AddressBook__FieldAccessorTable; #endregion #region Descriptor public static pbd::FileDescriptor Descriptor { @@ -46,19 +42,16 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { descriptor = root; internal__static_tutorial_Person__Descriptor = Descriptor.MessageTypes[0]; internal__static_tutorial_Person__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_tutorial_Person__Descriptor, + new pb::FieldAccess.FieldAccessorTable(internal__static_tutorial_Person__Descriptor, new string[] { "Name", "Id", "Email", "Phone", }); internal__static_tutorial_Person_PhoneNumber__Descriptor = internal__static_tutorial_Person__Descriptor.NestedTypes[0]; internal__static_tutorial_Person_PhoneNumber__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_tutorial_Person_PhoneNumber__Descriptor, + new pb::FieldAccess.FieldAccessorTable(internal__static_tutorial_Person_PhoneNumber__Descriptor, new string[] { "Number", "Type", }); internal__static_tutorial_AddressBook__Descriptor = Descriptor.MessageTypes[1]; internal__static_tutorial_AddressBook__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_tutorial_AddressBook__Descriptor, + new pb::FieldAccess.FieldAccessorTable(internal__static_tutorial_AddressBook__Descriptor, new string[] { "Person", }); - pb::ExtensionRegistry registry = pb::ExtensionRegistry.CreateInstance(); - RegisterAllExtensions(registry); - return registry; }; pbd::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, new pbd::FileDescriptor[] { @@ -69,1086 +62,368 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { } #region Messages [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Person : pb::GeneratedMessage { - private Person() { } - private static readonly Person defaultInstance = new Person().MakeReadOnly(); - private static readonly string[] _personFieldNames = new string[] { "email", "id", "name", "phone" }; - private static readonly uint[] _personFieldTags = new uint[] { 26, 16, 10, 34 }; - public static Person DefaultInstance { - get { return defaultInstance; } - } - - public override Person DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override Person ThisMessage { - get { return this; } - } + public sealed partial class Person : pb::IMessage, global::System.IEquatable { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Person()); + public static pb::MessageParser Parser { get { return _parser; } } + private static readonly string[] _fieldNames = new string[] { "email", "id", "name", "phone" }; + private static readonly uint[] _fieldTags = new uint[] { 26, 16, 10, 34 }; public static pbd::MessageDescriptor Descriptor { get { return global::Google.ProtocolBuffers.Examples.AddressBook.Addressbook.internal__static_tutorial_Person__Descriptor; } } - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.ProtocolBuffers.Examples.AddressBook.Addressbook.internal__static_tutorial_Person__FieldAccessorTable; } } - #region Nested types - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class Types { - public enum PhoneType { - MOBILE = 0, - HOME = 1, - WORK = 2, - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class PhoneNumber : pb::GeneratedMessage { - private PhoneNumber() { } - private static readonly PhoneNumber defaultInstance = new PhoneNumber().MakeReadOnly(); - private static readonly string[] _phoneNumberFieldNames = new string[] { "number", "type" }; - private static readonly uint[] _phoneNumberFieldTags = new uint[] { 10, 16 }; - public static PhoneNumber DefaultInstance { - get { return defaultInstance; } - } - - public override PhoneNumber DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override PhoneNumber ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.Examples.AddressBook.Addressbook.internal__static_tutorial_Person_PhoneNumber__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.Examples.AddressBook.Addressbook.internal__static_tutorial_Person_PhoneNumber__FieldAccessorTable; } - } - - public const int NumberFieldNumber = 1; - private bool hasNumber; - private string number_ = ""; - public bool HasNumber { - get { return hasNumber; } - } - public string Number { - get { return number_; } - } - - public const int TypeFieldNumber = 2; - private bool hasType; - private global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneType type_ = global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneType.HOME; - public bool HasType { - get { return hasType; } - } - public global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneType Type { - get { return type_; } - } - - public override bool IsInitialized { - get { - if (!hasNumber) return false; - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _phoneNumberFieldNames; - if (hasNumber) { - output.WriteString(1, field_names[0], Number); - } - if (hasType) { - output.WriteEnum(2, field_names[1], (int) Type, Type); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasNumber) { - size += pb::CodedOutputStream.ComputeStringSize(1, Number); - } - if (hasType) { - size += pb::CodedOutputStream.ComputeEnumSize(2, (int) Type); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static PhoneNumber ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static PhoneNumber ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static PhoneNumber ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static PhoneNumber ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static PhoneNumber ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static PhoneNumber ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static PhoneNumber ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static PhoneNumber ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static PhoneNumber ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static PhoneNumber ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private PhoneNumber MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(PhoneNumber prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(PhoneNumber cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private PhoneNumber result; - - private PhoneNumber PrepareBuilder() { - if (resultIsReadOnly) { - PhoneNumber original = result; - result = new PhoneNumber(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override PhoneNumber MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneNumber.Descriptor; } - } - - public override PhoneNumber DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneNumber.DefaultInstance; } - } - - public override PhoneNumber BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is PhoneNumber) { - return MergeFrom((PhoneNumber) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(PhoneNumber other) { - if (other == global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneNumber.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasNumber) { - Number = other.Number; - } - if (other.HasType) { - Type = other.Type; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_phoneNumberFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _phoneNumberFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 10: { - result.hasNumber = input.ReadString(ref result.number_); - break; - } - case 16: { - object unknown; - if(input.ReadEnum(ref result.type_, out unknown)) { - result.hasType = true; - } else if(unknown is int) { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - unknownFields.MergeVarintField(2, (ulong)(int)unknown); - } - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasNumber { - get { return result.hasNumber; } - } - public string Number { - get { return result.Number; } - set { SetNumber(value); } - } - public Builder SetNumber(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasNumber = true; - result.number_ = value; - return this; - } - public Builder ClearNumber() { - PrepareBuilder(); - result.hasNumber = false; - result.number_ = ""; - return this; - } - - public bool HasType { - get { return result.hasType; } - } - public global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneType Type { - get { return result.Type; } - set { SetType(value); } - } - public Builder SetType(global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneType value) { - PrepareBuilder(); - result.hasType = true; - result.type_ = value; - return this; - } - public Builder ClearType() { - PrepareBuilder(); - result.hasType = false; - result.type_ = global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneType.HOME; - return this; - } - } - static PhoneNumber() { - object.ReferenceEquals(global::Google.ProtocolBuffers.Examples.AddressBook.Addressbook.Descriptor, null); - } - } - + public Person() { } + public Person(Person other) { + MergeFrom(other); } - #endregion - public const int NameFieldNumber = 1; - private bool hasName; private string name_ = ""; - public bool HasName { - get { return hasName; } - } public string Name { get { return name_; } + set { name_ = value ?? ""; } } + public const int IdFieldNumber = 2; - private bool hasId; private int id_; - public bool HasId { - get { return hasId; } - } public int Id { get { return id_; } + set { id_ = value; } } + public const int EmailFieldNumber = 3; - private bool hasEmail; private string email_ = ""; - public bool HasEmail { - get { return hasEmail; } - } public string Email { get { return email_; } + set { email_ = value ?? ""; } } + public const int PhoneFieldNumber = 4; - private pbc::PopsicleList phone_ = new pbc::PopsicleList(); - public scg::IList PhoneList { + private readonly pbc::RepeatedField phone_ = new pbc::RepeatedField(); + public pbc::RepeatedField Phone { get { return phone_; } } - public int PhoneCount { - get { return phone_.Count; } - } - public global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneNumber GetPhone(int index) { - return phone_[index]; + + public override bool Equals(object other) { + return Equals(other as Person); } - public override bool IsInitialized { - get { - if (!hasName) return false; - if (!hasId) return false; - foreach (global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneNumber element in PhoneList) { - if (!element.IsInitialized) return false; - } + public bool Equals(Person other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { return true; } + if (Name != other.Name) return false; + if (Id != other.Id) return false; + if (Email != other.Email) return false; + if(!phone_.Equals(other.phone_)) return false; + return true; } - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _personFieldNames; - if (hasName) { - output.WriteString(1, field_names[2], Name); - } - if (hasId) { - output.WriteInt32(2, field_names[1], Id); - } - if (hasEmail) { - output.WriteString(3, field_names[0], Email); - } - if (phone_.Count > 0) { - output.WriteMessageArray(4, field_names[3], phone_); - } - UnknownFields.WriteTo(output); + public override int GetHashCode() { + int hash = 0; + if (Name != "") hash ^= Name.GetHashCode(); + if (Id != 0) hash ^= Id.GetHashCode(); + if (Email != "") hash ^= Email.GetHashCode(); + hash ^= phone_.GetHashCode(); + return hash; } - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); + public void WriteTo(pb::CodedOutputStream output) { + if (Name != "") { + output.WriteString(1, Name); + } + if (Id != 0) { + output.WriteInt32(2, Id); } + if (Email != "") { + output.WriteString(3, Email); + } + output.WriteMessageArray(4, phone_); } - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasName) { + public int CalculateSize() { + int size = 0; + if (Name != "") { size += pb::CodedOutputStream.ComputeStringSize(1, Name); } - if (hasId) { + if (Id != 0) { size += pb::CodedOutputStream.ComputeInt32Size(2, Id); } - if (hasEmail) { + if (Email != "") { size += pb::CodedOutputStream.ComputeStringSize(3, Email); } - foreach (global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneNumber element in PhoneList) { + foreach (global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneNumber element in phone_) { size += pb::CodedOutputStream.ComputeMessageSize(4, element); } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; return size; } - public static Person ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static Person ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static Person ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static Person ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static Person ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static Person ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static Person ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static Person ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static Person ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static Person ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private Person MakeReadOnly() { - phone_.MakeReadOnly(); - return this; + public void MergeFrom(Person other) { + if (other == null) { + return; + } + if (other.Name != "") { + Name = other.Name; + } + if (other.Id != 0) { + Id = other.Id; + } + if (other.Email != "") { + Email = other.Email; + } + phone_.Add(other.phone_); } - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(Person prototype) { - return new Builder(prototype); + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + name_ = input.ReadString(); + break; + } + case 16: { + id_ = input.ReadInt32(); + break; + } + case 26: { + email_ = input.ReadString(); + break; + } + case 34: { + input.ReadMessageArray(tag, phone_, global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneNumber.Parser); + break; + } + } + } } + #region Nested types [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(Person cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; + public static partial class Types { + public enum PhoneType { + MOBILE = 0, + HOME = 1, + WORK = 2, } - private bool resultIsReadOnly; - private Person result; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class PhoneNumber : pb::IMessage, global::System.IEquatable { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new PhoneNumber()); + public static pb::MessageParser Parser { get { return _parser; } } - private Person PrepareBuilder() { - if (resultIsReadOnly) { - Person original = result; - result = new Person(); - resultIsReadOnly = false; - MergeFrom(original); + private static readonly string[] _fieldNames = new string[] { "number", "type" }; + private static readonly uint[] _fieldTags = new uint[] { 10, 16 }; + public static pbd::MessageDescriptor Descriptor { + get { return global::Google.ProtocolBuffers.Examples.AddressBook.Addressbook.internal__static_tutorial_Person_PhoneNumber__Descriptor; } } - return result; - } - public override bool IsInitialized { - get { return result.IsInitialized; } - } + public pb::FieldAccess.FieldAccessorTable Fields { + get { return global::Google.ProtocolBuffers.Examples.AddressBook.Addressbook.internal__static_tutorial_Person_PhoneNumber__FieldAccessorTable; } + } - protected override Person MessageBeingBuilt { - get { return PrepareBuilder(); } - } + public PhoneNumber() { } + public PhoneNumber(PhoneNumber other) { + MergeFrom(other); + } + public const int NumberFieldNumber = 1; + private string number_ = ""; + public string Number { + get { return number_; } + set { number_ = value ?? ""; } + } - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); + public const int TypeFieldNumber = 2; + private global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneType type_ = global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneType.HOME; + public global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneType Type { + get { return type_; } + set { type_ = value; } } - } - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.Examples.AddressBook.Person.Descriptor; } - } - - public override Person DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.Examples.AddressBook.Person.DefaultInstance; } - } - public override Person BuildPartial() { - if (resultIsReadOnly) { - return result; + public override bool Equals(object other) { + return Equals(other as PhoneNumber); } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - public override Builder MergeFrom(pb::IMessage other) { - if (other is Person) { - return MergeFrom((Person) other); - } else { - base.MergeFrom(other); - return this; + public bool Equals(PhoneNumber other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Number != other.Number) return false; + if (Type != other.Type) return false; + return true; } - } - public override Builder MergeFrom(Person other) { - if (other == global::Google.ProtocolBuffers.Examples.AddressBook.Person.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasName) { - Name = other.Name; + public override int GetHashCode() { + int hash = 0; + if (Number != "") hash ^= Number.GetHashCode(); + if (Type != global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneType.HOME) hash ^= Type.GetHashCode(); + return hash; } - if (other.HasId) { - Id = other.Id; + + public void WriteTo(pb::CodedOutputStream output) { + if (Number != "") { + output.WriteString(1, Number); + } + if (Type != global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneType.HOME) { + output.WriteEnum(2, (int) Type); + } } - if (other.HasEmail) { - Email = other.Email; + + public int CalculateSize() { + int size = 0; + if (Number != "") { + size += pb::CodedOutputStream.ComputeStringSize(1, Number); + } + if (Type != global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneType.HOME) { + size += pb::CodedOutputStream.ComputeEnumSize(2, (int) Type); + } + return size; } - if (other.phone_.Count != 0) { - result.phone_.Add(other.phone_); + public void MergeFrom(PhoneNumber other) { + if (other == null) { + return; + } + if (other.Number != "") { + Number = other.Number; + } + if (other.Type != global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneType.HOME) { + Type = other.Type; + } } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_personFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _personFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; } - return this; + break; + case 10: { + number_ = input.ReadString(); + break; } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); + case 16: { + type_ = (global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneType) input.ReadEnum(); + break; } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 10: { - result.hasName = input.ReadString(ref result.name_); - break; - } - case 16: { - result.hasId = input.ReadInt32(ref result.id_); - break; - } - case 26: { - result.hasEmail = input.ReadString(ref result.email_); - break; - } - case 34: { - input.ReadMessageArray(tag, field_name, result.phone_, global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneNumber.DefaultInstance, extensionRegistry); - break; } } } - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; } - - public bool HasName { - get { return result.hasName; } - } - public string Name { - get { return result.Name; } - set { SetName(value); } - } - public Builder SetName(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasName = true; - result.name_ = value; - return this; - } - public Builder ClearName() { - PrepareBuilder(); - result.hasName = false; - result.name_ = ""; - return this; - } - - public bool HasId { - get { return result.hasId; } - } - public int Id { - get { return result.Id; } - set { SetId(value); } - } - public Builder SetId(int value) { - PrepareBuilder(); - result.hasId = true; - result.id_ = value; - return this; - } - public Builder ClearId() { - PrepareBuilder(); - result.hasId = false; - result.id_ = 0; - return this; - } - - public bool HasEmail { - get { return result.hasEmail; } - } - public string Email { - get { return result.Email; } - set { SetEmail(value); } - } - public Builder SetEmail(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasEmail = true; - result.email_ = value; - return this; - } - public Builder ClearEmail() { - PrepareBuilder(); - result.hasEmail = false; - result.email_ = ""; - return this; - } - - public pbc::IPopsicleList PhoneList { - get { return PrepareBuilder().phone_; } - } - public int PhoneCount { - get { return result.PhoneCount; } - } - public global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneNumber GetPhone(int index) { - return result.GetPhone(index); - } - public Builder SetPhone(int index, global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneNumber value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.phone_[index] = value; - return this; - } - public Builder SetPhone(int index, global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneNumber.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.phone_[index] = builderForValue.Build(); - return this; - } - public Builder AddPhone(global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneNumber value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.phone_.Add(value); - return this; - } - public Builder AddPhone(global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneNumber.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.phone_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangePhone(scg::IEnumerable values) { - PrepareBuilder(); - result.phone_.Add(values); - return this; - } - public Builder ClearPhone() { - PrepareBuilder(); - result.phone_.Clear(); - return this; - } - } - static Person() { - object.ReferenceEquals(global::Google.ProtocolBuffers.Examples.AddressBook.Addressbook.Descriptor, null); } + #endregion + } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class AddressBook : pb::GeneratedMessage { - private AddressBook() { } - private static readonly AddressBook defaultInstance = new AddressBook().MakeReadOnly(); - private static readonly string[] _addressBookFieldNames = new string[] { "person" }; - private static readonly uint[] _addressBookFieldTags = new uint[] { 10 }; - public static AddressBook DefaultInstance { - get { return defaultInstance; } - } - - public override AddressBook DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override AddressBook ThisMessage { - get { return this; } - } + public sealed partial class AddressBook : pb::IMessage, global::System.IEquatable { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new AddressBook()); + public static pb::MessageParser Parser { get { return _parser; } } + private static readonly string[] _fieldNames = new string[] { "person" }; + private static readonly uint[] _fieldTags = new uint[] { 10 }; public static pbd::MessageDescriptor Descriptor { get { return global::Google.ProtocolBuffers.Examples.AddressBook.Addressbook.internal__static_tutorial_AddressBook__Descriptor; } } - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.ProtocolBuffers.Examples.AddressBook.Addressbook.internal__static_tutorial_AddressBook__FieldAccessorTable; } } + public AddressBook() { } + public AddressBook(AddressBook other) { + MergeFrom(other); + } public const int PersonFieldNumber = 1; - private pbc::PopsicleList person_ = new pbc::PopsicleList(); - public scg::IList PersonList { + private readonly pbc::RepeatedField person_ = new pbc::RepeatedField(); + public pbc::RepeatedField Person { get { return person_; } } - public int PersonCount { - get { return person_.Count; } - } - public global::Google.ProtocolBuffers.Examples.AddressBook.Person GetPerson(int index) { - return person_[index]; + + public override bool Equals(object other) { + return Equals(other as AddressBook); } - public override bool IsInitialized { - get { - foreach (global::Google.ProtocolBuffers.Examples.AddressBook.Person element in PersonList) { - if (!element.IsInitialized) return false; - } + public bool Equals(AddressBook other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { return true; } + if(!person_.Equals(other.person_)) return false; + return true; } - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _addressBookFieldNames; - if (person_.Count > 0) { - output.WriteMessageArray(1, field_names[0], person_); - } - UnknownFields.WriteTo(output); + public override int GetHashCode() { + int hash = 0; + hash ^= person_.GetHashCode(); + return hash; } - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } + public void WriteTo(pb::CodedOutputStream output) { + output.WriteMessageArray(1, person_); } - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - foreach (global::Google.ProtocolBuffers.Examples.AddressBook.Person element in PersonList) { + public int CalculateSize() { + int size = 0; + foreach (global::Google.ProtocolBuffers.Examples.AddressBook.Person element in person_) { size += pb::CodedOutputStream.ComputeMessageSize(1, element); } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; return size; } - public static AddressBook ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static AddressBook ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static AddressBook ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static AddressBook ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static AddressBook ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static AddressBook ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static AddressBook ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static AddressBook ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static AddressBook ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static AddressBook ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private AddressBook MakeReadOnly() { - person_.MakeReadOnly(); - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(AddressBook prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(AddressBook cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private AddressBook result; - - private AddressBook PrepareBuilder() { - if (resultIsReadOnly) { - AddressBook original = result; - result = new AddressBook(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override AddressBook MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.Examples.AddressBook.AddressBook.Descriptor; } - } - - public override AddressBook DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.Examples.AddressBook.AddressBook.DefaultInstance; } - } - - public override AddressBook BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is AddressBook) { - return MergeFrom((AddressBook) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(AddressBook other) { - if (other == global::Google.ProtocolBuffers.Examples.AddressBook.AddressBook.DefaultInstance) return this; - PrepareBuilder(); - if (other.person_.Count != 0) { - result.person_.Add(other.person_); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); + public void MergeFrom(AddressBook other) { + if (other == null) { + return; } + person_.Add(other.person_); + } - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_addressBookFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _addressBookFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 10: { - input.ReadMessageArray(tag, field_name, result.person_, global::Google.ProtocolBuffers.Examples.AddressBook.Person.DefaultInstance, extensionRegistry); - break; + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; } + break; + case 10: { + input.ReadMessageArray(tag, person_, global::Google.ProtocolBuffers.Examples.AddressBook.Person.Parser); + break; } } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public pbc::IPopsicleList PersonList { - get { return PrepareBuilder().person_; } - } - public int PersonCount { - get { return result.PersonCount; } - } - public global::Google.ProtocolBuffers.Examples.AddressBook.Person GetPerson(int index) { - return result.GetPerson(index); - } - public Builder SetPerson(int index, global::Google.ProtocolBuffers.Examples.AddressBook.Person value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.person_[index] = value; - return this; - } - public Builder SetPerson(int index, global::Google.ProtocolBuffers.Examples.AddressBook.Person.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.person_[index] = builderForValue.Build(); - return this; - } - public Builder AddPerson(global::Google.ProtocolBuffers.Examples.AddressBook.Person value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.person_.Add(value); - return this; - } - public Builder AddPerson(global::Google.ProtocolBuffers.Examples.AddressBook.Person.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.person_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangePerson(scg::IEnumerable values) { - PrepareBuilder(); - result.person_.Add(values); - return this; - } - public Builder ClearPerson() { - PrepareBuilder(); - result.person_.Clear(); - return this; } } - static AddressBook() { - object.ReferenceEquals(global::Google.ProtocolBuffers.Examples.AddressBook.Addressbook.Descriptor, null); - } + } #endregion diff --git a/csharp/src/AddressBook/ListPeople.cs b/csharp/src/AddressBook/ListPeople.cs index fe6f52d8..9666c425 100644 --- a/csharp/src/AddressBook/ListPeople.cs +++ b/csharp/src/AddressBook/ListPeople.cs @@ -46,16 +46,16 @@ namespace Google.ProtocolBuffers.Examples.AddressBook /// private static void Print(AddressBook addressBook) { - foreach (Person person in addressBook.PersonList) + foreach (Person person in addressBook.Person) { Console.WriteLine("Person ID: {0}", person.Id); Console.WriteLine(" Name: {0}", person.Name); - if (person.HasEmail) + if (person.Email != "") { Console.WriteLine(" E-mail address: {0}", person.Email); } - foreach (Person.Types.PhoneNumber phoneNumber in person.PhoneList) + foreach (Person.Types.PhoneNumber phoneNumber in person.Phone) { switch (phoneNumber.Type) { @@ -94,7 +94,7 @@ namespace Google.ProtocolBuffers.Examples.AddressBook // Read the existing address book. using (Stream stream = File.OpenRead(args[0])) { - AddressBook addressBook = AddressBook.ParseFrom(stream); + AddressBook addressBook = AddressBook.Parser.ParseFrom(stream); Print(addressBook); } return 0; diff --git a/csharp/src/AddressBook/SampleUsage.cs b/csharp/src/AddressBook/SampleUsage.cs index 084b1655..c06188b4 100644 --- a/csharp/src/AddressBook/SampleUsage.cs +++ b/csharp/src/AddressBook/SampleUsage.cs @@ -1,4 +1,5 @@ -using System; +using Google.Protobuf; +using System; using System.IO; namespace Google.ProtocolBuffers.Examples.AddressBook @@ -8,37 +9,31 @@ namespace Google.ProtocolBuffers.Examples.AddressBook private static void Main() { byte[] bytes; - //Create a builder to start building a message - Person.Builder newContact = Person.CreateBuilder(); - //Set the primitive properties - newContact.SetId(1) - .SetName("Foo") - .SetEmail("foo@bar"); - //Now add an item to a list (repeating) field - newContact.AddPhone( - //Create the child message inline - Person.Types.PhoneNumber.CreateBuilder().SetNumber("555-1212").Build() - ); - //Now build the final message: - Person person = newContact.Build(); - //The builder is no longer valid (at least not now, scheduled for 2.4): - newContact = null; + // Create a new person + Person person = new Person + { + Id = 1, + Name = "Foo", + Email = "foo@bar", + Phone = { new Person.Types.PhoneNumber { Number = "555-1212" } } + }; using (MemoryStream stream = new MemoryStream()) { - //Save the person to a stream + // Save the person to a stream person.WriteTo(stream); bytes = stream.ToArray(); } - //Create another builder, merge the byte[], and build the message: - Person copy = Person.CreateBuilder().MergeFrom(bytes).Build(); + Person copy = Person.Parser.ParseFrom(bytes); - //A more streamlined approach might look like this: - bytes = AddressBook.CreateBuilder().AddPerson(copy).Build().ToByteArray(); - //And read the address book back again - AddressBook restored = AddressBook.CreateBuilder().MergeFrom(bytes).Build(); - //The message performs a deep-comparison on equality: - if (restored.PersonCount != 1 || !person.Equals(restored.PersonList[0])) + // A more streamlined approach might look like this: + bytes = copy.ToByteArray(); + // And read the address book back again + AddressBook restored = AddressBook.Parser.ParseFrom(bytes); + // The message performs a deep-comparison on equality: + if (restored.Person.Count != 1 || !person.Equals(restored.Person[0])) + { throw new ApplicationException("There is a bad person in here!"); + } } } } \ No newline at end of file -- cgit v1.2.3 From ca2adbd560baa504dd721fb68e81d911392b981d Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Fri, 12 Jun 2015 09:57:04 +0100 Subject: Fix incorrect handling of non-seekable streams. This mirrors commit 7c86bbbc7a3365c034d82173b38ec4427b98b3b2 in the pull request to the main protobuf project, but also reduces the size of the buffer created. (There's no point in creating a 1024-byte buffer if we're only skipping 5 bytes...) --- csharp/src/ProtocolBuffers/CodedInputStream.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/csharp/src/ProtocolBuffers/CodedInputStream.cs b/csharp/src/ProtocolBuffers/CodedInputStream.cs index cb47f1c2..17fcc64b 100644 --- a/csharp/src/ProtocolBuffers/CodedInputStream.cs +++ b/csharp/src/ProtocolBuffers/CodedInputStream.cs @@ -1429,10 +1429,10 @@ namespace Google.Protobuf } else { - byte[] skipBuffer = new byte[1024]; + byte[] skipBuffer = new byte[Math.Min(1024, amountToSkip)]; while (amountToSkip > 0) { - int bytesRead = input.Read(skipBuffer, 0, skipBuffer.Length); + int bytesRead = input.Read(skipBuffer, 0, Math.Min(skipBuffer.Length, amountToSkip)); if (bytesRead <= 0) { throw InvalidProtocolBufferException.TruncatedMessage(); -- cgit v1.2.3 From 8fcde2cabd02ffe6ea061e259f67241f277368de Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Fri, 12 Jun 2015 11:17:07 +0100 Subject: Fix oneof behaviour in the face of default values. --- .../protobuf/compiler/csharp/csharp_primitive_field.cc | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc b/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc index cb7e1b5a..69056790 100644 --- a/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc @@ -137,8 +137,6 @@ PrimitiveOneofFieldGenerator::~PrimitiveOneofFieldGenerator() { } void PrimitiveOneofFieldGenerator::GenerateMembers(io::Printer* printer) { - // TODO(jonskeet): What should foo.OneofIntField = 0; do? Clear the oneof? - // Currently foo.OneOfStringField = null will clear the oneof, but foo.OneOfStringField = "" won't. Ick. AddDeprecatedFlag(printer); printer->Print( variables_, @@ -148,15 +146,14 @@ void PrimitiveOneofFieldGenerator::GenerateMembers(io::Printer* printer) { if (is_value_type) { printer->Print( variables_, - " $oneof_name$_ = value;\n" - " $oneof_name$Case_ = $oneof_property_name$OneofCase.$property_name$;\n"); + " $oneof_name$_ = value;\n"); } else { printer->Print( variables_, - " $oneof_name$_ = value ?? $default_value$;\n" - " $oneof_name$Case_ = value == null ? $oneof_property_name$OneofCase.None : $oneof_property_name$OneofCase.$property_name$;\n"); + " $oneof_name$_ = value ?? $default_value$;\n"); } printer->Print( + " $oneof_name$Case_ = $oneof_property_name$OneofCase.$property_name$;\n" " }\n" "}\n"); } @@ -167,11 +164,9 @@ void PrimitiveOneofFieldGenerator::WriteToString(io::Printer* printer) { } void PrimitiveOneofFieldGenerator::GenerateParsingCode(io::Printer* printer) { - // TODO(jonskeet): What if the value we read is the default value for the type? printer->Print( variables_, - "$oneof_name$_ = input.Read$capitalized_type_name$()\n;" - "$oneof_name$Case_ = $oneof_property_name$OneofCase.$property_name$;\n"); + "$property_name$ = input.Read$capitalized_type_name$()\n;"); } } // namespace csharp -- cgit v1.2.3 From 43527448595b2e19a03747c494d1b33bced6086a Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Fri, 12 Jun 2015 11:18:37 +0100 Subject: Use Length to check string/bytes fields for emptiness - it's faster than an equality check. --- src/google/protobuf/compiler/csharp/csharp_primitive_field.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc b/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc index 69056790..e48c6ba9 100644 --- a/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc @@ -52,6 +52,10 @@ PrimitiveFieldGenerator::PrimitiveFieldGenerator( // TODO(jonskeet): Make this cleaner... is_value_type = descriptor->type() != FieldDescriptor::TYPE_STRING && descriptor->type() != FieldDescriptor::TYPE_BYTES; + if (!is_value_type) { + variables_["has_property_check"] = variables_["property_name"] + ".Length != 0"; + variables_["other_has_property_check"] = "other." + variables_["property_name"] + ".Length != 0"; + } } PrimitiveFieldGenerator::~PrimitiveFieldGenerator() { @@ -90,9 +94,11 @@ void PrimitiveFieldGenerator::GenerateMergingCode(io::Printer* printer) { } void PrimitiveFieldGenerator::GenerateParsingCode(io::Printer* printer) { + // Note: invoke the property setter rather than writing straight to the field, + // so that we can normalize "null to empty" for strings and bytes. printer->Print( variables_, - "$name$_ = input.Read$capitalized_type_name$();\n"); + "$property_name$ = input.Read$capitalized_type_name$();\n"); } void PrimitiveFieldGenerator::GenerateSerializationCode(io::Printer* printer) { -- cgit v1.2.3 From 9b66768e257dd8e61895d8a2c40f078f9987b577 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Fri, 12 Jun 2015 11:19:16 +0100 Subject: Optimization to avoid foreach over empty lists. --- csharp/src/ProtocolBuffers/CodedOutputStream.cs | 73 ++++++++++++++++++++++--- 1 file changed, 64 insertions(+), 9 deletions(-) diff --git a/csharp/src/ProtocolBuffers/CodedOutputStream.cs b/csharp/src/ProtocolBuffers/CodedOutputStream.cs index 132f8067..dfcaf8a2 100644 --- a/csharp/src/ProtocolBuffers/CodedOutputStream.cs +++ b/csharp/src/ProtocolBuffers/CodedOutputStream.cs @@ -543,19 +543,14 @@ namespace Google.Protobuf #endregion #region Write array members - public void WriteGroupArray(int fieldNumber, RepeatedField list) + public void WriteMessageArray(int fieldNumber, RepeatedField list) where T : IMessage { - foreach (IMessage value in list) + if (list.Count == 0) { - WriteGroup(fieldNumber, value); + return; } - } - - public void WriteMessageArray(int fieldNumber, RepeatedField list) - where T : IMessage - { - foreach (IMessage value in list) + foreach (T value in list) { WriteMessage(fieldNumber, value); } @@ -563,6 +558,10 @@ namespace Google.Protobuf public void WriteStringArray(int fieldNumber, RepeatedField list) { + if (list.Count == 0) + { + return; + } foreach (var value in list) { WriteString(fieldNumber, value); @@ -571,6 +570,10 @@ namespace Google.Protobuf public void WriteBytesArray(int fieldNumber, RepeatedField list) { + if (list.Count == 0) + { + return; + } foreach (var value in list) { WriteBytes(fieldNumber, value); @@ -579,6 +582,10 @@ namespace Google.Protobuf public void WriteBoolArray(int fieldNumber, RepeatedField list) { + if (list.Count == 0) + { + return; + } foreach (var value in list) { WriteBool(fieldNumber, value); @@ -587,6 +594,10 @@ namespace Google.Protobuf public void WriteInt32Array(int fieldNumber, RepeatedField list) { + if (list.Count == 0) + { + return; + } foreach (var value in list) { WriteInt32(fieldNumber, value); @@ -595,6 +606,10 @@ namespace Google.Protobuf public void WriteSInt32Array(int fieldNumber, RepeatedField list) { + if (list.Count == 0) + { + return; + } foreach (var value in list) { WriteSInt32(fieldNumber, value); @@ -603,6 +618,10 @@ namespace Google.Protobuf public void WriteUInt32Array(int fieldNumber, RepeatedField list) { + if (list.Count == 0) + { + return; + } foreach (var value in list) { WriteUInt32(fieldNumber, value); @@ -611,6 +630,10 @@ namespace Google.Protobuf public void WriteFixed32Array(int fieldNumber, RepeatedField list) { + if (list.Count == 0) + { + return; + } foreach (var value in list) { WriteFixed32(fieldNumber, value); @@ -619,6 +642,10 @@ namespace Google.Protobuf public void WriteSFixed32Array(int fieldNumber, RepeatedField list) { + if (list.Count == 0) + { + return; + } foreach (var value in list) { WriteSFixed32(fieldNumber, value); @@ -627,6 +654,10 @@ namespace Google.Protobuf public void WriteInt64Array(int fieldNumber, RepeatedField list) { + if (list.Count == 0) + { + return; + } foreach (var value in list) { WriteInt64(fieldNumber, value); @@ -635,6 +666,10 @@ namespace Google.Protobuf public void WriteSInt64Array(int fieldNumber, RepeatedField list) { + if (list.Count == 0) + { + return; + } foreach (var value in list) { WriteSInt64(fieldNumber, value); @@ -643,6 +678,10 @@ namespace Google.Protobuf public void WriteUInt64Array(int fieldNumber, RepeatedField list) { + if (list.Count == 0) + { + return; + } foreach (var value in list) { WriteUInt64(fieldNumber, value); @@ -651,6 +690,10 @@ namespace Google.Protobuf public void WriteFixed64Array(int fieldNumber, RepeatedField list) { + if (list.Count == 0) + { + return; + } foreach (var value in list) { WriteFixed64(fieldNumber, value); @@ -659,6 +702,10 @@ namespace Google.Protobuf public void WriteSFixed64Array(int fieldNumber, RepeatedField list) { + if (list.Count == 0) + { + return; + } foreach (var value in list) { WriteSFixed64(fieldNumber, value); @@ -667,6 +714,10 @@ namespace Google.Protobuf public void WriteDoubleArray(int fieldNumber, RepeatedField list) { + if (list.Count == 0) + { + return; + } foreach (var value in list) { WriteDouble(fieldNumber, value); @@ -675,6 +726,10 @@ namespace Google.Protobuf public void WriteFloatArray(int fieldNumber, RepeatedField list) { + if (list.Count == 0) + { + return; + } foreach (var value in list) { WriteFloat(fieldNumber, value); -- cgit v1.2.3 From 1b71db1180953e592e134ddd509f54d6024df593 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Fri, 12 Jun 2015 11:19:50 +0100 Subject: Optimization of CalculateSize: avoid foreach over empty lists. --- .../protobuf/compiler/csharp/csharp_repeated_enum_field.cc | 6 +----- .../protobuf/compiler/csharp/csharp_repeated_message_field.cc | 6 ++++-- .../compiler/csharp/csharp_repeated_primitive_field.cc | 10 +++++----- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc b/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc index 15e92ab9..3fe5ab21 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc @@ -89,13 +89,11 @@ void RepeatedEnumFieldGenerator::GenerateSerializationCode(io::Printer* printer) void RepeatedEnumFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) { // TODO(jonskeet): Move all this code into CodedOutputStream? It's a lot to repeat everywhere... - printer->Print("{\n"); - printer->Indent(); printer->Print( variables_, - "int dataSize = 0;\n" "if ($name$_.Count > 0) {\n"); printer->Indent(); + printer->Print("int dataSize = 0;\n"); printer->Print( variables_, "foreach ($type_name$ element in $name$_) {\n" @@ -115,8 +113,6 @@ void RepeatedEnumFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer } printer->Outdent(); printer->Print("}\n"); - printer->Outdent(); - printer->Print("}\n"); } void RepeatedEnumFieldGenerator::WriteHash(io::Printer* printer) { diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc b/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc index 6228aa67..d7e4d80f 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc @@ -90,8 +90,10 @@ void RepeatedMessageFieldGenerator::GenerateSerializedSizeCode(io::Printer* prin // TODO(jonskeet): Put this into CodedOutputStream. printer->Print( variables_, - "foreach ($type_name$ element in $name$_) {\n" - " size += pb::CodedOutputStream.ComputeMessageSize($number$, element);\n" + "if ($name$_.Count > 0) {\n" + " foreach ($type_name$ element in $name$_) {\n" + " size += pb::CodedOutputStream.ComputeMessageSize($number$, element);\n" + " }\n" "}\n"); } diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc b/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc index f62ea09d..2dd879fe 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc @@ -93,7 +93,9 @@ void RepeatedPrimitiveFieldGenerator::GenerateSerializationCode( void RepeatedPrimitiveFieldGenerator::GenerateSerializedSizeCode( io::Printer* printer) { // TODO(jonskeet): Do this in the runtime if possible. It's a pain, but it must be feasible... - printer->Print("{\n"); + printer->Print( + "if ($name$_.Count > 0) {\n", + "name", name()); printer->Indent(); printer->Print("int dataSize = 0;\n"); int fixedSize = GetFixedSize(descriptor_->type()); @@ -112,10 +114,8 @@ void RepeatedPrimitiveFieldGenerator::GenerateSerializedSizeCode( int tagSize = internal::WireFormat::TagSize(descriptor_->number(), descriptor_->type()); if (descriptor_->is_packed()) { printer->Print( - "if ($name$_.Count != 0) {\n" - " size += $tag_size$ + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize);\n" - "}\n", - "name", name(), "tag_size", SimpleItoa(tagSize)); + "size += $tag_size$ + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize);\n", + "tag_size", SimpleItoa(tagSize)); } else { printer->Print( "size += $tag_size$ * $name$_.Count;\n", -- cgit v1.2.3 From 5685e987112077b2df9fc59acfbfa30f1e3ea38b Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Fri, 12 Jun 2015 11:47:47 +0100 Subject: Simplify ComputeInt32Size to call ComputeInt32SizeNoTag. --- csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs b/csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs index b7629d7c..aba5a1a2 100644 --- a/csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs +++ b/csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs @@ -91,15 +91,7 @@ namespace Google.Protobuf /// public static int ComputeInt32Size(int fieldNumber, int value) { - if (value >= 0) - { - return ComputeTagSize(fieldNumber) + ComputeRawVarint32Size((uint) value); - } - else - { - // Must sign-extend. - return ComputeTagSize(fieldNumber) + 10; - } + return ComputeTagSize(fieldNumber) + ComputeInt32SizeNoTag(value); } /// @@ -418,7 +410,6 @@ namespace Google.Protobuf /// public static int ComputeRawVarint32Size(uint value) { - // TODO(jonskeet): Look at optimizing this to just hard-coded comparisons. if ((value & (0xffffffff << 7)) == 0) { return 1; @@ -443,7 +434,6 @@ namespace Google.Protobuf /// public static int ComputeRawVarint64Size(ulong value) { - // TODO(jonskeet): Look at optimizing this to just hard-coded comparisons. if ((value & (0xffffffffffffffffL << 7)) == 0) { return 1; -- cgit v1.2.3 From 5a33827eec75b980fb152c531e4c6b75ce5af015 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Fri, 12 Jun 2015 11:52:14 +0100 Subject: Move Count checks into the serialization code I wouldn't expect this to affect anything, but it appears to. --- .../compiler/csharp/csharp_repeated_enum_field.cc | 6 +++--- .../compiler/csharp/csharp_repeated_message_field.cc | 4 +++- .../compiler/csharp/csharp_repeated_primitive_field.cc | 15 ++++++--------- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc b/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc index 3fe5ab21..22dec710 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc @@ -80,11 +80,11 @@ void RepeatedEnumFieldGenerator::GenerateParsingCode(io::Printer* printer) { } void RepeatedEnumFieldGenerator::GenerateSerializationCode(io::Printer* printer) { - // TODO(jonskeet): Originally, this checked for Count > 0 first. - // The Write* call should make that cheap though - no need to generate it every time. printer->Print( variables_, - "output.Write$packed$EnumArray($number$, $name$_);\n"); + "if ($name$_.Count > 0) {\n" + " output.Write$packed$EnumArray($number$, $name$_);\n" + "}\n"); } void RepeatedEnumFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) { diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc b/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc index d7e4d80f..4b570d3b 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc @@ -83,7 +83,9 @@ void RepeatedMessageFieldGenerator::GenerateSerializationCode(io::Printer* print // The Write* call should make that cheap though - no need to generate it every time. printer->Print( variables_, - "output.WriteMessageArray($number$, $name$_);\n"); + "if ($name$_.Count > 0) {\n" + " output.WriteMessageArray($number$, $name$_);\n" + "}\n"); } void RepeatedMessageFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) { diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc b/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc index 2dd879fe..a5457785 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc @@ -49,6 +49,7 @@ namespace csharp { RepeatedPrimitiveFieldGenerator::RepeatedPrimitiveFieldGenerator( const FieldDescriptor* descriptor, int fieldOrdinal) : FieldGeneratorBase(descriptor, fieldOrdinal) { + variables_["packed"] = descriptor->is_packed() ? "Packed" : ""; } RepeatedPrimitiveFieldGenerator::~RepeatedPrimitiveFieldGenerator() { @@ -79,15 +80,11 @@ void RepeatedPrimitiveFieldGenerator::GenerateParsingCode(io::Printer* printer) void RepeatedPrimitiveFieldGenerator::GenerateSerializationCode( io::Printer* printer) { - // TODO(jonskeet): Originally, this checked for Count > 0 first. - // The Write* call should make that cheap though - no need to generate it every time. - if (descriptor_->is_packed()) { - printer->Print(variables_, - "output.WritePacked$capitalized_type_name$Array($number$, $name$_);\n"); - } else { - printer->Print(variables_, - "output.Write$capitalized_type_name$Array($number$, $name$_);\n"); - } + printer->Print( + variables_, + "if ($name$_.Count > 0) {\n" + " output.Write$packed$$capitalized_type_name$Array($number$, $name$_);\n" + "}\n"); } void RepeatedPrimitiveFieldGenerator::GenerateSerializedSizeCode( -- cgit v1.2.3 From 7532f0256f58e0d11711da4e159534bccbf266f0 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Fri, 12 Jun 2015 13:07:51 +0100 Subject: Reimplement RepeatedField using an array as the backing store. This is effectively reimplementing List, but with a few advantages: - We know that an empty repeated field is common, so don't allocate an array until we need to - With direct access to the array, we can easily convert enum values to int without boxing - We can relax the restrictions over what happens if the repeated field is modified while iterating, avoiding so much checking This is somewhat risky, in that reimplementing a building block like this is *always* risky, but hey... (The performance benefits are significant...) --- .../ProtocolBuffers.Test/CodedInputStreamTest.cs | 4 +- .../src/ProtocolBuffers.Test/RepeatedFieldTest.cs | 9 +- csharp/src/ProtocolBuffers/CodedInputStream.cs | 7 +- csharp/src/ProtocolBuffers/CodedOutputStream.cs | 23 +- .../ProtocolBuffers/Collections/RepeatedField.cs | 239 ++++++++++++++++++--- 5 files changed, 231 insertions(+), 51 deletions(-) diff --git a/csharp/src/ProtocolBuffers.Test/CodedInputStreamTest.cs b/csharp/src/ProtocolBuffers.Test/CodedInputStreamTest.cs index 450662a6..07f54e94 100644 --- a/csharp/src/ProtocolBuffers.Test/CodedInputStreamTest.cs +++ b/csharp/src/ProtocolBuffers.Test/CodedInputStreamTest.cs @@ -487,7 +487,7 @@ namespace Google.Protobuf uint tag; Assert.IsTrue(input.ReadTag(out tag)); - List values = new List(); + RepeatedField values = new RepeatedField(); input.ReadEnumArray(tag, values); Assert.AreEqual(6, values.Count); @@ -511,7 +511,7 @@ namespace Google.Protobuf uint tag; Assert.IsTrue(input.ReadTag(out tag)); - List values = new List(); + RepeatedField values = new RepeatedField(); input.ReadEnumArray(tag, values); Assert.AreEqual(6, values.Count); diff --git a/csharp/src/ProtocolBuffers.Test/RepeatedFieldTest.cs b/csharp/src/ProtocolBuffers.Test/RepeatedFieldTest.cs index 94e30189..cbe79294 100644 --- a/csharp/src/ProtocolBuffers.Test/RepeatedFieldTest.cs +++ b/csharp/src/ProtocolBuffers.Test/RepeatedFieldTest.cs @@ -40,11 +40,12 @@ namespace Google.Protobuf [Test] public void Add_RepeatedField() { - var list = new RepeatedField(); + var list = new RepeatedField { "original" }; list.Add(new RepeatedField { "foo", "bar" }); - Assert.AreEqual(2, list.Count); - Assert.AreEqual("foo", list[0]); - Assert.AreEqual("bar", list[1]); + Assert.AreEqual(3, list.Count); + Assert.AreEqual("original", list[0]); + Assert.AreEqual("foo", list[1]); + Assert.AreEqual("bar", list[2]); } } } diff --git a/csharp/src/ProtocolBuffers/CodedInputStream.cs b/csharp/src/ProtocolBuffers/CodedInputStream.cs index 17fcc64b..447adbb1 100644 --- a/csharp/src/ProtocolBuffers/CodedInputStream.cs +++ b/csharp/src/ProtocolBuffers/CodedInputStream.cs @@ -38,6 +38,7 @@ using System; using System.Collections.Generic; using System.IO; using System.Text; +using Google.Protobuf.Collections; using Google.Protobuf.Descriptors; namespace Google.Protobuf @@ -700,7 +701,7 @@ namespace Google.Protobuf } } - public void ReadEnumArray(uint fieldTag, ICollection list) + public void ReadEnumArray(uint fieldTag, RepeatedField list) where T : struct, IComparable, IFormattable { WireFormat.WireType wformat = WireFormat.GetTagWireType(fieldTag); @@ -712,8 +713,8 @@ namespace Google.Protobuf int limit = PushLimit(length); while (!ReachedLimit) { - // TODO(jonskeet): Avoid this horrible boxing! - list.Add((T)(object) ReadEnum()); + // Ghastly hack, but it works... + list.AddInt32(ReadEnum()); } PopLimit(limit); } diff --git a/csharp/src/ProtocolBuffers/CodedOutputStream.cs b/csharp/src/ProtocolBuffers/CodedOutputStream.cs index dfcaf8a2..bc3ed7d7 100644 --- a/csharp/src/ProtocolBuffers/CodedOutputStream.cs +++ b/csharp/src/ProtocolBuffers/CodedOutputStream.cs @@ -743,10 +743,11 @@ namespace Google.Protobuf { return; } - // TODO(jonskeet): Avoid the Cast call here. Work out a better mass "T to int" conversion. - foreach (int value in list.Cast()) + // Bit of a hack, to access the values as ints + var iterator = list.GetInt32Enumerator(); + while (iterator.MoveNext()) { - WriteEnum(fieldNumber, value); + WriteEnum(fieldNumber, iterator.Current); } } @@ -956,15 +957,19 @@ namespace Google.Protobuf { return; } - // Obviously, we'll want to get rid of this hack... - var temporaryHack = new RepeatedField(); - temporaryHack.Add(list.Cast()); - uint size = temporaryHack.CalculateSize(ComputeEnumSizeNoTag); + // Bit of a hack, to access the values as ints + var iterator = list.GetInt32Enumerator(); + uint size = 0; + while (iterator.MoveNext()) + { + size += (uint) ComputeEnumSizeNoTag(iterator.Current); + } + iterator.Reset(); WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited); WriteRawVarint32(size); - foreach (int value in temporaryHack) + while (iterator.MoveNext()) { - WriteEnumNoTag(value); + WriteEnumNoTag(iterator.Current); } } diff --git a/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs b/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs index 7dcd060e..0cd5cf80 100644 --- a/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs +++ b/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs @@ -6,7 +6,27 @@ namespace Google.Protobuf.Collections { public sealed class RepeatedField : IList, IEquatable> { - private readonly List list = new List(); + private const int MinArraySize = 8; + private T[] array = null; + private int count = 0; + + private void EnsureSize(int size) + { + if (array == null) + { + array = new T[Math.Max(size, MinArraySize)]; + } + else + { + if (array.Length < size) + { + int newSize = Math.Max(array.Length * 2, size); + var tmp = new T[newSize]; + Array.Copy(array, 0, tmp, 0, array.Length); + array = tmp; + } + } + } public void Add(T item) { @@ -14,38 +34,55 @@ namespace Google.Protobuf.Collections { throw new ArgumentNullException("item"); } - list.Add(item); + EnsureSize(count + 1); + array[count++] = item; + } + + /// + /// Hack to allow us to add enums easily... will only work with int-based types. + /// + /// + internal void AddInt32(int item) + { + EnsureSize(count + 1); + int[] castArray = (int[]) (object) array; + castArray[count++] = item; } public void Clear() { - list.Clear(); + array = null; + count = 0; } public bool Contains(T item) { - if (item == null) - { - throw new ArgumentNullException("item"); - } - return list.Contains(item); + return IndexOf(item) != -1; } public void CopyTo(T[] array, int arrayIndex) { - list.CopyTo(array); + if (this.array == null) + { + return; + } + Array.Copy(this.array, 0, array, arrayIndex, count); } public bool Remove(T item) { - if (item == null) + int index = IndexOf(item); + if (index == -1) { - throw new ArgumentNullException("item"); - } - return list.Remove(item); + return false; + } + Array.Copy(array, index + 1, array, index, count - index - 1); + count--; + array[count] = default(T); + return true; } - public int Count { get { return list.Count; } } + public int Count { get { return count; } } // TODO(jonskeet): If we implement freezing, make this reflect it. public bool IsReadOnly { get { return false; } } @@ -56,8 +93,10 @@ namespace Google.Protobuf.Collections { throw new ArgumentNullException("values"); } + EnsureSize(count + values.count); // We know that all the values will be valid, because it's a RepeatedField. - list.AddRange(values); + Array.Copy(values.array, 0, array, count, values.count); + count += values.count; } public void Add(IEnumerable values) @@ -66,21 +105,21 @@ namespace Google.Protobuf.Collections { throw new ArgumentNullException("values"); } + // TODO: Check for ICollection and get the Count? foreach (T item in values) { Add(item); } } - // TODO(jonskeet): Create our own mutable struct for this, rather than relying on List. - public List.Enumerator GetEnumerator() + public RepeatedField.Enumerator GetEnumerator() { - return list.GetEnumerator(); + return new Enumerator(this); } IEnumerator IEnumerable.GetEnumerator() { - return list.GetEnumerator(); + return GetEnumerator(); } public override bool Equals(object obj) @@ -88,21 +127,30 @@ namespace Google.Protobuf.Collections return Equals(obj as RepeatedField); } + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + /// + /// Returns an enumerator of the values in this list as integers. + /// Used for enum types. + /// + internal Int32Enumerator GetInt32Enumerator() + { + return new Int32Enumerator((int[])(object)array, count); + } + public override int GetHashCode() { int hash = 23; - foreach (T item in this) + for (int i = 0; i < count; i++) { - hash = hash * 31 + item.GetHashCode(); + hash = hash * 31 + array[i].GetHashCode(); } return hash; } - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } - public bool Equals(RepeatedField other) { if (ReferenceEquals(other, null)) @@ -119,9 +167,9 @@ namespace Google.Protobuf.Collections } // TODO(jonskeet): Does this box for enums? EqualityComparer comparer = EqualityComparer.Default; - for (int i = 0; i < Count; i++) + for (int i = 0; i < count; i++) { - if (!comparer.Equals(this[i], other[i])) + if (!comparer.Equals(array[i], other.array[i])) { return false; } @@ -135,7 +183,20 @@ namespace Google.Protobuf.Collections { throw new ArgumentNullException("item"); } - return list.IndexOf(item); + if (array == null) + { + return -1; + } + // TODO(jonskeet): Does this box for enums? + EqualityComparer comparer = EqualityComparer.Default; + for (int i = 0; i < count; i++) + { + if (comparer.Equals(array[i], item)) + { + return i; + } + } + return -1; } public void Insert(int index, T item) @@ -144,24 +205,136 @@ namespace Google.Protobuf.Collections { throw new ArgumentNullException("item"); } - list.Insert(index, item); + if (index < 0 || index > count) + { + throw new ArgumentOutOfRangeException("index"); + } + EnsureSize(count + 1); + Array.Copy(array, index, array, index + 1, count - index); + count++; } public void RemoveAt(int index) { - list.RemoveAt(index); + if (index < 0 || index >= count) + { + throw new ArgumentOutOfRangeException("index"); + } + Array.Copy(array, index + 1, array, index, count - index - 1); + count--; + array[count] = default(T); } public T this[int index] { - get { return list[index]; } + get + { + if (index < 0 || index >= count) + { + throw new ArgumentOutOfRangeException("index"); + } + return array[index]; + } set { + if (index < 0 || index >= count) + { + throw new ArgumentOutOfRangeException("index"); + } if (value == null) { throw new ArgumentNullException("value"); } - list[index] = value; + array[index] = value; + } + } + + public struct Enumerator : IEnumerator + { + private int index; + private readonly RepeatedField field; + + public Enumerator(RepeatedField field) + { + this.field = field; + this.index = -1; + } + + public bool MoveNext() + { + if (index + 1 >= field.Count) + { + return false; + } + index++; + return true; + } + + public void Reset() + { + index = -1; + } + + public T Current + { + get + { + if (index == -1 || index >= field.count) + { + throw new InvalidOperationException(); + } + return field.array[index]; + } + } + + object IEnumerator.Current + { + get { return Current; } + } + + public void Dispose() + { + } + } + + internal struct Int32Enumerator : IEnumerator + { + private int index; + private readonly int[] array; + private readonly int count; + + public Int32Enumerator(int[] array, int count) + { + this.array = array; + this.index = -1; + this.count = count; + } + + public bool MoveNext() + { + if (index + 1 >= count) + { + return false; + } + index++; + return true; + } + + public void Reset() + { + index = -1; + } + + // No guard here, as we're only going to use this internally... + public int Current { get { return array[index]; } } + + object IEnumerator.Current + { + get { return Current; } + } + + public void Dispose() + { } } } -- cgit v1.2.3 From a8dae140c60d9b29c72a7f342ec7081b2116fea9 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Fri, 12 Jun 2015 13:11:16 +0100 Subject: Fix oneof generator - forgot to provide variables... --- src/google/protobuf/compiler/csharp/csharp_primitive_field.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc b/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc index e48c6ba9..0164cdca 100644 --- a/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc @@ -159,6 +159,7 @@ void PrimitiveOneofFieldGenerator::GenerateMembers(io::Printer* printer) { " $oneof_name$_ = value ?? $default_value$;\n"); } printer->Print( + variables_, " $oneof_name$Case_ = $oneof_property_name$OneofCase.$property_name$;\n" " }\n" "}\n"); -- cgit v1.2.3 From fb1547b3884ace3be6acf9e947686d627ff90179 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Fri, 12 Jun 2015 13:11:54 +0100 Subject: Regenerate proto files --- csharp/src/AddressBook/Addressbook.cs | 52 +- .../TestProtos/UnittestImportProto3.cs | 2 +- .../TestProtos/UnittestImportPublicProto3.cs | 2 +- .../TestProtos/UnittestIssues.cs | 76 +- .../TestProtos/UnittestProto3.cs | 769 +++++++++++---------- .../DescriptorProtos/DescriptorProtoFile.cs | 608 +++++++++------- 6 files changed, 838 insertions(+), 671 deletions(-) diff --git a/csharp/src/AddressBook/Addressbook.cs b/csharp/src/AddressBook/Addressbook.cs index 5b513982..4acb8cac 100644 --- a/csharp/src/AddressBook/Addressbook.cs +++ b/csharp/src/AddressBook/Addressbook.cs @@ -130,39 +130,43 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { public override int GetHashCode() { int hash = 0; - if (Name != "") hash ^= Name.GetHashCode(); + if (Name.Length != 0) hash ^= Name.GetHashCode(); if (Id != 0) hash ^= Id.GetHashCode(); - if (Email != "") hash ^= Email.GetHashCode(); + if (Email.Length != 0) hash ^= Email.GetHashCode(); hash ^= phone_.GetHashCode(); return hash; } public void WriteTo(pb::CodedOutputStream output) { - if (Name != "") { + if (Name.Length != 0) { output.WriteString(1, Name); } if (Id != 0) { output.WriteInt32(2, Id); } - if (Email != "") { + if (Email.Length != 0) { output.WriteString(3, Email); } - output.WriteMessageArray(4, phone_); + if (phone_.Count > 0) { + output.WriteMessageArray(4, phone_); + } } public int CalculateSize() { int size = 0; - if (Name != "") { + if (Name.Length != 0) { size += pb::CodedOutputStream.ComputeStringSize(1, Name); } if (Id != 0) { size += pb::CodedOutputStream.ComputeInt32Size(2, Id); } - if (Email != "") { + if (Email.Length != 0) { size += pb::CodedOutputStream.ComputeStringSize(3, Email); } - foreach (global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneNumber element in phone_) { - size += pb::CodedOutputStream.ComputeMessageSize(4, element); + if (phone_.Count > 0) { + foreach (global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneNumber element in phone_) { + size += pb::CodedOutputStream.ComputeMessageSize(4, element); + } } return size; } @@ -170,13 +174,13 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { if (other == null) { return; } - if (other.Name != "") { + if (other.Name.Length != 0) { Name = other.Name; } if (other.Id != 0) { Id = other.Id; } - if (other.Email != "") { + if (other.Email.Length != 0) { Email = other.Email; } phone_.Add(other.phone_); @@ -194,15 +198,15 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { } break; case 10: { - name_ = input.ReadString(); + Name = input.ReadString(); break; } case 16: { - id_ = input.ReadInt32(); + Id = input.ReadInt32(); break; } case 26: { - email_ = input.ReadString(); + Email = input.ReadString(); break; } case 34: { @@ -275,13 +279,13 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { public override int GetHashCode() { int hash = 0; - if (Number != "") hash ^= Number.GetHashCode(); + if (Number.Length != 0) hash ^= Number.GetHashCode(); if (Type != global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneType.HOME) hash ^= Type.GetHashCode(); return hash; } public void WriteTo(pb::CodedOutputStream output) { - if (Number != "") { + if (Number.Length != 0) { output.WriteString(1, Number); } if (Type != global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneType.HOME) { @@ -291,7 +295,7 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { public int CalculateSize() { int size = 0; - if (Number != "") { + if (Number.Length != 0) { size += pb::CodedOutputStream.ComputeStringSize(1, Number); } if (Type != global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneType.HOME) { @@ -303,7 +307,7 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { if (other == null) { return; } - if (other.Number != "") { + if (other.Number.Length != 0) { Number = other.Number; } if (other.Type != global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneType.HOME) { @@ -323,7 +327,7 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { } break; case 10: { - number_ = input.ReadString(); + Number = input.ReadString(); break; } case 16: { @@ -388,13 +392,17 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { } public void WriteTo(pb::CodedOutputStream output) { - output.WriteMessageArray(1, person_); + if (person_.Count > 0) { + output.WriteMessageArray(1, person_); + } } public int CalculateSize() { int size = 0; - foreach (global::Google.ProtocolBuffers.Examples.AddressBook.Person element in person_) { - size += pb::CodedOutputStream.ComputeMessageSize(1, element); + if (person_.Count > 0) { + foreach (global::Google.ProtocolBuffers.Examples.AddressBook.Person element in person_) { + size += pb::CodedOutputStream.ComputeMessageSize(1, element); + } } return size; } diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportProto3.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportProto3.cs index 1bd4e22b..f4bbbc5f 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportProto3.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportProto3.cs @@ -141,7 +141,7 @@ namespace Google.Protobuf.TestProtos { } break; case 8: { - d_ = input.ReadInt32(); + D = input.ReadInt32(); break; } } diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportPublicProto3.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportPublicProto3.cs index 32123d53..a79fa70e 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportPublicProto3.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportPublicProto3.cs @@ -126,7 +126,7 @@ namespace Google.Protobuf.TestProtos { } break; case 8: { - e_ = input.ReadInt32(); + E = input.ReadInt32(); break; } } diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs index d8c8995b..6e59f205 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs @@ -157,8 +157,12 @@ namespace UnitTest.Issues.TestProtos { if (Value != global::UnitTest.Issues.TestProtos.NegativeEnum.NEGATIVE_ENUM_ZERO) { output.WriteEnum(1, (int) Value); } - output.WriteEnumArray(2, values_); - output.WritePackedEnumArray(3, packedValues_); + if (values_.Count > 0) { + output.WriteEnumArray(2, values_); + } + if (packedValues_.Count > 0) { + output.WritePackedEnumArray(3, packedValues_); + } } public int CalculateSize() { @@ -166,26 +170,22 @@ namespace UnitTest.Issues.TestProtos { if (Value != global::UnitTest.Issues.TestProtos.NegativeEnum.NEGATIVE_ENUM_ZERO) { size += pb::CodedOutputStream.ComputeEnumSize(1, (int) Value); } - { + if (values_.Count > 0) { int dataSize = 0; - if (values_.Count > 0) { - foreach (global::UnitTest.Issues.TestProtos.NegativeEnum element in values_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 1 * values_.Count; + foreach (global::UnitTest.Issues.TestProtos.NegativeEnum element in values_) { + dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); } + size += dataSize; + size += 1 * values_.Count; } - { + if (packedValues_.Count > 0) { int dataSize = 0; - if (packedValues_.Count > 0) { - foreach (global::UnitTest.Issues.TestProtos.NegativeEnum element in packedValues_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 1; - size += pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize); + foreach (global::UnitTest.Issues.TestProtos.NegativeEnum element in packedValues_) { + dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); } + size += dataSize; + size += 1; + size += pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize); } return size; } @@ -399,15 +399,21 @@ namespace UnitTest.Issues.TestProtos { if (PrimitiveValue != 0) { output.WriteInt32(1, PrimitiveValue); } - output.WritePackedInt32Array(2, primitiveArray_); + if (primitiveArray_.Count > 0) { + output.WritePackedInt32Array(2, primitiveArray_); + } if (messageValue_ != null) { output.WriteMessage(3, MessageValue); } - output.WriteMessageArray(4, messageArray_); + if (messageArray_.Count > 0) { + output.WriteMessageArray(4, messageArray_); + } if (EnumValue != global::UnitTest.Issues.TestProtos.DeprecatedEnum.DEPRECATED_ZERO) { output.WriteEnum(5, (int) EnumValue); } - output.WritePackedEnumArray(6, enumArray_); + if (enumArray_.Count > 0) { + output.WritePackedEnumArray(6, enumArray_); + } } public int CalculateSize() { @@ -415,35 +421,33 @@ namespace UnitTest.Issues.TestProtos { if (PrimitiveValue != 0) { size += pb::CodedOutputStream.ComputeInt32Size(1, PrimitiveValue); } - { + if (primitiveArray_.Count > 0) { int dataSize = 0; foreach (int element in primitiveArray_) { dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); } size += dataSize; - if (primitiveArray_.Count != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } + size += 1 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } if (messageValue_ != null) { size += pb::CodedOutputStream.ComputeMessageSize(3, MessageValue); } - foreach (global::UnitTest.Issues.TestProtos.DeprecatedChild element in messageArray_) { - size += pb::CodedOutputStream.ComputeMessageSize(4, element); + if (messageArray_.Count > 0) { + foreach (global::UnitTest.Issues.TestProtos.DeprecatedChild element in messageArray_) { + size += pb::CodedOutputStream.ComputeMessageSize(4, element); + } } if (EnumValue != global::UnitTest.Issues.TestProtos.DeprecatedEnum.DEPRECATED_ZERO) { size += pb::CodedOutputStream.ComputeEnumSize(5, (int) EnumValue); } - { + if (enumArray_.Count > 0) { int dataSize = 0; - if (enumArray_.Count > 0) { - foreach (global::UnitTest.Issues.TestProtos.DeprecatedEnum element in enumArray_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 1; - size += pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize); + foreach (global::UnitTest.Issues.TestProtos.DeprecatedEnum element in enumArray_) { + dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); } + size += dataSize; + size += 1; + size += pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize); } return size; } @@ -480,7 +484,7 @@ namespace UnitTest.Issues.TestProtos { } break; case 8: { - primitiveValue_ = input.ReadInt32(); + PrimitiveValue = input.ReadInt32(); break; } case 18: @@ -596,7 +600,7 @@ namespace UnitTest.Issues.TestProtos { } break; case 8: { - item_ = input.ReadInt32(); + Item = input.ReadInt32(); break; } } diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs index 4c4dabab..7e731a83 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs @@ -747,7 +747,7 @@ namespace Google.Protobuf.TestProtos { get { return oneofFieldCase_ == OneofFieldOneofCase.OneofString ? (string) oneofField_ : ""; } set { oneofField_ = value ?? ""; - oneofFieldCase_ = value == null ? OneofFieldOneofCase.None : OneofFieldOneofCase.OneofString; + oneofFieldCase_ = OneofFieldOneofCase.OneofString; } } @@ -756,7 +756,7 @@ namespace Google.Protobuf.TestProtos { get { return oneofFieldCase_ == OneofFieldOneofCase.OneofBytes ? (pb::ByteString) oneofField_ : pb::ByteString.Empty; } set { oneofField_ = value ?? pb::ByteString.Empty; - oneofFieldCase_ = value == null ? OneofFieldOneofCase.None : OneofFieldOneofCase.OneofBytes; + oneofFieldCase_ = OneofFieldOneofCase.OneofBytes; } } @@ -850,8 +850,8 @@ namespace Google.Protobuf.TestProtos { if (SingleFloat != 0F) hash ^= SingleFloat.GetHashCode(); if (SingleDouble != 0D) hash ^= SingleDouble.GetHashCode(); if (SingleBool != false) hash ^= SingleBool.GetHashCode(); - if (SingleString != "") hash ^= SingleString.GetHashCode(); - if (SingleBytes != pb::ByteString.Empty) hash ^= SingleBytes.GetHashCode(); + if (SingleString.Length != 0) hash ^= SingleString.GetHashCode(); + if (SingleBytes.Length != 0) hash ^= SingleBytes.GetHashCode(); if (singleNestedMessage_ != null) hash ^= SingleNestedMessage.GetHashCode(); if (singleForeignMessage_ != null) hash ^= SingleForeignMessage.GetHashCode(); if (singleImportMessage_ != null) hash ^= SingleImportMessage.GetHashCode(); @@ -928,10 +928,10 @@ namespace Google.Protobuf.TestProtos { if (SingleBool != false) { output.WriteBool(13, SingleBool); } - if (SingleString != "") { + if (SingleString.Length != 0) { output.WriteString(14, SingleString); } - if (SingleBytes != pb::ByteString.Empty) { + if (SingleBytes.Length != 0) { output.WriteBytes(15, SingleBytes); } if (singleNestedMessage_ != null) { @@ -955,28 +955,72 @@ namespace Google.Protobuf.TestProtos { if (singlePublicImportMessage_ != null) { output.WriteMessage(26, SinglePublicImportMessage); } - output.WritePackedInt32Array(31, repeatedInt32_); - output.WritePackedInt64Array(32, repeatedInt64_); - output.WritePackedUInt32Array(33, repeatedUint32_); - output.WritePackedUInt64Array(34, repeatedUint64_); - output.WritePackedSInt32Array(35, repeatedSint32_); - output.WritePackedSInt64Array(36, repeatedSint64_); - output.WritePackedFixed32Array(37, repeatedFixed32_); - output.WritePackedFixed64Array(38, repeatedFixed64_); - output.WritePackedSFixed32Array(39, repeatedSfixed32_); - output.WritePackedSFixed64Array(40, repeatedSfixed64_); - output.WritePackedFloatArray(41, repeatedFloat_); - output.WritePackedDoubleArray(42, repeatedDouble_); - output.WritePackedBoolArray(43, repeatedBool_); - output.WriteStringArray(44, repeatedString_); - output.WriteBytesArray(45, repeatedBytes_); - output.WriteMessageArray(48, repeatedNestedMessage_); - output.WriteMessageArray(49, repeatedForeignMessage_); - output.WriteMessageArray(50, repeatedImportMessage_); - output.WritePackedEnumArray(51, repeatedNestedEnum_); - output.WritePackedEnumArray(52, repeatedForeignEnum_); - output.WritePackedEnumArray(53, repeatedImportEnum_); - output.WriteMessageArray(54, repeatedPublicImportMessage_); + if (repeatedInt32_.Count > 0) { + output.WritePackedInt32Array(31, repeatedInt32_); + } + if (repeatedInt64_.Count > 0) { + output.WritePackedInt64Array(32, repeatedInt64_); + } + if (repeatedUint32_.Count > 0) { + output.WritePackedUInt32Array(33, repeatedUint32_); + } + if (repeatedUint64_.Count > 0) { + output.WritePackedUInt64Array(34, repeatedUint64_); + } + if (repeatedSint32_.Count > 0) { + output.WritePackedSInt32Array(35, repeatedSint32_); + } + if (repeatedSint64_.Count > 0) { + output.WritePackedSInt64Array(36, repeatedSint64_); + } + if (repeatedFixed32_.Count > 0) { + output.WritePackedFixed32Array(37, repeatedFixed32_); + } + if (repeatedFixed64_.Count > 0) { + output.WritePackedFixed64Array(38, repeatedFixed64_); + } + if (repeatedSfixed32_.Count > 0) { + output.WritePackedSFixed32Array(39, repeatedSfixed32_); + } + if (repeatedSfixed64_.Count > 0) { + output.WritePackedSFixed64Array(40, repeatedSfixed64_); + } + if (repeatedFloat_.Count > 0) { + output.WritePackedFloatArray(41, repeatedFloat_); + } + if (repeatedDouble_.Count > 0) { + output.WritePackedDoubleArray(42, repeatedDouble_); + } + if (repeatedBool_.Count > 0) { + output.WritePackedBoolArray(43, repeatedBool_); + } + if (repeatedString_.Count > 0) { + output.WriteStringArray(44, repeatedString_); + } + if (repeatedBytes_.Count > 0) { + output.WriteBytesArray(45, repeatedBytes_); + } + if (repeatedNestedMessage_.Count > 0) { + output.WriteMessageArray(48, repeatedNestedMessage_); + } + if (repeatedForeignMessage_.Count > 0) { + output.WriteMessageArray(49, repeatedForeignMessage_); + } + if (repeatedImportMessage_.Count > 0) { + output.WriteMessageArray(50, repeatedImportMessage_); + } + if (repeatedNestedEnum_.Count > 0) { + output.WritePackedEnumArray(51, repeatedNestedEnum_); + } + if (repeatedForeignEnum_.Count > 0) { + output.WritePackedEnumArray(52, repeatedForeignEnum_); + } + if (repeatedImportEnum_.Count > 0) { + output.WritePackedEnumArray(53, repeatedImportEnum_); + } + if (repeatedPublicImportMessage_.Count > 0) { + output.WriteMessageArray(54, repeatedPublicImportMessage_); + } if (oneofFieldCase_ == OneofFieldOneofCase.OneofUint32) { output.WriteUInt32(111, OneofUint32); } @@ -1032,10 +1076,10 @@ namespace Google.Protobuf.TestProtos { if (SingleBool != false) { size += pb::CodedOutputStream.ComputeBoolSize(13, SingleBool); } - if (SingleString != "") { + if (SingleString.Length != 0) { size += pb::CodedOutputStream.ComputeStringSize(14, SingleString); } - if (SingleBytes != pb::ByteString.Empty) { + if (SingleBytes.Length != 0) { size += pb::CodedOutputStream.ComputeBytesSize(15, SingleBytes); } if (singleNestedMessage_ != null) { @@ -1059,123 +1103,97 @@ namespace Google.Protobuf.TestProtos { if (singlePublicImportMessage_ != null) { size += pb::CodedOutputStream.ComputeMessageSize(26, SinglePublicImportMessage); } - { + if (repeatedInt32_.Count > 0) { int dataSize = 0; foreach (int element in repeatedInt32_) { dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); } size += dataSize; - if (repeatedInt32_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { + if (repeatedInt64_.Count > 0) { int dataSize = 0; foreach (long element in repeatedInt64_) { dataSize += pb::CodedOutputStream.ComputeInt64SizeNoTag(element); } size += dataSize; - if (repeatedInt64_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { + if (repeatedUint32_.Count > 0) { int dataSize = 0; foreach (uint element in repeatedUint32_) { dataSize += pb::CodedOutputStream.ComputeUInt32SizeNoTag(element); } size += dataSize; - if (repeatedUint32_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { + if (repeatedUint64_.Count > 0) { int dataSize = 0; foreach (ulong element in repeatedUint64_) { dataSize += pb::CodedOutputStream.ComputeUInt64SizeNoTag(element); } size += dataSize; - if (repeatedUint64_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { + if (repeatedSint32_.Count > 0) { int dataSize = 0; foreach (int element in repeatedSint32_) { dataSize += pb::CodedOutputStream.ComputeSInt32SizeNoTag(element); } size += dataSize; - if (repeatedSint32_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { + if (repeatedSint64_.Count > 0) { int dataSize = 0; foreach (long element in repeatedSint64_) { dataSize += pb::CodedOutputStream.ComputeSInt64SizeNoTag(element); } size += dataSize; - if (repeatedSint64_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { + if (repeatedFixed32_.Count > 0) { int dataSize = 0; dataSize = 4 * repeatedFixed32_.Count; size += dataSize; - if (repeatedFixed32_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { + if (repeatedFixed64_.Count > 0) { int dataSize = 0; dataSize = 8 * repeatedFixed64_.Count; size += dataSize; - if (repeatedFixed64_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { + if (repeatedSfixed32_.Count > 0) { int dataSize = 0; dataSize = 4 * repeatedSfixed32_.Count; size += dataSize; - if (repeatedSfixed32_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { + if (repeatedSfixed64_.Count > 0) { int dataSize = 0; dataSize = 8 * repeatedSfixed64_.Count; size += dataSize; - if (repeatedSfixed64_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { + if (repeatedFloat_.Count > 0) { int dataSize = 0; dataSize = 4 * repeatedFloat_.Count; size += dataSize; - if (repeatedFloat_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { + if (repeatedDouble_.Count > 0) { int dataSize = 0; dataSize = 8 * repeatedDouble_.Count; size += dataSize; - if (repeatedDouble_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { + if (repeatedBool_.Count > 0) { int dataSize = 0; dataSize = 1 * repeatedBool_.Count; size += dataSize; - if (repeatedBool_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { + if (repeatedString_.Count > 0) { int dataSize = 0; foreach (string element in repeatedString_) { dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); @@ -1183,7 +1201,7 @@ namespace Google.Protobuf.TestProtos { size += dataSize; size += 2 * repeatedString_.Count; } - { + if (repeatedBytes_.Count > 0) { int dataSize = 0; foreach (pb::ByteString element in repeatedBytes_) { dataSize += pb::CodedOutputStream.ComputeBytesSizeNoTag(element); @@ -1191,50 +1209,52 @@ namespace Google.Protobuf.TestProtos { size += dataSize; size += 2 * repeatedBytes_.Count; } - foreach (global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage element in repeatedNestedMessage_) { - size += pb::CodedOutputStream.ComputeMessageSize(48, element); + if (repeatedNestedMessage_.Count > 0) { + foreach (global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage element in repeatedNestedMessage_) { + size += pb::CodedOutputStream.ComputeMessageSize(48, element); + } } - foreach (global::Google.Protobuf.TestProtos.ForeignMessage element in repeatedForeignMessage_) { - size += pb::CodedOutputStream.ComputeMessageSize(49, element); + if (repeatedForeignMessage_.Count > 0) { + foreach (global::Google.Protobuf.TestProtos.ForeignMessage element in repeatedForeignMessage_) { + size += pb::CodedOutputStream.ComputeMessageSize(49, element); + } } - foreach (global::Google.Protobuf.TestProtos.ImportMessage element in repeatedImportMessage_) { - size += pb::CodedOutputStream.ComputeMessageSize(50, element); + if (repeatedImportMessage_.Count > 0) { + foreach (global::Google.Protobuf.TestProtos.ImportMessage element in repeatedImportMessage_) { + size += pb::CodedOutputStream.ComputeMessageSize(50, element); + } } - { + if (repeatedNestedEnum_.Count > 0) { int dataSize = 0; - if (repeatedNestedEnum_.Count > 0) { - foreach (global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum element in repeatedNestedEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 2; - size += pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize); + foreach (global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum element in repeatedNestedEnum_) { + dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); } + size += dataSize; + size += 2; + size += pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize); } - { + if (repeatedForeignEnum_.Count > 0) { int dataSize = 0; - if (repeatedForeignEnum_.Count > 0) { - foreach (global::Google.Protobuf.TestProtos.ForeignEnum element in repeatedForeignEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 2; - size += pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize); + foreach (global::Google.Protobuf.TestProtos.ForeignEnum element in repeatedForeignEnum_) { + dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); } + size += dataSize; + size += 2; + size += pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize); } - { + if (repeatedImportEnum_.Count > 0) { int dataSize = 0; - if (repeatedImportEnum_.Count > 0) { - foreach (global::Google.Protobuf.TestProtos.ImportEnum element in repeatedImportEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 2; - size += pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize); + foreach (global::Google.Protobuf.TestProtos.ImportEnum element in repeatedImportEnum_) { + dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); } + size += dataSize; + size += 2; + size += pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize); } - foreach (global::Google.Protobuf.TestProtos.PublicImportMessage element in repeatedPublicImportMessage_) { - size += pb::CodedOutputStream.ComputeMessageSize(54, element); + if (repeatedPublicImportMessage_.Count > 0) { + foreach (global::Google.Protobuf.TestProtos.PublicImportMessage element in repeatedPublicImportMessage_) { + size += pb::CodedOutputStream.ComputeMessageSize(54, element); + } } if (oneofFieldCase_ == OneofFieldOneofCase.OneofUint32) { size += pb::CodedOutputStream.ComputeUInt32Size(111, OneofUint32); @@ -1293,10 +1313,10 @@ namespace Google.Protobuf.TestProtos { if (other.SingleBool != false) { SingleBool = other.SingleBool; } - if (other.SingleString != "") { + if (other.SingleString.Length != 0) { SingleString = other.SingleString; } - if (other.SingleBytes != pb::ByteString.Empty) { + if (other.SingleBytes.Length != 0) { SingleBytes = other.SingleBytes; } if (other.singleNestedMessage_ != null) { @@ -1383,63 +1403,63 @@ namespace Google.Protobuf.TestProtos { } break; case 8: { - singleInt32_ = input.ReadInt32(); + SingleInt32 = input.ReadInt32(); break; } case 16: { - singleInt64_ = input.ReadInt64(); + SingleInt64 = input.ReadInt64(); break; } case 24: { - singleUint32_ = input.ReadUInt32(); + SingleUint32 = input.ReadUInt32(); break; } case 32: { - singleUint64_ = input.ReadUInt64(); + SingleUint64 = input.ReadUInt64(); break; } case 40: { - singleSint32_ = input.ReadSInt32(); + SingleSint32 = input.ReadSInt32(); break; } case 48: { - singleSint64_ = input.ReadSInt64(); + SingleSint64 = input.ReadSInt64(); break; } case 61: { - singleFixed32_ = input.ReadFixed32(); + SingleFixed32 = input.ReadFixed32(); break; } case 65: { - singleFixed64_ = input.ReadFixed64(); + SingleFixed64 = input.ReadFixed64(); break; } case 77: { - singleSfixed32_ = input.ReadSFixed32(); + SingleSfixed32 = input.ReadSFixed32(); break; } case 81: { - singleSfixed64_ = input.ReadSFixed64(); + SingleSfixed64 = input.ReadSFixed64(); break; } case 93: { - singleFloat_ = input.ReadFloat(); + SingleFloat = input.ReadFloat(); break; } case 97: { - singleDouble_ = input.ReadDouble(); + SingleDouble = input.ReadDouble(); break; } case 104: { - singleBool_ = input.ReadBool(); + SingleBool = input.ReadBool(); break; } case 114: { - singleString_ = input.ReadString(); + SingleString = input.ReadString(); break; } case 122: { - singleBytes_ = input.ReadBytes(); + SingleBytes = input.ReadBytes(); break; } case 146: { @@ -1587,9 +1607,8 @@ namespace Google.Protobuf.TestProtos { break; } case 888: { - oneofField_ = input.ReadUInt32() - ;oneofFieldCase_ = OneofFieldOneofCase.OneofUint32; - break; + OneofUint32 = input.ReadUInt32() + ;break; } case 898: { global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage subBuilder = new global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage(); @@ -1601,14 +1620,12 @@ namespace Google.Protobuf.TestProtos { break; } case 906: { - oneofField_ = input.ReadString() - ;oneofFieldCase_ = OneofFieldOneofCase.OneofString; - break; + OneofString = input.ReadString() + ;break; } case 914: { - oneofField_ = input.ReadBytes() - ;oneofFieldCase_ = OneofFieldOneofCase.OneofBytes; - break; + OneofBytes = input.ReadBytes() + ;break; } } } @@ -1707,7 +1724,7 @@ namespace Google.Protobuf.TestProtos { } break; case 8: { - bb_ = input.ReadInt32(); + Bb = input.ReadInt32(); break; } } @@ -1790,7 +1807,9 @@ namespace Google.Protobuf.TestProtos { if (payload_ != null) { output.WriteMessage(2, Payload); } - output.WriteMessageArray(3, repeatedChild_); + if (repeatedChild_.Count > 0) { + output.WriteMessageArray(3, repeatedChild_); + } } public int CalculateSize() { @@ -1801,8 +1820,10 @@ namespace Google.Protobuf.TestProtos { if (payload_ != null) { size += pb::CodedOutputStream.ComputeMessageSize(2, Payload); } - foreach (global::Google.Protobuf.TestProtos.NestedTestAllTypes element in repeatedChild_) { - size += pb::CodedOutputStream.ComputeMessageSize(3, element); + if (repeatedChild_.Count > 0) { + foreach (global::Google.Protobuf.TestProtos.NestedTestAllTypes element in repeatedChild_) { + size += pb::CodedOutputStream.ComputeMessageSize(3, element); + } } return size; } @@ -1943,7 +1964,7 @@ namespace Google.Protobuf.TestProtos { } break; case 8: { - deprecatedInt32_ = input.ReadInt32(); + DeprecatedInt32 = input.ReadInt32(); break; } } @@ -2034,7 +2055,7 @@ namespace Google.Protobuf.TestProtos { } break; case 8: { - c_ = input.ReadInt32(); + C = input.ReadInt32(); break; } } @@ -2307,11 +2328,11 @@ namespace Google.Protobuf.TestProtos { } break; case 8: { - a_ = input.ReadInt32(); + A = input.ReadInt32(); break; } case 2147483640: { - bb_ = input.ReadInt32(); + Bb = input.ReadInt32(); break; } } @@ -2429,7 +2450,7 @@ namespace Google.Protobuf.TestProtos { break; } case 16: { - i_ = input.ReadInt32(); + I = input.ReadInt32(); break; } } @@ -2642,7 +2663,7 @@ namespace Google.Protobuf.TestProtos { break; } case 16: { - optionalInt32_ = input.ReadInt32(); + OptionalInt32 = input.ReadInt32(); break; } } @@ -2749,7 +2770,7 @@ namespace Google.Protobuf.TestProtos { public override int GetHashCode() { int hash = 0; if (PrimitiveField != 0) hash ^= PrimitiveField.GetHashCode(); - if (StringField != "") hash ^= StringField.GetHashCode(); + if (StringField.Length != 0) hash ^= StringField.GetHashCode(); if (EnumField != global::Google.Protobuf.TestProtos.ForeignEnum.FOREIGN_UNSPECIFIED) hash ^= EnumField.GetHashCode(); if (messageField_ != null) hash ^= MessageField.GetHashCode(); hash ^= repeatedPrimitiveField_.GetHashCode(); @@ -2763,7 +2784,7 @@ namespace Google.Protobuf.TestProtos { if (PrimitiveField != 0) { output.WriteInt32(1, PrimitiveField); } - if (StringField != "") { + if (StringField.Length != 0) { output.WriteString(2, StringField); } if (EnumField != global::Google.Protobuf.TestProtos.ForeignEnum.FOREIGN_UNSPECIFIED) { @@ -2772,10 +2793,18 @@ namespace Google.Protobuf.TestProtos { if (messageField_ != null) { output.WriteMessage(4, MessageField); } - output.WritePackedInt32Array(7, repeatedPrimitiveField_); - output.WriteStringArray(8, repeatedStringField_); - output.WritePackedEnumArray(9, repeatedEnumField_); - output.WriteMessageArray(10, repeatedMessageField_); + if (repeatedPrimitiveField_.Count > 0) { + output.WritePackedInt32Array(7, repeatedPrimitiveField_); + } + if (repeatedStringField_.Count > 0) { + output.WriteStringArray(8, repeatedStringField_); + } + if (repeatedEnumField_.Count > 0) { + output.WritePackedEnumArray(9, repeatedEnumField_); + } + if (repeatedMessageField_.Count > 0) { + output.WriteMessageArray(10, repeatedMessageField_); + } } public int CalculateSize() { @@ -2783,7 +2812,7 @@ namespace Google.Protobuf.TestProtos { if (PrimitiveField != 0) { size += pb::CodedOutputStream.ComputeInt32Size(1, PrimitiveField); } - if (StringField != "") { + if (StringField.Length != 0) { size += pb::CodedOutputStream.ComputeStringSize(2, StringField); } if (EnumField != global::Google.Protobuf.TestProtos.ForeignEnum.FOREIGN_UNSPECIFIED) { @@ -2792,17 +2821,15 @@ namespace Google.Protobuf.TestProtos { if (messageField_ != null) { size += pb::CodedOutputStream.ComputeMessageSize(4, MessageField); } - { + if (repeatedPrimitiveField_.Count > 0) { int dataSize = 0; foreach (int element in repeatedPrimitiveField_) { dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); } size += dataSize; - if (repeatedPrimitiveField_.Count != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } + size += 1 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { + if (repeatedStringField_.Count > 0) { int dataSize = 0; foreach (string element in repeatedStringField_) { dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); @@ -2810,19 +2837,19 @@ namespace Google.Protobuf.TestProtos { size += dataSize; size += 1 * repeatedStringField_.Count; } - { + if (repeatedEnumField_.Count > 0) { int dataSize = 0; - if (repeatedEnumField_.Count > 0) { - foreach (global::Google.Protobuf.TestProtos.ForeignEnum element in repeatedEnumField_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 1; - size += pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize); + foreach (global::Google.Protobuf.TestProtos.ForeignEnum element in repeatedEnumField_) { + dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); } + size += dataSize; + size += 1; + size += pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize); } - foreach (global::Google.Protobuf.TestProtos.ForeignMessage element in repeatedMessageField_) { - size += pb::CodedOutputStream.ComputeMessageSize(10, element); + if (repeatedMessageField_.Count > 0) { + foreach (global::Google.Protobuf.TestProtos.ForeignMessage element in repeatedMessageField_) { + size += pb::CodedOutputStream.ComputeMessageSize(10, element); + } } return size; } @@ -2833,7 +2860,7 @@ namespace Google.Protobuf.TestProtos { if (other.PrimitiveField != 0) { PrimitiveField = other.PrimitiveField; } - if (other.StringField != "") { + if (other.StringField.Length != 0) { StringField = other.StringField; } if (other.EnumField != global::Google.Protobuf.TestProtos.ForeignEnum.FOREIGN_UNSPECIFIED) { @@ -2863,11 +2890,11 @@ namespace Google.Protobuf.TestProtos { } break; case 8: { - primitiveField_ = input.ReadInt32(); + PrimitiveField = input.ReadInt32(); break; } case 18: { - stringField_ = input.ReadString(); + StringField = input.ReadString(); break; } case 24: { @@ -2974,7 +3001,7 @@ namespace Google.Protobuf.TestProtos { public override int GetHashCode() { int hash = 0; - if (MyString != "") hash ^= MyString.GetHashCode(); + if (MyString.Length != 0) hash ^= MyString.GetHashCode(); if (MyInt != 0L) hash ^= MyInt.GetHashCode(); if (MyFloat != 0F) hash ^= MyFloat.GetHashCode(); if (singleNestedMessage_ != null) hash ^= SingleNestedMessage.GetHashCode(); @@ -2985,7 +3012,7 @@ namespace Google.Protobuf.TestProtos { if (MyInt != 0L) { output.WriteInt64(1, MyInt); } - if (MyString != "") { + if (MyString.Length != 0) { output.WriteString(11, MyString); } if (MyFloat != 0F) { @@ -2998,7 +3025,7 @@ namespace Google.Protobuf.TestProtos { public int CalculateSize() { int size = 0; - if (MyString != "") { + if (MyString.Length != 0) { size += pb::CodedOutputStream.ComputeStringSize(11, MyString); } if (MyInt != 0L) { @@ -3016,7 +3043,7 @@ namespace Google.Protobuf.TestProtos { if (other == null) { return; } - if (other.MyString != "") { + if (other.MyString.Length != 0) { MyString = other.MyString; } if (other.MyInt != 0L) { @@ -3045,15 +3072,15 @@ namespace Google.Protobuf.TestProtos { } break; case 8: { - myInt_ = input.ReadInt64(); + MyInt = input.ReadInt64(); break; } case 90: { - myString_ = input.ReadString(); + MyString = input.ReadString(); break; } case 813: { - myFloat_ = input.ReadFloat(); + MyFloat = input.ReadFloat(); break; } case 1602: { @@ -3171,11 +3198,11 @@ namespace Google.Protobuf.TestProtos { } break; case 8: { - bb_ = input.ReadInt32(); + Bb = input.ReadInt32(); break; } case 16: { - oo_ = input.ReadInt64(); + Oo = input.ReadInt64(); break; } } @@ -3324,19 +3351,19 @@ namespace Google.Protobuf.TestProtos { public override int GetHashCode() { int hash = 0; - if (Data != "") hash ^= Data.GetHashCode(); + if (Data.Length != 0) hash ^= Data.GetHashCode(); return hash; } public void WriteTo(pb::CodedOutputStream output) { - if (Data != "") { + if (Data.Length != 0) { output.WriteString(1, Data); } } public int CalculateSize() { int size = 0; - if (Data != "") { + if (Data.Length != 0) { size += pb::CodedOutputStream.ComputeStringSize(1, Data); } return size; @@ -3345,7 +3372,7 @@ namespace Google.Protobuf.TestProtos { if (other == null) { return; } - if (other.Data != "") { + if (other.Data.Length != 0) { Data = other.Data; } } @@ -3362,7 +3389,7 @@ namespace Google.Protobuf.TestProtos { } break; case 10: { - data_ = input.ReadString(); + Data = input.ReadString(); break; } } @@ -3418,12 +3445,14 @@ namespace Google.Protobuf.TestProtos { } public void WriteTo(pb::CodedOutputStream output) { - output.WriteStringArray(1, data_); + if (data_.Count > 0) { + output.WriteStringArray(1, data_); + } } public int CalculateSize() { int size = 0; - { + if (data_.Count > 0) { int dataSize = 0; foreach (string element in data_) { dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); @@ -3505,19 +3534,19 @@ namespace Google.Protobuf.TestProtos { public override int GetHashCode() { int hash = 0; - if (Data != pb::ByteString.Empty) hash ^= Data.GetHashCode(); + if (Data.Length != 0) hash ^= Data.GetHashCode(); return hash; } public void WriteTo(pb::CodedOutputStream output) { - if (Data != pb::ByteString.Empty) { + if (Data.Length != 0) { output.WriteBytes(1, Data); } } public int CalculateSize() { int size = 0; - if (Data != pb::ByteString.Empty) { + if (Data.Length != 0) { size += pb::CodedOutputStream.ComputeBytesSize(1, Data); } return size; @@ -3526,7 +3555,7 @@ namespace Google.Protobuf.TestProtos { if (other == null) { return; } - if (other.Data != pb::ByteString.Empty) { + if (other.Data.Length != 0) { Data = other.Data; } } @@ -3543,7 +3572,7 @@ namespace Google.Protobuf.TestProtos { } break; case 10: { - data_ = input.ReadBytes(); + Data = input.ReadBytes(); break; } } @@ -3596,19 +3625,19 @@ namespace Google.Protobuf.TestProtos { public override int GetHashCode() { int hash = 0; - if (Data != pb::ByteString.Empty) hash ^= Data.GetHashCode(); + if (Data.Length != 0) hash ^= Data.GetHashCode(); return hash; } public void WriteTo(pb::CodedOutputStream output) { - if (Data != pb::ByteString.Empty) { + if (Data.Length != 0) { output.WriteBytes(1, Data); } } public int CalculateSize() { int size = 0; - if (Data != pb::ByteString.Empty) { + if (Data.Length != 0) { size += pb::CodedOutputStream.ComputeBytesSize(1, Data); } return size; @@ -3617,7 +3646,7 @@ namespace Google.Protobuf.TestProtos { if (other == null) { return; } - if (other.Data != pb::ByteString.Empty) { + if (other.Data.Length != 0) { Data = other.Data; } } @@ -3634,7 +3663,7 @@ namespace Google.Protobuf.TestProtos { } break; case 10: { - data_ = input.ReadBytes(); + Data = input.ReadBytes(); break; } } @@ -3725,7 +3754,7 @@ namespace Google.Protobuf.TestProtos { } break; case 8: { - data_ = input.ReadInt32(); + Data = input.ReadInt32(); break; } } @@ -3816,7 +3845,7 @@ namespace Google.Protobuf.TestProtos { } break; case 8: { - data_ = input.ReadUInt32(); + Data = input.ReadUInt32(); break; } } @@ -3907,7 +3936,7 @@ namespace Google.Protobuf.TestProtos { } break; case 8: { - data_ = input.ReadInt64(); + Data = input.ReadInt64(); break; } } @@ -3998,7 +4027,7 @@ namespace Google.Protobuf.TestProtos { } break; case 8: { - data_ = input.ReadUInt64(); + Data = input.ReadUInt64(); break; } } @@ -4089,7 +4118,7 @@ namespace Google.Protobuf.TestProtos { } break; case 8: { - data_ = input.ReadBool(); + Data = input.ReadBool(); break; } } @@ -4131,7 +4160,7 @@ namespace Google.Protobuf.TestProtos { get { return fooCase_ == FooOneofCase.FooString ? (string) foo_ : ""; } set { foo_ = value ?? ""; - fooCase_ = value == null ? FooOneofCase.None : FooOneofCase.FooString; + fooCase_ = FooOneofCase.FooString; } } @@ -4240,14 +4269,12 @@ namespace Google.Protobuf.TestProtos { } break; case 8: { - foo_ = input.ReadInt32() - ;fooCase_ = FooOneofCase.FooInt; - break; + FooInt = input.ReadInt32() + ;break; } case 18: { - foo_ = input.ReadString() - ;fooCase_ = FooOneofCase.FooString; - break; + FooString = input.ReadString() + ;break; } case 26: { global::Google.Protobuf.TestProtos.TestAllTypes subBuilder = new global::Google.Protobuf.TestProtos.TestAllTypes(); @@ -4415,150 +4442,150 @@ namespace Google.Protobuf.TestProtos { } public void WriteTo(pb::CodedOutputStream output) { - output.WritePackedInt32Array(90, packedInt32_); - output.WritePackedInt64Array(91, packedInt64_); - output.WritePackedUInt32Array(92, packedUint32_); - output.WritePackedUInt64Array(93, packedUint64_); - output.WritePackedSInt32Array(94, packedSint32_); - output.WritePackedSInt64Array(95, packedSint64_); - output.WritePackedFixed32Array(96, packedFixed32_); - output.WritePackedFixed64Array(97, packedFixed64_); - output.WritePackedSFixed32Array(98, packedSfixed32_); - output.WritePackedSFixed64Array(99, packedSfixed64_); - output.WritePackedFloatArray(100, packedFloat_); - output.WritePackedDoubleArray(101, packedDouble_); - output.WritePackedBoolArray(102, packedBool_); - output.WritePackedEnumArray(103, packedEnum_); + if (packedInt32_.Count > 0) { + output.WritePackedInt32Array(90, packedInt32_); + } + if (packedInt64_.Count > 0) { + output.WritePackedInt64Array(91, packedInt64_); + } + if (packedUint32_.Count > 0) { + output.WritePackedUInt32Array(92, packedUint32_); + } + if (packedUint64_.Count > 0) { + output.WritePackedUInt64Array(93, packedUint64_); + } + if (packedSint32_.Count > 0) { + output.WritePackedSInt32Array(94, packedSint32_); + } + if (packedSint64_.Count > 0) { + output.WritePackedSInt64Array(95, packedSint64_); + } + if (packedFixed32_.Count > 0) { + output.WritePackedFixed32Array(96, packedFixed32_); + } + if (packedFixed64_.Count > 0) { + output.WritePackedFixed64Array(97, packedFixed64_); + } + if (packedSfixed32_.Count > 0) { + output.WritePackedSFixed32Array(98, packedSfixed32_); + } + if (packedSfixed64_.Count > 0) { + output.WritePackedSFixed64Array(99, packedSfixed64_); + } + if (packedFloat_.Count > 0) { + output.WritePackedFloatArray(100, packedFloat_); + } + if (packedDouble_.Count > 0) { + output.WritePackedDoubleArray(101, packedDouble_); + } + if (packedBool_.Count > 0) { + output.WritePackedBoolArray(102, packedBool_); + } + if (packedEnum_.Count > 0) { + output.WritePackedEnumArray(103, packedEnum_); + } } public int CalculateSize() { int size = 0; - { + if (packedInt32_.Count > 0) { int dataSize = 0; foreach (int element in packedInt32_) { dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); } size += dataSize; - if (packedInt32_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { + if (packedInt64_.Count > 0) { int dataSize = 0; foreach (long element in packedInt64_) { dataSize += pb::CodedOutputStream.ComputeInt64SizeNoTag(element); } size += dataSize; - if (packedInt64_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { + if (packedUint32_.Count > 0) { int dataSize = 0; foreach (uint element in packedUint32_) { dataSize += pb::CodedOutputStream.ComputeUInt32SizeNoTag(element); } size += dataSize; - if (packedUint32_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { + if (packedUint64_.Count > 0) { int dataSize = 0; foreach (ulong element in packedUint64_) { dataSize += pb::CodedOutputStream.ComputeUInt64SizeNoTag(element); } size += dataSize; - if (packedUint64_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { + if (packedSint32_.Count > 0) { int dataSize = 0; foreach (int element in packedSint32_) { dataSize += pb::CodedOutputStream.ComputeSInt32SizeNoTag(element); } size += dataSize; - if (packedSint32_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { + if (packedSint64_.Count > 0) { int dataSize = 0; foreach (long element in packedSint64_) { dataSize += pb::CodedOutputStream.ComputeSInt64SizeNoTag(element); } size += dataSize; - if (packedSint64_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { + if (packedFixed32_.Count > 0) { int dataSize = 0; dataSize = 4 * packedFixed32_.Count; size += dataSize; - if (packedFixed32_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { + if (packedFixed64_.Count > 0) { int dataSize = 0; dataSize = 8 * packedFixed64_.Count; size += dataSize; - if (packedFixed64_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { + if (packedSfixed32_.Count > 0) { int dataSize = 0; dataSize = 4 * packedSfixed32_.Count; size += dataSize; - if (packedSfixed32_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { + if (packedSfixed64_.Count > 0) { int dataSize = 0; dataSize = 8 * packedSfixed64_.Count; size += dataSize; - if (packedSfixed64_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { + if (packedFloat_.Count > 0) { int dataSize = 0; dataSize = 4 * packedFloat_.Count; size += dataSize; - if (packedFloat_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { + if (packedDouble_.Count > 0) { int dataSize = 0; dataSize = 8 * packedDouble_.Count; size += dataSize; - if (packedDouble_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { + if (packedBool_.Count > 0) { int dataSize = 0; dataSize = 1 * packedBool_.Count; size += dataSize; - if (packedBool_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { + if (packedEnum_.Count > 0) { int dataSize = 0; - if (packedEnum_.Count > 0) { - foreach (global::Google.Protobuf.TestProtos.ForeignEnum element in packedEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 2; - size += pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize); + foreach (global::Google.Protobuf.TestProtos.ForeignEnum element in packedEnum_) { + dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); } + size += dataSize; + size += 2; + size += pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize); } return size; } @@ -4820,25 +4847,53 @@ namespace Google.Protobuf.TestProtos { } public void WriteTo(pb::CodedOutputStream output) { - output.WriteInt32Array(90, unpackedInt32_); - output.WriteInt64Array(91, unpackedInt64_); - output.WriteUInt32Array(92, unpackedUint32_); - output.WriteUInt64Array(93, unpackedUint64_); - output.WriteSInt32Array(94, unpackedSint32_); - output.WriteSInt64Array(95, unpackedSint64_); - output.WriteFixed32Array(96, unpackedFixed32_); - output.WriteFixed64Array(97, unpackedFixed64_); - output.WriteSFixed32Array(98, unpackedSfixed32_); - output.WriteSFixed64Array(99, unpackedSfixed64_); - output.WriteFloatArray(100, unpackedFloat_); - output.WriteDoubleArray(101, unpackedDouble_); - output.WriteBoolArray(102, unpackedBool_); - output.WriteEnumArray(103, unpackedEnum_); + if (unpackedInt32_.Count > 0) { + output.WriteInt32Array(90, unpackedInt32_); + } + if (unpackedInt64_.Count > 0) { + output.WriteInt64Array(91, unpackedInt64_); + } + if (unpackedUint32_.Count > 0) { + output.WriteUInt32Array(92, unpackedUint32_); + } + if (unpackedUint64_.Count > 0) { + output.WriteUInt64Array(93, unpackedUint64_); + } + if (unpackedSint32_.Count > 0) { + output.WriteSInt32Array(94, unpackedSint32_); + } + if (unpackedSint64_.Count > 0) { + output.WriteSInt64Array(95, unpackedSint64_); + } + if (unpackedFixed32_.Count > 0) { + output.WriteFixed32Array(96, unpackedFixed32_); + } + if (unpackedFixed64_.Count > 0) { + output.WriteFixed64Array(97, unpackedFixed64_); + } + if (unpackedSfixed32_.Count > 0) { + output.WriteSFixed32Array(98, unpackedSfixed32_); + } + if (unpackedSfixed64_.Count > 0) { + output.WriteSFixed64Array(99, unpackedSfixed64_); + } + if (unpackedFloat_.Count > 0) { + output.WriteFloatArray(100, unpackedFloat_); + } + if (unpackedDouble_.Count > 0) { + output.WriteDoubleArray(101, unpackedDouble_); + } + if (unpackedBool_.Count > 0) { + output.WriteBoolArray(102, unpackedBool_); + } + if (unpackedEnum_.Count > 0) { + output.WriteEnumArray(103, unpackedEnum_); + } } public int CalculateSize() { int size = 0; - { + if (unpackedInt32_.Count > 0) { int dataSize = 0; foreach (int element in unpackedInt32_) { dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); @@ -4846,7 +4901,7 @@ namespace Google.Protobuf.TestProtos { size += dataSize; size += 2 * unpackedInt32_.Count; } - { + if (unpackedInt64_.Count > 0) { int dataSize = 0; foreach (long element in unpackedInt64_) { dataSize += pb::CodedOutputStream.ComputeInt64SizeNoTag(element); @@ -4854,7 +4909,7 @@ namespace Google.Protobuf.TestProtos { size += dataSize; size += 2 * unpackedInt64_.Count; } - { + if (unpackedUint32_.Count > 0) { int dataSize = 0; foreach (uint element in unpackedUint32_) { dataSize += pb::CodedOutputStream.ComputeUInt32SizeNoTag(element); @@ -4862,7 +4917,7 @@ namespace Google.Protobuf.TestProtos { size += dataSize; size += 2 * unpackedUint32_.Count; } - { + if (unpackedUint64_.Count > 0) { int dataSize = 0; foreach (ulong element in unpackedUint64_) { dataSize += pb::CodedOutputStream.ComputeUInt64SizeNoTag(element); @@ -4870,7 +4925,7 @@ namespace Google.Protobuf.TestProtos { size += dataSize; size += 2 * unpackedUint64_.Count; } - { + if (unpackedSint32_.Count > 0) { int dataSize = 0; foreach (int element in unpackedSint32_) { dataSize += pb::CodedOutputStream.ComputeSInt32SizeNoTag(element); @@ -4878,7 +4933,7 @@ namespace Google.Protobuf.TestProtos { size += dataSize; size += 2 * unpackedSint32_.Count; } - { + if (unpackedSint64_.Count > 0) { int dataSize = 0; foreach (long element in unpackedSint64_) { dataSize += pb::CodedOutputStream.ComputeSInt64SizeNoTag(element); @@ -4886,57 +4941,55 @@ namespace Google.Protobuf.TestProtos { size += dataSize; size += 2 * unpackedSint64_.Count; } - { + if (unpackedFixed32_.Count > 0) { int dataSize = 0; dataSize = 4 * unpackedFixed32_.Count; size += dataSize; size += 2 * unpackedFixed32_.Count; } - { + if (unpackedFixed64_.Count > 0) { int dataSize = 0; dataSize = 8 * unpackedFixed64_.Count; size += dataSize; size += 2 * unpackedFixed64_.Count; } - { + if (unpackedSfixed32_.Count > 0) { int dataSize = 0; dataSize = 4 * unpackedSfixed32_.Count; size += dataSize; size += 2 * unpackedSfixed32_.Count; } - { + if (unpackedSfixed64_.Count > 0) { int dataSize = 0; dataSize = 8 * unpackedSfixed64_.Count; size += dataSize; size += 2 * unpackedSfixed64_.Count; } - { + if (unpackedFloat_.Count > 0) { int dataSize = 0; dataSize = 4 * unpackedFloat_.Count; size += dataSize; size += 2 * unpackedFloat_.Count; } - { + if (unpackedDouble_.Count > 0) { int dataSize = 0; dataSize = 8 * unpackedDouble_.Count; size += dataSize; size += 2 * unpackedDouble_.Count; } - { + if (unpackedBool_.Count > 0) { int dataSize = 0; dataSize = 1 * unpackedBool_.Count; size += dataSize; size += 2 * unpackedBool_.Count; } - { + if (unpackedEnum_.Count > 0) { int dataSize = 0; - if (unpackedEnum_.Count > 0) { - foreach (global::Google.Protobuf.TestProtos.ForeignEnum element in unpackedEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 2 * unpackedEnum_.Count; + foreach (global::Google.Protobuf.TestProtos.ForeignEnum element in unpackedEnum_) { + dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); } + size += dataSize; + size += 2 * unpackedEnum_.Count; } return size; } @@ -5134,69 +5187,69 @@ namespace Google.Protobuf.TestProtos { } public void WriteTo(pb::CodedOutputStream output) { - output.WritePackedFixed32Array(12, repeatedFixed32_); - output.WritePackedInt32Array(13, repeatedInt32_); - output.WritePackedFixed64Array(2046, repeatedFixed64_); - output.WritePackedInt64Array(2047, repeatedInt64_); - output.WritePackedFloatArray(262142, repeatedFloat_); - output.WritePackedUInt64Array(262143, repeatedUint64_); + if (repeatedFixed32_.Count > 0) { + output.WritePackedFixed32Array(12, repeatedFixed32_); + } + if (repeatedInt32_.Count > 0) { + output.WritePackedInt32Array(13, repeatedInt32_); + } + if (repeatedFixed64_.Count > 0) { + output.WritePackedFixed64Array(2046, repeatedFixed64_); + } + if (repeatedInt64_.Count > 0) { + output.WritePackedInt64Array(2047, repeatedInt64_); + } + if (repeatedFloat_.Count > 0) { + output.WritePackedFloatArray(262142, repeatedFloat_); + } + if (repeatedUint64_.Count > 0) { + output.WritePackedUInt64Array(262143, repeatedUint64_); + } } public int CalculateSize() { int size = 0; - { + if (repeatedFixed32_.Count > 0) { int dataSize = 0; dataSize = 4 * repeatedFixed32_.Count; size += dataSize; - if (repeatedFixed32_.Count != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } + size += 1 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { + if (repeatedInt32_.Count > 0) { int dataSize = 0; foreach (int element in repeatedInt32_) { dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); } size += dataSize; - if (repeatedInt32_.Count != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } + size += 1 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { + if (repeatedFixed64_.Count > 0) { int dataSize = 0; dataSize = 8 * repeatedFixed64_.Count; size += dataSize; - if (repeatedFixed64_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { + if (repeatedInt64_.Count > 0) { int dataSize = 0; foreach (long element in repeatedInt64_) { dataSize += pb::CodedOutputStream.ComputeInt64SizeNoTag(element); } size += dataSize; - if (repeatedInt64_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } + size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { + if (repeatedFloat_.Count > 0) { int dataSize = 0; dataSize = 4 * repeatedFloat_.Count; size += dataSize; - if (repeatedFloat_.Count != 0) { - size += 3 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } + size += 3 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { + if (repeatedUint64_.Count > 0) { int dataSize = 0; foreach (ulong element in repeatedUint64_) { dataSize += pb::CodedOutputStream.ComputeUInt64SizeNoTag(element); } size += dataSize; - if (repeatedUint64_.Count != 0) { - size += 3 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } + size += 3 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } return size; } @@ -5303,19 +5356,19 @@ namespace Google.Protobuf.TestProtos { public override int GetHashCode() { int hash = 0; - if (A != "") hash ^= A.GetHashCode(); + if (A.Length != 0) hash ^= A.GetHashCode(); return hash; } public void WriteTo(pb::CodedOutputStream output) { - if (A != "") { + if (A.Length != 0) { output.WriteString(1, A); } } public int CalculateSize() { int size = 0; - if (A != "") { + if (A.Length != 0) { size += pb::CodedOutputStream.ComputeStringSize(1, A); } return size; @@ -5324,7 +5377,7 @@ namespace Google.Protobuf.TestProtos { if (other == null) { return; } - if (other.A != "") { + if (other.A.Length != 0) { A = other.A; } } @@ -5341,7 +5394,7 @@ namespace Google.Protobuf.TestProtos { } break; case 10: { - a_ = input.ReadString(); + A = input.ReadString(); break; } } diff --git a/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs b/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs index f4af4e2c..9a10d6ae 100644 --- a/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs +++ b/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs @@ -324,13 +324,17 @@ namespace Google.Protobuf.DescriptorProtos { } public void WriteTo(pb::CodedOutputStream output) { - output.WriteMessageArray(1, file_); + if (file_.Count > 0) { + output.WriteMessageArray(1, file_); + } } public int CalculateSize() { int size = 0; - foreach (global::Google.Protobuf.DescriptorProtos.FileDescriptorProto element in file_) { - size += pb::CodedOutputStream.ComputeMessageSize(1, element); + if (file_.Count > 0) { + foreach (global::Google.Protobuf.DescriptorProtos.FileDescriptorProto element in file_) { + size += pb::CodedOutputStream.ComputeMessageSize(1, element); + } } return size; } @@ -487,8 +491,8 @@ namespace Google.Protobuf.DescriptorProtos { public override int GetHashCode() { int hash = 0; - if (Name != "") hash ^= Name.GetHashCode(); - if (Package != "") hash ^= Package.GetHashCode(); + if (Name.Length != 0) hash ^= Name.GetHashCode(); + if (Package.Length != 0) hash ^= Package.GetHashCode(); hash ^= dependency_.GetHashCode(); hash ^= publicDependency_.GetHashCode(); hash ^= weakDependency_.GetHashCode(); @@ -498,44 +502,58 @@ namespace Google.Protobuf.DescriptorProtos { hash ^= extension_.GetHashCode(); if (options_ != null) hash ^= Options.GetHashCode(); if (sourceCodeInfo_ != null) hash ^= SourceCodeInfo.GetHashCode(); - if (Syntax != "") hash ^= Syntax.GetHashCode(); + if (Syntax.Length != 0) hash ^= Syntax.GetHashCode(); return hash; } public void WriteTo(pb::CodedOutputStream output) { - if (Name != "") { + if (Name.Length != 0) { output.WriteString(1, Name); } - if (Package != "") { + if (Package.Length != 0) { output.WriteString(2, Package); } - output.WriteStringArray(3, dependency_); - output.WriteMessageArray(4, messageType_); - output.WriteMessageArray(5, enumType_); - output.WriteMessageArray(6, service_); - output.WriteMessageArray(7, extension_); + if (dependency_.Count > 0) { + output.WriteStringArray(3, dependency_); + } + if (messageType_.Count > 0) { + output.WriteMessageArray(4, messageType_); + } + if (enumType_.Count > 0) { + output.WriteMessageArray(5, enumType_); + } + if (service_.Count > 0) { + output.WriteMessageArray(6, service_); + } + if (extension_.Count > 0) { + output.WriteMessageArray(7, extension_); + } if (options_ != null) { output.WriteMessage(8, Options); } if (sourceCodeInfo_ != null) { output.WriteMessage(9, SourceCodeInfo); } - output.WriteInt32Array(10, publicDependency_); - output.WriteInt32Array(11, weakDependency_); - if (Syntax != "") { + if (publicDependency_.Count > 0) { + output.WriteInt32Array(10, publicDependency_); + } + if (weakDependency_.Count > 0) { + output.WriteInt32Array(11, weakDependency_); + } + if (Syntax.Length != 0) { output.WriteString(12, Syntax); } } public int CalculateSize() { int size = 0; - if (Name != "") { + if (Name.Length != 0) { size += pb::CodedOutputStream.ComputeStringSize(1, Name); } - if (Package != "") { + if (Package.Length != 0) { size += pb::CodedOutputStream.ComputeStringSize(2, Package); } - { + if (dependency_.Count > 0) { int dataSize = 0; foreach (string element in dependency_) { dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); @@ -543,7 +561,7 @@ namespace Google.Protobuf.DescriptorProtos { size += dataSize; size += 1 * dependency_.Count; } - { + if (publicDependency_.Count > 0) { int dataSize = 0; foreach (int element in publicDependency_) { dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); @@ -551,7 +569,7 @@ namespace Google.Protobuf.DescriptorProtos { size += dataSize; size += 1 * publicDependency_.Count; } - { + if (weakDependency_.Count > 0) { int dataSize = 0; foreach (int element in weakDependency_) { dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); @@ -559,17 +577,25 @@ namespace Google.Protobuf.DescriptorProtos { size += dataSize; size += 1 * weakDependency_.Count; } - foreach (global::Google.Protobuf.DescriptorProtos.DescriptorProto element in messageType_) { - size += pb::CodedOutputStream.ComputeMessageSize(4, element); + if (messageType_.Count > 0) { + foreach (global::Google.Protobuf.DescriptorProtos.DescriptorProto element in messageType_) { + size += pb::CodedOutputStream.ComputeMessageSize(4, element); + } } - foreach (global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto element in enumType_) { - size += pb::CodedOutputStream.ComputeMessageSize(5, element); + if (enumType_.Count > 0) { + foreach (global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto element in enumType_) { + size += pb::CodedOutputStream.ComputeMessageSize(5, element); + } } - foreach (global::Google.Protobuf.DescriptorProtos.ServiceDescriptorProto element in service_) { - size += pb::CodedOutputStream.ComputeMessageSize(6, element); + if (service_.Count > 0) { + foreach (global::Google.Protobuf.DescriptorProtos.ServiceDescriptorProto element in service_) { + size += pb::CodedOutputStream.ComputeMessageSize(6, element); + } } - foreach (global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto element in extension_) { - size += pb::CodedOutputStream.ComputeMessageSize(7, element); + if (extension_.Count > 0) { + foreach (global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto element in extension_) { + size += pb::CodedOutputStream.ComputeMessageSize(7, element); + } } if (options_ != null) { size += pb::CodedOutputStream.ComputeMessageSize(8, Options); @@ -577,7 +603,7 @@ namespace Google.Protobuf.DescriptorProtos { if (sourceCodeInfo_ != null) { size += pb::CodedOutputStream.ComputeMessageSize(9, SourceCodeInfo); } - if (Syntax != "") { + if (Syntax.Length != 0) { size += pb::CodedOutputStream.ComputeStringSize(12, Syntax); } return size; @@ -586,10 +612,10 @@ namespace Google.Protobuf.DescriptorProtos { if (other == null) { return; } - if (other.Name != "") { + if (other.Name.Length != 0) { Name = other.Name; } - if (other.Package != "") { + if (other.Package.Length != 0) { Package = other.Package; } dependency_.Add(other.dependency_); @@ -611,7 +637,7 @@ namespace Google.Protobuf.DescriptorProtos { } SourceCodeInfo.MergeFrom(other.SourceCodeInfo); } - if (other.Syntax != "") { + if (other.Syntax.Length != 0) { Syntax = other.Syntax; } } @@ -628,11 +654,11 @@ namespace Google.Protobuf.DescriptorProtos { } break; case 10: { - name_ = input.ReadString(); + Name = input.ReadString(); break; } case 18: { - package_ = input.ReadString(); + Package = input.ReadString(); break; } case 26: { @@ -680,7 +706,7 @@ namespace Google.Protobuf.DescriptorProtos { break; } case 98: { - syntax_ = input.ReadString(); + Syntax = input.ReadString(); break; } } @@ -796,7 +822,7 @@ namespace Google.Protobuf.DescriptorProtos { public override int GetHashCode() { int hash = 0; - if (Name != "") hash ^= Name.GetHashCode(); + if (Name.Length != 0) hash ^= Name.GetHashCode(); hash ^= field_.GetHashCode(); hash ^= extension_.GetHashCode(); hash ^= nestedType_.GetHashCode(); @@ -810,52 +836,82 @@ namespace Google.Protobuf.DescriptorProtos { } public void WriteTo(pb::CodedOutputStream output) { - if (Name != "") { + if (Name.Length != 0) { output.WriteString(1, Name); } - output.WriteMessageArray(2, field_); - output.WriteMessageArray(3, nestedType_); - output.WriteMessageArray(4, enumType_); - output.WriteMessageArray(5, extensionRange_); - output.WriteMessageArray(6, extension_); + if (field_.Count > 0) { + output.WriteMessageArray(2, field_); + } + if (nestedType_.Count > 0) { + output.WriteMessageArray(3, nestedType_); + } + if (enumType_.Count > 0) { + output.WriteMessageArray(4, enumType_); + } + if (extensionRange_.Count > 0) { + output.WriteMessageArray(5, extensionRange_); + } + if (extension_.Count > 0) { + output.WriteMessageArray(6, extension_); + } if (options_ != null) { output.WriteMessage(7, Options); } - output.WriteMessageArray(8, oneofDecl_); - output.WriteMessageArray(9, reservedRange_); - output.WriteStringArray(10, reservedName_); + if (oneofDecl_.Count > 0) { + output.WriteMessageArray(8, oneofDecl_); + } + if (reservedRange_.Count > 0) { + output.WriteMessageArray(9, reservedRange_); + } + if (reservedName_.Count > 0) { + output.WriteStringArray(10, reservedName_); + } } public int CalculateSize() { int size = 0; - if (Name != "") { + if (Name.Length != 0) { size += pb::CodedOutputStream.ComputeStringSize(1, Name); } - foreach (global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto element in field_) { - size += pb::CodedOutputStream.ComputeMessageSize(2, element); + if (field_.Count > 0) { + foreach (global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto element in field_) { + size += pb::CodedOutputStream.ComputeMessageSize(2, element); + } } - foreach (global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto element in extension_) { - size += pb::CodedOutputStream.ComputeMessageSize(6, element); + if (extension_.Count > 0) { + foreach (global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto element in extension_) { + size += pb::CodedOutputStream.ComputeMessageSize(6, element); + } } - foreach (global::Google.Protobuf.DescriptorProtos.DescriptorProto element in nestedType_) { - size += pb::CodedOutputStream.ComputeMessageSize(3, element); + if (nestedType_.Count > 0) { + foreach (global::Google.Protobuf.DescriptorProtos.DescriptorProto element in nestedType_) { + size += pb::CodedOutputStream.ComputeMessageSize(3, element); + } } - foreach (global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto element in enumType_) { - size += pb::CodedOutputStream.ComputeMessageSize(4, element); + if (enumType_.Count > 0) { + foreach (global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto element in enumType_) { + size += pb::CodedOutputStream.ComputeMessageSize(4, element); + } } - foreach (global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ExtensionRange element in extensionRange_) { - size += pb::CodedOutputStream.ComputeMessageSize(5, element); + if (extensionRange_.Count > 0) { + foreach (global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ExtensionRange element in extensionRange_) { + size += pb::CodedOutputStream.ComputeMessageSize(5, element); + } } - foreach (global::Google.Protobuf.DescriptorProtos.OneofDescriptorProto element in oneofDecl_) { - size += pb::CodedOutputStream.ComputeMessageSize(8, element); + if (oneofDecl_.Count > 0) { + foreach (global::Google.Protobuf.DescriptorProtos.OneofDescriptorProto element in oneofDecl_) { + size += pb::CodedOutputStream.ComputeMessageSize(8, element); + } } if (options_ != null) { size += pb::CodedOutputStream.ComputeMessageSize(7, Options); } - foreach (global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ReservedRange element in reservedRange_) { - size += pb::CodedOutputStream.ComputeMessageSize(9, element); + if (reservedRange_.Count > 0) { + foreach (global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ReservedRange element in reservedRange_) { + size += pb::CodedOutputStream.ComputeMessageSize(9, element); + } } - { + if (reservedName_.Count > 0) { int dataSize = 0; foreach (string element in reservedName_) { dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); @@ -869,7 +925,7 @@ namespace Google.Protobuf.DescriptorProtos { if (other == null) { return; } - if (other.Name != "") { + if (other.Name.Length != 0) { Name = other.Name; } field_.Add(other.field_); @@ -900,7 +956,7 @@ namespace Google.Protobuf.DescriptorProtos { } break; case 10: { - name_ = input.ReadString(); + Name = input.ReadString(); break; } case 18: { @@ -1050,11 +1106,11 @@ namespace Google.Protobuf.DescriptorProtos { } break; case 8: { - start_ = input.ReadInt32(); + Start = input.ReadInt32(); break; } case 16: { - end_ = input.ReadInt32(); + End = input.ReadInt32(); break; } } @@ -1164,11 +1220,11 @@ namespace Google.Protobuf.DescriptorProtos { } break; case 8: { - start_ = input.ReadInt32(); + Start = input.ReadInt32(); break; } case 16: { - end_ = input.ReadInt32(); + End = input.ReadInt32(); break; } } @@ -1296,23 +1352,23 @@ namespace Google.Protobuf.DescriptorProtos { public override int GetHashCode() { int hash = 0; - if (Name != "") hash ^= Name.GetHashCode(); + if (Name.Length != 0) hash ^= Name.GetHashCode(); if (Number != 0) hash ^= Number.GetHashCode(); if (Label != global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Label.LABEL_OPTIONAL) hash ^= Label.GetHashCode(); if (Type != global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Type.TYPE_DOUBLE) hash ^= Type.GetHashCode(); - if (TypeName != "") hash ^= TypeName.GetHashCode(); - if (Extendee != "") hash ^= Extendee.GetHashCode(); - if (DefaultValue != "") hash ^= DefaultValue.GetHashCode(); + if (TypeName.Length != 0) hash ^= TypeName.GetHashCode(); + if (Extendee.Length != 0) hash ^= Extendee.GetHashCode(); + if (DefaultValue.Length != 0) hash ^= DefaultValue.GetHashCode(); if (OneofIndex != 0) hash ^= OneofIndex.GetHashCode(); if (options_ != null) hash ^= Options.GetHashCode(); return hash; } public void WriteTo(pb::CodedOutputStream output) { - if (Name != "") { + if (Name.Length != 0) { output.WriteString(1, Name); } - if (Extendee != "") { + if (Extendee.Length != 0) { output.WriteString(2, Extendee); } if (Number != 0) { @@ -1324,10 +1380,10 @@ namespace Google.Protobuf.DescriptorProtos { if (Type != global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Type.TYPE_DOUBLE) { output.WriteEnum(5, (int) Type); } - if (TypeName != "") { + if (TypeName.Length != 0) { output.WriteString(6, TypeName); } - if (DefaultValue != "") { + if (DefaultValue.Length != 0) { output.WriteString(7, DefaultValue); } if (options_ != null) { @@ -1340,7 +1396,7 @@ namespace Google.Protobuf.DescriptorProtos { public int CalculateSize() { int size = 0; - if (Name != "") { + if (Name.Length != 0) { size += pb::CodedOutputStream.ComputeStringSize(1, Name); } if (Number != 0) { @@ -1352,13 +1408,13 @@ namespace Google.Protobuf.DescriptorProtos { if (Type != global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Type.TYPE_DOUBLE) { size += pb::CodedOutputStream.ComputeEnumSize(5, (int) Type); } - if (TypeName != "") { + if (TypeName.Length != 0) { size += pb::CodedOutputStream.ComputeStringSize(6, TypeName); } - if (Extendee != "") { + if (Extendee.Length != 0) { size += pb::CodedOutputStream.ComputeStringSize(2, Extendee); } - if (DefaultValue != "") { + if (DefaultValue.Length != 0) { size += pb::CodedOutputStream.ComputeStringSize(7, DefaultValue); } if (OneofIndex != 0) { @@ -1373,7 +1429,7 @@ namespace Google.Protobuf.DescriptorProtos { if (other == null) { return; } - if (other.Name != "") { + if (other.Name.Length != 0) { Name = other.Name; } if (other.Number != 0) { @@ -1385,13 +1441,13 @@ namespace Google.Protobuf.DescriptorProtos { if (other.Type != global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Type.TYPE_DOUBLE) { Type = other.Type; } - if (other.TypeName != "") { + if (other.TypeName.Length != 0) { TypeName = other.TypeName; } - if (other.Extendee != "") { + if (other.Extendee.Length != 0) { Extendee = other.Extendee; } - if (other.DefaultValue != "") { + if (other.DefaultValue.Length != 0) { DefaultValue = other.DefaultValue; } if (other.OneofIndex != 0) { @@ -1417,15 +1473,15 @@ namespace Google.Protobuf.DescriptorProtos { } break; case 10: { - name_ = input.ReadString(); + Name = input.ReadString(); break; } case 18: { - extendee_ = input.ReadString(); + Extendee = input.ReadString(); break; } case 24: { - number_ = input.ReadInt32(); + Number = input.ReadInt32(); break; } case 32: { @@ -1437,11 +1493,11 @@ namespace Google.Protobuf.DescriptorProtos { break; } case 50: { - typeName_ = input.ReadString(); + TypeName = input.ReadString(); break; } case 58: { - defaultValue_ = input.ReadString(); + DefaultValue = input.ReadString(); break; } case 66: { @@ -1452,7 +1508,7 @@ namespace Google.Protobuf.DescriptorProtos { break; } case 72: { - oneofIndex_ = input.ReadInt32(); + OneofIndex = input.ReadInt32(); break; } } @@ -1538,19 +1594,19 @@ namespace Google.Protobuf.DescriptorProtos { public override int GetHashCode() { int hash = 0; - if (Name != "") hash ^= Name.GetHashCode(); + if (Name.Length != 0) hash ^= Name.GetHashCode(); return hash; } public void WriteTo(pb::CodedOutputStream output) { - if (Name != "") { + if (Name.Length != 0) { output.WriteString(1, Name); } } public int CalculateSize() { int size = 0; - if (Name != "") { + if (Name.Length != 0) { size += pb::CodedOutputStream.ComputeStringSize(1, Name); } return size; @@ -1559,7 +1615,7 @@ namespace Google.Protobuf.DescriptorProtos { if (other == null) { return; } - if (other.Name != "") { + if (other.Name.Length != 0) { Name = other.Name; } } @@ -1576,7 +1632,7 @@ namespace Google.Protobuf.DescriptorProtos { } break; case 10: { - name_ = input.ReadString(); + Name = input.ReadString(); break; } } @@ -1643,17 +1699,19 @@ namespace Google.Protobuf.DescriptorProtos { public override int GetHashCode() { int hash = 0; - if (Name != "") hash ^= Name.GetHashCode(); + if (Name.Length != 0) hash ^= Name.GetHashCode(); hash ^= value_.GetHashCode(); if (options_ != null) hash ^= Options.GetHashCode(); return hash; } public void WriteTo(pb::CodedOutputStream output) { - if (Name != "") { + if (Name.Length != 0) { output.WriteString(1, Name); } - output.WriteMessageArray(2, value_); + if (value_.Count > 0) { + output.WriteMessageArray(2, value_); + } if (options_ != null) { output.WriteMessage(3, Options); } @@ -1661,11 +1719,13 @@ namespace Google.Protobuf.DescriptorProtos { public int CalculateSize() { int size = 0; - if (Name != "") { + if (Name.Length != 0) { size += pb::CodedOutputStream.ComputeStringSize(1, Name); } - foreach (global::Google.Protobuf.DescriptorProtos.EnumValueDescriptorProto element in value_) { - size += pb::CodedOutputStream.ComputeMessageSize(2, element); + if (value_.Count > 0) { + foreach (global::Google.Protobuf.DescriptorProtos.EnumValueDescriptorProto element in value_) { + size += pb::CodedOutputStream.ComputeMessageSize(2, element); + } } if (options_ != null) { size += pb::CodedOutputStream.ComputeMessageSize(3, Options); @@ -1676,7 +1736,7 @@ namespace Google.Protobuf.DescriptorProtos { if (other == null) { return; } - if (other.Name != "") { + if (other.Name.Length != 0) { Name = other.Name; } value_.Add(other.value_); @@ -1700,7 +1760,7 @@ namespace Google.Protobuf.DescriptorProtos { } break; case 10: { - name_ = input.ReadString(); + Name = input.ReadString(); break; } case 18: { @@ -1780,14 +1840,14 @@ namespace Google.Protobuf.DescriptorProtos { public override int GetHashCode() { int hash = 0; - if (Name != "") hash ^= Name.GetHashCode(); + if (Name.Length != 0) hash ^= Name.GetHashCode(); if (Number != 0) hash ^= Number.GetHashCode(); if (options_ != null) hash ^= Options.GetHashCode(); return hash; } public void WriteTo(pb::CodedOutputStream output) { - if (Name != "") { + if (Name.Length != 0) { output.WriteString(1, Name); } if (Number != 0) { @@ -1800,7 +1860,7 @@ namespace Google.Protobuf.DescriptorProtos { public int CalculateSize() { int size = 0; - if (Name != "") { + if (Name.Length != 0) { size += pb::CodedOutputStream.ComputeStringSize(1, Name); } if (Number != 0) { @@ -1815,7 +1875,7 @@ namespace Google.Protobuf.DescriptorProtos { if (other == null) { return; } - if (other.Name != "") { + if (other.Name.Length != 0) { Name = other.Name; } if (other.Number != 0) { @@ -1841,11 +1901,11 @@ namespace Google.Protobuf.DescriptorProtos { } break; case 10: { - name_ = input.ReadString(); + Name = input.ReadString(); break; } case 16: { - number_ = input.ReadInt32(); + Number = input.ReadInt32(); break; } case 26: { @@ -1919,17 +1979,19 @@ namespace Google.Protobuf.DescriptorProtos { public override int GetHashCode() { int hash = 0; - if (Name != "") hash ^= Name.GetHashCode(); + if (Name.Length != 0) hash ^= Name.GetHashCode(); hash ^= method_.GetHashCode(); if (options_ != null) hash ^= Options.GetHashCode(); return hash; } public void WriteTo(pb::CodedOutputStream output) { - if (Name != "") { + if (Name.Length != 0) { output.WriteString(1, Name); } - output.WriteMessageArray(2, method_); + if (method_.Count > 0) { + output.WriteMessageArray(2, method_); + } if (options_ != null) { output.WriteMessage(3, Options); } @@ -1937,11 +1999,13 @@ namespace Google.Protobuf.DescriptorProtos { public int CalculateSize() { int size = 0; - if (Name != "") { + if (Name.Length != 0) { size += pb::CodedOutputStream.ComputeStringSize(1, Name); } - foreach (global::Google.Protobuf.DescriptorProtos.MethodDescriptorProto element in method_) { - size += pb::CodedOutputStream.ComputeMessageSize(2, element); + if (method_.Count > 0) { + foreach (global::Google.Protobuf.DescriptorProtos.MethodDescriptorProto element in method_) { + size += pb::CodedOutputStream.ComputeMessageSize(2, element); + } } if (options_ != null) { size += pb::CodedOutputStream.ComputeMessageSize(3, Options); @@ -1952,7 +2016,7 @@ namespace Google.Protobuf.DescriptorProtos { if (other == null) { return; } - if (other.Name != "") { + if (other.Name.Length != 0) { Name = other.Name; } method_.Add(other.method_); @@ -1976,7 +2040,7 @@ namespace Google.Protobuf.DescriptorProtos { } break; case 10: { - name_ = input.ReadString(); + Name = input.ReadString(); break; } case 18: { @@ -2083,9 +2147,9 @@ namespace Google.Protobuf.DescriptorProtos { public override int GetHashCode() { int hash = 0; - if (Name != "") hash ^= Name.GetHashCode(); - if (InputType != "") hash ^= InputType.GetHashCode(); - if (OutputType != "") hash ^= OutputType.GetHashCode(); + if (Name.Length != 0) hash ^= Name.GetHashCode(); + if (InputType.Length != 0) hash ^= InputType.GetHashCode(); + if (OutputType.Length != 0) hash ^= OutputType.GetHashCode(); if (options_ != null) hash ^= Options.GetHashCode(); if (ClientStreaming != false) hash ^= ClientStreaming.GetHashCode(); if (ServerStreaming != false) hash ^= ServerStreaming.GetHashCode(); @@ -2093,13 +2157,13 @@ namespace Google.Protobuf.DescriptorProtos { } public void WriteTo(pb::CodedOutputStream output) { - if (Name != "") { + if (Name.Length != 0) { output.WriteString(1, Name); } - if (InputType != "") { + if (InputType.Length != 0) { output.WriteString(2, InputType); } - if (OutputType != "") { + if (OutputType.Length != 0) { output.WriteString(3, OutputType); } if (options_ != null) { @@ -2115,13 +2179,13 @@ namespace Google.Protobuf.DescriptorProtos { public int CalculateSize() { int size = 0; - if (Name != "") { + if (Name.Length != 0) { size += pb::CodedOutputStream.ComputeStringSize(1, Name); } - if (InputType != "") { + if (InputType.Length != 0) { size += pb::CodedOutputStream.ComputeStringSize(2, InputType); } - if (OutputType != "") { + if (OutputType.Length != 0) { size += pb::CodedOutputStream.ComputeStringSize(3, OutputType); } if (options_ != null) { @@ -2139,13 +2203,13 @@ namespace Google.Protobuf.DescriptorProtos { if (other == null) { return; } - if (other.Name != "") { + if (other.Name.Length != 0) { Name = other.Name; } - if (other.InputType != "") { + if (other.InputType.Length != 0) { InputType = other.InputType; } - if (other.OutputType != "") { + if (other.OutputType.Length != 0) { OutputType = other.OutputType; } if (other.options_ != null) { @@ -2174,15 +2238,15 @@ namespace Google.Protobuf.DescriptorProtos { } break; case 10: { - name_ = input.ReadString(); + Name = input.ReadString(); break; } case 18: { - inputType_ = input.ReadString(); + InputType = input.ReadString(); break; } case 26: { - outputType_ = input.ReadString(); + OutputType = input.ReadString(); break; } case 34: { @@ -2193,11 +2257,11 @@ namespace Google.Protobuf.DescriptorProtos { break; } case 40: { - clientStreaming_ = input.ReadBool(); + ClientStreaming = input.ReadBool(); break; } case 48: { - serverStreaming_ = input.ReadBool(); + ServerStreaming = input.ReadBool(); break; } } @@ -2374,29 +2438,29 @@ namespace Google.Protobuf.DescriptorProtos { public override int GetHashCode() { int hash = 0; - if (JavaPackage != "") hash ^= JavaPackage.GetHashCode(); - if (JavaOuterClassname != "") hash ^= JavaOuterClassname.GetHashCode(); + if (JavaPackage.Length != 0) hash ^= JavaPackage.GetHashCode(); + if (JavaOuterClassname.Length != 0) hash ^= JavaOuterClassname.GetHashCode(); if (JavaMultipleFiles != false) hash ^= JavaMultipleFiles.GetHashCode(); if (JavaGenerateEqualsAndHash != false) hash ^= JavaGenerateEqualsAndHash.GetHashCode(); if (JavaStringCheckUtf8 != false) hash ^= JavaStringCheckUtf8.GetHashCode(); if (OptimizeFor != global::Google.Protobuf.DescriptorProtos.FileOptions.Types.OptimizeMode.SPEED) hash ^= OptimizeFor.GetHashCode(); - if (GoPackage != "") hash ^= GoPackage.GetHashCode(); + if (GoPackage.Length != 0) hash ^= GoPackage.GetHashCode(); if (CcGenericServices != false) hash ^= CcGenericServices.GetHashCode(); if (JavaGenericServices != false) hash ^= JavaGenericServices.GetHashCode(); if (PyGenericServices != false) hash ^= PyGenericServices.GetHashCode(); if (Deprecated != false) hash ^= Deprecated.GetHashCode(); if (CcEnableArenas != false) hash ^= CcEnableArenas.GetHashCode(); - if (ObjcClassPrefix != "") hash ^= ObjcClassPrefix.GetHashCode(); - if (CsharpNamespace != "") hash ^= CsharpNamespace.GetHashCode(); + if (ObjcClassPrefix.Length != 0) hash ^= ObjcClassPrefix.GetHashCode(); + if (CsharpNamespace.Length != 0) hash ^= CsharpNamespace.GetHashCode(); hash ^= uninterpretedOption_.GetHashCode(); return hash; } public void WriteTo(pb::CodedOutputStream output) { - if (JavaPackage != "") { + if (JavaPackage.Length != 0) { output.WriteString(1, JavaPackage); } - if (JavaOuterClassname != "") { + if (JavaOuterClassname.Length != 0) { output.WriteString(8, JavaOuterClassname); } if (OptimizeFor != global::Google.Protobuf.DescriptorProtos.FileOptions.Types.OptimizeMode.SPEED) { @@ -2405,7 +2469,7 @@ namespace Google.Protobuf.DescriptorProtos { if (JavaMultipleFiles != false) { output.WriteBool(10, JavaMultipleFiles); } - if (GoPackage != "") { + if (GoPackage.Length != 0) { output.WriteString(11, GoPackage); } if (CcGenericServices != false) { @@ -2429,21 +2493,23 @@ namespace Google.Protobuf.DescriptorProtos { if (CcEnableArenas != false) { output.WriteBool(31, CcEnableArenas); } - if (ObjcClassPrefix != "") { + if (ObjcClassPrefix.Length != 0) { output.WriteString(36, ObjcClassPrefix); } - if (CsharpNamespace != "") { + if (CsharpNamespace.Length != 0) { output.WriteString(37, CsharpNamespace); } - output.WriteMessageArray(999, uninterpretedOption_); + if (uninterpretedOption_.Count > 0) { + output.WriteMessageArray(999, uninterpretedOption_); + } } public int CalculateSize() { int size = 0; - if (JavaPackage != "") { + if (JavaPackage.Length != 0) { size += pb::CodedOutputStream.ComputeStringSize(1, JavaPackage); } - if (JavaOuterClassname != "") { + if (JavaOuterClassname.Length != 0) { size += pb::CodedOutputStream.ComputeStringSize(8, JavaOuterClassname); } if (JavaMultipleFiles != false) { @@ -2458,7 +2524,7 @@ namespace Google.Protobuf.DescriptorProtos { if (OptimizeFor != global::Google.Protobuf.DescriptorProtos.FileOptions.Types.OptimizeMode.SPEED) { size += pb::CodedOutputStream.ComputeEnumSize(9, (int) OptimizeFor); } - if (GoPackage != "") { + if (GoPackage.Length != 0) { size += pb::CodedOutputStream.ComputeStringSize(11, GoPackage); } if (CcGenericServices != false) { @@ -2476,14 +2542,16 @@ namespace Google.Protobuf.DescriptorProtos { if (CcEnableArenas != false) { size += pb::CodedOutputStream.ComputeBoolSize(31, CcEnableArenas); } - if (ObjcClassPrefix != "") { + if (ObjcClassPrefix.Length != 0) { size += pb::CodedOutputStream.ComputeStringSize(36, ObjcClassPrefix); } - if (CsharpNamespace != "") { + if (CsharpNamespace.Length != 0) { size += pb::CodedOutputStream.ComputeStringSize(37, CsharpNamespace); } - foreach (global::Google.Protobuf.DescriptorProtos.UninterpretedOption element in uninterpretedOption_) { - size += pb::CodedOutputStream.ComputeMessageSize(999, element); + if (uninterpretedOption_.Count > 0) { + foreach (global::Google.Protobuf.DescriptorProtos.UninterpretedOption element in uninterpretedOption_) { + size += pb::CodedOutputStream.ComputeMessageSize(999, element); + } } return size; } @@ -2491,10 +2559,10 @@ namespace Google.Protobuf.DescriptorProtos { if (other == null) { return; } - if (other.JavaPackage != "") { + if (other.JavaPackage.Length != 0) { JavaPackage = other.JavaPackage; } - if (other.JavaOuterClassname != "") { + if (other.JavaOuterClassname.Length != 0) { JavaOuterClassname = other.JavaOuterClassname; } if (other.JavaMultipleFiles != false) { @@ -2509,7 +2577,7 @@ namespace Google.Protobuf.DescriptorProtos { if (other.OptimizeFor != global::Google.Protobuf.DescriptorProtos.FileOptions.Types.OptimizeMode.SPEED) { OptimizeFor = other.OptimizeFor; } - if (other.GoPackage != "") { + if (other.GoPackage.Length != 0) { GoPackage = other.GoPackage; } if (other.CcGenericServices != false) { @@ -2527,10 +2595,10 @@ namespace Google.Protobuf.DescriptorProtos { if (other.CcEnableArenas != false) { CcEnableArenas = other.CcEnableArenas; } - if (other.ObjcClassPrefix != "") { + if (other.ObjcClassPrefix.Length != 0) { ObjcClassPrefix = other.ObjcClassPrefix; } - if (other.CsharpNamespace != "") { + if (other.CsharpNamespace.Length != 0) { CsharpNamespace = other.CsharpNamespace; } uninterpretedOption_.Add(other.uninterpretedOption_); @@ -2548,11 +2616,11 @@ namespace Google.Protobuf.DescriptorProtos { } break; case 10: { - javaPackage_ = input.ReadString(); + JavaPackage = input.ReadString(); break; } case 66: { - javaOuterClassname_ = input.ReadString(); + JavaOuterClassname = input.ReadString(); break; } case 72: { @@ -2560,47 +2628,47 @@ namespace Google.Protobuf.DescriptorProtos { break; } case 80: { - javaMultipleFiles_ = input.ReadBool(); + JavaMultipleFiles = input.ReadBool(); break; } case 90: { - goPackage_ = input.ReadString(); + GoPackage = input.ReadString(); break; } case 128: { - ccGenericServices_ = input.ReadBool(); + CcGenericServices = input.ReadBool(); break; } case 136: { - javaGenericServices_ = input.ReadBool(); + JavaGenericServices = input.ReadBool(); break; } case 144: { - pyGenericServices_ = input.ReadBool(); + PyGenericServices = input.ReadBool(); break; } case 160: { - javaGenerateEqualsAndHash_ = input.ReadBool(); + JavaGenerateEqualsAndHash = input.ReadBool(); break; } case 184: { - deprecated_ = input.ReadBool(); + Deprecated = input.ReadBool(); break; } case 216: { - javaStringCheckUtf8_ = input.ReadBool(); + JavaStringCheckUtf8 = input.ReadBool(); break; } case 248: { - ccEnableArenas_ = input.ReadBool(); + CcEnableArenas = input.ReadBool(); break; } case 290: { - objcClassPrefix_ = input.ReadString(); + ObjcClassPrefix = input.ReadString(); break; } case 298: { - csharpNamespace_ = input.ReadString(); + CsharpNamespace = input.ReadString(); break; } case 7994: { @@ -2724,7 +2792,9 @@ namespace Google.Protobuf.DescriptorProtos { if (MapEntry != false) { output.WriteBool(7, MapEntry); } - output.WriteMessageArray(999, uninterpretedOption_); + if (uninterpretedOption_.Count > 0) { + output.WriteMessageArray(999, uninterpretedOption_); + } } public int CalculateSize() { @@ -2741,8 +2811,10 @@ namespace Google.Protobuf.DescriptorProtos { if (MapEntry != false) { size += pb::CodedOutputStream.ComputeBoolSize(7, MapEntry); } - foreach (global::Google.Protobuf.DescriptorProtos.UninterpretedOption element in uninterpretedOption_) { - size += pb::CodedOutputStream.ComputeMessageSize(999, element); + if (uninterpretedOption_.Count > 0) { + foreach (global::Google.Protobuf.DescriptorProtos.UninterpretedOption element in uninterpretedOption_) { + size += pb::CodedOutputStream.ComputeMessageSize(999, element); + } } return size; } @@ -2777,19 +2849,19 @@ namespace Google.Protobuf.DescriptorProtos { } break; case 8: { - messageSetWireFormat_ = input.ReadBool(); + MessageSetWireFormat = input.ReadBool(); break; } case 16: { - noStandardDescriptorAccessor_ = input.ReadBool(); + NoStandardDescriptorAccessor = input.ReadBool(); break; } case 24: { - deprecated_ = input.ReadBool(); + Deprecated = input.ReadBool(); break; } case 56: { - mapEntry_ = input.ReadBool(); + MapEntry = input.ReadBool(); break; } case 7994: { @@ -2927,7 +2999,9 @@ namespace Google.Protobuf.DescriptorProtos { if (Weak != false) { output.WriteBool(10, Weak); } - output.WriteMessageArray(999, uninterpretedOption_); + if (uninterpretedOption_.Count > 0) { + output.WriteMessageArray(999, uninterpretedOption_); + } } public int CalculateSize() { @@ -2950,8 +3024,10 @@ namespace Google.Protobuf.DescriptorProtos { if (Weak != false) { size += pb::CodedOutputStream.ComputeBoolSize(10, Weak); } - foreach (global::Google.Protobuf.DescriptorProtos.UninterpretedOption element in uninterpretedOption_) { - size += pb::CodedOutputStream.ComputeMessageSize(999, element); + if (uninterpretedOption_.Count > 0) { + foreach (global::Google.Protobuf.DescriptorProtos.UninterpretedOption element in uninterpretedOption_) { + size += pb::CodedOutputStream.ComputeMessageSize(999, element); + } } return size; } @@ -2996,15 +3072,15 @@ namespace Google.Protobuf.DescriptorProtos { break; } case 16: { - packed_ = input.ReadBool(); + Packed = input.ReadBool(); break; } case 24: { - deprecated_ = input.ReadBool(); + Deprecated = input.ReadBool(); break; } case 40: { - lazy_ = input.ReadBool(); + Lazy = input.ReadBool(); break; } case 48: { @@ -3012,7 +3088,7 @@ namespace Google.Protobuf.DescriptorProtos { break; } case 80: { - weak_ = input.ReadBool(); + Weak = input.ReadBool(); break; } case 7994: { @@ -3116,7 +3192,9 @@ namespace Google.Protobuf.DescriptorProtos { if (Deprecated != false) { output.WriteBool(3, Deprecated); } - output.WriteMessageArray(999, uninterpretedOption_); + if (uninterpretedOption_.Count > 0) { + output.WriteMessageArray(999, uninterpretedOption_); + } } public int CalculateSize() { @@ -3127,8 +3205,10 @@ namespace Google.Protobuf.DescriptorProtos { if (Deprecated != false) { size += pb::CodedOutputStream.ComputeBoolSize(3, Deprecated); } - foreach (global::Google.Protobuf.DescriptorProtos.UninterpretedOption element in uninterpretedOption_) { - size += pb::CodedOutputStream.ComputeMessageSize(999, element); + if (uninterpretedOption_.Count > 0) { + foreach (global::Google.Protobuf.DescriptorProtos.UninterpretedOption element in uninterpretedOption_) { + size += pb::CodedOutputStream.ComputeMessageSize(999, element); + } } return size; } @@ -3157,11 +3237,11 @@ namespace Google.Protobuf.DescriptorProtos { } break; case 16: { - allowAlias_ = input.ReadBool(); + AllowAlias = input.ReadBool(); break; } case 24: { - deprecated_ = input.ReadBool(); + Deprecated = input.ReadBool(); break; } case 7994: { @@ -3234,7 +3314,9 @@ namespace Google.Protobuf.DescriptorProtos { if (Deprecated != false) { output.WriteBool(1, Deprecated); } - output.WriteMessageArray(999, uninterpretedOption_); + if (uninterpretedOption_.Count > 0) { + output.WriteMessageArray(999, uninterpretedOption_); + } } public int CalculateSize() { @@ -3242,8 +3324,10 @@ namespace Google.Protobuf.DescriptorProtos { if (Deprecated != false) { size += pb::CodedOutputStream.ComputeBoolSize(1, Deprecated); } - foreach (global::Google.Protobuf.DescriptorProtos.UninterpretedOption element in uninterpretedOption_) { - size += pb::CodedOutputStream.ComputeMessageSize(999, element); + if (uninterpretedOption_.Count > 0) { + foreach (global::Google.Protobuf.DescriptorProtos.UninterpretedOption element in uninterpretedOption_) { + size += pb::CodedOutputStream.ComputeMessageSize(999, element); + } } return size; } @@ -3269,7 +3353,7 @@ namespace Google.Protobuf.DescriptorProtos { } break; case 8: { - deprecated_ = input.ReadBool(); + Deprecated = input.ReadBool(); break; } case 7994: { @@ -3342,7 +3426,9 @@ namespace Google.Protobuf.DescriptorProtos { if (Deprecated != false) { output.WriteBool(33, Deprecated); } - output.WriteMessageArray(999, uninterpretedOption_); + if (uninterpretedOption_.Count > 0) { + output.WriteMessageArray(999, uninterpretedOption_); + } } public int CalculateSize() { @@ -3350,8 +3436,10 @@ namespace Google.Protobuf.DescriptorProtos { if (Deprecated != false) { size += pb::CodedOutputStream.ComputeBoolSize(33, Deprecated); } - foreach (global::Google.Protobuf.DescriptorProtos.UninterpretedOption element in uninterpretedOption_) { - size += pb::CodedOutputStream.ComputeMessageSize(999, element); + if (uninterpretedOption_.Count > 0) { + foreach (global::Google.Protobuf.DescriptorProtos.UninterpretedOption element in uninterpretedOption_) { + size += pb::CodedOutputStream.ComputeMessageSize(999, element); + } } return size; } @@ -3377,7 +3465,7 @@ namespace Google.Protobuf.DescriptorProtos { } break; case 264: { - deprecated_ = input.ReadBool(); + Deprecated = input.ReadBool(); break; } case 7994: { @@ -3450,7 +3538,9 @@ namespace Google.Protobuf.DescriptorProtos { if (Deprecated != false) { output.WriteBool(33, Deprecated); } - output.WriteMessageArray(999, uninterpretedOption_); + if (uninterpretedOption_.Count > 0) { + output.WriteMessageArray(999, uninterpretedOption_); + } } public int CalculateSize() { @@ -3458,8 +3548,10 @@ namespace Google.Protobuf.DescriptorProtos { if (Deprecated != false) { size += pb::CodedOutputStream.ComputeBoolSize(33, Deprecated); } - foreach (global::Google.Protobuf.DescriptorProtos.UninterpretedOption element in uninterpretedOption_) { - size += pb::CodedOutputStream.ComputeMessageSize(999, element); + if (uninterpretedOption_.Count > 0) { + foreach (global::Google.Protobuf.DescriptorProtos.UninterpretedOption element in uninterpretedOption_) { + size += pb::CodedOutputStream.ComputeMessageSize(999, element); + } } return size; } @@ -3485,7 +3577,7 @@ namespace Google.Protobuf.DescriptorProtos { } break; case 264: { - deprecated_ = input.ReadBool(); + Deprecated = input.ReadBool(); break; } case 7994: { @@ -3595,18 +3687,20 @@ namespace Google.Protobuf.DescriptorProtos { public override int GetHashCode() { int hash = 0; hash ^= name_.GetHashCode(); - if (IdentifierValue != "") hash ^= IdentifierValue.GetHashCode(); + if (IdentifierValue.Length != 0) hash ^= IdentifierValue.GetHashCode(); if (PositiveIntValue != 0UL) hash ^= PositiveIntValue.GetHashCode(); if (NegativeIntValue != 0L) hash ^= NegativeIntValue.GetHashCode(); if (DoubleValue != 0D) hash ^= DoubleValue.GetHashCode(); - if (StringValue != pb::ByteString.Empty) hash ^= StringValue.GetHashCode(); - if (AggregateValue != "") hash ^= AggregateValue.GetHashCode(); + if (StringValue.Length != 0) hash ^= StringValue.GetHashCode(); + if (AggregateValue.Length != 0) hash ^= AggregateValue.GetHashCode(); return hash; } public void WriteTo(pb::CodedOutputStream output) { - output.WriteMessageArray(2, name_); - if (IdentifierValue != "") { + if (name_.Count > 0) { + output.WriteMessageArray(2, name_); + } + if (IdentifierValue.Length != 0) { output.WriteString(3, IdentifierValue); } if (PositiveIntValue != 0UL) { @@ -3618,20 +3712,22 @@ namespace Google.Protobuf.DescriptorProtos { if (DoubleValue != 0D) { output.WriteDouble(6, DoubleValue); } - if (StringValue != pb::ByteString.Empty) { + if (StringValue.Length != 0) { output.WriteBytes(7, StringValue); } - if (AggregateValue != "") { + if (AggregateValue.Length != 0) { output.WriteString(8, AggregateValue); } } public int CalculateSize() { int size = 0; - foreach (global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Types.NamePart element in name_) { - size += pb::CodedOutputStream.ComputeMessageSize(2, element); + if (name_.Count > 0) { + foreach (global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Types.NamePart element in name_) { + size += pb::CodedOutputStream.ComputeMessageSize(2, element); + } } - if (IdentifierValue != "") { + if (IdentifierValue.Length != 0) { size += pb::CodedOutputStream.ComputeStringSize(3, IdentifierValue); } if (PositiveIntValue != 0UL) { @@ -3643,10 +3739,10 @@ namespace Google.Protobuf.DescriptorProtos { if (DoubleValue != 0D) { size += pb::CodedOutputStream.ComputeDoubleSize(6, DoubleValue); } - if (StringValue != pb::ByteString.Empty) { + if (StringValue.Length != 0) { size += pb::CodedOutputStream.ComputeBytesSize(7, StringValue); } - if (AggregateValue != "") { + if (AggregateValue.Length != 0) { size += pb::CodedOutputStream.ComputeStringSize(8, AggregateValue); } return size; @@ -3656,7 +3752,7 @@ namespace Google.Protobuf.DescriptorProtos { return; } name_.Add(other.name_); - if (other.IdentifierValue != "") { + if (other.IdentifierValue.Length != 0) { IdentifierValue = other.IdentifierValue; } if (other.PositiveIntValue != 0UL) { @@ -3668,10 +3764,10 @@ namespace Google.Protobuf.DescriptorProtos { if (other.DoubleValue != 0D) { DoubleValue = other.DoubleValue; } - if (other.StringValue != pb::ByteString.Empty) { + if (other.StringValue.Length != 0) { StringValue = other.StringValue; } - if (other.AggregateValue != "") { + if (other.AggregateValue.Length != 0) { AggregateValue = other.AggregateValue; } } @@ -3692,27 +3788,27 @@ namespace Google.Protobuf.DescriptorProtos { break; } case 26: { - identifierValue_ = input.ReadString(); + IdentifierValue = input.ReadString(); break; } case 32: { - positiveIntValue_ = input.ReadUInt64(); + PositiveIntValue = input.ReadUInt64(); break; } case 40: { - negativeIntValue_ = input.ReadInt64(); + NegativeIntValue = input.ReadInt64(); break; } case 49: { - doubleValue_ = input.ReadDouble(); + DoubleValue = input.ReadDouble(); break; } case 58: { - stringValue_ = input.ReadBytes(); + StringValue = input.ReadBytes(); break; } case 66: { - aggregateValue_ = input.ReadString(); + AggregateValue = input.ReadString(); break; } } @@ -3775,13 +3871,13 @@ namespace Google.Protobuf.DescriptorProtos { public override int GetHashCode() { int hash = 0; - if (NamePart_ != "") hash ^= NamePart_.GetHashCode(); + if (NamePart_.Length != 0) hash ^= NamePart_.GetHashCode(); if (IsExtension != false) hash ^= IsExtension.GetHashCode(); return hash; } public void WriteTo(pb::CodedOutputStream output) { - if (NamePart_ != "") { + if (NamePart_.Length != 0) { output.WriteString(1, NamePart_); } if (IsExtension != false) { @@ -3791,7 +3887,7 @@ namespace Google.Protobuf.DescriptorProtos { public int CalculateSize() { int size = 0; - if (NamePart_ != "") { + if (NamePart_.Length != 0) { size += pb::CodedOutputStream.ComputeStringSize(1, NamePart_); } if (IsExtension != false) { @@ -3803,7 +3899,7 @@ namespace Google.Protobuf.DescriptorProtos { if (other == null) { return; } - if (other.NamePart_ != "") { + if (other.NamePart_.Length != 0) { NamePart_ = other.NamePart_; } if (other.IsExtension != false) { @@ -3823,11 +3919,11 @@ namespace Google.Protobuf.DescriptorProtos { } break; case 10: { - namePart_ = input.ReadString(); + NamePart_ = input.ReadString(); break; } case 16: { - isExtension_ = input.ReadBool(); + IsExtension = input.ReadBool(); break; } } @@ -3888,13 +3984,17 @@ namespace Google.Protobuf.DescriptorProtos { } public void WriteTo(pb::CodedOutputStream output) { - output.WriteMessageArray(1, location_); + if (location_.Count > 0) { + output.WriteMessageArray(1, location_); + } } public int CalculateSize() { int size = 0; - foreach (global::Google.Protobuf.DescriptorProtos.SourceCodeInfo.Types.Location element in location_) { - size += pb::CodedOutputStream.ComputeMessageSize(1, element); + if (location_.Count > 0) { + foreach (global::Google.Protobuf.DescriptorProtos.SourceCodeInfo.Types.Location element in location_) { + size += pb::CodedOutputStream.ComputeMessageSize(1, element); + } } return size; } @@ -4003,53 +4103,55 @@ namespace Google.Protobuf.DescriptorProtos { int hash = 0; hash ^= path_.GetHashCode(); hash ^= span_.GetHashCode(); - if (LeadingComments != "") hash ^= LeadingComments.GetHashCode(); - if (TrailingComments != "") hash ^= TrailingComments.GetHashCode(); + if (LeadingComments.Length != 0) hash ^= LeadingComments.GetHashCode(); + if (TrailingComments.Length != 0) hash ^= TrailingComments.GetHashCode(); hash ^= leadingDetachedComments_.GetHashCode(); return hash; } public void WriteTo(pb::CodedOutputStream output) { - output.WritePackedInt32Array(1, path_); - output.WritePackedInt32Array(2, span_); - if (LeadingComments != "") { + if (path_.Count > 0) { + output.WritePackedInt32Array(1, path_); + } + if (span_.Count > 0) { + output.WritePackedInt32Array(2, span_); + } + if (LeadingComments.Length != 0) { output.WriteString(3, LeadingComments); } - if (TrailingComments != "") { + if (TrailingComments.Length != 0) { output.WriteString(4, TrailingComments); } - output.WriteStringArray(6, leadingDetachedComments_); + if (leadingDetachedComments_.Count > 0) { + output.WriteStringArray(6, leadingDetachedComments_); + } } public int CalculateSize() { int size = 0; - { + if (path_.Count > 0) { int dataSize = 0; foreach (int element in path_) { dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); } size += dataSize; - if (path_.Count != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } + size += 1 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - { + if (span_.Count > 0) { int dataSize = 0; foreach (int element in span_) { dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); } size += dataSize; - if (span_.Count != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } + size += 1 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); } - if (LeadingComments != "") { + if (LeadingComments.Length != 0) { size += pb::CodedOutputStream.ComputeStringSize(3, LeadingComments); } - if (TrailingComments != "") { + if (TrailingComments.Length != 0) { size += pb::CodedOutputStream.ComputeStringSize(4, TrailingComments); } - { + if (leadingDetachedComments_.Count > 0) { int dataSize = 0; foreach (string element in leadingDetachedComments_) { dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); @@ -4065,10 +4167,10 @@ namespace Google.Protobuf.DescriptorProtos { } path_.Add(other.path_); span_.Add(other.span_); - if (other.LeadingComments != "") { + if (other.LeadingComments.Length != 0) { LeadingComments = other.LeadingComments; } - if (other.TrailingComments != "") { + if (other.TrailingComments.Length != 0) { TrailingComments = other.TrailingComments; } leadingDetachedComments_.Add(other.leadingDetachedComments_); @@ -4096,11 +4198,11 @@ namespace Google.Protobuf.DescriptorProtos { break; } case 26: { - leadingComments_ = input.ReadString(); + LeadingComments = input.ReadString(); break; } case 34: { - trailingComments_ = input.ReadString(); + TrailingComments = input.ReadString(); break; } case 50: { -- cgit v1.2.3 From 828b7e61d0443832d99002fbda12a359e5f9f221 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Wed, 17 Jun 2015 14:59:10 +0100 Subject: Use the fact that we know the tag size and bytes at codegen time to optimize. --- csharp/src/AddressBook/Addressbook.cs | 31 +- csharp/src/ProtoMunge/Program.cs | 2 + .../ProtocolBuffers.Test/CodedInputStreamTest.cs | 9 +- .../ProtocolBuffers.Test/CodedOutputStreamTest.cs | 36 +- .../TestProtos/UnittestImportProto3.cs | 5 +- .../TestProtos/UnittestImportPublicProto3.cs | 5 +- .../TestProtos/UnittestIssues.cs | 55 +- .../TestProtos/UnittestProto3.cs | 613 +++++++++++--------- .../CodedOutputStream.ComputeSize.cs | 220 +------- csharp/src/ProtocolBuffers/CodedOutputStream.cs | 617 ++++++--------------- .../DescriptorProtos/DescriptorProtoFile.cs | 458 +++++++++------ .../protobuf/compiler/csharp/csharp_enum_field.cc | 10 +- .../protobuf/compiler/csharp/csharp_field_base.cc | 15 +- .../compiler/csharp/csharp_message_field.cc | 6 +- .../compiler/csharp/csharp_primitive_field.cc | 23 +- .../compiler/csharp/csharp_repeated_enum_field.cc | 22 +- .../csharp/csharp_repeated_message_field.cc | 8 +- .../csharp/csharp_repeated_primitive_field.cc | 21 +- src/google/protobuf/wire_format.h | 2 +- 19 files changed, 970 insertions(+), 1188 deletions(-) diff --git a/csharp/src/AddressBook/Addressbook.cs b/csharp/src/AddressBook/Addressbook.cs index 4acb8cac..480fb92a 100644 --- a/csharp/src/AddressBook/Addressbook.cs +++ b/csharp/src/AddressBook/Addressbook.cs @@ -139,13 +139,16 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { public void WriteTo(pb::CodedOutputStream output) { if (Name.Length != 0) { - output.WriteString(1, Name); + output.WriteRawTag(10); + output.WriteString(Name); } if (Id != 0) { - output.WriteInt32(2, Id); + output.WriteRawTag(16); + output.WriteInt32(Id); } if (Email.Length != 0) { - output.WriteString(3, Email); + output.WriteRawTag(26); + output.WriteString(Email); } if (phone_.Count > 0) { output.WriteMessageArray(4, phone_); @@ -155,18 +158,19 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { public int CalculateSize() { int size = 0; if (Name.Length != 0) { - size += pb::CodedOutputStream.ComputeStringSize(1, Name); + size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); } if (Id != 0) { - size += pb::CodedOutputStream.ComputeInt32Size(2, Id); + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Id); } if (Email.Length != 0) { - size += pb::CodedOutputStream.ComputeStringSize(3, Email); + size += 1 + pb::CodedOutputStream.ComputeStringSize(Email); } if (phone_.Count > 0) { foreach (global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneNumber element in phone_) { - size += pb::CodedOutputStream.ComputeMessageSize(4, element); + size += pb::CodedOutputStream.ComputeMessageSize(element); } + size += 1 * phone_.Count; } return size; } @@ -286,20 +290,22 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { public void WriteTo(pb::CodedOutputStream output) { if (Number.Length != 0) { - output.WriteString(1, Number); + output.WriteRawTag(10); + output.WriteString(Number); } if (Type != global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneType.HOME) { - output.WriteEnum(2, (int) Type); + output.WriteRawTag(16); + output.WriteEnum((int) Type); } } public int CalculateSize() { int size = 0; if (Number.Length != 0) { - size += pb::CodedOutputStream.ComputeStringSize(1, Number); + size += 1 + pb::CodedOutputStream.ComputeStringSize(Number); } if (Type != global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneType.HOME) { - size += pb::CodedOutputStream.ComputeEnumSize(2, (int) Type); + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Type); } return size; } @@ -401,8 +407,9 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { int size = 0; if (person_.Count > 0) { foreach (global::Google.ProtocolBuffers.Examples.AddressBook.Person element in person_) { - size += pb::CodedOutputStream.ComputeMessageSize(1, element); + size += pb::CodedOutputStream.ComputeMessageSize(element); } + size += 1 * person_.Count; } return size; } diff --git a/csharp/src/ProtoMunge/Program.cs b/csharp/src/ProtoMunge/Program.cs index 53dc3501..6379f30b 100644 --- a/csharp/src/ProtoMunge/Program.cs +++ b/csharp/src/ProtoMunge/Program.cs @@ -38,6 +38,8 @@ using System; using System.Collections; using System.Collections.Generic; using System.IO; +using Google.Protobuf; +using Google.Protobuf.Descriptors; using Google.ProtocolBuffers.Descriptors; namespace Google.ProtocolBuffers.ProtoMunge diff --git a/csharp/src/ProtocolBuffers.Test/CodedInputStreamTest.cs b/csharp/src/ProtocolBuffers.Test/CodedInputStreamTest.cs index 07f54e94..0baa3a75 100644 --- a/csharp/src/ProtocolBuffers.Test/CodedInputStreamTest.cs +++ b/csharp/src/ProtocolBuffers.Test/CodedInputStreamTest.cs @@ -479,7 +479,8 @@ namespace Google.Protobuf int msgSize = 1 + 1 + arraySize; byte[] bytes = new byte[msgSize]; CodedOutputStream output = CodedOutputStream.CreateInstance(bytes); - output.WritePackedInt32Array(8, new RepeatedField { 0, -1, -2, -3, -4, -5 }); + output.WriteTag(8, WireFormat.WireType.LengthDelimited); + output.WritePackedInt32Array(new RepeatedField { 0, -1, -2, -3, -4, -5 }); Assert.AreEqual(0, output.SpaceLeft); @@ -527,8 +528,10 @@ namespace Google.Protobuf using (var ms = new MemoryStream()) { CodedOutputStream output = CodedOutputStream.CreateInstance(ms); - output.WriteBytes(1, ByteString.CopyFrom(new byte[100])); - output.WriteBytes(2, ByteString.CopyFrom(new byte[100])); + output.WriteTag(1, WireFormat.WireType.LengthDelimited); + output.WriteBytes(ByteString.CopyFrom(new byte[100])); + output.WriteTag(2, WireFormat.WireType.LengthDelimited); + output.WriteBytes(ByteString.CopyFrom(new byte[100])); output.Flush(); ms.Position = 0; diff --git a/csharp/src/ProtocolBuffers.Test/CodedOutputStreamTest.cs b/csharp/src/ProtocolBuffers.Test/CodedOutputStreamTest.cs index 682c005a..bc053e19 100644 --- a/csharp/src/ProtocolBuffers.Test/CodedOutputStreamTest.cs +++ b/csharp/src/ProtocolBuffers.Test/CodedOutputStreamTest.cs @@ -295,12 +295,12 @@ namespace Google.Protobuf [Test] public void TestNegativeEnumNoTag() { - Assert.AreEqual(10, CodedOutputStream.ComputeInt32SizeNoTag(-2)); - Assert.AreEqual(10, CodedOutputStream.ComputeEnumSizeNoTag((int) TestNegEnum.Value)); + Assert.AreEqual(10, CodedOutputStream.ComputeInt32Size(-2)); + Assert.AreEqual(10, CodedOutputStream.ComputeEnumSize((int) TestNegEnum.Value)); byte[] bytes = new byte[10]; CodedOutputStream output = CodedOutputStream.CreateInstance(bytes); - output.WriteEnumNoTag((int) TestNegEnum.Value); + output.WriteEnum((int) TestNegEnum.Value); Assert.AreEqual(0, output.SpaceLeft); Assert.AreEqual("FE-FF-FF-FF-FF-FF-FF-FF-FF-01", BitConverter.ToString(bytes)); @@ -308,21 +308,6 @@ namespace Google.Protobuf enum TestNegEnum { None = 0, Value = -2 } - [Test] - public void TestNegativeEnumWithTag() - { - Assert.AreEqual(11, CodedOutputStream.ComputeInt32Size(8, -2)); - Assert.AreEqual(11, CodedOutputStream.ComputeEnumSize(8, (int) TestNegEnum.Value)); - - byte[] bytes = new byte[11]; - CodedOutputStream output = CodedOutputStream.CreateInstance(bytes); - output.WriteEnum(8, (int) TestNegEnum.Value); - - Assert.AreEqual(0, output.SpaceLeft); - //fyi, 0x40 == 0x08 << 3 + 0, field num + wire format shift - Assert.AreEqual("40-FE-FF-FF-FF-FF-FF-FF-FF-FF-01", BitConverter.ToString(bytes)); - } - [Test] public void TestNegativeEnumArrayPacked() { @@ -330,7 +315,8 @@ namespace Google.Protobuf int msgSize = 1 + 1 + arraySize; byte[] bytes = new byte[msgSize]; CodedOutputStream output = CodedOutputStream.CreateInstance(bytes); - output.WritePackedEnumArray(8, new RepeatedField { + output.WriteTag(8, WireFormat.WireType.LengthDelimited); + output.WritePackedEnumArray(new RepeatedField { 0, (TestNegEnum) (-1), TestNegEnum.Value, (TestNegEnum) (-3), (TestNegEnum) (-4), (TestNegEnum) (-5) }); Assert.AreEqual(0, output.SpaceLeft); @@ -384,17 +370,17 @@ namespace Google.Protobuf // Field 11: numeric value: 500 cout.WriteTag(11, WireFormat.WireType.Varint); Assert.AreEqual(1, cout.Position); - cout.WriteInt32NoTag(500); + cout.WriteInt32(500); Assert.AreEqual(3, cout.Position); //Field 12: length delimited 120 bytes cout.WriteTag(12, WireFormat.WireType.LengthDelimited); Assert.AreEqual(4, cout.Position); - cout.WriteBytesNoTag(ByteString.CopyFrom(content)); + cout.WriteBytes(ByteString.CopyFrom(content)); Assert.AreEqual(115, cout.Position); // Field 13: fixed numeric value: 501 cout.WriteTag(13, WireFormat.WireType.Fixed32); Assert.AreEqual(116, cout.Position); - cout.WriteSFixed32NoTag(501); + cout.WriteSFixed32(501); Assert.AreEqual(120, cout.Position); cout.Flush(); } @@ -405,17 +391,17 @@ namespace Google.Protobuf // Field 1: numeric value: 500 cout.WriteTag(1, WireFormat.WireType.Varint); Assert.AreEqual(1, cout.Position); - cout.WriteInt32NoTag(500); + cout.WriteInt32(500); Assert.AreEqual(3, cout.Position); //Field 2: length delimited 120 bytes cout.WriteTag(2, WireFormat.WireType.LengthDelimited); Assert.AreEqual(4, cout.Position); - cout.WriteBytesNoTag(ByteString.CopyFrom(child)); + cout.WriteBytes(ByteString.CopyFrom(child)); Assert.AreEqual(125, cout.Position); // Field 3: fixed numeric value: 500 cout.WriteTag(3, WireFormat.WireType.Fixed32); Assert.AreEqual(126, cout.Position); - cout.WriteSFixed32NoTag(501); + cout.WriteSFixed32(501); Assert.AreEqual(130, cout.Position); cout.Flush(); } diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportProto3.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportProto3.cs index f4bbbc5f..e048f65c 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportProto3.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportProto3.cs @@ -109,14 +109,15 @@ namespace Google.Protobuf.TestProtos { public void WriteTo(pb::CodedOutputStream output) { if (D != 0) { - output.WriteInt32(1, D); + output.WriteRawTag(8); + output.WriteInt32(D); } } public int CalculateSize() { int size = 0; if (D != 0) { - size += pb::CodedOutputStream.ComputeInt32Size(1, D); + size += 1 + pb::CodedOutputStream.ComputeInt32Size(D); } return size; } diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportPublicProto3.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportPublicProto3.cs index a79fa70e..5d9f0b7a 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportPublicProto3.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportPublicProto3.cs @@ -94,14 +94,15 @@ namespace Google.Protobuf.TestProtos { public void WriteTo(pb::CodedOutputStream output) { if (E != 0) { - output.WriteInt32(1, E); + output.WriteRawTag(8); + output.WriteInt32(E); } } public int CalculateSize() { int size = 0; if (E != 0) { - size += pb::CodedOutputStream.ComputeInt32Size(1, E); + size += 1 + pb::CodedOutputStream.ComputeInt32Size(E); } return size; } diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs index 6e59f205..1ea3728d 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs @@ -155,25 +155,27 @@ namespace UnitTest.Issues.TestProtos { public void WriteTo(pb::CodedOutputStream output) { if (Value != global::UnitTest.Issues.TestProtos.NegativeEnum.NEGATIVE_ENUM_ZERO) { - output.WriteEnum(1, (int) Value); + output.WriteRawTag(8); + output.WriteEnum((int) Value); } if (values_.Count > 0) { output.WriteEnumArray(2, values_); } if (packedValues_.Count > 0) { - output.WritePackedEnumArray(3, packedValues_); + output.WriteRawTag(26); + output.WritePackedEnumArray(packedValues_); } } public int CalculateSize() { int size = 0; if (Value != global::UnitTest.Issues.TestProtos.NegativeEnum.NEGATIVE_ENUM_ZERO) { - size += pb::CodedOutputStream.ComputeEnumSize(1, (int) Value); + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Value); } if (values_.Count > 0) { int dataSize = 0; foreach (global::UnitTest.Issues.TestProtos.NegativeEnum element in values_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); + dataSize += pb::CodedOutputStream.ComputeEnumSize((int) element); } size += dataSize; size += 1 * values_.Count; @@ -181,11 +183,10 @@ namespace UnitTest.Issues.TestProtos { if (packedValues_.Count > 0) { int dataSize = 0; foreach (global::UnitTest.Issues.TestProtos.NegativeEnum element in packedValues_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); + dataSize += pb::CodedOutputStream.ComputeEnumSize((int) element); } size += dataSize; - size += 1; - size += pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize); + size += 1 + pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize); } return size; } @@ -305,7 +306,7 @@ namespace UnitTest.Issues.TestProtos { public static pb::MessageParser Parser { get { return _parser; } } private static readonly string[] _fieldNames = new string[] { "EnumArray", "EnumValue", "MessageArray", "MessageValue", "PrimitiveArray", "PrimitiveValue" }; - private static readonly uint[] _fieldTags = new uint[] { 48, 40, 34, 26, 16, 8 }; + private static readonly uint[] _fieldTags = new uint[] { 50, 40, 34, 26, 18, 8 }; public static pbd::MessageDescriptor Descriptor { get { return global::UnitTest.Issues.TestProtos.UnittestIssues.internal__static_unittest_issues_DeprecatedFieldsMessage__Descriptor; } } @@ -397,57 +398,62 @@ namespace UnitTest.Issues.TestProtos { public void WriteTo(pb::CodedOutputStream output) { if (PrimitiveValue != 0) { - output.WriteInt32(1, PrimitiveValue); + output.WriteRawTag(8); + output.WriteInt32(PrimitiveValue); } if (primitiveArray_.Count > 0) { - output.WritePackedInt32Array(2, primitiveArray_); + output.WriteRawTag(18); + output.WritePackedInt32Array(primitiveArray_); } if (messageValue_ != null) { - output.WriteMessage(3, MessageValue); + output.WriteRawTag(26); + output.WriteMessage(MessageValue); } if (messageArray_.Count > 0) { output.WriteMessageArray(4, messageArray_); } if (EnumValue != global::UnitTest.Issues.TestProtos.DeprecatedEnum.DEPRECATED_ZERO) { - output.WriteEnum(5, (int) EnumValue); + output.WriteRawTag(40); + output.WriteEnum((int) EnumValue); } if (enumArray_.Count > 0) { - output.WritePackedEnumArray(6, enumArray_); + output.WriteRawTag(50); + output.WritePackedEnumArray(enumArray_); } } public int CalculateSize() { int size = 0; if (PrimitiveValue != 0) { - size += pb::CodedOutputStream.ComputeInt32Size(1, PrimitiveValue); + size += 1 + pb::CodedOutputStream.ComputeInt32Size(PrimitiveValue); } if (primitiveArray_.Count > 0) { int dataSize = 0; foreach (int element in primitiveArray_) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); + dataSize += pb::CodedOutputStream.ComputeInt32Size(element); } size += dataSize; - size += 1 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + size += 1 + pb::CodedOutputStream.ComputeInt32Size(dataSize); } if (messageValue_ != null) { - size += pb::CodedOutputStream.ComputeMessageSize(3, MessageValue); + size += 1 + pb::CodedOutputStream.ComputeMessageSize(MessageValue); } if (messageArray_.Count > 0) { foreach (global::UnitTest.Issues.TestProtos.DeprecatedChild element in messageArray_) { - size += pb::CodedOutputStream.ComputeMessageSize(4, element); + size += pb::CodedOutputStream.ComputeMessageSize(element); } + size += 1 * messageArray_.Count; } if (EnumValue != global::UnitTest.Issues.TestProtos.DeprecatedEnum.DEPRECATED_ZERO) { - size += pb::CodedOutputStream.ComputeEnumSize(5, (int) EnumValue); + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) EnumValue); } if (enumArray_.Count > 0) { int dataSize = 0; foreach (global::UnitTest.Issues.TestProtos.DeprecatedEnum element in enumArray_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); + dataSize += pb::CodedOutputStream.ComputeEnumSize((int) element); } size += dataSize; - size += 1; - size += pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize); + size += 1 + pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize); } return size; } @@ -568,14 +574,15 @@ namespace UnitTest.Issues.TestProtos { public void WriteTo(pb::CodedOutputStream output) { if (Item != 0) { - output.WriteInt32(1, Item); + output.WriteRawTag(8); + output.WriteInt32(Item); } } public int CalculateSize() { int size = 0; if (Item != 0) { - size += pb::CodedOutputStream.ComputeInt32Size(1, Item); + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Item); } return size; } diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs index 7e731a83..a2c5d5f6 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs @@ -407,7 +407,7 @@ namespace Google.Protobuf.TestProtos { public static pb::MessageParser Parser { get { return _parser; } } private static readonly string[] _fieldNames = new string[] { "oneof_bytes", "oneof_nested_message", "oneof_string", "oneof_uint32", "repeated_bool", "repeated_bytes", "repeated_double", "repeated_fixed32", "repeated_fixed64", "repeated_float", "repeated_foreign_enum", "repeated_foreign_message", "repeated_import_enum", "repeated_import_message", "repeated_int32", "repeated_int64", "repeated_nested_enum", "repeated_nested_message", "repeated_public_import_message", "repeated_sfixed32", "repeated_sfixed64", "repeated_sint32", "repeated_sint64", "repeated_string", "repeated_uint32", "repeated_uint64", "single_bool", "single_bytes", "single_double", "single_fixed32", "single_fixed64", "single_float", "single_foreign_enum", "single_foreign_message", "single_import_enum", "single_import_message", "single_int32", "single_int64", "single_nested_enum", "single_nested_message", "single_public_import_message", "single_sfixed32", "single_sfixed64", "single_sint32", "single_sint64", "single_string", "single_uint32", "single_uint64" }; - private static readonly uint[] _fieldTags = new uint[] { 914, 898, 906, 888, 344, 362, 337, 301, 305, 333, 416, 394, 424, 402, 248, 256, 408, 386, 434, 317, 321, 280, 288, 354, 264, 272, 104, 122, 97, 61, 65, 93, 176, 154, 184, 162, 8, 16, 168, 146, 210, 77, 81, 40, 48, 114, 24, 32 }; + private static readonly uint[] _fieldTags = new uint[] { 914, 898, 906, 888, 346, 362, 338, 298, 306, 330, 418, 394, 426, 402, 250, 258, 410, 386, 434, 314, 322, 282, 290, 354, 266, 274, 104, 122, 97, 61, 65, 93, 176, 154, 184, 162, 8, 16, 168, 146, 210, 77, 81, 40, 48, 114, 24, 32 }; public static pbd::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestAllTypes__Descriptor; } } @@ -890,109 +890,144 @@ namespace Google.Protobuf.TestProtos { public void WriteTo(pb::CodedOutputStream output) { if (SingleInt32 != 0) { - output.WriteInt32(1, SingleInt32); + output.WriteRawTag(8); + output.WriteInt32(SingleInt32); } if (SingleInt64 != 0L) { - output.WriteInt64(2, SingleInt64); + output.WriteRawTag(16); + output.WriteInt64(SingleInt64); } if (SingleUint32 != 0) { - output.WriteUInt32(3, SingleUint32); + output.WriteRawTag(24); + output.WriteUInt32(SingleUint32); } if (SingleUint64 != 0UL) { - output.WriteUInt64(4, SingleUint64); + output.WriteRawTag(32); + output.WriteUInt64(SingleUint64); } if (SingleSint32 != 0) { - output.WriteSInt32(5, SingleSint32); + output.WriteRawTag(40); + output.WriteSInt32(SingleSint32); } if (SingleSint64 != 0L) { - output.WriteSInt64(6, SingleSint64); + output.WriteRawTag(48); + output.WriteSInt64(SingleSint64); } if (SingleFixed32 != 0) { - output.WriteFixed32(7, SingleFixed32); + output.WriteRawTag(61); + output.WriteFixed32(SingleFixed32); } if (SingleFixed64 != 0UL) { - output.WriteFixed64(8, SingleFixed64); + output.WriteRawTag(65); + output.WriteFixed64(SingleFixed64); } if (SingleSfixed32 != 0) { - output.WriteSFixed32(9, SingleSfixed32); + output.WriteRawTag(77); + output.WriteSFixed32(SingleSfixed32); } if (SingleSfixed64 != 0L) { - output.WriteSFixed64(10, SingleSfixed64); + output.WriteRawTag(81); + output.WriteSFixed64(SingleSfixed64); } if (SingleFloat != 0F) { - output.WriteFloat(11, SingleFloat); + output.WriteRawTag(93); + output.WriteFloat(SingleFloat); } if (SingleDouble != 0D) { - output.WriteDouble(12, SingleDouble); + output.WriteRawTag(97); + output.WriteDouble(SingleDouble); } if (SingleBool != false) { - output.WriteBool(13, SingleBool); + output.WriteRawTag(104); + output.WriteBool(SingleBool); } if (SingleString.Length != 0) { - output.WriteString(14, SingleString); + output.WriteRawTag(114); + output.WriteString(SingleString); } if (SingleBytes.Length != 0) { - output.WriteBytes(15, SingleBytes); + output.WriteRawTag(122); + output.WriteBytes(SingleBytes); } if (singleNestedMessage_ != null) { - output.WriteMessage(18, SingleNestedMessage); + output.WriteRawTag(146, 1); + output.WriteMessage(SingleNestedMessage); } if (singleForeignMessage_ != null) { - output.WriteMessage(19, SingleForeignMessage); + output.WriteRawTag(154, 1); + output.WriteMessage(SingleForeignMessage); } if (singleImportMessage_ != null) { - output.WriteMessage(20, SingleImportMessage); + output.WriteRawTag(162, 1); + output.WriteMessage(SingleImportMessage); } if (SingleNestedEnum != global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum.NESTED_ENUM_UNSPECIFIED) { - output.WriteEnum(21, (int) SingleNestedEnum); + output.WriteRawTag(168, 1); + output.WriteEnum((int) SingleNestedEnum); } if (SingleForeignEnum != global::Google.Protobuf.TestProtos.ForeignEnum.FOREIGN_UNSPECIFIED) { - output.WriteEnum(22, (int) SingleForeignEnum); + output.WriteRawTag(176, 1); + output.WriteEnum((int) SingleForeignEnum); } if (SingleImportEnum != global::Google.Protobuf.TestProtos.ImportEnum.IMPORT_ENUM_UNSPECIFIED) { - output.WriteEnum(23, (int) SingleImportEnum); + output.WriteRawTag(184, 1); + output.WriteEnum((int) SingleImportEnum); } if (singlePublicImportMessage_ != null) { - output.WriteMessage(26, SinglePublicImportMessage); + output.WriteRawTag(210, 1); + output.WriteMessage(SinglePublicImportMessage); } if (repeatedInt32_.Count > 0) { - output.WritePackedInt32Array(31, repeatedInt32_); + output.WriteRawTag(250, 1); + output.WritePackedInt32Array(repeatedInt32_); } if (repeatedInt64_.Count > 0) { - output.WritePackedInt64Array(32, repeatedInt64_); + output.WriteRawTag(130, 2); + output.WritePackedInt64Array(repeatedInt64_); } if (repeatedUint32_.Count > 0) { - output.WritePackedUInt32Array(33, repeatedUint32_); + output.WriteRawTag(138, 2); + output.WritePackedUInt32Array(repeatedUint32_); } if (repeatedUint64_.Count > 0) { - output.WritePackedUInt64Array(34, repeatedUint64_); + output.WriteRawTag(146, 2); + output.WritePackedUInt64Array(repeatedUint64_); } if (repeatedSint32_.Count > 0) { - output.WritePackedSInt32Array(35, repeatedSint32_); + output.WriteRawTag(154, 2); + output.WritePackedSInt32Array(repeatedSint32_); } if (repeatedSint64_.Count > 0) { - output.WritePackedSInt64Array(36, repeatedSint64_); + output.WriteRawTag(162, 2); + output.WritePackedSInt64Array(repeatedSint64_); } if (repeatedFixed32_.Count > 0) { - output.WritePackedFixed32Array(37, repeatedFixed32_); + output.WriteRawTag(170, 2); + output.WritePackedFixed32Array(repeatedFixed32_); } if (repeatedFixed64_.Count > 0) { - output.WritePackedFixed64Array(38, repeatedFixed64_); + output.WriteRawTag(178, 2); + output.WritePackedFixed64Array(repeatedFixed64_); } if (repeatedSfixed32_.Count > 0) { - output.WritePackedSFixed32Array(39, repeatedSfixed32_); + output.WriteRawTag(186, 2); + output.WritePackedSFixed32Array(repeatedSfixed32_); } if (repeatedSfixed64_.Count > 0) { - output.WritePackedSFixed64Array(40, repeatedSfixed64_); + output.WriteRawTag(194, 2); + output.WritePackedSFixed64Array(repeatedSfixed64_); } if (repeatedFloat_.Count > 0) { - output.WritePackedFloatArray(41, repeatedFloat_); + output.WriteRawTag(202, 2); + output.WritePackedFloatArray(repeatedFloat_); } if (repeatedDouble_.Count > 0) { - output.WritePackedDoubleArray(42, repeatedDouble_); + output.WriteRawTag(210, 2); + output.WritePackedDoubleArray(repeatedDouble_); } if (repeatedBool_.Count > 0) { - output.WritePackedBoolArray(43, repeatedBool_); + output.WriteRawTag(218, 2); + output.WritePackedBoolArray(repeatedBool_); } if (repeatedString_.Count > 0) { output.WriteStringArray(44, repeatedString_); @@ -1010,193 +1045,200 @@ namespace Google.Protobuf.TestProtos { output.WriteMessageArray(50, repeatedImportMessage_); } if (repeatedNestedEnum_.Count > 0) { - output.WritePackedEnumArray(51, repeatedNestedEnum_); + output.WriteRawTag(154, 3); + output.WritePackedEnumArray(repeatedNestedEnum_); } if (repeatedForeignEnum_.Count > 0) { - output.WritePackedEnumArray(52, repeatedForeignEnum_); + output.WriteRawTag(162, 3); + output.WritePackedEnumArray(repeatedForeignEnum_); } if (repeatedImportEnum_.Count > 0) { - output.WritePackedEnumArray(53, repeatedImportEnum_); + output.WriteRawTag(170, 3); + output.WritePackedEnumArray(repeatedImportEnum_); } if (repeatedPublicImportMessage_.Count > 0) { output.WriteMessageArray(54, repeatedPublicImportMessage_); } if (oneofFieldCase_ == OneofFieldOneofCase.OneofUint32) { - output.WriteUInt32(111, OneofUint32); + output.WriteRawTag(248, 6); + output.WriteUInt32(OneofUint32); } if (oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage) { - output.WriteMessage(112, OneofNestedMessage); + output.WriteRawTag(130, 7); + output.WriteMessage(OneofNestedMessage); } if (oneofFieldCase_ == OneofFieldOneofCase.OneofString) { - output.WriteString(113, OneofString); + output.WriteRawTag(138, 7); + output.WriteString(OneofString); } if (oneofFieldCase_ == OneofFieldOneofCase.OneofBytes) { - output.WriteBytes(114, OneofBytes); + output.WriteRawTag(146, 7); + output.WriteBytes(OneofBytes); } } public int CalculateSize() { int size = 0; if (SingleInt32 != 0) { - size += pb::CodedOutputStream.ComputeInt32Size(1, SingleInt32); + size += 1 + pb::CodedOutputStream.ComputeInt32Size(SingleInt32); } if (SingleInt64 != 0L) { - size += pb::CodedOutputStream.ComputeInt64Size(2, SingleInt64); + size += 1 + pb::CodedOutputStream.ComputeInt64Size(SingleInt64); } if (SingleUint32 != 0) { - size += pb::CodedOutputStream.ComputeUInt32Size(3, SingleUint32); + size += 1 + pb::CodedOutputStream.ComputeUInt32Size(SingleUint32); } if (SingleUint64 != 0UL) { - size += pb::CodedOutputStream.ComputeUInt64Size(4, SingleUint64); + size += 1 + pb::CodedOutputStream.ComputeUInt64Size(SingleUint64); } if (SingleSint32 != 0) { - size += pb::CodedOutputStream.ComputeSInt32Size(5, SingleSint32); + size += 1 + pb::CodedOutputStream.ComputeSInt32Size(SingleSint32); } if (SingleSint64 != 0L) { - size += pb::CodedOutputStream.ComputeSInt64Size(6, SingleSint64); + size += 1 + pb::CodedOutputStream.ComputeSInt64Size(SingleSint64); } if (SingleFixed32 != 0) { - size += pb::CodedOutputStream.ComputeFixed32Size(7, SingleFixed32); + size += 1 + 4; } if (SingleFixed64 != 0UL) { - size += pb::CodedOutputStream.ComputeFixed64Size(8, SingleFixed64); + size += 1 + 8; } if (SingleSfixed32 != 0) { - size += pb::CodedOutputStream.ComputeSFixed32Size(9, SingleSfixed32); + size += 1 + 4; } if (SingleSfixed64 != 0L) { - size += pb::CodedOutputStream.ComputeSFixed64Size(10, SingleSfixed64); + size += 1 + 8; } if (SingleFloat != 0F) { - size += pb::CodedOutputStream.ComputeFloatSize(11, SingleFloat); + size += 1 + 4; } if (SingleDouble != 0D) { - size += pb::CodedOutputStream.ComputeDoubleSize(12, SingleDouble); + size += 1 + 8; } if (SingleBool != false) { - size += pb::CodedOutputStream.ComputeBoolSize(13, SingleBool); + size += 1 + 1; } if (SingleString.Length != 0) { - size += pb::CodedOutputStream.ComputeStringSize(14, SingleString); + size += 1 + pb::CodedOutputStream.ComputeStringSize(SingleString); } if (SingleBytes.Length != 0) { - size += pb::CodedOutputStream.ComputeBytesSize(15, SingleBytes); + size += 1 + pb::CodedOutputStream.ComputeBytesSize(SingleBytes); } if (singleNestedMessage_ != null) { - size += pb::CodedOutputStream.ComputeMessageSize(18, SingleNestedMessage); + size += 2 + pb::CodedOutputStream.ComputeMessageSize(SingleNestedMessage); } if (singleForeignMessage_ != null) { - size += pb::CodedOutputStream.ComputeMessageSize(19, SingleForeignMessage); + size += 2 + pb::CodedOutputStream.ComputeMessageSize(SingleForeignMessage); } if (singleImportMessage_ != null) { - size += pb::CodedOutputStream.ComputeMessageSize(20, SingleImportMessage); + size += 2 + pb::CodedOutputStream.ComputeMessageSize(SingleImportMessage); } if (SingleNestedEnum != global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum.NESTED_ENUM_UNSPECIFIED) { - size += pb::CodedOutputStream.ComputeEnumSize(21, (int) SingleNestedEnum); + size += 2 + pb::CodedOutputStream.ComputeEnumSize((int) SingleNestedEnum); } if (SingleForeignEnum != global::Google.Protobuf.TestProtos.ForeignEnum.FOREIGN_UNSPECIFIED) { - size += pb::CodedOutputStream.ComputeEnumSize(22, (int) SingleForeignEnum); + size += 2 + pb::CodedOutputStream.ComputeEnumSize((int) SingleForeignEnum); } if (SingleImportEnum != global::Google.Protobuf.TestProtos.ImportEnum.IMPORT_ENUM_UNSPECIFIED) { - size += pb::CodedOutputStream.ComputeEnumSize(23, (int) SingleImportEnum); + size += 2 + pb::CodedOutputStream.ComputeEnumSize((int) SingleImportEnum); } if (singlePublicImportMessage_ != null) { - size += pb::CodedOutputStream.ComputeMessageSize(26, SinglePublicImportMessage); + size += 2 + pb::CodedOutputStream.ComputeMessageSize(SinglePublicImportMessage); } if (repeatedInt32_.Count > 0) { int dataSize = 0; foreach (int element in repeatedInt32_) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); + dataSize += pb::CodedOutputStream.ComputeInt32Size(element); } size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); } if (repeatedInt64_.Count > 0) { int dataSize = 0; foreach (long element in repeatedInt64_) { - dataSize += pb::CodedOutputStream.ComputeInt64SizeNoTag(element); + dataSize += pb::CodedOutputStream.ComputeInt64Size(element); } size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); } if (repeatedUint32_.Count > 0) { int dataSize = 0; foreach (uint element in repeatedUint32_) { - dataSize += pb::CodedOutputStream.ComputeUInt32SizeNoTag(element); + dataSize += pb::CodedOutputStream.ComputeUInt32Size(element); } size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); } if (repeatedUint64_.Count > 0) { int dataSize = 0; foreach (ulong element in repeatedUint64_) { - dataSize += pb::CodedOutputStream.ComputeUInt64SizeNoTag(element); + dataSize += pb::CodedOutputStream.ComputeUInt64Size(element); } size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); } if (repeatedSint32_.Count > 0) { int dataSize = 0; foreach (int element in repeatedSint32_) { - dataSize += pb::CodedOutputStream.ComputeSInt32SizeNoTag(element); + dataSize += pb::CodedOutputStream.ComputeSInt32Size(element); } size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); } if (repeatedSint64_.Count > 0) { int dataSize = 0; foreach (long element in repeatedSint64_) { - dataSize += pb::CodedOutputStream.ComputeSInt64SizeNoTag(element); + dataSize += pb::CodedOutputStream.ComputeSInt64Size(element); } size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); } if (repeatedFixed32_.Count > 0) { int dataSize = 0; dataSize = 4 * repeatedFixed32_.Count; size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); } if (repeatedFixed64_.Count > 0) { int dataSize = 0; dataSize = 8 * repeatedFixed64_.Count; size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); } if (repeatedSfixed32_.Count > 0) { int dataSize = 0; dataSize = 4 * repeatedSfixed32_.Count; size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); } if (repeatedSfixed64_.Count > 0) { int dataSize = 0; dataSize = 8 * repeatedSfixed64_.Count; size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); } if (repeatedFloat_.Count > 0) { int dataSize = 0; dataSize = 4 * repeatedFloat_.Count; size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); } if (repeatedDouble_.Count > 0) { int dataSize = 0; dataSize = 8 * repeatedDouble_.Count; size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); } if (repeatedBool_.Count > 0) { int dataSize = 0; dataSize = 1 * repeatedBool_.Count; size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); } if (repeatedString_.Count > 0) { int dataSize = 0; foreach (string element in repeatedString_) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); + dataSize += pb::CodedOutputStream.ComputeStringSize(element); } size += dataSize; size += 2 * repeatedString_.Count; @@ -1204,69 +1246,70 @@ namespace Google.Protobuf.TestProtos { if (repeatedBytes_.Count > 0) { int dataSize = 0; foreach (pb::ByteString element in repeatedBytes_) { - dataSize += pb::CodedOutputStream.ComputeBytesSizeNoTag(element); + dataSize += pb::CodedOutputStream.ComputeBytesSize(element); } size += dataSize; size += 2 * repeatedBytes_.Count; } if (repeatedNestedMessage_.Count > 0) { foreach (global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage element in repeatedNestedMessage_) { - size += pb::CodedOutputStream.ComputeMessageSize(48, element); + size += pb::CodedOutputStream.ComputeMessageSize(element); } + size += 2 * repeatedNestedMessage_.Count; } if (repeatedForeignMessage_.Count > 0) { foreach (global::Google.Protobuf.TestProtos.ForeignMessage element in repeatedForeignMessage_) { - size += pb::CodedOutputStream.ComputeMessageSize(49, element); + size += pb::CodedOutputStream.ComputeMessageSize(element); } + size += 2 * repeatedForeignMessage_.Count; } if (repeatedImportMessage_.Count > 0) { foreach (global::Google.Protobuf.TestProtos.ImportMessage element in repeatedImportMessage_) { - size += pb::CodedOutputStream.ComputeMessageSize(50, element); + size += pb::CodedOutputStream.ComputeMessageSize(element); } + size += 2 * repeatedImportMessage_.Count; } if (repeatedNestedEnum_.Count > 0) { int dataSize = 0; foreach (global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum element in repeatedNestedEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); + dataSize += pb::CodedOutputStream.ComputeEnumSize((int) element); } size += dataSize; - size += 2; - size += pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize); + size += 2 + pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize); } if (repeatedForeignEnum_.Count > 0) { int dataSize = 0; foreach (global::Google.Protobuf.TestProtos.ForeignEnum element in repeatedForeignEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); + dataSize += pb::CodedOutputStream.ComputeEnumSize((int) element); } size += dataSize; - size += 2; - size += pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize); + size += 2 + pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize); } if (repeatedImportEnum_.Count > 0) { int dataSize = 0; foreach (global::Google.Protobuf.TestProtos.ImportEnum element in repeatedImportEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); + dataSize += pb::CodedOutputStream.ComputeEnumSize((int) element); } size += dataSize; - size += 2; - size += pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize); + size += 2 + pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize); } if (repeatedPublicImportMessage_.Count > 0) { foreach (global::Google.Protobuf.TestProtos.PublicImportMessage element in repeatedPublicImportMessage_) { - size += pb::CodedOutputStream.ComputeMessageSize(54, element); + size += pb::CodedOutputStream.ComputeMessageSize(element); } + size += 2 * repeatedPublicImportMessage_.Count; } if (oneofFieldCase_ == OneofFieldOneofCase.OneofUint32) { - size += pb::CodedOutputStream.ComputeUInt32Size(111, OneofUint32); + size += 2 + pb::CodedOutputStream.ComputeUInt32Size(OneofUint32); } if (oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(112, OneofNestedMessage); + size += 2 + pb::CodedOutputStream.ComputeMessageSize(OneofNestedMessage); } if (oneofFieldCase_ == OneofFieldOneofCase.OneofString) { - size += pb::CodedOutputStream.ComputeStringSize(113, OneofString); + size += 2 + pb::CodedOutputStream.ComputeStringSize(OneofString); } if (oneofFieldCase_ == OneofFieldOneofCase.OneofBytes) { - size += pb::CodedOutputStream.ComputeBytesSize(114, OneofBytes); + size += 2 + pb::CodedOutputStream.ComputeBytesSize(OneofBytes); } return size; } @@ -1607,8 +1650,8 @@ namespace Google.Protobuf.TestProtos { break; } case 888: { - OneofUint32 = input.ReadUInt32() - ;break; + OneofUint32 = input.ReadUInt32(); + break; } case 898: { global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage subBuilder = new global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage(); @@ -1620,12 +1663,12 @@ namespace Google.Protobuf.TestProtos { break; } case 906: { - OneofString = input.ReadString() - ;break; + OneofString = input.ReadString(); + break; } case 914: { - OneofBytes = input.ReadBytes() - ;break; + OneofBytes = input.ReadBytes(); + break; } } } @@ -1692,14 +1735,15 @@ namespace Google.Protobuf.TestProtos { public void WriteTo(pb::CodedOutputStream output) { if (Bb != 0) { - output.WriteInt32(1, Bb); + output.WriteRawTag(8); + output.WriteInt32(Bb); } } public int CalculateSize() { int size = 0; if (Bb != 0) { - size += pb::CodedOutputStream.ComputeInt32Size(1, Bb); + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Bb); } return size; } @@ -1802,10 +1846,12 @@ namespace Google.Protobuf.TestProtos { public void WriteTo(pb::CodedOutputStream output) { if (child_ != null) { - output.WriteMessage(1, Child); + output.WriteRawTag(10); + output.WriteMessage(Child); } if (payload_ != null) { - output.WriteMessage(2, Payload); + output.WriteRawTag(18); + output.WriteMessage(Payload); } if (repeatedChild_.Count > 0) { output.WriteMessageArray(3, repeatedChild_); @@ -1815,15 +1861,16 @@ namespace Google.Protobuf.TestProtos { public int CalculateSize() { int size = 0; if (child_ != null) { - size += pb::CodedOutputStream.ComputeMessageSize(1, Child); + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Child); } if (payload_ != null) { - size += pb::CodedOutputStream.ComputeMessageSize(2, Payload); + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Payload); } if (repeatedChild_.Count > 0) { foreach (global::Google.Protobuf.TestProtos.NestedTestAllTypes element in repeatedChild_) { - size += pb::CodedOutputStream.ComputeMessageSize(3, element); + size += pb::CodedOutputStream.ComputeMessageSize(element); } + size += 1 * repeatedChild_.Count; } return size; } @@ -1932,14 +1979,15 @@ namespace Google.Protobuf.TestProtos { public void WriteTo(pb::CodedOutputStream output) { if (DeprecatedInt32 != 0) { - output.WriteInt32(1, DeprecatedInt32); + output.WriteRawTag(8); + output.WriteInt32(DeprecatedInt32); } } public int CalculateSize() { int size = 0; if (DeprecatedInt32 != 0) { - size += pb::CodedOutputStream.ComputeInt32Size(1, DeprecatedInt32); + size += 1 + pb::CodedOutputStream.ComputeInt32Size(DeprecatedInt32); } return size; } @@ -2023,14 +2071,15 @@ namespace Google.Protobuf.TestProtos { public void WriteTo(pb::CodedOutputStream output) { if (C != 0) { - output.WriteInt32(1, C); + output.WriteRawTag(8); + output.WriteInt32(C); } } public int CalculateSize() { int size = 0; if (C != 0) { - size += pb::CodedOutputStream.ComputeInt32Size(1, C); + size += 1 + pb::CodedOutputStream.ComputeInt32Size(C); } return size; } @@ -2180,14 +2229,15 @@ namespace Google.Protobuf.TestProtos { public void WriteTo(pb::CodedOutputStream output) { if (foreignNested_ != null) { - output.WriteMessage(1, ForeignNested); + output.WriteRawTag(10); + output.WriteMessage(ForeignNested); } } public int CalculateSize() { int size = 0; if (foreignNested_ != null) { - size += pb::CodedOutputStream.ComputeMessageSize(1, ForeignNested); + size += 1 + pb::CodedOutputStream.ComputeMessageSize(ForeignNested); } return size; } @@ -2287,20 +2337,22 @@ namespace Google.Protobuf.TestProtos { public void WriteTo(pb::CodedOutputStream output) { if (A != 0) { - output.WriteInt32(1, A); + output.WriteRawTag(8); + output.WriteInt32(A); } if (Bb != 0) { - output.WriteInt32(268435455, Bb); + output.WriteRawTag(248, 255, 255, 255, 7); + output.WriteInt32(Bb); } } public int CalculateSize() { int size = 0; if (A != 0) { - size += pb::CodedOutputStream.ComputeInt32Size(1, A); + size += 1 + pb::CodedOutputStream.ComputeInt32Size(A); } if (Bb != 0) { - size += pb::CodedOutputStream.ComputeInt32Size(268435455, Bb); + size += 5 + pb::CodedOutputStream.ComputeInt32Size(Bb); } return size; } @@ -2399,20 +2451,22 @@ namespace Google.Protobuf.TestProtos { public void WriteTo(pb::CodedOutputStream output) { if (a_ != null) { - output.WriteMessage(1, A); + output.WriteRawTag(10); + output.WriteMessage(A); } if (I != 0) { - output.WriteInt32(2, I); + output.WriteRawTag(16); + output.WriteInt32(I); } } public int CalculateSize() { int size = 0; if (a_ != null) { - size += pb::CodedOutputStream.ComputeMessageSize(1, A); + size += 1 + pb::CodedOutputStream.ComputeMessageSize(A); } if (I != 0) { - size += pb::CodedOutputStream.ComputeInt32Size(2, I); + size += 1 + pb::CodedOutputStream.ComputeInt32Size(I); } return size; } @@ -2507,14 +2561,15 @@ namespace Google.Protobuf.TestProtos { public void WriteTo(pb::CodedOutputStream output) { if (bb_ != null) { - output.WriteMessage(1, Bb); + output.WriteRawTag(10); + output.WriteMessage(Bb); } } public int CalculateSize() { int size = 0; if (bb_ != null) { - size += pb::CodedOutputStream.ComputeMessageSize(1, Bb); + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Bb); } return size; } @@ -2612,20 +2667,22 @@ namespace Google.Protobuf.TestProtos { public void WriteTo(pb::CodedOutputStream output) { if (a_ != null) { - output.WriteMessage(1, A); + output.WriteRawTag(10); + output.WriteMessage(A); } if (OptionalInt32 != 0) { - output.WriteInt32(2, OptionalInt32); + output.WriteRawTag(16); + output.WriteInt32(OptionalInt32); } } public int CalculateSize() { int size = 0; if (a_ != null) { - size += pb::CodedOutputStream.ComputeMessageSize(1, A); + size += 1 + pb::CodedOutputStream.ComputeMessageSize(A); } if (OptionalInt32 != 0) { - size += pb::CodedOutputStream.ComputeInt32Size(2, OptionalInt32); + size += 1 + pb::CodedOutputStream.ComputeInt32Size(OptionalInt32); } return size; } @@ -2678,7 +2735,7 @@ namespace Google.Protobuf.TestProtos { public static pb::MessageParser Parser { get { return _parser; } } private static readonly string[] _fieldNames = new string[] { "EnumField", "MessageField", "PrimitiveField", "RepeatedEnumField", "RepeatedMessageField", "RepeatedPrimitiveField", "RepeatedStringField", "StringField" }; - private static readonly uint[] _fieldTags = new uint[] { 24, 34, 8, 72, 82, 56, 66, 18 }; + private static readonly uint[] _fieldTags = new uint[] { 24, 34, 8, 74, 82, 58, 66, 18 }; public static pbd::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestCamelCaseFieldNames__Descriptor; } } @@ -2782,25 +2839,31 @@ namespace Google.Protobuf.TestProtos { public void WriteTo(pb::CodedOutputStream output) { if (PrimitiveField != 0) { - output.WriteInt32(1, PrimitiveField); + output.WriteRawTag(8); + output.WriteInt32(PrimitiveField); } if (StringField.Length != 0) { - output.WriteString(2, StringField); + output.WriteRawTag(18); + output.WriteString(StringField); } if (EnumField != global::Google.Protobuf.TestProtos.ForeignEnum.FOREIGN_UNSPECIFIED) { - output.WriteEnum(3, (int) EnumField); + output.WriteRawTag(24); + output.WriteEnum((int) EnumField); } if (messageField_ != null) { - output.WriteMessage(4, MessageField); + output.WriteRawTag(34); + output.WriteMessage(MessageField); } if (repeatedPrimitiveField_.Count > 0) { - output.WritePackedInt32Array(7, repeatedPrimitiveField_); + output.WriteRawTag(58); + output.WritePackedInt32Array(repeatedPrimitiveField_); } if (repeatedStringField_.Count > 0) { output.WriteStringArray(8, repeatedStringField_); } if (repeatedEnumField_.Count > 0) { - output.WritePackedEnumArray(9, repeatedEnumField_); + output.WriteRawTag(74); + output.WritePackedEnumArray(repeatedEnumField_); } if (repeatedMessageField_.Count > 0) { output.WriteMessageArray(10, repeatedMessageField_); @@ -2810,29 +2873,29 @@ namespace Google.Protobuf.TestProtos { public int CalculateSize() { int size = 0; if (PrimitiveField != 0) { - size += pb::CodedOutputStream.ComputeInt32Size(1, PrimitiveField); + size += 1 + pb::CodedOutputStream.ComputeInt32Size(PrimitiveField); } if (StringField.Length != 0) { - size += pb::CodedOutputStream.ComputeStringSize(2, StringField); + size += 1 + pb::CodedOutputStream.ComputeStringSize(StringField); } if (EnumField != global::Google.Protobuf.TestProtos.ForeignEnum.FOREIGN_UNSPECIFIED) { - size += pb::CodedOutputStream.ComputeEnumSize(3, (int) EnumField); + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) EnumField); } if (messageField_ != null) { - size += pb::CodedOutputStream.ComputeMessageSize(4, MessageField); + size += 1 + pb::CodedOutputStream.ComputeMessageSize(MessageField); } if (repeatedPrimitiveField_.Count > 0) { int dataSize = 0; foreach (int element in repeatedPrimitiveField_) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); + dataSize += pb::CodedOutputStream.ComputeInt32Size(element); } size += dataSize; - size += 1 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + size += 1 + pb::CodedOutputStream.ComputeInt32Size(dataSize); } if (repeatedStringField_.Count > 0) { int dataSize = 0; foreach (string element in repeatedStringField_) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); + dataSize += pb::CodedOutputStream.ComputeStringSize(element); } size += dataSize; size += 1 * repeatedStringField_.Count; @@ -2840,16 +2903,16 @@ namespace Google.Protobuf.TestProtos { if (repeatedEnumField_.Count > 0) { int dataSize = 0; foreach (global::Google.Protobuf.TestProtos.ForeignEnum element in repeatedEnumField_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); + dataSize += pb::CodedOutputStream.ComputeEnumSize((int) element); } size += dataSize; - size += 1; - size += pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize); + size += 1 + pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize); } if (repeatedMessageField_.Count > 0) { foreach (global::Google.Protobuf.TestProtos.ForeignMessage element in repeatedMessageField_) { - size += pb::CodedOutputStream.ComputeMessageSize(10, element); + size += pb::CodedOutputStream.ComputeMessageSize(element); } + size += 1 * repeatedMessageField_.Count; } return size; } @@ -3010,32 +3073,36 @@ namespace Google.Protobuf.TestProtos { public void WriteTo(pb::CodedOutputStream output) { if (MyInt != 0L) { - output.WriteInt64(1, MyInt); + output.WriteRawTag(8); + output.WriteInt64(MyInt); } if (MyString.Length != 0) { - output.WriteString(11, MyString); + output.WriteRawTag(90); + output.WriteString(MyString); } if (MyFloat != 0F) { - output.WriteFloat(101, MyFloat); + output.WriteRawTag(173, 6); + output.WriteFloat(MyFloat); } if (singleNestedMessage_ != null) { - output.WriteMessage(200, SingleNestedMessage); + output.WriteRawTag(194, 12); + output.WriteMessage(SingleNestedMessage); } } public int CalculateSize() { int size = 0; if (MyString.Length != 0) { - size += pb::CodedOutputStream.ComputeStringSize(11, MyString); + size += 1 + pb::CodedOutputStream.ComputeStringSize(MyString); } if (MyInt != 0L) { - size += pb::CodedOutputStream.ComputeInt64Size(1, MyInt); + size += 1 + pb::CodedOutputStream.ComputeInt64Size(MyInt); } if (MyFloat != 0F) { - size += pb::CodedOutputStream.ComputeFloatSize(101, MyFloat); + size += 2 + 4; } if (singleNestedMessage_ != null) { - size += pb::CodedOutputStream.ComputeMessageSize(200, SingleNestedMessage); + size += 2 + pb::CodedOutputStream.ComputeMessageSize(SingleNestedMessage); } return size; } @@ -3157,20 +3224,22 @@ namespace Google.Protobuf.TestProtos { public void WriteTo(pb::CodedOutputStream output) { if (Bb != 0) { - output.WriteInt32(1, Bb); + output.WriteRawTag(8); + output.WriteInt32(Bb); } if (Oo != 0L) { - output.WriteInt64(2, Oo); + output.WriteRawTag(16); + output.WriteInt64(Oo); } } public int CalculateSize() { int size = 0; if (Oo != 0L) { - size += pb::CodedOutputStream.ComputeInt64Size(2, Oo); + size += 1 + pb::CodedOutputStream.ComputeInt64Size(Oo); } if (Bb != 0) { - size += pb::CodedOutputStream.ComputeInt32Size(1, Bb); + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Bb); } return size; } @@ -3266,14 +3335,15 @@ namespace Google.Protobuf.TestProtos { public void WriteTo(pb::CodedOutputStream output) { if (SparseEnum != global::Google.Protobuf.TestProtos.TestSparseEnum.TEST_SPARSE_ENUM_UNSPECIFIED) { - output.WriteEnum(1, (int) SparseEnum); + output.WriteRawTag(8); + output.WriteEnum((int) SparseEnum); } } public int CalculateSize() { int size = 0; if (SparseEnum != global::Google.Protobuf.TestProtos.TestSparseEnum.TEST_SPARSE_ENUM_UNSPECIFIED) { - size += pb::CodedOutputStream.ComputeEnumSize(1, (int) SparseEnum); + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) SparseEnum); } return size; } @@ -3357,14 +3427,15 @@ namespace Google.Protobuf.TestProtos { public void WriteTo(pb::CodedOutputStream output) { if (Data.Length != 0) { - output.WriteString(1, Data); + output.WriteRawTag(10); + output.WriteString(Data); } } public int CalculateSize() { int size = 0; if (Data.Length != 0) { - size += pb::CodedOutputStream.ComputeStringSize(1, Data); + size += 1 + pb::CodedOutputStream.ComputeStringSize(Data); } return size; } @@ -3455,7 +3526,7 @@ namespace Google.Protobuf.TestProtos { if (data_.Count > 0) { int dataSize = 0; foreach (string element in data_) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); + dataSize += pb::CodedOutputStream.ComputeStringSize(element); } size += dataSize; size += 1 * data_.Count; @@ -3540,14 +3611,15 @@ namespace Google.Protobuf.TestProtos { public void WriteTo(pb::CodedOutputStream output) { if (Data.Length != 0) { - output.WriteBytes(1, Data); + output.WriteRawTag(10); + output.WriteBytes(Data); } } public int CalculateSize() { int size = 0; if (Data.Length != 0) { - size += pb::CodedOutputStream.ComputeBytesSize(1, Data); + size += 1 + pb::CodedOutputStream.ComputeBytesSize(Data); } return size; } @@ -3631,14 +3703,15 @@ namespace Google.Protobuf.TestProtos { public void WriteTo(pb::CodedOutputStream output) { if (Data.Length != 0) { - output.WriteBytes(1, Data); + output.WriteRawTag(10); + output.WriteBytes(Data); } } public int CalculateSize() { int size = 0; if (Data.Length != 0) { - size += pb::CodedOutputStream.ComputeBytesSize(1, Data); + size += 1 + pb::CodedOutputStream.ComputeBytesSize(Data); } return size; } @@ -3722,14 +3795,15 @@ namespace Google.Protobuf.TestProtos { public void WriteTo(pb::CodedOutputStream output) { if (Data != 0) { - output.WriteInt32(1, Data); + output.WriteRawTag(8); + output.WriteInt32(Data); } } public int CalculateSize() { int size = 0; if (Data != 0) { - size += pb::CodedOutputStream.ComputeInt32Size(1, Data); + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Data); } return size; } @@ -3813,14 +3887,15 @@ namespace Google.Protobuf.TestProtos { public void WriteTo(pb::CodedOutputStream output) { if (Data != 0) { - output.WriteUInt32(1, Data); + output.WriteRawTag(8); + output.WriteUInt32(Data); } } public int CalculateSize() { int size = 0; if (Data != 0) { - size += pb::CodedOutputStream.ComputeUInt32Size(1, Data); + size += 1 + pb::CodedOutputStream.ComputeUInt32Size(Data); } return size; } @@ -3904,14 +3979,15 @@ namespace Google.Protobuf.TestProtos { public void WriteTo(pb::CodedOutputStream output) { if (Data != 0L) { - output.WriteInt64(1, Data); + output.WriteRawTag(8); + output.WriteInt64(Data); } } public int CalculateSize() { int size = 0; if (Data != 0L) { - size += pb::CodedOutputStream.ComputeInt64Size(1, Data); + size += 1 + pb::CodedOutputStream.ComputeInt64Size(Data); } return size; } @@ -3995,14 +4071,15 @@ namespace Google.Protobuf.TestProtos { public void WriteTo(pb::CodedOutputStream output) { if (Data != 0UL) { - output.WriteUInt64(1, Data); + output.WriteRawTag(8); + output.WriteUInt64(Data); } } public int CalculateSize() { int size = 0; if (Data != 0UL) { - size += pb::CodedOutputStream.ComputeUInt64Size(1, Data); + size += 1 + pb::CodedOutputStream.ComputeUInt64Size(Data); } return size; } @@ -4086,14 +4163,15 @@ namespace Google.Protobuf.TestProtos { public void WriteTo(pb::CodedOutputStream output) { if (Data != false) { - output.WriteBool(1, Data); + output.WriteRawTag(8); + output.WriteBool(Data); } } public int CalculateSize() { int size = 0; if (Data != false) { - size += pb::CodedOutputStream.ComputeBoolSize(1, Data); + size += 1 + 1; } return size; } @@ -4216,26 +4294,29 @@ namespace Google.Protobuf.TestProtos { public void WriteTo(pb::CodedOutputStream output) { if (fooCase_ == FooOneofCase.FooInt) { - output.WriteInt32(1, FooInt); + output.WriteRawTag(8); + output.WriteInt32(FooInt); } if (fooCase_ == FooOneofCase.FooString) { - output.WriteString(2, FooString); + output.WriteRawTag(18); + output.WriteString(FooString); } if (fooCase_ == FooOneofCase.FooMessage) { - output.WriteMessage(3, FooMessage); + output.WriteRawTag(26); + output.WriteMessage(FooMessage); } } public int CalculateSize() { int size = 0; if (fooCase_ == FooOneofCase.FooInt) { - size += pb::CodedOutputStream.ComputeInt32Size(1, FooInt); + size += 1 + pb::CodedOutputStream.ComputeInt32Size(FooInt); } if (fooCase_ == FooOneofCase.FooString) { - size += pb::CodedOutputStream.ComputeStringSize(2, FooString); + size += 1 + pb::CodedOutputStream.ComputeStringSize(FooString); } if (fooCase_ == FooOneofCase.FooMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(3, FooMessage); + size += 1 + pb::CodedOutputStream.ComputeMessageSize(FooMessage); } return size; } @@ -4269,12 +4350,12 @@ namespace Google.Protobuf.TestProtos { } break; case 8: { - FooInt = input.ReadInt32() - ;break; + FooInt = input.ReadInt32(); + break; } case 18: { - FooString = input.ReadString() - ;break; + FooString = input.ReadString(); + break; } case 26: { global::Google.Protobuf.TestProtos.TestAllTypes subBuilder = new global::Google.Protobuf.TestProtos.TestAllTypes(); @@ -4443,46 +4524,60 @@ namespace Google.Protobuf.TestProtos { public void WriteTo(pb::CodedOutputStream output) { if (packedInt32_.Count > 0) { - output.WritePackedInt32Array(90, packedInt32_); + output.WriteRawTag(210, 5); + output.WritePackedInt32Array(packedInt32_); } if (packedInt64_.Count > 0) { - output.WritePackedInt64Array(91, packedInt64_); + output.WriteRawTag(218, 5); + output.WritePackedInt64Array(packedInt64_); } if (packedUint32_.Count > 0) { - output.WritePackedUInt32Array(92, packedUint32_); + output.WriteRawTag(226, 5); + output.WritePackedUInt32Array(packedUint32_); } if (packedUint64_.Count > 0) { - output.WritePackedUInt64Array(93, packedUint64_); + output.WriteRawTag(234, 5); + output.WritePackedUInt64Array(packedUint64_); } if (packedSint32_.Count > 0) { - output.WritePackedSInt32Array(94, packedSint32_); + output.WriteRawTag(242, 5); + output.WritePackedSInt32Array(packedSint32_); } if (packedSint64_.Count > 0) { - output.WritePackedSInt64Array(95, packedSint64_); + output.WriteRawTag(250, 5); + output.WritePackedSInt64Array(packedSint64_); } if (packedFixed32_.Count > 0) { - output.WritePackedFixed32Array(96, packedFixed32_); + output.WriteRawTag(130, 6); + output.WritePackedFixed32Array(packedFixed32_); } if (packedFixed64_.Count > 0) { - output.WritePackedFixed64Array(97, packedFixed64_); + output.WriteRawTag(138, 6); + output.WritePackedFixed64Array(packedFixed64_); } if (packedSfixed32_.Count > 0) { - output.WritePackedSFixed32Array(98, packedSfixed32_); + output.WriteRawTag(146, 6); + output.WritePackedSFixed32Array(packedSfixed32_); } if (packedSfixed64_.Count > 0) { - output.WritePackedSFixed64Array(99, packedSfixed64_); + output.WriteRawTag(154, 6); + output.WritePackedSFixed64Array(packedSfixed64_); } if (packedFloat_.Count > 0) { - output.WritePackedFloatArray(100, packedFloat_); + output.WriteRawTag(162, 6); + output.WritePackedFloatArray(packedFloat_); } if (packedDouble_.Count > 0) { - output.WritePackedDoubleArray(101, packedDouble_); + output.WriteRawTag(170, 6); + output.WritePackedDoubleArray(packedDouble_); } if (packedBool_.Count > 0) { - output.WritePackedBoolArray(102, packedBool_); + output.WriteRawTag(178, 6); + output.WritePackedBoolArray(packedBool_); } if (packedEnum_.Count > 0) { - output.WritePackedEnumArray(103, packedEnum_); + output.WriteRawTag(186, 6); + output.WritePackedEnumArray(packedEnum_); } } @@ -4491,101 +4586,100 @@ namespace Google.Protobuf.TestProtos { if (packedInt32_.Count > 0) { int dataSize = 0; foreach (int element in packedInt32_) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); + dataSize += pb::CodedOutputStream.ComputeInt32Size(element); } size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); } if (packedInt64_.Count > 0) { int dataSize = 0; foreach (long element in packedInt64_) { - dataSize += pb::CodedOutputStream.ComputeInt64SizeNoTag(element); + dataSize += pb::CodedOutputStream.ComputeInt64Size(element); } size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); } if (packedUint32_.Count > 0) { int dataSize = 0; foreach (uint element in packedUint32_) { - dataSize += pb::CodedOutputStream.ComputeUInt32SizeNoTag(element); + dataSize += pb::CodedOutputStream.ComputeUInt32Size(element); } size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); } if (packedUint64_.Count > 0) { int dataSize = 0; foreach (ulong element in packedUint64_) { - dataSize += pb::CodedOutputStream.ComputeUInt64SizeNoTag(element); + dataSize += pb::CodedOutputStream.ComputeUInt64Size(element); } size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); } if (packedSint32_.Count > 0) { int dataSize = 0; foreach (int element in packedSint32_) { - dataSize += pb::CodedOutputStream.ComputeSInt32SizeNoTag(element); + dataSize += pb::CodedOutputStream.ComputeSInt32Size(element); } size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); } if (packedSint64_.Count > 0) { int dataSize = 0; foreach (long element in packedSint64_) { - dataSize += pb::CodedOutputStream.ComputeSInt64SizeNoTag(element); + dataSize += pb::CodedOutputStream.ComputeSInt64Size(element); } size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); } if (packedFixed32_.Count > 0) { int dataSize = 0; dataSize = 4 * packedFixed32_.Count; size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); } if (packedFixed64_.Count > 0) { int dataSize = 0; dataSize = 8 * packedFixed64_.Count; size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); } if (packedSfixed32_.Count > 0) { int dataSize = 0; dataSize = 4 * packedSfixed32_.Count; size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); } if (packedSfixed64_.Count > 0) { int dataSize = 0; dataSize = 8 * packedSfixed64_.Count; size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); } if (packedFloat_.Count > 0) { int dataSize = 0; dataSize = 4 * packedFloat_.Count; size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); } if (packedDouble_.Count > 0) { int dataSize = 0; dataSize = 8 * packedDouble_.Count; size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); } if (packedBool_.Count > 0) { int dataSize = 0; dataSize = 1 * packedBool_.Count; size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); } if (packedEnum_.Count > 0) { int dataSize = 0; foreach (global::Google.Protobuf.TestProtos.ForeignEnum element in packedEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); + dataSize += pb::CodedOutputStream.ComputeEnumSize((int) element); } size += dataSize; - size += 2; - size += pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize); + size += 2 + pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize); } return size; } @@ -4896,7 +4990,7 @@ namespace Google.Protobuf.TestProtos { if (unpackedInt32_.Count > 0) { int dataSize = 0; foreach (int element in unpackedInt32_) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); + dataSize += pb::CodedOutputStream.ComputeInt32Size(element); } size += dataSize; size += 2 * unpackedInt32_.Count; @@ -4904,7 +4998,7 @@ namespace Google.Protobuf.TestProtos { if (unpackedInt64_.Count > 0) { int dataSize = 0; foreach (long element in unpackedInt64_) { - dataSize += pb::CodedOutputStream.ComputeInt64SizeNoTag(element); + dataSize += pb::CodedOutputStream.ComputeInt64Size(element); } size += dataSize; size += 2 * unpackedInt64_.Count; @@ -4912,7 +5006,7 @@ namespace Google.Protobuf.TestProtos { if (unpackedUint32_.Count > 0) { int dataSize = 0; foreach (uint element in unpackedUint32_) { - dataSize += pb::CodedOutputStream.ComputeUInt32SizeNoTag(element); + dataSize += pb::CodedOutputStream.ComputeUInt32Size(element); } size += dataSize; size += 2 * unpackedUint32_.Count; @@ -4920,7 +5014,7 @@ namespace Google.Protobuf.TestProtos { if (unpackedUint64_.Count > 0) { int dataSize = 0; foreach (ulong element in unpackedUint64_) { - dataSize += pb::CodedOutputStream.ComputeUInt64SizeNoTag(element); + dataSize += pb::CodedOutputStream.ComputeUInt64Size(element); } size += dataSize; size += 2 * unpackedUint64_.Count; @@ -4928,7 +5022,7 @@ namespace Google.Protobuf.TestProtos { if (unpackedSint32_.Count > 0) { int dataSize = 0; foreach (int element in unpackedSint32_) { - dataSize += pb::CodedOutputStream.ComputeSInt32SizeNoTag(element); + dataSize += pb::CodedOutputStream.ComputeSInt32Size(element); } size += dataSize; size += 2 * unpackedSint32_.Count; @@ -4936,7 +5030,7 @@ namespace Google.Protobuf.TestProtos { if (unpackedSint64_.Count > 0) { int dataSize = 0; foreach (long element in unpackedSint64_) { - dataSize += pb::CodedOutputStream.ComputeSInt64SizeNoTag(element); + dataSize += pb::CodedOutputStream.ComputeSInt64Size(element); } size += dataSize; size += 2 * unpackedSint64_.Count; @@ -4986,7 +5080,7 @@ namespace Google.Protobuf.TestProtos { if (unpackedEnum_.Count > 0) { int dataSize = 0; foreach (global::Google.Protobuf.TestProtos.ForeignEnum element in unpackedEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); + dataSize += pb::CodedOutputStream.ComputeEnumSize((int) element); } size += dataSize; size += 2 * unpackedEnum_.Count; @@ -5106,7 +5200,7 @@ namespace Google.Protobuf.TestProtos { public static pb::MessageParser Parser { get { return _parser; } } private static readonly string[] _fieldNames = new string[] { "repeated_fixed32", "repeated_fixed64", "repeated_float", "repeated_int32", "repeated_int64", "repeated_uint64" }; - private static readonly uint[] _fieldTags = new uint[] { 101, 16369, 2097141, 104, 16376, 2097144 }; + private static readonly uint[] _fieldTags = new uint[] { 98, 16370, 2097138, 106, 16378, 2097146 }; public static pbd::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestRepeatedScalarDifferentTagSizes__Descriptor; } } @@ -5188,22 +5282,28 @@ namespace Google.Protobuf.TestProtos { public void WriteTo(pb::CodedOutputStream output) { if (repeatedFixed32_.Count > 0) { - output.WritePackedFixed32Array(12, repeatedFixed32_); + output.WriteRawTag(98); + output.WritePackedFixed32Array(repeatedFixed32_); } if (repeatedInt32_.Count > 0) { - output.WritePackedInt32Array(13, repeatedInt32_); + output.WriteRawTag(106); + output.WritePackedInt32Array(repeatedInt32_); } if (repeatedFixed64_.Count > 0) { - output.WritePackedFixed64Array(2046, repeatedFixed64_); + output.WriteRawTag(242, 127); + output.WritePackedFixed64Array(repeatedFixed64_); } if (repeatedInt64_.Count > 0) { - output.WritePackedInt64Array(2047, repeatedInt64_); + output.WriteRawTag(250, 127); + output.WritePackedInt64Array(repeatedInt64_); } if (repeatedFloat_.Count > 0) { - output.WritePackedFloatArray(262142, repeatedFloat_); + output.WriteRawTag(242, 255, 127); + output.WritePackedFloatArray(repeatedFloat_); } if (repeatedUint64_.Count > 0) { - output.WritePackedUInt64Array(262143, repeatedUint64_); + output.WriteRawTag(250, 255, 127); + output.WritePackedUInt64Array(repeatedUint64_); } } @@ -5213,43 +5313,43 @@ namespace Google.Protobuf.TestProtos { int dataSize = 0; dataSize = 4 * repeatedFixed32_.Count; size += dataSize; - size += 1 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + size += 1 + pb::CodedOutputStream.ComputeInt32Size(dataSize); } if (repeatedInt32_.Count > 0) { int dataSize = 0; foreach (int element in repeatedInt32_) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); + dataSize += pb::CodedOutputStream.ComputeInt32Size(element); } size += dataSize; - size += 1 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + size += 1 + pb::CodedOutputStream.ComputeInt32Size(dataSize); } if (repeatedFixed64_.Count > 0) { int dataSize = 0; dataSize = 8 * repeatedFixed64_.Count; size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); } if (repeatedInt64_.Count > 0) { int dataSize = 0; foreach (long element in repeatedInt64_) { - dataSize += pb::CodedOutputStream.ComputeInt64SizeNoTag(element); + dataSize += pb::CodedOutputStream.ComputeInt64Size(element); } size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); } if (repeatedFloat_.Count > 0) { int dataSize = 0; dataSize = 4 * repeatedFloat_.Count; size += dataSize; - size += 3 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + size += 3 + pb::CodedOutputStream.ComputeInt32Size(dataSize); } if (repeatedUint64_.Count > 0) { int dataSize = 0; foreach (ulong element in repeatedUint64_) { - dataSize += pb::CodedOutputStream.ComputeUInt64SizeNoTag(element); + dataSize += pb::CodedOutputStream.ComputeUInt64Size(element); } size += dataSize; - size += 3 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + size += 3 + pb::CodedOutputStream.ComputeInt32Size(dataSize); } return size; } @@ -5362,14 +5462,15 @@ namespace Google.Protobuf.TestProtos { public void WriteTo(pb::CodedOutputStream output) { if (A.Length != 0) { - output.WriteString(1, A); + output.WriteRawTag(10); + output.WriteString(A); } } public int CalculateSize() { int size = 0; if (A.Length != 0) { - size += pb::CodedOutputStream.ComputeStringSize(1, A); + size += 1 + pb::CodedOutputStream.ComputeStringSize(A); } return size; } diff --git a/csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs b/csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs index aba5a1a2..e3d2b068 100644 --- a/csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs +++ b/csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs @@ -47,193 +47,13 @@ namespace Google.Protobuf public sealed partial class CodedOutputStream { private const int LittleEndian64Size = 8; - private const int LittleEndian32Size = 4; + private const int LittleEndian32Size = 4; /// /// Compute the number of bytes that would be needed to encode a /// double field, including the tag. /// - public static int ComputeDoubleSize(int fieldNumber, double value) - { - return ComputeTagSize(fieldNumber) + LittleEndian64Size; - } - - /// - /// Compute the number of bytes that would be needed to encode a - /// float field, including the tag. - /// - public static int ComputeFloatSize(int fieldNumber, float value) - { - return ComputeTagSize(fieldNumber) + LittleEndian32Size; - } - - /// - /// Compute the number of bytes that would be needed to encode a - /// uint64 field, including the tag. - /// - public static int ComputeUInt64Size(int fieldNumber, ulong value) - { - return ComputeTagSize(fieldNumber) + ComputeRawVarint64Size(value); - } - - /// - /// Compute the number of bytes that would be needed to encode an - /// int64 field, including the tag. - /// - public static int ComputeInt64Size(int fieldNumber, long value) - { - return ComputeTagSize(fieldNumber) + ComputeRawVarint64Size((ulong) value); - } - - /// - /// Compute the number of bytes that would be needed to encode an - /// int32 field, including the tag. - /// - public static int ComputeInt32Size(int fieldNumber, int value) - { - return ComputeTagSize(fieldNumber) + ComputeInt32SizeNoTag(value); - } - - /// - /// Compute the number of bytes that would be needed to encode a - /// fixed64 field, including the tag. - /// - public static int ComputeFixed64Size(int fieldNumber, ulong value) - { - return ComputeTagSize(fieldNumber) + LittleEndian64Size; - } - - /// - /// Compute the number of bytes that would be needed to encode a - /// fixed32 field, including the tag. - /// - public static int ComputeFixed32Size(int fieldNumber, uint value) - { - return ComputeTagSize(fieldNumber) + LittleEndian32Size; - } - - /// - /// Compute the number of bytes that would be needed to encode a - /// bool field, including the tag. - /// - public static int ComputeBoolSize(int fieldNumber, bool value) - { - return ComputeTagSize(fieldNumber) + 1; - } - - /// - /// Compute the number of bytes that would be needed to encode a - /// string field, including the tag. - /// - public static int ComputeStringSize(int fieldNumber, String value) - { - int byteArraySize = UTF8.GetByteCount(value); - return ComputeTagSize(fieldNumber) + - ComputeRawVarint32Size((uint) byteArraySize) + - byteArraySize; - } - - /// - /// Compute the number of bytes that would be needed to encode a - /// group field, including the tag. - /// - public static int ComputeGroupSize(int fieldNumber, IMessage value) - { - return ComputeTagSize(fieldNumber)*2 + value.CalculateSize(); - } - - /// - /// Compute the number of bytes that would be needed to encode a - /// group field represented by an UnknownFieldSet, including the tag. - /// - [Obsolete] - public static int ComputeUnknownGroupSize(int fieldNumber, - IMessage value) - { - return ComputeTagSize(fieldNumber)*2 + value.CalculateSize(); - } - - /// - /// Compute the number of bytes that would be needed to encode an - /// embedded message field, including the tag. - /// - public static int ComputeMessageSize(int fieldNumber, IMessage value) - { - int size = value.CalculateSize(); - return ComputeTagSize(fieldNumber) + ComputeRawVarint32Size((uint) size) + size; - } - - /// - /// Compute the number of bytes that would be needed to encode a - /// bytes field, including the tag. - /// - public static int ComputeBytesSize(int fieldNumber, ByteString value) - { - return ComputeTagSize(fieldNumber) + - ComputeRawVarint32Size((uint) value.Length) + - value.Length; - } - - /// - /// Compute the number of bytes that would be needed to encode a - /// uint32 field, including the tag. - /// - public static int ComputeUInt32Size(int fieldNumber, uint value) - { - return ComputeTagSize(fieldNumber) + ComputeRawVarint32Size(value); - } - - /// - /// Compute the number of bytes that would be needed to encode a - /// enum field, including the tag. The caller is responsible for - /// converting the enum value to its numeric value. - /// - public static int ComputeEnumSize(int fieldNumber, int value) - { - return ComputeTagSize(fieldNumber) + ComputeEnumSizeNoTag(value); - } - - /// - /// Compute the number of bytes that would be needed to encode an - /// sfixed32 field, including the tag. - /// - public static int ComputeSFixed32Size(int fieldNumber, int value) - { - return ComputeTagSize(fieldNumber) + LittleEndian32Size; - } - - /// - /// Compute the number of bytes that would be needed to encode an - /// sfixed64 field, including the tag. - /// - public static int ComputeSFixed64Size(int fieldNumber, long value) - { - return ComputeTagSize(fieldNumber) + LittleEndian64Size; - } - - /// - /// Compute the number of bytes that would be needed to encode an - /// sint32 field, including the tag. - /// - public static int ComputeSInt32Size(int fieldNumber, int value) - { - return ComputeTagSize(fieldNumber) + ComputeRawVarint32Size(EncodeZigZag32(value)); - } - - /// - /// Compute the number of bytes that would be needed to encode an - /// sint64 field, including the tag. - /// - public static int ComputeSInt64Size(int fieldNumber, long value) - { - return ComputeTagSize(fieldNumber) + ComputeRawVarint64Size(EncodeZigZag64(value)); - } - - /// - /// Compute the number of bytes that would be needed to encode a - /// double field, including the tag. - /// - public static int ComputeDoubleSizeNoTag(double value) + public static int ComputeDoubleSize(double value) { return LittleEndian64Size; } @@ -242,7 +62,7 @@ namespace Google.Protobuf /// Compute the number of bytes that would be needed to encode a /// float field, including the tag. /// - public static int ComputeFloatSizeNoTag(float value) + public static int ComputeFloatSize(float value) { return LittleEndian32Size; } @@ -251,7 +71,7 @@ namespace Google.Protobuf /// Compute the number of bytes that would be needed to encode a /// uint64 field, including the tag. /// - public static int ComputeUInt64SizeNoTag(ulong value) + public static int ComputeUInt64Size(ulong value) { return ComputeRawVarint64Size(value); } @@ -260,7 +80,7 @@ namespace Google.Protobuf /// Compute the number of bytes that would be needed to encode an /// int64 field, including the tag. /// - public static int ComputeInt64SizeNoTag(long value) + public static int ComputeInt64Size(long value) { return ComputeRawVarint64Size((ulong) value); } @@ -269,7 +89,7 @@ namespace Google.Protobuf /// Compute the number of bytes that would be needed to encode an /// int32 field, including the tag. /// - public static int ComputeInt32SizeNoTag(int value) + public static int ComputeInt32Size(int value) { if (value >= 0) { @@ -286,7 +106,7 @@ namespace Google.Protobuf /// Compute the number of bytes that would be needed to encode a /// fixed64 field, including the tag. /// - public static int ComputeFixed64SizeNoTag(ulong value) + public static int ComputeFixed64Size(ulong value) { return LittleEndian64Size; } @@ -295,7 +115,7 @@ namespace Google.Protobuf /// Compute the number of bytes that would be needed to encode a /// fixed32 field, including the tag. /// - public static int ComputeFixed32SizeNoTag(uint value) + public static int ComputeFixed32Size(uint value) { return LittleEndian32Size; } @@ -304,7 +124,7 @@ namespace Google.Protobuf /// Compute the number of bytes that would be needed to encode a /// bool field, including the tag. /// - public static int ComputeBoolSizeNoTag(bool value) + public static int ComputeBoolSize(bool value) { return 1; } @@ -313,7 +133,7 @@ namespace Google.Protobuf /// Compute the number of bytes that would be needed to encode a /// string field, including the tag. /// - public static int ComputeStringSizeNoTag(String value) + public static int ComputeStringSize(String value) { int byteArraySize = UTF8.GetByteCount(value); return ComputeRawVarint32Size((uint) byteArraySize) + @@ -324,7 +144,7 @@ namespace Google.Protobuf /// Compute the number of bytes that would be needed to encode a /// group field, including the tag. /// - public static int ComputeGroupSizeNoTag(IMessage value) + public static int ComputeGroupSize(IMessage value) { return value.CalculateSize(); } @@ -333,7 +153,7 @@ namespace Google.Protobuf /// Compute the number of bytes that would be needed to encode an /// embedded message field, including the tag. /// - public static int ComputeMessageSizeNoTag(IMessage value) + public static int ComputeMessageSize(IMessage value) { int size = value.CalculateSize(); return ComputeRawVarint32Size((uint) size) + size; @@ -343,7 +163,7 @@ namespace Google.Protobuf /// Compute the number of bytes that would be needed to encode a /// bytes field, including the tag. /// - public static int ComputeBytesSizeNoTag(ByteString value) + public static int ComputeBytesSize(ByteString value) { return ComputeRawVarint32Size((uint) value.Length) + value.Length; @@ -353,7 +173,7 @@ namespace Google.Protobuf /// Compute the number of bytes that would be needed to encode a /// uint32 field, including the tag. /// - public static int ComputeUInt32SizeNoTag(uint value) + public static int ComputeUInt32Size(uint value) { return ComputeRawVarint32Size(value); } @@ -363,17 +183,17 @@ namespace Google.Protobuf /// enum field, including the tag. The caller is responsible for /// converting the enum value to its numeric value. /// - public static int ComputeEnumSizeNoTag(int value) + public static int ComputeEnumSize(int value) { // Currently just a pass-through, but it's nice to separate it logically. - return ComputeInt32SizeNoTag(value); + return ComputeInt32Size(value); } /// /// Compute the number of bytes that would be needed to encode an /// sfixed32 field, including the tag. /// - public static int ComputeSFixed32SizeNoTag(int value) + public static int ComputeSFixed32Size(int value) { return LittleEndian32Size; } @@ -382,7 +202,7 @@ namespace Google.Protobuf /// Compute the number of bytes that would be needed to encode an /// sfixed64 field, including the tag. /// - public static int ComputeSFixed64SizeNoTag(long value) + public static int ComputeSFixed64Size(long value) { return LittleEndian64Size; } @@ -391,7 +211,7 @@ namespace Google.Protobuf /// Compute the number of bytes that would be needed to encode an /// sint32 field, including the tag. /// - public static int ComputeSInt32SizeNoTag(int value) + public static int ComputeSInt32Size(int value) { return ComputeRawVarint32Size(EncodeZigZag32(value)); } @@ -400,7 +220,7 @@ namespace Google.Protobuf /// Compute the number of bytes that would be needed to encode an /// sint64 field, including the tag. /// - public static int ComputeSInt64SizeNoTag(long value) + public static int ComputeSInt64Size(long value) { return ComputeRawVarint64Size(EncodeZigZag64(value)); } diff --git a/csharp/src/ProtocolBuffers/CodedOutputStream.cs b/csharp/src/ProtocolBuffers/CodedOutputStream.cs index bc3ed7d7..6c135e86 100644 --- a/csharp/src/ProtocolBuffers/CodedOutputStream.cs +++ b/csharp/src/ProtocolBuffers/CodedOutputStream.cs @@ -143,248 +143,12 @@ namespace Google.Protobuf } } - #region Writing of tags and fields - /// - /// Writes a double field value, including tag, to the stream. - /// - public void WriteDouble(int fieldNumber, double value) - { - WriteTag(fieldNumber, WireFormat.WireType.Fixed64); - WriteDoubleNoTag(value); - } - - /// - /// Writes a float field value, including tag, to the stream. - /// - public void WriteFloat(int fieldNumber, float value) - { - WriteTag(fieldNumber, WireFormat.WireType.Fixed32); - WriteFloatNoTag(value); - } - - /// - /// Writes a uint64 field value, including tag, to the stream. - /// - public void WriteUInt64(int fieldNumber, ulong value) - { - WriteTag(fieldNumber, WireFormat.WireType.Varint); - WriteRawVarint64(value); - } - - /// - /// Writes an int64 field value, including tag, to the stream. - /// - public void WriteInt64(int fieldNumber, long value) - { - WriteTag(fieldNumber, WireFormat.WireType.Varint); - WriteRawVarint64((ulong) value); - } - - /// - /// Writes an int32 field value, including tag, to the stream. - /// - public void WriteInt32(int fieldNumber, int value) - { - WriteTag(fieldNumber, WireFormat.WireType.Varint); - if (value >= 0) - { - WriteRawVarint32((uint) value); - } - else - { - // Must sign-extend. - WriteRawVarint64((ulong) value); - } - } - - /// - /// Writes a fixed64 field value, including tag, to the stream. - /// - public void WriteFixed64(int fieldNumber, ulong value) - { - WriteTag(fieldNumber, WireFormat.WireType.Fixed64); - WriteRawLittleEndian64(value); - } - - /// - /// Writes a fixed32 field value, including tag, to the stream. - /// - public void WriteFixed32(int fieldNumber, uint value) - { - WriteTag(fieldNumber, WireFormat.WireType.Fixed32); - WriteRawLittleEndian32(value); - } - - /// - /// Writes a bool field value, including tag, to the stream. - /// - public void WriteBool(int fieldNumber, bool value) - { - WriteTag(fieldNumber, WireFormat.WireType.Varint); - WriteRawByte(value ? (byte) 1 : (byte) 0); - } - - /// - /// Writes a string field value, including tag, to the stream. - /// - public void WriteString(int fieldNumber, string value) - { - WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited); - // Optimise the case where we have enough space to write - // the string directly to the buffer, which should be common. - int length = UTF8.GetByteCount(value); - WriteRawVarint32((uint) length); - if (limit - position >= length) - { - if (length == value.Length) // Must be all ASCII... - { - for (int i = 0; i < length; i++) - { - buffer[position + i] = (byte)value[i]; - } - } - else - { - UTF8.GetBytes(value, 0, value.Length, buffer, position); - } - position += length; - } - else - { - byte[] bytes = UTF8.GetBytes(value); - WriteRawBytes(bytes); - } - } - - /// - /// Writes a group field value, including tag, to the stream. - /// - public void WriteGroup(int fieldNumber, IMessage value) - { - WriteTag(fieldNumber, WireFormat.WireType.StartGroup); - value.WriteTo(this); - WriteTag(fieldNumber, WireFormat.WireType.EndGroup); - } - - public void WriteMessage(int fieldNumber, IMessage value) - { - WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited); - WriteRawVarint32((uint) value.CalculateSize()); - value.WriteTo(this); - } - - public void WriteBytes(int fieldNumber, ByteString value) - { - WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited); - WriteRawVarint32((uint) value.Length); - value.WriteRawBytesTo(this); - } - - public void WriteUInt32(int fieldNumber, uint value) - { - WriteTag(fieldNumber, WireFormat.WireType.Varint); - WriteRawVarint32(value); - } - - public void WriteEnum(int fieldNumber, int value) - { - // Currently just a pass-through, but it's nice to separate it logically from WriteInt32. - WriteTag(fieldNumber, WireFormat.WireType.Varint); - WriteInt32NoTag(value); - } - - public void WriteSFixed32(int fieldNumber, int value) - { - WriteTag(fieldNumber, WireFormat.WireType.Fixed32); - WriteRawLittleEndian32((uint) value); - } - - public void WriteSFixed64(int fieldNumber, long value) - { - WriteTag(fieldNumber, WireFormat.WireType.Fixed64); - WriteRawLittleEndian64((ulong) value); - } - - public void WriteSInt32(int fieldNumber, int value) - { - WriteTag(fieldNumber, WireFormat.WireType.Varint); - WriteRawVarint32(EncodeZigZag32(value)); - } - - public void WriteSInt64(int fieldNumber, long value) - { - WriteTag(fieldNumber, WireFormat.WireType.Varint); - WriteRawVarint64(EncodeZigZag64(value)); - } - #endregion - #region Writing of values without tags - // TODO(jonskeet): Remove this? - public void WriteFieldNoTag(FieldType fieldType, object value) - { - switch (fieldType) - { - case FieldType.String: - WriteStringNoTag((string) value); - break; - case FieldType.Message: - WriteMessageNoTag((IMessage) value); - break; - case FieldType.Group: - WriteGroupNoTag((IMessage) value); - break; - case FieldType.Bytes: - WriteBytesNoTag((ByteString) value); - break; - case FieldType.Bool: - WriteBoolNoTag((bool) value); - break; - case FieldType.Enum: - WriteEnumNoTag((int) value); - break; - case FieldType.Int32: - WriteInt32NoTag((int) value); - break; - case FieldType.Int64: - WriteInt64NoTag((long) value); - break; - case FieldType.UInt32: - WriteUInt32NoTag((uint) value); - break; - case FieldType.UInt64: - WriteUInt64NoTag((ulong) value); - break; - case FieldType.SInt32: - WriteSInt32NoTag((int) value); - break; - case FieldType.SInt64: - WriteSInt64NoTag((long) value); - break; - case FieldType.Fixed32: - WriteFixed32NoTag((uint) value); - break; - case FieldType.Fixed64: - WriteFixed64NoTag((ulong) value); - break; - case FieldType.SFixed32: - WriteSFixed32NoTag((int) value); - break; - case FieldType.SFixed64: - WriteSFixed64NoTag((long) value); - break; - case FieldType.Double: - WriteDoubleNoTag((double) value); - break; - case FieldType.Float: - WriteFloatNoTag((float) value); - break; - } - } /// /// Writes a double field value, including tag, to the stream. /// - public void WriteDoubleNoTag(double value) + public void WriteDouble(double value) { WriteRawLittleEndian64((ulong)FrameworkPortability.DoubleToInt64(value)); } @@ -392,7 +156,7 @@ namespace Google.Protobuf /// /// Writes a float field value, without a tag, to the stream. /// - public void WriteFloatNoTag(float value) + public void WriteFloat(float value) { byte[] rawBytes = BitConverter.GetBytes(value); if (!BitConverter.IsLittleEndian) @@ -416,7 +180,7 @@ namespace Google.Protobuf /// /// Writes a uint64 field value, without a tag, to the stream. /// - public void WriteUInt64NoTag(ulong value) + public void WriteUInt64(ulong value) { WriteRawVarint64(value); } @@ -424,7 +188,7 @@ namespace Google.Protobuf /// /// Writes an int64 field value, without a tag, to the stream. /// - public void WriteInt64NoTag(long value) + public void WriteInt64(long value) { WriteRawVarint64((ulong) value); } @@ -432,7 +196,7 @@ namespace Google.Protobuf /// /// Writes an int32 field value, without a tag, to the stream. /// - public void WriteInt32NoTag(int value) + public void WriteInt32(int value) { if (value >= 0) { @@ -448,7 +212,7 @@ namespace Google.Protobuf /// /// Writes a fixed64 field value, without a tag, to the stream. /// - public void WriteFixed64NoTag(ulong value) + public void WriteFixed64(ulong value) { WriteRawLittleEndian64(value); } @@ -456,7 +220,7 @@ namespace Google.Protobuf /// /// Writes a fixed32 field value, without a tag, to the stream. /// - public void WriteFixed32NoTag(uint value) + public void WriteFixed32(uint value) { WriteRawLittleEndian32(value); } @@ -464,7 +228,7 @@ namespace Google.Protobuf /// /// Writes a bool field value, without a tag, to the stream. /// - public void WriteBoolNoTag(bool value) + public void WriteBool(bool value) { WriteRawByte(value ? (byte) 1 : (byte) 0); } @@ -472,485 +236,440 @@ namespace Google.Protobuf /// /// Writes a string field value, without a tag, to the stream. /// - public void WriteStringNoTag(string value) + public void WriteString(string value) { // Optimise the case where we have enough space to write // the string directly to the buffer, which should be common. - int length = Encoding.UTF8.GetByteCount(value); - WriteRawVarint32((uint) length); + int length = UTF8.GetByteCount(value); + WriteRawVarint32((uint)length); if (limit - position >= length) { - Encoding.UTF8.GetBytes(value, 0, value.Length, buffer, position); + if (length == value.Length) // Must be all ASCII... + { + for (int i = 0; i < length; i++) + { + buffer[position + i] = (byte)value[i]; + } + } + else + { + UTF8.GetBytes(value, 0, value.Length, buffer, position); + } position += length; } else { - byte[] bytes = Encoding.UTF8.GetBytes(value); + byte[] bytes = UTF8.GetBytes(value); WriteRawBytes(bytes); } } - /// - /// Writes a group field value, without a tag, to the stream. - /// - public void WriteGroupNoTag(IMessage value) - { - value.WriteTo(this); - } - - public void WriteMessageNoTag(IMessage value) + public void WriteMessage(IMessage value) { WriteRawVarint32((uint) value.CalculateSize()); value.WriteTo(this); } - public void WriteBytesNoTag(ByteString value) + public void WriteBytes(ByteString value) { WriteRawVarint32((uint) value.Length); value.WriteRawBytesTo(this); } - public void WriteUInt32NoTag(uint value) + public void WriteUInt32(uint value) { WriteRawVarint32(value); } - public void WriteEnumNoTag(int value) + public void WriteEnum(int value) { - WriteInt32NoTag(value); + WriteInt32(value); } - public void WriteSFixed32NoTag(int value) + public void WriteSFixed32(int value) { WriteRawLittleEndian32((uint) value); } - public void WriteSFixed64NoTag(long value) + public void WriteSFixed64(long value) { WriteRawLittleEndian64((ulong) value); } - public void WriteSInt32NoTag(int value) + public void WriteSInt32(int value) { WriteRawVarint32(EncodeZigZag32(value)); } - public void WriteSInt64NoTag(long value) + public void WriteSInt64(long value) { WriteRawVarint64(EncodeZigZag64(value)); } #endregion - #region Write array members + #region Write array members, with fields. public void WriteMessageArray(int fieldNumber, RepeatedField list) where T : IMessage { - if (list.Count == 0) - { - return; - } foreach (T value in list) { - WriteMessage(fieldNumber, value); + WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited); + WriteMessage(value); } } public void WriteStringArray(int fieldNumber, RepeatedField list) { - if (list.Count == 0) - { - return; - } foreach (var value in list) { - WriteString(fieldNumber, value); + WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited); + WriteString(value); } } public void WriteBytesArray(int fieldNumber, RepeatedField list) { - if (list.Count == 0) - { - return; - } foreach (var value in list) { - WriteBytes(fieldNumber, value); + WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited); + WriteBytes(value); } } public void WriteBoolArray(int fieldNumber, RepeatedField list) { - if (list.Count == 0) - { - return; - } foreach (var value in list) { - WriteBool(fieldNumber, value); + WriteTag(fieldNumber, WireFormat.WireType.Varint); + WriteBool(value); } } public void WriteInt32Array(int fieldNumber, RepeatedField list) { - if (list.Count == 0) - { - return; - } foreach (var value in list) { - WriteInt32(fieldNumber, value); + WriteTag(fieldNumber, WireFormat.WireType.Varint); + WriteInt32(value); } } public void WriteSInt32Array(int fieldNumber, RepeatedField list) { - if (list.Count == 0) - { - return; - } foreach (var value in list) { - WriteSInt32(fieldNumber, value); + WriteTag(fieldNumber, WireFormat.WireType.Varint); + WriteSInt32(value); } } public void WriteUInt32Array(int fieldNumber, RepeatedField list) { - if (list.Count == 0) - { - return; - } foreach (var value in list) { - WriteUInt32(fieldNumber, value); + WriteTag(fieldNumber, WireFormat.WireType.Varint); + WriteUInt32(value); } } public void WriteFixed32Array(int fieldNumber, RepeatedField list) { - if (list.Count == 0) - { - return; - } foreach (var value in list) { - WriteFixed32(fieldNumber, value); + WriteTag(fieldNumber, WireFormat.WireType.Fixed32); + WriteFixed32(value); } } public void WriteSFixed32Array(int fieldNumber, RepeatedField list) { - if (list.Count == 0) - { - return; - } foreach (var value in list) { - WriteSFixed32(fieldNumber, value); + WriteTag(fieldNumber, WireFormat.WireType.Fixed32); + WriteSFixed32(value); } } public void WriteInt64Array(int fieldNumber, RepeatedField list) { - if (list.Count == 0) - { - return; - } foreach (var value in list) { - WriteInt64(fieldNumber, value); + WriteTag(fieldNumber, WireFormat.WireType.Fixed64); + WriteInt64(value); } } public void WriteSInt64Array(int fieldNumber, RepeatedField list) { - if (list.Count == 0) - { - return; - } foreach (var value in list) { - WriteSInt64(fieldNumber, value); + WriteTag(fieldNumber, WireFormat.WireType.Varint); + WriteSInt64(value); } } public void WriteUInt64Array(int fieldNumber, RepeatedField list) { - if (list.Count == 0) - { - return; - } foreach (var value in list) { - WriteUInt64(fieldNumber, value); + WriteTag(fieldNumber, WireFormat.WireType.Varint); + WriteUInt64(value); } } public void WriteFixed64Array(int fieldNumber, RepeatedField list) { - if (list.Count == 0) - { - return; - } foreach (var value in list) { - WriteFixed64(fieldNumber, value); + WriteTag(fieldNumber, WireFormat.WireType.Fixed64); + WriteFixed64(value); } } public void WriteSFixed64Array(int fieldNumber, RepeatedField list) { - if (list.Count == 0) - { - return; - } foreach (var value in list) { - WriteSFixed64(fieldNumber, value); + WriteTag(fieldNumber, WireFormat.WireType.Fixed64); + WriteSFixed64(value); } } public void WriteDoubleArray(int fieldNumber, RepeatedField list) { - if (list.Count == 0) - { - return; - } foreach (var value in list) { - WriteDouble(fieldNumber, value); + WriteTag(fieldNumber, WireFormat.WireType.Fixed64); + WriteDouble(value); } } public void WriteFloatArray(int fieldNumber, RepeatedField list) { - if (list.Count == 0) - { - return; - } foreach (var value in list) { - WriteFloat(fieldNumber, value); + WriteTag(fieldNumber, WireFormat.WireType.Fixed32); + WriteFloat(value); } } public void WriteEnumArray(int fieldNumber, RepeatedField list) where T : struct, IComparable, IFormattable { - if (list.Count == 0) - { - return; - } // Bit of a hack, to access the values as ints var iterator = list.GetInt32Enumerator(); while (iterator.MoveNext()) { - WriteEnum(fieldNumber, iterator.Current); + WriteTag(fieldNumber, WireFormat.WireType.Varint); + WriteEnum(iterator.Current); } } #endregion + #region Raw tag writing + /// + /// Encodes and writes a tag. + /// + public void WriteTag(int fieldNumber, WireFormat.WireType type) + { + WriteRawVarint32(WireFormat.MakeTag(fieldNumber, type)); + } + + /// + /// Writes the given single-byte tag directly to the stream. + /// + public void WriteRawTag(byte b1) + { + WriteRawByte(b1); + } + + /// + /// Writes the given two-byte tag directly to the stream. + /// + public void WriteRawTag(byte b1, byte b2) + { + WriteRawByte(b1); + WriteRawByte(b2); + } + + /// + /// Writes the given three-byte tag directly to the stream. + /// + public void WriteRawTag(byte b1, byte b2, byte b3) + { + WriteRawByte(b1); + WriteRawByte(b2); + WriteRawByte(b3); + } + + /// + /// Writes the given four-byte tag directly to the stream. + /// + public void WriteRawTag(byte b1, byte b2, byte b3, byte b4) + { + WriteRawByte(b1); + WriteRawByte(b2); + WriteRawByte(b3); + WriteRawByte(b4); + } + + /// + /// Writes the given five-byte tag directly to the stream. + /// + public void WriteRawTag(byte b1, byte b2, byte b3, byte b4, byte b5) + { + WriteRawByte(b1); + WriteRawByte(b2); + WriteRawByte(b3); + WriteRawByte(b4); + WriteRawByte(b5); + } + #endregion + #region Write packed array members // TODO(jonskeet): A lot of these are really inefficient, due to method group conversions. Fix! - public void WritePackedBoolArray(int fieldNumber, RepeatedField list) + // (Alternatively, add extension methods to RepeatedField, accepting the Write* methods via delegates too.) + public void WritePackedBoolArray(RepeatedField list) { - if (list.Count == 0) - { - return; - } uint size = (uint)list.Count; - WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited); WriteRawVarint32(size); foreach (var value in list) { - WriteBoolNoTag(value); + WriteBool(value); } } - public void WritePackedInt32Array(int fieldNumber, RepeatedField list) + public void WritePackedInt32Array(RepeatedField list) { - if (list.Count == 0) - { - return; - } - uint size = list.CalculateSize(ComputeInt32SizeNoTag); - WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited); + uint size = list.CalculateSize(ComputeInt32Size); WriteRawVarint32(size); foreach (var value in list) { - WriteInt32NoTag(value); + WriteInt32(value); } } - public void WritePackedSInt32Array(int fieldNumber, RepeatedField list) + public void WritePackedSInt32Array(RepeatedField list) { - if (list.Count == 0) - { - return; - } - uint size = list.CalculateSize(ComputeSInt32SizeNoTag); - WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited); + uint size = list.CalculateSize(ComputeSInt32Size); WriteRawVarint32(size); foreach (var value in list) { - WriteSInt32NoTag(value); + WriteSInt32(value); } } - public void WritePackedUInt32Array(int fieldNumber, RepeatedField list) + public void WritePackedUInt32Array(RepeatedField list) { - if (list.Count == 0) - { - return; - } - uint size = list.CalculateSize(ComputeUInt32SizeNoTag); - WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited); + uint size = list.CalculateSize(ComputeUInt32Size); WriteRawVarint32(size); foreach (var value in list) { - WriteUInt32NoTag(value); + WriteUInt32(value); } } - public void WritePackedFixed32Array(int fieldNumber, RepeatedField list) + public void WritePackedFixed32Array(RepeatedField list) { - if (list.Count == 0) - { - return; - } uint size = (uint) list.Count * 4; - WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited); WriteRawVarint32(size); foreach (var value in list) { - WriteFixed32NoTag(value); + WriteFixed32(value); } } - public void WritePackedSFixed32Array(int fieldNumber, RepeatedField list) + public void WritePackedSFixed32Array(RepeatedField list) { - if (list.Count == 0) - { - return; - } uint size = (uint) list.Count * 4; - WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited); WriteRawVarint32(size); foreach (var value in list) { - WriteSFixed32NoTag(value); + WriteSFixed32(value); } } - public void WritePackedInt64Array(int fieldNumber, RepeatedField list) + public void WritePackedInt64Array(RepeatedField list) { - if (list.Count == 0) - { - return; - } - uint size = list.CalculateSize(ComputeInt64SizeNoTag); - WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited); + uint size = list.CalculateSize(ComputeInt64Size); WriteRawVarint32(size); foreach (var value in list) { - WriteInt64NoTag(value); + WriteInt64(value); } } - public void WritePackedSInt64Array(int fieldNumber, RepeatedField list) + public void WritePackedSInt64Array(RepeatedField list) { - if (list.Count == 0) - { - return; - } - uint size = list.CalculateSize(ComputeSInt64SizeNoTag); - WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited); + uint size = list.CalculateSize(ComputeSInt64Size); WriteRawVarint32(size); foreach (var value in list) { - WriteSInt64NoTag(value); + WriteSInt64(value); } } - public void WritePackedUInt64Array(int fieldNumber, RepeatedField list) + public void WritePackedUInt64Array(RepeatedField list) { if (list.Count == 0) { return; } - uint size = list.CalculateSize(ComputeUInt64SizeNoTag); - WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited); + uint size = list.CalculateSize(ComputeUInt64Size); WriteRawVarint32(size); foreach (var value in list) { - WriteUInt64NoTag(value); + WriteUInt64(value); } } - public void WritePackedFixed64Array(int fieldNumber, RepeatedField list) + public void WritePackedFixed64Array(RepeatedField list) { - if (list.Count == 0) - { - return; - } uint size = (uint) list.Count * 8; - WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited); WriteRawVarint32(size); foreach (var value in list) { - WriteFixed64NoTag(value); + WriteFixed64(value); } } - public void WritePackedSFixed64Array(int fieldNumber, RepeatedField list) + public void WritePackedSFixed64Array(RepeatedField list) { - if (list.Count == 0) - { - return; - } uint size = (uint) list.Count * 8; - WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited); WriteRawVarint32(size); foreach (var value in list) { - WriteSFixed64NoTag(value); + WriteSFixed64(value); } } - public void WritePackedDoubleArray(int fieldNumber, RepeatedField list) + public void WritePackedDoubleArray(RepeatedField list) { - if (list.Count == 0) - { - return; - } uint size = (uint) list.Count * 8; - WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited); WriteRawVarint32(size); foreach (var value in list) { - WriteDoubleNoTag(value); + WriteDouble(value); } } - public void WritePackedFloatArray(int fieldNumber, RepeatedField list) + public void WritePackedFloatArray(RepeatedField list) { if (list.Count == 0) { return; } uint size = (uint) list.Count * 4; - WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited); WriteRawVarint32(size); foreach (var value in list) { - WriteFloatNoTag(value); + WriteFloat(value); } } - public void WritePackedEnumArray(int fieldNumber, RepeatedField list) + public void WritePackedEnumArray(RepeatedField list) where T : struct, IComparable, IFormattable { if (list.Count == 0) @@ -962,29 +681,19 @@ namespace Google.Protobuf uint size = 0; while (iterator.MoveNext()) { - size += (uint) ComputeEnumSizeNoTag(iterator.Current); + size += (uint) ComputeEnumSize(iterator.Current); } iterator.Reset(); - WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited); WriteRawVarint32(size); while (iterator.MoveNext()) { - WriteEnumNoTag(iterator.Current); + WriteEnum(iterator.Current); } } #endregion #region Underlying writing primitives - - /// - /// Encodes and writes a tag. - /// - public void WriteTag(int fieldNumber, WireFormat.WireType type) - { - WriteRawVarint32(WireFormat.MakeTag(fieldNumber, type)); - } - /// /// Writes a 32 bit value as a varint. The fast route is taken when /// there's enough buffer space left to whizz through without checking diff --git a/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs b/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs index 9a10d6ae..44e6e2e9 100644 --- a/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs +++ b/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs @@ -333,8 +333,9 @@ namespace Google.Protobuf.DescriptorProtos { int size = 0; if (file_.Count > 0) { foreach (global::Google.Protobuf.DescriptorProtos.FileDescriptorProto element in file_) { - size += pb::CodedOutputStream.ComputeMessageSize(1, element); + size += pb::CodedOutputStream.ComputeMessageSize(element); } + size += 1 * file_.Count; } return size; } @@ -508,10 +509,12 @@ namespace Google.Protobuf.DescriptorProtos { public void WriteTo(pb::CodedOutputStream output) { if (Name.Length != 0) { - output.WriteString(1, Name); + output.WriteRawTag(10); + output.WriteString(Name); } if (Package.Length != 0) { - output.WriteString(2, Package); + output.WriteRawTag(18); + output.WriteString(Package); } if (dependency_.Count > 0) { output.WriteStringArray(3, dependency_); @@ -529,10 +532,12 @@ namespace Google.Protobuf.DescriptorProtos { output.WriteMessageArray(7, extension_); } if (options_ != null) { - output.WriteMessage(8, Options); + output.WriteRawTag(66); + output.WriteMessage(Options); } if (sourceCodeInfo_ != null) { - output.WriteMessage(9, SourceCodeInfo); + output.WriteRawTag(74); + output.WriteMessage(SourceCodeInfo); } if (publicDependency_.Count > 0) { output.WriteInt32Array(10, publicDependency_); @@ -541,22 +546,23 @@ namespace Google.Protobuf.DescriptorProtos { output.WriteInt32Array(11, weakDependency_); } if (Syntax.Length != 0) { - output.WriteString(12, Syntax); + output.WriteRawTag(98); + output.WriteString(Syntax); } } public int CalculateSize() { int size = 0; if (Name.Length != 0) { - size += pb::CodedOutputStream.ComputeStringSize(1, Name); + size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); } if (Package.Length != 0) { - size += pb::CodedOutputStream.ComputeStringSize(2, Package); + size += 1 + pb::CodedOutputStream.ComputeStringSize(Package); } if (dependency_.Count > 0) { int dataSize = 0; foreach (string element in dependency_) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); + dataSize += pb::CodedOutputStream.ComputeStringSize(element); } size += dataSize; size += 1 * dependency_.Count; @@ -564,7 +570,7 @@ namespace Google.Protobuf.DescriptorProtos { if (publicDependency_.Count > 0) { int dataSize = 0; foreach (int element in publicDependency_) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); + dataSize += pb::CodedOutputStream.ComputeInt32Size(element); } size += dataSize; size += 1 * publicDependency_.Count; @@ -572,39 +578,43 @@ namespace Google.Protobuf.DescriptorProtos { if (weakDependency_.Count > 0) { int dataSize = 0; foreach (int element in weakDependency_) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); + dataSize += pb::CodedOutputStream.ComputeInt32Size(element); } size += dataSize; size += 1 * weakDependency_.Count; } if (messageType_.Count > 0) { foreach (global::Google.Protobuf.DescriptorProtos.DescriptorProto element in messageType_) { - size += pb::CodedOutputStream.ComputeMessageSize(4, element); + size += pb::CodedOutputStream.ComputeMessageSize(element); } + size += 1 * messageType_.Count; } if (enumType_.Count > 0) { foreach (global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto element in enumType_) { - size += pb::CodedOutputStream.ComputeMessageSize(5, element); + size += pb::CodedOutputStream.ComputeMessageSize(element); } + size += 1 * enumType_.Count; } if (service_.Count > 0) { foreach (global::Google.Protobuf.DescriptorProtos.ServiceDescriptorProto element in service_) { - size += pb::CodedOutputStream.ComputeMessageSize(6, element); + size += pb::CodedOutputStream.ComputeMessageSize(element); } + size += 1 * service_.Count; } if (extension_.Count > 0) { foreach (global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto element in extension_) { - size += pb::CodedOutputStream.ComputeMessageSize(7, element); + size += pb::CodedOutputStream.ComputeMessageSize(element); } + size += 1 * extension_.Count; } if (options_ != null) { - size += pb::CodedOutputStream.ComputeMessageSize(8, Options); + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Options); } if (sourceCodeInfo_ != null) { - size += pb::CodedOutputStream.ComputeMessageSize(9, SourceCodeInfo); + size += 1 + pb::CodedOutputStream.ComputeMessageSize(SourceCodeInfo); } if (Syntax.Length != 0) { - size += pb::CodedOutputStream.ComputeStringSize(12, Syntax); + size += 1 + pb::CodedOutputStream.ComputeStringSize(Syntax); } return size; } @@ -837,7 +847,8 @@ namespace Google.Protobuf.DescriptorProtos { public void WriteTo(pb::CodedOutputStream output) { if (Name.Length != 0) { - output.WriteString(1, Name); + output.WriteRawTag(10); + output.WriteString(Name); } if (field_.Count > 0) { output.WriteMessageArray(2, field_); @@ -855,7 +866,8 @@ namespace Google.Protobuf.DescriptorProtos { output.WriteMessageArray(6, extension_); } if (options_ != null) { - output.WriteMessage(7, Options); + output.WriteRawTag(58); + output.WriteMessage(Options); } if (oneofDecl_.Count > 0) { output.WriteMessageArray(8, oneofDecl_); @@ -871,50 +883,57 @@ namespace Google.Protobuf.DescriptorProtos { public int CalculateSize() { int size = 0; if (Name.Length != 0) { - size += pb::CodedOutputStream.ComputeStringSize(1, Name); + size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); } if (field_.Count > 0) { foreach (global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto element in field_) { - size += pb::CodedOutputStream.ComputeMessageSize(2, element); + size += pb::CodedOutputStream.ComputeMessageSize(element); } + size += 1 * field_.Count; } if (extension_.Count > 0) { foreach (global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto element in extension_) { - size += pb::CodedOutputStream.ComputeMessageSize(6, element); + size += pb::CodedOutputStream.ComputeMessageSize(element); } + size += 1 * extension_.Count; } if (nestedType_.Count > 0) { foreach (global::Google.Protobuf.DescriptorProtos.DescriptorProto element in nestedType_) { - size += pb::CodedOutputStream.ComputeMessageSize(3, element); + size += pb::CodedOutputStream.ComputeMessageSize(element); } + size += 1 * nestedType_.Count; } if (enumType_.Count > 0) { foreach (global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto element in enumType_) { - size += pb::CodedOutputStream.ComputeMessageSize(4, element); + size += pb::CodedOutputStream.ComputeMessageSize(element); } + size += 1 * enumType_.Count; } if (extensionRange_.Count > 0) { foreach (global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ExtensionRange element in extensionRange_) { - size += pb::CodedOutputStream.ComputeMessageSize(5, element); + size += pb::CodedOutputStream.ComputeMessageSize(element); } + size += 1 * extensionRange_.Count; } if (oneofDecl_.Count > 0) { foreach (global::Google.Protobuf.DescriptorProtos.OneofDescriptorProto element in oneofDecl_) { - size += pb::CodedOutputStream.ComputeMessageSize(8, element); + size += pb::CodedOutputStream.ComputeMessageSize(element); } + size += 1 * oneofDecl_.Count; } if (options_ != null) { - size += pb::CodedOutputStream.ComputeMessageSize(7, Options); + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Options); } if (reservedRange_.Count > 0) { foreach (global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ReservedRange element in reservedRange_) { - size += pb::CodedOutputStream.ComputeMessageSize(9, element); + size += pb::CodedOutputStream.ComputeMessageSize(element); } + size += 1 * reservedRange_.Count; } if (reservedName_.Count > 0) { int dataSize = 0; foreach (string element in reservedName_) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); + dataSize += pb::CodedOutputStream.ComputeStringSize(element); } size += dataSize; size += 1 * reservedName_.Count; @@ -1065,20 +1084,22 @@ namespace Google.Protobuf.DescriptorProtos { public void WriteTo(pb::CodedOutputStream output) { if (Start != 0) { - output.WriteInt32(1, Start); + output.WriteRawTag(8); + output.WriteInt32(Start); } if (End != 0) { - output.WriteInt32(2, End); + output.WriteRawTag(16); + output.WriteInt32(End); } } public int CalculateSize() { int size = 0; if (Start != 0) { - size += pb::CodedOutputStream.ComputeInt32Size(1, Start); + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Start); } if (End != 0) { - size += pb::CodedOutputStream.ComputeInt32Size(2, End); + size += 1 + pb::CodedOutputStream.ComputeInt32Size(End); } return size; } @@ -1179,20 +1200,22 @@ namespace Google.Protobuf.DescriptorProtos { public void WriteTo(pb::CodedOutputStream output) { if (Start != 0) { - output.WriteInt32(1, Start); + output.WriteRawTag(8); + output.WriteInt32(Start); } if (End != 0) { - output.WriteInt32(2, End); + output.WriteRawTag(16); + output.WriteInt32(End); } } public int CalculateSize() { int size = 0; if (Start != 0) { - size += pb::CodedOutputStream.ComputeInt32Size(1, Start); + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Start); } if (End != 0) { - size += pb::CodedOutputStream.ComputeInt32Size(2, End); + size += 1 + pb::CodedOutputStream.ComputeInt32Size(End); } return size; } @@ -1366,62 +1389,71 @@ namespace Google.Protobuf.DescriptorProtos { public void WriteTo(pb::CodedOutputStream output) { if (Name.Length != 0) { - output.WriteString(1, Name); + output.WriteRawTag(10); + output.WriteString(Name); } if (Extendee.Length != 0) { - output.WriteString(2, Extendee); + output.WriteRawTag(18); + output.WriteString(Extendee); } if (Number != 0) { - output.WriteInt32(3, Number); + output.WriteRawTag(24); + output.WriteInt32(Number); } if (Label != global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Label.LABEL_OPTIONAL) { - output.WriteEnum(4, (int) Label); + output.WriteRawTag(32); + output.WriteEnum((int) Label); } if (Type != global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Type.TYPE_DOUBLE) { - output.WriteEnum(5, (int) Type); + output.WriteRawTag(40); + output.WriteEnum((int) Type); } if (TypeName.Length != 0) { - output.WriteString(6, TypeName); + output.WriteRawTag(50); + output.WriteString(TypeName); } if (DefaultValue.Length != 0) { - output.WriteString(7, DefaultValue); + output.WriteRawTag(58); + output.WriteString(DefaultValue); } if (options_ != null) { - output.WriteMessage(8, Options); + output.WriteRawTag(66); + output.WriteMessage(Options); } if (OneofIndex != 0) { - output.WriteInt32(9, OneofIndex); + output.WriteRawTag(72); + output.WriteInt32(OneofIndex); } } public int CalculateSize() { int size = 0; if (Name.Length != 0) { - size += pb::CodedOutputStream.ComputeStringSize(1, Name); + size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); } if (Number != 0) { - size += pb::CodedOutputStream.ComputeInt32Size(3, Number); + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Number); } if (Label != global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Label.LABEL_OPTIONAL) { - size += pb::CodedOutputStream.ComputeEnumSize(4, (int) Label); + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Label); } if (Type != global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Type.TYPE_DOUBLE) { - size += pb::CodedOutputStream.ComputeEnumSize(5, (int) Type); + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Type); } if (TypeName.Length != 0) { - size += pb::CodedOutputStream.ComputeStringSize(6, TypeName); + size += 1 + pb::CodedOutputStream.ComputeStringSize(TypeName); } if (Extendee.Length != 0) { - size += pb::CodedOutputStream.ComputeStringSize(2, Extendee); + size += 1 + pb::CodedOutputStream.ComputeStringSize(Extendee); } if (DefaultValue.Length != 0) { - size += pb::CodedOutputStream.ComputeStringSize(7, DefaultValue); + size += 1 + pb::CodedOutputStream.ComputeStringSize(DefaultValue); } if (OneofIndex != 0) { - size += pb::CodedOutputStream.ComputeInt32Size(9, OneofIndex); + size += 1 + pb::CodedOutputStream.ComputeInt32Size(OneofIndex); } if (options_ != null) { - size += pb::CodedOutputStream.ComputeMessageSize(8, Options); + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Options); } return size; } @@ -1600,14 +1632,15 @@ namespace Google.Protobuf.DescriptorProtos { public void WriteTo(pb::CodedOutputStream output) { if (Name.Length != 0) { - output.WriteString(1, Name); + output.WriteRawTag(10); + output.WriteString(Name); } } public int CalculateSize() { int size = 0; if (Name.Length != 0) { - size += pb::CodedOutputStream.ComputeStringSize(1, Name); + size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); } return size; } @@ -1707,28 +1740,31 @@ namespace Google.Protobuf.DescriptorProtos { public void WriteTo(pb::CodedOutputStream output) { if (Name.Length != 0) { - output.WriteString(1, Name); + output.WriteRawTag(10); + output.WriteString(Name); } if (value_.Count > 0) { output.WriteMessageArray(2, value_); } if (options_ != null) { - output.WriteMessage(3, Options); + output.WriteRawTag(26); + output.WriteMessage(Options); } } public int CalculateSize() { int size = 0; if (Name.Length != 0) { - size += pb::CodedOutputStream.ComputeStringSize(1, Name); + size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); } if (value_.Count > 0) { foreach (global::Google.Protobuf.DescriptorProtos.EnumValueDescriptorProto element in value_) { - size += pb::CodedOutputStream.ComputeMessageSize(2, element); + size += pb::CodedOutputStream.ComputeMessageSize(element); } + size += 1 * value_.Count; } if (options_ != null) { - size += pb::CodedOutputStream.ComputeMessageSize(3, Options); + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Options); } return size; } @@ -1848,26 +1884,29 @@ namespace Google.Protobuf.DescriptorProtos { public void WriteTo(pb::CodedOutputStream output) { if (Name.Length != 0) { - output.WriteString(1, Name); + output.WriteRawTag(10); + output.WriteString(Name); } if (Number != 0) { - output.WriteInt32(2, Number); + output.WriteRawTag(16); + output.WriteInt32(Number); } if (options_ != null) { - output.WriteMessage(3, Options); + output.WriteRawTag(26); + output.WriteMessage(Options); } } public int CalculateSize() { int size = 0; if (Name.Length != 0) { - size += pb::CodedOutputStream.ComputeStringSize(1, Name); + size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); } if (Number != 0) { - size += pb::CodedOutputStream.ComputeInt32Size(2, Number); + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Number); } if (options_ != null) { - size += pb::CodedOutputStream.ComputeMessageSize(3, Options); + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Options); } return size; } @@ -1987,28 +2026,31 @@ namespace Google.Protobuf.DescriptorProtos { public void WriteTo(pb::CodedOutputStream output) { if (Name.Length != 0) { - output.WriteString(1, Name); + output.WriteRawTag(10); + output.WriteString(Name); } if (method_.Count > 0) { output.WriteMessageArray(2, method_); } if (options_ != null) { - output.WriteMessage(3, Options); + output.WriteRawTag(26); + output.WriteMessage(Options); } } public int CalculateSize() { int size = 0; if (Name.Length != 0) { - size += pb::CodedOutputStream.ComputeStringSize(1, Name); + size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); } if (method_.Count > 0) { foreach (global::Google.Protobuf.DescriptorProtos.MethodDescriptorProto element in method_) { - size += pb::CodedOutputStream.ComputeMessageSize(2, element); + size += pb::CodedOutputStream.ComputeMessageSize(element); } + size += 1 * method_.Count; } if (options_ != null) { - size += pb::CodedOutputStream.ComputeMessageSize(3, Options); + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Options); } return size; } @@ -2158,44 +2200,50 @@ namespace Google.Protobuf.DescriptorProtos { public void WriteTo(pb::CodedOutputStream output) { if (Name.Length != 0) { - output.WriteString(1, Name); + output.WriteRawTag(10); + output.WriteString(Name); } if (InputType.Length != 0) { - output.WriteString(2, InputType); + output.WriteRawTag(18); + output.WriteString(InputType); } if (OutputType.Length != 0) { - output.WriteString(3, OutputType); + output.WriteRawTag(26); + output.WriteString(OutputType); } if (options_ != null) { - output.WriteMessage(4, Options); + output.WriteRawTag(34); + output.WriteMessage(Options); } if (ClientStreaming != false) { - output.WriteBool(5, ClientStreaming); + output.WriteRawTag(40); + output.WriteBool(ClientStreaming); } if (ServerStreaming != false) { - output.WriteBool(6, ServerStreaming); + output.WriteRawTag(48); + output.WriteBool(ServerStreaming); } } public int CalculateSize() { int size = 0; if (Name.Length != 0) { - size += pb::CodedOutputStream.ComputeStringSize(1, Name); + size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); } if (InputType.Length != 0) { - size += pb::CodedOutputStream.ComputeStringSize(2, InputType); + size += 1 + pb::CodedOutputStream.ComputeStringSize(InputType); } if (OutputType.Length != 0) { - size += pb::CodedOutputStream.ComputeStringSize(3, OutputType); + size += 1 + pb::CodedOutputStream.ComputeStringSize(OutputType); } if (options_ != null) { - size += pb::CodedOutputStream.ComputeMessageSize(4, Options); + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Options); } if (ClientStreaming != false) { - size += pb::CodedOutputStream.ComputeBoolSize(5, ClientStreaming); + size += 1 + 1; } if (ServerStreaming != false) { - size += pb::CodedOutputStream.ComputeBoolSize(6, ServerStreaming); + size += 1 + 1; } return size; } @@ -2458,46 +2506,60 @@ namespace Google.Protobuf.DescriptorProtos { public void WriteTo(pb::CodedOutputStream output) { if (JavaPackage.Length != 0) { - output.WriteString(1, JavaPackage); + output.WriteRawTag(10); + output.WriteString(JavaPackage); } if (JavaOuterClassname.Length != 0) { - output.WriteString(8, JavaOuterClassname); + output.WriteRawTag(66); + output.WriteString(JavaOuterClassname); } if (OptimizeFor != global::Google.Protobuf.DescriptorProtos.FileOptions.Types.OptimizeMode.SPEED) { - output.WriteEnum(9, (int) OptimizeFor); + output.WriteRawTag(72); + output.WriteEnum((int) OptimizeFor); } if (JavaMultipleFiles != false) { - output.WriteBool(10, JavaMultipleFiles); + output.WriteRawTag(80); + output.WriteBool(JavaMultipleFiles); } if (GoPackage.Length != 0) { - output.WriteString(11, GoPackage); + output.WriteRawTag(90); + output.WriteString(GoPackage); } if (CcGenericServices != false) { - output.WriteBool(16, CcGenericServices); + output.WriteRawTag(128, 1); + output.WriteBool(CcGenericServices); } if (JavaGenericServices != false) { - output.WriteBool(17, JavaGenericServices); + output.WriteRawTag(136, 1); + output.WriteBool(JavaGenericServices); } if (PyGenericServices != false) { - output.WriteBool(18, PyGenericServices); + output.WriteRawTag(144, 1); + output.WriteBool(PyGenericServices); } if (JavaGenerateEqualsAndHash != false) { - output.WriteBool(20, JavaGenerateEqualsAndHash); + output.WriteRawTag(160, 1); + output.WriteBool(JavaGenerateEqualsAndHash); } if (Deprecated != false) { - output.WriteBool(23, Deprecated); + output.WriteRawTag(184, 1); + output.WriteBool(Deprecated); } if (JavaStringCheckUtf8 != false) { - output.WriteBool(27, JavaStringCheckUtf8); + output.WriteRawTag(216, 1); + output.WriteBool(JavaStringCheckUtf8); } if (CcEnableArenas != false) { - output.WriteBool(31, CcEnableArenas); + output.WriteRawTag(248, 1); + output.WriteBool(CcEnableArenas); } if (ObjcClassPrefix.Length != 0) { - output.WriteString(36, ObjcClassPrefix); + output.WriteRawTag(162, 2); + output.WriteString(ObjcClassPrefix); } if (CsharpNamespace.Length != 0) { - output.WriteString(37, CsharpNamespace); + output.WriteRawTag(170, 2); + output.WriteString(CsharpNamespace); } if (uninterpretedOption_.Count > 0) { output.WriteMessageArray(999, uninterpretedOption_); @@ -2507,51 +2569,52 @@ namespace Google.Protobuf.DescriptorProtos { public int CalculateSize() { int size = 0; if (JavaPackage.Length != 0) { - size += pb::CodedOutputStream.ComputeStringSize(1, JavaPackage); + size += 1 + pb::CodedOutputStream.ComputeStringSize(JavaPackage); } if (JavaOuterClassname.Length != 0) { - size += pb::CodedOutputStream.ComputeStringSize(8, JavaOuterClassname); + size += 1 + pb::CodedOutputStream.ComputeStringSize(JavaOuterClassname); } if (JavaMultipleFiles != false) { - size += pb::CodedOutputStream.ComputeBoolSize(10, JavaMultipleFiles); + size += 1 + 1; } if (JavaGenerateEqualsAndHash != false) { - size += pb::CodedOutputStream.ComputeBoolSize(20, JavaGenerateEqualsAndHash); + size += 2 + 1; } if (JavaStringCheckUtf8 != false) { - size += pb::CodedOutputStream.ComputeBoolSize(27, JavaStringCheckUtf8); + size += 2 + 1; } if (OptimizeFor != global::Google.Protobuf.DescriptorProtos.FileOptions.Types.OptimizeMode.SPEED) { - size += pb::CodedOutputStream.ComputeEnumSize(9, (int) OptimizeFor); + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) OptimizeFor); } if (GoPackage.Length != 0) { - size += pb::CodedOutputStream.ComputeStringSize(11, GoPackage); + size += 1 + pb::CodedOutputStream.ComputeStringSize(GoPackage); } if (CcGenericServices != false) { - size += pb::CodedOutputStream.ComputeBoolSize(16, CcGenericServices); + size += 2 + 1; } if (JavaGenericServices != false) { - size += pb::CodedOutputStream.ComputeBoolSize(17, JavaGenericServices); + size += 2 + 1; } if (PyGenericServices != false) { - size += pb::CodedOutputStream.ComputeBoolSize(18, PyGenericServices); + size += 2 + 1; } if (Deprecated != false) { - size += pb::CodedOutputStream.ComputeBoolSize(23, Deprecated); + size += 2 + 1; } if (CcEnableArenas != false) { - size += pb::CodedOutputStream.ComputeBoolSize(31, CcEnableArenas); + size += 2 + 1; } if (ObjcClassPrefix.Length != 0) { - size += pb::CodedOutputStream.ComputeStringSize(36, ObjcClassPrefix); + size += 2 + pb::CodedOutputStream.ComputeStringSize(ObjcClassPrefix); } if (CsharpNamespace.Length != 0) { - size += pb::CodedOutputStream.ComputeStringSize(37, CsharpNamespace); + size += 2 + pb::CodedOutputStream.ComputeStringSize(CsharpNamespace); } if (uninterpretedOption_.Count > 0) { foreach (global::Google.Protobuf.DescriptorProtos.UninterpretedOption element in uninterpretedOption_) { - size += pb::CodedOutputStream.ComputeMessageSize(999, element); + size += pb::CodedOutputStream.ComputeMessageSize(element); } + size += 2 * uninterpretedOption_.Count; } return size; } @@ -2781,16 +2844,20 @@ namespace Google.Protobuf.DescriptorProtos { public void WriteTo(pb::CodedOutputStream output) { if (MessageSetWireFormat != false) { - output.WriteBool(1, MessageSetWireFormat); + output.WriteRawTag(8); + output.WriteBool(MessageSetWireFormat); } if (NoStandardDescriptorAccessor != false) { - output.WriteBool(2, NoStandardDescriptorAccessor); + output.WriteRawTag(16); + output.WriteBool(NoStandardDescriptorAccessor); } if (Deprecated != false) { - output.WriteBool(3, Deprecated); + output.WriteRawTag(24); + output.WriteBool(Deprecated); } if (MapEntry != false) { - output.WriteBool(7, MapEntry); + output.WriteRawTag(56); + output.WriteBool(MapEntry); } if (uninterpretedOption_.Count > 0) { output.WriteMessageArray(999, uninterpretedOption_); @@ -2800,21 +2867,22 @@ namespace Google.Protobuf.DescriptorProtos { public int CalculateSize() { int size = 0; if (MessageSetWireFormat != false) { - size += pb::CodedOutputStream.ComputeBoolSize(1, MessageSetWireFormat); + size += 1 + 1; } if (NoStandardDescriptorAccessor != false) { - size += pb::CodedOutputStream.ComputeBoolSize(2, NoStandardDescriptorAccessor); + size += 1 + 1; } if (Deprecated != false) { - size += pb::CodedOutputStream.ComputeBoolSize(3, Deprecated); + size += 1 + 1; } if (MapEntry != false) { - size += pb::CodedOutputStream.ComputeBoolSize(7, MapEntry); + size += 1 + 1; } if (uninterpretedOption_.Count > 0) { foreach (global::Google.Protobuf.DescriptorProtos.UninterpretedOption element in uninterpretedOption_) { - size += pb::CodedOutputStream.ComputeMessageSize(999, element); + size += pb::CodedOutputStream.ComputeMessageSize(element); } + size += 2 * uninterpretedOption_.Count; } return size; } @@ -2982,22 +3050,28 @@ namespace Google.Protobuf.DescriptorProtos { public void WriteTo(pb::CodedOutputStream output) { if (Ctype != global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.CType.STRING) { - output.WriteEnum(1, (int) Ctype); + output.WriteRawTag(8); + output.WriteEnum((int) Ctype); } if (Packed != false) { - output.WriteBool(2, Packed); + output.WriteRawTag(16); + output.WriteBool(Packed); } if (Deprecated != false) { - output.WriteBool(3, Deprecated); + output.WriteRawTag(24); + output.WriteBool(Deprecated); } if (Lazy != false) { - output.WriteBool(5, Lazy); + output.WriteRawTag(40); + output.WriteBool(Lazy); } if (Jstype != global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.JSType.JS_NORMAL) { - output.WriteEnum(6, (int) Jstype); + output.WriteRawTag(48); + output.WriteEnum((int) Jstype); } if (Weak != false) { - output.WriteBool(10, Weak); + output.WriteRawTag(80); + output.WriteBool(Weak); } if (uninterpretedOption_.Count > 0) { output.WriteMessageArray(999, uninterpretedOption_); @@ -3007,27 +3081,28 @@ namespace Google.Protobuf.DescriptorProtos { public int CalculateSize() { int size = 0; if (Ctype != global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.CType.STRING) { - size += pb::CodedOutputStream.ComputeEnumSize(1, (int) Ctype); + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Ctype); } if (Packed != false) { - size += pb::CodedOutputStream.ComputeBoolSize(2, Packed); + size += 1 + 1; } if (Jstype != global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.JSType.JS_NORMAL) { - size += pb::CodedOutputStream.ComputeEnumSize(6, (int) Jstype); + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Jstype); } if (Lazy != false) { - size += pb::CodedOutputStream.ComputeBoolSize(5, Lazy); + size += 1 + 1; } if (Deprecated != false) { - size += pb::CodedOutputStream.ComputeBoolSize(3, Deprecated); + size += 1 + 1; } if (Weak != false) { - size += pb::CodedOutputStream.ComputeBoolSize(10, Weak); + size += 1 + 1; } if (uninterpretedOption_.Count > 0) { foreach (global::Google.Protobuf.DescriptorProtos.UninterpretedOption element in uninterpretedOption_) { - size += pb::CodedOutputStream.ComputeMessageSize(999, element); + size += pb::CodedOutputStream.ComputeMessageSize(element); } + size += 2 * uninterpretedOption_.Count; } return size; } @@ -3187,10 +3262,12 @@ namespace Google.Protobuf.DescriptorProtos { public void WriteTo(pb::CodedOutputStream output) { if (AllowAlias != false) { - output.WriteBool(2, AllowAlias); + output.WriteRawTag(16); + output.WriteBool(AllowAlias); } if (Deprecated != false) { - output.WriteBool(3, Deprecated); + output.WriteRawTag(24); + output.WriteBool(Deprecated); } if (uninterpretedOption_.Count > 0) { output.WriteMessageArray(999, uninterpretedOption_); @@ -3200,15 +3277,16 @@ namespace Google.Protobuf.DescriptorProtos { public int CalculateSize() { int size = 0; if (AllowAlias != false) { - size += pb::CodedOutputStream.ComputeBoolSize(2, AllowAlias); + size += 1 + 1; } if (Deprecated != false) { - size += pb::CodedOutputStream.ComputeBoolSize(3, Deprecated); + size += 1 + 1; } if (uninterpretedOption_.Count > 0) { foreach (global::Google.Protobuf.DescriptorProtos.UninterpretedOption element in uninterpretedOption_) { - size += pb::CodedOutputStream.ComputeMessageSize(999, element); + size += pb::CodedOutputStream.ComputeMessageSize(element); } + size += 2 * uninterpretedOption_.Count; } return size; } @@ -3312,7 +3390,8 @@ namespace Google.Protobuf.DescriptorProtos { public void WriteTo(pb::CodedOutputStream output) { if (Deprecated != false) { - output.WriteBool(1, Deprecated); + output.WriteRawTag(8); + output.WriteBool(Deprecated); } if (uninterpretedOption_.Count > 0) { output.WriteMessageArray(999, uninterpretedOption_); @@ -3322,12 +3401,13 @@ namespace Google.Protobuf.DescriptorProtos { public int CalculateSize() { int size = 0; if (Deprecated != false) { - size += pb::CodedOutputStream.ComputeBoolSize(1, Deprecated); + size += 1 + 1; } if (uninterpretedOption_.Count > 0) { foreach (global::Google.Protobuf.DescriptorProtos.UninterpretedOption element in uninterpretedOption_) { - size += pb::CodedOutputStream.ComputeMessageSize(999, element); + size += pb::CodedOutputStream.ComputeMessageSize(element); } + size += 2 * uninterpretedOption_.Count; } return size; } @@ -3424,7 +3504,8 @@ namespace Google.Protobuf.DescriptorProtos { public void WriteTo(pb::CodedOutputStream output) { if (Deprecated != false) { - output.WriteBool(33, Deprecated); + output.WriteRawTag(136, 2); + output.WriteBool(Deprecated); } if (uninterpretedOption_.Count > 0) { output.WriteMessageArray(999, uninterpretedOption_); @@ -3434,12 +3515,13 @@ namespace Google.Protobuf.DescriptorProtos { public int CalculateSize() { int size = 0; if (Deprecated != false) { - size += pb::CodedOutputStream.ComputeBoolSize(33, Deprecated); + size += 2 + 1; } if (uninterpretedOption_.Count > 0) { foreach (global::Google.Protobuf.DescriptorProtos.UninterpretedOption element in uninterpretedOption_) { - size += pb::CodedOutputStream.ComputeMessageSize(999, element); + size += pb::CodedOutputStream.ComputeMessageSize(element); } + size += 2 * uninterpretedOption_.Count; } return size; } @@ -3536,7 +3618,8 @@ namespace Google.Protobuf.DescriptorProtos { public void WriteTo(pb::CodedOutputStream output) { if (Deprecated != false) { - output.WriteBool(33, Deprecated); + output.WriteRawTag(136, 2); + output.WriteBool(Deprecated); } if (uninterpretedOption_.Count > 0) { output.WriteMessageArray(999, uninterpretedOption_); @@ -3546,12 +3629,13 @@ namespace Google.Protobuf.DescriptorProtos { public int CalculateSize() { int size = 0; if (Deprecated != false) { - size += pb::CodedOutputStream.ComputeBoolSize(33, Deprecated); + size += 2 + 1; } if (uninterpretedOption_.Count > 0) { foreach (global::Google.Protobuf.DescriptorProtos.UninterpretedOption element in uninterpretedOption_) { - size += pb::CodedOutputStream.ComputeMessageSize(999, element); + size += pb::CodedOutputStream.ComputeMessageSize(element); } + size += 2 * uninterpretedOption_.Count; } return size; } @@ -3701,22 +3785,28 @@ namespace Google.Protobuf.DescriptorProtos { output.WriteMessageArray(2, name_); } if (IdentifierValue.Length != 0) { - output.WriteString(3, IdentifierValue); + output.WriteRawTag(26); + output.WriteString(IdentifierValue); } if (PositiveIntValue != 0UL) { - output.WriteUInt64(4, PositiveIntValue); + output.WriteRawTag(32); + output.WriteUInt64(PositiveIntValue); } if (NegativeIntValue != 0L) { - output.WriteInt64(5, NegativeIntValue); + output.WriteRawTag(40); + output.WriteInt64(NegativeIntValue); } if (DoubleValue != 0D) { - output.WriteDouble(6, DoubleValue); + output.WriteRawTag(49); + output.WriteDouble(DoubleValue); } if (StringValue.Length != 0) { - output.WriteBytes(7, StringValue); + output.WriteRawTag(58); + output.WriteBytes(StringValue); } if (AggregateValue.Length != 0) { - output.WriteString(8, AggregateValue); + output.WriteRawTag(66); + output.WriteString(AggregateValue); } } @@ -3724,26 +3814,27 @@ namespace Google.Protobuf.DescriptorProtos { int size = 0; if (name_.Count > 0) { foreach (global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Types.NamePart element in name_) { - size += pb::CodedOutputStream.ComputeMessageSize(2, element); + size += pb::CodedOutputStream.ComputeMessageSize(element); } + size += 1 * name_.Count; } if (IdentifierValue.Length != 0) { - size += pb::CodedOutputStream.ComputeStringSize(3, IdentifierValue); + size += 1 + pb::CodedOutputStream.ComputeStringSize(IdentifierValue); } if (PositiveIntValue != 0UL) { - size += pb::CodedOutputStream.ComputeUInt64Size(4, PositiveIntValue); + size += 1 + pb::CodedOutputStream.ComputeUInt64Size(PositiveIntValue); } if (NegativeIntValue != 0L) { - size += pb::CodedOutputStream.ComputeInt64Size(5, NegativeIntValue); + size += 1 + pb::CodedOutputStream.ComputeInt64Size(NegativeIntValue); } if (DoubleValue != 0D) { - size += pb::CodedOutputStream.ComputeDoubleSize(6, DoubleValue); + size += 1 + 8; } if (StringValue.Length != 0) { - size += pb::CodedOutputStream.ComputeBytesSize(7, StringValue); + size += 1 + pb::CodedOutputStream.ComputeBytesSize(StringValue); } if (AggregateValue.Length != 0) { - size += pb::CodedOutputStream.ComputeStringSize(8, AggregateValue); + size += 1 + pb::CodedOutputStream.ComputeStringSize(AggregateValue); } return size; } @@ -3878,20 +3969,22 @@ namespace Google.Protobuf.DescriptorProtos { public void WriteTo(pb::CodedOutputStream output) { if (NamePart_.Length != 0) { - output.WriteString(1, NamePart_); + output.WriteRawTag(10); + output.WriteString(NamePart_); } if (IsExtension != false) { - output.WriteBool(2, IsExtension); + output.WriteRawTag(16); + output.WriteBool(IsExtension); } } public int CalculateSize() { int size = 0; if (NamePart_.Length != 0) { - size += pb::CodedOutputStream.ComputeStringSize(1, NamePart_); + size += 1 + pb::CodedOutputStream.ComputeStringSize(NamePart_); } if (IsExtension != false) { - size += pb::CodedOutputStream.ComputeBoolSize(2, IsExtension); + size += 1 + 1; } return size; } @@ -3993,8 +4086,9 @@ namespace Google.Protobuf.DescriptorProtos { int size = 0; if (location_.Count > 0) { foreach (global::Google.Protobuf.DescriptorProtos.SourceCodeInfo.Types.Location element in location_) { - size += pb::CodedOutputStream.ComputeMessageSize(1, element); + size += pb::CodedOutputStream.ComputeMessageSize(element); } + size += 1 * location_.Count; } return size; } @@ -4111,16 +4205,20 @@ namespace Google.Protobuf.DescriptorProtos { public void WriteTo(pb::CodedOutputStream output) { if (path_.Count > 0) { - output.WritePackedInt32Array(1, path_); + output.WriteRawTag(10); + output.WritePackedInt32Array(path_); } if (span_.Count > 0) { - output.WritePackedInt32Array(2, span_); + output.WriteRawTag(18); + output.WritePackedInt32Array(span_); } if (LeadingComments.Length != 0) { - output.WriteString(3, LeadingComments); + output.WriteRawTag(26); + output.WriteString(LeadingComments); } if (TrailingComments.Length != 0) { - output.WriteString(4, TrailingComments); + output.WriteRawTag(34); + output.WriteString(TrailingComments); } if (leadingDetachedComments_.Count > 0) { output.WriteStringArray(6, leadingDetachedComments_); @@ -4132,29 +4230,29 @@ namespace Google.Protobuf.DescriptorProtos { if (path_.Count > 0) { int dataSize = 0; foreach (int element in path_) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); + dataSize += pb::CodedOutputStream.ComputeInt32Size(element); } size += dataSize; - size += 1 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + size += 1 + pb::CodedOutputStream.ComputeInt32Size(dataSize); } if (span_.Count > 0) { int dataSize = 0; foreach (int element in span_) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); + dataSize += pb::CodedOutputStream.ComputeInt32Size(element); } size += dataSize; - size += 1 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); + size += 1 + pb::CodedOutputStream.ComputeInt32Size(dataSize); } if (LeadingComments.Length != 0) { - size += pb::CodedOutputStream.ComputeStringSize(3, LeadingComments); + size += 1 + pb::CodedOutputStream.ComputeStringSize(LeadingComments); } if (TrailingComments.Length != 0) { - size += pb::CodedOutputStream.ComputeStringSize(4, TrailingComments); + size += 1 + pb::CodedOutputStream.ComputeStringSize(TrailingComments); } if (leadingDetachedComments_.Count > 0) { int dataSize = 0; foreach (string element in leadingDetachedComments_) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); + dataSize += pb::CodedOutputStream.ComputeStringSize(element); } size += dataSize; size += 1 * leadingDetachedComments_.Count; diff --git a/src/google/protobuf/compiler/csharp/csharp_enum_field.cc b/src/google/protobuf/compiler/csharp/csharp_enum_field.cc index 19fd50cf..af34f50c 100644 --- a/src/google/protobuf/compiler/csharp/csharp_enum_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_enum_field.cc @@ -61,7 +61,8 @@ void EnumFieldGenerator::GenerateParsingCode(io::Printer* printer) { void EnumFieldGenerator::GenerateSerializationCode(io::Printer* printer) { printer->Print(variables_, "if ($has_property_check$) {\n" - " output.WriteEnum($number$, (int) $property_name$);\n" + " output.WriteRawTag($tag_bytes$);\n" + " output.WriteEnum((int) $property_name$);\n" "}\n"); } @@ -69,7 +70,7 @@ void EnumFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) { printer->Print( variables_, "if ($has_property_check$) {\n" - " size += pb::CodedOutputStream.ComputeEnumSize($number$, (int) $property_name$);\n" + " size += $tag_size$ + pb::CodedOutputStream.ComputeEnumSize((int) $property_name$);\n" "}\n"); } @@ -93,7 +94,8 @@ void EnumOneofFieldGenerator::GenerateSerializationCode(io::Printer* printer) { printer->Print( variables_, "if ($has_property_check$) {\n" - " output.WriteEnum($number$, (int) $property_name$);\n" + " output.WriteRawTag($tag_bytes$);\n" + " output.WriteEnum((int) $property_name$);\n" "}\n"); } @@ -101,7 +103,7 @@ void EnumOneofFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) { printer->Print( variables_, "if ($has_property_check$) {\n" - " size += pb::CodedOutputStream.ComputeEnumSize($number$, (int) $property_name$);\n" + " size += $tag_size$ + pb::CodedOutputStream.ComputeEnumSize((int) $property_name$);\n" "}\n"); } diff --git a/src/google/protobuf/compiler/csharp/csharp_field_base.cc b/src/google/protobuf/compiler/csharp/csharp_field_base.cc index ec0d51ca..54f281ee 100644 --- a/src/google/protobuf/compiler/csharp/csharp_field_base.cc +++ b/src/google/protobuf/compiler/csharp/csharp_field_base.cc @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -55,8 +56,18 @@ void FieldGeneratorBase::SetCommonFieldVariables( // Note: this will be valid even though the tag emitted for packed and unpacked versions of // repeated fields varies by wire format. The wire format is encoded in the bottom 3 bits, which // never effects the tag size. - int tagSize = internal::WireFormat::TagSize(descriptor_->number(), descriptor_->type()); - (*variables)["tag_size"] = SimpleItoa(tagSize); + int tag_size = internal::WireFormat::TagSize(descriptor_->number(), descriptor_->type()); + uint tag = internal::WireFormat::MakeTag(descriptor_); + uint8 tag_array[5]; + io::CodedOutputStream::WriteTagToArray(tag, tag_array); + string tag_bytes = SimpleItoa(tag_array[0]); + for (int i = 1; i < tag_size; i++) { + tag_bytes += ", " + SimpleItoa(tag_array[i]); + } + + (*variables)["tag_size"] = SimpleItoa(tag_size); + (*variables)["tag_bytes"] = tag_bytes; + (*variables)["property_name"] = property_name(); (*variables)["type_name"] = type_name(); (*variables)["name"] = name(); diff --git a/src/google/protobuf/compiler/csharp/csharp_message_field.cc b/src/google/protobuf/compiler/csharp/csharp_message_field.cc index 804a5ae2..bd67aa0f 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message_field.cc @@ -92,11 +92,11 @@ void MessageFieldGenerator::GenerateParsingCode(io::Printer* printer) { } void MessageFieldGenerator::GenerateSerializationCode(io::Printer* printer) { - // TODO(jonskeet): Why are we using array access instead of a literal here? printer->Print( variables_, "if ($has_property_check$) {\n" - " output.WriteMessage($number$, $property_name$);\n" + " output.WriteRawTag($tag_bytes$);\n" + " output.WriteMessage($property_name$);\n" "}\n"); } @@ -104,7 +104,7 @@ void MessageFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) { printer->Print( variables_, "if ($has_property_check$) {\n" - " size += pb::CodedOutputStream.ComputeMessageSize($number$, $property_name$);\n" + " size += $tag_size$ + pb::CodedOutputStream.ComputeMessageSize($property_name$);\n" "}\n"); } diff --git a/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc b/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc index 0164cdca..5820eb37 100644 --- a/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc @@ -105,16 +105,29 @@ void PrimitiveFieldGenerator::GenerateSerializationCode(io::Printer* printer) { printer->Print( variables_, "if ($has_property_check$) {\n" - " output.Write$capitalized_type_name$($number$, $property_name$);\n" + " output.WriteRawTag($tag_bytes$);\n" + " output.Write$capitalized_type_name$($property_name$);\n" "}\n"); } void PrimitiveFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) { printer->Print( variables_, - "if ($has_property_check$) {\n" - " size += pb::CodedOutputStream.Compute$capitalized_type_name$Size($number$, $property_name$);\n" - "}\n"); + "if ($has_property_check$) {\n"); + printer->Indent(); + int fixedSize = GetFixedSize(descriptor_->type()); + if (fixedSize == -1) { + printer->Print( + variables_, + "size += $tag_size$ + pb::CodedOutputStream.Compute$capitalized_type_name$Size($property_name$);\n"); + } else { + printer->Print( + "size += $tag_size$ + $fixed_size$;\n", + "fixed_size", SimpleItoa(fixedSize), + "tag_size", variables_["tag_size"]); + } + printer->Outdent(); + printer->Print("}\n"); } void PrimitiveFieldGenerator::WriteHash(io::Printer* printer) { @@ -173,7 +186,7 @@ void PrimitiveOneofFieldGenerator::WriteToString(io::Printer* printer) { void PrimitiveOneofFieldGenerator::GenerateParsingCode(io::Printer* printer) { printer->Print( variables_, - "$property_name$ = input.Read$capitalized_type_name$()\n;"); + "$property_name$ = input.Read$capitalized_type_name$();\n"); } } // namespace csharp diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc b/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc index 22dec710..c78aaef6 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc @@ -82,9 +82,20 @@ void RepeatedEnumFieldGenerator::GenerateParsingCode(io::Printer* printer) { void RepeatedEnumFieldGenerator::GenerateSerializationCode(io::Printer* printer) { printer->Print( variables_, - "if ($name$_.Count > 0) {\n" - " output.Write$packed$EnumArray($number$, $name$_);\n" - "}\n"); + "if ($name$_.Count > 0) {\n"); + printer->Indent(); + if (descriptor_->is_packed()) { + printer->Print( + variables_, + "output.WriteRawTag($tag_bytes$);\n" + "output.WritePackedEnumArray($name$_);\n"); + } else { + printer->Print( + variables_, + "output.Write$capitalized_type_name$Array($number$, $name$_);\n"); + } + printer->Outdent(); + printer->Print("}\n"); } void RepeatedEnumFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) { @@ -97,14 +108,13 @@ void RepeatedEnumFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer printer->Print( variables_, "foreach ($type_name$ element in $name$_) {\n" - " dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element);\n" + " dataSize += pb::CodedOutputStream.ComputeEnumSize((int) element);\n" "}\n" "size += dataSize;\n"); int tagSize = internal::WireFormat::TagSize(descriptor_->number(), descriptor_->type()); if (descriptor_->is_packed()) { printer->Print( - "size += $tag_size$;\n" - "size += pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize);\n", + "size += $tag_size$ + pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize);\n", "tag_size", SimpleItoa(tagSize)); } else { printer->Print( diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc b/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc index 4b570d3b..3553fe12 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc @@ -79,8 +79,8 @@ void RepeatedMessageFieldGenerator::GenerateParsingCode(io::Printer* printer) { } void RepeatedMessageFieldGenerator::GenerateSerializationCode(io::Printer* printer) { - // TODO(jonskeet): Originally, this checked for Count > 0 first. - // The Write* call should make that cheap though - no need to generate it every time. + // TODO(jonskeet): Bake the foreach loop into the generated code? We lose the + // advantage of knowing the tag bytes this way :( printer->Print( variables_, "if ($name$_.Count > 0) {\n" @@ -89,13 +89,13 @@ void RepeatedMessageFieldGenerator::GenerateSerializationCode(io::Printer* print } void RepeatedMessageFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) { - // TODO(jonskeet): Put this into CodedOutputStream. printer->Print( variables_, "if ($name$_.Count > 0) {\n" " foreach ($type_name$ element in $name$_) {\n" - " size += pb::CodedOutputStream.ComputeMessageSize($number$, element);\n" + " size += pb::CodedOutputStream.ComputeMessageSize(element);\n" " }\n" + " size += $tag_size$ * $name$_.Count;\n" "}\n"); } diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc b/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc index a5457785..fe8a4364 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc @@ -82,9 +82,20 @@ void RepeatedPrimitiveFieldGenerator::GenerateSerializationCode( io::Printer* printer) { printer->Print( variables_, - "if ($name$_.Count > 0) {\n" - " output.Write$packed$$capitalized_type_name$Array($number$, $name$_);\n" - "}\n"); + "if ($name$_.Count > 0) {\n"); + printer->Indent(); + if (descriptor_->is_packed()) { + printer->Print( + variables_, + "output.WriteRawTag($tag_bytes$);\n" + "output.WritePacked$capitalized_type_name$Array($name$_);\n"); + } else { + printer->Print( + variables_, + "output.Write$capitalized_type_name$Array($number$, $name$_);\n"); + } + printer->Outdent(); + printer->Print("}\n"); } void RepeatedPrimitiveFieldGenerator::GenerateSerializedSizeCode( @@ -100,7 +111,7 @@ void RepeatedPrimitiveFieldGenerator::GenerateSerializedSizeCode( printer->Print( variables_, "foreach ($type_name$ element in $name$_) {\n" - " dataSize += pb::CodedOutputStream.Compute$capitalized_type_name$SizeNoTag(element);\n" + " dataSize += pb::CodedOutputStream.Compute$capitalized_type_name$Size(element);\n" "}\n"); } else { printer->Print( @@ -111,7 +122,7 @@ void RepeatedPrimitiveFieldGenerator::GenerateSerializedSizeCode( int tagSize = internal::WireFormat::TagSize(descriptor_->number(), descriptor_->type()); if (descriptor_->is_packed()) { printer->Print( - "size += $tag_size$ + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize);\n", + "size += $tag_size$ + pb::CodedOutputStream.ComputeInt32Size(dataSize);\n", "tag_size", SimpleItoa(tagSize)); } else { printer->Print( diff --git a/src/google/protobuf/wire_format.h b/src/google/protobuf/wire_format.h index 8de491a6..84270fee 100644 --- a/src/google/protobuf/wire_format.h +++ b/src/google/protobuf/wire_format.h @@ -290,7 +290,7 @@ class LIBPROTOBUF_EXPORT UnknownFieldSetFieldSkipper : public FieldSkipper { inline WireFormatLite::WireType WireFormat::WireTypeForField( const FieldDescriptor* field) { - if (field->options().packed()) { + if (field->is_packed()) { return WireFormatLite::WIRETYPE_LENGTH_DELIMITED; } else { return WireTypeForFieldType(field->type()); -- cgit v1.2.3 From d9dc05e500807a6f0cd10d4637c599acc9a6aecf Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Wed, 17 Jun 2015 14:59:49 +0100 Subject: Remove a lot of projects which are effectively dead from the solution - files to be killed later. --- csharp/src/ProtocolBuffers.sln | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/csharp/src/ProtocolBuffers.sln b/csharp/src/ProtocolBuffers.sln index 6d609dc9..0889c50e 100644 --- a/csharp/src/ProtocolBuffers.sln +++ b/csharp/src/ProtocolBuffers.sln @@ -1,21 +1,13 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.22609.0 +VisualStudioVersion = 14.0.22823.1 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProtocolBuffers", "ProtocolBuffers\ProtocolBuffers.csproj", "{6908BDCE-D925-43F3-94AC-A531E6DF2591}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProtocolBuffersLite", "ProtocolBuffers\ProtocolBuffersLite.csproj", "{6969BDCE-D925-43F3-94AC-A531E6DF2591}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProtocolBuffers.Serialization", "ProtocolBuffers.Serialization\ProtocolBuffers.Serialization.csproj", "{231391AF-449C-4A39-986C-AD7F270F4750}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProtocolBuffersLite.Serialization", "ProtocolBuffers.Serialization\ProtocolBuffersLite.Serialization.csproj", "{E067A59D-9D0A-4A1F-92B1-38E4457241D1}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProtocolBuffers.Test", "ProtocolBuffers.Test\ProtocolBuffers.Test.csproj", "{DD01ED24-3750-4567-9A23-1DB676A15610}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProtocolBuffersLite.Test", "ProtocolBuffersLite.Test\ProtocolBuffersLite.Test.csproj", "{EE01ED24-3750-4567-9A23-1DB676A15610}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProtocolBuffersLiteMixed.Test", "ProtocolBuffersLite.Test\ProtocolBuffersLiteMixed.Test.csproj", "{EEFFED24-3750-4567-9A23-1DB676A15610}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AddressBook", "AddressBook\AddressBook.csproj", "{A31F5FB2-4FF3-432A-B35B-5CD203606311}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProtoDump", "ProtoDump\ProtoDump.csproj", "{D7282E99-2DC3-405B-946F-177DB2FD2AE2}" @@ -34,30 +26,14 @@ Global {6908BDCE-D925-43F3-94AC-A531E6DF2591}.Debug|Any CPU.Build.0 = Debug|Any CPU {6908BDCE-D925-43F3-94AC-A531E6DF2591}.Release|Any CPU.ActiveCfg = Release|Any CPU {6908BDCE-D925-43F3-94AC-A531E6DF2591}.Release|Any CPU.Build.0 = Release|Any CPU - {6969BDCE-D925-43F3-94AC-A531E6DF2591}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6969BDCE-D925-43F3-94AC-A531E6DF2591}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6969BDCE-D925-43F3-94AC-A531E6DF2591}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6969BDCE-D925-43F3-94AC-A531E6DF2591}.Release|Any CPU.Build.0 = Release|Any CPU {231391AF-449C-4A39-986C-AD7F270F4750}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {231391AF-449C-4A39-986C-AD7F270F4750}.Debug|Any CPU.Build.0 = Debug|Any CPU {231391AF-449C-4A39-986C-AD7F270F4750}.Release|Any CPU.ActiveCfg = Release|Any CPU {231391AF-449C-4A39-986C-AD7F270F4750}.Release|Any CPU.Build.0 = Release|Any CPU - {E067A59D-9D0A-4A1F-92B1-38E4457241D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E067A59D-9D0A-4A1F-92B1-38E4457241D1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E067A59D-9D0A-4A1F-92B1-38E4457241D1}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E067A59D-9D0A-4A1F-92B1-38E4457241D1}.Release|Any CPU.Build.0 = Release|Any CPU {DD01ED24-3750-4567-9A23-1DB676A15610}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {DD01ED24-3750-4567-9A23-1DB676A15610}.Debug|Any CPU.Build.0 = Debug|Any CPU {DD01ED24-3750-4567-9A23-1DB676A15610}.Release|Any CPU.ActiveCfg = Release|Any CPU {DD01ED24-3750-4567-9A23-1DB676A15610}.Release|Any CPU.Build.0 = Release|Any CPU - {EE01ED24-3750-4567-9A23-1DB676A15610}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {EE01ED24-3750-4567-9A23-1DB676A15610}.Debug|Any CPU.Build.0 = Debug|Any CPU - {EE01ED24-3750-4567-9A23-1DB676A15610}.Release|Any CPU.ActiveCfg = Release|Any CPU - {EE01ED24-3750-4567-9A23-1DB676A15610}.Release|Any CPU.Build.0 = Release|Any CPU - {EEFFED24-3750-4567-9A23-1DB676A15610}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {EEFFED24-3750-4567-9A23-1DB676A15610}.Debug|Any CPU.Build.0 = Debug|Any CPU - {EEFFED24-3750-4567-9A23-1DB676A15610}.Release|Any CPU.ActiveCfg = Release|Any CPU - {EEFFED24-3750-4567-9A23-1DB676A15610}.Release|Any CPU.Build.0 = Release|Any CPU {A31F5FB2-4FF3-432A-B35B-5CD203606311}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A31F5FB2-4FF3-432A-B35B-5CD203606311}.Debug|Any CPU.Build.0 = Debug|Any CPU {A31F5FB2-4FF3-432A-B35B-5CD203606311}.Release|Any CPU.ActiveCfg = Release|Any CPU -- cgit v1.2.3 From 09f3f4eec3a7e6b2f58b47eb007bcb24dfdbf7a0 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Wed, 17 Jun 2015 15:16:14 +0100 Subject: Updates to handle use of cmake for Windows builds. --- .gitignore | 3 +-- cmake/libprotoc.cmake | 2 -- csharp/generate_protos.sh | 8 ++++---- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 52c92dfb..ea7e654f 100644 --- a/.gitignore +++ b/.gitignore @@ -77,8 +77,7 @@ java/target javanano/target # Windows native output. -vsprojects/Debug -vsprojects/Release +cmake/build # NuGet packages: we want the repository configuration, but not the # packages themselves. diff --git a/cmake/libprotoc.cmake b/cmake/libprotoc.cmake index 8caa9e9e..e9e88af5 100644 --- a/cmake/libprotoc.cmake +++ b/cmake/libprotoc.cmake @@ -16,7 +16,6 @@ set(libprotoc_files ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_string_field.cc ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_enum.cc ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_enum_field.cc - ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_extension.cc ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_field_base.cc ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_generator.cc ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_helpers.cc @@ -28,7 +27,6 @@ set(libprotoc_files ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_umbrella_class.cc - ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_writer.cc ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_context.cc ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_doc_comment.cc ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_enum.cc diff --git a/csharp/generate_protos.sh b/csharp/generate_protos.sh index d239fcb2..60bc2813 100755 --- a/csharp/generate_protos.sh +++ b/csharp/generate_protos.sh @@ -23,10 +23,10 @@ cd $(dirname $0)/.. # Windows and Unix. if [ -z "$PROTOC" ]; then # TODO(jonskeet): Use an array and a for loop instead? - if [ -x vsprojects/Debug/protoc.exe ]; then - PROTOC=vsprojects/Debug/protoc.exe - elif [ -x vsprojects/Release/protoc.exe ]; then - PROTOC=vsprojects/Release/protoc.exe + if [ -x cmake/build/Debug/protoc.exe ]; then + PROTOC=cmake/build/Debug/protoc.exe + elif [ -x cmake/build/Release/protoc.exe ]; then + PROTOC=cmake/build/Release/protoc.exe elif [ -x src/protoc ]; then PROTOC=src/protoc else -- cgit v1.2.3 From d1b88f43109d23111e9cae158d25a8b7c9d7e36d Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Wed, 17 Jun 2015 15:16:31 +0100 Subject: Regenerated files. --- csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs b/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs index 44e6e2e9..67938260 100644 --- a/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs +++ b/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs @@ -175,9 +175,9 @@ namespace Google.Protobuf.DescriptorProtos { "LkxvY2F0aW9uGoYBCghMb2NhdGlvbhIQCgRwYXRoGAEgAygFQgIQARIQCgRz", "cGFuGAIgAygFQgIQARIYChBsZWFkaW5nX2NvbW1lbnRzGAMgASgJEhkKEXRy", "YWlsaW5nX2NvbW1lbnRzGAQgASgJEiEKGWxlYWRpbmdfZGV0YWNoZWRfY29t", - "bWVudHMYBiADKAlCUgoTY29tLmdvb2dsZS5wcm90b2J1ZkIQRGVzY3JpcHRv", - "clByb3Rvc0gBogIDR1BCqgIgR29vZ2xlLlByb3RvYnVmLkRlc2NyaXB0b3JQ", - "cm90b3M=")); + "bWVudHMYBiADKAlCXgoTY29tLmdvb2dsZS5wcm90b2J1ZkIQRGVzY3JpcHRv", + "clByb3Rvc0gBWgpkZXNjcmlwdG9yogIDR1BCqgIgR29vZ2xlLlByb3RvYnVm", + "LkRlc2NyaXB0b3JQcm90b3M=")); pbd::FileDescriptor.InternalDescriptorAssigner assigner = delegate(pbd::FileDescriptor root) { descriptor = root; internal__static_google_protobuf_FileDescriptorSet__Descriptor = Descriptor.MessageTypes[0]; -- cgit v1.2.3 From a09b491080b5756d19c132f840ede5a7920b8d87 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Wed, 17 Jun 2015 15:25:15 +0100 Subject: Delete "lite" project and serialization project+code We'll probably want a lot of the code from the serialization project when we do JSON, but enough of it will change that it's not worth keeping in a broken state for now. --- .../AbstractReader.cs | 686 - .../AbstractTextReader.cs | 175 - .../AbstractTextWriter.cs | 104 - .../AbstractWriter.cs | 503 - .../DictionaryReader.cs | 265 - .../DictionaryWriter.cs | 200 - .../ProtocolBuffers.Serialization/Extensions.cs | 185 - .../Http/FormUrlEncodedReader.cs | 162 - .../Http/MessageFormatFactory.cs | 112 - .../Http/MessageFormatOptions.cs | 176 - .../JsonFormatReader.cs | 262 - .../JsonFormatWriter.cs | 541 - .../JsonTextCursor.cs | 442 - .../Properties/AssemblyInfo.cs | 65 - .../ProtocolBuffers.Serialization.csproj | 93 - .../ProtocolBuffersLite.Serialization.csproj | 93 - .../RecursionLimitExceeded.cs | 18 - .../XmlFormatReader.cs | 338 - .../XmlFormatWriter.cs | 280 - .../XmlReaderOptions.cs | 17 - .../XmlWriterOptions.cs | 24 - .../src/ProtocolBuffers/ProtocolBuffersLite.csproj | 99 - .../AbstractBuilderLiteTest.cs | 336 - .../AbstractMessageLiteTest.cs | 133 - csharp/src/ProtocolBuffersLite.Test/App.xaml | 8 - csharp/src/ProtocolBuffersLite.Test/App.xaml.cs | 60 - .../ExtendableBuilderLiteTest.cs | 286 - .../ExtendableMessageLiteTest.cs | 378 - .../ProtocolBuffersLite.Test/InteropLiteTest.cs | 185 - csharp/src/ProtocolBuffersLite.Test/LiteTest.cs | 113 - .../MissingFieldAndExtensionTest.cs | 237 - .../Properties/AppManifest.xml | 6 - .../Properties/OutOfBrowserSettings.xml | 7 - .../ProtocolBuffersLite.Test.csproj | 113 - .../ProtocolBuffersLiteMixed.Test.csproj | 110 - .../src/ProtocolBuffersLite.Test/TestLiteByApi.cs | 120 - .../TestProtos/Unittest.cs | 33878 ------------------- .../TestProtos/UnittestExtrasFull.cs | 2138 -- .../TestProtos/UnittestExtrasLite.cs | 4206 --- .../TestProtos/UnittestImport.cs | 347 - .../TestProtos/UnittestImportLite.cs | 311 - .../TestProtos/UnittestImportPublic.cs | 333 - .../TestProtos/UnittestImportPublicLite.cs | 302 - .../TestProtos/UnittestLite.cs | 12493 ------- .../TestProtos/UnittestLiteImportsNonlite.cs | 325 - .../src/ProtocolBuffersLite.Test/packages.config | 5 - 46 files changed, 61270 deletions(-) delete mode 100644 csharp/src/ProtocolBuffers.Serialization/AbstractReader.cs delete mode 100644 csharp/src/ProtocolBuffers.Serialization/AbstractTextReader.cs delete mode 100644 csharp/src/ProtocolBuffers.Serialization/AbstractTextWriter.cs delete mode 100644 csharp/src/ProtocolBuffers.Serialization/AbstractWriter.cs delete mode 100644 csharp/src/ProtocolBuffers.Serialization/DictionaryReader.cs delete mode 100644 csharp/src/ProtocolBuffers.Serialization/DictionaryWriter.cs delete mode 100644 csharp/src/ProtocolBuffers.Serialization/Extensions.cs delete mode 100644 csharp/src/ProtocolBuffers.Serialization/Http/FormUrlEncodedReader.cs delete mode 100644 csharp/src/ProtocolBuffers.Serialization/Http/MessageFormatFactory.cs delete mode 100644 csharp/src/ProtocolBuffers.Serialization/Http/MessageFormatOptions.cs delete mode 100644 csharp/src/ProtocolBuffers.Serialization/JsonFormatReader.cs delete mode 100644 csharp/src/ProtocolBuffers.Serialization/JsonFormatWriter.cs delete mode 100644 csharp/src/ProtocolBuffers.Serialization/JsonTextCursor.cs delete mode 100644 csharp/src/ProtocolBuffers.Serialization/Properties/AssemblyInfo.cs delete mode 100644 csharp/src/ProtocolBuffers.Serialization/ProtocolBuffers.Serialization.csproj delete mode 100644 csharp/src/ProtocolBuffers.Serialization/ProtocolBuffersLite.Serialization.csproj delete mode 100644 csharp/src/ProtocolBuffers.Serialization/RecursionLimitExceeded.cs delete mode 100644 csharp/src/ProtocolBuffers.Serialization/XmlFormatReader.cs delete mode 100644 csharp/src/ProtocolBuffers.Serialization/XmlFormatWriter.cs delete mode 100644 csharp/src/ProtocolBuffers.Serialization/XmlReaderOptions.cs delete mode 100644 csharp/src/ProtocolBuffers.Serialization/XmlWriterOptions.cs delete mode 100644 csharp/src/ProtocolBuffers/ProtocolBuffersLite.csproj delete mode 100644 csharp/src/ProtocolBuffersLite.Test/AbstractBuilderLiteTest.cs delete mode 100644 csharp/src/ProtocolBuffersLite.Test/AbstractMessageLiteTest.cs delete mode 100644 csharp/src/ProtocolBuffersLite.Test/App.xaml delete mode 100644 csharp/src/ProtocolBuffersLite.Test/App.xaml.cs delete mode 100644 csharp/src/ProtocolBuffersLite.Test/ExtendableBuilderLiteTest.cs delete mode 100644 csharp/src/ProtocolBuffersLite.Test/ExtendableMessageLiteTest.cs delete mode 100644 csharp/src/ProtocolBuffersLite.Test/InteropLiteTest.cs delete mode 100644 csharp/src/ProtocolBuffersLite.Test/LiteTest.cs delete mode 100644 csharp/src/ProtocolBuffersLite.Test/MissingFieldAndExtensionTest.cs delete mode 100644 csharp/src/ProtocolBuffersLite.Test/Properties/AppManifest.xml delete mode 100644 csharp/src/ProtocolBuffersLite.Test/Properties/OutOfBrowserSettings.xml delete mode 100644 csharp/src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test.csproj delete mode 100644 csharp/src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.csproj delete mode 100644 csharp/src/ProtocolBuffersLite.Test/TestLiteByApi.cs delete mode 100644 csharp/src/ProtocolBuffersLite.Test/TestProtos/Unittest.cs delete mode 100644 csharp/src/ProtocolBuffersLite.Test/TestProtos/UnittestExtrasFull.cs delete mode 100644 csharp/src/ProtocolBuffersLite.Test/TestProtos/UnittestExtrasLite.cs delete mode 100644 csharp/src/ProtocolBuffersLite.Test/TestProtos/UnittestImport.cs delete mode 100644 csharp/src/ProtocolBuffersLite.Test/TestProtos/UnittestImportLite.cs delete mode 100644 csharp/src/ProtocolBuffersLite.Test/TestProtos/UnittestImportPublic.cs delete mode 100644 csharp/src/ProtocolBuffersLite.Test/TestProtos/UnittestImportPublicLite.cs delete mode 100644 csharp/src/ProtocolBuffersLite.Test/TestProtos/UnittestLite.cs delete mode 100644 csharp/src/ProtocolBuffersLite.Test/TestProtos/UnittestLiteImportsNonlite.cs delete mode 100644 csharp/src/ProtocolBuffersLite.Test/packages.config diff --git a/csharp/src/ProtocolBuffers.Serialization/AbstractReader.cs b/csharp/src/ProtocolBuffers.Serialization/AbstractReader.cs deleted file mode 100644 index 99ecec88..00000000 --- a/csharp/src/ProtocolBuffers.Serialization/AbstractReader.cs +++ /dev/null @@ -1,686 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using Google.ProtocolBuffers.Descriptors; - -//Disable CS3011: only CLS-compliant members can be abstract -#pragma warning disable 3011 - -namespace Google.ProtocolBuffers.Serialization -{ - /// - /// Provides a base-class that provides some basic functionality for handling type dispatching - /// - public abstract class AbstractReader : ICodedInputStream - { - private const int DefaultMaxDepth = 64; - private int _depth; - - /// Constructs a new reader - protected AbstractReader() { MaxDepth = DefaultMaxDepth; } - - /// Gets or sets the maximum recursion depth allowed - public int MaxDepth { get; set; } - - /// - /// Merges the contents of stream into the provided message builder - /// - public TBuilder Merge(TBuilder builder) where TBuilder : IBuilderLite - { - return Merge(builder, ExtensionRegistry.Empty); - } - - /// - /// Merges the contents of stream into the provided message builder - /// - public abstract TBuilder Merge(TBuilder builder, ExtensionRegistry registry) - where TBuilder : IBuilderLite; - - /// - /// Peeks at the next field in the input stream and returns what information is available. - /// - /// - /// This may be called multiple times without actually reading the field. Only after the field - /// is either read, or skipped, should PeekNext return a different value. - /// - protected abstract bool PeekNext(out string field); - - /// - /// Causes the reader to skip past this field - /// - protected abstract void Skip(); - - /// - /// Returns true if it was able to read a Boolean from the input - /// - protected abstract bool Read(ref bool value); - - /// - /// Returns true if it was able to read a Int32 from the input - /// - protected abstract bool Read(ref int value); - - /// - /// Returns true if it was able to read a UInt32 from the input - /// - protected abstract bool Read(ref uint value); - - /// - /// Returns true if it was able to read a Int64 from the input - /// - protected abstract bool Read(ref long value); - - /// - /// Returns true if it was able to read a UInt64 from the input - /// - protected abstract bool Read(ref ulong value); - - /// - /// Returns true if it was able to read a Single from the input - /// - protected abstract bool Read(ref float value); - - /// - /// Returns true if it was able to read a Double from the input - /// - protected abstract bool Read(ref double value); - - /// - /// Returns true if it was able to read a String from the input - /// - protected abstract bool Read(ref string value); - - /// - /// Returns true if it was able to read a ByteString from the input - /// - protected abstract bool Read(ref ByteString value); - - /// - /// returns true if it was able to read a single value into the value reference. The value - /// stored may be of type System.String, System.Int32, or an IEnumLite from the IEnumLiteMap. - /// - protected abstract bool ReadEnum(ref object value); - - /// - /// Merges the input stream into the provided IBuilderLite - /// - protected abstract bool ReadMessage(IBuilderLite builder, ExtensionRegistry registry); - - /// - /// Reads the root-message preamble specific to this formatter - /// - public abstract void ReadMessageStart(); - - /// - /// Reads the root-message close specific to this formatter - /// - public abstract void ReadMessageEnd(); - - /// - /// Merges the input stream into the provided IBuilderLite - /// - public virtual bool ReadGroup(IBuilderLite value, ExtensionRegistry registry) - { - return ReadMessage(value, registry); - } - - /// - /// Cursors through the array elements and stops at the end of the array - /// - protected virtual IEnumerable ForeachArrayItem(string field) - { - string next = field; - while (true) - { - yield return next; - - if (!PeekNext(out next) || next != field) - { - break; - } - } - } - - /// - /// Reads an array of T messages - /// - public virtual bool ReadMessageArray(string field, ICollection items, IMessageLite messageType, - ExtensionRegistry registry) - { - bool success = false; - foreach (string next in ForeachArrayItem(field)) - { - IBuilderLite builder = messageType.WeakCreateBuilderForType(); - if (ReadMessage(builder, registry)) - { - items.Add((T) builder.WeakBuild()); - success |= true; - } - } - return success; - } - - /// - /// Reads an array of T messages as a proto-buffer group - /// - public virtual bool ReadGroupArray(string field, ICollection items, IMessageLite messageType, - ExtensionRegistry registry) - { - bool success = false; - foreach (string next in ForeachArrayItem(field)) - { - IBuilderLite builder = messageType.WeakCreateBuilderForType(); - if (ReadGroup(builder, registry)) - { - items.Add((T) builder.WeakBuild()); - success |= true; - } - } - return success; - } - - /// - /// Reads an array of System.Enum type T and adds them to the collection - /// - public virtual bool ReadEnumArray(string field, ICollection items) - { - bool success = false; - foreach (string next in ForeachArrayItem(field)) - { - object temp = null; - if (ReadEnum(ref temp)) - { - items.Add(temp); - success |= true; - } - } - return success; - } - - /// - /// Reads an array of T, where T is a primitive type defined by FieldType - /// - public virtual bool ReadArray(FieldType type, string field, ICollection items) - { - bool success = false; - foreach (string next in ForeachArrayItem(field)) - { - object temp = null; - if (ReadField(type, ref temp)) - { - items.Add((T) temp); - success |= true; - } - } - return success; - } - - /// - /// returns true if it was able to read a single primitive value of FieldType into the value reference - /// - public virtual bool ReadField(FieldType type, ref object value) - { - switch (type) - { - case FieldType.Bool: - { - bool temp = false; - if (Read(ref temp)) - { - value = temp; - } - else - { - return false; - } - break; - } - case FieldType.Int64: - case FieldType.SInt64: - case FieldType.SFixed64: - { - long temp = 0; - if (Read(ref temp)) - { - value = temp; - } - else - { - return false; - } - break; - } - case FieldType.UInt64: - case FieldType.Fixed64: - { - ulong temp = 0; - if (Read(ref temp)) - { - value = temp; - } - else - { - return false; - } - break; - } - case FieldType.Int32: - case FieldType.SInt32: - case FieldType.SFixed32: - { - int temp = 0; - if (Read(ref temp)) - { - value = temp; - } - else - { - return false; - } - break; - } - case FieldType.UInt32: - case FieldType.Fixed32: - { - uint temp = 0; - if (Read(ref temp)) - { - value = temp; - } - else - { - return false; - } - break; - } - case FieldType.Float: - { - float temp = float.NaN; - if (Read(ref temp)) - { - value = temp; - } - else - { - return false; - } - break; - } - case FieldType.Double: - { - double temp = float.NaN; - if (Read(ref temp)) - { - value = temp; - } - else - { - return false; - } - break; - } - case FieldType.String: - { - string temp = null; - if (Read(ref temp)) - { - value = temp; - } - else - { - return false; - } - break; - } - case FieldType.Bytes: - { - ByteString temp = null; - if (Read(ref temp)) - { - value = temp; - } - else - { - return false; - } - break; - } - default: - throw InvalidProtocolBufferException.InvalidTag(); - } - return true; - } - - #region ICodedInputStream Members - - bool ICodedInputStream.ReadTag(out uint fieldTag, out string fieldName) - { - fieldTag = 0; - if (PeekNext(out fieldName)) - { - return true; - } - return false; - } - - bool ICodedInputStream.ReadDouble(ref double value) - { - return Read(ref value); - } - - bool ICodedInputStream.ReadFloat(ref float value) - { - return Read(ref value); - } - - bool ICodedInputStream.ReadUInt64(ref ulong value) - { - return Read(ref value); - } - - bool ICodedInputStream.ReadInt64(ref long value) - { - return Read(ref value); - } - - bool ICodedInputStream.ReadInt32(ref int value) - { - return Read(ref value); - } - - bool ICodedInputStream.ReadFixed64(ref ulong value) - { - return Read(ref value); - } - - bool ICodedInputStream.ReadFixed32(ref uint value) - { - return Read(ref value); - } - - bool ICodedInputStream.ReadBool(ref bool value) - { - return Read(ref value); - } - - bool ICodedInputStream.ReadString(ref string value) - { - return Read(ref value); - } - - void ICodedInputStream.ReadGroup(int fieldNumber, IBuilderLite builder, ExtensionRegistry extensionRegistry) - { - if (_depth++ > MaxDepth) - { - throw new RecursionLimitExceededException(); - } - ReadGroup(builder, extensionRegistry); - _depth--; - } - - void ICodedInputStream.ReadUnknownGroup(int fieldNumber, IBuilderLite builder) - { - throw new NotSupportedException(); - } - - void ICodedInputStream.ReadMessage(IBuilderLite builder, ExtensionRegistry extensionRegistry) - { - if (_depth++ > MaxDepth) - { - throw new RecursionLimitExceededException(); - } - ReadMessage(builder, extensionRegistry); - _depth--; - } - - bool ICodedInputStream.ReadBytes(ref ByteString value) - { - return Read(ref value); - } - - bool ICodedInputStream.ReadUInt32(ref uint value) - { - return Read(ref value); - } - - bool ICodedInputStream.ReadEnum(ref IEnumLite value, out object unknown, IEnumLiteMap mapping) - { - value = null; - unknown = null; - if (ReadEnum(ref unknown)) - { - if (unknown is int) - { - value = mapping.FindValueByNumber((int) unknown); - } - else if (unknown is string) - { - value = mapping.FindValueByName((string) unknown); - } - return value != null; - } - return false; - } - - bool ICodedInputStream.ReadEnum(ref T value, out object rawValue) - { - rawValue = null; - if (ReadEnum(ref rawValue)) - { - if (!EnumParser.TryConvert(rawValue, ref value)) - { - value = default(T); - return false; - } - return true; - } - return false; - } - - bool ICodedInputStream.ReadSFixed32(ref int value) - { - return Read(ref value); - } - - bool ICodedInputStream.ReadSFixed64(ref long value) - { - return Read(ref value); - } - - bool ICodedInputStream.ReadSInt32(ref int value) - { - return Read(ref value); - } - - bool ICodedInputStream.ReadSInt64(ref long value) - { - return Read(ref value); - } - - void ICodedInputStream.ReadPrimitiveArray(FieldType fieldType, uint fieldTag, string fieldName, - ICollection list) - { - ReadArray(fieldType, fieldName, list); - } - - void ICodedInputStream.ReadEnumArray(uint fieldTag, string fieldName, ICollection list, - out ICollection unknown, IEnumLiteMap mapping) - { - unknown = null; - List array = new List(); - if (ReadEnumArray(fieldName, array)) - { - foreach (object rawValue in array) - { - IEnumLite item = null; - if (rawValue is int) - { - item = mapping.FindValueByNumber((int) rawValue); - } - else if (rawValue is string) - { - item = mapping.FindValueByName((string) rawValue); - } - - if (item != null) - { - list.Add(item); - } - else - { - if (unknown == null) - { - unknown = new List(); - } - unknown.Add(rawValue); - } - } - } - } - - void ICodedInputStream.ReadEnumArray(uint fieldTag, string fieldName, ICollection list, - out ICollection unknown) - { - unknown = null; - List array = new List(); - if (ReadEnumArray(fieldName, array)) - { - foreach (object rawValue in array) - { - T val = default(T); - if (EnumParser.TryConvert(rawValue, ref val)) - { - list.Add(val); - } - else - { - if (unknown == null) - { - unknown = new List(); - } - unknown.Add(rawValue); - } - } - } - } - - void ICodedInputStream.ReadMessageArray(uint fieldTag, string fieldName, ICollection list, T messageType, - ExtensionRegistry registry) - { - if (_depth++ > MaxDepth) - { - throw new RecursionLimitExceededException(); - } - ReadMessageArray(fieldName, list, messageType, registry); - _depth--; - } - - void ICodedInputStream.ReadGroupArray(uint fieldTag, string fieldName, ICollection list, T messageType, - ExtensionRegistry registry) - { - if (_depth++ > MaxDepth) - { - throw new RecursionLimitExceededException(); - } - ReadGroupArray(fieldName, list, messageType, registry); - _depth--; - } - - bool ICodedInputStream.ReadPrimitiveField(FieldType fieldType, ref object value) - { - return ReadField(fieldType, ref value); - } - - bool ICodedInputStream.IsAtEnd - { - get - { - string next; - return PeekNext(out next) == false; - } - } - - bool ICodedInputStream.SkipField() - { - Skip(); - return true; - } - - void ICodedInputStream.ReadStringArray(uint fieldTag, string fieldName, ICollection list) - { - ReadArray(FieldType.String, fieldName, list); - } - - void ICodedInputStream.ReadBytesArray(uint fieldTag, string fieldName, ICollection list) - { - ReadArray(FieldType.Bytes, fieldName, list); - } - - void ICodedInputStream.ReadBoolArray(uint fieldTag, string fieldName, ICollection list) - { - ReadArray(FieldType.Bool, fieldName, list); - } - - void ICodedInputStream.ReadInt32Array(uint fieldTag, string fieldName, ICollection list) - { - ReadArray(FieldType.Int32, fieldName, list); - } - - void ICodedInputStream.ReadSInt32Array(uint fieldTag, string fieldName, ICollection list) - { - ReadArray(FieldType.SInt32, fieldName, list); - } - - void ICodedInputStream.ReadUInt32Array(uint fieldTag, string fieldName, ICollection list) - { - ReadArray(FieldType.UInt32, fieldName, list); - } - - void ICodedInputStream.ReadFixed32Array(uint fieldTag, string fieldName, ICollection list) - { - ReadArray(FieldType.Fixed32, fieldName, list); - } - - void ICodedInputStream.ReadSFixed32Array(uint fieldTag, string fieldName, ICollection list) - { - ReadArray(FieldType.SFixed32, fieldName, list); - } - - void ICodedInputStream.ReadInt64Array(uint fieldTag, string fieldName, ICollection list) - { - ReadArray(FieldType.Int64, fieldName, list); - } - - void ICodedInputStream.ReadSInt64Array(uint fieldTag, string fieldName, ICollection list) - { - ReadArray(FieldType.SInt64, fieldName, list); - } - - void ICodedInputStream.ReadUInt64Array(uint fieldTag, string fieldName, ICollection list) - { - ReadArray(FieldType.UInt64, fieldName, list); - } - - void ICodedInputStream.ReadFixed64Array(uint fieldTag, string fieldName, ICollection list) - { - ReadArray(FieldType.Fixed64, fieldName, list); - } - - void ICodedInputStream.ReadSFixed64Array(uint fieldTag, string fieldName, ICollection list) - { - ReadArray(FieldType.SFixed64, fieldName, list); - } - - void ICodedInputStream.ReadDoubleArray(uint fieldTag, string fieldName, ICollection list) - { - ReadArray(FieldType.Double, fieldName, list); - } - - void ICodedInputStream.ReadFloatArray(uint fieldTag, string fieldName, ICollection list) - { - ReadArray(FieldType.Float, fieldName, list); - } - - #endregion - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers.Serialization/AbstractTextReader.cs b/csharp/src/ProtocolBuffers.Serialization/AbstractTextReader.cs deleted file mode 100644 index 41578fab..00000000 --- a/csharp/src/ProtocolBuffers.Serialization/AbstractTextReader.cs +++ /dev/null @@ -1,175 +0,0 @@ -using System; -using System.Globalization; -using System.Xml; - -namespace Google.ProtocolBuffers.Serialization -{ - /// - /// Provides a base class for text-parsing readers - /// - public abstract class AbstractTextReader : AbstractReader - { - /// Constructs a new reader - protected AbstractTextReader() { } - - /// - /// Reads a typed field as a string - /// - protected abstract bool ReadAsText(ref string textValue, Type type); - - /// - /// Returns true if it was able to read a String from the input - /// - protected override bool Read(ref string value) - { - string text = null; - if (ReadAsText(ref text, typeof(string))) - { - value = text; - return true; - } - return false; - } - - /// - /// Returns true if it was able to read a Boolean from the input - /// - protected override bool Read(ref bool value) - { - string text = null; - if (ReadAsText(ref text, typeof(bool))) - { - value = XmlConvert.ToBoolean(text); - return true; - } - return false; - } - - /// - /// Returns true if it was able to read a Int32 from the input - /// - protected override bool Read(ref int value) - { - string text = null; - if (ReadAsText(ref text, typeof(int))) - { - value = XmlConvert.ToInt32(text); - return true; - } - return false; - } - - /// - /// Returns true if it was able to read a UInt32 from the input - /// - protected override bool Read(ref uint value) - { - string text = null; - if (ReadAsText(ref text, typeof(uint))) - { - value = XmlConvert.ToUInt32(text); - return true; - } - return false; - } - - /// - /// Returns true if it was able to read a Int64 from the input - /// - protected override bool Read(ref long value) - { - string text = null; - if (ReadAsText(ref text, typeof(long))) - { - value = XmlConvert.ToInt64(text); - return true; - } - return false; - } - - /// - /// Returns true if it was able to read a UInt64 from the input - /// - protected override bool Read(ref ulong value) - { - string text = null; - if (ReadAsText(ref text, typeof(ulong))) - { - value = XmlConvert.ToUInt64(text); - return true; - } - return false; - } - - /// - /// Returns true if it was able to read a Single from the input - /// - protected override bool Read(ref float value) - { - string text = null; - if (ReadAsText(ref text, typeof(float))) - { - value = XmlConvert.ToSingle(text); - return true; - } - return false; - } - - /// - /// Returns true if it was able to read a Double from the input - /// - protected override bool Read(ref double value) - { - string text = null; - if (ReadAsText(ref text, typeof(double))) - { - value = XmlConvert.ToDouble(text); - return true; - } - return false; - } - - /// - /// Provides decoding of bytes read from the input stream - /// - protected virtual ByteString DecodeBytes(string bytes) - { - return ByteString.FromBase64(bytes); - } - - /// - /// Returns true if it was able to read a ByteString from the input - /// - protected override bool Read(ref ByteString value) - { - string text = null; - if (ReadAsText(ref text, typeof(ByteString))) - { - value = DecodeBytes(text); - return true; - } - return false; - } - - /// - /// returns true if it was able to read a single value into the value reference. The value - /// stored may be of type System.String, System.Int32, or an IEnumLite from the IEnumLiteMap. - /// - protected override bool ReadEnum(ref object value) - { - string text = null; - if (ReadAsText(ref text, typeof(Enum))) - { - int number; - if (FrameworkPortability.TryParseInt32(text, NumberStyles.Integer, FrameworkPortability.InvariantCulture, out number)) - { - value = number; - return true; - } - value = text; - return true; - } - return false; - } - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers.Serialization/AbstractTextWriter.cs b/csharp/src/ProtocolBuffers.Serialization/AbstractTextWriter.cs deleted file mode 100644 index e13cbbab..00000000 --- a/csharp/src/ProtocolBuffers.Serialization/AbstractTextWriter.cs +++ /dev/null @@ -1,104 +0,0 @@ -using System; -using System.Xml; - -namespace Google.ProtocolBuffers.Serialization -{ - /// - /// Provides a base class for text writers - /// - public abstract class AbstractTextWriter : AbstractWriter - { - /// - /// Encodes raw bytes to be written to the stream - /// - protected virtual string EncodeBytes(ByteString bytes) - { - return bytes.ToBase64(); - } - - /// - /// Writes a typed field as a text value - /// - protected abstract void WriteAsText(string field, string textValue, object typedValue); - - /// - /// Writes a String value - /// - protected override void Write(string field, string value) - { - WriteAsText(field, value, value); - } - - /// - /// Writes a Boolean value - /// - protected override void Write(string field, bool value) - { - WriteAsText(field, XmlConvert.ToString(value), value); - } - - /// - /// Writes a Int32 value - /// - protected override void Write(string field, int value) - { - WriteAsText(field, XmlConvert.ToString(value), value); - } - - /// - /// Writes a UInt32 value - /// - protected override void Write(string field, uint value) - { - WriteAsText(field, XmlConvert.ToString(value), value); - } - - /// - /// Writes a Int64 value - /// - protected override void Write(string field, long value) - { - WriteAsText(field, XmlConvert.ToString(value), value); - } - - /// - /// Writes a UInt64 value - /// - protected override void Write(string field, ulong value) - { - WriteAsText(field, XmlConvert.ToString(value), value); - } - - /// - /// Writes a Single value - /// - protected override void Write(string field, float value) - { - WriteAsText(field, XmlConvert.ToString(value), value); - } - - /// - /// Writes a Double value - /// - protected override void Write(string field, double value) - { - WriteAsText(field, XmlConvert.ToString(value), value); - } - - /// - /// Writes a set of bytes - /// - protected override void Write(string field, ByteString value) - { - WriteAsText(field, EncodeBytes(value), value); - } - - /// - /// Writes a System.Enum by the numeric and textual value - /// - protected override void WriteEnum(string field, int number, string name) - { - WriteAsText(field, name, number); - } - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers.Serialization/AbstractWriter.cs b/csharp/src/ProtocolBuffers.Serialization/AbstractWriter.cs deleted file mode 100644 index f4cfe3e1..00000000 --- a/csharp/src/ProtocolBuffers.Serialization/AbstractWriter.cs +++ /dev/null @@ -1,503 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Globalization; -using Google.ProtocolBuffers.Descriptors; - -//Disable CS3011: only CLS-compliant members can be abstract -#pragma warning disable 3011 - -namespace Google.ProtocolBuffers.Serialization -{ - /// - /// Provides a base class for writers that performs some basic type dispatching - /// - public abstract class AbstractWriter : ICodedOutputStream - { - /// - /// Completes any pending write operations - /// - public virtual void Flush() - { - } - - /// - /// Writes the message to the the formatted stream. - /// - public abstract void WriteMessage(IMessageLite message); - - /// - /// Used to write any nessary root-message preamble. After this call you can call - /// IMessageLite.MergeTo(...) and complete the message with a call to WriteMessageEnd(). - /// These three calls are identical to just calling WriteMessage(message); - /// - /// - /// AbstractWriter writer; - /// writer.WriteMessageStart(); - /// message.WriteTo(writer); - /// writer.WriteMessageEnd(); - /// // ... or, but not both ... - /// writer.WriteMessage(message); - /// - public abstract void WriteMessageStart(); - - /// - /// Used to complete a root-message previously started with a call to WriteMessageStart() - /// - public abstract void WriteMessageEnd(); - - /// - /// Writes a Boolean value - /// - protected abstract void Write(string field, Boolean value); - - /// - /// Writes a Int32 value - /// - protected abstract void Write(string field, Int32 value); - - /// - /// Writes a UInt32 value - /// - protected abstract void Write(string field, UInt32 value); - - /// - /// Writes a Int64 value - /// - protected abstract void Write(string field, Int64 value); - - /// - /// Writes a UInt64 value - /// - protected abstract void Write(string field, UInt64 value); - - /// - /// Writes a Single value - /// - protected abstract void Write(string field, Single value); - - /// - /// Writes a Double value - /// - protected abstract void Write(string field, Double value); - - /// - /// Writes a String value - /// - protected abstract void Write(string field, String value); - - /// - /// Writes a set of bytes - /// - protected abstract void Write(string field, ByteString value); - - /// - /// Writes a message or group as a field - /// - protected abstract void WriteMessageOrGroup(string field, IMessageLite message); - - /// - /// Writes a System.Enum by the numeric and textual value - /// - protected abstract void WriteEnum(string field, int number, string name); - - /// - /// Writes a field of the type determined by field.FieldType - /// - protected virtual void WriteField(FieldType fieldType, string field, object value) - { - switch (fieldType) - { - case FieldType.Bool: - Write(field, (bool) value); - break; - case FieldType.Int64: - case FieldType.SInt64: - case FieldType.SFixed64: - Write(field, (long) value); - break; - case FieldType.UInt64: - case FieldType.Fixed64: - Write(field, (ulong) value); - break; - case FieldType.Int32: - case FieldType.SInt32: - case FieldType.SFixed32: - Write(field, (int) value); - break; - case FieldType.UInt32: - case FieldType.Fixed32: - Write(field, (uint) value); - break; - case FieldType.Float: - Write(field, (float) value); - break; - case FieldType.Double: - Write(field, (double) value); - break; - case FieldType.String: - Write(field, (string) value); - break; - case FieldType.Bytes: - Write(field, (ByteString) value); - break; - case FieldType.Group: - WriteMessageOrGroup(field, (IMessageLite) value); - break; - case FieldType.Message: - WriteMessageOrGroup(field, (IMessageLite) value); - break; - case FieldType.Enum: - { - if (value is IEnumLite) - { - WriteEnum(field, ((IEnumLite) value).Number, ((IEnumLite) value).Name); - } - else if (value is IConvertible) - { - WriteEnum(field, ((IConvertible)value).ToInt32(FrameworkPortability.InvariantCulture), - ((IConvertible)value).ToString(FrameworkPortability.InvariantCulture)); - } - else - { - throw new ArgumentException("Expected an Enum type for field " + field); - } - break; - } - default: - throw InvalidProtocolBufferException.InvalidTag(); - } - } - - /// - /// Writes an array of field values - /// - protected virtual void WriteArray(FieldType fieldType, string field, IEnumerable items) - { - foreach (object obj in items) - { - WriteField(fieldType, field, obj); - } - } - - /// - /// Writes a numeric unknown field of wire type: Fixed32, Fixed64, or Variant - /// - protected virtual void WriteUnknown(WireFormat.WireType wireType, int fieldNumber, ulong value) - { - } - - /// - /// Writes an unknown field, Expect WireType of GroupStart or LengthPrefix - /// - protected virtual void WriteUnknown(WireFormat.WireType wireType, int fieldNumber, ByteString value) - { - } - - #region ICodedOutputStream Members - - void ICodedOutputStream.WriteUnknownGroup(int fieldNumber, IMessageLite value) - { - } - - void ICodedOutputStream.WriteUnknownBytes(int fieldNumber, ByteString value) - { - } - - void ICodedOutputStream.WriteUnknownField(int fieldNumber, WireFormat.WireType type, ulong value) - { - } - - void ICodedOutputStream.WriteMessageSetExtension(int fieldNumber, string fieldName, IMessageLite value) - { - } - - void ICodedOutputStream.WriteMessageSetExtension(int fieldNumber, string fieldName, ByteString value) - { - } - - void ICodedOutputStream.WriteField(FieldType fieldType, int fieldNumber, string fieldName, object value) - { - WriteField(fieldType, fieldName, value); - } - - void ICodedOutputStream.WriteDouble(int fieldNumber, string fieldName, double value) - { - Write(fieldName, value); - } - - void ICodedOutputStream.WriteFloat(int fieldNumber, string fieldName, float value) - { - Write(fieldName, value); - } - - void ICodedOutputStream.WriteUInt64(int fieldNumber, string fieldName, ulong value) - { - Write(fieldName, value); - } - - void ICodedOutputStream.WriteInt64(int fieldNumber, string fieldName, long value) - { - Write(fieldName, value); - } - - void ICodedOutputStream.WriteInt32(int fieldNumber, string fieldName, int value) - { - Write(fieldName, value); - } - - void ICodedOutputStream.WriteFixed64(int fieldNumber, string fieldName, ulong value) - { - Write(fieldName, value); - } - - void ICodedOutputStream.WriteFixed32(int fieldNumber, string fieldName, uint value) - { - Write(fieldName, value); - } - - void ICodedOutputStream.WriteBool(int fieldNumber, string fieldName, bool value) - { - Write(fieldName, value); - } - - void ICodedOutputStream.WriteString(int fieldNumber, string fieldName, string value) - { - Write(fieldName, value); - } - - void ICodedOutputStream.WriteGroup(int fieldNumber, string fieldName, IMessageLite value) - { - WriteMessageOrGroup(fieldName, value); - } - - void ICodedOutputStream.WriteMessage(int fieldNumber, string fieldName, IMessageLite value) - { - WriteMessageOrGroup(fieldName, value); - } - - void ICodedOutputStream.WriteBytes(int fieldNumber, string fieldName, ByteString value) - { - Write(fieldName, value); - } - - void ICodedOutputStream.WriteUInt32(int fieldNumber, string fieldName, uint value) - { - Write(fieldName, value); - } - - void ICodedOutputStream.WriteEnum(int fieldNumber, string fieldName, int value, object rawValue) - { - WriteEnum(fieldName, value, rawValue.ToString()); - } - - void ICodedOutputStream.WriteSFixed32(int fieldNumber, string fieldName, int value) - { - Write(fieldName, value); - } - - void ICodedOutputStream.WriteSFixed64(int fieldNumber, string fieldName, long value) - { - Write(fieldName, value); - } - - void ICodedOutputStream.WriteSInt32(int fieldNumber, string fieldName, int value) - { - Write(fieldName, value); - } - - void ICodedOutputStream.WriteSInt64(int fieldNumber, string fieldName, long value) - { - Write(fieldName, value); - } - - - void ICodedOutputStream.WriteArray(FieldType fieldType, int fieldNumber, string fieldName, IEnumerable list) - { - WriteArray(fieldType, fieldName, list); - } - - void ICodedOutputStream.WriteGroupArray(int fieldNumber, string fieldName, IEnumerable list) - { - WriteArray(FieldType.Group, fieldName, list); - } - - void ICodedOutputStream.WriteMessageArray(int fieldNumber, string fieldName, IEnumerable list) - { - WriteArray(FieldType.Message, fieldName, list); - } - - void ICodedOutputStream.WriteStringArray(int fieldNumber, string fieldName, IEnumerable list) - { - WriteArray(FieldType.String, fieldName, list); - } - - void ICodedOutputStream.WriteBytesArray(int fieldNumber, string fieldName, IEnumerable list) - { - WriteArray(FieldType.Bytes, fieldName, list); - } - - void ICodedOutputStream.WriteBoolArray(int fieldNumber, string fieldName, IEnumerable list) - { - WriteArray(FieldType.Bool, fieldName, list); - } - - void ICodedOutputStream.WriteInt32Array(int fieldNumber, string fieldName, IEnumerable list) - { - WriteArray(FieldType.Int32, fieldName, list); - } - - void ICodedOutputStream.WriteSInt32Array(int fieldNumber, string fieldName, IEnumerable list) - { - WriteArray(FieldType.SInt32, fieldName, list); - } - - void ICodedOutputStream.WriteUInt32Array(int fieldNumber, string fieldName, IEnumerable list) - { - WriteArray(FieldType.UInt32, fieldName, list); - } - - void ICodedOutputStream.WriteFixed32Array(int fieldNumber, string fieldName, IEnumerable list) - { - WriteArray(FieldType.Fixed32, fieldName, list); - } - - void ICodedOutputStream.WriteSFixed32Array(int fieldNumber, string fieldName, IEnumerable list) - { - WriteArray(FieldType.SFixed32, fieldName, list); - } - - void ICodedOutputStream.WriteInt64Array(int fieldNumber, string fieldName, IEnumerable list) - { - WriteArray(FieldType.Int64, fieldName, list); - } - - void ICodedOutputStream.WriteSInt64Array(int fieldNumber, string fieldName, IEnumerable list) - { - WriteArray(FieldType.SInt64, fieldName, list); - } - - void ICodedOutputStream.WriteUInt64Array(int fieldNumber, string fieldName, IEnumerable list) - { - WriteArray(FieldType.UInt64, fieldName, list); - } - - void ICodedOutputStream.WriteFixed64Array(int fieldNumber, string fieldName, IEnumerable list) - { - WriteArray(FieldType.Fixed64, fieldName, list); - } - - void ICodedOutputStream.WriteSFixed64Array(int fieldNumber, string fieldName, IEnumerable list) - { - WriteArray(FieldType.SFixed64, fieldName, list); - } - - void ICodedOutputStream.WriteDoubleArray(int fieldNumber, string fieldName, IEnumerable list) - { - WriteArray(FieldType.Double, fieldName, list); - } - - void ICodedOutputStream.WriteFloatArray(int fieldNumber, string fieldName, IEnumerable list) - { - WriteArray(FieldType.Float, fieldName, list); - } - - void ICodedOutputStream.WriteEnumArray(int fieldNumber, string fieldName, IEnumerable list) - { - WriteArray(FieldType.Enum, fieldName, list); - } - - void ICodedOutputStream.WritePackedArray(FieldType fieldType, int fieldNumber, string fieldName, - IEnumerable list) - { - WriteArray(fieldType, fieldName, list); - } - - - void ICodedOutputStream.WritePackedBoolArray(int fieldNumber, string fieldName, int computedSize, - IEnumerable list) - { - WriteArray(FieldType.Bool, fieldName, list); - } - - void ICodedOutputStream.WritePackedInt32Array(int fieldNumber, string fieldName, int computedSize, - IEnumerable list) - { - WriteArray(FieldType.Int32, fieldName, list); - } - - void ICodedOutputStream.WritePackedSInt32Array(int fieldNumber, string fieldName, int computedSize, - IEnumerable list) - { - WriteArray(FieldType.SInt32, fieldName, list); - } - - void ICodedOutputStream.WritePackedUInt32Array(int fieldNumber, string fieldName, int computedSize, - IEnumerable list) - { - WriteArray(FieldType.UInt32, fieldName, list); - } - - void ICodedOutputStream.WritePackedFixed32Array(int fieldNumber, string fieldName, int computedSize, - IEnumerable list) - { - WriteArray(FieldType.Fixed32, fieldName, list); - } - - void ICodedOutputStream.WritePackedSFixed32Array(int fieldNumber, string fieldName, int computedSize, - IEnumerable list) - { - WriteArray(FieldType.SFixed32, fieldName, list); - } - - void ICodedOutputStream.WritePackedInt64Array(int fieldNumber, string fieldName, int computedSize, - IEnumerable list) - { - WriteArray(FieldType.Int64, fieldName, list); - } - - void ICodedOutputStream.WritePackedSInt64Array(int fieldNumber, string fieldName, int computedSize, - IEnumerable list) - { - WriteArray(FieldType.SInt64, fieldName, list); - } - - void ICodedOutputStream.WritePackedUInt64Array(int fieldNumber, string fieldName, int computedSize, - IEnumerable list) - { - WriteArray(FieldType.UInt64, fieldName, list); - } - - void ICodedOutputStream.WritePackedFixed64Array(int fieldNumber, string fieldName, int computedSize, - IEnumerable list) - { - WriteArray(FieldType.Fixed64, fieldName, list); - } - - void ICodedOutputStream.WritePackedSFixed64Array(int fieldNumber, string fieldName, int computedSize, - IEnumerable list) - { - WriteArray(FieldType.SFixed64, fieldName, list); - } - - void ICodedOutputStream.WritePackedDoubleArray(int fieldNumber, string fieldName, int computedSize, - IEnumerable list) - { - WriteArray(FieldType.Double, fieldName, list); - } - - void ICodedOutputStream.WritePackedFloatArray(int fieldNumber, string fieldName, int computedSize, - IEnumerable list) - { - WriteArray(FieldType.Float, fieldName, list); - } - - void ICodedOutputStream.WritePackedEnumArray(int fieldNumber, string fieldName, int computedSize, - IEnumerable list) - { - WriteArray(FieldType.Enum, fieldName, list); - } - - #endregion - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers.Serialization/DictionaryReader.cs b/csharp/src/ProtocolBuffers.Serialization/DictionaryReader.cs deleted file mode 100644 index 971d0fee..00000000 --- a/csharp/src/ProtocolBuffers.Serialization/DictionaryReader.cs +++ /dev/null @@ -1,265 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using Google.ProtocolBuffers.Descriptors; - -namespace Google.ProtocolBuffers.Serialization -{ - /// - /// Allows reading messages from a name/value dictionary - /// - public class DictionaryReader : AbstractReader - { - private readonly IEnumerator> _input; - private bool _ready; - - /// - /// Creates a dictionary reader from an enumeration of KeyValuePair data, like an IDictionary - /// - public DictionaryReader(IEnumerable> input) - { - _input = input.GetEnumerator(); - _ready = _input.MoveNext(); - } - - /// - /// No-op - /// - public override void ReadMessageStart() - { } - - /// - /// No-op - /// - public override void ReadMessageEnd() - { } - - /// - /// Merges the contents of stream into the provided message builder - /// - public override TBuilder Merge(TBuilder builder, ExtensionRegistry registry) - { - builder.WeakMergeFrom(this, registry); - return builder; - } - - /// - /// Peeks at the next field in the input stream and returns what information is available. - /// - /// - /// This may be called multiple times without actually reading the field. Only after the field - /// is either read, or skipped, should PeekNext return a different value. - /// - protected override bool PeekNext(out string field) - { - field = _ready ? _input.Current.Key : null; - return _ready; - } - - /// - /// Causes the reader to skip past this field - /// - protected override void Skip() - { - _ready = _input.MoveNext(); - } - - private bool GetValue(ref T value) - { - if (!_ready) - { - return false; - } - - object obj = _input.Current.Value; - if (obj is T) - { - value = (T) obj; - } - else - { - try - { - if (obj is IConvertible) - { - value = (T)Convert.ChangeType(obj, typeof(T), FrameworkPortability.InvariantCulture); - } - else - { - value = (T) obj; - } - } - catch - { - _ready = _input.MoveNext(); - return false; - } - } - _ready = _input.MoveNext(); - return true; - } - - /// - /// Returns true if it was able to read a Boolean from the input - /// - protected override bool Read(ref bool value) - { - return GetValue(ref value); - } - - /// - /// Returns true if it was able to read a Int32 from the input - /// - protected override bool Read(ref int value) - { - return GetValue(ref value); - } - - /// - /// Returns true if it was able to read a UInt32 from the input - /// - protected override bool Read(ref uint value) - { - return GetValue(ref value); - } - - /// - /// Returns true if it was able to read a Int64 from the input - /// - protected override bool Read(ref long value) - { - return GetValue(ref value); - } - - /// - /// Returns true if it was able to read a UInt64 from the input - /// - protected override bool Read(ref ulong value) - { - return GetValue(ref value); - } - - /// - /// Returns true if it was able to read a Single from the input - /// - protected override bool Read(ref float value) - { - return GetValue(ref value); - } - - /// - /// Returns true if it was able to read a Double from the input - /// - protected override bool Read(ref double value) - { - return GetValue(ref value); - } - - /// - /// Returns true if it was able to read a String from the input - /// - protected override bool Read(ref string value) - { - return GetValue(ref value); - } - - /// - /// Returns true if it was able to read a ByteString from the input - /// - protected override bool Read(ref ByteString value) - { - byte[] rawbytes = null; - if (GetValue(ref rawbytes)) - { - value = ByteString.CopyFrom(rawbytes); - return true; - } - return false; - } - - /// - /// returns true if it was able to read a single value into the value reference. The value - /// stored may be of type System.String, System.Int32, or an IEnumLite from the IEnumLiteMap. - /// - protected override bool ReadEnum(ref object value) - { - return GetValue(ref value); - } - - /// - /// Merges the input stream into the provided IBuilderLite - /// - protected override bool ReadMessage(IBuilderLite builder, ExtensionRegistry registry) - { - IDictionary values = null; - if (GetValue(ref values)) - { - new DictionaryReader(values).Merge(builder, registry); - return true; - } - return false; - } - - public override bool ReadArray(FieldType type, string field, ICollection items) - { - object[] array = null; - if (GetValue(ref array)) - { - if (typeof(T) == typeof(ByteString)) - { - ICollection output = (ICollection) items; - foreach (byte[] item in array) - { - output.Add(ByteString.CopyFrom(item)); - } - } - else - { - foreach (T item in array) - { - items.Add(item); - } - } - return true; - } - return false; - } - - public override bool ReadEnumArray(string field, ICollection items) - { - object[] array = null; - if (GetValue(ref array)) - { - foreach (object item in array) - { - items.Add(item); - } - return true; - } - return false; - } - - public override bool ReadMessageArray(string field, ICollection items, IMessageLite messageType, - ExtensionRegistry registry) - { - object[] array = null; - if (GetValue(ref array)) - { - foreach (IDictionary item in array) - { - IBuilderLite builder = messageType.WeakCreateBuilderForType(); - new DictionaryReader(item).Merge(builder); - items.Add((T) builder.WeakBuild()); - } - return true; - } - return false; - } - - public override bool ReadGroupArray(string field, ICollection items, IMessageLite messageType, - ExtensionRegistry registry) - { - return ReadMessageArray(field, items, messageType, registry); - } - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers.Serialization/DictionaryWriter.cs b/csharp/src/ProtocolBuffers.Serialization/DictionaryWriter.cs deleted file mode 100644 index 8cc8ed6b..00000000 --- a/csharp/src/ProtocolBuffers.Serialization/DictionaryWriter.cs +++ /dev/null @@ -1,200 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using Google.ProtocolBuffers.Descriptors; - -namespace Google.ProtocolBuffers.Serialization -{ - /// - /// Allows writing messages to a name/value dictionary - /// - public class DictionaryWriter : AbstractWriter - { - private readonly IDictionary _output; - - /// - /// Constructs a writer using a new dictionary - /// - public DictionaryWriter() - : this(new Dictionary(StringComparer.Ordinal)) - { - } - - /// - /// Constructs a writer using an existing dictionary - /// - public DictionaryWriter(IDictionary output) - { - ThrowHelper.ThrowIfNull(output, "output"); - _output = output; - } - - /// - /// Creates the dictionary instance for a child message. - /// - protected virtual DictionaryWriter Create() - { - return new DictionaryWriter(); - } - - /// - /// Accesses the dictionary that is backing this writer - /// - public IDictionary ToDictionary() - { - return _output; - } - - /// - /// Writes the message to the the formatted stream. - /// - public override void WriteMessage(IMessageLite message) - { - message.WriteTo(this); - } - - - /// - /// No-op - /// - public override void WriteMessageStart() - { } - - /// - /// No-op - /// - public override void WriteMessageEnd() - { } - - /// - /// Writes a Boolean value - /// - protected override void Write(string field, bool value) - { - _output[field] = value; - } - - /// - /// Writes a Int32 value - /// - protected override void Write(string field, int value) - { - _output[field] = value; - } - - /// - /// Writes a UInt32 value - /// - protected override void Write(string field, uint value) - { - _output[field] = value; - } - - /// - /// Writes a Int64 value - /// - protected override void Write(string field, long value) - { - _output[field] = value; - } - - /// - /// Writes a UInt64 value - /// - protected override void Write(string field, ulong value) - { - _output[field] = value; - } - - /// - /// Writes a Single value - /// - protected override void Write(string field, float value) - { - _output[field] = value; - } - - /// - /// Writes a Double value - /// - protected override void Write(string field, double value) - { - _output[field] = value; - } - - /// - /// Writes a String value - /// - protected override void Write(string field, string value) - { - _output[field] = value; - } - - /// - /// Writes a set of bytes - /// - protected override void Write(string field, ByteString value) - { - _output[field] = value.ToByteArray(); - } - - /// - /// Writes a message or group as a field - /// - protected override void WriteMessageOrGroup(string field, IMessageLite message) - { - DictionaryWriter writer = Create(); - writer.WriteMessage(message); - - _output[field] = writer.ToDictionary(); - } - - /// - /// Writes a System.Enum by the numeric and textual value - /// - protected override void WriteEnum(string field, int number, string name) - { - _output[field] = number; - } - - /// - /// Writes an array of field values - /// - protected override void WriteArray(FieldType fieldType, string field, IEnumerable items) - { - List objects = new List(); - foreach (object o in items) - { - switch (fieldType) - { - case FieldType.Group: - case FieldType.Message: - { - DictionaryWriter writer = Create(); - writer.WriteMessage((IMessageLite) o); - objects.Add(writer.ToDictionary()); - } - break; - case FieldType.Bytes: - objects.Add(((ByteString) o).ToByteArray()); - break; - case FieldType.Enum: - if (o is IEnumLite) - { - objects.Add(((IEnumLite) o).Number); - } - else - { - objects.Add((int) o); - } - break; - default: - objects.Add(o); - break; - } - } - - _output[field] = objects.ToArray(); - } - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers.Serialization/Extensions.cs b/csharp/src/ProtocolBuffers.Serialization/Extensions.cs deleted file mode 100644 index 63ac98d8..00000000 --- a/csharp/src/ProtocolBuffers.Serialization/Extensions.cs +++ /dev/null @@ -1,185 +0,0 @@ -using System; -using System.Text; -using System.IO; -using System.Xml; -using Google.ProtocolBuffers.Serialization; -using Google.ProtocolBuffers.Serialization.Http; - -namespace Google.ProtocolBuffers -{ - /// - /// Extension methods for using serializers on instances of IMessageLite/IBuilderLite - /// - public static class Extensions - { - #region IMessageLite Extension - /// - /// Serializes the message to JSON text. This is a trivial wrapper - /// around Serialization.JsonFormatWriter.WriteMessage. - /// - public static string ToJson( -#if !NOEXTENSIONS - this -#endif - IMessageLite message) - { - JsonFormatWriter w = JsonFormatWriter.CreateInstance(); - w.WriteMessage(message); - return w.ToString(); - } - /// - /// Serializes the message to XML text. This is a trivial wrapper - /// around Serialization.XmlFormatWriter.WriteMessage. - /// - public static string ToXml( -#if !NOEXTENSIONS - this -#endif - IMessageLite message) - { - StringWriter w = new StringWriter(new StringBuilder(4096)); - XmlFormatWriter.CreateInstance(w).WriteMessage(message); - return w.ToString(); - } - /// - /// Serializes the message to XML text using the element name provided. - /// This is a trivial wrapper around Serialization.XmlFormatWriter.WriteMessage. - /// - public static string ToXml( -#if !NOEXTENSIONS - this -#endif - IMessageLite message, string rootElementName) - { - StringWriter w = new StringWriter(new StringBuilder(4096)); - XmlFormatWriter.CreateInstance(w).WriteMessage(rootElementName, message); - return w.ToString(); - } - - /// - /// Writes the message instance to the stream using the content type provided - /// - /// An instance of a message - /// Options specific to writing this message and/or content type - /// The mime type of the content to be written - /// The stream to write the message to - public static void WriteTo( -#if !NOEXTENSIONS - this -#endif - IMessageLite message, MessageFormatOptions options, string contentType, Stream output) - { - ICodedOutputStream codedOutput = MessageFormatFactory.CreateOutputStream(options, contentType, output); - - // Output the appropriate message preamble - codedOutput.WriteMessageStart(); - - // Write the message content to the output - message.WriteTo(codedOutput); - - // Write the closing message fragment - codedOutput.WriteMessageEnd(); - codedOutput.Flush(); - } - - #endregion - #region IBuilderLite Extensions - /// - /// Merges a JSON object into this builder and returns - /// - public static TBuilder MergeFromJson( -#if !NOEXTENSIONS - this -#endif - TBuilder builder, string jsonText) where TBuilder : IBuilderLite - { - return JsonFormatReader.CreateInstance(jsonText) - .Merge(builder); - } - /// - /// Merges a JSON object into this builder and returns - /// - public static TBuilder MergeFromJson( -#if !NOEXTENSIONS - this -#endif - TBuilder builder, TextReader reader) where TBuilder : IBuilderLite - { - return MergeFromJson(builder, reader, ExtensionRegistry.Empty); - } - /// - /// Merges a JSON object into this builder using the extensions provided and returns - /// - public static TBuilder MergeFromJson( -#if !NOEXTENSIONS - this -#endif - TBuilder builder, TextReader reader, ExtensionRegistry extensionRegistry) where TBuilder : IBuilderLite - { - return JsonFormatReader.CreateInstance(reader) - .Merge(builder, extensionRegistry); - } - - /// - /// Merges an XML object into this builder and returns - /// - public static TBuilder MergeFromXml( -#if !NOEXTENSIONS - this -#endif - TBuilder builder, XmlReader reader) where TBuilder : IBuilderLite - { - return MergeFromXml(builder, XmlFormatReader.DefaultRootElementName, reader, ExtensionRegistry.Empty); - } - - /// - /// Merges an XML object into this builder and returns - /// - public static TBuilder MergeFromXml( -#if !NOEXTENSIONS - this -#endif - TBuilder builder, string rootElementName, XmlReader reader) where TBuilder : IBuilderLite - { - return MergeFromXml(builder, rootElementName, reader, ExtensionRegistry.Empty); - } - - /// - /// Merges an XML object into this builder using the extensions provided and returns - /// - public static TBuilder MergeFromXml( -#if !NOEXTENSIONS - this -#endif - TBuilder builder, string rootElementName, XmlReader reader, - ExtensionRegistry extensionRegistry) where TBuilder : IBuilderLite - { - return XmlFormatReader.CreateInstance(reader) - .Merge(rootElementName, builder, extensionRegistry); - } - - /// - /// Merges the message from the input stream based on the contentType provided - /// - /// A type derived from IBuilderLite - /// An instance of a message builder - /// Options specific to reading this message and/or content type - /// The mime type of the input stream content - /// The stream to read the message from - /// The same builder instance that was supplied in the builder parameter - public static TBuilder MergeFrom( -#if !NOEXTENSIONS - this -#endif - TBuilder builder, MessageFormatOptions options, string contentType, Stream input) where TBuilder : IBuilderLite - { - ICodedInputStream codedInput = MessageFormatFactory.CreateInputStream(options, contentType, input); - codedInput.ReadMessageStart(); - builder.WeakMergeFrom(codedInput, options.ExtensionRegistry); - codedInput.ReadMessageEnd(); - return builder; - } - - #endregion - } -} diff --git a/csharp/src/ProtocolBuffers.Serialization/Http/FormUrlEncodedReader.cs b/csharp/src/ProtocolBuffers.Serialization/Http/FormUrlEncodedReader.cs deleted file mode 100644 index 508d76a9..00000000 --- a/csharp/src/ProtocolBuffers.Serialization/Http/FormUrlEncodedReader.cs +++ /dev/null @@ -1,162 +0,0 @@ -using System; -using System.IO; -using System.Text; - -namespace Google.ProtocolBuffers.Serialization.Http -{ - /// - /// Allows reading messages from a name/value dictionary - /// - public class FormUrlEncodedReader : AbstractTextReader - { - private readonly TextReader _input; - private string _fieldName, _fieldValue; - private bool _ready; - - /// - /// Creates a dictionary reader from an enumeration of KeyValuePair data, like an IDictionary - /// - FormUrlEncodedReader(TextReader input) - { - _input = input; - int ch = input.Peek(); - if (ch == '?') - { - input.Read(); - } - _ready = ReadNext(); - } - - #region CreateInstance overloads - /// - /// Constructs a FormUrlEncodedReader to parse form data, or url query text into a message. - /// - public static FormUrlEncodedReader CreateInstance(Stream stream) - { - return new FormUrlEncodedReader(new StreamReader(stream, Encoding.UTF8, false)); - } - - /// - /// Constructs a FormUrlEncodedReader to parse form data, or url query text into a message. - /// - public static FormUrlEncodedReader CreateInstance(byte[] bytes) - { - return new FormUrlEncodedReader(new StreamReader(new MemoryStream(bytes, false), Encoding.UTF8, false)); - } - - /// - /// Constructs a FormUrlEncodedReader to parse form data, or url query text into a message. - /// - public static FormUrlEncodedReader CreateInstance(string text) - { - return new FormUrlEncodedReader(new StringReader(text)); - } - - /// - /// Constructs a FormUrlEncodedReader to parse form data, or url query text into a message. - /// - public static FormUrlEncodedReader CreateInstance(TextReader input) - { - return new FormUrlEncodedReader(input); - } - #endregion - - private bool ReadNext() - { - StringBuilder field = new StringBuilder(32); - StringBuilder value = new StringBuilder(64); - int ch; - while (-1 != (ch = _input.Read()) && ch != '=' && ch != '&') - { - field.Append((char)ch); - } - - if (ch != -1 && ch != '&') - { - while (-1 != (ch = _input.Read()) && ch != '&') - { - value.Append((char)ch); - } - } - - _fieldName = field.ToString(); - _fieldValue = Uri.UnescapeDataString(value.Replace('+', ' ').ToString()); - - return !String.IsNullOrEmpty(_fieldName); - } - - /// - /// No-op - /// - public override void ReadMessageStart() - { } - - /// - /// No-op - /// - public override void ReadMessageEnd() - { } - - /// - /// Merges the contents of stream into the provided message builder - /// - public override TBuilder Merge(TBuilder builder, ExtensionRegistry registry) - { - builder.WeakMergeFrom(this, registry); - return builder; - } - - /// - /// Causes the reader to skip past this field - /// - protected override void Skip() - { - _ready = ReadNext(); - } - - /// - /// Peeks at the next field in the input stream and returns what information is available. - /// - /// - /// This may be called multiple times without actually reading the field. Only after the field - /// is either read, or skipped, should PeekNext return a different value. - /// - protected override bool PeekNext(out string field) - { - field = _ready ? _fieldName : null; - return field != null; - } - - /// - /// Returns true if it was able to read a String from the input - /// - protected override bool ReadAsText(ref string value, Type typeInfo) - { - if (_ready) - { - value = _fieldValue; - _ready = ReadNext(); - return true; - } - return false; - } - - /// - /// It's unlikely this will work for anything but text data as bytes UTF8 are transformed to text and back to bytes - /// - protected override ByteString DecodeBytes(string bytes) - { return ByteString.CopyFromUtf8(bytes); } - - /// - /// Not Supported - /// - public override bool ReadGroup(IBuilderLite value, ExtensionRegistry registry) - { throw new NotSupportedException(); } - - /// - /// Not Supported - /// - protected override bool ReadMessage(IBuilderLite builder, ExtensionRegistry registry) - { throw new NotSupportedException(); } - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers.Serialization/Http/MessageFormatFactory.cs b/csharp/src/ProtocolBuffers.Serialization/Http/MessageFormatFactory.cs deleted file mode 100644 index 270af64b..00000000 --- a/csharp/src/ProtocolBuffers.Serialization/Http/MessageFormatFactory.cs +++ /dev/null @@ -1,112 +0,0 @@ -using System; -using System.IO; -using System.Xml; -using System.Text; - -namespace Google.ProtocolBuffers.Serialization.Http -{ - /// - /// Extensions and helpers to abstract the reading/writing of messages by a client-specified content type. - /// - public static class MessageFormatFactory - { - /// - /// Constructs an ICodedInputStream from the input stream based on the contentType provided - /// - /// Options specific to reading this message and/or content type - /// The mime type of the input stream content - /// The stream to read the message from - /// The ICodedInputStream that can be given to the IBuilder.MergeFrom(...) method - public static ICodedInputStream CreateInputStream(MessageFormatOptions options, string contentType, Stream input) - { - ICodedInputStream codedInput = ContentTypeToInputStream(contentType, options, input); - - if (codedInput is XmlFormatReader) - { - XmlFormatReader reader = (XmlFormatReader)codedInput; - reader.RootElementName = options.XmlReaderRootElementName; - reader.Options = options.XmlReaderOptions; - } - - return codedInput; - } - - /// - /// Writes the message instance to the stream using the content type provided - /// - /// Options specific to writing this message and/or content type - /// The mime type of the content to be written - /// The stream to write the message to - /// If you do not dispose of ICodedOutputStream some formats may yield incomplete output - public static ICodedOutputStream CreateOutputStream(MessageFormatOptions options, string contentType, Stream output) - { - ICodedOutputStream codedOutput = ContentTypeToOutputStream(contentType, options, output); - - if (codedOutput is JsonFormatWriter) - { - JsonFormatWriter writer = (JsonFormatWriter)codedOutput; - if (options.FormattedOutput) - { - writer.Formatted(); - } - } - else if (codedOutput is XmlFormatWriter) - { - XmlFormatWriter writer = (XmlFormatWriter)codedOutput; - if (options.FormattedOutput) - { - XmlWriterSettings settings = new XmlWriterSettings() - { - CheckCharacters = false, - NewLineHandling = NewLineHandling.Entitize, - OmitXmlDeclaration = true, - Encoding = new UTF8Encoding(false), - Indent = true, - IndentChars = " ", - }; - // Don't know how else to change xml writer options? - codedOutput = writer = XmlFormatWriter.CreateInstance(XmlWriter.Create(output, settings)); - } - writer.RootElementName = options.XmlWriterRootElementName; - writer.Options = options.XmlWriterOptions; - } - - return codedOutput; - } - - private static ICodedInputStream ContentTypeToInputStream(string contentType, MessageFormatOptions options, Stream input) - { - contentType = (contentType ?? String.Empty).Split(';')[0].Trim(); - - CodedInputBuilder factory; - if(!options.MimeInputTypesReadOnly.TryGetValue(contentType, out factory) || factory == null) - { - if(String.IsNullOrEmpty(options.DefaultContentType) || - !options.MimeInputTypesReadOnly.TryGetValue(options.DefaultContentType, out factory) || factory == null) - { - throw new ArgumentOutOfRangeException("contentType"); - } - } - - return factory(input); - } - - private static ICodedOutputStream ContentTypeToOutputStream(string contentType, MessageFormatOptions options, Stream output) - { - contentType = (contentType ?? String.Empty).Split(';')[0].Trim(); - - CodedOutputBuilder factory; - if (!options.MimeOutputTypesReadOnly.TryGetValue(contentType, out factory) || factory == null) - { - if (String.IsNullOrEmpty(options.DefaultContentType) || - !options.MimeOutputTypesReadOnly.TryGetValue(options.DefaultContentType, out factory) || factory == null) - { - throw new ArgumentOutOfRangeException("contentType"); - } - } - - return factory(output); - } - - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers.Serialization/Http/MessageFormatOptions.cs b/csharp/src/ProtocolBuffers.Serialization/Http/MessageFormatOptions.cs deleted file mode 100644 index 1480e50a..00000000 --- a/csharp/src/ProtocolBuffers.Serialization/Http/MessageFormatOptions.cs +++ /dev/null @@ -1,176 +0,0 @@ -using System; -using System.IO; -using System.Collections.Generic; -using Google.ProtocolBuffers.Collections; - -namespace Google.ProtocolBuffers.Serialization.Http -{ - /// - /// A delegate used to specify a method that constructs an ICodedInputStream from a .NET Stream. - /// - public delegate ICodedInputStream CodedInputBuilder(Stream stream); - /// - /// A delegate used to specify a method that constructs an ICodedOutputStream from a .NET Stream. - /// - public delegate ICodedOutputStream CodedOutputBuilder(Stream stream); - - /// - /// Defines control information for the various formatting used with HTTP services - /// - public class MessageFormatOptions - { - /// The mime type for xml content - /// Other valid xml mime types include: application/binary, application/x-protobuf - public const string ContentTypeProtoBuffer = "application/vnd.google.protobuf"; - - /// The mime type for xml content - /// Other valid xml mime types include: text/xml - public const string ContentTypeXml = "application/xml"; - - /// The mime type for json content - /// - /// Other valid json mime types include: application/json, application/x-json, - /// application/x-javascript, text/javascript, text/x-javascript, text/x-json, text/json - /// - public const string ContentTypeJson = "application/json"; - - /// The mime type for query strings and x-www-form-urlencoded content - /// This mime type is input-only - public const string ContentFormUrlEncoded = "application/x-www-form-urlencoded"; - - /// - /// Default mime-type handling for input - /// - private static readonly IDictionary MimeInputDefaults = - new ReadOnlyDictionary( - new Dictionary(StringComparer.OrdinalIgnoreCase) - { - {"application/json", JsonFormatReader.CreateInstance}, - {"application/x-json", JsonFormatReader.CreateInstance}, - {"application/x-javascript", JsonFormatReader.CreateInstance}, - {"text/javascript", JsonFormatReader.CreateInstance}, - {"text/x-javascript", JsonFormatReader.CreateInstance}, - {"text/x-json", JsonFormatReader.CreateInstance}, - {"text/json", JsonFormatReader.CreateInstance}, - {"text/xml", XmlFormatReader.CreateInstance}, - {"application/xml", XmlFormatReader.CreateInstance}, - {"application/binary", CodedInputStream.CreateInstance}, - {"application/x-protobuf", CodedInputStream.CreateInstance}, - {"application/vnd.google.protobuf", CodedInputStream.CreateInstance}, - {"application/x-www-form-urlencoded", FormUrlEncodedReader.CreateInstance}, - } - ); - - /// - /// Default mime-type handling for output - /// - private static readonly IDictionary MimeOutputDefaults = - new ReadOnlyDictionary( - new Dictionary(StringComparer.OrdinalIgnoreCase) - { - {"application/json", JsonFormatWriter.CreateInstance}, - {"application/x-json", JsonFormatWriter.CreateInstance}, - {"application/x-javascript", JsonFormatWriter.CreateInstance}, - {"text/javascript", JsonFormatWriter.CreateInstance}, - {"text/x-javascript", JsonFormatWriter.CreateInstance}, - {"text/x-json", JsonFormatWriter.CreateInstance}, - {"text/json", JsonFormatWriter.CreateInstance}, - {"text/xml", XmlFormatWriter.CreateInstance}, - {"application/xml", XmlFormatWriter.CreateInstance}, - {"application/binary", CodedOutputStream.CreateInstance}, - {"application/x-protobuf", CodedOutputStream.CreateInstance}, - {"application/vnd.google.protobuf", CodedOutputStream.CreateInstance}, - } - ); - - - - - private string _defaultContentType; - private string _xmlReaderRootElementName; - private string _xmlWriterRootElementName; - private ExtensionRegistry _extensionRegistry; - private Dictionary _mimeInputTypes; - private Dictionary _mimeOutputTypes; - - /// Provides access to modify the mime-type input stream construction - public IDictionary MimeInputTypes - { - get - { - return _mimeInputTypes ?? - (_mimeInputTypes = new Dictionary( - MimeInputDefaults, StringComparer.OrdinalIgnoreCase)); - } - } - - /// Provides access to modify the mime-type input stream construction - public IDictionary MimeOutputTypes - { - get - { - return _mimeOutputTypes ?? - (_mimeOutputTypes = new Dictionary( - MimeOutputDefaults, StringComparer.OrdinalIgnoreCase)); - } - } - - internal IDictionary MimeInputTypesReadOnly - { get { return _mimeInputTypes ?? MimeInputDefaults; } } - - internal IDictionary MimeOutputTypesReadOnly - { get { return _mimeOutputTypes ?? MimeOutputDefaults; } } - - /// - /// The default content type to use if the input type is null or empty. If this - /// value is not supplied an ArgumentOutOfRangeException exception will be raised. - /// - public string DefaultContentType - { - get { return _defaultContentType ?? String.Empty; } - set { _defaultContentType = value; } - } - - /// - /// The extension registry to use when reading messages - /// - public ExtensionRegistry ExtensionRegistry - { - get { return _extensionRegistry ?? ExtensionRegistry.Empty; } - set { _extensionRegistry = value; } - } - - /// - /// The name of the xml root element when reading messages - /// - public string XmlReaderRootElementName - { - get { return _xmlReaderRootElementName ?? XmlFormatReader.DefaultRootElementName; } - set { _xmlReaderRootElementName = value; } - } - - /// - /// Xml reader options - /// - public XmlReaderOptions XmlReaderOptions { get; set; } - - /// - /// True to use formatted output including new-lines and default indentation - /// - public bool FormattedOutput { get; set; } - - /// - /// The name of the xml root element when writing messages - /// - public string XmlWriterRootElementName - { - get { return _xmlWriterRootElementName ?? XmlFormatWriter.DefaultRootElementName; } - set { _xmlWriterRootElementName = value; } - } - - /// - /// Xml writer options - /// - public XmlWriterOptions XmlWriterOptions { get; set; } - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers.Serialization/JsonFormatReader.cs b/csharp/src/ProtocolBuffers.Serialization/JsonFormatReader.cs deleted file mode 100644 index 423196d8..00000000 --- a/csharp/src/ProtocolBuffers.Serialization/JsonFormatReader.cs +++ /dev/null @@ -1,262 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Xml; - -namespace Google.ProtocolBuffers.Serialization -{ - /// - /// JsonFormatReader is used to parse Json into a message or an array of messages - /// - public class JsonFormatReader : AbstractTextReader - { - private readonly JsonCursor _input; - // The expected token that ends the current item, either ']' or '}' - private readonly Stack _stopChar; - - private enum ReaderState - { - Start, - BeginValue, - EndValue, - BeginObject, - BeginArray - } - - private string _current; - private ReaderState _state; - - /// - /// Constructs a JsonFormatReader to parse Json into a message, this method does not use text encoding, all bytes MUST - /// represent ASCII character values. - /// - public static JsonFormatReader CreateInstance(Stream stream) - { - return new JsonFormatReader(JsonCursor.CreateInstance(stream)); - } - - /// - /// Constructs a JsonFormatReader to parse Json into a message, this method does not use text encoding, all bytes MUST - /// represent ASCII character values. - /// - public static JsonFormatReader CreateInstance(byte[] bytes) - { - return new JsonFormatReader(JsonCursor.CreateInstance(bytes)); - } - - /// - /// Constructs a JsonFormatReader to parse Json into a message - /// - public static JsonFormatReader CreateInstance(string jsonText) - { - return new JsonFormatReader(JsonCursor.CreateInstance(jsonText)); - } - - /// - /// Constructs a JsonFormatReader to parse Json into a message - /// - public static JsonFormatReader CreateInstance(TextReader input) - { - return new JsonFormatReader(JsonCursor.CreateInstance(input)); - } - - /// - /// Constructs a JsonFormatReader to parse Json into a message - /// - internal JsonFormatReader(JsonCursor input) - { - _input = input; - _stopChar = new Stack(); - _stopChar.Push(-1); - _state = ReaderState.Start; - } - - /// - /// Constructs a JsonFormatReader to parse Json into a message - /// - protected JsonFormatReader(TextReader input) - : this(JsonCursor.CreateInstance(input)) - { - } - - /// - /// Returns true if the reader is currently on an array element - /// - public bool IsArrayMessage - { - get { return _input.NextChar == '['; } - } - - /// - /// Returns an enumerator that is used to cursor over an array of messages - /// - /// - /// This is generally used when receiving an array of messages rather than a single root message - /// - public IEnumerable EnumerateArray() - { - foreach (string ignored in ForeachArrayItem(_current)) - { - yield return this; - } - } - - /// - /// Reads the root-message preamble specific to this formatter - /// - public override void ReadMessageStart() - { - _input.Consume('{'); - _stopChar.Push('}'); - - _state = ReaderState.BeginObject; - } - - /// - /// Reads the root-message close specific to this formatter - /// - public override void ReadMessageEnd() - { - _input.Consume((char)_stopChar.Pop()); - _state = ReaderState.EndValue; - } - - /// - /// Merges the contents of stream into the provided message builder - /// - public override TBuilder Merge(TBuilder builder, ExtensionRegistry registry) - { - ReadMessageStart(); - builder.WeakMergeFrom(this, registry); - ReadMessageEnd(); - return builder; - } - - /// - /// Causes the reader to skip past this field - /// - protected override void Skip() - { - object temp; - _input.ReadVariant(out temp); - _state = ReaderState.EndValue; - } - - /// - /// Peeks at the next field in the input stream and returns what information is available. - /// - /// - /// This may be called multiple times without actually reading the field. Only after the field - /// is either read, or skipped, should PeekNext return a different value. - /// - protected override bool PeekNext(out string field) - { - field = _current; - if (_state == ReaderState.BeginValue) - { - return true; - } - - int next = _input.NextChar; - if (next == _stopChar.Peek()) - { - return false; - } - - _input.Assert(next != -1, "Unexpected end of file."); - - //not sure about this yet, it will allow {, "a":true } - if (_state == ReaderState.EndValue && !_input.TryConsume(',')) - { - return false; - } - - field = _current = _input.ReadString(); - _input.Consume(':'); - _state = ReaderState.BeginValue; - return true; - } - - /// - /// Returns true if it was able to read a String from the input - /// - protected override bool ReadAsText(ref string value, Type typeInfo) - { - object temp; - JsonCursor.JsType type = _input.ReadVariant(out temp); - _state = ReaderState.EndValue; - - _input.Assert(type != JsonCursor.JsType.Array && type != JsonCursor.JsType.Object, - "Encountered {0} while expecting {1}", type, typeInfo); - if (type == JsonCursor.JsType.Null) - { - return false; - } - if (type == JsonCursor.JsType.True) - { - value = "1"; - } - else if (type == JsonCursor.JsType.False) - { - value = "0"; - } - else - { - value = temp as string; - } - - //exponent representation of integer number: - if (value != null && type == JsonCursor.JsType.Number && - (typeInfo != typeof(double) && typeInfo != typeof(float)) && - value.IndexOf("e", StringComparison.OrdinalIgnoreCase) > 0) - { - value = XmlConvert.ToString((long) Math.Round(XmlConvert.ToDouble(value), 0)); - } - return value != null; - } - - /// - /// Returns true if it was able to read a ByteString from the input - /// - protected override bool Read(ref ByteString value) - { - string bytes = null; - if (Read(ref bytes)) - { - value = ByteString.FromBase64(bytes); - return true; - } - return false; - } - - /// - /// Cursors through the array elements and stops at the end of the array - /// - protected override IEnumerable ForeachArrayItem(string field) - { - _input.Consume('['); - _stopChar.Push(']'); - _state = ReaderState.BeginArray; - while (_input.NextChar != ']') - { - _current = field; - yield return field; - if (!_input.TryConsume(',')) - { - break; - } - } - _input.Consume((char) _stopChar.Pop()); - _state = ReaderState.EndValue; - } - - /// - /// Merges the input stream into the provided IBuilderLite - /// - protected override bool ReadMessage(IBuilderLite builder, ExtensionRegistry registry) - { - Merge(builder, registry); - return true; - } - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers.Serialization/JsonFormatWriter.cs b/csharp/src/ProtocolBuffers.Serialization/JsonFormatWriter.cs deleted file mode 100644 index 15e0424e..00000000 --- a/csharp/src/ProtocolBuffers.Serialization/JsonFormatWriter.cs +++ /dev/null @@ -1,541 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.IO; -using System.Text; -using Google.ProtocolBuffers.Descriptors; - -namespace Google.ProtocolBuffers.Serialization -{ - /// - /// JsonFormatWriter is a .NET 2.0 friendly json formatter for proto buffer messages. For .NET 3.5 - /// you may also use the XmlFormatWriter with an XmlWriter created by the - /// JsonReaderWriterFactory. - /// - public abstract class JsonFormatWriter : AbstractTextWriter - { - #region buffering implementations - - private class JsonTextWriter : JsonFormatWriter - { - private readonly char[] _buffer; - private TextWriter _output; - private int _bufferPos; - - public JsonTextWriter(TextWriter output) - { - _buffer = new char[4096]; - _bufferPos = 0; - _output = output; - _counter.Add(0); - } - - /// - /// Returns the output of TextWriter.ToString() where TextWriter is the ctor argument. - /// - public override string ToString() - { - Flush(); - - if (_output != null) - { - return _output.ToString(); - } - - return new String(_buffer, 0, _bufferPos); - } - - protected override void WriteToOutput(char[] chars, int offset, int len) - { - if (_bufferPos + len >= _buffer.Length) - { - if (_output == null) - { - _output = new StringWriter(new StringBuilder(_buffer.Length*2 + len)); - } - Flush(); - } - - if (len < _buffer.Length) - { - if (len <= 12) - { - int stop = offset + len; - for (int i = offset; i < stop; i++) - { - _buffer[_bufferPos++] = chars[i]; - } - } - else - { - Buffer.BlockCopy(chars, offset << 1, _buffer, _bufferPos << 1, len << 1); - _bufferPos += len; - } - } - else - { - _output.Write(chars, offset, len); - } - } - - protected override void WriteToOutput(char ch) - { - if (_bufferPos >= _buffer.Length) - { - if (_output == null) - { - _output = new StringWriter(new StringBuilder(_buffer.Length * 2)); - } - Flush(); - } - _buffer[_bufferPos++] = ch; - } - - public override void Flush() - { - if (_bufferPos > 0 && _output != null) - { - _output.Write(_buffer, 0, _bufferPos); - _bufferPos = 0; - } - base.Flush(); - } - } - - private class JsonStreamWriter : JsonFormatWriter - { - static readonly Encoding Encoding = new UTF8Encoding(false); - private readonly byte[] _buffer; - private Stream _output; - private int _bufferPos; - - public JsonStreamWriter(Stream output) - { - _buffer = new byte[8192]; - _bufferPos = 0; - _output = output; - _counter.Add(0); - } - - protected override void WriteToOutput(char[] chars, int offset, int len) - { - if (_bufferPos + len >= _buffer.Length) - { - Flush(); - } - - if (len < _buffer.Length) - { - if (len <= 12) - { - int stop = offset + len; - for (int i = offset; i < stop; i++) - { - _buffer[_bufferPos++] = (byte) chars[i]; - } - } - else - { - _bufferPos += Encoding.GetBytes(chars, offset, len, _buffer, _bufferPos); - } - } - else - { - byte[] temp = Encoding.GetBytes(chars, offset, len); - _output.Write(temp, 0, temp.Length); - } - } - - protected override void WriteToOutput(char ch) - { - if (_bufferPos >= _buffer.Length) - { - Flush(); - } - _buffer[_bufferPos++] = (byte) ch; - } - - public override void Flush() - { - if (_bufferPos > 0 && _output != null) - { - _output.Write(_buffer, 0, _bufferPos); - _bufferPos = 0; - } - base.Flush(); - } - } - - #endregion - - //Tracks the writer depth and the array element count at that depth. - private readonly List _counter; - //True if the top-level of the writer is an array as opposed to a single message. - private bool _isArray; - - /// - /// Constructs a JsonFormatWriter, use the ToString() member to extract the final Json on completion. - /// - protected JsonFormatWriter() - { - _counter = new List(); - } - - /// - /// Constructs a JsonFormatWriter, use ToString() to extract the final output - /// - public static JsonFormatWriter CreateInstance() - { - return new JsonTextWriter(null); - } - - /// - /// Constructs a JsonFormatWriter to output to the given text writer - /// - public static JsonFormatWriter CreateInstance(TextWriter output) - { - return new JsonTextWriter(output); - } - - /// - /// Constructs a JsonFormatWriter to output to the given stream - /// - public static JsonFormatWriter CreateInstance(Stream output) - { - return new JsonStreamWriter(output); - } - - /// Write to the output stream - protected void WriteToOutput(string format, params object[] args) - { - WriteToOutput(String.Format(format, args)); - } - - /// Write to the output stream - protected void WriteToOutput(string text) - { - WriteToOutput(text.ToCharArray(), 0, text.Length); - } - - /// Write to the output stream - protected abstract void WriteToOutput(char ch); - - /// Write to the output stream - protected abstract void WriteToOutput(char[] chars, int offset, int len); - - /// Sets the output formatting to use Environment.NewLine with 4-character indentions - public JsonFormatWriter Formatted() - { - NewLine = FrameworkPortability.NewLine; - Indent = " "; - Whitespace = " "; - return this; - } - - /// Gets or sets the characters to use for the new-line, default = empty - public string NewLine { get; set; } - - /// Gets or sets the text to use for indenting, default = empty - public string Indent { get; set; } - - /// Gets or sets the whitespace to use to separate the text, default = empty - public string Whitespace { get; set; } - - private void Seperator() - { - if (_counter.Count == 0) - { - throw new InvalidOperationException("Mismatched open/close in Json writer."); - } - - int index = _counter.Count - 1; - if (_counter[index] > 0) - { - WriteToOutput(','); - } - - WriteLine(String.Empty); - _counter[index] = _counter[index] + 1; - } - - private void WriteLine(string content) - { - if (!String.IsNullOrEmpty(NewLine)) - { - WriteToOutput(NewLine); - for (int i = 1; i < _counter.Count; i++) - { - WriteToOutput(Indent); - } - } - else if (!String.IsNullOrEmpty(Whitespace)) - { - WriteToOutput(Whitespace); - } - - WriteToOutput(content); - } - - private void WriteName(string field) - { - Seperator(); - if (!String.IsNullOrEmpty(field)) - { - WriteToOutput('"'); - WriteToOutput(field); - WriteToOutput('"'); - WriteToOutput(':'); - if (!String.IsNullOrEmpty(Whitespace)) - { - WriteToOutput(Whitespace); - } - } - } - - private void EncodeText(string value) - { - char[] text = value.ToCharArray(); - int len = text.Length; - int pos = 0; - - while (pos < len) - { - int next = pos; - while (next < len && text[next] >= 32 && text[next] < 127 && text[next] != '\\' && text[next] != '/' && - text[next] != '"') - { - next++; - } - WriteToOutput(text, pos, next - pos); - if (next < len) - { - switch (text[next]) - { - case '"': - WriteToOutput(@"\"""); - break; - case '\\': - WriteToOutput(@"\\"); - break; - //odd at best to escape '/', most Json implementations don't, but it is defined in the rfc-4627 - case '/': - WriteToOutput(@"\/"); - break; - case '\b': - WriteToOutput(@"\b"); - break; - case '\f': - WriteToOutput(@"\f"); - break; - case '\n': - WriteToOutput(@"\n"); - break; - case '\r': - WriteToOutput(@"\r"); - break; - case '\t': - WriteToOutput(@"\t"); - break; - default: - WriteToOutput(@"\u{0:x4}", (int) text[next]); - break; - } - next++; - } - pos = next; - } - } - - /// - /// Writes a String value - /// - protected override void WriteAsText(string field, string textValue, object typedValue) - { - WriteName(field); - if (typedValue is bool || typedValue is int || typedValue is uint || typedValue is long || - typedValue is ulong || typedValue is double || typedValue is float) - { - WriteToOutput(textValue); - } - else - { - WriteToOutput('"'); - if (typedValue is string) - { - EncodeText(textValue); - } - else - { - WriteToOutput(textValue); - } - WriteToOutput('"'); - } - } - - /// - /// Writes a Double value - /// - protected override void Write(string field, double value) - { - if (double.IsNaN(value) || double.IsNegativeInfinity(value) || double.IsPositiveInfinity(value)) - { - throw new InvalidOperationException("This format does not support NaN, Infinity, or -Infinity"); - } - base.Write(field, value); - } - - /// - /// Writes a Single value - /// - protected override void Write(string field, float value) - { - if (float.IsNaN(value) || float.IsNegativeInfinity(value) || float.IsPositiveInfinity(value)) - { - throw new InvalidOperationException("This format does not support NaN, Infinity, or -Infinity"); - } - base.Write(field, value); - } - - // Treat enum as string - protected override void WriteEnum(string field, int number, string name) - { - Write(field, name); - } - - /// - /// Writes an array of field values - /// - protected override void WriteArray(FieldType type, string field, IEnumerable items) - { - IEnumerator enumerator = items.GetEnumerator(); - try - { - if (!enumerator.MoveNext()) - { - return; - } - } - finally - { - if (enumerator is IDisposable) - { - ((IDisposable) enumerator).Dispose(); - } - } - - WriteName(field); - WriteToOutput("["); - _counter.Add(0); - - base.WriteArray(type, String.Empty, items); - - _counter.RemoveAt(_counter.Count - 1); - WriteLine("]"); - } - - /// - /// Writes a message - /// - protected override void WriteMessageOrGroup(string field, IMessageLite message) - { - WriteName(field); - WriteMessage(message); - } - - /// - /// Writes the message to the the formatted stream. - /// - public override void WriteMessage(IMessageLite message) - { - WriteMessageStart(); - message.WriteTo(this); - WriteMessageEnd(); - } - - /// - /// Used to write the root-message preamble, in json this is the left-curly brace '{'. - /// After this call you can call IMessageLite.MergeTo(...) and complete the message with - /// a call to WriteMessageEnd(). - /// - public override void WriteMessageStart() - { - if (_isArray) - { - Seperator(); - } - WriteToOutput("{"); - _counter.Add(0); - } - - /// - /// Used to complete a root-message previously started with a call to WriteMessageStart() - /// - public override void WriteMessageEnd() - { - _counter.RemoveAt(_counter.Count - 1); - WriteLine("}"); - Flush(); - } - - /// - /// Used in streaming arrays of objects to the writer - /// - /// - /// - /// using(writer.StartArray()) - /// foreach(IMessageLite m in messages) - /// writer.WriteMessage(m); - /// - /// - public sealed class JsonArray : IDisposable - { - private JsonFormatWriter _writer; - - internal JsonArray(JsonFormatWriter writer) - { - _writer = writer; - _writer.WriteToOutput("["); - _writer._counter.Add(0); - } - - /// - /// Causes the end of the array character to be written. - /// - private void EndArray() - { - if (_writer != null) - { - _writer._counter.RemoveAt(_writer._counter.Count - 1); - _writer.WriteLine("]"); - _writer.Flush(); - } - _writer = null; - } - - void IDisposable.Dispose() - { - EndArray(); - } - } - - /// - /// Used to write an array of messages as the output rather than a single message. - /// - /// - /// - /// using(writer.StartArray()) - /// foreach(IMessageLite m in messages) - /// writer.WriteMessage(m); - /// - /// - public JsonArray StartArray() - { - if (_isArray) - { - Seperator(); - } - _isArray = true; - return new JsonArray(this); - } - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers.Serialization/JsonTextCursor.cs b/csharp/src/ProtocolBuffers.Serialization/JsonTextCursor.cs deleted file mode 100644 index 19c45af7..00000000 --- a/csharp/src/ProtocolBuffers.Serialization/JsonTextCursor.cs +++ /dev/null @@ -1,442 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Globalization; -using System.IO; - -namespace Google.ProtocolBuffers.Serialization -{ - /// - /// JSon Tokenizer used by JsonFormatReader - /// - internal abstract class JsonCursor - { - public enum JsType - { - String, - Number, - Object, - Array, - True, - False, - Null - } - - #region Buffering implementations - - private class JsonStreamCursor : JsonCursor - { - private readonly byte[] _buffer; - private int _bufferPos; - private readonly Stream _input; - - public JsonStreamCursor(Stream input) - { - _input = input; - _next = _input.ReadByte(); - } - - public JsonStreamCursor(byte[] input) - { - _input = null; - _buffer = input; - _next = _buffer[_bufferPos]; - } - - protected override int Peek() - { - if (_input != null) - { - return _next; - } - else if (_bufferPos < _buffer.Length) - { - return _buffer[_bufferPos]; - } - else - { - return -1; - } - } - - protected override int Read() - { - if (_input != null) - { - int result = _next; - _next = _input.ReadByte(); - return result; - } - else if (_bufferPos < _buffer.Length) - { - return _buffer[_bufferPos++]; - } - else - { - return -1; - } - } - } - - private class JsonTextCursor : JsonCursor - { - private readonly char[] _buffer; - private int _bufferPos; - private readonly TextReader _input; - - public JsonTextCursor(char[] input) - { - _input = null; - _buffer = input; - _bufferPos = 0; - _next = Peek(); - } - - public JsonTextCursor(TextReader input) - { - _input = input; - _next = Peek(); - } - - protected override int Peek() - { - if (_input != null) - { - return _input.Peek(); - } - else if (_bufferPos < _buffer.Length) - { - return _buffer[_bufferPos]; - } - else - { - return -1; - } - } - - protected override int Read() - { - if (_input != null) - { - return _input.Read(); - } - else if (_bufferPos < _buffer.Length) - { - return _buffer[_bufferPos++]; - } - else - { - return -1; - } - } - } - - #endregion - - protected int _next; - private int _lineNo, _linePos; - - public static JsonCursor CreateInstance(byte[] input) - { - return new JsonStreamCursor(input); - } - - public static JsonCursor CreateInstance(Stream input) - { - return new JsonStreamCursor(input); - } - - public static JsonCursor CreateInstance(string input) - { - return new JsonTextCursor(input.ToCharArray()); - } - - public static JsonCursor CreateInstance(TextReader input) - { - return new JsonTextCursor(input); - } - - protected JsonCursor() - { - _lineNo = 1; - _linePos = 0; - } - - /// Returns the next character without actually 'reading' it - protected abstract int Peek(); - - /// Reads the next character in the input - protected abstract int Read(); - - public Char NextChar - { - get - { - SkipWhitespace(); - return (char) _next; - } - } - - #region Assert(...) - - [DebuggerNonUserCode] - private string CharDisplay(int ch) - { - return ch == -1 - ? "EOF" - : (ch > 32 && ch < 127) - ? String.Format("'{0}'", (char) ch) - : String.Format("'\\u{0:x4}'", ch); - } - - [DebuggerNonUserCode] - private void Assert(bool cond, char expected) - { - if (!cond) - { - throw new FormatException( - String.Format(FrameworkPortability.InvariantCulture, - "({0}:{1}) error: Unexpected token {2}, expected: {3}.", - _lineNo, _linePos, - CharDisplay(_next), - CharDisplay(expected) - )); - } - } - - [DebuggerNonUserCode] - public void Assert(bool cond, string message) - { - if (!cond) - { - throw new FormatException( - String.Format(FrameworkPortability.InvariantCulture, - "({0},{1}) error: {2}", _lineNo, _linePos, message)); - } - } - - [DebuggerNonUserCode] - public void Assert(bool cond, string format, params object[] args) - { - if (!cond) - { - if (args != null && args.Length > 0) - { - format = String.Format(format, args); - } - throw new FormatException( - String.Format(FrameworkPortability.InvariantCulture, - "({0},{1}) error: {2}", _lineNo, _linePos, format)); - } - } - - #endregion - - private char ReadChar() - { - int ch = Read(); - Assert(ch != -1, "Unexpected end of file."); - if (ch == '\n') - { - _lineNo++; - _linePos = 0; - } - else if (ch != '\r') - { - _linePos++; - } - _next = Peek(); - return (char) ch; - } - - public void Consume(char ch) - { - Assert(TryConsume(ch), ch); - } - - public bool TryConsume(char ch) - { - SkipWhitespace(); - if (_next == ch) - { - ReadChar(); - return true; - } - return false; - } - - public void Consume(string sequence) - { - SkipWhitespace(); - - foreach (char ch in sequence) - { - Assert(ch == ReadChar(), "Expected token '{0}'.", sequence); - } - } - - public void SkipWhitespace() - { - int chnext = _next; - while (chnext != -1) - { - if (!Char.IsWhiteSpace((char) chnext)) - { - break; - } - ReadChar(); - chnext = _next; - } - } - - public string ReadString() - { - SkipWhitespace(); - Consume('"'); - List sb = new List(100); - while (_next != '"') - { - if (_next == '\\') - { - Consume('\\'); //skip the escape - char ch = ReadChar(); - switch (ch) - { - case 'b': - sb.Add('\b'); - break; - case 'f': - sb.Add('\f'); - break; - case 'n': - sb.Add('\n'); - break; - case 'r': - sb.Add('\r'); - break; - case 't': - sb.Add('\t'); - break; - case 'u': - { - string hex = new string(new char[] {ReadChar(), ReadChar(), ReadChar(), ReadChar()}); - int result; - Assert( - FrameworkPortability.TryParseInt32(hex, NumberStyles.AllowHexSpecifier, FrameworkPortability.InvariantCulture, - out result), - "Expected a 4-character hex specifier."); - sb.Add((char) result); - break; - } - default: - sb.Add(ch); - break; - } - } - else - { - Assert(_next != '\n' && _next != '\r' && _next != '\f' && _next != -1, '"'); - sb.Add(ReadChar()); - } - } - Consume('"'); - return new String(sb.ToArray()); - } - - public string ReadNumber() - { - SkipWhitespace(); - List sb = new List(24); - if (_next == '-') - { - sb.Add(ReadChar()); - } - Assert(_next >= '0' && _next <= '9', "Expected a numeric type."); - while ((_next >= '0' && _next <= '9') || _next == '.') - { - sb.Add(ReadChar()); - } - if (_next == 'e' || _next == 'E') - { - sb.Add(ReadChar()); - if (_next == '-' || _next == '+') - { - sb.Add(ReadChar()); - } - Assert(_next >= '0' && _next <= '9', "Expected a numeric type."); - while (_next >= '0' && _next <= '9') - { - sb.Add(ReadChar()); - } - } - return new String(sb.ToArray()); - } - - public JsType ReadVariant(out object value) - { - SkipWhitespace(); - switch (_next) - { - case 'n': - Consume("null"); - value = null; - return JsType.Null; - case 't': - Consume("true"); - value = true; - return JsType.True; - case 'f': - Consume("false"); - value = false; - return JsType.False; - case '"': - value = ReadString(); - return JsType.String; - case '{': - { - Consume('{'); - while (NextChar != '}') - { - ReadString(); - Consume(':'); - object tmp; - ReadVariant(out tmp); - if (!TryConsume(',')) - { - break; - } - } - Consume('}'); - value = null; - return JsType.Object; - } - case '[': - { - Consume('['); - List values = new List(); - while (NextChar != ']') - { - object tmp; - ReadVariant(out tmp); - values.Add(tmp); - if (!TryConsume(',')) - { - break; - } - } - Consume(']'); - value = values.ToArray(); - return JsType.Array; - } - default: - if ((_next >= '0' && _next <= '9') || _next == '-') - { - value = ReadNumber(); - return JsType.Number; - } - Assert(false, "Expected a value."); - throw new FormatException(); - } - } - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers.Serialization/Properties/AssemblyInfo.cs b/csharp/src/ProtocolBuffers.Serialization/Properties/AssemblyInfo.cs deleted file mode 100644 index 0ab58120..00000000 --- a/csharp/src/ProtocolBuffers.Serialization/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,65 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/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. -using System; -using System.Reflection; -using System.Runtime.InteropServices; -using System.Runtime.CompilerServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. - -[assembly: AssemblyTitle("ProtocolBuffers")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("ProtocolBuffers")] -[assembly: AssemblyCopyright("Copyright © 2008")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("2.4.1.555")] - -[assembly: AssemblyVersion("2.4.1.555")] - -#if !NOFILEVERSION -[assembly: AssemblyFileVersion("2.4.1.555")] -#endif diff --git a/csharp/src/ProtocolBuffers.Serialization/ProtocolBuffers.Serialization.csproj b/csharp/src/ProtocolBuffers.Serialization/ProtocolBuffers.Serialization.csproj deleted file mode 100644 index 4ee41ab7..00000000 --- a/csharp/src/ProtocolBuffers.Serialization/ProtocolBuffers.Serialization.csproj +++ /dev/null @@ -1,93 +0,0 @@ - - - - Debug - AnyCPU - 9.0.30729 - 2.0 - {231391AF-449C-4A39-986C-AD7F270F4750} - Library - Properties - Google.ProtocolBuffers.Serialization - Google.ProtocolBuffers.Serialization - {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - Profile92 - v4.0 - 512 - true - ..\..\keys\Google.ProtocolBuffers.snk - 3.5 - - - true - full - false - bin\Debug - obj\Debug\ - $(OutputPath)\$(AssemblyName).xml - 1591, 1570, 1571, 1572, 1573, 1574 - DEBUG;TRACE;$(EnvironmentFlavor);$(EnvironmentTemplate) - prompt - 4 - true - Off - - - pdbonly - true - bin\Release - obj\Release\ - $(OutputPath)\$(AssemblyName).xml - 1591, 1570, 1571, 1572, 1573, 1574 - TRACE;$(EnvironmentFlavor);$(EnvironmentTemplate) - prompt - 4 - true - Off - - - - - - - - - - FrameworkPortability.cs - - - - - - - - - - - - - - - - - - - - - - - - {6908BDCE-D925-43F3-94AC-A531E6DF2591} - ProtocolBuffers - False - - - - - \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers.Serialization/ProtocolBuffersLite.Serialization.csproj b/csharp/src/ProtocolBuffers.Serialization/ProtocolBuffersLite.Serialization.csproj deleted file mode 100644 index 5faa74f6..00000000 --- a/csharp/src/ProtocolBuffers.Serialization/ProtocolBuffersLite.Serialization.csproj +++ /dev/null @@ -1,93 +0,0 @@ - - - - Debug - AnyCPU - 9.0.30729 - 2.0 - {E067A59D-9D0A-4A1F-92B1-38E4457241D1} - Library - Properties - Google.ProtocolBuffers.Serialization - Google.ProtocolBuffersLite.Serialization - {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - Profile92 - v4.0 - 512 - true - ..\..\keys\Google.ProtocolBuffers.snk - 3.5 - - - true - full - false - bin\Debug - obj\Debug\ - $(OutputPath)\$(AssemblyName).xml - 1591, 1570, 1571, 1572, 1573, 1574 - DEBUG;TRACE;LITE;$(EnvironmentFlavor);$(EnvironmentTemplate) - prompt - 4 - true - Off - - - pdbonly - true - bin\Release - obj\Release\ - $(OutputPath)\$(AssemblyName).xml - 1591, 1570, 1571, 1572, 1573, 1574 - TRACE;LITE;$(EnvironmentFlavor);$(EnvironmentTemplate) - prompt - 4 - true - Off - - - - - - - - - - FrameworkPortability.cs - - - - - - - - - - - - - - - - - - - - - - - - {6969BDCE-D925-43F3-94AC-A531E6DF2591} - ProtocolBuffersLite - False - - - - - \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers.Serialization/RecursionLimitExceeded.cs b/csharp/src/ProtocolBuffers.Serialization/RecursionLimitExceeded.cs deleted file mode 100644 index 14e72ba8..00000000 --- a/csharp/src/ProtocolBuffers.Serialization/RecursionLimitExceeded.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Google.ProtocolBuffers.Serialization -{ - /// - /// The exception raised when a recursion limit is reached while parsing input. - /// - public sealed class RecursionLimitExceededException : FormatException - { - const string message = "Possible malicious message had too many levels of nesting."; - - internal RecursionLimitExceededException() : base(message) - { - } - } -} diff --git a/csharp/src/ProtocolBuffers.Serialization/XmlFormatReader.cs b/csharp/src/ProtocolBuffers.Serialization/XmlFormatReader.cs deleted file mode 100644 index a4f111d4..00000000 --- a/csharp/src/ProtocolBuffers.Serialization/XmlFormatReader.cs +++ /dev/null @@ -1,338 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Xml; -using System.Diagnostics; - -namespace Google.ProtocolBuffers.Serialization -{ - /// - /// Parses a proto buffer from an XML document or fragment. .NET 3.5 users may also - /// use this class to process Json by setting the options to support Json and providing - /// an XmlReader obtained from . - /// - public class XmlFormatReader : AbstractTextReader - { - public const string DefaultRootElementName = XmlFormatWriter.DefaultRootElementName; - private readonly XmlReader _input; - // Tracks the message element for each nested message read - private readonly Stack _elements; - // The default element name for ReadMessageStart - private string _rootElementName; - - private struct ElementStackEntry - { - public readonly string LocalName; - public readonly int Depth; - public readonly bool IsEmpty; - - public ElementStackEntry(string localName, int depth, bool isEmpty) : this() - { - LocalName = localName; - IsEmpty = isEmpty; - Depth = depth; - } - } - - private static XmlReaderSettings DefaultSettings - { - get - { - return new XmlReaderSettings() - {CheckCharacters = false, IgnoreComments = true, IgnoreProcessingInstructions = true}; - } - } - - /// - /// Constructs the XmlFormatReader using the stream provided as the xml - /// - public static XmlFormatReader CreateInstance(byte[] input) - { - return new XmlFormatReader(XmlReader.Create(new MemoryStream(input, false), DefaultSettings)); - } - - /// - /// Constructs the XmlFormatReader using the stream provided as the xml - /// - public static XmlFormatReader CreateInstance(Stream input) - { - return new XmlFormatReader(XmlReader.Create(input, DefaultSettings)); - } - - /// - /// Constructs the XmlFormatReader using the string provided as the xml to be read - /// - public static XmlFormatReader CreateInstance(String input) - { - return new XmlFormatReader(XmlReader.Create(new StringReader(input), DefaultSettings)); - } - - /// - /// Constructs the XmlFormatReader using the xml in the TextReader - /// - public static XmlFormatReader CreateInstance(TextReader input) - { - return new XmlFormatReader(XmlReader.Create(input, DefaultSettings)); - } - - /// - /// Constructs the XmlFormatReader with the XmlReader - /// - public static XmlFormatReader CreateInstance(XmlReader input) - { - return new XmlFormatReader(input); - } - - /// - /// Constructs the XmlFormatReader with the XmlReader and options - /// - protected XmlFormatReader(XmlReader input) - { - _input = input; - _rootElementName = DefaultRootElementName; - _elements = new Stack(); - Options = XmlReaderOptions.None; - } - - /// - /// Gets or sets the options to use when reading the xml - /// - public XmlReaderOptions Options { get; set; } - - /// - /// Sets the options to use while generating the XML - /// - public XmlFormatReader SetOptions(XmlReaderOptions options) - { - Options = options; - return this; - } - - /// - /// Gets or sets the default element name to use when using the Merge<TBuilder>() - /// - public string RootElementName - { - get { return _rootElementName; } - set - { - ThrowHelper.ThrowIfNull(value, "RootElementName"); - _rootElementName = value; - } - } - - [DebuggerNonUserCode] - private static void Assert(bool cond) - { - if (!cond) - { - throw new FormatException(); - } - } - - /// - /// Reads the root-message preamble specific to this formatter - /// - public override void ReadMessageStart() - { - ReadMessageStart(_rootElementName); - } - - /// - /// Reads the root-message preamble specific to this formatter - /// - public void ReadMessageStart(string element) - { - while (!_input.IsStartElement() && _input.Read()) - { - continue; - } - Assert(_input.IsStartElement() && _input.LocalName == element); - _elements.Push(new ElementStackEntry(element, _input.Depth, _input.IsEmptyElement)); - _input.Read(); - } - - /// - /// Reads the root-message close specific to this formatter, MUST be called - /// on the reader obtained from ReadMessageStart(string element). - /// - public override void ReadMessageEnd() - { - Assert(_elements.Count > 0); - - ElementStackEntry stop = _elements.Peek(); - while (_input.NodeType != XmlNodeType.EndElement && _input.NodeType != XmlNodeType.Element - && _input.Depth > stop.Depth && _input.Read()) - { - continue; - } - - if (!stop.IsEmpty) - { - Assert(_input.NodeType == XmlNodeType.EndElement - && _input.LocalName == stop.LocalName - && _input.Depth == stop.Depth); - - _input.Read(); - } - _elements.Pop(); - } - - /// - /// Merge the provided builder as an element named in the current context - /// - public override TBuilder Merge(TBuilder builder, ExtensionRegistry registry) - { - return Merge(_rootElementName, builder, registry); - } - - /// - /// Merge the provided builder as an element of the current context - /// - public TBuilder Merge(string element, TBuilder builder) where TBuilder : IBuilderLite - { - return Merge(element, builder, ExtensionRegistry.Empty); - } - - /// - /// Merge the provided builder as an element of the current context - /// - public TBuilder Merge(string element, TBuilder builder, ExtensionRegistry registry) - where TBuilder : IBuilderLite - { - ReadMessageStart(element); - builder.WeakMergeFrom(this, registry); - ReadMessageEnd(); - return builder; - } - - /// - /// Peeks at the next field in the input stream and returns what information is available. - /// - /// - /// This may be called multiple times without actually reading the field. Only after the field - /// is either read, or skipped, should PeekNext return a different value. - /// - protected override bool PeekNext(out string field) - { - ElementStackEntry stopNode; - if (_elements.Count == 0) - { - stopNode = new ElementStackEntry(null, _input.Depth - 1, false); - } - else - { - stopNode = _elements.Peek(); - } - - if (!stopNode.IsEmpty) - { - while (!_input.IsStartElement() && _input.Depth > stopNode.Depth && _input.Read()) - { - continue; - } - - if (_input.IsStartElement() && _input.Depth > stopNode.Depth) - { - field = _input.LocalName; - return true; - } - } - field = null; - return false; - } - - /// - /// Causes the reader to skip past this field - /// - protected override void Skip() - { - if (_input.IsStartElement()) - { - if (!_input.IsEmptyElement) - { - int depth = _input.Depth; - while (_input.Depth >= depth && _input.NodeType != XmlNodeType.EndElement) - { - Assert(_input.Read()); - } - } - _input.Read(); - } - } - - /// - /// returns true if it was able to read a single value into the value reference. The value - /// stored may be of type System.String, System.Int32, or an IEnumLite from the IEnumLiteMap. - /// - protected override bool ReadEnum(ref object value) - { - int number; - string temp; - if (null != (temp = _input.GetAttribute("value")) && FrameworkPortability.TryParseInt32(temp, out number)) - { - Skip(); - value = number; - return true; - } - return base.ReadEnum(ref value); - } - - /// - /// Returns true if it was able to read a String from the input - /// - protected override bool ReadAsText(ref string value, Type type) - { - Assert(_input.NodeType == XmlNodeType.Element); - value = _input.ReadElementContentAsString(); - - return true; - } - - /// - /// Merges the input stream into the provided IBuilderLite - /// - protected override bool ReadMessage(IBuilderLite builder, ExtensionRegistry registry) - { - Assert(_input.IsStartElement()); - ReadMessageStart(_input.LocalName); - builder.WeakMergeFrom(this, registry); - ReadMessageEnd(); - return true; - } - - private IEnumerable NonNestedArrayItems(string field) - { - return base.ForeachArrayItem(field); - } - - /// - /// Cursors through the array elements and stops at the end of the array - /// - protected override IEnumerable ForeachArrayItem(string field) - { - bool isNested = (Options & XmlReaderOptions.ReadNestedArrays) != 0; - - if (!isNested) - { - foreach (string item in NonNestedArrayItems(field)) - { - yield return item; - } - } - else - { - string found; - ReadMessageStart(field); - if (PeekNext(out found) && found == "item") - { - foreach (string item in NonNestedArrayItems("item")) - { - yield return item; - } - } - ReadMessageEnd(); - } - } - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers.Serialization/XmlFormatWriter.cs b/csharp/src/ProtocolBuffers.Serialization/XmlFormatWriter.cs deleted file mode 100644 index 4bd27562..00000000 --- a/csharp/src/ProtocolBuffers.Serialization/XmlFormatWriter.cs +++ /dev/null @@ -1,280 +0,0 @@ -using System; -using System.Collections; -using System.IO; -using System.Text; -using System.Xml; -using Google.ProtocolBuffers.Descriptors; - -namespace Google.ProtocolBuffers.Serialization -{ - /// - /// Writes a proto buffer to an XML document or fragment. .NET 3.5 users may also - /// use this class to produce Json by setting the options to support Json and providing - /// an XmlWriter obtained from . - /// - public class XmlFormatWriter : AbstractTextWriter - { - private static readonly Encoding DefaultEncoding = new UTF8Encoding(false); - public const string DefaultRootElementName = "root"; - - private readonly XmlWriter _output; - // The default element name used for WriteMessageStart - private string _rootElementName; - // Used to assert matching WriteMessageStart/WriteMessageEnd calls - private int _messageOpenCount; - - private static XmlWriterSettings DefaultSettings(Encoding encoding) - { - return new XmlWriterSettings() - { - CheckCharacters = false, - NewLineHandling = NewLineHandling.Entitize, - OmitXmlDeclaration = true, - Encoding = encoding, - }; - } - - /// - /// Constructs the XmlFormatWriter to write to the given TextWriter - /// - public static XmlFormatWriter CreateInstance(TextWriter output) - { - return new XmlFormatWriter(XmlWriter.Create(output, DefaultSettings(output.Encoding))); - } - - /// - /// Constructs the XmlFormatWriter to write to the given stream - /// - public static XmlFormatWriter CreateInstance(Stream output) - { - return new XmlFormatWriter(XmlWriter.Create(output, DefaultSettings(DefaultEncoding))); - } - - /// - /// Constructs the XmlFormatWriter to write to the given stream - /// - public static XmlFormatWriter CreateInstance(Stream output, Encoding encoding) - { - return new XmlFormatWriter(XmlWriter.Create(output, DefaultSettings(encoding))); - } - - /// - /// Constructs the XmlFormatWriter to write to the given XmlWriter - /// - public static XmlFormatWriter CreateInstance(XmlWriter output) - { - return new XmlFormatWriter(output); - } - - protected XmlFormatWriter(XmlWriter output) - { - _output = output; - _messageOpenCount = 0; - _rootElementName = DefaultRootElementName; - } - - /// - /// Gets or sets the default element name to use when using the Merge<TBuilder>() - /// - public string RootElementName - { - get { return _rootElementName; } - set - { - ThrowHelper.ThrowIfNull(value, "RootElementName"); - _rootElementName = value; - } - } - - /// - /// Gets or sets the options to use while generating the XML - /// - public XmlWriterOptions Options { get; set; } - - /// - /// Sets the options to use while generating the XML - /// - public XmlFormatWriter SetOptions(XmlWriterOptions options) - { - Options = options; - return this; - } - - private bool TestOption(XmlWriterOptions option) - { - return (Options & option) != 0; - } - - /// - /// Completes any pending write operations - /// - public override void Flush() - { - _output.Flush(); - base.Flush(); - } - - /// - /// Used to write the root-message preamble, in xml this is open element for RootElementName, - /// by default "<root>". After this call you can call IMessageLite.MergeTo(...) and - /// complete the message with a call to WriteMessageEnd(). - /// - public override void WriteMessageStart() - { - WriteMessageStart(_rootElementName); - } - - /// - /// Used to write the root-message preamble, in xml this is open element for elementName. - /// After this call you can call IMessageLite.MergeTo(...) and complete the message with - /// a call to WriteMessageEnd(). - /// - public void WriteMessageStart(string elementName) - { - if (TestOption(XmlWriterOptions.OutputJsonTypes)) - { - _output.WriteStartElement("root"); // json requires this is the root-element - _output.WriteAttributeString("type", "object"); - } - else - { - _output.WriteStartElement(elementName); - } - _messageOpenCount++; - } - - /// - /// Used to complete a root-message previously started with a call to WriteMessageStart() - /// - public override void WriteMessageEnd() - { - if (_messageOpenCount <= 0) - { - throw new InvalidOperationException(); - } - - _output.WriteEndElement(); - _output.Flush(); - _messageOpenCount--; - } - - /// - /// Writes a message as an element using the name defined in - /// - public override void WriteMessage(IMessageLite message) - { - WriteMessage(_rootElementName, message); - } - - /// - /// Writes a message as an element with the given name - /// - public void WriteMessage(string elementName, IMessageLite message) - { - WriteMessageStart(elementName); - message.WriteTo(this); - WriteMessageEnd(); - } - - /// - /// Writes a message - /// - protected override void WriteMessageOrGroup(string field, IMessageLite message) - { - _output.WriteStartElement(field); - - if (TestOption(XmlWriterOptions.OutputJsonTypes)) - { - _output.WriteAttributeString("type", "object"); - } - - message.WriteTo(this); - _output.WriteEndElement(); - } - - /// - /// Writes a String value - /// - protected override void WriteAsText(string field, string textValue, object typedValue) - { - _output.WriteStartElement(field); - - if (TestOption(XmlWriterOptions.OutputJsonTypes)) - { - if (typedValue is int || typedValue is uint || typedValue is long || typedValue is ulong || - typedValue is double || typedValue is float) - { - _output.WriteAttributeString("type", "number"); - } - else if (typedValue is bool) - { - _output.WriteAttributeString("type", "boolean"); - } - } - _output.WriteString(textValue); - - //Empty strings should not be written as empty elements '', rather as '' - if (_output.WriteState == WriteState.Element) - { - _output.WriteRaw(""); - } - - _output.WriteEndElement(); - } - - /// - /// Writes an array of field values - /// - protected override void WriteArray(FieldType fieldType, string field, IEnumerable items) - { - //see if it's empty - IEnumerator eitems = items.GetEnumerator(); - try - { - if (!eitems.MoveNext()) - { - return; - } - } - finally - { - if (eitems is IDisposable) - { - ((IDisposable) eitems).Dispose(); - } - } - - if (TestOption(XmlWriterOptions.OutputNestedArrays | XmlWriterOptions.OutputJsonTypes)) - { - _output.WriteStartElement(field); - if (TestOption(XmlWriterOptions.OutputJsonTypes)) - { - _output.WriteAttributeString("type", "array"); - } - - base.WriteArray(fieldType, "item", items); - _output.WriteEndElement(); - } - else - { - base.WriteArray(fieldType, field, items); - } - } - - /// - /// Writes a System.Enum by the numeric and textual value - /// - protected override void WriteEnum(string field, int number, string name) - { - _output.WriteStartElement(field); - - if (!TestOption(XmlWriterOptions.OutputJsonTypes) && TestOption(XmlWriterOptions.OutputEnumValues)) - { - _output.WriteAttributeString("value", XmlConvert.ToString(number)); - } - - _output.WriteString(name); - _output.WriteEndElement(); - } - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers.Serialization/XmlReaderOptions.cs b/csharp/src/ProtocolBuffers.Serialization/XmlReaderOptions.cs deleted file mode 100644 index f7eca1d7..00000000 --- a/csharp/src/ProtocolBuffers.Serialization/XmlReaderOptions.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; - -namespace Google.ProtocolBuffers.Serialization -{ - /// - /// Options available for the xml reader output - /// - [Flags] - public enum XmlReaderOptions - { - /// Simple xml formatting with no attributes - None, - - /// Requires that arrays items are nested in an <item> element - ReadNestedArrays = 1, - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers.Serialization/XmlWriterOptions.cs b/csharp/src/ProtocolBuffers.Serialization/XmlWriterOptions.cs deleted file mode 100644 index 7d740ee3..00000000 --- a/csharp/src/ProtocolBuffers.Serialization/XmlWriterOptions.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; - -namespace Google.ProtocolBuffers.Serialization -{ - /// - /// Options available for the xml writer output - /// - [Flags] - public enum XmlWriterOptions - { - /// Simple xml formatting with no attributes - None, - - /// Writes the 'value' attribute on all enumerations with the numeric identifier - OutputEnumValues = 0x1, - - /// Embeds array items into child <item> elements - OutputNestedArrays = 0x4, - - /// Outputs the 'type' attribute for compatibility with the JsonReaderWriterFactory - /// This option must, by nessessity, also enable NestedArrayItems - OutputJsonTypes = 0x8, - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/ProtocolBuffersLite.csproj b/csharp/src/ProtocolBuffers/ProtocolBuffersLite.csproj deleted file mode 100644 index d0912a6b..00000000 --- a/csharp/src/ProtocolBuffers/ProtocolBuffersLite.csproj +++ /dev/null @@ -1,99 +0,0 @@ - - - - Debug - AnyCPU - 9.0.30729 - 2.0 - {6969BDCE-D925-43F3-94AC-A531E6DF2591} - Library - Properties - Google.ProtocolBuffers - Google.ProtocolBuffersLite - {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - Profile92 - v4.0 - 512 - true - ..\..\keys\Google.ProtocolBuffers.snk - 3.5 - 10.0 - - - true - full - false - bin\Debug - obj\Debug\ - $(OutputPath)\$(AssemblyName).xml - 1591, 1570, 1571, 1572, 1573, 1574 - DEBUG;TRACE;LITE;$(EnvironmentFlavor);$(EnvironmentTemplate) - prompt - 4 - true - Off - - - pdbonly - true - bin\Release - obj\Release\ - $(OutputPath)\$(AssemblyName).xml - 1591, 1570, 1571, 1572, 1573, 1574 - TRACE;LITE;$(EnvironmentFlavor);$(EnvironmentTemplate) - prompt - 4 - true - Off - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/csharp/src/ProtocolBuffersLite.Test/AbstractBuilderLiteTest.cs b/csharp/src/ProtocolBuffersLite.Test/AbstractBuilderLiteTest.cs deleted file mode 100644 index f5932ab3..00000000 --- a/csharp/src/ProtocolBuffersLite.Test/AbstractBuilderLiteTest.cs +++ /dev/null @@ -1,336 +0,0 @@ -#region Copyright notice and license - -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/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.IO; -using Google.ProtocolBuffers.TestProtos; -using NUnit.Framework; - -namespace Google.ProtocolBuffers -{ - public class AbstractBuilderLiteTest - { - [Test] - public void TestMergeFromCodedInputStream() - { - TestAllTypesLite copy, - msg = TestAllTypesLite.CreateBuilder() - .SetOptionalUint32(uint.MaxValue).Build(); - - copy = TestAllTypesLite.DefaultInstance; - Assert.AreNotEqual(msg.ToByteArray(), copy.ToByteArray()); - - using (MemoryStream ms = new MemoryStream(msg.ToByteArray())) - { - CodedInputStream ci = CodedInputStream.CreateInstance(ms); - copy = copy.ToBuilder().MergeFrom(ci).Build(); - } - - Assert.AreEqual(msg.ToByteArray(), copy.ToByteArray()); - } - - [Test] - public void TestIBuilderLiteWeakClear() - { - TestAllTypesLite copy, msg = TestAllTypesLite.DefaultInstance; - - copy = msg.ToBuilder().SetOptionalString("Should be removed.").Build(); - Assert.AreNotEqual(msg.ToByteArray(), copy.ToByteArray()); - - copy = (TestAllTypesLite) ((IBuilderLite) copy.ToBuilder()).WeakClear().WeakBuild(); - Assert.AreEqual(msg.ToByteArray(), copy.ToByteArray()); - } - - [Test] - public void TestBuilderLiteMergeFromCodedInputStream() - { - TestAllTypesLite copy, - msg = TestAllTypesLite.CreateBuilder() - .SetOptionalString("Should be merged.").Build(); - - copy = TestAllTypesLite.DefaultInstance; - Assert.AreNotEqual(msg.ToByteArray(), copy.ToByteArray()); - - copy = - copy.ToBuilder().MergeFrom(CodedInputStream.CreateInstance(new MemoryStream(msg.ToByteArray()))).Build(); - Assert.AreEqual(msg.ToByteArray(), copy.ToByteArray()); - } - - [Test] - public void TestBuilderLiteMergeDelimitedFrom() - { - TestAllTypesLite copy, - msg = TestAllTypesLite.CreateBuilder() - .SetOptionalString("Should be merged.").Build(); - - copy = TestAllTypesLite.DefaultInstance; - Assert.AreNotEqual(msg.ToByteArray(), copy.ToByteArray()); - Stream s = new MemoryStream(); - msg.WriteDelimitedTo(s); - s.Position = 0; - copy = copy.ToBuilder().MergeDelimitedFrom(s).Build(); - Assert.AreEqual(msg.ToByteArray(), copy.ToByteArray()); - } - - [Test] - public void TestBuilderLiteMergeDelimitedFromExtensions() - { - TestAllExtensionsLite copy, - msg = TestAllExtensionsLite.CreateBuilder() - .SetExtension(UnittestLite.OptionalStringExtensionLite, - "Should be merged.").Build(); - - copy = TestAllExtensionsLite.DefaultInstance; - Assert.AreNotEqual(msg.ToByteArray(), copy.ToByteArray()); - - Stream s = new MemoryStream(); - msg.WriteDelimitedTo(s); - s.Position = 0; - - ExtensionRegistry registry = ExtensionRegistry.CreateInstance(); - UnittestLite.RegisterAllExtensions(registry); - - copy = copy.ToBuilder().MergeDelimitedFrom(s, registry).Build(); - Assert.AreEqual(msg.ToByteArray(), copy.ToByteArray()); - Assert.AreEqual("Should be merged.", copy.GetExtension(UnittestLite.OptionalStringExtensionLite)); - } - - [Test] - public void TestBuilderLiteMergeFromStream() - { - TestAllTypesLite copy, - msg = TestAllTypesLite.CreateBuilder() - .SetOptionalString("Should be merged.").Build(); - - copy = TestAllTypesLite.DefaultInstance; - Assert.AreNotEqual(msg.ToByteArray(), copy.ToByteArray()); - Stream s = new MemoryStream(); - msg.WriteTo(s); - s.Position = 0; - copy = copy.ToBuilder().MergeFrom(s).Build(); - Assert.AreEqual(msg.ToByteArray(), copy.ToByteArray()); - } - - [Test] - public void TestBuilderLiteMergeFromStreamExtensions() - { - TestAllExtensionsLite copy, - msg = TestAllExtensionsLite.CreateBuilder() - .SetExtension(UnittestLite.OptionalStringExtensionLite, - "Should be merged.").Build(); - - copy = TestAllExtensionsLite.DefaultInstance; - Assert.AreNotEqual(msg.ToByteArray(), copy.ToByteArray()); - - Stream s = new MemoryStream(); - msg.WriteTo(s); - s.Position = 0; - - ExtensionRegistry registry = ExtensionRegistry.CreateInstance(); - UnittestLite.RegisterAllExtensions(registry); - - copy = copy.ToBuilder().MergeFrom(s, registry).Build(); - Assert.AreEqual(msg.ToByteArray(), copy.ToByteArray()); - Assert.AreEqual("Should be merged.", copy.GetExtension(UnittestLite.OptionalStringExtensionLite)); - } - - [Test] - public void TestIBuilderLiteWeakMergeFromIMessageLite() - { - TestAllTypesLite copy, - msg = TestAllTypesLite.CreateBuilder() - .SetOptionalString("Should be merged.").Build(); - - copy = TestAllTypesLite.DefaultInstance; - Assert.AreNotEqual(msg.ToByteArray(), copy.ToByteArray()); - - copy = (TestAllTypesLite) ((IBuilderLite) copy.ToBuilder()).WeakMergeFrom((IMessageLite) msg).WeakBuild(); - Assert.AreEqual(msg.ToByteArray(), copy.ToByteArray()); - } - - [Test] - public void TestIBuilderLiteWeakMergeFromByteString() - { - TestAllTypesLite copy, - msg = TestAllTypesLite.CreateBuilder() - .SetOptionalString("Should be merged.").Build(); - - copy = TestAllTypesLite.DefaultInstance; - Assert.AreNotEqual(msg.ToByteArray(), copy.ToByteArray()); - - copy = (TestAllTypesLite) ((IBuilderLite) copy.ToBuilder()).WeakMergeFrom(msg.ToByteString()).WeakBuild(); - Assert.AreEqual(msg.ToByteArray(), copy.ToByteArray()); - } - - [Test] - public void TestIBuilderLiteWeakMergeFromByteStringExtensions() - { - TestAllExtensionsLite copy, - msg = TestAllExtensionsLite.CreateBuilder() - .SetExtension(UnittestLite.OptionalStringExtensionLite, - "Should be merged.").Build(); - - copy = TestAllExtensionsLite.DefaultInstance; - Assert.AreNotEqual(msg.ToByteArray(), copy.ToByteArray()); - - copy = - (TestAllExtensionsLite) - ((IBuilderLite) copy.ToBuilder()).WeakMergeFrom(msg.ToByteString(), ExtensionRegistry.Empty).WeakBuild(); - Assert.AreNotEqual(msg.ToByteArray(), copy.ToByteArray()); - - ExtensionRegistry registry = ExtensionRegistry.CreateInstance(); - UnittestLite.RegisterAllExtensions(registry); - - copy = - (TestAllExtensionsLite) - ((IBuilderLite) copy.ToBuilder()).WeakMergeFrom(msg.ToByteString(), registry).WeakBuild(); - Assert.AreEqual(msg.ToByteArray(), copy.ToByteArray()); - Assert.AreEqual("Should be merged.", copy.GetExtension(UnittestLite.OptionalStringExtensionLite)); - } - - [Test] - public void TestIBuilderLiteWeakMergeFromCodedInputStream() - { - TestAllTypesLite copy, - msg = TestAllTypesLite.CreateBuilder() - .SetOptionalUint32(uint.MaxValue).Build(); - - copy = TestAllTypesLite.DefaultInstance; - Assert.AreNotEqual(msg.ToByteArray(), copy.ToByteArray()); - - using (MemoryStream ms = new MemoryStream(msg.ToByteArray())) - { - CodedInputStream ci = CodedInputStream.CreateInstance(ms); - copy = (TestAllTypesLite) ((IBuilderLite) copy.ToBuilder()).WeakMergeFrom(ci).WeakBuild(); - } - - Assert.AreEqual(msg.ToByteArray(), copy.ToByteArray()); - } - - [Test] - public void TestIBuilderLiteWeakBuildPartial() - { - IBuilderLite builder = TestRequiredLite.CreateBuilder(); - Assert.IsFalse(builder.IsInitialized); - - IMessageLite msg = builder.WeakBuildPartial(); - Assert.IsFalse(msg.IsInitialized); - - Assert.AreEqual(msg.ToByteArray(), TestRequiredLite.DefaultInstance.ToByteArray()); - } - - [Test] - public void TestIBuilderLiteWeakBuildUninitialized() - { - IBuilderLite builder = TestRequiredLite.CreateBuilder(); - Assert.IsFalse(builder.IsInitialized); - Assert.Throws(() => builder.WeakBuild()); - } - - [Test] - public void TestIBuilderLiteWeakBuild() - { - IBuilderLite builder = TestRequiredLite.CreateBuilder() - .SetD(0) - .SetEn(ExtraEnum.EXLITE_BAZ); - Assert.IsTrue(builder.IsInitialized); - builder.WeakBuild(); - } - - [Test] - public void TestIBuilderLiteWeakClone() - { - TestRequiredLite msg = TestRequiredLite.CreateBuilder() - .SetD(1).SetEn(ExtraEnum.EXLITE_BAR).Build(); - Assert.IsTrue(msg.IsInitialized); - - IMessageLite copy = ((IBuilderLite) msg.ToBuilder()).WeakClone().WeakBuild(); - Assert.AreEqual(msg.ToByteArray(), copy.ToByteArray()); - } - - [Test] - public void TestIBuilderLiteWeakDefaultInstance() - { - Assert.IsTrue(ReferenceEquals(TestRequiredLite.DefaultInstance, - ((IBuilderLite) TestRequiredLite.CreateBuilder()).WeakDefaultInstanceForType)); - } - - [Test] - public void TestGeneratedBuilderLiteAddRange() - { - TestAllTypesLite copy, - msg = TestAllTypesLite.CreateBuilder() - .SetOptionalUint32(123) - .AddRepeatedInt32(1) - .AddRepeatedInt32(2) - .AddRepeatedInt32(3) - .Build(); - - copy = msg.DefaultInstanceForType.ToBuilder().MergeFrom(msg).Build(); - Assert.AreEqual(msg.ToByteArray(), copy.ToByteArray()); - } - - // ROK 5/7/2013 Issue #54: should retire all bytes in buffer (bufferSize) - [Test] - public void TestBufferRefillIssue() - { - var ms = new MemoryStream(); - BucketOfBytes.CreateBuilder() - .SetValue(ByteString.CopyFrom(new byte[3000])) - .Build().WriteDelimitedTo(ms); - BucketOfBytesEx.CreateBuilder() - .SetValue(ByteString.CopyFrom(new byte[1000])) - .SetValue2(ByteString.CopyFrom(new byte[1100])) - .Build().WriteDelimitedTo(ms); - BucketOfBytes.CreateBuilder() - .SetValue(ByteString.CopyFrom(new byte[100])) - .Build().WriteDelimitedTo(ms); - - ms.Position = 0; - var input = CodedInputStream.CreateInstance(ms); - var builder = BucketOfBytes.CreateBuilder(); - input.ReadMessage(builder, ExtensionRegistry.Empty); - Assert.AreEqual(3005L, input.Position); - Assert.AreEqual(3000, builder.Value.Length); - input.ReadMessage(builder, ExtensionRegistry.Empty); - Assert.AreEqual(5114, input.Position); - Assert.AreEqual(1000, builder.Value.Length); - input.ReadMessage(builder, ExtensionRegistry.Empty); - Assert.AreEqual(5217L, input.Position); - Assert.AreEqual(input.Position, ms.Length); - Assert.AreEqual(100, builder.Value.Length); - } - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffersLite.Test/AbstractMessageLiteTest.cs b/csharp/src/ProtocolBuffersLite.Test/AbstractMessageLiteTest.cs deleted file mode 100644 index 93ed5ea5..00000000 --- a/csharp/src/ProtocolBuffersLite.Test/AbstractMessageLiteTest.cs +++ /dev/null @@ -1,133 +0,0 @@ -#region Copyright notice and license - -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/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 Google.ProtocolBuffers.TestProtos; -using NUnit.Framework; - -namespace Google.ProtocolBuffers -{ - public class AbstractMessageLiteTest - { - [Test] - public void TestMessageLiteToByteString() - { - TestRequiredLite msg = TestRequiredLite.CreateBuilder() - .SetD(42) - .SetEn(ExtraEnum.EXLITE_BAZ) - .Build(); - - ByteString b = msg.ToByteString(); - Assert.AreEqual(4, b.Length); - Assert.AreEqual(TestRequiredLite.DFieldNumber << 3, b[0]); - Assert.AreEqual(42, b[1]); - Assert.AreEqual(TestRequiredLite.EnFieldNumber << 3, b[2]); - Assert.AreEqual((int) ExtraEnum.EXLITE_BAZ, b[3]); - } - - [Test] - public void TestMessageLiteToByteArray() - { - TestRequiredLite msg = TestRequiredLite.CreateBuilder() - .SetD(42) - .SetEn(ExtraEnum.EXLITE_BAZ) - .Build(); - - ByteString b = msg.ToByteString(); - ByteString copy = ByteString.CopyFrom(msg.ToByteArray()); - Assert.AreEqual(b, copy); - } - - [Test] - public void TestMessageLiteWriteTo() - { - TestRequiredLite msg = TestRequiredLite.CreateBuilder() - .SetD(42) - .SetEn(ExtraEnum.EXLITE_BAZ) - .Build(); - - MemoryStream ms = new MemoryStream(); - msg.WriteTo(ms); - Assert.AreEqual(msg.ToByteArray(), ms.ToArray()); - } - - [Test] - public void TestMessageLiteWriteDelimitedTo() - { - TestRequiredLite msg = TestRequiredLite.CreateBuilder() - .SetD(42) - .SetEn(ExtraEnum.EXLITE_BAZ) - .Build(); - - MemoryStream ms = new MemoryStream(); - msg.WriteDelimitedTo(ms); - byte[] buffer = ms.ToArray(); - - Assert.AreEqual(5, buffer.Length); - Assert.AreEqual(4, buffer[0]); - byte[] msgBytes = new byte[4]; - Array.Copy(buffer, 1, msgBytes, 0, 4); - Assert.AreEqual(msg.ToByteArray(), msgBytes); - } - - [Test] - public void TestIMessageLiteWeakCreateBuilderForType() - { - IMessageLite msg = TestRequiredLite.DefaultInstance; - Assert.AreEqual(typeof(TestRequiredLite.Builder), msg.WeakCreateBuilderForType().GetType()); - } - - [Test] - public void TestMessageLiteWeakToBuilder() - { - IMessageLite msg = TestRequiredLite.CreateBuilder() - .SetD(42) - .SetEn(ExtraEnum.EXLITE_BAZ) - .Build(); - - IMessageLite copy = msg.WeakToBuilder().WeakBuild(); - Assert.AreEqual(msg.ToByteArray(), copy.ToByteArray()); - } - - [Test] - public void TestMessageLiteWeakDefaultInstanceForType() - { - IMessageLite msg = TestRequiredLite.DefaultInstance; - Assert.IsTrue(Object.ReferenceEquals(TestRequiredLite.DefaultInstance, msg.WeakDefaultInstanceForType)); - } - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffersLite.Test/App.xaml b/csharp/src/ProtocolBuffersLite.Test/App.xaml deleted file mode 100644 index d4f1f2e3..00000000 --- a/csharp/src/ProtocolBuffersLite.Test/App.xaml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - diff --git a/csharp/src/ProtocolBuffersLite.Test/App.xaml.cs b/csharp/src/ProtocolBuffersLite.Test/App.xaml.cs deleted file mode 100644 index 0c9fd9e6..00000000 --- a/csharp/src/ProtocolBuffersLite.Test/App.xaml.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System; -using System.Windows; -using Microsoft.Silverlight.Testing; - -namespace Google.ProtocolBuffers -{ - public partial class App : Application - { - - public App() - { - this.Startup += this.Application_Startup; - this.Exit += this.Application_Exit; - this.UnhandledException += this.Application_UnhandledException; - - //InitializeComponent(); - } - - private void Application_Startup(object sender, StartupEventArgs e) - { - this.RootVisual = UnitTestSystem.CreateTestPage(); - } - - private void Application_Exit(object sender, EventArgs e) - { - - } - private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e) - { - // If the app is running outside of the debugger then report the exception using - // the browser's exception mechanism. On IE this will display it a yellow alert - // icon in the status bar and Firefox will display a script error. - if (!System.Diagnostics.Debugger.IsAttached) - { - - // NOTE: This will allow the application to continue running after an exception has been thrown - // but not handled. - // For production applications this error handling should be replaced with something that will - // report the error to the website and stop the application. - e.Handled = true; - Deployment.Current.Dispatcher.BeginInvoke( - new EventHandler(ReportErrorToDOM), - new object[] { sender, e } ); - } - } - private void ReportErrorToDOM(object sender, ApplicationUnhandledExceptionEventArgs e) - { - try - { - string errorMsg = e.ExceptionObject.Message + e.ExceptionObject.StackTrace; - errorMsg = errorMsg.Replace('"', '\'').Replace("\r\n", @"\n"); - - System.Windows.Browser.HtmlPage.Window.Eval("throw new Error(\"Unhandled Error in Silverlight 2 Application " + errorMsg + "\");"); - } - catch (Exception) - { - } - } - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffersLite.Test/ExtendableBuilderLiteTest.cs b/csharp/src/ProtocolBuffersLite.Test/ExtendableBuilderLiteTest.cs deleted file mode 100644 index 1ea712d4..00000000 --- a/csharp/src/ProtocolBuffersLite.Test/ExtendableBuilderLiteTest.cs +++ /dev/null @@ -1,286 +0,0 @@ -#region Copyright notice and license - -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/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.Collections.Generic; -using Google.ProtocolBuffers.TestProtos; -using NUnit.Framework; - -namespace Google.ProtocolBuffers -{ - public class ExtendableBuilderLiteTest - { - [Test] - public void TestHasExtensionT() - { - TestAllExtensionsLite.Builder builder = TestAllExtensionsLite.CreateBuilder() - .SetExtension(UnittestLite.OptionalInt32ExtensionLite, 123); - - Assert.IsTrue(builder.HasExtension(UnittestLite.OptionalInt32ExtensionLite)); - } - - [Test] - public void TestHasExtensionTMissing() - { - TestAllExtensionsLite.Builder builder = TestAllExtensionsLite.CreateBuilder(); - Assert.IsFalse(builder.HasExtension(UnittestLite.OptionalInt32ExtensionLite)); - } - - [Test] - public void TestGetExtensionCountT() - { - TestAllExtensionsLite.Builder builder = TestAllExtensionsLite.CreateBuilder() - .AddExtension(UnittestLite.RepeatedInt32ExtensionLite, 1) - .AddExtension(UnittestLite.RepeatedInt32ExtensionLite, 2) - .AddExtension(UnittestLite.RepeatedInt32ExtensionLite, 3); - - Assert.AreEqual(3, builder.GetExtensionCount(UnittestLite.RepeatedInt32ExtensionLite)); - } - - [Test] - public void TestGetExtensionCountTEmpty() - { - TestAllExtensionsLite.Builder builder = TestAllExtensionsLite.CreateBuilder(); - Assert.AreEqual(0, builder.GetExtensionCount(UnittestLite.RepeatedInt32ExtensionLite)); - } - - [Test] - public void TestGetExtensionTNull() - { - TestAllExtensionsLite.Builder builder = TestAllExtensionsLite.CreateBuilder(); - string value = builder.GetExtension(UnittestLite.OptionalStringExtensionLite); - Assert.Null(value); - } - - [Test] - public void TestGetExtensionTValue() - { - TestAllExtensionsLite.Builder builder = TestAllExtensionsLite.CreateBuilder() - .SetExtension(UnittestLite.OptionalInt32ExtensionLite, 3); - - Assert.AreEqual(3, builder.GetExtension(UnittestLite.OptionalInt32ExtensionLite)); - } - - [Test] - public void TestGetExtensionTEmpty() - { - TestAllExtensionsLite.Builder builder = TestAllExtensionsLite.CreateBuilder(); - Assert.AreEqual(0, builder.GetExtension(UnittestLite.RepeatedInt32ExtensionLite).Count); - } - - [Test] - public void TestGetExtensionTList() - { - TestAllExtensionsLite.Builder builder = TestAllExtensionsLite.CreateBuilder() - .AddExtension(UnittestLite.RepeatedInt32ExtensionLite, 1) - .AddExtension(UnittestLite.RepeatedInt32ExtensionLite, 2) - .AddExtension(UnittestLite.RepeatedInt32ExtensionLite, 3); - - IList values = builder.GetExtension(UnittestLite.RepeatedInt32ExtensionLite); - Assert.AreEqual(3, values.Count); - } - - [Test] - public void TestGetExtensionTIndex() - { - TestAllExtensionsLite.Builder builder = TestAllExtensionsLite.CreateBuilder() - .AddExtension(UnittestLite.RepeatedInt32ExtensionLite, 0) - .AddExtension(UnittestLite.RepeatedInt32ExtensionLite, 1) - .AddExtension(UnittestLite.RepeatedInt32ExtensionLite, 2); - - for (int i = 0; i < 3; i++) - Assert.AreEqual(i, builder.GetExtension(UnittestLite.RepeatedInt32ExtensionLite, i)); - } - - [Test] - public void TestGetExtensionTIndexOutOfRange() - { - TestAllExtensionsLite.Builder builder = TestAllExtensionsLite.CreateBuilder(); - Assert.Throws(() => builder.GetExtension(UnittestLite.RepeatedInt32ExtensionLite, 0)); - } - - [Test] - public void TestSetExtensionTIndex() - { - TestAllExtensionsLite.Builder builder = TestAllExtensionsLite.CreateBuilder() - .AddExtension(UnittestLite.RepeatedInt32ExtensionLite, 0) - .AddExtension(UnittestLite.RepeatedInt32ExtensionLite, 1) - .AddExtension(UnittestLite.RepeatedInt32ExtensionLite, 2); - - for (int i = 0; i < 3; i++) - Assert.AreEqual(i, builder.GetExtension(UnittestLite.RepeatedInt32ExtensionLite, i)); - - builder.SetExtension(UnittestLite.RepeatedInt32ExtensionLite, 0, 5); - builder.SetExtension(UnittestLite.RepeatedInt32ExtensionLite, 1, 6); - builder.SetExtension(UnittestLite.RepeatedInt32ExtensionLite, 2, 7); - - for (int i = 0; i < 3; i++) - Assert.AreEqual(5 + i, builder.GetExtension(UnittestLite.RepeatedInt32ExtensionLite, i)); - } - - [Test] - public void TestSetExtensionTIndexOutOfRange() - { - TestAllExtensionsLite.Builder builder = TestAllExtensionsLite.CreateBuilder(); - Assert.Throws(() => builder.SetExtension(UnittestLite.RepeatedInt32ExtensionLite, 0, -1)); - } - - [Test] - public void TestClearExtensionTList() - { - TestAllExtensionsLite.Builder builder = TestAllExtensionsLite.CreateBuilder() - .AddExtension(UnittestLite.RepeatedInt32ExtensionLite, 0); - Assert.AreEqual(1, builder.GetExtensionCount(UnittestLite.RepeatedInt32ExtensionLite)); - - builder.ClearExtension(UnittestLite.RepeatedInt32ExtensionLite); - Assert.AreEqual(0, builder.GetExtensionCount(UnittestLite.RepeatedInt32ExtensionLite)); - } - - [Test] - public void TestClearExtensionTValue() - { - TestAllExtensionsLite.Builder builder = TestAllExtensionsLite.CreateBuilder() - .SetExtension(UnittestLite.OptionalInt32ExtensionLite, 0); - Assert.IsTrue(builder.HasExtension(UnittestLite.OptionalInt32ExtensionLite)); - - builder.ClearExtension(UnittestLite.OptionalInt32ExtensionLite); - Assert.IsFalse(builder.HasExtension(UnittestLite.OptionalInt32ExtensionLite)); - } - - [Test] - public void TestIndexedByDescriptor() - { - TestAllExtensionsLite.Builder builder = TestAllExtensionsLite.CreateBuilder(); - Assert.IsFalse(builder.HasExtension(UnittestLite.OptionalInt32ExtensionLite)); - - builder[UnittestLite.OptionalInt32ExtensionLite.Descriptor] = 123; - - Assert.IsTrue(builder.HasExtension(UnittestLite.OptionalInt32ExtensionLite)); - Assert.AreEqual(123, builder.GetExtension(UnittestLite.OptionalInt32ExtensionLite)); - } - - [Test] - public void TestIndexedByDescriptorAndOrdinal() - { - TestAllExtensionsLite.Builder builder = TestAllExtensionsLite.CreateBuilder() - .AddExtension(UnittestLite.RepeatedInt32ExtensionLite, 0); - Assert.AreEqual(1, builder.GetExtensionCount(UnittestLite.RepeatedInt32ExtensionLite)); - - IFieldDescriptorLite f = UnittestLite.RepeatedInt32ExtensionLite.Descriptor; - builder[f, 0] = 123; - - Assert.AreEqual(1, builder.GetExtensionCount(UnittestLite.RepeatedInt32ExtensionLite)); - Assert.AreEqual(123, builder.GetExtension(UnittestLite.RepeatedInt32ExtensionLite, 0)); - } - - [Test] - public void TestIndexedByDescriptorAndOrdinalOutOfRange() - { - TestAllExtensionsLite.Builder builder = TestAllExtensionsLite.CreateBuilder(); - Assert.AreEqual(0, builder.GetExtensionCount(UnittestLite.RepeatedInt32ExtensionLite)); - - IFieldDescriptorLite f = UnittestLite.RepeatedInt32ExtensionLite.Descriptor; - Assert.Throws(() => builder[f, 0] = 123); - } - - [Test] - public void TestClearFieldByDescriptor() - { - TestAllExtensionsLite.Builder builder = TestAllExtensionsLite.CreateBuilder() - .AddExtension(UnittestLite.RepeatedInt32ExtensionLite, 0); - Assert.AreEqual(1, builder.GetExtensionCount(UnittestLite.RepeatedInt32ExtensionLite)); - - IFieldDescriptorLite f = UnittestLite.RepeatedInt32ExtensionLite.Descriptor; - builder.ClearField(f); - Assert.AreEqual(0, builder.GetExtensionCount(UnittestLite.RepeatedInt32ExtensionLite)); - } - - [Test] - public void TestAddRepeatedFieldByDescriptor() - { - TestAllExtensionsLite.Builder builder = TestAllExtensionsLite.CreateBuilder() - .AddExtension(UnittestLite.RepeatedInt32ExtensionLite, 0); - Assert.AreEqual(1, builder.GetExtensionCount(UnittestLite.RepeatedInt32ExtensionLite)); - - IFieldDescriptorLite f = UnittestLite.RepeatedInt32ExtensionLite.Descriptor; - builder.AddRepeatedField(f, 123); - Assert.AreEqual(2, builder.GetExtensionCount(UnittestLite.RepeatedInt32ExtensionLite)); - Assert.AreEqual(123, builder.GetExtension(UnittestLite.RepeatedInt32ExtensionLite, 1)); - } - - [Test] - public void TestMissingExtensionsLite() - { - const int optionalInt32 = 12345678; - TestAllExtensionsLite.Builder builder = TestAllExtensionsLite.CreateBuilder(); - builder.SetExtension(UnittestLite.OptionalInt32ExtensionLite, optionalInt32); - builder.AddExtension(UnittestLite.RepeatedDoubleExtensionLite, 1.1); - builder.AddExtension(UnittestLite.RepeatedDoubleExtensionLite, 1.2); - builder.AddExtension(UnittestLite.RepeatedDoubleExtensionLite, 1.3); - TestAllExtensionsLite msg = builder.Build(); - - Assert.IsTrue(msg.HasExtension(UnittestLite.OptionalInt32ExtensionLite)); - Assert.AreEqual(3, msg.GetExtensionCount(UnittestLite.RepeatedDoubleExtensionLite)); - - byte[] bits = msg.ToByteArray(); - TestAllExtensionsLite copy = TestAllExtensionsLite.ParseFrom(bits); - Assert.IsFalse(copy.HasExtension(UnittestLite.OptionalInt32ExtensionLite)); - Assert.AreEqual(0, copy.GetExtensionCount(UnittestLite.RepeatedDoubleExtensionLite)); - Assert.AreNotEqual(msg, copy); - - //The lite runtime removes all unknown fields and extensions - byte[] copybits = copy.ToByteArray(); - Assert.AreEqual(0, copybits.Length); - } - - [Test] - public void TestMissingFieldsLite() - { - TestAllTypesLite msg = TestAllTypesLite.CreateBuilder() - .SetOptionalInt32(123) - .SetOptionalString("123") - .Build(); - - byte[] bits = msg.ToByteArray(); - IMessageLite copy = TestAllExtensionsLite.ParseFrom(bits); - Assert.AreNotEqual(msg, copy); - - //The lite runtime removes all unknown fields and extensions - byte[] copybits = copy.ToByteArray(); - Assert.AreEqual(0, copybits.Length); - } - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffersLite.Test/ExtendableMessageLiteTest.cs b/csharp/src/ProtocolBuffersLite.Test/ExtendableMessageLiteTest.cs deleted file mode 100644 index 9a8e35b6..00000000 --- a/csharp/src/ProtocolBuffersLite.Test/ExtendableMessageLiteTest.cs +++ /dev/null @@ -1,378 +0,0 @@ -#region Copyright notice and license - -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/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.Collections.Generic; -using System.Text; -using Google.ProtocolBuffers; -using Google.ProtocolBuffers.TestProtos; -using NUnit.Framework; - -namespace Google.ProtocolBuffers -{ - public class ExtendableMessageLiteTest - { - //The lite framework does not make this assertion - //[TestMethod, Ignore, ExpectedException(typeof(ArgumentException))] - //public void ExtensionWriterInvalidExtension() - //{ - // TestPackedExtensionsLite.CreateBuilder()[ - // UnittestLite.OptionalForeignMessageExtensionLite.DescriptorProtoFile] = - // ForeignMessageLite.DefaultInstance; - //} - - [Test] - public void ExtensionWriterTestMessages() - { - TestAllExtensionsLite.Builder b = TestAllExtensionsLite.CreateBuilder().SetExtension( - UnittestLite.OptionalForeignMessageExtensionLite, - ForeignMessageLite.CreateBuilder().SetC(123).Build()); - TestAllExtensionsLite copy, msg = b.Build(); - - ExtensionRegistry registry = ExtensionRegistry.CreateInstance(); - UnittestLite.RegisterAllExtensions(registry); - - copy = TestAllExtensionsLite.ParseFrom(msg.ToByteArray(), registry); - Assert.AreEqual(msg.ToByteArray(), copy.ToByteArray()); - } - - [Test] - public void ExtensionWriterIsInitialized() - { - Assert.IsTrue(ForeignMessageLite.DefaultInstance.IsInitialized); - Assert.IsTrue(TestPackedExtensionsLite.CreateBuilder().IsInitialized); - Assert.IsTrue(TestAllExtensionsLite.CreateBuilder().SetExtension( - UnittestLite.OptionalForeignMessageExtensionLite, ForeignMessageLite.DefaultInstance) - .IsInitialized); - } - - [Test] - public void ExtensionWriterTestSetExtensionLists() - { - TestAllExtensionsLite msg, copy; - TestAllExtensionsLite.Builder builder = TestAllExtensionsLite.CreateBuilder() - .SetExtension(UnittestLite.RepeatedBoolExtensionLite, new[] {true, false}) - .SetExtension(UnittestLite.RepeatedCordExtensionLite, new[] {"123", "456"}) - .SetExtension(UnittestLite.RepeatedForeignEnumExtensionLite, - new[] {ForeignEnumLite.FOREIGN_LITE_BAZ, ForeignEnumLite.FOREIGN_LITE_FOO}) - ; - - msg = builder.Build(); - ExtensionRegistry registry = ExtensionRegistry.CreateInstance(); - UnittestLite.RegisterAllExtensions(registry); - - copy = TestAllExtensionsLite.ParseFrom(msg.ToByteArray(), registry); - Assert.AreEqual(msg.ToByteArray(), copy.ToByteArray()); - - Assert.AreEqual(ForeignEnumLite.FOREIGN_LITE_FOO, - copy.GetExtension(UnittestLite.RepeatedForeignEnumExtensionLite, 1)); - } - - [Test] - public void ExtensionWriterTest() - { - TestAllExtensionsLite.Builder builder = TestAllExtensionsLite.CreateBuilder() - .SetExtension(UnittestLite.DefaultBoolExtensionLite, true) - .SetExtension(UnittestLite.DefaultBytesExtensionLite, ByteString.CopyFromUtf8("123")) - .SetExtension(UnittestLite.DefaultCordExtensionLite, "123") - .SetExtension(UnittestLite.DefaultDoubleExtensionLite, 123) - .SetExtension(UnittestLite.DefaultFixed32ExtensionLite, 123u) - .SetExtension(UnittestLite.DefaultFixed64ExtensionLite, 123u) - .SetExtension(UnittestLite.DefaultFloatExtensionLite, 123) - .SetExtension(UnittestLite.DefaultForeignEnumExtensionLite, ForeignEnumLite.FOREIGN_LITE_BAZ) - .SetExtension(UnittestLite.DefaultImportEnumExtensionLite, ImportEnumLite.IMPORT_LITE_BAZ) - .SetExtension(UnittestLite.DefaultInt32ExtensionLite, 123) - .SetExtension(UnittestLite.DefaultInt64ExtensionLite, 123) - .SetExtension(UnittestLite.DefaultNestedEnumExtensionLite, - TestAllTypesLite.Types.NestedEnum.FOO) - .SetExtension(UnittestLite.DefaultSfixed32ExtensionLite, 123) - .SetExtension(UnittestLite.DefaultSfixed64ExtensionLite, 123) - .SetExtension(UnittestLite.DefaultSint32ExtensionLite, 123) - .SetExtension(UnittestLite.DefaultSint64ExtensionLite, 123) - .SetExtension(UnittestLite.DefaultStringExtensionLite, "123") - .SetExtension(UnittestLite.DefaultStringPieceExtensionLite, "123") - .SetExtension(UnittestLite.DefaultUint32ExtensionLite, 123u) - .SetExtension(UnittestLite.DefaultUint64ExtensionLite, 123u) - //Optional - .SetExtension(UnittestLite.OptionalBoolExtensionLite, true) - .SetExtension(UnittestLite.OptionalBytesExtensionLite, ByteString.CopyFromUtf8("123")) - .SetExtension(UnittestLite.OptionalCordExtensionLite, "123") - .SetExtension(UnittestLite.OptionalDoubleExtensionLite, 123) - .SetExtension(UnittestLite.OptionalFixed32ExtensionLite, 123u) - .SetExtension(UnittestLite.OptionalFixed64ExtensionLite, 123u) - .SetExtension(UnittestLite.OptionalFloatExtensionLite, 123) - .SetExtension(UnittestLite.OptionalForeignEnumExtensionLite, ForeignEnumLite.FOREIGN_LITE_BAZ) - .SetExtension(UnittestLite.OptionalImportEnumExtensionLite, ImportEnumLite.IMPORT_LITE_BAZ) - .SetExtension(UnittestLite.OptionalInt32ExtensionLite, 123) - .SetExtension(UnittestLite.OptionalInt64ExtensionLite, 123) - .SetExtension(UnittestLite.OptionalNestedEnumExtensionLite, - TestAllTypesLite.Types.NestedEnum.FOO) - .SetExtension(UnittestLite.OptionalSfixed32ExtensionLite, 123) - .SetExtension(UnittestLite.OptionalSfixed64ExtensionLite, 123) - .SetExtension(UnittestLite.OptionalSint32ExtensionLite, 123) - .SetExtension(UnittestLite.OptionalSint64ExtensionLite, 123) - .SetExtension(UnittestLite.OptionalStringExtensionLite, "123") - .SetExtension(UnittestLite.OptionalStringPieceExtensionLite, "123") - .SetExtension(UnittestLite.OptionalUint32ExtensionLite, 123u) - .SetExtension(UnittestLite.OptionalUint64ExtensionLite, 123u) - //Repeated - .AddExtension(UnittestLite.RepeatedBoolExtensionLite, true) - .AddExtension(UnittestLite.RepeatedBytesExtensionLite, ByteString.CopyFromUtf8("123")) - .AddExtension(UnittestLite.RepeatedCordExtensionLite, "123") - .AddExtension(UnittestLite.RepeatedDoubleExtensionLite, 123) - .AddExtension(UnittestLite.RepeatedFixed32ExtensionLite, 123u) - .AddExtension(UnittestLite.RepeatedFixed64ExtensionLite, 123u) - .AddExtension(UnittestLite.RepeatedFloatExtensionLite, 123) - .AddExtension(UnittestLite.RepeatedForeignEnumExtensionLite, ForeignEnumLite.FOREIGN_LITE_BAZ) - .AddExtension(UnittestLite.RepeatedImportEnumExtensionLite, ImportEnumLite.IMPORT_LITE_BAZ) - .AddExtension(UnittestLite.RepeatedInt32ExtensionLite, 123) - .AddExtension(UnittestLite.RepeatedInt64ExtensionLite, 123) - .AddExtension(UnittestLite.RepeatedNestedEnumExtensionLite, - TestAllTypesLite.Types.NestedEnum.FOO) - .AddExtension(UnittestLite.RepeatedSfixed32ExtensionLite, 123) - .AddExtension(UnittestLite.RepeatedSfixed64ExtensionLite, 123) - .AddExtension(UnittestLite.RepeatedSint32ExtensionLite, 123) - .AddExtension(UnittestLite.RepeatedSint64ExtensionLite, 123) - .AddExtension(UnittestLite.RepeatedStringExtensionLite, "123") - .AddExtension(UnittestLite.RepeatedStringPieceExtensionLite, "123") - .AddExtension(UnittestLite.RepeatedUint32ExtensionLite, 123u) - .AddExtension(UnittestLite.RepeatedUint64ExtensionLite, 123u) - ; - TestAllExtensionsLite msg = builder.Build(); - - ExtensionRegistry registry = ExtensionRegistry.CreateInstance(); - UnittestLite.RegisterAllExtensions(registry); - - TestAllExtensionsLite.Builder copyBuilder = - TestAllExtensionsLite.CreateBuilder().MergeFrom(msg.ToByteArray(), registry); - TestAllExtensionsLite copy = copyBuilder.Build(); - - Assert.AreEqual(msg.ToByteArray(), copy.ToByteArray()); - - Assert.AreEqual(true, copy.GetExtension(UnittestLite.DefaultBoolExtensionLite)); - Assert.AreEqual(ByteString.CopyFromUtf8("123"), - copy.GetExtension(UnittestLite.DefaultBytesExtensionLite)); - Assert.AreEqual("123", copy.GetExtension(UnittestLite.DefaultCordExtensionLite)); - Assert.AreEqual(123, copy.GetExtension(UnittestLite.DefaultDoubleExtensionLite)); - Assert.AreEqual(123u, copy.GetExtension(UnittestLite.DefaultFixed32ExtensionLite)); - Assert.AreEqual(123u, copy.GetExtension(UnittestLite.DefaultFixed64ExtensionLite)); - Assert.AreEqual(123, copy.GetExtension(UnittestLite.DefaultFloatExtensionLite)); - Assert.AreEqual(ForeignEnumLite.FOREIGN_LITE_BAZ, - copy.GetExtension(UnittestLite.DefaultForeignEnumExtensionLite)); - Assert.AreEqual(ImportEnumLite.IMPORT_LITE_BAZ, - copy.GetExtension(UnittestLite.DefaultImportEnumExtensionLite)); - Assert.AreEqual(123, copy.GetExtension(UnittestLite.DefaultInt32ExtensionLite)); - Assert.AreEqual(123, copy.GetExtension(UnittestLite.DefaultInt64ExtensionLite)); - Assert.AreEqual(TestAllTypesLite.Types.NestedEnum.FOO, - copy.GetExtension(UnittestLite.DefaultNestedEnumExtensionLite)); - Assert.AreEqual(123, copy.GetExtension(UnittestLite.DefaultSfixed32ExtensionLite)); - Assert.AreEqual(123, copy.GetExtension(UnittestLite.DefaultSfixed64ExtensionLite)); - Assert.AreEqual(123, copy.GetExtension(UnittestLite.DefaultSint32ExtensionLite)); - Assert.AreEqual(123, copy.GetExtension(UnittestLite.DefaultSint64ExtensionLite)); - Assert.AreEqual("123", copy.GetExtension(UnittestLite.DefaultStringExtensionLite)); - Assert.AreEqual("123", copy.GetExtension(UnittestLite.DefaultStringPieceExtensionLite)); - Assert.AreEqual(123u, copy.GetExtension(UnittestLite.DefaultUint32ExtensionLite)); - Assert.AreEqual(123u, copy.GetExtension(UnittestLite.DefaultUint64ExtensionLite)); - - Assert.AreEqual(true, copy.GetExtension(UnittestLite.OptionalBoolExtensionLite)); - Assert.AreEqual(ByteString.CopyFromUtf8("123"), - copy.GetExtension(UnittestLite.OptionalBytesExtensionLite)); - Assert.AreEqual("123", copy.GetExtension(UnittestLite.OptionalCordExtensionLite)); - Assert.AreEqual(123, copy.GetExtension(UnittestLite.OptionalDoubleExtensionLite)); - Assert.AreEqual(123u, copy.GetExtension(UnittestLite.OptionalFixed32ExtensionLite)); - Assert.AreEqual(123u, copy.GetExtension(UnittestLite.OptionalFixed64ExtensionLite)); - Assert.AreEqual(123, copy.GetExtension(UnittestLite.OptionalFloatExtensionLite)); - Assert.AreEqual(ForeignEnumLite.FOREIGN_LITE_BAZ, - copy.GetExtension(UnittestLite.OptionalForeignEnumExtensionLite)); - Assert.AreEqual(ImportEnumLite.IMPORT_LITE_BAZ, - copy.GetExtension(UnittestLite.OptionalImportEnumExtensionLite)); - Assert.AreEqual(123, copy.GetExtension(UnittestLite.OptionalInt32ExtensionLite)); - Assert.AreEqual(123, copy.GetExtension(UnittestLite.OptionalInt64ExtensionLite)); - Assert.AreEqual(TestAllTypesLite.Types.NestedEnum.FOO, - copy.GetExtension(UnittestLite.OptionalNestedEnumExtensionLite)); - Assert.AreEqual(123, copy.GetExtension(UnittestLite.OptionalSfixed32ExtensionLite)); - Assert.AreEqual(123, copy.GetExtension(UnittestLite.OptionalSfixed64ExtensionLite)); - Assert.AreEqual(123, copy.GetExtension(UnittestLite.OptionalSint32ExtensionLite)); - Assert.AreEqual(123, copy.GetExtension(UnittestLite.OptionalSint64ExtensionLite)); - Assert.AreEqual("123", copy.GetExtension(UnittestLite.OptionalStringExtensionLite)); - Assert.AreEqual("123", copy.GetExtension(UnittestLite.OptionalStringPieceExtensionLite)); - Assert.AreEqual(123u, copy.GetExtension(UnittestLite.OptionalUint32ExtensionLite)); - Assert.AreEqual(123u, copy.GetExtension(UnittestLite.OptionalUint64ExtensionLite)); - - Assert.AreEqual(true, copy.GetExtension(UnittestLite.RepeatedBoolExtensionLite, 0)); - Assert.AreEqual(ByteString.CopyFromUtf8("123"), - copy.GetExtension(UnittestLite.RepeatedBytesExtensionLite, 0)); - Assert.AreEqual("123", copy.GetExtension(UnittestLite.RepeatedCordExtensionLite, 0)); - Assert.AreEqual(123, copy.GetExtension(UnittestLite.RepeatedDoubleExtensionLite, 0)); - Assert.AreEqual(123u, copy.GetExtension(UnittestLite.RepeatedFixed32ExtensionLite, 0)); - Assert.AreEqual(123u, copy.GetExtension(UnittestLite.RepeatedFixed64ExtensionLite, 0)); - Assert.AreEqual(123, copy.GetExtension(UnittestLite.RepeatedFloatExtensionLite, 0)); - Assert.AreEqual(ForeignEnumLite.FOREIGN_LITE_BAZ, - copy.GetExtension(UnittestLite.RepeatedForeignEnumExtensionLite, 0)); - Assert.AreEqual(ImportEnumLite.IMPORT_LITE_BAZ, - copy.GetExtension(UnittestLite.RepeatedImportEnumExtensionLite, 0)); - Assert.AreEqual(123, copy.GetExtension(UnittestLite.RepeatedInt32ExtensionLite, 0)); - Assert.AreEqual(123, copy.GetExtension(UnittestLite.RepeatedInt64ExtensionLite, 0)); - Assert.AreEqual(TestAllTypesLite.Types.NestedEnum.FOO, - copy.GetExtension(UnittestLite.RepeatedNestedEnumExtensionLite, 0)); - Assert.AreEqual(123, copy.GetExtension(UnittestLite.RepeatedSfixed32ExtensionLite, 0)); - Assert.AreEqual(123, copy.GetExtension(UnittestLite.RepeatedSfixed64ExtensionLite, 0)); - Assert.AreEqual(123, copy.GetExtension(UnittestLite.RepeatedSint32ExtensionLite, 0)); - Assert.AreEqual(123, copy.GetExtension(UnittestLite.RepeatedSint64ExtensionLite, 0)); - Assert.AreEqual("123", copy.GetExtension(UnittestLite.RepeatedStringExtensionLite, 0)); - Assert.AreEqual("123", copy.GetExtension(UnittestLite.RepeatedStringPieceExtensionLite, 0)); - Assert.AreEqual(123u, copy.GetExtension(UnittestLite.RepeatedUint32ExtensionLite, 0)); - Assert.AreEqual(123u, copy.GetExtension(UnittestLite.RepeatedUint64ExtensionLite, 0)); - } - - private TestPackedExtensionsLite BuildPackedExtensions() - { - TestPackedExtensionsLite.Builder builder = TestPackedExtensionsLite.CreateBuilder() - .AddExtension(UnittestLite.PackedBoolExtensionLite, true) - .AddExtension(UnittestLite.PackedDoubleExtensionLite, 123) - .AddExtension(UnittestLite.PackedFixed32ExtensionLite, 123u) - .AddExtension(UnittestLite.PackedFixed64ExtensionLite, 123u) - .AddExtension(UnittestLite.PackedFloatExtensionLite, 123) - .AddExtension(UnittestLite.PackedInt32ExtensionLite, 123) - .AddExtension(UnittestLite.PackedInt64ExtensionLite, 123) - .AddExtension(UnittestLite.PackedSfixed32ExtensionLite, 123) - .AddExtension(UnittestLite.PackedSfixed64ExtensionLite, 123) - .AddExtension(UnittestLite.PackedSint32ExtensionLite, 123) - .AddExtension(UnittestLite.PackedSint64ExtensionLite, 123) - .AddExtension(UnittestLite.PackedUint32ExtensionLite, 123u) - .AddExtension(UnittestLite.PackedUint64ExtensionLite, 123u) - .AddExtension(UnittestLite.PackedBoolExtensionLite, true) - .AddExtension(UnittestLite.PackedDoubleExtensionLite, 123) - .AddExtension(UnittestLite.PackedFixed32ExtensionLite, 123u) - .AddExtension(UnittestLite.PackedFixed64ExtensionLite, 123u) - .AddExtension(UnittestLite.PackedFloatExtensionLite, 123) - .AddExtension(UnittestLite.PackedInt32ExtensionLite, 123) - .AddExtension(UnittestLite.PackedInt64ExtensionLite, 123) - .AddExtension(UnittestLite.PackedSfixed32ExtensionLite, 123) - .AddExtension(UnittestLite.PackedSfixed64ExtensionLite, 123) - .AddExtension(UnittestLite.PackedSint32ExtensionLite, 123) - .AddExtension(UnittestLite.PackedSint64ExtensionLite, 123) - .AddExtension(UnittestLite.PackedUint32ExtensionLite, 123u) - .AddExtension(UnittestLite.PackedUint64ExtensionLite, 123u); - - TestPackedExtensionsLite msg = builder.Build(); - return msg; - } - - private void AssertPackedExtensions(TestPackedExtensionsLite copy) - { - Assert.AreEqual(true, copy.GetExtension(UnittestLite.PackedBoolExtensionLite, 0)); - Assert.AreEqual(123, copy.GetExtension(UnittestLite.PackedDoubleExtensionLite, 0)); - Assert.AreEqual(123u, copy.GetExtension(UnittestLite.PackedFixed32ExtensionLite, 0)); - Assert.AreEqual(123u, copy.GetExtension(UnittestLite.PackedFixed64ExtensionLite, 0)); - Assert.AreEqual(123, copy.GetExtension(UnittestLite.PackedFloatExtensionLite, 0)); - Assert.AreEqual(123, copy.GetExtension(UnittestLite.PackedInt32ExtensionLite, 0)); - Assert.AreEqual(123, copy.GetExtension(UnittestLite.PackedInt64ExtensionLite, 0)); - Assert.AreEqual(123, copy.GetExtension(UnittestLite.PackedSfixed32ExtensionLite, 0)); - Assert.AreEqual(123, copy.GetExtension(UnittestLite.PackedSfixed64ExtensionLite, 0)); - Assert.AreEqual(123, copy.GetExtension(UnittestLite.PackedSint32ExtensionLite, 0)); - Assert.AreEqual(123, copy.GetExtension(UnittestLite.PackedSint64ExtensionLite, 0)); - Assert.AreEqual(123u, copy.GetExtension(UnittestLite.PackedUint32ExtensionLite, 0)); - Assert.AreEqual(123u, copy.GetExtension(UnittestLite.PackedUint64ExtensionLite, 0)); - - Assert.AreEqual(true, copy.GetExtension(UnittestLite.PackedBoolExtensionLite, 1)); - Assert.AreEqual(123, copy.GetExtension(UnittestLite.PackedDoubleExtensionLite, 1)); - Assert.AreEqual(123u, copy.GetExtension(UnittestLite.PackedFixed32ExtensionLite, 1)); - Assert.AreEqual(123u, copy.GetExtension(UnittestLite.PackedFixed64ExtensionLite, 1)); - Assert.AreEqual(123, copy.GetExtension(UnittestLite.PackedFloatExtensionLite, 1)); - Assert.AreEqual(123, copy.GetExtension(UnittestLite.PackedInt32ExtensionLite, 1)); - Assert.AreEqual(123, copy.GetExtension(UnittestLite.PackedInt64ExtensionLite, 1)); - Assert.AreEqual(123, copy.GetExtension(UnittestLite.PackedSfixed32ExtensionLite, 1)); - Assert.AreEqual(123, copy.GetExtension(UnittestLite.PackedSfixed64ExtensionLite, 1)); - Assert.AreEqual(123, copy.GetExtension(UnittestLite.PackedSint32ExtensionLite, 1)); - Assert.AreEqual(123, copy.GetExtension(UnittestLite.PackedSint64ExtensionLite, 1)); - Assert.AreEqual(123u, copy.GetExtension(UnittestLite.PackedUint32ExtensionLite, 1)); - Assert.AreEqual(123u, copy.GetExtension(UnittestLite.PackedUint64ExtensionLite, 1)); - } - - [Test] - public void ExtensionWriterTestPacked() - { - TestPackedExtensionsLite msg = BuildPackedExtensions(); - - ExtensionRegistry registry = ExtensionRegistry.CreateInstance(); - UnittestLite.RegisterAllExtensions(registry); - - TestPackedExtensionsLite.Builder copyBuilder = - TestPackedExtensionsLite.CreateBuilder().MergeFrom(msg.ToByteArray(), registry); - TestPackedExtensionsLite copy = copyBuilder.Build(); - - Assert.AreEqual(msg.ToByteArray(), copy.ToByteArray()); - - AssertPackedExtensions(copy); - } - - [Test] - public void TestUnpackedAndPackedExtensions() - { - TestPackedExtensionsLite original = BuildPackedExtensions(); - AssertPackedExtensions(original); - - ExtensionRegistry registry = ExtensionRegistry.CreateInstance(); - UnittestLite.RegisterAllExtensions(registry); - UnittestExtrasLite.RegisterAllExtensions(registry); - - TestUnpackedExtensionsLite unpacked = TestUnpackedExtensionsLite.ParseFrom(original.ToByteArray(), registry); - - TestPackedExtensionsLite packed = TestPackedExtensionsLite.ParseFrom(unpacked.ToByteArray(), registry); - - Assert.AreEqual(original, packed); - Assert.AreEqual(original.ToByteArray(), packed.ToByteArray()); - AssertPackedExtensions(packed); - } - - [Test] - public void TestUnpackedFromPackedInput() - { - byte[] packedData = BuildPackedExtensions().ToByteArray(); - - TestUnpackedTypesLite unpacked = TestUnpackedTypesLite.ParseFrom(packedData); - TestPackedTypesLite packed = TestPackedTypesLite.ParseFrom(unpacked.ToByteArray()); - Assert.AreEqual(packedData, packed.ToByteArray()); - - unpacked = TestUnpackedTypesLite.ParseFrom(packed.ToByteArray()); - - ExtensionRegistry registry = ExtensionRegistry.CreateInstance(); - UnittestLite.RegisterAllExtensions(registry); - AssertPackedExtensions(TestPackedExtensionsLite.ParseFrom(unpacked.ToByteArray(), registry)); - } - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffersLite.Test/InteropLiteTest.cs b/csharp/src/ProtocolBuffersLite.Test/InteropLiteTest.cs deleted file mode 100644 index 227b53d2..00000000 --- a/csharp/src/ProtocolBuffersLite.Test/InteropLiteTest.cs +++ /dev/null @@ -1,185 +0,0 @@ -#region Copyright notice and license - -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/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 Google.ProtocolBuffers.TestProtos; -using NUnit.Framework; - -namespace Google.ProtocolBuffers -{ - public class InteropLiteTest - { - [Test] - public void TestConvertFromFullMinimal() - { - TestInteropPerson person = TestInteropPerson.CreateBuilder() - .SetId(123) - .SetName("abc") - .Build(); - Assert.IsTrue(person.IsInitialized); - - TestInteropPersonLite copy = TestInteropPersonLite.ParseFrom(person.ToByteArray()); - - Assert.AreEqual(person.ToByteArray(), copy.ToByteArray()); - } - - [Test] - public void TestConvertFromFullComplete() - { - TestInteropPerson person = TestInteropPerson.CreateBuilder() - .SetId(123) - .SetName("abc") - .SetEmail("abc@123.com") - .AddRangeCodes(new[] {1, 2, 3}) - .AddPhone(TestInteropPerson.Types.PhoneNumber.CreateBuilder().SetNumber("555-1234").Build()) - .AddPhone(TestInteropPerson.Types.PhoneNumber.CreateBuilder().SetNumber("555-5678").Build()) - .AddAddresses( - TestInteropPerson.Types.Addresses.CreateBuilder().SetAddress("123 Seseme").SetCity("Wonderland"). - SetState("NA").SetZip(12345).Build()) - .SetExtension(UnittestExtrasFull.EmployeeId, - TestInteropEmployeeId.CreateBuilder().SetNumber("123").Build()) - .Build(); - Assert.IsTrue(person.IsInitialized); - - ExtensionRegistry registry = ExtensionRegistry.CreateInstance(); - UnittestExtrasLite.RegisterAllExtensions(registry); - byte[] fullBytes = person.ToByteArray(); - - TestInteropPersonLite copy = TestInteropPersonLite.ParseFrom(fullBytes, registry); - byte[] liteBytes = copy.ToByteArray(); - - Assert.AreEqual(fullBytes, liteBytes); - } - - [Test] - public void TestConvertFromLiteMinimal() - { - TestInteropPersonLite person = TestInteropPersonLite.CreateBuilder() - .SetId(123) - .SetName("abc") - .Build(); - Assert.IsTrue(person.IsInitialized); - - TestInteropPerson copy = TestInteropPerson.ParseFrom(person.ToByteArray()); - - Assert.AreEqual(person.ToByteArray(), copy.ToByteArray()); - } - - [Test] - public void TestConvertFromLiteComplete() - { - TestInteropPersonLite person = TestInteropPersonLite.CreateBuilder() - .SetId(123) - .SetName("abc") - .SetEmail("abc@123.com") - .AddRangeCodes(new[] {1, 2, 3}) - .AddPhone(TestInteropPersonLite.Types.PhoneNumber.CreateBuilder().SetNumber("555-1234").Build()) - .AddPhone(TestInteropPersonLite.Types.PhoneNumber.CreateBuilder().SetNumber("555-5678").Build()) - .AddAddresses( - TestInteropPersonLite.Types.Addresses.CreateBuilder().SetAddress("123 Seseme").SetCity("Wonderland") - .SetState("NA").SetZip(12345).Build()) - .SetExtension(UnittestExtrasLite.EmployeeIdLite, - TestInteropEmployeeIdLite.CreateBuilder().SetNumber("123").Build()) - .Build(); - Assert.IsTrue(person.IsInitialized); - - ExtensionRegistry registry = ExtensionRegistry.CreateInstance(); - UnittestExtrasFull.RegisterAllExtensions(registry); - - TestInteropPerson copy = TestInteropPerson.ParseFrom(person.ToByteArray(), registry); - - Assert.AreEqual(person.ToByteArray(), copy.ToByteArray()); - } - - public ByteString AllBytes - { - get - { - byte[] bytes = new byte[256]; - for (int i = 0; i < bytes.Length; i++) - bytes[i] = (byte) i; - return ByteString.CopyFrom(bytes); - } - } - - [Test] - public void TestCompareStringValues() - { - TestInteropPersonLite person = TestInteropPersonLite.CreateBuilder() - .SetId(123) - .SetName("abc") - .SetEmail("abc@123.com") - .AddRangeCodes(new[] {1, 2, 3}) - .AddPhone(TestInteropPersonLite.Types.PhoneNumber.CreateBuilder().SetNumber("555-1234").Build()) - .AddPhone( - TestInteropPersonLite.Types.PhoneNumber.CreateBuilder().SetNumber( - System.Text.Encoding.UTF8.GetString(AllBytes.ToByteArray(), 0, AllBytes.Length)).Build()) - .AddAddresses( - TestInteropPersonLite.Types.Addresses.CreateBuilder().SetAddress("123 Seseme").SetCity("Wonderland") - .SetState("NA").SetZip(12345).Build()) - .SetExtension(UnittestExtrasLite.EmployeeIdLite, - TestInteropEmployeeIdLite.CreateBuilder().SetNumber("123").Build()) - .Build(); - Assert.IsTrue(person.IsInitialized); - - ExtensionRegistry registry = ExtensionRegistry.CreateInstance(); - UnittestExtrasFull.RegisterAllExtensions(registry); - - TestInteropPerson copy = TestInteropPerson.ParseFrom(person.ToByteArray(), registry); - - Assert.AreEqual(person.ToByteArray(), copy.ToByteArray()); - - TestInteropPerson.Builder copyBuilder = TestInteropPerson.CreateBuilder(); - TextFormat.Merge( - person.ToString().Replace("[protobuf_unittest_extra.employee_id_lite]", - "[protobuf_unittest_extra.employee_id]"), registry, copyBuilder); - - copy = copyBuilder.Build(); - Assert.AreEqual(person.ToByteArray(), copy.ToByteArray()); - - string liteText = person.ToString().TrimEnd().Replace("\r", ""); - string fullText = copy.ToString().TrimEnd().Replace("\r", ""); - //map the extension type - liteText = liteText.Replace("[protobuf_unittest_extra.employee_id_lite]", - "[protobuf_unittest_extra.employee_id]"); - //lite version does not indent - while (fullText.IndexOf("\n ", StringComparison.Ordinal) >= 0) - fullText = fullText.Replace("\n ", "\n"); - - Assert.AreEqual(fullText, liteText); - } - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffersLite.Test/LiteTest.cs b/csharp/src/ProtocolBuffersLite.Test/LiteTest.cs deleted file mode 100644 index 5defc26e..00000000 --- a/csharp/src/ProtocolBuffersLite.Test/LiteTest.cs +++ /dev/null @@ -1,113 +0,0 @@ -#region Copyright notice and license - -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/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 Google.ProtocolBuffers.TestProtos; -using NUnit.Framework; - -namespace Google.ProtocolBuffers -{ - /// - /// Miscellaneous tests for message operations that apply to both - /// generated and dynamic messages. - /// - public class LiteTest - { - [Test] - public void TestLite() - { - // Since lite messages are a subset of regular messages, we can mostly - // assume that the functionality of lite messages is already thoroughly - // tested by the regular tests. All this test really verifies is that - // a proto with optimize_for = LITE_RUNTIME compiles correctly when - // linked only against the lite library. That is all tested at compile - // time, leaving not much to do in this method. Let's just do some random - // stuff to make sure the lite message is actually here and usable. - - TestAllTypesLite message = - TestAllTypesLite.CreateBuilder() - .SetOptionalInt32(123) - .AddRepeatedString("hello") - .SetOptionalNestedMessage( - TestAllTypesLite.Types.NestedMessage.CreateBuilder().SetBb(7)) - .Build(); - - ByteString data = message.ToByteString(); - - TestAllTypesLite message2 = TestAllTypesLite.ParseFrom(data); - - Assert.AreEqual(123, message2.OptionalInt32); - Assert.AreEqual(1, message2.RepeatedStringCount); - Assert.AreEqual("hello", message2.RepeatedStringList[0]); - Assert.AreEqual(7, message2.OptionalNestedMessage.Bb); - } - - [Test] - public void TestLiteExtensions() - { - // TODO(kenton): Unlike other features of the lite library, extensions are - // implemented completely differently from the regular library. We - // should probably test them more thoroughly. - - TestAllExtensionsLite message = - TestAllExtensionsLite.CreateBuilder() - .SetExtension(UnittestLite.OptionalInt32ExtensionLite, 123) - .AddExtension(UnittestLite.RepeatedStringExtensionLite, "hello") - .SetExtension(UnittestLite.OptionalNestedEnumExtensionLite, - TestAllTypesLite.Types.NestedEnum.BAZ) - .SetExtension(UnittestLite.OptionalNestedMessageExtensionLite, - TestAllTypesLite.Types.NestedMessage.CreateBuilder().SetBb(7).Build()) - .Build(); - - // Test copying a message, since coping extensions actually does use a - // different code path between lite and regular libraries, and as of this - // writing, parsing hasn't been implemented yet. - TestAllExtensionsLite message2 = message.ToBuilder().Build(); - - Assert.AreEqual(123, (int) message2.GetExtension( - UnittestLite.OptionalInt32ExtensionLite)); - Assert.AreEqual(1, message2.GetExtensionCount( - UnittestLite.RepeatedStringExtensionLite)); - Assert.AreEqual(1, message2.GetExtension( - UnittestLite.RepeatedStringExtensionLite).Count); - Assert.AreEqual("hello", message2.GetExtension( - UnittestLite.RepeatedStringExtensionLite, 0)); - Assert.AreEqual(TestAllTypesLite.Types.NestedEnum.BAZ, message2.GetExtension( - UnittestLite.OptionalNestedEnumExtensionLite)); - Assert.AreEqual(7, message2.GetExtension( - UnittestLite.OptionalNestedMessageExtensionLite).Bb); - } - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffersLite.Test/MissingFieldAndExtensionTest.cs b/csharp/src/ProtocolBuffersLite.Test/MissingFieldAndExtensionTest.cs deleted file mode 100644 index 2385bde5..00000000 --- a/csharp/src/ProtocolBuffersLite.Test/MissingFieldAndExtensionTest.cs +++ /dev/null @@ -1,237 +0,0 @@ -#region Copyright notice and license - -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/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 Google.ProtocolBuffers.TestProtos; -using NUnit.Framework; - -namespace Google.ProtocolBuffers -{ - public class MissingFieldAndExtensionTest - { - [Test] - public void TestRecoverMissingExtensions() - { - const int optionalInt32 = 12345678; - TestAllExtensions.Builder builder = TestAllExtensions.CreateBuilder(); - builder.SetExtension(Unittest.OptionalInt32Extension, optionalInt32); - builder.AddExtension(Unittest.RepeatedDoubleExtension, 1.1); - builder.AddExtension(Unittest.RepeatedDoubleExtension, 1.2); - builder.AddExtension(Unittest.RepeatedDoubleExtension, 1.3); - TestAllExtensions msg = builder.Build(); - - Assert.IsTrue(msg.HasExtension(Unittest.OptionalInt32Extension)); - Assert.AreEqual(3, msg.GetExtensionCount(Unittest.RepeatedDoubleExtension)); - - byte[] bits = msg.ToByteArray(); - TestAllExtensions copy = TestAllExtensions.ParseFrom(bits); - Assert.IsFalse(copy.HasExtension(Unittest.OptionalInt32Extension)); - Assert.AreEqual(0, copy.GetExtensionCount(Unittest.RepeatedDoubleExtension)); - Assert.AreNotEqual(msg, copy); - - //Even though copy does not understand the typees they serialize correctly - byte[] copybits = copy.ToByteArray(); - Assert.AreEqual(bits, copybits); - - ExtensionRegistry registry = ExtensionRegistry.CreateInstance(); - Unittest.RegisterAllExtensions(registry); - - //Now we can take those copy bits and restore the full message with extensions - copy = TestAllExtensions.ParseFrom(copybits, registry); - Assert.IsTrue(copy.HasExtension(Unittest.OptionalInt32Extension)); - Assert.AreEqual(3, copy.GetExtensionCount(Unittest.RepeatedDoubleExtension)); - - Assert.AreEqual(msg, copy); - Assert.AreEqual(bits, copy.ToByteArray()); - - //If we modify the object this should all continue to work as before - copybits = copy.ToBuilder().Build().ToByteArray(); - Assert.AreEqual(bits, copybits); - - //If we replace extension the object this should all continue to work as before - copybits = copy.ToBuilder() - .SetExtension(Unittest.OptionalInt32Extension, optionalInt32) - .Build().ToByteArray(); - Assert.AreEqual(bits, copybits); - } - - [Test] - public void TestRecoverMissingFields() - { - TestMissingFieldsA msga = TestMissingFieldsA.CreateBuilder() - .SetId(1001) - .SetName("Name") - .SetEmail("missing@field.value") - .Build(); - - //serialize to type B and verify all fields exist - TestMissingFieldsB msgb = TestMissingFieldsB.ParseFrom(msga.ToByteArray()); - Assert.AreEqual(1001, msgb.Id); - Assert.AreEqual("Name", msgb.Name); - Assert.IsFalse(msgb.HasWebsite); - Assert.AreEqual(1, msgb.UnknownFields.FieldDictionary.Count); - Assert.AreEqual("missing@field.value", - msgb.UnknownFields[TestMissingFieldsA.EmailFieldNumber].LengthDelimitedList[0].ToStringUtf8()); - - //serializes exactly the same (at least for this simple example) - Assert.AreEqual(msga.ToByteArray(), msgb.ToByteArray()); - Assert.AreEqual(msga, TestMissingFieldsA.ParseFrom(msgb.ToByteArray())); - - //now re-create an exact copy of A from serialized B - TestMissingFieldsA copya = TestMissingFieldsA.ParseFrom(msgb.ToByteArray()); - Assert.AreEqual(msga, copya); - Assert.AreEqual(1001, copya.Id); - Assert.AreEqual("Name", copya.Name); - Assert.AreEqual("missing@field.value", copya.Email); - - //Now we modify B... and try again - msgb = msgb.ToBuilder().SetWebsite("http://new.missing.field").Build(); - //Does B still have the missing field? - Assert.AreEqual(1, msgb.UnknownFields.FieldDictionary.Count); - - //Convert back to A and see if all fields are there? - copya = TestMissingFieldsA.ParseFrom(msgb.ToByteArray()); - Assert.AreNotEqual(msga, copya); - Assert.AreEqual(1001, copya.Id); - Assert.AreEqual("Name", copya.Name); - Assert.AreEqual("missing@field.value", copya.Email); - Assert.AreEqual(1, copya.UnknownFields.FieldDictionary.Count); - Assert.AreEqual("http://new.missing.field", - copya.UnknownFields[TestMissingFieldsB.WebsiteFieldNumber].LengthDelimitedList[0]. - ToStringUtf8()); - - //Lastly we can even still trip back to type B and see all fields: - TestMissingFieldsB copyb = TestMissingFieldsB.ParseFrom(copya.ToByteArray()); - Assert.AreEqual(copya.ToByteArray().Length, copyb.ToByteArray().Length); //not exact order. - Assert.AreEqual(1001, copyb.Id); - Assert.AreEqual("Name", copyb.Name); - Assert.AreEqual("http://new.missing.field", copyb.Website); - Assert.AreEqual(1, copyb.UnknownFields.FieldDictionary.Count); - Assert.AreEqual("missing@field.value", - copyb.UnknownFields[TestMissingFieldsA.EmailFieldNumber].LengthDelimitedList[0].ToStringUtf8 - ()); - } - - [Test] - public void TestRecoverMissingMessage() - { - TestMissingFieldsA.Types.SubA suba = - TestMissingFieldsA.Types.SubA.CreateBuilder().SetCount(3).AddValues("a").AddValues("b").AddValues("c"). - Build(); - TestMissingFieldsA msga = TestMissingFieldsA.CreateBuilder() - .SetId(1001) - .SetName("Name") - .SetTestA(suba) - .Build(); - - //serialize to type B and verify all fields exist - TestMissingFieldsB msgb = TestMissingFieldsB.ParseFrom(msga.ToByteArray()); - Assert.AreEqual(1001, msgb.Id); - Assert.AreEqual("Name", msgb.Name); - Assert.AreEqual(1, msgb.UnknownFields.FieldDictionary.Count); - Assert.AreEqual(suba.ToString(), - TestMissingFieldsA.Types.SubA.ParseFrom( - msgb.UnknownFields[TestMissingFieldsA.TestAFieldNumber].LengthDelimitedList[0]).ToString - ()); - - //serializes exactly the same (at least for this simple example) - Assert.AreEqual(msga.ToByteArray(), msgb.ToByteArray()); - Assert.AreEqual(msga, TestMissingFieldsA.ParseFrom(msgb.ToByteArray())); - - //now re-create an exact copy of A from serialized B - TestMissingFieldsA copya = TestMissingFieldsA.ParseFrom(msgb.ToByteArray()); - Assert.AreEqual(msga, copya); - Assert.AreEqual(1001, copya.Id); - Assert.AreEqual("Name", copya.Name); - Assert.AreEqual(suba, copya.TestA); - - //Now we modify B... and try again - TestMissingFieldsB.Types.SubB subb = - TestMissingFieldsB.Types.SubB.CreateBuilder().AddValues("test-b").Build(); - msgb = msgb.ToBuilder().SetTestB(subb).Build(); - //Does B still have the missing field? - Assert.AreEqual(1, msgb.UnknownFields.FieldDictionary.Count); - - //Convert back to A and see if all fields are there? - copya = TestMissingFieldsA.ParseFrom(msgb.ToByteArray()); - Assert.AreNotEqual(msga, copya); - Assert.AreEqual(1001, copya.Id); - Assert.AreEqual("Name", copya.Name); - Assert.AreEqual(suba, copya.TestA); - Assert.AreEqual(1, copya.UnknownFields.FieldDictionary.Count); - Assert.AreEqual(subb.ToByteArray(), - copya.UnknownFields[TestMissingFieldsB.TestBFieldNumber].LengthDelimitedList[0].ToByteArray()); - - //Lastly we can even still trip back to type B and see all fields: - TestMissingFieldsB copyb = TestMissingFieldsB.ParseFrom(copya.ToByteArray()); - Assert.AreEqual(copya.ToByteArray().Length, copyb.ToByteArray().Length); //not exact order. - Assert.AreEqual(1001, copyb.Id); - Assert.AreEqual("Name", copyb.Name); - Assert.AreEqual(subb, copyb.TestB); - Assert.AreEqual(1, copyb.UnknownFields.FieldDictionary.Count); - } - - [Test] - public void TestRestoreFromOtherType() - { - TestInteropPerson person = TestInteropPerson.CreateBuilder() - .SetId(123) - .SetName("abc") - .SetEmail("abc@123.com") - .AddRangeCodes(new[] {1, 2, 3}) - .AddPhone(TestInteropPerson.Types.PhoneNumber.CreateBuilder().SetNumber("555-1234").Build()) - .AddPhone(TestInteropPerson.Types.PhoneNumber.CreateBuilder().SetNumber("555-5678").Build()) - .AddAddresses( - TestInteropPerson.Types.Addresses.CreateBuilder().SetAddress("123 Seseme").SetCity("Wonderland"). - SetState("NA").SetZip(12345).Build()) - .SetExtension(UnittestExtrasFull.EmployeeId, - TestInteropEmployeeId.CreateBuilder().SetNumber("123").Build()) - .Build(); - Assert.IsTrue(person.IsInitialized); - - TestEmptyMessage temp = TestEmptyMessage.ParseFrom(person.ToByteArray()); - Assert.AreEqual(7, temp.UnknownFields.FieldDictionary.Count); - temp = temp.ToBuilder().Build(); - Assert.AreEqual(7, temp.UnknownFields.FieldDictionary.Count); - - ExtensionRegistry registry = ExtensionRegistry.CreateInstance(); - UnittestExtrasFull.RegisterAllExtensions(registry); - - TestInteropPerson copy = TestInteropPerson.ParseFrom(temp.ToByteArray(), registry); - Assert.AreEqual(person, copy); - Assert.AreEqual(person.ToByteArray(), copy.ToByteArray()); - } - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffersLite.Test/Properties/AppManifest.xml b/csharp/src/ProtocolBuffersLite.Test/Properties/AppManifest.xml deleted file mode 100644 index a9552327..00000000 --- a/csharp/src/ProtocolBuffersLite.Test/Properties/AppManifest.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - diff --git a/csharp/src/ProtocolBuffersLite.Test/Properties/OutOfBrowserSettings.xml b/csharp/src/ProtocolBuffersLite.Test/Properties/OutOfBrowserSettings.xml deleted file mode 100644 index 634f44bf..00000000 --- a/csharp/src/ProtocolBuffersLite.Test/Properties/OutOfBrowserSettings.xml +++ /dev/null @@ -1,7 +0,0 @@ - - ProtocolBuffers.Test - - - - - \ No newline at end of file diff --git a/csharp/src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test.csproj b/csharp/src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test.csproj deleted file mode 100644 index 4d813f83..00000000 --- a/csharp/src/ProtocolBuffersLite.Test/ProtocolBuffersLite.Test.csproj +++ /dev/null @@ -1,113 +0,0 @@ - - - - Debug - AnyCPU - 9.0.30729 - 2.0 - {EE01ED24-3750-4567-9A23-1DB676A15610} - Library - Properties - Google.ProtocolBuffers - Google.ProtocolBuffersLite.Test - v4.5 - 512 - true - ..\..\keys\Google.ProtocolBuffers.snk - 3.5 - - - - - - - true - full - false - bin\Debug - obj\Debug\ - DEBUG;TRACE;$(EnvironmentFlavor);$(EnvironmentTemplate) - prompt - 4 - true - Off - false - - - pdbonly - true - bin\Release - obj\Release\ - TRACE;$(EnvironmentFlavor);$(EnvironmentTemplate) - prompt - 4 - true - Off - false - - - - - ..\packages\NUnitTestAdapter.2.0.0\lib\nunit.core.dll - True - - - ..\packages\NUnitTestAdapter.2.0.0\lib\nunit.core.interfaces.dll - True - - - ..\packages\NUnit.2.6.4\lib\nunit.framework.dll - True - - - ..\packages\NUnitTestAdapter.2.0.0\lib\nunit.util.dll - True - - - ..\packages\NUnitTestAdapter.2.0.0\lib\NUnit.VisualStudio.TestAdapter.dll - True - - - - - - - Properties\AssemblyInfo.cs - - - - - - - - - - - - - - - {E067A59D-9D0A-4A1F-92B1-38E4457241D1} - ProtocolBuffersLite.Serialization - - - {6969BDCE-D925-43F3-94AC-A531E6DF2591} - ProtocolBuffersLite - True - - - - - - - - - - - \ No newline at end of file diff --git a/csharp/src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.csproj b/csharp/src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.csproj deleted file mode 100644 index c42ab93c..00000000 --- a/csharp/src/ProtocolBuffersLite.Test/ProtocolBuffersLiteMixed.Test.csproj +++ /dev/null @@ -1,110 +0,0 @@ - - - - Debug - AnyCPU - 9.0.30729 - 2.0 - {EEFFED24-3750-4567-9A23-1DB676A15610} - Library - Properties - Google.ProtocolBuffers - Google.ProtocolBuffersMixedLite.Test - v4.5 - 512 - true - ..\..\keys\Google.ProtocolBuffers.snk - 3.5 - - - - - true - full - false - bin\Debug - obj\Debug\ - DEBUG;TRACE;$(EnvironmentFlavor);$(EnvironmentTemplate) - prompt - 4 - true - Off - false - - - pdbonly - true - bin\Release - obj\Release\ - TRACE;$(EnvironmentFlavor);$(EnvironmentTemplate) - prompt - 4 - true - Off - false - - - - - ..\packages\NUnitTestAdapter.2.0.0\lib\nunit.core.dll - True - - - ..\packages\NUnitTestAdapter.2.0.0\lib\nunit.core.interfaces.dll - True - - - ..\packages\NUnit.2.6.4\lib\nunit.framework.dll - True - - - ..\packages\NUnitTestAdapter.2.0.0\lib\nunit.util.dll - True - - - ..\packages\NUnitTestAdapter.2.0.0\lib\NUnit.VisualStudio.TestAdapter.dll - True - - - - - - - Properties\AssemblyInfo.cs - - - - - - - - - - - - - - - - - - - - - - {6908BDCE-D925-43F3-94AC-A531E6DF2591} - ProtocolBuffers - - - - - - - - \ No newline at end of file diff --git a/csharp/src/ProtocolBuffersLite.Test/TestLiteByApi.cs b/csharp/src/ProtocolBuffersLite.Test/TestLiteByApi.cs deleted file mode 100644 index 9c864618..00000000 --- a/csharp/src/ProtocolBuffersLite.Test/TestLiteByApi.cs +++ /dev/null @@ -1,120 +0,0 @@ -#region Copyright notice and license - -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/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 Google.ProtocolBuffers.TestProtos; -using NUnit.Framework; - -namespace Google.ProtocolBuffers -{ - public class TestLiteByApi - { - [Test] - public void TestAllTypesEquality() - { - TestAllTypesLite msg = TestAllTypesLite.DefaultInstance; - TestAllTypesLite copy = msg.ToBuilder().Build(); - Assert.AreEqual(msg.GetHashCode(), copy.GetHashCode()); - Assert.IsTrue(msg.Equals(copy)); - msg = msg.ToBuilder().SetOptionalString("Hi").Build(); - Assert.AreNotEqual(msg.GetHashCode(), copy.GetHashCode()); - Assert.IsFalse(msg.Equals(copy)); - copy = copy.ToBuilder().SetOptionalString("Hi").Build(); - Assert.AreEqual(msg.GetHashCode(), copy.GetHashCode()); - Assert.IsTrue(msg.Equals(copy)); - } - - [Test] - public void TestEqualityOnExtensions() - { - TestAllExtensionsLite msg = TestAllExtensionsLite.DefaultInstance; - TestAllExtensionsLite copy = msg.ToBuilder().Build(); - Assert.AreEqual(msg.GetHashCode(), copy.GetHashCode()); - Assert.IsTrue(msg.Equals(copy)); - msg = msg.ToBuilder().SetExtension(UnittestLite.OptionalStringExtensionLite, "Hi").Build(); - Assert.AreNotEqual(msg.GetHashCode(), copy.GetHashCode()); - Assert.IsFalse(msg.Equals(copy)); - copy = copy.ToBuilder().SetExtension(UnittestLite.OptionalStringExtensionLite, "Hi").Build(); - Assert.AreEqual(msg.GetHashCode(), copy.GetHashCode()); - Assert.IsTrue(msg.Equals(copy)); - } - - [Test] - public void TestAllTypesToString() - { - TestAllTypesLite msg = TestAllTypesLite.DefaultInstance; - TestAllTypesLite copy = msg.ToBuilder().Build(); - Assert.AreEqual(msg.ToString(), copy.ToString()); - Assert.AreEqual(0, msg.ToString().Length); - msg = msg.ToBuilder().SetOptionalInt32(-1).Build(); - Assert.AreEqual("optional_int32: -1", msg.ToString().TrimEnd()); - msg = msg.ToBuilder().SetOptionalString("abc123").Build(); - Assert.AreEqual("optional_int32: -1\noptional_string: \"abc123\"", - msg.ToString().Replace("\r", "").TrimEnd()); - } - - [Test] - public void TestAllTypesDefaultedRoundTrip() - { - TestAllTypesLite msg = TestAllTypesLite.DefaultInstance; - Assert.IsTrue(msg.IsInitialized); - TestAllTypesLite copy = TestAllTypesLite.CreateBuilder().MergeFrom(msg.ToByteArray()).Build(); - Assert.AreEqual(msg.ToByteArray(), copy.ToByteArray()); - } - - [Test] - public void TestAllTypesModifiedRoundTrip() - { - TestAllTypesLite msg = TestAllTypesLite.DefaultInstance; - msg.ToBuilder() - .SetOptionalBool(true) - .SetOptionalCord("Hi") - .SetOptionalDouble(1.123) - .SetOptionalForeignEnum(ForeignEnumLite.FOREIGN_LITE_FOO) - .SetOptionalForeignMessage(ForeignMessageLite.CreateBuilder().SetC('c').Build()) - .SetOptionalGroup(TestAllTypesLite.Types.OptionalGroup.CreateBuilder().SetA('a').Build()) - .SetOptionalImportEnum(ImportEnumLite.IMPORT_LITE_BAR) - .SetOptionalInt32(32) - .SetOptionalInt64(64) - .SetOptionalNestedEnum(TestAllTypesLite.Types.NestedEnum.FOO) - .SetOptionalString("SetOptionalString") - .AddRepeatedGroup(TestAllTypesLite.Types.RepeatedGroup.CreateBuilder().SetA('a').Build()) - .AddRepeatedGroup(TestAllTypesLite.Types.RepeatedGroup.CreateBuilder().SetA('A').Build()) - ; - TestAllTypesLite copy = TestAllTypesLite.CreateBuilder().MergeFrom(msg.ToByteArray()).Build(); - Assert.AreEqual(msg.ToByteArray(), copy.ToByteArray()); - } - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffersLite.Test/TestProtos/Unittest.cs b/csharp/src/ProtocolBuffersLite.Test/TestProtos/Unittest.cs deleted file mode 100644 index d3441937..00000000 --- a/csharp/src/ProtocolBuffersLite.Test/TestProtos/Unittest.cs +++ /dev/null @@ -1,33878 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/protobuf/unittest.proto -#pragma warning disable 1591, 0612, 3021 -#region Designer generated code - -using pb = global::Google.ProtocolBuffers; -using pbc = global::Google.ProtocolBuffers.Collections; -using pbd = global::Google.ProtocolBuffers.Descriptors; -using scg = global::System.Collections.Generic; -namespace Google.ProtocolBuffers.TestProtos { - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class Unittest { - - #region Extension registration - public static void RegisterAllExtensions(pb::ExtensionRegistry registry) { - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalInt32Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalInt64Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalUint32Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalUint64Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalSint32Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalSint64Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalFixed32Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalFixed64Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalSfixed32Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalSfixed64Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalFloatExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalDoubleExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalBoolExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalStringExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalBytesExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalGroupExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalNestedMessageExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalForeignMessageExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalImportMessageExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalNestedEnumExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalForeignEnumExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalImportEnumExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalStringPieceExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalCordExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalPublicImportMessageExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalLazyMessageExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedInt32Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedInt64Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedUint32Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedUint64Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedSint32Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedSint64Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedFixed32Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedFixed64Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedSfixed32Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedSfixed64Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedFloatExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedDoubleExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedBoolExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedStringExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedBytesExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedGroupExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedNestedMessageExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedForeignMessageExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedImportMessageExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedNestedEnumExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedForeignEnumExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedImportEnumExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedStringPieceExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedCordExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedLazyMessageExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultInt32Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultInt64Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultUint32Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultUint64Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultSint32Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultSint64Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultFixed32Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultFixed64Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultSfixed32Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultSfixed64Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultFloatExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultDoubleExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultBoolExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultStringExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultBytesExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultNestedEnumExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultForeignEnumExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultImportEnumExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultStringPieceExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultCordExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OneofUint32Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OneofNestedMessageExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OneofStringExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OneofBytesExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.MyExtensionString); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.MyExtensionInt); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.PackedInt32Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.PackedInt64Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.PackedUint32Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.PackedUint64Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.PackedSint32Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.PackedSint64Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.PackedFixed32Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.PackedFixed64Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.PackedSfixed32Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.PackedSfixed64Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.PackedFloatExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.PackedDoubleExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.PackedBoolExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.PackedEnumExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedInt32Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedInt64Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedUint32Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedUint64Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedSint32Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedSint64Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedFixed32Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedFixed64Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedSfixed32Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedSfixed64Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedFloatExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedDoubleExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedBoolExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedEnumExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.TestNestedExtension.Test); - registry.Add(global::Google.ProtocolBuffers.TestProtos.TestNestedExtension.NestedStringExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.TestRequired.Single); - registry.Add(global::Google.ProtocolBuffers.TestProtos.TestRequired.Multi); - registry.Add(global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.OptionalExt); - registry.Add(global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.RepeatedExt); - } - #endregion - #region Extensions - public const int OptionalInt32ExtensionFieldNumber = 1; - public static pb::GeneratedExtensionBase OptionalInt32Extension; - public const int OptionalInt64ExtensionFieldNumber = 2; - public static pb::GeneratedExtensionBase OptionalInt64Extension; - public const int OptionalUint32ExtensionFieldNumber = 3; - public static pb::GeneratedExtensionBase OptionalUint32Extension; - public const int OptionalUint64ExtensionFieldNumber = 4; - public static pb::GeneratedExtensionBase OptionalUint64Extension; - public const int OptionalSint32ExtensionFieldNumber = 5; - public static pb::GeneratedExtensionBase OptionalSint32Extension; - public const int OptionalSint64ExtensionFieldNumber = 6; - public static pb::GeneratedExtensionBase OptionalSint64Extension; - public const int OptionalFixed32ExtensionFieldNumber = 7; - public static pb::GeneratedExtensionBase OptionalFixed32Extension; - public const int OptionalFixed64ExtensionFieldNumber = 8; - public static pb::GeneratedExtensionBase OptionalFixed64Extension; - public const int OptionalSfixed32ExtensionFieldNumber = 9; - public static pb::GeneratedExtensionBase OptionalSfixed32Extension; - public const int OptionalSfixed64ExtensionFieldNumber = 10; - public static pb::GeneratedExtensionBase OptionalSfixed64Extension; - public const int OptionalFloatExtensionFieldNumber = 11; - public static pb::GeneratedExtensionBase OptionalFloatExtension; - public const int OptionalDoubleExtensionFieldNumber = 12; - public static pb::GeneratedExtensionBase OptionalDoubleExtension; - public const int OptionalBoolExtensionFieldNumber = 13; - public static pb::GeneratedExtensionBase OptionalBoolExtension; - public const int OptionalStringExtensionFieldNumber = 14; - public static pb::GeneratedExtensionBase OptionalStringExtension; - public const int OptionalBytesExtensionFieldNumber = 15; - public static pb::GeneratedExtensionBase OptionalBytesExtension; - public const int OptionalGroupExtensionFieldNumber = 16; - public static pb::GeneratedExtensionBase OptionalGroupExtension; - public const int OptionalNestedMessageExtensionFieldNumber = 18; - public static pb::GeneratedExtensionBase OptionalNestedMessageExtension; - public const int OptionalForeignMessageExtensionFieldNumber = 19; - public static pb::GeneratedExtensionBase OptionalForeignMessageExtension; - public const int OptionalImportMessageExtensionFieldNumber = 20; - public static pb::GeneratedExtensionBase OptionalImportMessageExtension; - public const int OptionalNestedEnumExtensionFieldNumber = 21; - public static pb::GeneratedExtensionBase OptionalNestedEnumExtension; - public const int OptionalForeignEnumExtensionFieldNumber = 22; - public static pb::GeneratedExtensionBase OptionalForeignEnumExtension; - public const int OptionalImportEnumExtensionFieldNumber = 23; - public static pb::GeneratedExtensionBase OptionalImportEnumExtension; - public const int OptionalStringPieceExtensionFieldNumber = 24; - public static pb::GeneratedExtensionBase OptionalStringPieceExtension; - public const int OptionalCordExtensionFieldNumber = 25; - public static pb::GeneratedExtensionBase OptionalCordExtension; - public const int OptionalPublicImportMessageExtensionFieldNumber = 26; - public static pb::GeneratedExtensionBase OptionalPublicImportMessageExtension; - public const int OptionalLazyMessageExtensionFieldNumber = 27; - public static pb::GeneratedExtensionBase OptionalLazyMessageExtension; - public const int RepeatedInt32ExtensionFieldNumber = 31; - public static pb::GeneratedExtensionBase> RepeatedInt32Extension; - public const int RepeatedInt64ExtensionFieldNumber = 32; - public static pb::GeneratedExtensionBase> RepeatedInt64Extension; - public const int RepeatedUint32ExtensionFieldNumber = 33; - public static pb::GeneratedExtensionBase> RepeatedUint32Extension; - public const int RepeatedUint64ExtensionFieldNumber = 34; - public static pb::GeneratedExtensionBase> RepeatedUint64Extension; - public const int RepeatedSint32ExtensionFieldNumber = 35; - public static pb::GeneratedExtensionBase> RepeatedSint32Extension; - public const int RepeatedSint64ExtensionFieldNumber = 36; - public static pb::GeneratedExtensionBase> RepeatedSint64Extension; - public const int RepeatedFixed32ExtensionFieldNumber = 37; - public static pb::GeneratedExtensionBase> RepeatedFixed32Extension; - public const int RepeatedFixed64ExtensionFieldNumber = 38; - public static pb::GeneratedExtensionBase> RepeatedFixed64Extension; - public const int RepeatedSfixed32ExtensionFieldNumber = 39; - public static pb::GeneratedExtensionBase> RepeatedSfixed32Extension; - public const int RepeatedSfixed64ExtensionFieldNumber = 40; - public static pb::GeneratedExtensionBase> RepeatedSfixed64Extension; - public const int RepeatedFloatExtensionFieldNumber = 41; - public static pb::GeneratedExtensionBase> RepeatedFloatExtension; - public const int RepeatedDoubleExtensionFieldNumber = 42; - public static pb::GeneratedExtensionBase> RepeatedDoubleExtension; - public const int RepeatedBoolExtensionFieldNumber = 43; - public static pb::GeneratedExtensionBase> RepeatedBoolExtension; - public const int RepeatedStringExtensionFieldNumber = 44; - public static pb::GeneratedExtensionBase> RepeatedStringExtension; - public const int RepeatedBytesExtensionFieldNumber = 45; - public static pb::GeneratedExtensionBase> RepeatedBytesExtension; - public const int RepeatedGroupExtensionFieldNumber = 46; - public static pb::GeneratedExtensionBase> RepeatedGroupExtension; - public const int RepeatedNestedMessageExtensionFieldNumber = 48; - public static pb::GeneratedExtensionBase> RepeatedNestedMessageExtension; - public const int RepeatedForeignMessageExtensionFieldNumber = 49; - public static pb::GeneratedExtensionBase> RepeatedForeignMessageExtension; - public const int RepeatedImportMessageExtensionFieldNumber = 50; - public static pb::GeneratedExtensionBase> RepeatedImportMessageExtension; - public const int RepeatedNestedEnumExtensionFieldNumber = 51; - public static pb::GeneratedExtensionBase> RepeatedNestedEnumExtension; - public const int RepeatedForeignEnumExtensionFieldNumber = 52; - public static pb::GeneratedExtensionBase> RepeatedForeignEnumExtension; - public const int RepeatedImportEnumExtensionFieldNumber = 53; - public static pb::GeneratedExtensionBase> RepeatedImportEnumExtension; - public const int RepeatedStringPieceExtensionFieldNumber = 54; - public static pb::GeneratedExtensionBase> RepeatedStringPieceExtension; - public const int RepeatedCordExtensionFieldNumber = 55; - public static pb::GeneratedExtensionBase> RepeatedCordExtension; - public const int RepeatedLazyMessageExtensionFieldNumber = 57; - public static pb::GeneratedExtensionBase> RepeatedLazyMessageExtension; - public const int DefaultInt32ExtensionFieldNumber = 61; - public static pb::GeneratedExtensionBase DefaultInt32Extension; - public const int DefaultInt64ExtensionFieldNumber = 62; - public static pb::GeneratedExtensionBase DefaultInt64Extension; - public const int DefaultUint32ExtensionFieldNumber = 63; - public static pb::GeneratedExtensionBase DefaultUint32Extension; - public const int DefaultUint64ExtensionFieldNumber = 64; - public static pb::GeneratedExtensionBase DefaultUint64Extension; - public const int DefaultSint32ExtensionFieldNumber = 65; - public static pb::GeneratedExtensionBase DefaultSint32Extension; - public const int DefaultSint64ExtensionFieldNumber = 66; - public static pb::GeneratedExtensionBase DefaultSint64Extension; - public const int DefaultFixed32ExtensionFieldNumber = 67; - public static pb::GeneratedExtensionBase DefaultFixed32Extension; - public const int DefaultFixed64ExtensionFieldNumber = 68; - public static pb::GeneratedExtensionBase DefaultFixed64Extension; - public const int DefaultSfixed32ExtensionFieldNumber = 69; - public static pb::GeneratedExtensionBase DefaultSfixed32Extension; - public const int DefaultSfixed64ExtensionFieldNumber = 70; - public static pb::GeneratedExtensionBase DefaultSfixed64Extension; - public const int DefaultFloatExtensionFieldNumber = 71; - public static pb::GeneratedExtensionBase DefaultFloatExtension; - public const int DefaultDoubleExtensionFieldNumber = 72; - public static pb::GeneratedExtensionBase DefaultDoubleExtension; - public const int DefaultBoolExtensionFieldNumber = 73; - public static pb::GeneratedExtensionBase DefaultBoolExtension; - public const int DefaultStringExtensionFieldNumber = 74; - public static pb::GeneratedExtensionBase DefaultStringExtension; - public const int DefaultBytesExtensionFieldNumber = 75; - public static pb::GeneratedExtensionBase DefaultBytesExtension; - public const int DefaultNestedEnumExtensionFieldNumber = 81; - public static pb::GeneratedExtensionBase DefaultNestedEnumExtension; - public const int DefaultForeignEnumExtensionFieldNumber = 82; - public static pb::GeneratedExtensionBase DefaultForeignEnumExtension; - public const int DefaultImportEnumExtensionFieldNumber = 83; - public static pb::GeneratedExtensionBase DefaultImportEnumExtension; - public const int DefaultStringPieceExtensionFieldNumber = 84; - public static pb::GeneratedExtensionBase DefaultStringPieceExtension; - public const int DefaultCordExtensionFieldNumber = 85; - public static pb::GeneratedExtensionBase DefaultCordExtension; - public const int OneofUint32ExtensionFieldNumber = 111; - public static pb::GeneratedExtensionBase OneofUint32Extension; - public const int OneofNestedMessageExtensionFieldNumber = 112; - public static pb::GeneratedExtensionBase OneofNestedMessageExtension; - public const int OneofStringExtensionFieldNumber = 113; - public static pb::GeneratedExtensionBase OneofStringExtension; - public const int OneofBytesExtensionFieldNumber = 114; - public static pb::GeneratedExtensionBase OneofBytesExtension; - public const int MyExtensionStringFieldNumber = 50; - public static pb::GeneratedExtensionBase MyExtensionString; - public const int MyExtensionIntFieldNumber = 5; - public static pb::GeneratedExtensionBase MyExtensionInt; - public const int PackedInt32ExtensionFieldNumber = 90; - public static pb::GeneratedExtensionBase> PackedInt32Extension; - public const int PackedInt64ExtensionFieldNumber = 91; - public static pb::GeneratedExtensionBase> PackedInt64Extension; - public const int PackedUint32ExtensionFieldNumber = 92; - public static pb::GeneratedExtensionBase> PackedUint32Extension; - public const int PackedUint64ExtensionFieldNumber = 93; - public static pb::GeneratedExtensionBase> PackedUint64Extension; - public const int PackedSint32ExtensionFieldNumber = 94; - public static pb::GeneratedExtensionBase> PackedSint32Extension; - public const int PackedSint64ExtensionFieldNumber = 95; - public static pb::GeneratedExtensionBase> PackedSint64Extension; - public const int PackedFixed32ExtensionFieldNumber = 96; - public static pb::GeneratedExtensionBase> PackedFixed32Extension; - public const int PackedFixed64ExtensionFieldNumber = 97; - public static pb::GeneratedExtensionBase> PackedFixed64Extension; - public const int PackedSfixed32ExtensionFieldNumber = 98; - public static pb::GeneratedExtensionBase> PackedSfixed32Extension; - public const int PackedSfixed64ExtensionFieldNumber = 99; - public static pb::GeneratedExtensionBase> PackedSfixed64Extension; - public const int PackedFloatExtensionFieldNumber = 100; - public static pb::GeneratedExtensionBase> PackedFloatExtension; - public const int PackedDoubleExtensionFieldNumber = 101; - public static pb::GeneratedExtensionBase> PackedDoubleExtension; - public const int PackedBoolExtensionFieldNumber = 102; - public static pb::GeneratedExtensionBase> PackedBoolExtension; - public const int PackedEnumExtensionFieldNumber = 103; - public static pb::GeneratedExtensionBase> PackedEnumExtension; - public const int UnpackedInt32ExtensionFieldNumber = 90; - public static pb::GeneratedExtensionBase> UnpackedInt32Extension; - public const int UnpackedInt64ExtensionFieldNumber = 91; - public static pb::GeneratedExtensionBase> UnpackedInt64Extension; - public const int UnpackedUint32ExtensionFieldNumber = 92; - public static pb::GeneratedExtensionBase> UnpackedUint32Extension; - public const int UnpackedUint64ExtensionFieldNumber = 93; - public static pb::GeneratedExtensionBase> UnpackedUint64Extension; - public const int UnpackedSint32ExtensionFieldNumber = 94; - public static pb::GeneratedExtensionBase> UnpackedSint32Extension; - public const int UnpackedSint64ExtensionFieldNumber = 95; - public static pb::GeneratedExtensionBase> UnpackedSint64Extension; - public const int UnpackedFixed32ExtensionFieldNumber = 96; - public static pb::GeneratedExtensionBase> UnpackedFixed32Extension; - public const int UnpackedFixed64ExtensionFieldNumber = 97; - public static pb::GeneratedExtensionBase> UnpackedFixed64Extension; - public const int UnpackedSfixed32ExtensionFieldNumber = 98; - public static pb::GeneratedExtensionBase> UnpackedSfixed32Extension; - public const int UnpackedSfixed64ExtensionFieldNumber = 99; - public static pb::GeneratedExtensionBase> UnpackedSfixed64Extension; - public const int UnpackedFloatExtensionFieldNumber = 100; - public static pb::GeneratedExtensionBase> UnpackedFloatExtension; - public const int UnpackedDoubleExtensionFieldNumber = 101; - public static pb::GeneratedExtensionBase> UnpackedDoubleExtension; - public const int UnpackedBoolExtensionFieldNumber = 102; - public static pb::GeneratedExtensionBase> UnpackedBoolExtension; - public const int UnpackedEnumExtensionFieldNumber = 103; - public static pb::GeneratedExtensionBase> UnpackedEnumExtension; - #endregion - - #region Static variables - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestAllTypes__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestAllTypes__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestAllTypes_NestedMessage__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestAllTypes_NestedMessage__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestAllTypes_OptionalGroup__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestAllTypes_OptionalGroup__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestAllTypes_RepeatedGroup__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestAllTypes_RepeatedGroup__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_NestedTestAllTypes__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_NestedTestAllTypes__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestDeprecatedFields__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestDeprecatedFields__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_ForeignMessage__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_ForeignMessage__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestReservedFields__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestReservedFields__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestAllExtensions__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestAllExtensions__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_OptionalGroup_extension__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_OptionalGroup_extension__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_RepeatedGroup_extension__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_RepeatedGroup_extension__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestNestedExtension__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestNestedExtension__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestRequired__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestRequired__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestRequiredForeign__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestRequiredForeign__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestForeignNested__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestForeignNested__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestEmptyMessage__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestEmptyMessage__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestEmptyMessageWithExtensions__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestEmptyMessageWithExtensions__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestMultipleExtensionRanges__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMultipleExtensionRanges__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestReallyLargeTagNumber__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestReallyLargeTagNumber__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestRecursiveMessage__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestRecursiveMessage__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestMutualRecursionA__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMutualRecursionA__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestMutualRecursionB__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMutualRecursionB__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestDupFieldNumber__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestDupFieldNumber__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestDupFieldNumber_Foo__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestDupFieldNumber_Foo__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestDupFieldNumber_Bar__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestDupFieldNumber_Bar__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestEagerMessage__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestEagerMessage__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestLazyMessage__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestLazyMessage__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestNestedMessageHasBits__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestNestedMessageHasBits__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestNestedMessageHasBits_NestedMessage__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestNestedMessageHasBits_NestedMessage__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestCamelCaseFieldNames__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestCamelCaseFieldNames__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestFieldOrderings__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestFieldOrderings__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestFieldOrderings_NestedMessage__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestFieldOrderings_NestedMessage__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestExtremeDefaultValues__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestExtremeDefaultValues__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_SparseEnumMessage__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_SparseEnumMessage__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_OneString__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_OneString__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_MoreString__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_MoreString__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_OneBytes__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_OneBytes__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_MoreBytes__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_MoreBytes__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_Int32Message__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_Int32Message__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_Uint32Message__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_Uint32Message__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_Int64Message__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_Int64Message__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_Uint64Message__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_Uint64Message__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_BoolMessage__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_BoolMessage__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestOneof__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestOneof__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestOneof_FooGroup__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestOneof_FooGroup__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestOneofBackwardsCompatible__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestOneofBackwardsCompatible__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestOneofBackwardsCompatible_FooGroup__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestOneofBackwardsCompatible_FooGroup__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestOneof2__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestOneof2__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestOneof2_FooGroup__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestOneof2_FooGroup__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestOneof2_NestedMessage__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestOneof2_NestedMessage__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestRequiredOneof__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestRequiredOneof__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestRequiredOneof_NestedMessage__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestRequiredOneof_NestedMessage__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestPackedTypes__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestPackedTypes__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestUnpackedTypes__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestUnpackedTypes__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestPackedExtensions__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestPackedExtensions__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestUnpackedExtensions__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestUnpackedExtensions__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestDynamicExtensions__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestDynamicExtensions__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestDynamicExtensions_DynamicMessageType__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestDynamicExtensions_DynamicMessageType__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestRepeatedScalarDifferentTagSizes__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestRepeatedScalarDifferentTagSizes__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestParsingMerge__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestParsingMerge__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestParsingMerge_RepeatedFieldsGenerator__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestParsingMerge_RepeatedFieldsGenerator__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestParsingMerge_RepeatedFieldsGenerator_Group1__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestParsingMerge_RepeatedFieldsGenerator_Group1__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestParsingMerge_RepeatedFieldsGenerator_Group2__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestParsingMerge_RepeatedFieldsGenerator_Group2__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestParsingMerge_OptionalGroup__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestParsingMerge_OptionalGroup__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestParsingMerge_RepeatedGroup__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestParsingMerge_RepeatedGroup__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestCommentInjectionMessage__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestCommentInjectionMessage__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_FooRequest__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_FooRequest__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_FooResponse__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_FooResponse__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_FooClientMessage__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_FooClientMessage__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_FooServerMessage__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_FooServerMessage__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_BarRequest__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_BarRequest__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_BarResponse__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_BarResponse__FieldAccessorTable; - #endregion - #region Descriptor - public static pbd::FileDescriptor Descriptor { - get { return descriptor; } - } - private static pbd::FileDescriptor descriptor; - - static Unittest() { - byte[] descriptorData = global::System.Convert.FromBase64String( - string.Concat( - "Ch5nb29nbGUvcHJvdG9idWYvdW5pdHRlc3QucHJvdG8SEXByb3RvYnVmX3Vu", - "aXR0ZXN0GiVnb29nbGUvcHJvdG9idWYvdW5pdHRlc3RfaW1wb3J0LnByb3Rv", - "Iu0YCgxUZXN0QWxsVHlwZXMSFgoOb3B0aW9uYWxfaW50MzIYASABKAUSFgoO", - "b3B0aW9uYWxfaW50NjQYAiABKAMSFwoPb3B0aW9uYWxfdWludDMyGAMgASgN", - "EhcKD29wdGlvbmFsX3VpbnQ2NBgEIAEoBBIXCg9vcHRpb25hbF9zaW50MzIY", - "BSABKBESFwoPb3B0aW9uYWxfc2ludDY0GAYgASgSEhgKEG9wdGlvbmFsX2Zp", - "eGVkMzIYByABKAcSGAoQb3B0aW9uYWxfZml4ZWQ2NBgIIAEoBhIZChFvcHRp", - "b25hbF9zZml4ZWQzMhgJIAEoDxIZChFvcHRpb25hbF9zZml4ZWQ2NBgKIAEo", - "EBIWCg5vcHRpb25hbF9mbG9hdBgLIAEoAhIXCg9vcHRpb25hbF9kb3VibGUY", - "DCABKAESFQoNb3B0aW9uYWxfYm9vbBgNIAEoCBIXCg9vcHRpb25hbF9zdHJp", - "bmcYDiABKAkSFgoOb3B0aW9uYWxfYnl0ZXMYDyABKAwSRAoNb3B0aW9uYWxn", - "cm91cBgQIAEoCjItLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RBbGxUeXBlcy5P", - "cHRpb25hbEdyb3VwEk4KF29wdGlvbmFsX25lc3RlZF9tZXNzYWdlGBIgASgL", - "Mi0ucHJvdG9idWZfdW5pdHRlc3QuVGVzdEFsbFR5cGVzLk5lc3RlZE1lc3Nh", - "Z2USQwoYb3B0aW9uYWxfZm9yZWlnbl9tZXNzYWdlGBMgASgLMiEucHJvdG9i", - "dWZfdW5pdHRlc3QuRm9yZWlnbk1lc3NhZ2USSAoXb3B0aW9uYWxfaW1wb3J0", - "X21lc3NhZ2UYFCABKAsyJy5wcm90b2J1Zl91bml0dGVzdF9pbXBvcnQuSW1w", - "b3J0TWVzc2FnZRJIChRvcHRpb25hbF9uZXN0ZWRfZW51bRgVIAEoDjIqLnBy", - "b3RvYnVmX3VuaXR0ZXN0LlRlc3RBbGxUeXBlcy5OZXN0ZWRFbnVtEj0KFW9w", - "dGlvbmFsX2ZvcmVpZ25fZW51bRgWIAEoDjIeLnByb3RvYnVmX3VuaXR0ZXN0", - "LkZvcmVpZ25FbnVtEkIKFG9wdGlvbmFsX2ltcG9ydF9lbnVtGBcgASgOMiQu", - "cHJvdG9idWZfdW5pdHRlc3RfaW1wb3J0LkltcG9ydEVudW0SIQoVb3B0aW9u", - "YWxfc3RyaW5nX3BpZWNlGBggASgJQgIIAhIZCg1vcHRpb25hbF9jb3JkGBkg", - "ASgJQgIIARJVCh5vcHRpb25hbF9wdWJsaWNfaW1wb3J0X21lc3NhZ2UYGiAB", - "KAsyLS5wcm90b2J1Zl91bml0dGVzdF9pbXBvcnQuUHVibGljSW1wb3J0TWVz", - "c2FnZRJQChVvcHRpb25hbF9sYXp5X21lc3NhZ2UYGyABKAsyLS5wcm90b2J1", - "Zl91bml0dGVzdC5UZXN0QWxsVHlwZXMuTmVzdGVkTWVzc2FnZUICKAESFgoO", - "cmVwZWF0ZWRfaW50MzIYHyADKAUSFgoOcmVwZWF0ZWRfaW50NjQYICADKAMS", - "FwoPcmVwZWF0ZWRfdWludDMyGCEgAygNEhcKD3JlcGVhdGVkX3VpbnQ2NBgi", - "IAMoBBIXCg9yZXBlYXRlZF9zaW50MzIYIyADKBESFwoPcmVwZWF0ZWRfc2lu", - "dDY0GCQgAygSEhgKEHJlcGVhdGVkX2ZpeGVkMzIYJSADKAcSGAoQcmVwZWF0", - "ZWRfZml4ZWQ2NBgmIAMoBhIZChFyZXBlYXRlZF9zZml4ZWQzMhgnIAMoDxIZ", - "ChFyZXBlYXRlZF9zZml4ZWQ2NBgoIAMoEBIWCg5yZXBlYXRlZF9mbG9hdBgp", - "IAMoAhIXCg9yZXBlYXRlZF9kb3VibGUYKiADKAESFQoNcmVwZWF0ZWRfYm9v", - "bBgrIAMoCBIXCg9yZXBlYXRlZF9zdHJpbmcYLCADKAkSFgoOcmVwZWF0ZWRf", - "Ynl0ZXMYLSADKAwSRAoNcmVwZWF0ZWRncm91cBguIAMoCjItLnByb3RvYnVm", - "X3VuaXR0ZXN0LlRlc3RBbGxUeXBlcy5SZXBlYXRlZEdyb3VwEk4KF3JlcGVh", - "dGVkX25lc3RlZF9tZXNzYWdlGDAgAygLMi0ucHJvdG9idWZfdW5pdHRlc3Qu", - "VGVzdEFsbFR5cGVzLk5lc3RlZE1lc3NhZ2USQwoYcmVwZWF0ZWRfZm9yZWln", - "bl9tZXNzYWdlGDEgAygLMiEucHJvdG9idWZfdW5pdHRlc3QuRm9yZWlnbk1l", - "c3NhZ2USSAoXcmVwZWF0ZWRfaW1wb3J0X21lc3NhZ2UYMiADKAsyJy5wcm90", - "b2J1Zl91bml0dGVzdF9pbXBvcnQuSW1wb3J0TWVzc2FnZRJIChRyZXBlYXRl", - "ZF9uZXN0ZWRfZW51bRgzIAMoDjIqLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RB", - "bGxUeXBlcy5OZXN0ZWRFbnVtEj0KFXJlcGVhdGVkX2ZvcmVpZ25fZW51bRg0", - "IAMoDjIeLnByb3RvYnVmX3VuaXR0ZXN0LkZvcmVpZ25FbnVtEkIKFHJlcGVh", - "dGVkX2ltcG9ydF9lbnVtGDUgAygOMiQucHJvdG9idWZfdW5pdHRlc3RfaW1w", - "b3J0LkltcG9ydEVudW0SIQoVcmVwZWF0ZWRfc3RyaW5nX3BpZWNlGDYgAygJ", - "QgIIAhIZCg1yZXBlYXRlZF9jb3JkGDcgAygJQgIIARJQChVyZXBlYXRlZF9s", - "YXp5X21lc3NhZ2UYOSADKAsyLS5wcm90b2J1Zl91bml0dGVzdC5UZXN0QWxs", - "VHlwZXMuTmVzdGVkTWVzc2FnZUICKAESGQoNZGVmYXVsdF9pbnQzMhg9IAEo", - "BToCNDESGQoNZGVmYXVsdF9pbnQ2NBg+IAEoAzoCNDISGgoOZGVmYXVsdF91", - "aW50MzIYPyABKA06AjQzEhoKDmRlZmF1bHRfdWludDY0GEAgASgEOgI0NBIb", - "Cg5kZWZhdWx0X3NpbnQzMhhBIAEoEToDLTQ1EhoKDmRlZmF1bHRfc2ludDY0", - "GEIgASgSOgI0NhIbCg9kZWZhdWx0X2ZpeGVkMzIYQyABKAc6AjQ3EhsKD2Rl", - "ZmF1bHRfZml4ZWQ2NBhEIAEoBjoCNDgSHAoQZGVmYXVsdF9zZml4ZWQzMhhF", - "IAEoDzoCNDkSHQoQZGVmYXVsdF9zZml4ZWQ2NBhGIAEoEDoDLTUwEhsKDWRl", - "ZmF1bHRfZmxvYXQYRyABKAI6BDUxLjUSHQoOZGVmYXVsdF9kb3VibGUYSCAB", - "KAE6BTUyMDAwEhoKDGRlZmF1bHRfYm9vbBhJIAEoCDoEdHJ1ZRIdCg5kZWZh", - "dWx0X3N0cmluZxhKIAEoCToFaGVsbG8SHAoNZGVmYXVsdF9ieXRlcxhLIAEo", - "DDoFd29ybGQSTAoTZGVmYXVsdF9uZXN0ZWRfZW51bRhRIAEoDjIqLnByb3Rv", - "YnVmX3VuaXR0ZXN0LlRlc3RBbGxUeXBlcy5OZXN0ZWRFbnVtOgNCQVISSQoU", - "ZGVmYXVsdF9mb3JlaWduX2VudW0YUiABKA4yHi5wcm90b2J1Zl91bml0dGVz", - "dC5Gb3JlaWduRW51bToLRk9SRUlHTl9CQVISTQoTZGVmYXVsdF9pbXBvcnRf", - "ZW51bRhTIAEoDjIkLnByb3RvYnVmX3VuaXR0ZXN0X2ltcG9ydC5JbXBvcnRF", - "bnVtOgpJTVBPUlRfQkFSEiUKFGRlZmF1bHRfc3RyaW5nX3BpZWNlGFQgASgJ", - "OgNhYmNCAggCEh0KDGRlZmF1bHRfY29yZBhVIAEoCToDMTIzQgIIARIWCgxv", - "bmVvZl91aW50MzIYbyABKA1IABJNChRvbmVvZl9uZXN0ZWRfbWVzc2FnZRhw", - "IAEoCzItLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RBbGxUeXBlcy5OZXN0ZWRN", - "ZXNzYWdlSAASFgoMb25lb2Zfc3RyaW5nGHEgASgJSAASFQoLb25lb2ZfYnl0", - "ZXMYciABKAxIABobCg1OZXN0ZWRNZXNzYWdlEgoKAmJiGAEgASgFGhoKDU9w", - "dGlvbmFsR3JvdXASCQoBYRgRIAEoBRoaCg1SZXBlYXRlZEdyb3VwEgkKAWEY", - "LyABKAUiOQoKTmVzdGVkRW51bRIHCgNGT08QARIHCgNCQVIQAhIHCgNCQVoQ", - "AxIQCgNORUcQ////////////AUINCgtvbmVvZl9maWVsZCK7AQoSTmVzdGVk", - "VGVzdEFsbFR5cGVzEjQKBWNoaWxkGAEgASgLMiUucHJvdG9idWZfdW5pdHRl", - "c3QuTmVzdGVkVGVzdEFsbFR5cGVzEjAKB3BheWxvYWQYAiABKAsyHy5wcm90", - "b2J1Zl91bml0dGVzdC5UZXN0QWxsVHlwZXMSPQoOcmVwZWF0ZWRfY2hpbGQY", - "AyADKAsyJS5wcm90b2J1Zl91bml0dGVzdC5OZXN0ZWRUZXN0QWxsVHlwZXMi", - "NAoUVGVzdERlcHJlY2F0ZWRGaWVsZHMSHAoQZGVwcmVjYXRlZF9pbnQzMhgB", - "IAEoBUICGAEiGwoORm9yZWlnbk1lc3NhZ2USCQoBYxgBIAEoBSIwChJUZXN0", - "UmVzZXJ2ZWRGaWVsZHNKBAgCEANKBAgPEBBKBAgJEAxSA2JhclIDYmF6Ih0K", - "EVRlc3RBbGxFeHRlbnNpb25zKggIARCAgICAAiIkChdPcHRpb25hbEdyb3Vw", - "X2V4dGVuc2lvbhIJCgFhGBEgASgFIiQKF1JlcGVhdGVkR3JvdXBfZXh0ZW5z", - "aW9uEgkKAWEYLyABKAUimAEKE1Rlc3ROZXN0ZWRFeHRlbnNpb24yOQoEdGVz", - "dBIkLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RBbGxFeHRlbnNpb25zGOoHIAEo", - "CToEdGVzdDJGChduZXN0ZWRfc3RyaW5nX2V4dGVuc2lvbhIkLnByb3RvYnVm", - "X3VuaXR0ZXN0LlRlc3RBbGxFeHRlbnNpb25zGOsHIAEoCSLVBQoMVGVzdFJl", - "cXVpcmVkEgkKAWEYASACKAUSDgoGZHVtbXkyGAIgASgFEgkKAWIYAyACKAUS", - "DgoGZHVtbXk0GAQgASgFEg4KBmR1bW15NRgFIAEoBRIOCgZkdW1teTYYBiAB", - "KAUSDgoGZHVtbXk3GAcgASgFEg4KBmR1bW15OBgIIAEoBRIOCgZkdW1teTkY", - "CSABKAUSDwoHZHVtbXkxMBgKIAEoBRIPCgdkdW1teTExGAsgASgFEg8KB2R1", - "bW15MTIYDCABKAUSDwoHZHVtbXkxMxgNIAEoBRIPCgdkdW1teTE0GA4gASgF", - "Eg8KB2R1bW15MTUYDyABKAUSDwoHZHVtbXkxNhgQIAEoBRIPCgdkdW1teTE3", - "GBEgASgFEg8KB2R1bW15MTgYEiABKAUSDwoHZHVtbXkxORgTIAEoBRIPCgdk", - "dW1teTIwGBQgASgFEg8KB2R1bW15MjEYFSABKAUSDwoHZHVtbXkyMhgWIAEo", - "BRIPCgdkdW1teTIzGBcgASgFEg8KB2R1bW15MjQYGCABKAUSDwoHZHVtbXky", - "NRgZIAEoBRIPCgdkdW1teTI2GBogASgFEg8KB2R1bW15MjcYGyABKAUSDwoH", - "ZHVtbXkyOBgcIAEoBRIPCgdkdW1teTI5GB0gASgFEg8KB2R1bW15MzAYHiAB", - "KAUSDwoHZHVtbXkzMRgfIAEoBRIPCgdkdW1teTMyGCAgASgFEgkKAWMYISAC", - "KAUyVgoGc2luZ2xlEiQucHJvdG9idWZfdW5pdHRlc3QuVGVzdEFsbEV4dGVu", - "c2lvbnMY6AcgASgLMh8ucHJvdG9idWZfdW5pdHRlc3QuVGVzdFJlcXVpcmVk", - "MlUKBW11bHRpEiQucHJvdG9idWZfdW5pdHRlc3QuVGVzdEFsbEV4dGVuc2lv", - "bnMY6QcgAygLMh8ucHJvdG9idWZfdW5pdHRlc3QuVGVzdFJlcXVpcmVkIpoB", - "ChNUZXN0UmVxdWlyZWRGb3JlaWduEjkKEG9wdGlvbmFsX21lc3NhZ2UYASAB", - "KAsyHy5wcm90b2J1Zl91bml0dGVzdC5UZXN0UmVxdWlyZWQSOQoQcmVwZWF0", - "ZWRfbWVzc2FnZRgCIAMoCzIfLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RSZXF1", - "aXJlZBINCgVkdW1teRgDIAEoBSJaChFUZXN0Rm9yZWlnbk5lc3RlZBJFCg5m", - "b3JlaWduX25lc3RlZBgBIAEoCzItLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RB", - "bGxUeXBlcy5OZXN0ZWRNZXNzYWdlIhIKEFRlc3RFbXB0eU1lc3NhZ2UiKgoe", - "VGVzdEVtcHR5TWVzc2FnZVdpdGhFeHRlbnNpb25zKggIARCAgICAAiI3ChtU", - "ZXN0TXVsdGlwbGVFeHRlbnNpb25SYW5nZXMqBAgqECsqBgivIBCUISoKCICA", - "BBCAgICAAiI0ChhUZXN0UmVhbGx5TGFyZ2VUYWdOdW1iZXISCQoBYRgBIAEo", - "BRINCgJiYhj///9/IAEoBSJVChRUZXN0UmVjdXJzaXZlTWVzc2FnZRIyCgFh", - "GAEgASgLMicucHJvdG9idWZfdW5pdHRlc3QuVGVzdFJlY3Vyc2l2ZU1lc3Nh", - "Z2USCQoBaRgCIAEoBSJLChRUZXN0TXV0dWFsUmVjdXJzaW9uQRIzCgJiYhgB", - "IAEoCzInLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RNdXR1YWxSZWN1cnNpb25C", - "ImIKFFRlc3RNdXR1YWxSZWN1cnNpb25CEjIKAWEYASABKAsyJy5wcm90b2J1", - "Zl91bml0dGVzdC5UZXN0TXV0dWFsUmVjdXJzaW9uQRIWCg5vcHRpb25hbF9p", - "bnQzMhgCIAEoBSKzAQoSVGVzdER1cEZpZWxkTnVtYmVyEgkKAWEYASABKAUS", - "NgoDZm9vGAIgASgKMikucHJvdG9idWZfdW5pdHRlc3QuVGVzdER1cEZpZWxk", - "TnVtYmVyLkZvbxI2CgNiYXIYAyABKAoyKS5wcm90b2J1Zl91bml0dGVzdC5U", - "ZXN0RHVwRmllbGROdW1iZXIuQmFyGhAKA0ZvbxIJCgFhGAEgASgFGhAKA0Jh", - "chIJCgFhGAEgASgFIkwKEFRlc3RFYWdlck1lc3NhZ2USOAoLc3ViX21lc3Nh", - "Z2UYASABKAsyHy5wcm90b2J1Zl91bml0dGVzdC5UZXN0QWxsVHlwZXNCAigA", - "IksKD1Rlc3RMYXp5TWVzc2FnZRI4CgtzdWJfbWVzc2FnZRgBIAEoCzIfLnBy", - "b3RvYnVmX3VuaXR0ZXN0LlRlc3RBbGxUeXBlc0ICKAEigAIKGFRlc3ROZXN0", - "ZWRNZXNzYWdlSGFzQml0cxJaChdvcHRpb25hbF9uZXN0ZWRfbWVzc2FnZRgB", - "IAEoCzI5LnByb3RvYnVmX3VuaXR0ZXN0LlRlc3ROZXN0ZWRNZXNzYWdlSGFz", - "Qml0cy5OZXN0ZWRNZXNzYWdlGocBCg1OZXN0ZWRNZXNzYWdlEiQKHG5lc3Rl", - "ZG1lc3NhZ2VfcmVwZWF0ZWRfaW50MzIYASADKAUSUAolbmVzdGVkbWVzc2Fn", - "ZV9yZXBlYXRlZF9mb3JlaWdubWVzc2FnZRgCIAMoCzIhLnByb3RvYnVmX3Vu", - "aXR0ZXN0LkZvcmVpZ25NZXNzYWdlIuUDChdUZXN0Q2FtZWxDYXNlRmllbGRO", - "YW1lcxIWCg5QcmltaXRpdmVGaWVsZBgBIAEoBRITCgtTdHJpbmdGaWVsZBgC", - "IAEoCRIxCglFbnVtRmllbGQYAyABKA4yHi5wcm90b2J1Zl91bml0dGVzdC5G", - "b3JlaWduRW51bRI3CgxNZXNzYWdlRmllbGQYBCABKAsyIS5wcm90b2J1Zl91", - "bml0dGVzdC5Gb3JlaWduTWVzc2FnZRIcChBTdHJpbmdQaWVjZUZpZWxkGAUg", - "ASgJQgIIAhIVCglDb3JkRmllbGQYBiABKAlCAggBEh4KFlJlcGVhdGVkUHJp", - "bWl0aXZlRmllbGQYByADKAUSGwoTUmVwZWF0ZWRTdHJpbmdGaWVsZBgIIAMo", - "CRI5ChFSZXBlYXRlZEVudW1GaWVsZBgJIAMoDjIeLnByb3RvYnVmX3VuaXR0", - "ZXN0LkZvcmVpZ25FbnVtEj8KFFJlcGVhdGVkTWVzc2FnZUZpZWxkGAogAygL", - "MiEucHJvdG9idWZfdW5pdHRlc3QuRm9yZWlnbk1lc3NhZ2USJAoYUmVwZWF0", - "ZWRTdHJpbmdQaWVjZUZpZWxkGAsgAygJQgIIAhIdChFSZXBlYXRlZENvcmRG", - "aWVsZBgMIAMoCUICCAEi1QEKElRlc3RGaWVsZE9yZGVyaW5ncxIRCglteV9z", - "dHJpbmcYCyABKAkSDgoGbXlfaW50GAEgASgDEhAKCG15X2Zsb2F0GGUgASgC", - "ElUKF29wdGlvbmFsX25lc3RlZF9tZXNzYWdlGMgBIAEoCzIzLnByb3RvYnVm", - "X3VuaXR0ZXN0LlRlc3RGaWVsZE9yZGVyaW5ncy5OZXN0ZWRNZXNzYWdlGicK", - "DU5lc3RlZE1lc3NhZ2USCgoCb28YAiABKAMSCgoCYmIYASABKAUqBAgCEAsq", - "BAgMEGUitgcKGFRlc3RFeHRyZW1lRGVmYXVsdFZhbHVlcxI/Cg1lc2NhcGVk", - "X2J5dGVzGAEgASgMOihcMDAwXDAwMVwwMDdcMDEwXDAxNFxuXHJcdFwwMTNc", - "XFwnXCJcMzc2EiAKDGxhcmdlX3VpbnQzMhgCIAEoDToKNDI5NDk2NzI5NRIq", - "CgxsYXJnZV91aW50NjQYAyABKAQ6FDE4NDQ2NzQ0MDczNzA5NTUxNjE1EiAK", - "C3NtYWxsX2ludDMyGAQgASgFOgstMjE0NzQ4MzY0NxIpCgtzbWFsbF9pbnQ2", - "NBgFIAEoAzoULTkyMjMzNzIwMzY4NTQ3NzU4MDcSJwoScmVhbGx5X3NtYWxs", - "X2ludDMyGBUgASgFOgstMjE0NzQ4MzY0OBIwChJyZWFsbHlfc21hbGxfaW50", - "NjQYFiABKAM6FC05MjIzMzcyMDM2ODU0Nzc1ODA4EhgKC3V0Zjhfc3RyaW5n", - "GAYgASgJOgPhiLQSFQoKemVyb19mbG9hdBgHIAEoAjoBMBIUCglvbmVfZmxv", - "YXQYCCABKAI6ATESGAoLc21hbGxfZmxvYXQYCSABKAI6AzEuNRIeChJuZWdh", - "dGl2ZV9vbmVfZmxvYXQYCiABKAI6Ai0xEhwKDm5lZ2F0aXZlX2Zsb2F0GAsg", - "ASgCOgQtMS41EhoKC2xhcmdlX2Zsb2F0GAwgASgCOgUyZSswOBIkChRzbWFs", - "bF9uZWdhdGl2ZV9mbG9hdBgNIAEoAjoGLThlLTI4EhcKCmluZl9kb3VibGUY", - "DiABKAE6A2luZhIcCg5uZWdfaW5mX2RvdWJsZRgPIAEoAToELWluZhIXCgpu", - "YW5fZG91YmxlGBAgASgBOgNuYW4SFgoJaW5mX2Zsb2F0GBEgASgCOgNpbmYS", - "GwoNbmVnX2luZl9mbG9hdBgSIAEoAjoELWluZhIWCgluYW5fZmxvYXQYEyAB", - "KAI6A25hbhIrCgxjcHBfdHJpZ3JhcGgYFCABKAk6FT8gPyA/PyA/PyA/Pz8g", - "Pz8vID8/LRIgChBzdHJpbmdfd2l0aF96ZXJvGBcgASgJOgZoZWwAbG8SIgoP", - "Ynl0ZXNfd2l0aF96ZXJvGBggASgMOgl3b3JcMDAwbGQSKAoWc3RyaW5nX3Bp", - "ZWNlX3dpdGhfemVybxgZIAEoCToEYWIAY0ICCAISIAoOY29yZF93aXRoX3pl", - "cm8YGiABKAk6BDEyADNCAggBEiYKEnJlcGxhY2VtZW50X3N0cmluZxgbIAEo", - "CToKJHt1bmtub3dufSJLChFTcGFyc2VFbnVtTWVzc2FnZRI2CgtzcGFyc2Vf", - "ZW51bRgBIAEoDjIhLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RTcGFyc2VFbnVt", - "IhkKCU9uZVN0cmluZxIMCgRkYXRhGAEgASgJIhoKCk1vcmVTdHJpbmcSDAoE", - "ZGF0YRgBIAMoCSIYCghPbmVCeXRlcxIMCgRkYXRhGAEgASgMIhkKCU1vcmVC", - "eXRlcxIMCgRkYXRhGAEgAygMIhwKDEludDMyTWVzc2FnZRIMCgRkYXRhGAEg", - "ASgFIh0KDVVpbnQzMk1lc3NhZ2USDAoEZGF0YRgBIAEoDSIcCgxJbnQ2NE1l", - "c3NhZ2USDAoEZGF0YRgBIAEoAyIdCg1VaW50NjRNZXNzYWdlEgwKBGRhdGEY", - "ASABKAQiGwoLQm9vbE1lc3NhZ2USDAoEZGF0YRgBIAEoCCLQAQoJVGVzdE9u", - "ZW9mEhEKB2Zvb19pbnQYASABKAVIABIUCgpmb29fc3RyaW5nGAIgASgJSAAS", - "NgoLZm9vX21lc3NhZ2UYAyABKAsyHy5wcm90b2J1Zl91bml0dGVzdC5UZXN0", - "QWxsVHlwZXNIABI5Cghmb29ncm91cBgEIAEoCjIlLnByb3RvYnVmX3VuaXR0", - "ZXN0LlRlc3RPbmVvZi5Gb29Hcm91cEgAGiAKCEZvb0dyb3VwEgkKAWEYBSAB", - "KAUSCQoBYhgGIAEoCUIFCgNmb28i5wEKHFRlc3RPbmVvZkJhY2t3YXJkc0Nv", - "bXBhdGlibGUSDwoHZm9vX2ludBgBIAEoBRISCgpmb29fc3RyaW5nGAIgASgJ", - "EjQKC2Zvb19tZXNzYWdlGAMgASgLMh8ucHJvdG9idWZfdW5pdHRlc3QuVGVz", - "dEFsbFR5cGVzEkoKCGZvb2dyb3VwGAQgASgKMjgucHJvdG9idWZfdW5pdHRl", - "c3QuVGVzdE9uZW9mQmFja3dhcmRzQ29tcGF0aWJsZS5Gb29Hcm91cBogCghG", - "b29Hcm91cBIJCgFhGAUgASgFEgkKAWIYBiABKAkingYKClRlc3RPbmVvZjIS", - "EQoHZm9vX2ludBgBIAEoBUgAEhQKCmZvb19zdHJpbmcYAiABKAlIABIWCghm", - "b29fY29yZBgDIAEoCUICCAFIABIeChBmb29fc3RyaW5nX3BpZWNlGAQgASgJ", - "QgIIAkgAEhMKCWZvb19ieXRlcxgFIAEoDEgAEjwKCGZvb19lbnVtGAYgASgO", - "MigucHJvdG9idWZfdW5pdHRlc3QuVGVzdE9uZW9mMi5OZXN0ZWRFbnVtSAAS", - "QgoLZm9vX21lc3NhZ2UYByABKAsyKy5wcm90b2J1Zl91bml0dGVzdC5UZXN0", - "T25lb2YyLk5lc3RlZE1lc3NhZ2VIABI6Cghmb29ncm91cBgIIAEoCjImLnBy", - "b3RvYnVmX3VuaXR0ZXN0LlRlc3RPbmVvZjIuRm9vR3JvdXBIABJLChBmb29f", - "bGF6eV9tZXNzYWdlGAsgASgLMisucHJvdG9idWZfdW5pdHRlc3QuVGVzdE9u", - "ZW9mMi5OZXN0ZWRNZXNzYWdlQgIoAUgAEhQKB2Jhcl9pbnQYDCABKAU6ATVI", - "ARIcCgpiYXJfc3RyaW5nGA0gASgJOgZTVFJJTkdIARIcCghiYXJfY29yZBgO", - "IAEoCToEQ09SREICCAFIARImChBiYXJfc3RyaW5nX3BpZWNlGA8gASgJOgZT", - "UElFQ0VCAggCSAESGgoJYmFyX2J5dGVzGBAgASgMOgVCWVRFU0gBEkEKCGJh", - "cl9lbnVtGBEgASgOMigucHJvdG9idWZfdW5pdHRlc3QuVGVzdE9uZW9mMi5O", - "ZXN0ZWRFbnVtOgNCQVJIARIPCgdiYXpfaW50GBIgASgFEhcKCmJhel9zdHJp", - "bmcYEyABKAk6A0JBWhogCghGb29Hcm91cBIJCgFhGAkgASgFEgkKAWIYCiAB", - "KAkaMwoNTmVzdGVkTWVzc2FnZRIPCgdxdXhfaW50GAEgASgDEhEKCWNvcmdl", - "X2ludBgCIAMoBSInCgpOZXN0ZWRFbnVtEgcKA0ZPTxABEgcKA0JBUhACEgcK", - "A0JBWhADQgUKA2Zvb0IFCgNiYXIiuAEKEVRlc3RSZXF1aXJlZE9uZW9mEhEK", - "B2Zvb19pbnQYASABKAVIABIUCgpmb29fc3RyaW5nGAIgASgJSAASSQoLZm9v", - "X21lc3NhZ2UYAyABKAsyMi5wcm90b2J1Zl91bml0dGVzdC5UZXN0UmVxdWly", - "ZWRPbmVvZi5OZXN0ZWRNZXNzYWdlSAAaKAoNTmVzdGVkTWVzc2FnZRIXCg9y", - "ZXF1aXJlZF9kb3VibGUYASACKAFCBQoDZm9vIqoDCg9UZXN0UGFja2VkVHlw", - "ZXMSGAoMcGFja2VkX2ludDMyGFogAygFQgIQARIYCgxwYWNrZWRfaW50NjQY", - "WyADKANCAhABEhkKDXBhY2tlZF91aW50MzIYXCADKA1CAhABEhkKDXBhY2tl", - "ZF91aW50NjQYXSADKARCAhABEhkKDXBhY2tlZF9zaW50MzIYXiADKBFCAhAB", - "EhkKDXBhY2tlZF9zaW50NjQYXyADKBJCAhABEhoKDnBhY2tlZF9maXhlZDMy", - "GGAgAygHQgIQARIaCg5wYWNrZWRfZml4ZWQ2NBhhIAMoBkICEAESGwoPcGFj", - "a2VkX3NmaXhlZDMyGGIgAygPQgIQARIbCg9wYWNrZWRfc2ZpeGVkNjQYYyAD", - "KBBCAhABEhgKDHBhY2tlZF9mbG9hdBhkIAMoAkICEAESGQoNcGFja2VkX2Rv", - "dWJsZRhlIAMoAUICEAESFwoLcGFja2VkX2Jvb2wYZiADKAhCAhABEjcKC3Bh", - "Y2tlZF9lbnVtGGcgAygOMh4ucHJvdG9idWZfdW5pdHRlc3QuRm9yZWlnbkVu", - "dW1CAhABIsgDChFUZXN0VW5wYWNrZWRUeXBlcxIaCg51bnBhY2tlZF9pbnQz", - "MhhaIAMoBUICEAASGgoOdW5wYWNrZWRfaW50NjQYWyADKANCAhAAEhsKD3Vu", - "cGFja2VkX3VpbnQzMhhcIAMoDUICEAASGwoPdW5wYWNrZWRfdWludDY0GF0g", - "AygEQgIQABIbCg91bnBhY2tlZF9zaW50MzIYXiADKBFCAhAAEhsKD3VucGFj", - "a2VkX3NpbnQ2NBhfIAMoEkICEAASHAoQdW5wYWNrZWRfZml4ZWQzMhhgIAMo", - "B0ICEAASHAoQdW5wYWNrZWRfZml4ZWQ2NBhhIAMoBkICEAASHQoRdW5wYWNr", - "ZWRfc2ZpeGVkMzIYYiADKA9CAhAAEh0KEXVucGFja2VkX3NmaXhlZDY0GGMg", - "AygQQgIQABIaCg51bnBhY2tlZF9mbG9hdBhkIAMoAkICEAASGwoPdW5wYWNr", - "ZWRfZG91YmxlGGUgAygBQgIQABIZCg11bnBhY2tlZF9ib29sGGYgAygIQgIQ", - "ABI5Cg11bnBhY2tlZF9lbnVtGGcgAygOMh4ucHJvdG9idWZfdW5pdHRlc3Qu", - "Rm9yZWlnbkVudW1CAhAAIiAKFFRlc3RQYWNrZWRFeHRlbnNpb25zKggIARCA", - "gICAAiIiChZUZXN0VW5wYWNrZWRFeHRlbnNpb25zKggIARCAgICAAiKZBAoV", - "VGVzdER5bmFtaWNFeHRlbnNpb25zEhkKEHNjYWxhcl9leHRlbnNpb24Y0A8g", - "ASgHEjcKDmVudW1fZXh0ZW5zaW9uGNEPIAEoDjIeLnByb3RvYnVmX3VuaXR0", - "ZXN0LkZvcmVpZ25FbnVtElkKFmR5bmFtaWNfZW51bV9leHRlbnNpb24Y0g8g", - "ASgOMjgucHJvdG9idWZfdW5pdHRlc3QuVGVzdER5bmFtaWNFeHRlbnNpb25z", - "LkR5bmFtaWNFbnVtVHlwZRI9ChFtZXNzYWdlX2V4dGVuc2lvbhjTDyABKAsy", - "IS5wcm90b2J1Zl91bml0dGVzdC5Gb3JlaWduTWVzc2FnZRJfChlkeW5hbWlj", - "X21lc3NhZ2VfZXh0ZW5zaW9uGNQPIAEoCzI7LnByb3RvYnVmX3VuaXR0ZXN0", - "LlRlc3REeW5hbWljRXh0ZW5zaW9ucy5EeW5hbWljTWVzc2FnZVR5cGUSGwoS", - "cmVwZWF0ZWRfZXh0ZW5zaW9uGNUPIAMoCRIdChBwYWNrZWRfZXh0ZW5zaW9u", - "GNYPIAMoEUICEAEaLAoSRHluYW1pY01lc3NhZ2VUeXBlEhYKDWR5bmFtaWNf", - "ZmllbGQYtBAgASgFIkcKD0R5bmFtaWNFbnVtVHlwZRIQCgtEWU5BTUlDX0ZP", - "TxCYERIQCgtEWU5BTUlDX0JBUhCZERIQCgtEWU5BTUlDX0JBWhCaESLAAQoj", - "VGVzdFJlcGVhdGVkU2NhbGFyRGlmZmVyZW50VGFnU2l6ZXMSGAoQcmVwZWF0", - "ZWRfZml4ZWQzMhgMIAMoBxIWCg5yZXBlYXRlZF9pbnQzMhgNIAMoBRIZChBy", - "ZXBlYXRlZF9maXhlZDY0GP4PIAMoBhIXCg5yZXBlYXRlZF9pbnQ2NBj/DyAD", - "KAMSGAoOcmVwZWF0ZWRfZmxvYXQY/v8PIAMoAhIZCg9yZXBlYXRlZF91aW50", - "NjQY//8PIAMoBCL3CQoQVGVzdFBhcnNpbmdNZXJnZRI7ChJyZXF1aXJlZF9h", - "bGxfdHlwZXMYASACKAsyHy5wcm90b2J1Zl91bml0dGVzdC5UZXN0QWxsVHlw", - "ZXMSOwoSb3B0aW9uYWxfYWxsX3R5cGVzGAIgASgLMh8ucHJvdG9idWZfdW5p", - "dHRlc3QuVGVzdEFsbFR5cGVzEjsKEnJlcGVhdGVkX2FsbF90eXBlcxgDIAMo", - "CzIfLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RBbGxUeXBlcxJICg1vcHRpb25h", - "bGdyb3VwGAogASgKMjEucHJvdG9idWZfdW5pdHRlc3QuVGVzdFBhcnNpbmdN", - "ZXJnZS5PcHRpb25hbEdyb3VwEkgKDXJlcGVhdGVkZ3JvdXAYFCADKAoyMS5w", - "cm90b2J1Zl91bml0dGVzdC5UZXN0UGFyc2luZ01lcmdlLlJlcGVhdGVkR3Jv", - "dXAaqgQKF1JlcGVhdGVkRmllbGRzR2VuZXJhdG9yEi8KBmZpZWxkMRgBIAMo", - "CzIfLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RBbGxUeXBlcxIvCgZmaWVsZDIY", - "AiADKAsyHy5wcm90b2J1Zl91bml0dGVzdC5UZXN0QWxsVHlwZXMSLwoGZmll", - "bGQzGAMgAygLMh8ucHJvdG9idWZfdW5pdHRlc3QuVGVzdEFsbFR5cGVzElIK", - "Bmdyb3VwMRgKIAMoCjJCLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RQYXJzaW5n", - "TWVyZ2UuUmVwZWF0ZWRGaWVsZHNHZW5lcmF0b3IuR3JvdXAxElIKBmdyb3Vw", - "MhgUIAMoCjJCLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RQYXJzaW5nTWVyZ2Uu", - "UmVwZWF0ZWRGaWVsZHNHZW5lcmF0b3IuR3JvdXAyEi4KBGV4dDEY6AcgAygL", - "Mh8ucHJvdG9idWZfdW5pdHRlc3QuVGVzdEFsbFR5cGVzEi4KBGV4dDIY6Qcg", - "AygLMh8ucHJvdG9idWZfdW5pdHRlc3QuVGVzdEFsbFR5cGVzGjkKBkdyb3Vw", - "MRIvCgZmaWVsZDEYCyABKAsyHy5wcm90b2J1Zl91bml0dGVzdC5UZXN0QWxs", - "VHlwZXMaOQoGR3JvdXAyEi8KBmZpZWxkMRgVIAEoCzIfLnByb3RvYnVmX3Vu", - "aXR0ZXN0LlRlc3RBbGxUeXBlcxpSCg1PcHRpb25hbEdyb3VwEkEKGG9wdGlv", - "bmFsX2dyb3VwX2FsbF90eXBlcxgLIAEoCzIfLnByb3RvYnVmX3VuaXR0ZXN0", - "LlRlc3RBbGxUeXBlcxpSCg1SZXBlYXRlZEdyb3VwEkEKGHJlcGVhdGVkX2dy", - "b3VwX2FsbF90eXBlcxgVIAEoCzIfLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RB", - "bGxUeXBlcyoJCOgHEICAgIACMlsKDG9wdGlvbmFsX2V4dBIjLnByb3RvYnVm", - "X3VuaXR0ZXN0LlRlc3RQYXJzaW5nTWVyZ2UY6AcgASgLMh8ucHJvdG9idWZf", - "dW5pdHRlc3QuVGVzdEFsbFR5cGVzMlsKDHJlcGVhdGVkX2V4dBIjLnByb3Rv", - "YnVmX3VuaXR0ZXN0LlRlc3RQYXJzaW5nTWVyZ2UY6QcgAygLMh8ucHJvdG9i", - "dWZfdW5pdHRlc3QuVGVzdEFsbFR5cGVzIkQKG1Rlc3RDb21tZW50SW5qZWN0", - "aW9uTWVzc2FnZRIlCgFhGAEgASgJOhoqLyA8LSBOZWl0aGVyIHNob3VsZCB0", - "aGlzLiIMCgpGb29SZXF1ZXN0Ig0KC0Zvb1Jlc3BvbnNlIhIKEEZvb0NsaWVu", - "dE1lc3NhZ2UiEgoQRm9vU2VydmVyTWVzc2FnZSIMCgpCYXJSZXF1ZXN0Ig0K", - "C0JhclJlc3BvbnNlKkAKC0ZvcmVpZ25FbnVtEg8KC0ZPUkVJR05fRk9PEAQS", - "DwoLRk9SRUlHTl9CQVIQBRIPCgtGT1JFSUdOX0JBWhAGKksKFFRlc3RFbnVt", - "V2l0aER1cFZhbHVlEggKBEZPTzEQARIICgRCQVIxEAISBwoDQkFaEAMSCAoE", - "Rk9PMhABEggKBEJBUjIQAhoCEAEqiQEKDlRlc3RTcGFyc2VFbnVtEgwKCFNQ", - "QVJTRV9BEHsSDgoIU1BBUlNFX0IQpucDEg8KCFNQQVJTRV9DELKxgAYSFQoI", - "U1BBUlNFX0QQ8f//////////ARIVCghTUEFSU0VfRRC03vz///////8BEgwK", - "CFNQQVJTRV9GEAASDAoIU1BBUlNFX0cQAjKZAQoLVGVzdFNlcnZpY2USRAoD", - "Rm9vEh0ucHJvdG9idWZfdW5pdHRlc3QuRm9vUmVxdWVzdBoeLnByb3RvYnVm", - "X3VuaXR0ZXN0LkZvb1Jlc3BvbnNlEkQKA0JhchIdLnByb3RvYnVmX3VuaXR0", - "ZXN0LkJhclJlcXVlc3QaHi5wcm90b2J1Zl91bml0dGVzdC5CYXJSZXNwb25z", - "ZTpGChhvcHRpb25hbF9pbnQzMl9leHRlbnNpb24SJC5wcm90b2J1Zl91bml0", - "dGVzdC5UZXN0QWxsRXh0ZW5zaW9ucxgBIAEoBTpGChhvcHRpb25hbF9pbnQ2", - "NF9leHRlbnNpb24SJC5wcm90b2J1Zl91bml0dGVzdC5UZXN0QWxsRXh0ZW5z", - "aW9ucxgCIAEoAzpHChlvcHRpb25hbF91aW50MzJfZXh0ZW5zaW9uEiQucHJv", - "dG9idWZfdW5pdHRlc3QuVGVzdEFsbEV4dGVuc2lvbnMYAyABKA06RwoZb3B0", - "aW9uYWxfdWludDY0X2V4dGVuc2lvbhIkLnByb3RvYnVmX3VuaXR0ZXN0LlRl", - "c3RBbGxFeHRlbnNpb25zGAQgASgEOkcKGW9wdGlvbmFsX3NpbnQzMl9leHRl", - "bnNpb24SJC5wcm90b2J1Zl91bml0dGVzdC5UZXN0QWxsRXh0ZW5zaW9ucxgF", - "IAEoETpHChlvcHRpb25hbF9zaW50NjRfZXh0ZW5zaW9uEiQucHJvdG9idWZf", - "dW5pdHRlc3QuVGVzdEFsbEV4dGVuc2lvbnMYBiABKBI6SAoab3B0aW9uYWxf", - "Zml4ZWQzMl9leHRlbnNpb24SJC5wcm90b2J1Zl91bml0dGVzdC5UZXN0QWxs", - "RXh0ZW5zaW9ucxgHIAEoBzpIChpvcHRpb25hbF9maXhlZDY0X2V4dGVuc2lv", - "bhIkLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RBbGxFeHRlbnNpb25zGAggASgG", - "OkkKG29wdGlvbmFsX3NmaXhlZDMyX2V4dGVuc2lvbhIkLnByb3RvYnVmX3Vu", - "aXR0ZXN0LlRlc3RBbGxFeHRlbnNpb25zGAkgASgPOkkKG29wdGlvbmFsX3Nm", - "aXhlZDY0X2V4dGVuc2lvbhIkLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RBbGxF", - "eHRlbnNpb25zGAogASgQOkYKGG9wdGlvbmFsX2Zsb2F0X2V4dGVuc2lvbhIk", - "LnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RBbGxFeHRlbnNpb25zGAsgASgCOkcK", - "GW9wdGlvbmFsX2RvdWJsZV9leHRlbnNpb24SJC5wcm90b2J1Zl91bml0dGVz", - "dC5UZXN0QWxsRXh0ZW5zaW9ucxgMIAEoATpFChdvcHRpb25hbF9ib29sX2V4", - "dGVuc2lvbhIkLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RBbGxFeHRlbnNpb25z", - "GA0gASgIOkcKGW9wdGlvbmFsX3N0cmluZ19leHRlbnNpb24SJC5wcm90b2J1", - "Zl91bml0dGVzdC5UZXN0QWxsRXh0ZW5zaW9ucxgOIAEoCTpGChhvcHRpb25h", - "bF9ieXRlc19leHRlbnNpb24SJC5wcm90b2J1Zl91bml0dGVzdC5UZXN0QWxs", - "RXh0ZW5zaW9ucxgPIAEoDDpxChdvcHRpb25hbGdyb3VwX2V4dGVuc2lvbhIk", - "LnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RBbGxFeHRlbnNpb25zGBAgASgKMiou", - "cHJvdG9idWZfdW5pdHRlc3QuT3B0aW9uYWxHcm91cF9leHRlbnNpb246fgoh", - "b3B0aW9uYWxfbmVzdGVkX21lc3NhZ2VfZXh0ZW5zaW9uEiQucHJvdG9idWZf", - "dW5pdHRlc3QuVGVzdEFsbEV4dGVuc2lvbnMYEiABKAsyLS5wcm90b2J1Zl91", - "bml0dGVzdC5UZXN0QWxsVHlwZXMuTmVzdGVkTWVzc2FnZTpzCiJvcHRpb25h", - "bF9mb3JlaWduX21lc3NhZ2VfZXh0ZW5zaW9uEiQucHJvdG9idWZfdW5pdHRl", - "c3QuVGVzdEFsbEV4dGVuc2lvbnMYEyABKAsyIS5wcm90b2J1Zl91bml0dGVz", - "dC5Gb3JlaWduTWVzc2FnZTp4CiFvcHRpb25hbF9pbXBvcnRfbWVzc2FnZV9l", - "eHRlbnNpb24SJC5wcm90b2J1Zl91bml0dGVzdC5UZXN0QWxsRXh0ZW5zaW9u", - "cxgUIAEoCzInLnByb3RvYnVmX3VuaXR0ZXN0X2ltcG9ydC5JbXBvcnRNZXNz", - "YWdlOngKHm9wdGlvbmFsX25lc3RlZF9lbnVtX2V4dGVuc2lvbhIkLnByb3Rv", - "YnVmX3VuaXR0ZXN0LlRlc3RBbGxFeHRlbnNpb25zGBUgASgOMioucHJvdG9i", - "dWZfdW5pdHRlc3QuVGVzdEFsbFR5cGVzLk5lc3RlZEVudW06bQofb3B0aW9u", - "YWxfZm9yZWlnbl9lbnVtX2V4dGVuc2lvbhIkLnByb3RvYnVmX3VuaXR0ZXN0", - "LlRlc3RBbGxFeHRlbnNpb25zGBYgASgOMh4ucHJvdG9idWZfdW5pdHRlc3Qu", - "Rm9yZWlnbkVudW06cgoeb3B0aW9uYWxfaW1wb3J0X2VudW1fZXh0ZW5zaW9u", - "EiQucHJvdG9idWZfdW5pdHRlc3QuVGVzdEFsbEV4dGVuc2lvbnMYFyABKA4y", - "JC5wcm90b2J1Zl91bml0dGVzdF9pbXBvcnQuSW1wb3J0RW51bTpRCh9vcHRp", - "b25hbF9zdHJpbmdfcGllY2VfZXh0ZW5zaW9uEiQucHJvdG9idWZfdW5pdHRl", - "c3QuVGVzdEFsbEV4dGVuc2lvbnMYGCABKAlCAggCOkkKF29wdGlvbmFsX2Nv", - "cmRfZXh0ZW5zaW9uEiQucHJvdG9idWZfdW5pdHRlc3QuVGVzdEFsbEV4dGVu", - "c2lvbnMYGSABKAlCAggBOoUBCihvcHRpb25hbF9wdWJsaWNfaW1wb3J0X21l", - "c3NhZ2VfZXh0ZW5zaW9uEiQucHJvdG9idWZfdW5pdHRlc3QuVGVzdEFsbEV4", - "dGVuc2lvbnMYGiABKAsyLS5wcm90b2J1Zl91bml0dGVzdF9pbXBvcnQuUHVi", - "bGljSW1wb3J0TWVzc2FnZTqAAQofb3B0aW9uYWxfbGF6eV9tZXNzYWdlX2V4", - "dGVuc2lvbhIkLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RBbGxFeHRlbnNpb25z", - "GBsgASgLMi0ucHJvdG9idWZfdW5pdHRlc3QuVGVzdEFsbFR5cGVzLk5lc3Rl", - "ZE1lc3NhZ2VCAigBOkYKGHJlcGVhdGVkX2ludDMyX2V4dGVuc2lvbhIkLnBy", - "b3RvYnVmX3VuaXR0ZXN0LlRlc3RBbGxFeHRlbnNpb25zGB8gAygFOkYKGHJl", - "cGVhdGVkX2ludDY0X2V4dGVuc2lvbhIkLnByb3RvYnVmX3VuaXR0ZXN0LlRl", - "c3RBbGxFeHRlbnNpb25zGCAgAygDOkcKGXJlcGVhdGVkX3VpbnQzMl9leHRl", - "bnNpb24SJC5wcm90b2J1Zl91bml0dGVzdC5UZXN0QWxsRXh0ZW5zaW9ucxgh", - "IAMoDTpHChlyZXBlYXRlZF91aW50NjRfZXh0ZW5zaW9uEiQucHJvdG9idWZf", - "dW5pdHRlc3QuVGVzdEFsbEV4dGVuc2lvbnMYIiADKAQ6RwoZcmVwZWF0ZWRf", - "c2ludDMyX2V4dGVuc2lvbhIkLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RBbGxF", - "eHRlbnNpb25zGCMgAygROkcKGXJlcGVhdGVkX3NpbnQ2NF9leHRlbnNpb24S", - "JC5wcm90b2J1Zl91bml0dGVzdC5UZXN0QWxsRXh0ZW5zaW9ucxgkIAMoEjpI", - "ChpyZXBlYXRlZF9maXhlZDMyX2V4dGVuc2lvbhIkLnByb3RvYnVmX3VuaXR0", - "ZXN0LlRlc3RBbGxFeHRlbnNpb25zGCUgAygHOkgKGnJlcGVhdGVkX2ZpeGVk", - "NjRfZXh0ZW5zaW9uEiQucHJvdG9idWZfdW5pdHRlc3QuVGVzdEFsbEV4dGVu", - "c2lvbnMYJiADKAY6SQobcmVwZWF0ZWRfc2ZpeGVkMzJfZXh0ZW5zaW9uEiQu", - "cHJvdG9idWZfdW5pdHRlc3QuVGVzdEFsbEV4dGVuc2lvbnMYJyADKA86SQob", - "cmVwZWF0ZWRfc2ZpeGVkNjRfZXh0ZW5zaW9uEiQucHJvdG9idWZfdW5pdHRl", - "c3QuVGVzdEFsbEV4dGVuc2lvbnMYKCADKBA6RgoYcmVwZWF0ZWRfZmxvYXRf", - "ZXh0ZW5zaW9uEiQucHJvdG9idWZfdW5pdHRlc3QuVGVzdEFsbEV4dGVuc2lv", - "bnMYKSADKAI6RwoZcmVwZWF0ZWRfZG91YmxlX2V4dGVuc2lvbhIkLnByb3Rv", - "YnVmX3VuaXR0ZXN0LlRlc3RBbGxFeHRlbnNpb25zGCogAygBOkUKF3JlcGVh", - "dGVkX2Jvb2xfZXh0ZW5zaW9uEiQucHJvdG9idWZfdW5pdHRlc3QuVGVzdEFs", - "bEV4dGVuc2lvbnMYKyADKAg6RwoZcmVwZWF0ZWRfc3RyaW5nX2V4dGVuc2lv", - "bhIkLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RBbGxFeHRlbnNpb25zGCwgAygJ", - "OkYKGHJlcGVhdGVkX2J5dGVzX2V4dGVuc2lvbhIkLnByb3RvYnVmX3VuaXR0", - "ZXN0LlRlc3RBbGxFeHRlbnNpb25zGC0gAygMOnEKF3JlcGVhdGVkZ3JvdXBf", - "ZXh0ZW5zaW9uEiQucHJvdG9idWZfdW5pdHRlc3QuVGVzdEFsbEV4dGVuc2lv", - "bnMYLiADKAoyKi5wcm90b2J1Zl91bml0dGVzdC5SZXBlYXRlZEdyb3VwX2V4", - "dGVuc2lvbjp+CiFyZXBlYXRlZF9uZXN0ZWRfbWVzc2FnZV9leHRlbnNpb24S", - "JC5wcm90b2J1Zl91bml0dGVzdC5UZXN0QWxsRXh0ZW5zaW9ucxgwIAMoCzIt", - "LnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RBbGxUeXBlcy5OZXN0ZWRNZXNzYWdl", - "OnMKInJlcGVhdGVkX2ZvcmVpZ25fbWVzc2FnZV9leHRlbnNpb24SJC5wcm90", - "b2J1Zl91bml0dGVzdC5UZXN0QWxsRXh0ZW5zaW9ucxgxIAMoCzIhLnByb3Rv", - "YnVmX3VuaXR0ZXN0LkZvcmVpZ25NZXNzYWdlOngKIXJlcGVhdGVkX2ltcG9y", - "dF9tZXNzYWdlX2V4dGVuc2lvbhIkLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RB", - "bGxFeHRlbnNpb25zGDIgAygLMicucHJvdG9idWZfdW5pdHRlc3RfaW1wb3J0", - "LkltcG9ydE1lc3NhZ2U6eAoecmVwZWF0ZWRfbmVzdGVkX2VudW1fZXh0ZW5z", - "aW9uEiQucHJvdG9idWZfdW5pdHRlc3QuVGVzdEFsbEV4dGVuc2lvbnMYMyAD", - "KA4yKi5wcm90b2J1Zl91bml0dGVzdC5UZXN0QWxsVHlwZXMuTmVzdGVkRW51", - "bTptCh9yZXBlYXRlZF9mb3JlaWduX2VudW1fZXh0ZW5zaW9uEiQucHJvdG9i", - "dWZfdW5pdHRlc3QuVGVzdEFsbEV4dGVuc2lvbnMYNCADKA4yHi5wcm90b2J1", - "Zl91bml0dGVzdC5Gb3JlaWduRW51bTpyCh5yZXBlYXRlZF9pbXBvcnRfZW51", - "bV9leHRlbnNpb24SJC5wcm90b2J1Zl91bml0dGVzdC5UZXN0QWxsRXh0ZW5z", - "aW9ucxg1IAMoDjIkLnByb3RvYnVmX3VuaXR0ZXN0X2ltcG9ydC5JbXBvcnRF", - "bnVtOlEKH3JlcGVhdGVkX3N0cmluZ19waWVjZV9leHRlbnNpb24SJC5wcm90", - "b2J1Zl91bml0dGVzdC5UZXN0QWxsRXh0ZW5zaW9ucxg2IAMoCUICCAI6SQoX", - "cmVwZWF0ZWRfY29yZF9leHRlbnNpb24SJC5wcm90b2J1Zl91bml0dGVzdC5U", - "ZXN0QWxsRXh0ZW5zaW9ucxg3IAMoCUICCAE6gAEKH3JlcGVhdGVkX2xhenlf", - "bWVzc2FnZV9leHRlbnNpb24SJC5wcm90b2J1Zl91bml0dGVzdC5UZXN0QWxs", - "RXh0ZW5zaW9ucxg5IAMoCzItLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RBbGxU", - "eXBlcy5OZXN0ZWRNZXNzYWdlQgIoATpJChdkZWZhdWx0X2ludDMyX2V4dGVu", - "c2lvbhIkLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RBbGxFeHRlbnNpb25zGD0g", - "ASgFOgI0MTpJChdkZWZhdWx0X2ludDY0X2V4dGVuc2lvbhIkLnByb3RvYnVm", - "X3VuaXR0ZXN0LlRlc3RBbGxFeHRlbnNpb25zGD4gASgDOgI0MjpKChhkZWZh", - "dWx0X3VpbnQzMl9leHRlbnNpb24SJC5wcm90b2J1Zl91bml0dGVzdC5UZXN0", - "QWxsRXh0ZW5zaW9ucxg/IAEoDToCNDM6SgoYZGVmYXVsdF91aW50NjRfZXh0", - "ZW5zaW9uEiQucHJvdG9idWZfdW5pdHRlc3QuVGVzdEFsbEV4dGVuc2lvbnMY", - "QCABKAQ6AjQ0OksKGGRlZmF1bHRfc2ludDMyX2V4dGVuc2lvbhIkLnByb3Rv", - "YnVmX3VuaXR0ZXN0LlRlc3RBbGxFeHRlbnNpb25zGEEgASgROgMtNDU6SgoY", - "ZGVmYXVsdF9zaW50NjRfZXh0ZW5zaW9uEiQucHJvdG9idWZfdW5pdHRlc3Qu", - "VGVzdEFsbEV4dGVuc2lvbnMYQiABKBI6AjQ2OksKGWRlZmF1bHRfZml4ZWQz", - "Ml9leHRlbnNpb24SJC5wcm90b2J1Zl91bml0dGVzdC5UZXN0QWxsRXh0ZW5z", - "aW9ucxhDIAEoBzoCNDc6SwoZZGVmYXVsdF9maXhlZDY0X2V4dGVuc2lvbhIk", - "LnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RBbGxFeHRlbnNpb25zGEQgASgGOgI0", - "ODpMChpkZWZhdWx0X3NmaXhlZDMyX2V4dGVuc2lvbhIkLnByb3RvYnVmX3Vu", - "aXR0ZXN0LlRlc3RBbGxFeHRlbnNpb25zGEUgASgPOgI0OTpNChpkZWZhdWx0", - "X3NmaXhlZDY0X2V4dGVuc2lvbhIkLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RB", - "bGxFeHRlbnNpb25zGEYgASgQOgMtNTA6SwoXZGVmYXVsdF9mbG9hdF9leHRl", - "bnNpb24SJC5wcm90b2J1Zl91bml0dGVzdC5UZXN0QWxsRXh0ZW5zaW9ucxhH", - "IAEoAjoENTEuNTpNChhkZWZhdWx0X2RvdWJsZV9leHRlbnNpb24SJC5wcm90", - "b2J1Zl91bml0dGVzdC5UZXN0QWxsRXh0ZW5zaW9ucxhIIAEoAToFNTIwMDA6", - "SgoWZGVmYXVsdF9ib29sX2V4dGVuc2lvbhIkLnByb3RvYnVmX3VuaXR0ZXN0", - "LlRlc3RBbGxFeHRlbnNpb25zGEkgASgIOgR0cnVlOk0KGGRlZmF1bHRfc3Ry", - "aW5nX2V4dGVuc2lvbhIkLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RBbGxFeHRl", - "bnNpb25zGEogASgJOgVoZWxsbzpMChdkZWZhdWx0X2J5dGVzX2V4dGVuc2lv", - "bhIkLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RBbGxFeHRlbnNpb25zGEsgASgM", - "OgV3b3JsZDp8Ch1kZWZhdWx0X25lc3RlZF9lbnVtX2V4dGVuc2lvbhIkLnBy", - "b3RvYnVmX3VuaXR0ZXN0LlRlc3RBbGxFeHRlbnNpb25zGFEgASgOMioucHJv", - "dG9idWZfdW5pdHRlc3QuVGVzdEFsbFR5cGVzLk5lc3RlZEVudW06A0JBUjp5", - "Ch5kZWZhdWx0X2ZvcmVpZ25fZW51bV9leHRlbnNpb24SJC5wcm90b2J1Zl91", - "bml0dGVzdC5UZXN0QWxsRXh0ZW5zaW9ucxhSIAEoDjIeLnByb3RvYnVmX3Vu", - "aXR0ZXN0LkZvcmVpZ25FbnVtOgtGT1JFSUdOX0JBUjp9Ch1kZWZhdWx0X2lt", - "cG9ydF9lbnVtX2V4dGVuc2lvbhIkLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RB", - "bGxFeHRlbnNpb25zGFMgASgOMiQucHJvdG9idWZfdW5pdHRlc3RfaW1wb3J0", - "LkltcG9ydEVudW06CklNUE9SVF9CQVI6VQoeZGVmYXVsdF9zdHJpbmdfcGll", - "Y2VfZXh0ZW5zaW9uEiQucHJvdG9idWZfdW5pdHRlc3QuVGVzdEFsbEV4dGVu", - "c2lvbnMYVCABKAk6A2FiY0ICCAI6TQoWZGVmYXVsdF9jb3JkX2V4dGVuc2lv", - "bhIkLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RBbGxFeHRlbnNpb25zGFUgASgJ", - "OgMxMjNCAggBOkQKFm9uZW9mX3VpbnQzMl9leHRlbnNpb24SJC5wcm90b2J1", - "Zl91bml0dGVzdC5UZXN0QWxsRXh0ZW5zaW9ucxhvIAEoDTp7Ch5vbmVvZl9u", - "ZXN0ZWRfbWVzc2FnZV9leHRlbnNpb24SJC5wcm90b2J1Zl91bml0dGVzdC5U", - "ZXN0QWxsRXh0ZW5zaW9ucxhwIAEoCzItLnByb3RvYnVmX3VuaXR0ZXN0LlRl", - "c3RBbGxUeXBlcy5OZXN0ZWRNZXNzYWdlOkQKFm9uZW9mX3N0cmluZ19leHRl", - "bnNpb24SJC5wcm90b2J1Zl91bml0dGVzdC5UZXN0QWxsRXh0ZW5zaW9ucxhx", - "IAEoCTpDChVvbmVvZl9ieXRlc19leHRlbnNpb24SJC5wcm90b2J1Zl91bml0", - "dGVzdC5UZXN0QWxsRXh0ZW5zaW9ucxhyIAEoDDpCChNteV9leHRlbnNpb25f", - "c3RyaW5nEiUucHJvdG9idWZfdW5pdHRlc3QuVGVzdEZpZWxkT3JkZXJpbmdz", - "GDIgASgJOj8KEG15X2V4dGVuc2lvbl9pbnQSJS5wcm90b2J1Zl91bml0dGVz", - "dC5UZXN0RmllbGRPcmRlcmluZ3MYBSABKAU6SwoWcGFja2VkX2ludDMyX2V4", - "dGVuc2lvbhInLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RQYWNrZWRFeHRlbnNp", - "b25zGFogAygFQgIQATpLChZwYWNrZWRfaW50NjRfZXh0ZW5zaW9uEicucHJv", - "dG9idWZfdW5pdHRlc3QuVGVzdFBhY2tlZEV4dGVuc2lvbnMYWyADKANCAhAB", - "OkwKF3BhY2tlZF91aW50MzJfZXh0ZW5zaW9uEicucHJvdG9idWZfdW5pdHRl", - "c3QuVGVzdFBhY2tlZEV4dGVuc2lvbnMYXCADKA1CAhABOkwKF3BhY2tlZF91", - "aW50NjRfZXh0ZW5zaW9uEicucHJvdG9idWZfdW5pdHRlc3QuVGVzdFBhY2tl", - "ZEV4dGVuc2lvbnMYXSADKARCAhABOkwKF3BhY2tlZF9zaW50MzJfZXh0ZW5z", - "aW9uEicucHJvdG9idWZfdW5pdHRlc3QuVGVzdFBhY2tlZEV4dGVuc2lvbnMY", - "XiADKBFCAhABOkwKF3BhY2tlZF9zaW50NjRfZXh0ZW5zaW9uEicucHJvdG9i", - "dWZfdW5pdHRlc3QuVGVzdFBhY2tlZEV4dGVuc2lvbnMYXyADKBJCAhABOk0K", - "GHBhY2tlZF9maXhlZDMyX2V4dGVuc2lvbhInLnByb3RvYnVmX3VuaXR0ZXN0", - "LlRlc3RQYWNrZWRFeHRlbnNpb25zGGAgAygHQgIQATpNChhwYWNrZWRfZml4", - "ZWQ2NF9leHRlbnNpb24SJy5wcm90b2J1Zl91bml0dGVzdC5UZXN0UGFja2Vk", - "RXh0ZW5zaW9ucxhhIAMoBkICEAE6TgoZcGFja2VkX3NmaXhlZDMyX2V4dGVu", - "c2lvbhInLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RQYWNrZWRFeHRlbnNpb25z", - "GGIgAygPQgIQATpOChlwYWNrZWRfc2ZpeGVkNjRfZXh0ZW5zaW9uEicucHJv", - "dG9idWZfdW5pdHRlc3QuVGVzdFBhY2tlZEV4dGVuc2lvbnMYYyADKBBCAhAB", - "OksKFnBhY2tlZF9mbG9hdF9leHRlbnNpb24SJy5wcm90b2J1Zl91bml0dGVz", - "dC5UZXN0UGFja2VkRXh0ZW5zaW9ucxhkIAMoAkICEAE6TAoXcGFja2VkX2Rv", - "dWJsZV9leHRlbnNpb24SJy5wcm90b2J1Zl91bml0dGVzdC5UZXN0UGFja2Vk", - "RXh0ZW5zaW9ucxhlIAMoAUICEAE6SgoVcGFja2VkX2Jvb2xfZXh0ZW5zaW9u", - "EicucHJvdG9idWZfdW5pdHRlc3QuVGVzdFBhY2tlZEV4dGVuc2lvbnMYZiAD", - "KAhCAhABOmoKFXBhY2tlZF9lbnVtX2V4dGVuc2lvbhInLnByb3RvYnVmX3Vu", - "aXR0ZXN0LlRlc3RQYWNrZWRFeHRlbnNpb25zGGcgAygOMh4ucHJvdG9idWZf", - "dW5pdHRlc3QuRm9yZWlnbkVudW1CAhABOk8KGHVucGFja2VkX2ludDMyX2V4", - "dGVuc2lvbhIpLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RVbnBhY2tlZEV4dGVu", - "c2lvbnMYWiADKAVCAhAAOk8KGHVucGFja2VkX2ludDY0X2V4dGVuc2lvbhIp", - "LnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RVbnBhY2tlZEV4dGVuc2lvbnMYWyAD", - "KANCAhAAOlAKGXVucGFja2VkX3VpbnQzMl9leHRlbnNpb24SKS5wcm90b2J1", - "Zl91bml0dGVzdC5UZXN0VW5wYWNrZWRFeHRlbnNpb25zGFwgAygNQgIQADpQ", - "Chl1bnBhY2tlZF91aW50NjRfZXh0ZW5zaW9uEikucHJvdG9idWZfdW5pdHRl", - "c3QuVGVzdFVucGFja2VkRXh0ZW5zaW9ucxhdIAMoBEICEAA6UAoZdW5wYWNr", - "ZWRfc2ludDMyX2V4dGVuc2lvbhIpLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RV", - "bnBhY2tlZEV4dGVuc2lvbnMYXiADKBFCAhAAOlAKGXVucGFja2VkX3NpbnQ2", - "NF9leHRlbnNpb24SKS5wcm90b2J1Zl91bml0dGVzdC5UZXN0VW5wYWNrZWRF", - "eHRlbnNpb25zGF8gAygSQgIQADpRChp1bnBhY2tlZF9maXhlZDMyX2V4dGVu", - "c2lvbhIpLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RVbnBhY2tlZEV4dGVuc2lv", - "bnMYYCADKAdCAhAAOlEKGnVucGFja2VkX2ZpeGVkNjRfZXh0ZW5zaW9uEiku", - "cHJvdG9idWZfdW5pdHRlc3QuVGVzdFVucGFja2VkRXh0ZW5zaW9ucxhhIAMo", - "BkICEAA6UgobdW5wYWNrZWRfc2ZpeGVkMzJfZXh0ZW5zaW9uEikucHJvdG9i", - "dWZfdW5pdHRlc3QuVGVzdFVucGFja2VkRXh0ZW5zaW9ucxhiIAMoD0ICEAA6", - "UgobdW5wYWNrZWRfc2ZpeGVkNjRfZXh0ZW5zaW9uEikucHJvdG9idWZfdW5p", - "dHRlc3QuVGVzdFVucGFja2VkRXh0ZW5zaW9ucxhjIAMoEEICEAA6TwoYdW5w", - "YWNrZWRfZmxvYXRfZXh0ZW5zaW9uEikucHJvdG9idWZfdW5pdHRlc3QuVGVz", - "dFVucGFja2VkRXh0ZW5zaW9ucxhkIAMoAkICEAA6UAoZdW5wYWNrZWRfZG91", - "YmxlX2V4dGVuc2lvbhIpLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RVbnBhY2tl", - "ZEV4dGVuc2lvbnMYZSADKAFCAhAAOk4KF3VucGFja2VkX2Jvb2xfZXh0ZW5z", - "aW9uEikucHJvdG9idWZfdW5pdHRlc3QuVGVzdFVucGFja2VkRXh0ZW5zaW9u", - "cxhmIAMoCEICEAA6bgoXdW5wYWNrZWRfZW51bV9leHRlbnNpb24SKS5wcm90", - "b2J1Zl91bml0dGVzdC5UZXN0VW5wYWNrZWRFeHRlbnNpb25zGGcgAygOMh4u", - "cHJvdG9idWZfdW5pdHRlc3QuRm9yZWlnbkVudW1CAhAAQkFCDVVuaXR0ZXN0", - "UHJvdG9IAYABAYgBAZABAfgBAaoCIUdvb2dsZS5Qcm90b2NvbEJ1ZmZlcnMu", - "VGVzdFByb3Rvcw==")); - pbd::FileDescriptor.InternalDescriptorAssigner assigner = delegate(pbd::FileDescriptor root) { - descriptor = root; - internal__static_protobuf_unittest_TestAllTypes__Descriptor = Descriptor.MessageTypes[0]; - internal__static_protobuf_unittest_TestAllTypes__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestAllTypes__Descriptor, - new string[] { "OptionalInt32", "OptionalInt64", "OptionalUint32", "OptionalUint64", "OptionalSint32", "OptionalSint64", "OptionalFixed32", "OptionalFixed64", "OptionalSfixed32", "OptionalSfixed64", "OptionalFloat", "OptionalDouble", "OptionalBool", "OptionalString", "OptionalBytes", "OptionalGroup", "OptionalNestedMessage", "OptionalForeignMessage", "OptionalImportMessage", "OptionalNestedEnum", "OptionalForeignEnum", "OptionalImportEnum", "OptionalStringPiece", "OptionalCord", "OptionalPublicImportMessage", "OptionalLazyMessage", "RepeatedInt32", "RepeatedInt64", "RepeatedUint32", "RepeatedUint64", "RepeatedSint32", "RepeatedSint64", "RepeatedFixed32", "RepeatedFixed64", "RepeatedSfixed32", "RepeatedSfixed64", "RepeatedFloat", "RepeatedDouble", "RepeatedBool", "RepeatedString", "RepeatedBytes", "RepeatedGroup", "RepeatedNestedMessage", "RepeatedForeignMessage", "RepeatedImportMessage", "RepeatedNestedEnum", "RepeatedForeignEnum", "RepeatedImportEnum", "RepeatedStringPiece", "RepeatedCord", "RepeatedLazyMessage", "DefaultInt32", "DefaultInt64", "DefaultUint32", "DefaultUint64", "DefaultSint32", "DefaultSint64", "DefaultFixed32", "DefaultFixed64", "DefaultSfixed32", "DefaultSfixed64", "DefaultFloat", "DefaultDouble", "DefaultBool", "DefaultString", "DefaultBytes", "DefaultNestedEnum", "DefaultForeignEnum", "DefaultImportEnum", "DefaultStringPiece", "DefaultCord", "OneofUint32", "OneofNestedMessage", "OneofString", "OneofBytes", "OneofField", }); - internal__static_protobuf_unittest_TestAllTypes_NestedMessage__Descriptor = internal__static_protobuf_unittest_TestAllTypes__Descriptor.NestedTypes[0]; - internal__static_protobuf_unittest_TestAllTypes_NestedMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestAllTypes_NestedMessage__Descriptor, - new string[] { "Bb", }); - internal__static_protobuf_unittest_TestAllTypes_OptionalGroup__Descriptor = internal__static_protobuf_unittest_TestAllTypes__Descriptor.NestedTypes[1]; - internal__static_protobuf_unittest_TestAllTypes_OptionalGroup__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestAllTypes_OptionalGroup__Descriptor, - new string[] { "A", }); - internal__static_protobuf_unittest_TestAllTypes_RepeatedGroup__Descriptor = internal__static_protobuf_unittest_TestAllTypes__Descriptor.NestedTypes[2]; - internal__static_protobuf_unittest_TestAllTypes_RepeatedGroup__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestAllTypes_RepeatedGroup__Descriptor, - new string[] { "A", }); - internal__static_protobuf_unittest_NestedTestAllTypes__Descriptor = Descriptor.MessageTypes[1]; - internal__static_protobuf_unittest_NestedTestAllTypes__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_NestedTestAllTypes__Descriptor, - new string[] { "Child", "Payload", "RepeatedChild", }); - internal__static_protobuf_unittest_TestDeprecatedFields__Descriptor = Descriptor.MessageTypes[2]; - internal__static_protobuf_unittest_TestDeprecatedFields__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestDeprecatedFields__Descriptor, - new string[] { "DeprecatedInt32", }); - internal__static_protobuf_unittest_ForeignMessage__Descriptor = Descriptor.MessageTypes[3]; - internal__static_protobuf_unittest_ForeignMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_ForeignMessage__Descriptor, - new string[] { "C", }); - internal__static_protobuf_unittest_TestReservedFields__Descriptor = Descriptor.MessageTypes[4]; - internal__static_protobuf_unittest_TestReservedFields__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestReservedFields__Descriptor, - new string[] { }); - internal__static_protobuf_unittest_TestAllExtensions__Descriptor = Descriptor.MessageTypes[5]; - internal__static_protobuf_unittest_TestAllExtensions__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestAllExtensions__Descriptor, - new string[] { }); - internal__static_protobuf_unittest_OptionalGroup_extension__Descriptor = Descriptor.MessageTypes[6]; - internal__static_protobuf_unittest_OptionalGroup_extension__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_OptionalGroup_extension__Descriptor, - new string[] { "A", }); - internal__static_protobuf_unittest_RepeatedGroup_extension__Descriptor = Descriptor.MessageTypes[7]; - internal__static_protobuf_unittest_RepeatedGroup_extension__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_RepeatedGroup_extension__Descriptor, - new string[] { "A", }); - internal__static_protobuf_unittest_TestNestedExtension__Descriptor = Descriptor.MessageTypes[8]; - internal__static_protobuf_unittest_TestNestedExtension__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestNestedExtension__Descriptor, - new string[] { }); - global::Google.ProtocolBuffers.TestProtos.TestNestedExtension.Test = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.TestNestedExtension.Descriptor.Extensions[0]); - global::Google.ProtocolBuffers.TestProtos.TestNestedExtension.NestedStringExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.TestNestedExtension.Descriptor.Extensions[1]); - internal__static_protobuf_unittest_TestRequired__Descriptor = Descriptor.MessageTypes[9]; - internal__static_protobuf_unittest_TestRequired__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestRequired__Descriptor, - new string[] { "A", "Dummy2", "B", "Dummy4", "Dummy5", "Dummy6", "Dummy7", "Dummy8", "Dummy9", "Dummy10", "Dummy11", "Dummy12", "Dummy13", "Dummy14", "Dummy15", "Dummy16", "Dummy17", "Dummy18", "Dummy19", "Dummy20", "Dummy21", "Dummy22", "Dummy23", "Dummy24", "Dummy25", "Dummy26", "Dummy27", "Dummy28", "Dummy29", "Dummy30", "Dummy31", "Dummy32", "C", }); - global::Google.ProtocolBuffers.TestProtos.TestRequired.Single = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.TestRequired.Descriptor.Extensions[0]); - global::Google.ProtocolBuffers.TestProtos.TestRequired.Multi = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.TestRequired.Descriptor.Extensions[1]); - internal__static_protobuf_unittest_TestRequiredForeign__Descriptor = Descriptor.MessageTypes[10]; - internal__static_protobuf_unittest_TestRequiredForeign__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestRequiredForeign__Descriptor, - new string[] { "OptionalMessage", "RepeatedMessage", "Dummy", }); - internal__static_protobuf_unittest_TestForeignNested__Descriptor = Descriptor.MessageTypes[11]; - internal__static_protobuf_unittest_TestForeignNested__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestForeignNested__Descriptor, - new string[] { "ForeignNested", }); - internal__static_protobuf_unittest_TestEmptyMessage__Descriptor = Descriptor.MessageTypes[12]; - internal__static_protobuf_unittest_TestEmptyMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestEmptyMessage__Descriptor, - new string[] { }); - internal__static_protobuf_unittest_TestEmptyMessageWithExtensions__Descriptor = Descriptor.MessageTypes[13]; - internal__static_protobuf_unittest_TestEmptyMessageWithExtensions__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestEmptyMessageWithExtensions__Descriptor, - new string[] { }); - internal__static_protobuf_unittest_TestMultipleExtensionRanges__Descriptor = Descriptor.MessageTypes[14]; - internal__static_protobuf_unittest_TestMultipleExtensionRanges__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestMultipleExtensionRanges__Descriptor, - new string[] { }); - internal__static_protobuf_unittest_TestReallyLargeTagNumber__Descriptor = Descriptor.MessageTypes[15]; - internal__static_protobuf_unittest_TestReallyLargeTagNumber__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestReallyLargeTagNumber__Descriptor, - new string[] { "A", "Bb", }); - internal__static_protobuf_unittest_TestRecursiveMessage__Descriptor = Descriptor.MessageTypes[16]; - internal__static_protobuf_unittest_TestRecursiveMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestRecursiveMessage__Descriptor, - new string[] { "A", "I", }); - internal__static_protobuf_unittest_TestMutualRecursionA__Descriptor = Descriptor.MessageTypes[17]; - internal__static_protobuf_unittest_TestMutualRecursionA__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestMutualRecursionA__Descriptor, - new string[] { "Bb", }); - internal__static_protobuf_unittest_TestMutualRecursionB__Descriptor = Descriptor.MessageTypes[18]; - internal__static_protobuf_unittest_TestMutualRecursionB__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestMutualRecursionB__Descriptor, - new string[] { "A", "OptionalInt32", }); - internal__static_protobuf_unittest_TestDupFieldNumber__Descriptor = Descriptor.MessageTypes[19]; - internal__static_protobuf_unittest_TestDupFieldNumber__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestDupFieldNumber__Descriptor, - new string[] { "A", "Foo", "Bar", }); - internal__static_protobuf_unittest_TestDupFieldNumber_Foo__Descriptor = internal__static_protobuf_unittest_TestDupFieldNumber__Descriptor.NestedTypes[0]; - internal__static_protobuf_unittest_TestDupFieldNumber_Foo__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestDupFieldNumber_Foo__Descriptor, - new string[] { "A", }); - internal__static_protobuf_unittest_TestDupFieldNumber_Bar__Descriptor = internal__static_protobuf_unittest_TestDupFieldNumber__Descriptor.NestedTypes[1]; - internal__static_protobuf_unittest_TestDupFieldNumber_Bar__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestDupFieldNumber_Bar__Descriptor, - new string[] { "A", }); - internal__static_protobuf_unittest_TestEagerMessage__Descriptor = Descriptor.MessageTypes[20]; - internal__static_protobuf_unittest_TestEagerMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestEagerMessage__Descriptor, - new string[] { "SubMessage", }); - internal__static_protobuf_unittest_TestLazyMessage__Descriptor = Descriptor.MessageTypes[21]; - internal__static_protobuf_unittest_TestLazyMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestLazyMessage__Descriptor, - new string[] { "SubMessage", }); - internal__static_protobuf_unittest_TestNestedMessageHasBits__Descriptor = Descriptor.MessageTypes[22]; - internal__static_protobuf_unittest_TestNestedMessageHasBits__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestNestedMessageHasBits__Descriptor, - new string[] { "OptionalNestedMessage", }); - internal__static_protobuf_unittest_TestNestedMessageHasBits_NestedMessage__Descriptor = internal__static_protobuf_unittest_TestNestedMessageHasBits__Descriptor.NestedTypes[0]; - internal__static_protobuf_unittest_TestNestedMessageHasBits_NestedMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestNestedMessageHasBits_NestedMessage__Descriptor, - new string[] { "NestedmessageRepeatedInt32", "NestedmessageRepeatedForeignmessage", }); - internal__static_protobuf_unittest_TestCamelCaseFieldNames__Descriptor = Descriptor.MessageTypes[23]; - internal__static_protobuf_unittest_TestCamelCaseFieldNames__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestCamelCaseFieldNames__Descriptor, - new string[] { "PrimitiveField", "StringField", "EnumField", "MessageField", "StringPieceField", "CordField", "RepeatedPrimitiveField", "RepeatedStringField", "RepeatedEnumField", "RepeatedMessageField", "RepeatedStringPieceField", "RepeatedCordField", }); - internal__static_protobuf_unittest_TestFieldOrderings__Descriptor = Descriptor.MessageTypes[24]; - internal__static_protobuf_unittest_TestFieldOrderings__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestFieldOrderings__Descriptor, - new string[] { "MyString", "MyInt", "MyFloat", "OptionalNestedMessage", }); - internal__static_protobuf_unittest_TestFieldOrderings_NestedMessage__Descriptor = internal__static_protobuf_unittest_TestFieldOrderings__Descriptor.NestedTypes[0]; - internal__static_protobuf_unittest_TestFieldOrderings_NestedMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestFieldOrderings_NestedMessage__Descriptor, - new string[] { "Oo", "Bb", }); - internal__static_protobuf_unittest_TestExtremeDefaultValues__Descriptor = Descriptor.MessageTypes[25]; - internal__static_protobuf_unittest_TestExtremeDefaultValues__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestExtremeDefaultValues__Descriptor, - new string[] { "EscapedBytes", "LargeUint32", "LargeUint64", "SmallInt32", "SmallInt64", "ReallySmallInt32", "ReallySmallInt64", "Utf8String", "ZeroFloat", "OneFloat", "SmallFloat", "NegativeOneFloat", "NegativeFloat", "LargeFloat", "SmallNegativeFloat", "InfDouble", "NegInfDouble", "NanDouble", "InfFloat", "NegInfFloat", "NanFloat", "CppTrigraph", "StringWithZero", "BytesWithZero", "StringPieceWithZero", "CordWithZero", "ReplacementString", }); - internal__static_protobuf_unittest_SparseEnumMessage__Descriptor = Descriptor.MessageTypes[26]; - internal__static_protobuf_unittest_SparseEnumMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_SparseEnumMessage__Descriptor, - new string[] { "SparseEnum", }); - internal__static_protobuf_unittest_OneString__Descriptor = Descriptor.MessageTypes[27]; - internal__static_protobuf_unittest_OneString__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_OneString__Descriptor, - new string[] { "Data", }); - internal__static_protobuf_unittest_MoreString__Descriptor = Descriptor.MessageTypes[28]; - internal__static_protobuf_unittest_MoreString__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_MoreString__Descriptor, - new string[] { "Data", }); - internal__static_protobuf_unittest_OneBytes__Descriptor = Descriptor.MessageTypes[29]; - internal__static_protobuf_unittest_OneBytes__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_OneBytes__Descriptor, - new string[] { "Data", }); - internal__static_protobuf_unittest_MoreBytes__Descriptor = Descriptor.MessageTypes[30]; - internal__static_protobuf_unittest_MoreBytes__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_MoreBytes__Descriptor, - new string[] { "Data", }); - internal__static_protobuf_unittest_Int32Message__Descriptor = Descriptor.MessageTypes[31]; - internal__static_protobuf_unittest_Int32Message__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_Int32Message__Descriptor, - new string[] { "Data", }); - internal__static_protobuf_unittest_Uint32Message__Descriptor = Descriptor.MessageTypes[32]; - internal__static_protobuf_unittest_Uint32Message__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_Uint32Message__Descriptor, - new string[] { "Data", }); - internal__static_protobuf_unittest_Int64Message__Descriptor = Descriptor.MessageTypes[33]; - internal__static_protobuf_unittest_Int64Message__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_Int64Message__Descriptor, - new string[] { "Data", }); - internal__static_protobuf_unittest_Uint64Message__Descriptor = Descriptor.MessageTypes[34]; - internal__static_protobuf_unittest_Uint64Message__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_Uint64Message__Descriptor, - new string[] { "Data", }); - internal__static_protobuf_unittest_BoolMessage__Descriptor = Descriptor.MessageTypes[35]; - internal__static_protobuf_unittest_BoolMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_BoolMessage__Descriptor, - new string[] { "Data", }); - internal__static_protobuf_unittest_TestOneof__Descriptor = Descriptor.MessageTypes[36]; - internal__static_protobuf_unittest_TestOneof__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestOneof__Descriptor, - new string[] { "FooInt", "FooString", "FooMessage", "FooGroup", "Foo", }); - internal__static_protobuf_unittest_TestOneof_FooGroup__Descriptor = internal__static_protobuf_unittest_TestOneof__Descriptor.NestedTypes[0]; - internal__static_protobuf_unittest_TestOneof_FooGroup__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestOneof_FooGroup__Descriptor, - new string[] { "A", "B", }); - internal__static_protobuf_unittest_TestOneofBackwardsCompatible__Descriptor = Descriptor.MessageTypes[37]; - internal__static_protobuf_unittest_TestOneofBackwardsCompatible__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestOneofBackwardsCompatible__Descriptor, - new string[] { "FooInt", "FooString", "FooMessage", "FooGroup", }); - internal__static_protobuf_unittest_TestOneofBackwardsCompatible_FooGroup__Descriptor = internal__static_protobuf_unittest_TestOneofBackwardsCompatible__Descriptor.NestedTypes[0]; - internal__static_protobuf_unittest_TestOneofBackwardsCompatible_FooGroup__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestOneofBackwardsCompatible_FooGroup__Descriptor, - new string[] { "A", "B", }); - internal__static_protobuf_unittest_TestOneof2__Descriptor = Descriptor.MessageTypes[38]; - internal__static_protobuf_unittest_TestOneof2__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestOneof2__Descriptor, - new string[] { "FooInt", "FooString", "FooCord", "FooStringPiece", "FooBytes", "FooEnum", "FooMessage", "FooGroup", "FooLazyMessage", "BarInt", "BarString", "BarCord", "BarStringPiece", "BarBytes", "BarEnum", "BazInt", "BazString", "Foo", "Bar", }); - internal__static_protobuf_unittest_TestOneof2_FooGroup__Descriptor = internal__static_protobuf_unittest_TestOneof2__Descriptor.NestedTypes[0]; - internal__static_protobuf_unittest_TestOneof2_FooGroup__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestOneof2_FooGroup__Descriptor, - new string[] { "A", "B", }); - internal__static_protobuf_unittest_TestOneof2_NestedMessage__Descriptor = internal__static_protobuf_unittest_TestOneof2__Descriptor.NestedTypes[1]; - internal__static_protobuf_unittest_TestOneof2_NestedMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestOneof2_NestedMessage__Descriptor, - new string[] { "QuxInt", "CorgeInt", }); - internal__static_protobuf_unittest_TestRequiredOneof__Descriptor = Descriptor.MessageTypes[39]; - internal__static_protobuf_unittest_TestRequiredOneof__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestRequiredOneof__Descriptor, - new string[] { "FooInt", "FooString", "FooMessage", "Foo", }); - internal__static_protobuf_unittest_TestRequiredOneof_NestedMessage__Descriptor = internal__static_protobuf_unittest_TestRequiredOneof__Descriptor.NestedTypes[0]; - internal__static_protobuf_unittest_TestRequiredOneof_NestedMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestRequiredOneof_NestedMessage__Descriptor, - new string[] { "RequiredDouble", }); - internal__static_protobuf_unittest_TestPackedTypes__Descriptor = Descriptor.MessageTypes[40]; - internal__static_protobuf_unittest_TestPackedTypes__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestPackedTypes__Descriptor, - new string[] { "PackedInt32", "PackedInt64", "PackedUint32", "PackedUint64", "PackedSint32", "PackedSint64", "PackedFixed32", "PackedFixed64", "PackedSfixed32", "PackedSfixed64", "PackedFloat", "PackedDouble", "PackedBool", "PackedEnum", }); - internal__static_protobuf_unittest_TestUnpackedTypes__Descriptor = Descriptor.MessageTypes[41]; - internal__static_protobuf_unittest_TestUnpackedTypes__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestUnpackedTypes__Descriptor, - new string[] { "UnpackedInt32", "UnpackedInt64", "UnpackedUint32", "UnpackedUint64", "UnpackedSint32", "UnpackedSint64", "UnpackedFixed32", "UnpackedFixed64", "UnpackedSfixed32", "UnpackedSfixed64", "UnpackedFloat", "UnpackedDouble", "UnpackedBool", "UnpackedEnum", }); - internal__static_protobuf_unittest_TestPackedExtensions__Descriptor = Descriptor.MessageTypes[42]; - internal__static_protobuf_unittest_TestPackedExtensions__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestPackedExtensions__Descriptor, - new string[] { }); - internal__static_protobuf_unittest_TestUnpackedExtensions__Descriptor = Descriptor.MessageTypes[43]; - internal__static_protobuf_unittest_TestUnpackedExtensions__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestUnpackedExtensions__Descriptor, - new string[] { }); - internal__static_protobuf_unittest_TestDynamicExtensions__Descriptor = Descriptor.MessageTypes[44]; - internal__static_protobuf_unittest_TestDynamicExtensions__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestDynamicExtensions__Descriptor, - new string[] { "ScalarExtension", "EnumExtension", "DynamicEnumExtension", "MessageExtension", "DynamicMessageExtension", "RepeatedExtension", "PackedExtension", }); - internal__static_protobuf_unittest_TestDynamicExtensions_DynamicMessageType__Descriptor = internal__static_protobuf_unittest_TestDynamicExtensions__Descriptor.NestedTypes[0]; - internal__static_protobuf_unittest_TestDynamicExtensions_DynamicMessageType__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestDynamicExtensions_DynamicMessageType__Descriptor, - new string[] { "DynamicField", }); - internal__static_protobuf_unittest_TestRepeatedScalarDifferentTagSizes__Descriptor = Descriptor.MessageTypes[45]; - internal__static_protobuf_unittest_TestRepeatedScalarDifferentTagSizes__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestRepeatedScalarDifferentTagSizes__Descriptor, - new string[] { "RepeatedFixed32", "RepeatedInt32", "RepeatedFixed64", "RepeatedInt64", "RepeatedFloat", "RepeatedUint64", }); - internal__static_protobuf_unittest_TestParsingMerge__Descriptor = Descriptor.MessageTypes[46]; - internal__static_protobuf_unittest_TestParsingMerge__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestParsingMerge__Descriptor, - new string[] { "RequiredAllTypes", "OptionalAllTypes", "RepeatedAllTypes", "OptionalGroup", "RepeatedGroup", }); - internal__static_protobuf_unittest_TestParsingMerge_RepeatedFieldsGenerator__Descriptor = internal__static_protobuf_unittest_TestParsingMerge__Descriptor.NestedTypes[0]; - internal__static_protobuf_unittest_TestParsingMerge_RepeatedFieldsGenerator__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestParsingMerge_RepeatedFieldsGenerator__Descriptor, - new string[] { "Field1", "Field2", "Field3", "Group1", "Group2", "Ext1", "Ext2", }); - internal__static_protobuf_unittest_TestParsingMerge_RepeatedFieldsGenerator_Group1__Descriptor = internal__static_protobuf_unittest_TestParsingMerge_RepeatedFieldsGenerator__Descriptor.NestedTypes[0]; - internal__static_protobuf_unittest_TestParsingMerge_RepeatedFieldsGenerator_Group1__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestParsingMerge_RepeatedFieldsGenerator_Group1__Descriptor, - new string[] { "Field1", }); - internal__static_protobuf_unittest_TestParsingMerge_RepeatedFieldsGenerator_Group2__Descriptor = internal__static_protobuf_unittest_TestParsingMerge_RepeatedFieldsGenerator__Descriptor.NestedTypes[1]; - internal__static_protobuf_unittest_TestParsingMerge_RepeatedFieldsGenerator_Group2__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestParsingMerge_RepeatedFieldsGenerator_Group2__Descriptor, - new string[] { "Field1", }); - internal__static_protobuf_unittest_TestParsingMerge_OptionalGroup__Descriptor = internal__static_protobuf_unittest_TestParsingMerge__Descriptor.NestedTypes[1]; - internal__static_protobuf_unittest_TestParsingMerge_OptionalGroup__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestParsingMerge_OptionalGroup__Descriptor, - new string[] { "OptionalGroupAllTypes", }); - internal__static_protobuf_unittest_TestParsingMerge_RepeatedGroup__Descriptor = internal__static_protobuf_unittest_TestParsingMerge__Descriptor.NestedTypes[2]; - internal__static_protobuf_unittest_TestParsingMerge_RepeatedGroup__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestParsingMerge_RepeatedGroup__Descriptor, - new string[] { "RepeatedGroupAllTypes", }); - global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.OptionalExt = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Descriptor.Extensions[0]); - global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.RepeatedExt = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Descriptor.Extensions[1]); - internal__static_protobuf_unittest_TestCommentInjectionMessage__Descriptor = Descriptor.MessageTypes[47]; - internal__static_protobuf_unittest_TestCommentInjectionMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestCommentInjectionMessage__Descriptor, - new string[] { "A", }); - internal__static_protobuf_unittest_FooRequest__Descriptor = Descriptor.MessageTypes[48]; - internal__static_protobuf_unittest_FooRequest__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_FooRequest__Descriptor, - new string[] { }); - internal__static_protobuf_unittest_FooResponse__Descriptor = Descriptor.MessageTypes[49]; - internal__static_protobuf_unittest_FooResponse__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_FooResponse__Descriptor, - new string[] { }); - internal__static_protobuf_unittest_FooClientMessage__Descriptor = Descriptor.MessageTypes[50]; - internal__static_protobuf_unittest_FooClientMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_FooClientMessage__Descriptor, - new string[] { }); - internal__static_protobuf_unittest_FooServerMessage__Descriptor = Descriptor.MessageTypes[51]; - internal__static_protobuf_unittest_FooServerMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_FooServerMessage__Descriptor, - new string[] { }); - internal__static_protobuf_unittest_BarRequest__Descriptor = Descriptor.MessageTypes[52]; - internal__static_protobuf_unittest_BarRequest__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_BarRequest__Descriptor, - new string[] { }); - internal__static_protobuf_unittest_BarResponse__Descriptor = Descriptor.MessageTypes[53]; - internal__static_protobuf_unittest_BarResponse__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_BarResponse__Descriptor, - new string[] { }); - global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalInt32Extension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[0]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalInt64Extension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[1]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalUint32Extension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[2]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalUint64Extension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[3]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalSint32Extension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[4]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalSint64Extension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[5]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalFixed32Extension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[6]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalFixed64Extension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[7]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalSfixed32Extension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[8]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalSfixed64Extension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[9]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalFloatExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[10]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalDoubleExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[11]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalBoolExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[12]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalStringExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[13]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalBytesExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[14]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalGroupExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[15]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalNestedMessageExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[16]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalForeignMessageExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[17]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalImportMessageExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[18]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalNestedEnumExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[19]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalForeignEnumExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[20]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalImportEnumExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[21]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalStringPieceExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[22]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalCordExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[23]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalPublicImportMessageExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[24]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalLazyMessageExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[25]); - global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedInt32Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[26]); - global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedInt64Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[27]); - global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedUint32Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[28]); - global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedUint64Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[29]); - global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedSint32Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[30]); - global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedSint64Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[31]); - global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedFixed32Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[32]); - global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedFixed64Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[33]); - global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedSfixed32Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[34]); - global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedSfixed64Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[35]); - global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedFloatExtension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[36]); - global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedDoubleExtension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[37]); - global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedBoolExtension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[38]); - global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedStringExtension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[39]); - global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedBytesExtension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[40]); - global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedGroupExtension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[41]); - global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedNestedMessageExtension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[42]); - global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedForeignMessageExtension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[43]); - global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedImportMessageExtension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[44]); - global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedNestedEnumExtension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[45]); - global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedForeignEnumExtension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[46]); - global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedImportEnumExtension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[47]); - global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedStringPieceExtension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[48]); - global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedCordExtension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[49]); - global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedLazyMessageExtension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[50]); - global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultInt32Extension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[51]); - global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultInt64Extension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[52]); - global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultUint32Extension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[53]); - global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultUint64Extension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[54]); - global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultSint32Extension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[55]); - global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultSint64Extension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[56]); - global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultFixed32Extension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[57]); - global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultFixed64Extension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[58]); - global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultSfixed32Extension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[59]); - global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultSfixed64Extension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[60]); - global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultFloatExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[61]); - global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultDoubleExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[62]); - global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultBoolExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[63]); - global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultStringExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[64]); - global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultBytesExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[65]); - global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultNestedEnumExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[66]); - global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultForeignEnumExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[67]); - global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultImportEnumExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[68]); - global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultStringPieceExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[69]); - global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultCordExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[70]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OneofUint32Extension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[71]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OneofNestedMessageExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[72]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OneofStringExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[73]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OneofBytesExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[74]); - global::Google.ProtocolBuffers.TestProtos.Unittest.MyExtensionString = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[75]); - global::Google.ProtocolBuffers.TestProtos.Unittest.MyExtensionInt = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[76]); - global::Google.ProtocolBuffers.TestProtos.Unittest.PackedInt32Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[77]); - global::Google.ProtocolBuffers.TestProtos.Unittest.PackedInt64Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[78]); - global::Google.ProtocolBuffers.TestProtos.Unittest.PackedUint32Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[79]); - global::Google.ProtocolBuffers.TestProtos.Unittest.PackedUint64Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[80]); - global::Google.ProtocolBuffers.TestProtos.Unittest.PackedSint32Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[81]); - global::Google.ProtocolBuffers.TestProtos.Unittest.PackedSint64Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[82]); - global::Google.ProtocolBuffers.TestProtos.Unittest.PackedFixed32Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[83]); - global::Google.ProtocolBuffers.TestProtos.Unittest.PackedFixed64Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[84]); - global::Google.ProtocolBuffers.TestProtos.Unittest.PackedSfixed32Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[85]); - global::Google.ProtocolBuffers.TestProtos.Unittest.PackedSfixed64Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[86]); - global::Google.ProtocolBuffers.TestProtos.Unittest.PackedFloatExtension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[87]); - global::Google.ProtocolBuffers.TestProtos.Unittest.PackedDoubleExtension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[88]); - global::Google.ProtocolBuffers.TestProtos.Unittest.PackedBoolExtension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[89]); - global::Google.ProtocolBuffers.TestProtos.Unittest.PackedEnumExtension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[90]); - global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedInt32Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[91]); - global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedInt64Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[92]); - global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedUint32Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[93]); - global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedUint64Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[94]); - global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedSint32Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[95]); - global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedSint64Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[96]); - global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedFixed32Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[97]); - global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedFixed64Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[98]); - global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedSfixed32Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[99]); - global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedSfixed64Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[100]); - global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedFloatExtension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[101]); - global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedDoubleExtension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[102]); - global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedBoolExtension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[103]); - global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedEnumExtension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[104]); - pb::ExtensionRegistry registry = pb::ExtensionRegistry.CreateInstance(); - RegisterAllExtensions(registry); - global::Google.ProtocolBuffers.TestProtos.UnittestImport.RegisterAllExtensions(registry); - return registry; - }; - pbd::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, - new pbd::FileDescriptor[] { - global::Google.ProtocolBuffers.TestProtos.UnittestImport.Descriptor, - }, assigner); - } - #endregion - - } - #region Enums - public enum ForeignEnum { - FOREIGN_FOO = 4, - FOREIGN_BAR = 5, - FOREIGN_BAZ = 6, - } - - public enum TestEnumWithDupValue { - FOO1 = 1, - BAR1 = 2, - BAZ = 3, - FOO2 = 1, - BAR2 = 2, - } - - public enum TestSparseEnum { - SPARSE_A = 123, - SPARSE_B = 62374, - SPARSE_C = 12589234, - SPARSE_D = -15, - SPARSE_E = -53452, - SPARSE_F = 0, - SPARSE_G = 2, - } - - #endregion - - #region Messages - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestAllTypes : pb::GeneratedMessage { - private TestAllTypes() { } - private static readonly TestAllTypes defaultInstance = new TestAllTypes().MakeReadOnly(); - private static readonly string[] _testAllTypesFieldNames = new string[] { "default_bool", "default_bytes", "default_cord", "default_double", "default_fixed32", "default_fixed64", "default_float", "default_foreign_enum", "default_import_enum", "default_int32", "default_int64", "default_nested_enum", "default_sfixed32", "default_sfixed64", "default_sint32", "default_sint64", "default_string", "default_string_piece", "default_uint32", "default_uint64", "oneof_bytes", "oneof_nested_message", "oneof_string", "oneof_uint32", "optional_bool", "optional_bytes", "optional_cord", "optional_double", "optional_fixed32", "optional_fixed64", "optional_float", "optional_foreign_enum", "optional_foreign_message", "optional_import_enum", "optional_import_message", "optional_int32", "optional_int64", "optional_lazy_message", "optional_nested_enum", "optional_nested_message", "optional_public_import_message", "optional_sfixed32", "optional_sfixed64", "optional_sint32", "optional_sint64", "optional_string", "optional_string_piece", "optional_uint32", "optional_uint64", "optionalgroup", "repeated_bool", "repeated_bytes", "repeated_cord", "repeated_double", "repeated_fixed32", "repeated_fixed64", "repeated_float", "repeated_foreign_enum", "repeated_foreign_message", "repeated_import_enum", "repeated_import_message", "repeated_int32", "repeated_int64", "repeated_lazy_message", "repeated_nested_enum", "repeated_nested_message", "repeated_sfixed32", "repeated_sfixed64", "repeated_sint32", "repeated_sint64", "repeated_string", "repeated_string_piece", "repeated_uint32", "repeated_uint64", "repeatedgroup" }; - private static readonly uint[] _testAllTypesFieldTags = new uint[] { 584, 602, 682, 577, 541, 545, 573, 656, 664, 488, 496, 648, 557, 561, 520, 528, 594, 674, 504, 512, 914, 898, 906, 888, 104, 122, 202, 97, 61, 65, 93, 176, 154, 184, 162, 8, 16, 218, 168, 146, 210, 77, 81, 40, 48, 114, 194, 24, 32, 131, 344, 362, 442, 337, 301, 305, 333, 416, 394, 424, 402, 248, 256, 458, 408, 386, 317, 321, 280, 288, 354, 434, 264, 272, 371 }; - public static TestAllTypes DefaultInstance { - get { return defaultInstance; } - } - - public override TestAllTypes DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestAllTypes ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestAllTypes__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestAllTypes__FieldAccessorTable; } - } - - #region Nested types - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class Types { - public enum NestedEnum { - FOO = 1, - BAR = 2, - BAZ = 3, - NEG = -1, - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class NestedMessage : pb::GeneratedMessage { - private NestedMessage() { } - private static readonly NestedMessage defaultInstance = new NestedMessage().MakeReadOnly(); - private static readonly string[] _nestedMessageFieldNames = new string[] { "bb" }; - private static readonly uint[] _nestedMessageFieldTags = new uint[] { 8 }; - public static NestedMessage DefaultInstance { - get { return defaultInstance; } - } - - public override NestedMessage DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override NestedMessage ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestAllTypes_NestedMessage__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestAllTypes_NestedMessage__FieldAccessorTable; } - } - - public const int BbFieldNumber = 1; - private bool hasBb; - private int bb_; - public bool HasBb { - get { return hasBb; } - } - public int Bb { - get { return bb_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _nestedMessageFieldNames; - if (hasBb) { - output.WriteInt32(1, field_names[0], Bb); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasBb) { - size += pb::CodedOutputStream.ComputeInt32Size(1, Bb); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static NestedMessage ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static NestedMessage ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static NestedMessage ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static NestedMessage ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static NestedMessage ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static NestedMessage ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static NestedMessage ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static NestedMessage ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static NestedMessage ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static NestedMessage ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private NestedMessage MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(NestedMessage prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(NestedMessage cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private NestedMessage result; - - private NestedMessage PrepareBuilder() { - if (resultIsReadOnly) { - NestedMessage original = result; - result = new NestedMessage(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override NestedMessage MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.Descriptor; } - } - - public override NestedMessage DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.DefaultInstance; } - } - - public override NestedMessage BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is NestedMessage) { - return MergeFrom((NestedMessage) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(NestedMessage other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasBb) { - Bb = other.Bb; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_nestedMessageFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _nestedMessageFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasBb = input.ReadInt32(ref result.bb_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasBb { - get { return result.hasBb; } - } - public int Bb { - get { return result.Bb; } - set { SetBb(value); } - } - public Builder SetBb(int value) { - PrepareBuilder(); - result.hasBb = true; - result.bb_ = value; - return this; - } - public Builder ClearBb() { - PrepareBuilder(); - result.hasBb = false; - result.bb_ = 0; - return this; - } - } - static NestedMessage() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class OptionalGroup : pb::GeneratedMessage { - private OptionalGroup() { } - private static readonly OptionalGroup defaultInstance = new OptionalGroup().MakeReadOnly(); - private static readonly string[] _optionalGroupFieldNames = new string[] { "a" }; - private static readonly uint[] _optionalGroupFieldTags = new uint[] { 136 }; - public static OptionalGroup DefaultInstance { - get { return defaultInstance; } - } - - public override OptionalGroup DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override OptionalGroup ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestAllTypes_OptionalGroup__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestAllTypes_OptionalGroup__FieldAccessorTable; } - } - - public const int AFieldNumber = 17; - private bool hasA; - private int a_; - public bool HasA { - get { return hasA; } - } - public int A { - get { return a_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _optionalGroupFieldNames; - if (hasA) { - output.WriteInt32(17, field_names[0], A); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(17, A); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static OptionalGroup ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static OptionalGroup ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static OptionalGroup ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static OptionalGroup ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static OptionalGroup ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static OptionalGroup ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static OptionalGroup ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static OptionalGroup ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static OptionalGroup ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static OptionalGroup ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private OptionalGroup MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(OptionalGroup prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(OptionalGroup cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private OptionalGroup result; - - private OptionalGroup PrepareBuilder() { - if (resultIsReadOnly) { - OptionalGroup original = result; - result = new OptionalGroup(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override OptionalGroup MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.OptionalGroup.Descriptor; } - } - - public override OptionalGroup DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.OptionalGroup.DefaultInstance; } - } - - public override OptionalGroup BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is OptionalGroup) { - return MergeFrom((OptionalGroup) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(OptionalGroup other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.OptionalGroup.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasA) { - A = other.A; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_optionalGroupFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _optionalGroupFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 136: { - result.hasA = input.ReadInt32(ref result.a_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasA { - get { return result.hasA; } - } - public int A { - get { return result.A; } - set { SetA(value); } - } - public Builder SetA(int value) { - PrepareBuilder(); - result.hasA = true; - result.a_ = value; - return this; - } - public Builder ClearA() { - PrepareBuilder(); - result.hasA = false; - result.a_ = 0; - return this; - } - } - static OptionalGroup() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class RepeatedGroup : pb::GeneratedMessage { - private RepeatedGroup() { } - private static readonly RepeatedGroup defaultInstance = new RepeatedGroup().MakeReadOnly(); - private static readonly string[] _repeatedGroupFieldNames = new string[] { "a" }; - private static readonly uint[] _repeatedGroupFieldTags = new uint[] { 376 }; - public static RepeatedGroup DefaultInstance { - get { return defaultInstance; } - } - - public override RepeatedGroup DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override RepeatedGroup ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestAllTypes_RepeatedGroup__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestAllTypes_RepeatedGroup__FieldAccessorTable; } - } - - public const int AFieldNumber = 47; - private bool hasA; - private int a_; - public bool HasA { - get { return hasA; } - } - public int A { - get { return a_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _repeatedGroupFieldNames; - if (hasA) { - output.WriteInt32(47, field_names[0], A); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(47, A); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static RepeatedGroup ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static RepeatedGroup ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static RepeatedGroup ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static RepeatedGroup ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static RepeatedGroup ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static RepeatedGroup ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static RepeatedGroup ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static RepeatedGroup ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static RepeatedGroup ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static RepeatedGroup ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private RepeatedGroup MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(RepeatedGroup prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(RepeatedGroup cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private RepeatedGroup result; - - private RepeatedGroup PrepareBuilder() { - if (resultIsReadOnly) { - RepeatedGroup original = result; - result = new RepeatedGroup(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override RepeatedGroup MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup.Descriptor; } - } - - public override RepeatedGroup DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup.DefaultInstance; } - } - - public override RepeatedGroup BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is RepeatedGroup) { - return MergeFrom((RepeatedGroup) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(RepeatedGroup other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasA) { - A = other.A; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_repeatedGroupFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _repeatedGroupFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 376: { - result.hasA = input.ReadInt32(ref result.a_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasA { - get { return result.hasA; } - } - public int A { - get { return result.A; } - set { SetA(value); } - } - public Builder SetA(int value) { - PrepareBuilder(); - result.hasA = true; - result.a_ = value; - return this; - } - public Builder ClearA() { - PrepareBuilder(); - result.hasA = false; - result.a_ = 0; - return this; - } - } - static RepeatedGroup() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - } - #endregion - - private object oneofField_; - public enum OneofFieldOneofCase { - OneofUint32 = 111, - OneofNestedMessage = 112, - OneofString = 113, - OneofBytes = 114, - None = 0, - } - private OneofFieldOneofCase oneofFieldCase_ = OneofFieldOneofCase.None; - public OneofFieldOneofCase OneofFieldCase { - get { return oneofFieldCase_; } - } - - public const int OptionalInt32FieldNumber = 1; - private bool hasOptionalInt32; - private int optionalInt32_; - public bool HasOptionalInt32 { - get { return hasOptionalInt32; } - } - public int OptionalInt32 { - get { return optionalInt32_; } - } - - public const int OptionalInt64FieldNumber = 2; - private bool hasOptionalInt64; - private long optionalInt64_; - public bool HasOptionalInt64 { - get { return hasOptionalInt64; } - } - public long OptionalInt64 { - get { return optionalInt64_; } - } - - public const int OptionalUint32FieldNumber = 3; - private bool hasOptionalUint32; - private uint optionalUint32_; - public bool HasOptionalUint32 { - get { return hasOptionalUint32; } - } - public uint OptionalUint32 { - get { return optionalUint32_; } - } - - public const int OptionalUint64FieldNumber = 4; - private bool hasOptionalUint64; - private ulong optionalUint64_; - public bool HasOptionalUint64 { - get { return hasOptionalUint64; } - } - public ulong OptionalUint64 { - get { return optionalUint64_; } - } - - public const int OptionalSint32FieldNumber = 5; - private bool hasOptionalSint32; - private int optionalSint32_; - public bool HasOptionalSint32 { - get { return hasOptionalSint32; } - } - public int OptionalSint32 { - get { return optionalSint32_; } - } - - public const int OptionalSint64FieldNumber = 6; - private bool hasOptionalSint64; - private long optionalSint64_; - public bool HasOptionalSint64 { - get { return hasOptionalSint64; } - } - public long OptionalSint64 { - get { return optionalSint64_; } - } - - public const int OptionalFixed32FieldNumber = 7; - private bool hasOptionalFixed32; - private uint optionalFixed32_; - public bool HasOptionalFixed32 { - get { return hasOptionalFixed32; } - } - public uint OptionalFixed32 { - get { return optionalFixed32_; } - } - - public const int OptionalFixed64FieldNumber = 8; - private bool hasOptionalFixed64; - private ulong optionalFixed64_; - public bool HasOptionalFixed64 { - get { return hasOptionalFixed64; } - } - public ulong OptionalFixed64 { - get { return optionalFixed64_; } - } - - public const int OptionalSfixed32FieldNumber = 9; - private bool hasOptionalSfixed32; - private int optionalSfixed32_; - public bool HasOptionalSfixed32 { - get { return hasOptionalSfixed32; } - } - public int OptionalSfixed32 { - get { return optionalSfixed32_; } - } - - public const int OptionalSfixed64FieldNumber = 10; - private bool hasOptionalSfixed64; - private long optionalSfixed64_; - public bool HasOptionalSfixed64 { - get { return hasOptionalSfixed64; } - } - public long OptionalSfixed64 { - get { return optionalSfixed64_; } - } - - public const int OptionalFloatFieldNumber = 11; - private bool hasOptionalFloat; - private float optionalFloat_; - public bool HasOptionalFloat { - get { return hasOptionalFloat; } - } - public float OptionalFloat { - get { return optionalFloat_; } - } - - public const int OptionalDoubleFieldNumber = 12; - private bool hasOptionalDouble; - private double optionalDouble_; - public bool HasOptionalDouble { - get { return hasOptionalDouble; } - } - public double OptionalDouble { - get { return optionalDouble_; } - } - - public const int OptionalBoolFieldNumber = 13; - private bool hasOptionalBool; - private bool optionalBool_; - public bool HasOptionalBool { - get { return hasOptionalBool; } - } - public bool OptionalBool { - get { return optionalBool_; } - } - - public const int OptionalStringFieldNumber = 14; - private bool hasOptionalString; - private string optionalString_ = ""; - public bool HasOptionalString { - get { return hasOptionalString; } - } - public string OptionalString { - get { return optionalString_; } - } - - public const int OptionalBytesFieldNumber = 15; - private bool hasOptionalBytes; - private pb::ByteString optionalBytes_ = pb::ByteString.Empty; - public bool HasOptionalBytes { - get { return hasOptionalBytes; } - } - public pb::ByteString OptionalBytes { - get { return optionalBytes_; } - } - - public const int OptionalGroupFieldNumber = 16; - private bool hasOptionalGroup; - private global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.OptionalGroup optionalGroup_; - public bool HasOptionalGroup { - get { return hasOptionalGroup; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.OptionalGroup OptionalGroup { - get { return optionalGroup_ ?? global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.OptionalGroup.DefaultInstance; } - } - - public const int OptionalNestedMessageFieldNumber = 18; - private bool hasOptionalNestedMessage; - private global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage optionalNestedMessage_; - public bool HasOptionalNestedMessage { - get { return hasOptionalNestedMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage OptionalNestedMessage { - get { return optionalNestedMessage_ ?? global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.DefaultInstance; } - } - - public const int OptionalForeignMessageFieldNumber = 19; - private bool hasOptionalForeignMessage; - private global::Google.ProtocolBuffers.TestProtos.ForeignMessage optionalForeignMessage_; - public bool HasOptionalForeignMessage { - get { return hasOptionalForeignMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignMessage OptionalForeignMessage { - get { return optionalForeignMessage_ ?? global::Google.ProtocolBuffers.TestProtos.ForeignMessage.DefaultInstance; } - } - - public const int OptionalImportMessageFieldNumber = 20; - private bool hasOptionalImportMessage; - private global::Google.ProtocolBuffers.TestProtos.ImportMessage optionalImportMessage_; - public bool HasOptionalImportMessage { - get { return hasOptionalImportMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.ImportMessage OptionalImportMessage { - get { return optionalImportMessage_ ?? global::Google.ProtocolBuffers.TestProtos.ImportMessage.DefaultInstance; } - } - - public const int OptionalNestedEnumFieldNumber = 21; - private bool hasOptionalNestedEnum; - private global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedEnum optionalNestedEnum_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedEnum.FOO; - public bool HasOptionalNestedEnum { - get { return hasOptionalNestedEnum; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedEnum OptionalNestedEnum { - get { return optionalNestedEnum_; } - } - - public const int OptionalForeignEnumFieldNumber = 22; - private bool hasOptionalForeignEnum; - private global::Google.ProtocolBuffers.TestProtos.ForeignEnum optionalForeignEnum_ = global::Google.ProtocolBuffers.TestProtos.ForeignEnum.FOREIGN_FOO; - public bool HasOptionalForeignEnum { - get { return hasOptionalForeignEnum; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignEnum OptionalForeignEnum { - get { return optionalForeignEnum_; } - } - - public const int OptionalImportEnumFieldNumber = 23; - private bool hasOptionalImportEnum; - private global::Google.ProtocolBuffers.TestProtos.ImportEnum optionalImportEnum_ = global::Google.ProtocolBuffers.TestProtos.ImportEnum.IMPORT_FOO; - public bool HasOptionalImportEnum { - get { return hasOptionalImportEnum; } - } - public global::Google.ProtocolBuffers.TestProtos.ImportEnum OptionalImportEnum { - get { return optionalImportEnum_; } - } - - public const int OptionalStringPieceFieldNumber = 24; - private bool hasOptionalStringPiece; - private string optionalStringPiece_ = ""; - public bool HasOptionalStringPiece { - get { return hasOptionalStringPiece; } - } - public string OptionalStringPiece { - get { return optionalStringPiece_; } - } - - public const int OptionalCordFieldNumber = 25; - private bool hasOptionalCord; - private string optionalCord_ = ""; - public bool HasOptionalCord { - get { return hasOptionalCord; } - } - public string OptionalCord { - get { return optionalCord_; } - } - - public const int OptionalPublicImportMessageFieldNumber = 26; - private bool hasOptionalPublicImportMessage; - private global::Google.ProtocolBuffers.TestProtos.PublicImportMessage optionalPublicImportMessage_; - public bool HasOptionalPublicImportMessage { - get { return hasOptionalPublicImportMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.PublicImportMessage OptionalPublicImportMessage { - get { return optionalPublicImportMessage_ ?? global::Google.ProtocolBuffers.TestProtos.PublicImportMessage.DefaultInstance; } - } - - public const int OptionalLazyMessageFieldNumber = 27; - private bool hasOptionalLazyMessage; - private global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage optionalLazyMessage_; - public bool HasOptionalLazyMessage { - get { return hasOptionalLazyMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage OptionalLazyMessage { - get { return optionalLazyMessage_ ?? global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.DefaultInstance; } - } - - public const int RepeatedInt32FieldNumber = 31; - private pbc::PopsicleList repeatedInt32_ = new pbc::PopsicleList(); - public scg::IList RepeatedInt32List { - get { return pbc::Lists.AsReadOnly(repeatedInt32_); } - } - public int RepeatedInt32Count { - get { return repeatedInt32_.Count; } - } - public int GetRepeatedInt32(int index) { - return repeatedInt32_[index]; - } - - public const int RepeatedInt64FieldNumber = 32; - private pbc::PopsicleList repeatedInt64_ = new pbc::PopsicleList(); - public scg::IList RepeatedInt64List { - get { return pbc::Lists.AsReadOnly(repeatedInt64_); } - } - public int RepeatedInt64Count { - get { return repeatedInt64_.Count; } - } - public long GetRepeatedInt64(int index) { - return repeatedInt64_[index]; - } - - public const int RepeatedUint32FieldNumber = 33; - private pbc::PopsicleList repeatedUint32_ = new pbc::PopsicleList(); - public scg::IList RepeatedUint32List { - get { return pbc::Lists.AsReadOnly(repeatedUint32_); } - } - public int RepeatedUint32Count { - get { return repeatedUint32_.Count; } - } - public uint GetRepeatedUint32(int index) { - return repeatedUint32_[index]; - } - - public const int RepeatedUint64FieldNumber = 34; - private pbc::PopsicleList repeatedUint64_ = new pbc::PopsicleList(); - public scg::IList RepeatedUint64List { - get { return pbc::Lists.AsReadOnly(repeatedUint64_); } - } - public int RepeatedUint64Count { - get { return repeatedUint64_.Count; } - } - public ulong GetRepeatedUint64(int index) { - return repeatedUint64_[index]; - } - - public const int RepeatedSint32FieldNumber = 35; - private pbc::PopsicleList repeatedSint32_ = new pbc::PopsicleList(); - public scg::IList RepeatedSint32List { - get { return pbc::Lists.AsReadOnly(repeatedSint32_); } - } - public int RepeatedSint32Count { - get { return repeatedSint32_.Count; } - } - public int GetRepeatedSint32(int index) { - return repeatedSint32_[index]; - } - - public const int RepeatedSint64FieldNumber = 36; - private pbc::PopsicleList repeatedSint64_ = new pbc::PopsicleList(); - public scg::IList RepeatedSint64List { - get { return pbc::Lists.AsReadOnly(repeatedSint64_); } - } - public int RepeatedSint64Count { - get { return repeatedSint64_.Count; } - } - public long GetRepeatedSint64(int index) { - return repeatedSint64_[index]; - } - - public const int RepeatedFixed32FieldNumber = 37; - private pbc::PopsicleList repeatedFixed32_ = new pbc::PopsicleList(); - public scg::IList RepeatedFixed32List { - get { return pbc::Lists.AsReadOnly(repeatedFixed32_); } - } - public int RepeatedFixed32Count { - get { return repeatedFixed32_.Count; } - } - public uint GetRepeatedFixed32(int index) { - return repeatedFixed32_[index]; - } - - public const int RepeatedFixed64FieldNumber = 38; - private pbc::PopsicleList repeatedFixed64_ = new pbc::PopsicleList(); - public scg::IList RepeatedFixed64List { - get { return pbc::Lists.AsReadOnly(repeatedFixed64_); } - } - public int RepeatedFixed64Count { - get { return repeatedFixed64_.Count; } - } - public ulong GetRepeatedFixed64(int index) { - return repeatedFixed64_[index]; - } - - public const int RepeatedSfixed32FieldNumber = 39; - private pbc::PopsicleList repeatedSfixed32_ = new pbc::PopsicleList(); - public scg::IList RepeatedSfixed32List { - get { return pbc::Lists.AsReadOnly(repeatedSfixed32_); } - } - public int RepeatedSfixed32Count { - get { return repeatedSfixed32_.Count; } - } - public int GetRepeatedSfixed32(int index) { - return repeatedSfixed32_[index]; - } - - public const int RepeatedSfixed64FieldNumber = 40; - private pbc::PopsicleList repeatedSfixed64_ = new pbc::PopsicleList(); - public scg::IList RepeatedSfixed64List { - get { return pbc::Lists.AsReadOnly(repeatedSfixed64_); } - } - public int RepeatedSfixed64Count { - get { return repeatedSfixed64_.Count; } - } - public long GetRepeatedSfixed64(int index) { - return repeatedSfixed64_[index]; - } - - public const int RepeatedFloatFieldNumber = 41; - private pbc::PopsicleList repeatedFloat_ = new pbc::PopsicleList(); - public scg::IList RepeatedFloatList { - get { return pbc::Lists.AsReadOnly(repeatedFloat_); } - } - public int RepeatedFloatCount { - get { return repeatedFloat_.Count; } - } - public float GetRepeatedFloat(int index) { - return repeatedFloat_[index]; - } - - public const int RepeatedDoubleFieldNumber = 42; - private pbc::PopsicleList repeatedDouble_ = new pbc::PopsicleList(); - public scg::IList RepeatedDoubleList { - get { return pbc::Lists.AsReadOnly(repeatedDouble_); } - } - public int RepeatedDoubleCount { - get { return repeatedDouble_.Count; } - } - public double GetRepeatedDouble(int index) { - return repeatedDouble_[index]; - } - - public const int RepeatedBoolFieldNumber = 43; - private pbc::PopsicleList repeatedBool_ = new pbc::PopsicleList(); - public scg::IList RepeatedBoolList { - get { return pbc::Lists.AsReadOnly(repeatedBool_); } - } - public int RepeatedBoolCount { - get { return repeatedBool_.Count; } - } - public bool GetRepeatedBool(int index) { - return repeatedBool_[index]; - } - - public const int RepeatedStringFieldNumber = 44; - private pbc::PopsicleList repeatedString_ = new pbc::PopsicleList(); - public scg::IList RepeatedStringList { - get { return pbc::Lists.AsReadOnly(repeatedString_); } - } - public int RepeatedStringCount { - get { return repeatedString_.Count; } - } - public string GetRepeatedString(int index) { - return repeatedString_[index]; - } - - public const int RepeatedBytesFieldNumber = 45; - private pbc::PopsicleList repeatedBytes_ = new pbc::PopsicleList(); - public scg::IList RepeatedBytesList { - get { return pbc::Lists.AsReadOnly(repeatedBytes_); } - } - public int RepeatedBytesCount { - get { return repeatedBytes_.Count; } - } - public pb::ByteString GetRepeatedBytes(int index) { - return repeatedBytes_[index]; - } - - public const int RepeatedGroupFieldNumber = 46; - private pbc::PopsicleList repeatedGroup_ = new pbc::PopsicleList(); - public scg::IList RepeatedGroupList { - get { return repeatedGroup_; } - } - public int RepeatedGroupCount { - get { return repeatedGroup_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup GetRepeatedGroup(int index) { - return repeatedGroup_[index]; - } - - public const int RepeatedNestedMessageFieldNumber = 48; - private pbc::PopsicleList repeatedNestedMessage_ = new pbc::PopsicleList(); - public scg::IList RepeatedNestedMessageList { - get { return repeatedNestedMessage_; } - } - public int RepeatedNestedMessageCount { - get { return repeatedNestedMessage_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage GetRepeatedNestedMessage(int index) { - return repeatedNestedMessage_[index]; - } - - public const int RepeatedForeignMessageFieldNumber = 49; - private pbc::PopsicleList repeatedForeignMessage_ = new pbc::PopsicleList(); - public scg::IList RepeatedForeignMessageList { - get { return repeatedForeignMessage_; } - } - public int RepeatedForeignMessageCount { - get { return repeatedForeignMessage_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignMessage GetRepeatedForeignMessage(int index) { - return repeatedForeignMessage_[index]; - } - - public const int RepeatedImportMessageFieldNumber = 50; - private pbc::PopsicleList repeatedImportMessage_ = new pbc::PopsicleList(); - public scg::IList RepeatedImportMessageList { - get { return repeatedImportMessage_; } - } - public int RepeatedImportMessageCount { - get { return repeatedImportMessage_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.ImportMessage GetRepeatedImportMessage(int index) { - return repeatedImportMessage_[index]; - } - - public const int RepeatedNestedEnumFieldNumber = 51; - private pbc::PopsicleList repeatedNestedEnum_ = new pbc::PopsicleList(); - public scg::IList RepeatedNestedEnumList { - get { return pbc::Lists.AsReadOnly(repeatedNestedEnum_); } - } - public int RepeatedNestedEnumCount { - get { return repeatedNestedEnum_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedEnum GetRepeatedNestedEnum(int index) { - return repeatedNestedEnum_[index]; - } - - public const int RepeatedForeignEnumFieldNumber = 52; - private pbc::PopsicleList repeatedForeignEnum_ = new pbc::PopsicleList(); - public scg::IList RepeatedForeignEnumList { - get { return pbc::Lists.AsReadOnly(repeatedForeignEnum_); } - } - public int RepeatedForeignEnumCount { - get { return repeatedForeignEnum_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignEnum GetRepeatedForeignEnum(int index) { - return repeatedForeignEnum_[index]; - } - - public const int RepeatedImportEnumFieldNumber = 53; - private pbc::PopsicleList repeatedImportEnum_ = new pbc::PopsicleList(); - public scg::IList RepeatedImportEnumList { - get { return pbc::Lists.AsReadOnly(repeatedImportEnum_); } - } - public int RepeatedImportEnumCount { - get { return repeatedImportEnum_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.ImportEnum GetRepeatedImportEnum(int index) { - return repeatedImportEnum_[index]; - } - - public const int RepeatedStringPieceFieldNumber = 54; - private pbc::PopsicleList repeatedStringPiece_ = new pbc::PopsicleList(); - public scg::IList RepeatedStringPieceList { - get { return pbc::Lists.AsReadOnly(repeatedStringPiece_); } - } - public int RepeatedStringPieceCount { - get { return repeatedStringPiece_.Count; } - } - public string GetRepeatedStringPiece(int index) { - return repeatedStringPiece_[index]; - } - - public const int RepeatedCordFieldNumber = 55; - private pbc::PopsicleList repeatedCord_ = new pbc::PopsicleList(); - public scg::IList RepeatedCordList { - get { return pbc::Lists.AsReadOnly(repeatedCord_); } - } - public int RepeatedCordCount { - get { return repeatedCord_.Count; } - } - public string GetRepeatedCord(int index) { - return repeatedCord_[index]; - } - - public const int RepeatedLazyMessageFieldNumber = 57; - private pbc::PopsicleList repeatedLazyMessage_ = new pbc::PopsicleList(); - public scg::IList RepeatedLazyMessageList { - get { return repeatedLazyMessage_; } - } - public int RepeatedLazyMessageCount { - get { return repeatedLazyMessage_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage GetRepeatedLazyMessage(int index) { - return repeatedLazyMessage_[index]; - } - - public const int DefaultInt32FieldNumber = 61; - private bool hasDefaultInt32; - private int defaultInt32_ = 41; - public bool HasDefaultInt32 { - get { return hasDefaultInt32; } - } - public int DefaultInt32 { - get { return defaultInt32_; } - } - - public const int DefaultInt64FieldNumber = 62; - private bool hasDefaultInt64; - private long defaultInt64_ = 42L; - public bool HasDefaultInt64 { - get { return hasDefaultInt64; } - } - public long DefaultInt64 { - get { return defaultInt64_; } - } - - public const int DefaultUint32FieldNumber = 63; - private bool hasDefaultUint32; - private uint defaultUint32_ = 43; - public bool HasDefaultUint32 { - get { return hasDefaultUint32; } - } - public uint DefaultUint32 { - get { return defaultUint32_; } - } - - public const int DefaultUint64FieldNumber = 64; - private bool hasDefaultUint64; - private ulong defaultUint64_ = 44UL; - public bool HasDefaultUint64 { - get { return hasDefaultUint64; } - } - public ulong DefaultUint64 { - get { return defaultUint64_; } - } - - public const int DefaultSint32FieldNumber = 65; - private bool hasDefaultSint32; - private int defaultSint32_ = -45; - public bool HasDefaultSint32 { - get { return hasDefaultSint32; } - } - public int DefaultSint32 { - get { return defaultSint32_; } - } - - public const int DefaultSint64FieldNumber = 66; - private bool hasDefaultSint64; - private long defaultSint64_ = 46L; - public bool HasDefaultSint64 { - get { return hasDefaultSint64; } - } - public long DefaultSint64 { - get { return defaultSint64_; } - } - - public const int DefaultFixed32FieldNumber = 67; - private bool hasDefaultFixed32; - private uint defaultFixed32_ = 47; - public bool HasDefaultFixed32 { - get { return hasDefaultFixed32; } - } - public uint DefaultFixed32 { - get { return defaultFixed32_; } - } - - public const int DefaultFixed64FieldNumber = 68; - private bool hasDefaultFixed64; - private ulong defaultFixed64_ = 48UL; - public bool HasDefaultFixed64 { - get { return hasDefaultFixed64; } - } - public ulong DefaultFixed64 { - get { return defaultFixed64_; } - } - - public const int DefaultSfixed32FieldNumber = 69; - private bool hasDefaultSfixed32; - private int defaultSfixed32_ = 49; - public bool HasDefaultSfixed32 { - get { return hasDefaultSfixed32; } - } - public int DefaultSfixed32 { - get { return defaultSfixed32_; } - } - - public const int DefaultSfixed64FieldNumber = 70; - private bool hasDefaultSfixed64; - private long defaultSfixed64_ = -50L; - public bool HasDefaultSfixed64 { - get { return hasDefaultSfixed64; } - } - public long DefaultSfixed64 { - get { return defaultSfixed64_; } - } - - public const int DefaultFloatFieldNumber = 71; - private bool hasDefaultFloat; - private float defaultFloat_ = 51.5F; - public bool HasDefaultFloat { - get { return hasDefaultFloat; } - } - public float DefaultFloat { - get { return defaultFloat_; } - } - - public const int DefaultDoubleFieldNumber = 72; - private bool hasDefaultDouble; - private double defaultDouble_ = 52000D; - public bool HasDefaultDouble { - get { return hasDefaultDouble; } - } - public double DefaultDouble { - get { return defaultDouble_; } - } - - public const int DefaultBoolFieldNumber = 73; - private bool hasDefaultBool; - private bool defaultBool_ = true; - public bool HasDefaultBool { - get { return hasDefaultBool; } - } - public bool DefaultBool { - get { return defaultBool_; } - } - - public const int DefaultStringFieldNumber = 74; - private bool hasDefaultString; - private string defaultString_ = "hello"; - public bool HasDefaultString { - get { return hasDefaultString; } - } - public string DefaultString { - get { return defaultString_; } - } - - public const int DefaultBytesFieldNumber = 75; - private bool hasDefaultBytes; - private pb::ByteString defaultBytes_ = (pb::ByteString) global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Descriptor.Fields[65].DefaultValue; - public bool HasDefaultBytes { - get { return hasDefaultBytes; } - } - public pb::ByteString DefaultBytes { - get { return defaultBytes_; } - } - - public const int DefaultNestedEnumFieldNumber = 81; - private bool hasDefaultNestedEnum; - private global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedEnum defaultNestedEnum_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedEnum.BAR; - public bool HasDefaultNestedEnum { - get { return hasDefaultNestedEnum; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedEnum DefaultNestedEnum { - get { return defaultNestedEnum_; } - } - - public const int DefaultForeignEnumFieldNumber = 82; - private bool hasDefaultForeignEnum; - private global::Google.ProtocolBuffers.TestProtos.ForeignEnum defaultForeignEnum_ = global::Google.ProtocolBuffers.TestProtos.ForeignEnum.FOREIGN_BAR; - public bool HasDefaultForeignEnum { - get { return hasDefaultForeignEnum; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignEnum DefaultForeignEnum { - get { return defaultForeignEnum_; } - } - - public const int DefaultImportEnumFieldNumber = 83; - private bool hasDefaultImportEnum; - private global::Google.ProtocolBuffers.TestProtos.ImportEnum defaultImportEnum_ = global::Google.ProtocolBuffers.TestProtos.ImportEnum.IMPORT_BAR; - public bool HasDefaultImportEnum { - get { return hasDefaultImportEnum; } - } - public global::Google.ProtocolBuffers.TestProtos.ImportEnum DefaultImportEnum { - get { return defaultImportEnum_; } - } - - public const int DefaultStringPieceFieldNumber = 84; - private bool hasDefaultStringPiece; - private string defaultStringPiece_ = "abc"; - public bool HasDefaultStringPiece { - get { return hasDefaultStringPiece; } - } - public string DefaultStringPiece { - get { return defaultStringPiece_; } - } - - public const int DefaultCordFieldNumber = 85; - private bool hasDefaultCord; - private string defaultCord_ = "123"; - public bool HasDefaultCord { - get { return hasDefaultCord; } - } - public string DefaultCord { - get { return defaultCord_; } - } - - public const int OneofUint32FieldNumber = 111; - public bool HasOneofUint32 { - get { return oneofFieldCase_ == OneofFieldOneofCase.OneofUint32; } - } - public uint OneofUint32 { - get { return oneofFieldCase_ == OneofFieldOneofCase.OneofUint32 ? (uint) oneofField_ : 0; } - } - - public const int OneofNestedMessageFieldNumber = 112; - public bool HasOneofNestedMessage { - get { return oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage OneofNestedMessage { - get { return oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage ? (global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage) oneofField_ : global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.DefaultInstance; } - } - - public const int OneofStringFieldNumber = 113; - public bool HasOneofString { - get { return oneofFieldCase_ == OneofFieldOneofCase.OneofString; } - } - public string OneofString { - get { return oneofFieldCase_ == OneofFieldOneofCase.OneofString ? (string) oneofField_ : ""; } - } - - public const int OneofBytesFieldNumber = 114; - public bool HasOneofBytes { - get { return oneofFieldCase_ == OneofFieldOneofCase.OneofBytes; } - } - public pb::ByteString OneofBytes { - get { return oneofFieldCase_ == OneofFieldOneofCase.OneofBytes ? (pb::ByteString) oneofField_ : pb::ByteString.Empty; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testAllTypesFieldNames; - if (hasOptionalInt32) { - output.WriteInt32(1, field_names[35], OptionalInt32); - } - if (hasOptionalInt64) { - output.WriteInt64(2, field_names[36], OptionalInt64); - } - if (hasOptionalUint32) { - output.WriteUInt32(3, field_names[47], OptionalUint32); - } - if (hasOptionalUint64) { - output.WriteUInt64(4, field_names[48], OptionalUint64); - } - if (hasOptionalSint32) { - output.WriteSInt32(5, field_names[43], OptionalSint32); - } - if (hasOptionalSint64) { - output.WriteSInt64(6, field_names[44], OptionalSint64); - } - if (hasOptionalFixed32) { - output.WriteFixed32(7, field_names[28], OptionalFixed32); - } - if (hasOptionalFixed64) { - output.WriteFixed64(8, field_names[29], OptionalFixed64); - } - if (hasOptionalSfixed32) { - output.WriteSFixed32(9, field_names[41], OptionalSfixed32); - } - if (hasOptionalSfixed64) { - output.WriteSFixed64(10, field_names[42], OptionalSfixed64); - } - if (hasOptionalFloat) { - output.WriteFloat(11, field_names[30], OptionalFloat); - } - if (hasOptionalDouble) { - output.WriteDouble(12, field_names[27], OptionalDouble); - } - if (hasOptionalBool) { - output.WriteBool(13, field_names[24], OptionalBool); - } - if (hasOptionalString) { - output.WriteString(14, field_names[45], OptionalString); - } - if (hasOptionalBytes) { - output.WriteBytes(15, field_names[25], OptionalBytes); - } - if (hasOptionalGroup) { - output.WriteGroup(16, field_names[49], OptionalGroup); - } - if (hasOptionalNestedMessage) { - output.WriteMessage(18, field_names[39], OptionalNestedMessage); - } - if (hasOptionalForeignMessage) { - output.WriteMessage(19, field_names[32], OptionalForeignMessage); - } - if (hasOptionalImportMessage) { - output.WriteMessage(20, field_names[34], OptionalImportMessage); - } - if (hasOptionalNestedEnum) { - output.WriteEnum(21, field_names[38], (int) OptionalNestedEnum, OptionalNestedEnum); - } - if (hasOptionalForeignEnum) { - output.WriteEnum(22, field_names[31], (int) OptionalForeignEnum, OptionalForeignEnum); - } - if (hasOptionalImportEnum) { - output.WriteEnum(23, field_names[33], (int) OptionalImportEnum, OptionalImportEnum); - } - if (hasOptionalStringPiece) { - output.WriteString(24, field_names[46], OptionalStringPiece); - } - if (hasOptionalCord) { - output.WriteString(25, field_names[26], OptionalCord); - } - if (hasOptionalPublicImportMessage) { - output.WriteMessage(26, field_names[40], OptionalPublicImportMessage); - } - if (hasOptionalLazyMessage) { - output.WriteMessage(27, field_names[37], OptionalLazyMessage); - } - if (repeatedInt32_.Count > 0) { - output.WriteInt32Array(31, field_names[61], repeatedInt32_); - } - if (repeatedInt64_.Count > 0) { - output.WriteInt64Array(32, field_names[62], repeatedInt64_); - } - if (repeatedUint32_.Count > 0) { - output.WriteUInt32Array(33, field_names[72], repeatedUint32_); - } - if (repeatedUint64_.Count > 0) { - output.WriteUInt64Array(34, field_names[73], repeatedUint64_); - } - if (repeatedSint32_.Count > 0) { - output.WriteSInt32Array(35, field_names[68], repeatedSint32_); - } - if (repeatedSint64_.Count > 0) { - output.WriteSInt64Array(36, field_names[69], repeatedSint64_); - } - if (repeatedFixed32_.Count > 0) { - output.WriteFixed32Array(37, field_names[54], repeatedFixed32_); - } - if (repeatedFixed64_.Count > 0) { - output.WriteFixed64Array(38, field_names[55], repeatedFixed64_); - } - if (repeatedSfixed32_.Count > 0) { - output.WriteSFixed32Array(39, field_names[66], repeatedSfixed32_); - } - if (repeatedSfixed64_.Count > 0) { - output.WriteSFixed64Array(40, field_names[67], repeatedSfixed64_); - } - if (repeatedFloat_.Count > 0) { - output.WriteFloatArray(41, field_names[56], repeatedFloat_); - } - if (repeatedDouble_.Count > 0) { - output.WriteDoubleArray(42, field_names[53], repeatedDouble_); - } - if (repeatedBool_.Count > 0) { - output.WriteBoolArray(43, field_names[50], repeatedBool_); - } - if (repeatedString_.Count > 0) { - output.WriteStringArray(44, field_names[70], repeatedString_); - } - if (repeatedBytes_.Count > 0) { - output.WriteBytesArray(45, field_names[51], repeatedBytes_); - } - if (repeatedGroup_.Count > 0) { - output.WriteGroupArray(46, field_names[74], repeatedGroup_); - } - if (repeatedNestedMessage_.Count > 0) { - output.WriteMessageArray(48, field_names[65], repeatedNestedMessage_); - } - if (repeatedForeignMessage_.Count > 0) { - output.WriteMessageArray(49, field_names[58], repeatedForeignMessage_); - } - if (repeatedImportMessage_.Count > 0) { - output.WriteMessageArray(50, field_names[60], repeatedImportMessage_); - } - if (repeatedNestedEnum_.Count > 0) { - output.WriteEnumArray(51, field_names[64], repeatedNestedEnum_); - } - if (repeatedForeignEnum_.Count > 0) { - output.WriteEnumArray(52, field_names[57], repeatedForeignEnum_); - } - if (repeatedImportEnum_.Count > 0) { - output.WriteEnumArray(53, field_names[59], repeatedImportEnum_); - } - if (repeatedStringPiece_.Count > 0) { - output.WriteStringArray(54, field_names[71], repeatedStringPiece_); - } - if (repeatedCord_.Count > 0) { - output.WriteStringArray(55, field_names[52], repeatedCord_); - } - if (repeatedLazyMessage_.Count > 0) { - output.WriteMessageArray(57, field_names[63], repeatedLazyMessage_); - } - if (hasDefaultInt32) { - output.WriteInt32(61, field_names[9], DefaultInt32); - } - if (hasDefaultInt64) { - output.WriteInt64(62, field_names[10], DefaultInt64); - } - if (hasDefaultUint32) { - output.WriteUInt32(63, field_names[18], DefaultUint32); - } - if (hasDefaultUint64) { - output.WriteUInt64(64, field_names[19], DefaultUint64); - } - if (hasDefaultSint32) { - output.WriteSInt32(65, field_names[14], DefaultSint32); - } - if (hasDefaultSint64) { - output.WriteSInt64(66, field_names[15], DefaultSint64); - } - if (hasDefaultFixed32) { - output.WriteFixed32(67, field_names[4], DefaultFixed32); - } - if (hasDefaultFixed64) { - output.WriteFixed64(68, field_names[5], DefaultFixed64); - } - if (hasDefaultSfixed32) { - output.WriteSFixed32(69, field_names[12], DefaultSfixed32); - } - if (hasDefaultSfixed64) { - output.WriteSFixed64(70, field_names[13], DefaultSfixed64); - } - if (hasDefaultFloat) { - output.WriteFloat(71, field_names[6], DefaultFloat); - } - if (hasDefaultDouble) { - output.WriteDouble(72, field_names[3], DefaultDouble); - } - if (hasDefaultBool) { - output.WriteBool(73, field_names[0], DefaultBool); - } - if (hasDefaultString) { - output.WriteString(74, field_names[16], DefaultString); - } - if (hasDefaultBytes) { - output.WriteBytes(75, field_names[1], DefaultBytes); - } - if (hasDefaultNestedEnum) { - output.WriteEnum(81, field_names[11], (int) DefaultNestedEnum, DefaultNestedEnum); - } - if (hasDefaultForeignEnum) { - output.WriteEnum(82, field_names[7], (int) DefaultForeignEnum, DefaultForeignEnum); - } - if (hasDefaultImportEnum) { - output.WriteEnum(83, field_names[8], (int) DefaultImportEnum, DefaultImportEnum); - } - if (hasDefaultStringPiece) { - output.WriteString(84, field_names[17], DefaultStringPiece); - } - if (hasDefaultCord) { - output.WriteString(85, field_names[2], DefaultCord); - } - if (oneofFieldCase_ == OneofFieldOneofCase.OneofUint32) { - output.WriteUInt32(111, field_names[23], OneofUint32); - } - if (oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage) { - output.WriteMessage(112, field_names[21], OneofNestedMessage); - } - if (oneofFieldCase_ == OneofFieldOneofCase.OneofString) { - output.WriteString(113, field_names[22], OneofString); - } - if (oneofFieldCase_ == OneofFieldOneofCase.OneofBytes) { - output.WriteBytes(114, field_names[20], OneofBytes); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasOptionalInt32) { - size += pb::CodedOutputStream.ComputeInt32Size(1, OptionalInt32); - } - if (hasOptionalInt64) { - size += pb::CodedOutputStream.ComputeInt64Size(2, OptionalInt64); - } - if (hasOptionalUint32) { - size += pb::CodedOutputStream.ComputeUInt32Size(3, OptionalUint32); - } - if (hasOptionalUint64) { - size += pb::CodedOutputStream.ComputeUInt64Size(4, OptionalUint64); - } - if (hasOptionalSint32) { - size += pb::CodedOutputStream.ComputeSInt32Size(5, OptionalSint32); - } - if (hasOptionalSint64) { - size += pb::CodedOutputStream.ComputeSInt64Size(6, OptionalSint64); - } - if (hasOptionalFixed32) { - size += pb::CodedOutputStream.ComputeFixed32Size(7, OptionalFixed32); - } - if (hasOptionalFixed64) { - size += pb::CodedOutputStream.ComputeFixed64Size(8, OptionalFixed64); - } - if (hasOptionalSfixed32) { - size += pb::CodedOutputStream.ComputeSFixed32Size(9, OptionalSfixed32); - } - if (hasOptionalSfixed64) { - size += pb::CodedOutputStream.ComputeSFixed64Size(10, OptionalSfixed64); - } - if (hasOptionalFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(11, OptionalFloat); - } - if (hasOptionalDouble) { - size += pb::CodedOutputStream.ComputeDoubleSize(12, OptionalDouble); - } - if (hasOptionalBool) { - size += pb::CodedOutputStream.ComputeBoolSize(13, OptionalBool); - } - if (hasOptionalString) { - size += pb::CodedOutputStream.ComputeStringSize(14, OptionalString); - } - if (hasOptionalBytes) { - size += pb::CodedOutputStream.ComputeBytesSize(15, OptionalBytes); - } - if (hasOptionalGroup) { - size += pb::CodedOutputStream.ComputeGroupSize(16, OptionalGroup); - } - if (hasOptionalNestedMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(18, OptionalNestedMessage); - } - if (hasOptionalForeignMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(19, OptionalForeignMessage); - } - if (hasOptionalImportMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(20, OptionalImportMessage); - } - if (hasOptionalNestedEnum) { - size += pb::CodedOutputStream.ComputeEnumSize(21, (int) OptionalNestedEnum); - } - if (hasOptionalForeignEnum) { - size += pb::CodedOutputStream.ComputeEnumSize(22, (int) OptionalForeignEnum); - } - if (hasOptionalImportEnum) { - size += pb::CodedOutputStream.ComputeEnumSize(23, (int) OptionalImportEnum); - } - if (hasOptionalStringPiece) { - size += pb::CodedOutputStream.ComputeStringSize(24, OptionalStringPiece); - } - if (hasOptionalCord) { - size += pb::CodedOutputStream.ComputeStringSize(25, OptionalCord); - } - if (hasOptionalPublicImportMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(26, OptionalPublicImportMessage); - } - if (hasOptionalLazyMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(27, OptionalLazyMessage); - } - { - int dataSize = 0; - foreach (int element in RepeatedInt32List) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedInt32_.Count; - } - { - int dataSize = 0; - foreach (long element in RepeatedInt64List) { - dataSize += pb::CodedOutputStream.ComputeInt64SizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedInt64_.Count; - } - { - int dataSize = 0; - foreach (uint element in RepeatedUint32List) { - dataSize += pb::CodedOutputStream.ComputeUInt32SizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedUint32_.Count; - } - { - int dataSize = 0; - foreach (ulong element in RepeatedUint64List) { - dataSize += pb::CodedOutputStream.ComputeUInt64SizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedUint64_.Count; - } - { - int dataSize = 0; - foreach (int element in RepeatedSint32List) { - dataSize += pb::CodedOutputStream.ComputeSInt32SizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedSint32_.Count; - } - { - int dataSize = 0; - foreach (long element in RepeatedSint64List) { - dataSize += pb::CodedOutputStream.ComputeSInt64SizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedSint64_.Count; - } - { - int dataSize = 0; - dataSize = 4 * repeatedFixed32_.Count; - size += dataSize; - size += 2 * repeatedFixed32_.Count; - } - { - int dataSize = 0; - dataSize = 8 * repeatedFixed64_.Count; - size += dataSize; - size += 2 * repeatedFixed64_.Count; - } - { - int dataSize = 0; - dataSize = 4 * repeatedSfixed32_.Count; - size += dataSize; - size += 2 * repeatedSfixed32_.Count; - } - { - int dataSize = 0; - dataSize = 8 * repeatedSfixed64_.Count; - size += dataSize; - size += 2 * repeatedSfixed64_.Count; - } - { - int dataSize = 0; - dataSize = 4 * repeatedFloat_.Count; - size += dataSize; - size += 2 * repeatedFloat_.Count; - } - { - int dataSize = 0; - dataSize = 8 * repeatedDouble_.Count; - size += dataSize; - size += 2 * repeatedDouble_.Count; - } - { - int dataSize = 0; - dataSize = 1 * repeatedBool_.Count; - size += dataSize; - size += 2 * repeatedBool_.Count; - } - { - int dataSize = 0; - foreach (string element in RepeatedStringList) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedString_.Count; - } - { - int dataSize = 0; - foreach (pb::ByteString element in RepeatedBytesList) { - dataSize += pb::CodedOutputStream.ComputeBytesSizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedBytes_.Count; - } - foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup element in RepeatedGroupList) { - size += pb::CodedOutputStream.ComputeGroupSize(46, element); - } - foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage element in RepeatedNestedMessageList) { - size += pb::CodedOutputStream.ComputeMessageSize(48, element); - } - foreach (global::Google.ProtocolBuffers.TestProtos.ForeignMessage element in RepeatedForeignMessageList) { - size += pb::CodedOutputStream.ComputeMessageSize(49, element); - } - foreach (global::Google.ProtocolBuffers.TestProtos.ImportMessage element in RepeatedImportMessageList) { - size += pb::CodedOutputStream.ComputeMessageSize(50, element); - } - { - int dataSize = 0; - if (repeatedNestedEnum_.Count > 0) { - foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedEnum element in repeatedNestedEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 2 * repeatedNestedEnum_.Count; - } - } - { - int dataSize = 0; - if (repeatedForeignEnum_.Count > 0) { - foreach (global::Google.ProtocolBuffers.TestProtos.ForeignEnum element in repeatedForeignEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 2 * repeatedForeignEnum_.Count; - } - } - { - int dataSize = 0; - if (repeatedImportEnum_.Count > 0) { - foreach (global::Google.ProtocolBuffers.TestProtos.ImportEnum element in repeatedImportEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 2 * repeatedImportEnum_.Count; - } - } - { - int dataSize = 0; - foreach (string element in RepeatedStringPieceList) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedStringPiece_.Count; - } - { - int dataSize = 0; - foreach (string element in RepeatedCordList) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedCord_.Count; - } - foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage element in RepeatedLazyMessageList) { - size += pb::CodedOutputStream.ComputeMessageSize(57, element); - } - if (hasDefaultInt32) { - size += pb::CodedOutputStream.ComputeInt32Size(61, DefaultInt32); - } - if (hasDefaultInt64) { - size += pb::CodedOutputStream.ComputeInt64Size(62, DefaultInt64); - } - if (hasDefaultUint32) { - size += pb::CodedOutputStream.ComputeUInt32Size(63, DefaultUint32); - } - if (hasDefaultUint64) { - size += pb::CodedOutputStream.ComputeUInt64Size(64, DefaultUint64); - } - if (hasDefaultSint32) { - size += pb::CodedOutputStream.ComputeSInt32Size(65, DefaultSint32); - } - if (hasDefaultSint64) { - size += pb::CodedOutputStream.ComputeSInt64Size(66, DefaultSint64); - } - if (hasDefaultFixed32) { - size += pb::CodedOutputStream.ComputeFixed32Size(67, DefaultFixed32); - } - if (hasDefaultFixed64) { - size += pb::CodedOutputStream.ComputeFixed64Size(68, DefaultFixed64); - } - if (hasDefaultSfixed32) { - size += pb::CodedOutputStream.ComputeSFixed32Size(69, DefaultSfixed32); - } - if (hasDefaultSfixed64) { - size += pb::CodedOutputStream.ComputeSFixed64Size(70, DefaultSfixed64); - } - if (hasDefaultFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(71, DefaultFloat); - } - if (hasDefaultDouble) { - size += pb::CodedOutputStream.ComputeDoubleSize(72, DefaultDouble); - } - if (hasDefaultBool) { - size += pb::CodedOutputStream.ComputeBoolSize(73, DefaultBool); - } - if (hasDefaultString) { - size += pb::CodedOutputStream.ComputeStringSize(74, DefaultString); - } - if (hasDefaultBytes) { - size += pb::CodedOutputStream.ComputeBytesSize(75, DefaultBytes); - } - if (hasDefaultNestedEnum) { - size += pb::CodedOutputStream.ComputeEnumSize(81, (int) DefaultNestedEnum); - } - if (hasDefaultForeignEnum) { - size += pb::CodedOutputStream.ComputeEnumSize(82, (int) DefaultForeignEnum); - } - if (hasDefaultImportEnum) { - size += pb::CodedOutputStream.ComputeEnumSize(83, (int) DefaultImportEnum); - } - if (hasDefaultStringPiece) { - size += pb::CodedOutputStream.ComputeStringSize(84, DefaultStringPiece); - } - if (hasDefaultCord) { - size += pb::CodedOutputStream.ComputeStringSize(85, DefaultCord); - } - if (oneofFieldCase_ == OneofFieldOneofCase.OneofUint32) { - size += pb::CodedOutputStream.ComputeUInt32Size(111, OneofUint32); - } - if (oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(112, OneofNestedMessage); - } - if (oneofFieldCase_ == OneofFieldOneofCase.OneofString) { - size += pb::CodedOutputStream.ComputeStringSize(113, OneofString); - } - if (oneofFieldCase_ == OneofFieldOneofCase.OneofBytes) { - size += pb::CodedOutputStream.ComputeBytesSize(114, OneofBytes); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestAllTypes ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestAllTypes ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestAllTypes ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestAllTypes ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestAllTypes ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestAllTypes ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestAllTypes ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestAllTypes ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestAllTypes ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestAllTypes ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestAllTypes MakeReadOnly() { - repeatedInt32_.MakeReadOnly(); - repeatedInt64_.MakeReadOnly(); - repeatedUint32_.MakeReadOnly(); - repeatedUint64_.MakeReadOnly(); - repeatedSint32_.MakeReadOnly(); - repeatedSint64_.MakeReadOnly(); - repeatedFixed32_.MakeReadOnly(); - repeatedFixed64_.MakeReadOnly(); - repeatedSfixed32_.MakeReadOnly(); - repeatedSfixed64_.MakeReadOnly(); - repeatedFloat_.MakeReadOnly(); - repeatedDouble_.MakeReadOnly(); - repeatedBool_.MakeReadOnly(); - repeatedString_.MakeReadOnly(); - repeatedBytes_.MakeReadOnly(); - repeatedGroup_.MakeReadOnly(); - repeatedNestedMessage_.MakeReadOnly(); - repeatedForeignMessage_.MakeReadOnly(); - repeatedImportMessage_.MakeReadOnly(); - repeatedNestedEnum_.MakeReadOnly(); - repeatedForeignEnum_.MakeReadOnly(); - repeatedImportEnum_.MakeReadOnly(); - repeatedStringPiece_.MakeReadOnly(); - repeatedCord_.MakeReadOnly(); - repeatedLazyMessage_.MakeReadOnly(); - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestAllTypes prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestAllTypes cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestAllTypes result; - - private TestAllTypes PrepareBuilder() { - if (resultIsReadOnly) { - TestAllTypes original = result; - result = new TestAllTypes(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestAllTypes MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Descriptor; } - } - - public override TestAllTypes DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance; } - } - - public override TestAllTypes BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestAllTypes) { - return MergeFrom((TestAllTypes) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestAllTypes other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasOptionalInt32) { - OptionalInt32 = other.OptionalInt32; - } - if (other.HasOptionalInt64) { - OptionalInt64 = other.OptionalInt64; - } - if (other.HasOptionalUint32) { - OptionalUint32 = other.OptionalUint32; - } - if (other.HasOptionalUint64) { - OptionalUint64 = other.OptionalUint64; - } - if (other.HasOptionalSint32) { - OptionalSint32 = other.OptionalSint32; - } - if (other.HasOptionalSint64) { - OptionalSint64 = other.OptionalSint64; - } - if (other.HasOptionalFixed32) { - OptionalFixed32 = other.OptionalFixed32; - } - if (other.HasOptionalFixed64) { - OptionalFixed64 = other.OptionalFixed64; - } - if (other.HasOptionalSfixed32) { - OptionalSfixed32 = other.OptionalSfixed32; - } - if (other.HasOptionalSfixed64) { - OptionalSfixed64 = other.OptionalSfixed64; - } - if (other.HasOptionalFloat) { - OptionalFloat = other.OptionalFloat; - } - if (other.HasOptionalDouble) { - OptionalDouble = other.OptionalDouble; - } - if (other.HasOptionalBool) { - OptionalBool = other.OptionalBool; - } - if (other.HasOptionalString) { - OptionalString = other.OptionalString; - } - if (other.HasOptionalBytes) { - OptionalBytes = other.OptionalBytes; - } - if (other.HasOptionalGroup) { - MergeOptionalGroup(other.OptionalGroup); - } - if (other.HasOptionalNestedMessage) { - MergeOptionalNestedMessage(other.OptionalNestedMessage); - } - if (other.HasOptionalForeignMessage) { - MergeOptionalForeignMessage(other.OptionalForeignMessage); - } - if (other.HasOptionalImportMessage) { - MergeOptionalImportMessage(other.OptionalImportMessage); - } - if (other.HasOptionalNestedEnum) { - OptionalNestedEnum = other.OptionalNestedEnum; - } - if (other.HasOptionalForeignEnum) { - OptionalForeignEnum = other.OptionalForeignEnum; - } - if (other.HasOptionalImportEnum) { - OptionalImportEnum = other.OptionalImportEnum; - } - if (other.HasOptionalStringPiece) { - OptionalStringPiece = other.OptionalStringPiece; - } - if (other.HasOptionalCord) { - OptionalCord = other.OptionalCord; - } - if (other.HasOptionalPublicImportMessage) { - MergeOptionalPublicImportMessage(other.OptionalPublicImportMessage); - } - if (other.HasOptionalLazyMessage) { - MergeOptionalLazyMessage(other.OptionalLazyMessage); - } - if (other.repeatedInt32_.Count != 0) { - result.repeatedInt32_.Add(other.repeatedInt32_); - } - if (other.repeatedInt64_.Count != 0) { - result.repeatedInt64_.Add(other.repeatedInt64_); - } - if (other.repeatedUint32_.Count != 0) { - result.repeatedUint32_.Add(other.repeatedUint32_); - } - if (other.repeatedUint64_.Count != 0) { - result.repeatedUint64_.Add(other.repeatedUint64_); - } - if (other.repeatedSint32_.Count != 0) { - result.repeatedSint32_.Add(other.repeatedSint32_); - } - if (other.repeatedSint64_.Count != 0) { - result.repeatedSint64_.Add(other.repeatedSint64_); - } - if (other.repeatedFixed32_.Count != 0) { - result.repeatedFixed32_.Add(other.repeatedFixed32_); - } - if (other.repeatedFixed64_.Count != 0) { - result.repeatedFixed64_.Add(other.repeatedFixed64_); - } - if (other.repeatedSfixed32_.Count != 0) { - result.repeatedSfixed32_.Add(other.repeatedSfixed32_); - } - if (other.repeatedSfixed64_.Count != 0) { - result.repeatedSfixed64_.Add(other.repeatedSfixed64_); - } - if (other.repeatedFloat_.Count != 0) { - result.repeatedFloat_.Add(other.repeatedFloat_); - } - if (other.repeatedDouble_.Count != 0) { - result.repeatedDouble_.Add(other.repeatedDouble_); - } - if (other.repeatedBool_.Count != 0) { - result.repeatedBool_.Add(other.repeatedBool_); - } - if (other.repeatedString_.Count != 0) { - result.repeatedString_.Add(other.repeatedString_); - } - if (other.repeatedBytes_.Count != 0) { - result.repeatedBytes_.Add(other.repeatedBytes_); - } - if (other.repeatedGroup_.Count != 0) { - result.repeatedGroup_.Add(other.repeatedGroup_); - } - if (other.repeatedNestedMessage_.Count != 0) { - result.repeatedNestedMessage_.Add(other.repeatedNestedMessage_); - } - if (other.repeatedForeignMessage_.Count != 0) { - result.repeatedForeignMessage_.Add(other.repeatedForeignMessage_); - } - if (other.repeatedImportMessage_.Count != 0) { - result.repeatedImportMessage_.Add(other.repeatedImportMessage_); - } - if (other.repeatedNestedEnum_.Count != 0) { - result.repeatedNestedEnum_.Add(other.repeatedNestedEnum_); - } - if (other.repeatedForeignEnum_.Count != 0) { - result.repeatedForeignEnum_.Add(other.repeatedForeignEnum_); - } - if (other.repeatedImportEnum_.Count != 0) { - result.repeatedImportEnum_.Add(other.repeatedImportEnum_); - } - if (other.repeatedStringPiece_.Count != 0) { - result.repeatedStringPiece_.Add(other.repeatedStringPiece_); - } - if (other.repeatedCord_.Count != 0) { - result.repeatedCord_.Add(other.repeatedCord_); - } - if (other.repeatedLazyMessage_.Count != 0) { - result.repeatedLazyMessage_.Add(other.repeatedLazyMessage_); - } - if (other.HasDefaultInt32) { - DefaultInt32 = other.DefaultInt32; - } - if (other.HasDefaultInt64) { - DefaultInt64 = other.DefaultInt64; - } - if (other.HasDefaultUint32) { - DefaultUint32 = other.DefaultUint32; - } - if (other.HasDefaultUint64) { - DefaultUint64 = other.DefaultUint64; - } - if (other.HasDefaultSint32) { - DefaultSint32 = other.DefaultSint32; - } - if (other.HasDefaultSint64) { - DefaultSint64 = other.DefaultSint64; - } - if (other.HasDefaultFixed32) { - DefaultFixed32 = other.DefaultFixed32; - } - if (other.HasDefaultFixed64) { - DefaultFixed64 = other.DefaultFixed64; - } - if (other.HasDefaultSfixed32) { - DefaultSfixed32 = other.DefaultSfixed32; - } - if (other.HasDefaultSfixed64) { - DefaultSfixed64 = other.DefaultSfixed64; - } - if (other.HasDefaultFloat) { - DefaultFloat = other.DefaultFloat; - } - if (other.HasDefaultDouble) { - DefaultDouble = other.DefaultDouble; - } - if (other.HasDefaultBool) { - DefaultBool = other.DefaultBool; - } - if (other.HasDefaultString) { - DefaultString = other.DefaultString; - } - if (other.HasDefaultBytes) { - DefaultBytes = other.DefaultBytes; - } - if (other.HasDefaultNestedEnum) { - DefaultNestedEnum = other.DefaultNestedEnum; - } - if (other.HasDefaultForeignEnum) { - DefaultForeignEnum = other.DefaultForeignEnum; - } - if (other.HasDefaultImportEnum) { - DefaultImportEnum = other.DefaultImportEnum; - } - if (other.HasDefaultStringPiece) { - DefaultStringPiece = other.DefaultStringPiece; - } - if (other.HasDefaultCord) { - DefaultCord = other.DefaultCord; - } - switch (other.OneofFieldCase) { - case OneofFieldOneofCase.OneofUint32: { - SetOneofUint32(other.OneofUint32); - break; - } - case OneofFieldOneofCase.OneofNestedMessage: { - MergeOneofNestedMessage(other.OneofNestedMessage); - break; - } - case OneofFieldOneofCase.OneofString: { - SetOneofString(other.OneofString); - break; - } - case OneofFieldOneofCase.OneofBytes: { - SetOneofBytes(other.OneofBytes); - break; - } - case OneofFieldOneofCase.None: { break; } - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testAllTypesFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testAllTypesFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasOptionalInt32 = input.ReadInt32(ref result.optionalInt32_); - break; - } - case 16: { - result.hasOptionalInt64 = input.ReadInt64(ref result.optionalInt64_); - break; - } - case 24: { - result.hasOptionalUint32 = input.ReadUInt32(ref result.optionalUint32_); - break; - } - case 32: { - result.hasOptionalUint64 = input.ReadUInt64(ref result.optionalUint64_); - break; - } - case 40: { - result.hasOptionalSint32 = input.ReadSInt32(ref result.optionalSint32_); - break; - } - case 48: { - result.hasOptionalSint64 = input.ReadSInt64(ref result.optionalSint64_); - break; - } - case 61: { - result.hasOptionalFixed32 = input.ReadFixed32(ref result.optionalFixed32_); - break; - } - case 65: { - result.hasOptionalFixed64 = input.ReadFixed64(ref result.optionalFixed64_); - break; - } - case 77: { - result.hasOptionalSfixed32 = input.ReadSFixed32(ref result.optionalSfixed32_); - break; - } - case 81: { - result.hasOptionalSfixed64 = input.ReadSFixed64(ref result.optionalSfixed64_); - break; - } - case 93: { - result.hasOptionalFloat = input.ReadFloat(ref result.optionalFloat_); - break; - } - case 97: { - result.hasOptionalDouble = input.ReadDouble(ref result.optionalDouble_); - break; - } - case 104: { - result.hasOptionalBool = input.ReadBool(ref result.optionalBool_); - break; - } - case 114: { - result.hasOptionalString = input.ReadString(ref result.optionalString_); - break; - } - case 122: { - result.hasOptionalBytes = input.ReadBytes(ref result.optionalBytes_); - break; - } - case 131: { - global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.OptionalGroup.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.OptionalGroup.CreateBuilder(); - if (result.hasOptionalGroup) { - subBuilder.MergeFrom(OptionalGroup); - } - input.ReadGroup(16, subBuilder, extensionRegistry); - OptionalGroup = subBuilder.BuildPartial(); - break; - } - case 146: { - global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.CreateBuilder(); - if (result.hasOptionalNestedMessage) { - subBuilder.MergeFrom(OptionalNestedMessage); - } - input.ReadMessage(subBuilder, extensionRegistry); - OptionalNestedMessage = subBuilder.BuildPartial(); - break; - } - case 154: { - global::Google.ProtocolBuffers.TestProtos.ForeignMessage.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.ForeignMessage.CreateBuilder(); - if (result.hasOptionalForeignMessage) { - subBuilder.MergeFrom(OptionalForeignMessage); - } - input.ReadMessage(subBuilder, extensionRegistry); - OptionalForeignMessage = subBuilder.BuildPartial(); - break; - } - case 162: { - global::Google.ProtocolBuffers.TestProtos.ImportMessage.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.ImportMessage.CreateBuilder(); - if (result.hasOptionalImportMessage) { - subBuilder.MergeFrom(OptionalImportMessage); - } - input.ReadMessage(subBuilder, extensionRegistry); - OptionalImportMessage = subBuilder.BuildPartial(); - break; - } - case 168: { - object unknown; - if(input.ReadEnum(ref result.optionalNestedEnum_, out unknown)) { - result.hasOptionalNestedEnum = true; - } else if(unknown is int) { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - unknownFields.MergeVarintField(21, (ulong)(int)unknown); - } - break; - } - case 176: { - object unknown; - if(input.ReadEnum(ref result.optionalForeignEnum_, out unknown)) { - result.hasOptionalForeignEnum = true; - } else if(unknown is int) { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - unknownFields.MergeVarintField(22, (ulong)(int)unknown); - } - break; - } - case 184: { - object unknown; - if(input.ReadEnum(ref result.optionalImportEnum_, out unknown)) { - result.hasOptionalImportEnum = true; - } else if(unknown is int) { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - unknownFields.MergeVarintField(23, (ulong)(int)unknown); - } - break; - } - case 194: { - result.hasOptionalStringPiece = input.ReadString(ref result.optionalStringPiece_); - break; - } - case 202: { - result.hasOptionalCord = input.ReadString(ref result.optionalCord_); - break; - } - case 210: { - global::Google.ProtocolBuffers.TestProtos.PublicImportMessage.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.PublicImportMessage.CreateBuilder(); - if (result.hasOptionalPublicImportMessage) { - subBuilder.MergeFrom(OptionalPublicImportMessage); - } - input.ReadMessage(subBuilder, extensionRegistry); - OptionalPublicImportMessage = subBuilder.BuildPartial(); - break; - } - case 218: { - global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.CreateBuilder(); - if (result.hasOptionalLazyMessage) { - subBuilder.MergeFrom(OptionalLazyMessage); - } - input.ReadMessage(subBuilder, extensionRegistry); - OptionalLazyMessage = subBuilder.BuildPartial(); - break; - } - case 250: - case 248: { - input.ReadInt32Array(tag, field_name, result.repeatedInt32_); - break; - } - case 258: - case 256: { - input.ReadInt64Array(tag, field_name, result.repeatedInt64_); - break; - } - case 266: - case 264: { - input.ReadUInt32Array(tag, field_name, result.repeatedUint32_); - break; - } - case 274: - case 272: { - input.ReadUInt64Array(tag, field_name, result.repeatedUint64_); - break; - } - case 282: - case 280: { - input.ReadSInt32Array(tag, field_name, result.repeatedSint32_); - break; - } - case 290: - case 288: { - input.ReadSInt64Array(tag, field_name, result.repeatedSint64_); - break; - } - case 298: - case 301: { - input.ReadFixed32Array(tag, field_name, result.repeatedFixed32_); - break; - } - case 306: - case 305: { - input.ReadFixed64Array(tag, field_name, result.repeatedFixed64_); - break; - } - case 314: - case 317: { - input.ReadSFixed32Array(tag, field_name, result.repeatedSfixed32_); - break; - } - case 322: - case 321: { - input.ReadSFixed64Array(tag, field_name, result.repeatedSfixed64_); - break; - } - case 330: - case 333: { - input.ReadFloatArray(tag, field_name, result.repeatedFloat_); - break; - } - case 338: - case 337: { - input.ReadDoubleArray(tag, field_name, result.repeatedDouble_); - break; - } - case 346: - case 344: { - input.ReadBoolArray(tag, field_name, result.repeatedBool_); - break; - } - case 354: { - input.ReadStringArray(tag, field_name, result.repeatedString_); - break; - } - case 362: { - input.ReadBytesArray(tag, field_name, result.repeatedBytes_); - break; - } - case 371: { - input.ReadGroupArray(tag, field_name, result.repeatedGroup_, global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup.DefaultInstance, extensionRegistry); - break; - } - case 386: { - input.ReadMessageArray(tag, field_name, result.repeatedNestedMessage_, global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.DefaultInstance, extensionRegistry); - break; - } - case 394: { - input.ReadMessageArray(tag, field_name, result.repeatedForeignMessage_, global::Google.ProtocolBuffers.TestProtos.ForeignMessage.DefaultInstance, extensionRegistry); - break; - } - case 402: { - input.ReadMessageArray(tag, field_name, result.repeatedImportMessage_, global::Google.ProtocolBuffers.TestProtos.ImportMessage.DefaultInstance, extensionRegistry); - break; - } - case 410: - case 408: { - scg::ICollection unknownItems; - input.ReadEnumArray(tag, field_name, result.repeatedNestedEnum_, out unknownItems); - if (unknownItems != null) { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - foreach (object rawValue in unknownItems) - if (rawValue is int) - unknownFields.MergeVarintField(51, (ulong)(int)rawValue); - } - break; - } - case 418: - case 416: { - scg::ICollection unknownItems; - input.ReadEnumArray(tag, field_name, result.repeatedForeignEnum_, out unknownItems); - if (unknownItems != null) { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - foreach (object rawValue in unknownItems) - if (rawValue is int) - unknownFields.MergeVarintField(52, (ulong)(int)rawValue); - } - break; - } - case 426: - case 424: { - scg::ICollection unknownItems; - input.ReadEnumArray(tag, field_name, result.repeatedImportEnum_, out unknownItems); - if (unknownItems != null) { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - foreach (object rawValue in unknownItems) - if (rawValue is int) - unknownFields.MergeVarintField(53, (ulong)(int)rawValue); - } - break; - } - case 434: { - input.ReadStringArray(tag, field_name, result.repeatedStringPiece_); - break; - } - case 442: { - input.ReadStringArray(tag, field_name, result.repeatedCord_); - break; - } - case 458: { - input.ReadMessageArray(tag, field_name, result.repeatedLazyMessage_, global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.DefaultInstance, extensionRegistry); - break; - } - case 488: { - result.hasDefaultInt32 = input.ReadInt32(ref result.defaultInt32_); - break; - } - case 496: { - result.hasDefaultInt64 = input.ReadInt64(ref result.defaultInt64_); - break; - } - case 504: { - result.hasDefaultUint32 = input.ReadUInt32(ref result.defaultUint32_); - break; - } - case 512: { - result.hasDefaultUint64 = input.ReadUInt64(ref result.defaultUint64_); - break; - } - case 520: { - result.hasDefaultSint32 = input.ReadSInt32(ref result.defaultSint32_); - break; - } - case 528: { - result.hasDefaultSint64 = input.ReadSInt64(ref result.defaultSint64_); - break; - } - case 541: { - result.hasDefaultFixed32 = input.ReadFixed32(ref result.defaultFixed32_); - break; - } - case 545: { - result.hasDefaultFixed64 = input.ReadFixed64(ref result.defaultFixed64_); - break; - } - case 557: { - result.hasDefaultSfixed32 = input.ReadSFixed32(ref result.defaultSfixed32_); - break; - } - case 561: { - result.hasDefaultSfixed64 = input.ReadSFixed64(ref result.defaultSfixed64_); - break; - } - case 573: { - result.hasDefaultFloat = input.ReadFloat(ref result.defaultFloat_); - break; - } - case 577: { - result.hasDefaultDouble = input.ReadDouble(ref result.defaultDouble_); - break; - } - case 584: { - result.hasDefaultBool = input.ReadBool(ref result.defaultBool_); - break; - } - case 594: { - result.hasDefaultString = input.ReadString(ref result.defaultString_); - break; - } - case 602: { - result.hasDefaultBytes = input.ReadBytes(ref result.defaultBytes_); - break; - } - case 648: { - object unknown; - if(input.ReadEnum(ref result.defaultNestedEnum_, out unknown)) { - result.hasDefaultNestedEnum = true; - } else if(unknown is int) { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - unknownFields.MergeVarintField(81, (ulong)(int)unknown); - } - break; - } - case 656: { - object unknown; - if(input.ReadEnum(ref result.defaultForeignEnum_, out unknown)) { - result.hasDefaultForeignEnum = true; - } else if(unknown is int) { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - unknownFields.MergeVarintField(82, (ulong)(int)unknown); - } - break; - } - case 664: { - object unknown; - if(input.ReadEnum(ref result.defaultImportEnum_, out unknown)) { - result.hasDefaultImportEnum = true; - } else if(unknown is int) { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - unknownFields.MergeVarintField(83, (ulong)(int)unknown); - } - break; - } - case 674: { - result.hasDefaultStringPiece = input.ReadString(ref result.defaultStringPiece_); - break; - } - case 682: { - result.hasDefaultCord = input.ReadString(ref result.defaultCord_); - break; - } - case 888: { - uint value = 0; - if (input.ReadUInt32(ref value)) { - result.oneofField_ = value; - result.oneofFieldCase_ = OneofFieldOneofCase.OneofUint32; - } - break; - } - case 898: { - global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.CreateBuilder(); - if (result.oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage) { - subBuilder.MergeFrom(OneofNestedMessage); - } - input.ReadMessage(subBuilder, extensionRegistry); - result.oneofField_ = subBuilder.BuildPartial(); - result.oneofFieldCase_ = OneofFieldOneofCase.OneofNestedMessage; - break; - } - case 906: { - string value = ""; - if (input.ReadString(ref value)) { - result.oneofField_ = value; - result.oneofFieldCase_ = OneofFieldOneofCase.OneofString; - } - break; - } - case 914: { - pb::ByteString value = pb::ByteString.Empty; - if (input.ReadBytes(ref value)) { - result.oneofField_ = value; - result.oneofFieldCase_ = OneofFieldOneofCase.OneofBytes; - } - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasOptionalInt32 { - get { return result.hasOptionalInt32; } - } - public int OptionalInt32 { - get { return result.OptionalInt32; } - set { SetOptionalInt32(value); } - } - public Builder SetOptionalInt32(int value) { - PrepareBuilder(); - result.hasOptionalInt32 = true; - result.optionalInt32_ = value; - return this; - } - public Builder ClearOptionalInt32() { - PrepareBuilder(); - result.hasOptionalInt32 = false; - result.optionalInt32_ = 0; - return this; - } - - public bool HasOptionalInt64 { - get { return result.hasOptionalInt64; } - } - public long OptionalInt64 { - get { return result.OptionalInt64; } - set { SetOptionalInt64(value); } - } - public Builder SetOptionalInt64(long value) { - PrepareBuilder(); - result.hasOptionalInt64 = true; - result.optionalInt64_ = value; - return this; - } - public Builder ClearOptionalInt64() { - PrepareBuilder(); - result.hasOptionalInt64 = false; - result.optionalInt64_ = 0L; - return this; - } - - public bool HasOptionalUint32 { - get { return result.hasOptionalUint32; } - } - public uint OptionalUint32 { - get { return result.OptionalUint32; } - set { SetOptionalUint32(value); } - } - public Builder SetOptionalUint32(uint value) { - PrepareBuilder(); - result.hasOptionalUint32 = true; - result.optionalUint32_ = value; - return this; - } - public Builder ClearOptionalUint32() { - PrepareBuilder(); - result.hasOptionalUint32 = false; - result.optionalUint32_ = 0; - return this; - } - - public bool HasOptionalUint64 { - get { return result.hasOptionalUint64; } - } - public ulong OptionalUint64 { - get { return result.OptionalUint64; } - set { SetOptionalUint64(value); } - } - public Builder SetOptionalUint64(ulong value) { - PrepareBuilder(); - result.hasOptionalUint64 = true; - result.optionalUint64_ = value; - return this; - } - public Builder ClearOptionalUint64() { - PrepareBuilder(); - result.hasOptionalUint64 = false; - result.optionalUint64_ = 0UL; - return this; - } - - public bool HasOptionalSint32 { - get { return result.hasOptionalSint32; } - } - public int OptionalSint32 { - get { return result.OptionalSint32; } - set { SetOptionalSint32(value); } - } - public Builder SetOptionalSint32(int value) { - PrepareBuilder(); - result.hasOptionalSint32 = true; - result.optionalSint32_ = value; - return this; - } - public Builder ClearOptionalSint32() { - PrepareBuilder(); - result.hasOptionalSint32 = false; - result.optionalSint32_ = 0; - return this; - } - - public bool HasOptionalSint64 { - get { return result.hasOptionalSint64; } - } - public long OptionalSint64 { - get { return result.OptionalSint64; } - set { SetOptionalSint64(value); } - } - public Builder SetOptionalSint64(long value) { - PrepareBuilder(); - result.hasOptionalSint64 = true; - result.optionalSint64_ = value; - return this; - } - public Builder ClearOptionalSint64() { - PrepareBuilder(); - result.hasOptionalSint64 = false; - result.optionalSint64_ = 0L; - return this; - } - - public bool HasOptionalFixed32 { - get { return result.hasOptionalFixed32; } - } - public uint OptionalFixed32 { - get { return result.OptionalFixed32; } - set { SetOptionalFixed32(value); } - } - public Builder SetOptionalFixed32(uint value) { - PrepareBuilder(); - result.hasOptionalFixed32 = true; - result.optionalFixed32_ = value; - return this; - } - public Builder ClearOptionalFixed32() { - PrepareBuilder(); - result.hasOptionalFixed32 = false; - result.optionalFixed32_ = 0; - return this; - } - - public bool HasOptionalFixed64 { - get { return result.hasOptionalFixed64; } - } - public ulong OptionalFixed64 { - get { return result.OptionalFixed64; } - set { SetOptionalFixed64(value); } - } - public Builder SetOptionalFixed64(ulong value) { - PrepareBuilder(); - result.hasOptionalFixed64 = true; - result.optionalFixed64_ = value; - return this; - } - public Builder ClearOptionalFixed64() { - PrepareBuilder(); - result.hasOptionalFixed64 = false; - result.optionalFixed64_ = 0UL; - return this; - } - - public bool HasOptionalSfixed32 { - get { return result.hasOptionalSfixed32; } - } - public int OptionalSfixed32 { - get { return result.OptionalSfixed32; } - set { SetOptionalSfixed32(value); } - } - public Builder SetOptionalSfixed32(int value) { - PrepareBuilder(); - result.hasOptionalSfixed32 = true; - result.optionalSfixed32_ = value; - return this; - } - public Builder ClearOptionalSfixed32() { - PrepareBuilder(); - result.hasOptionalSfixed32 = false; - result.optionalSfixed32_ = 0; - return this; - } - - public bool HasOptionalSfixed64 { - get { return result.hasOptionalSfixed64; } - } - public long OptionalSfixed64 { - get { return result.OptionalSfixed64; } - set { SetOptionalSfixed64(value); } - } - public Builder SetOptionalSfixed64(long value) { - PrepareBuilder(); - result.hasOptionalSfixed64 = true; - result.optionalSfixed64_ = value; - return this; - } - public Builder ClearOptionalSfixed64() { - PrepareBuilder(); - result.hasOptionalSfixed64 = false; - result.optionalSfixed64_ = 0L; - return this; - } - - public bool HasOptionalFloat { - get { return result.hasOptionalFloat; } - } - public float OptionalFloat { - get { return result.OptionalFloat; } - set { SetOptionalFloat(value); } - } - public Builder SetOptionalFloat(float value) { - PrepareBuilder(); - result.hasOptionalFloat = true; - result.optionalFloat_ = value; - return this; - } - public Builder ClearOptionalFloat() { - PrepareBuilder(); - result.hasOptionalFloat = false; - result.optionalFloat_ = 0F; - return this; - } - - public bool HasOptionalDouble { - get { return result.hasOptionalDouble; } - } - public double OptionalDouble { - get { return result.OptionalDouble; } - set { SetOptionalDouble(value); } - } - public Builder SetOptionalDouble(double value) { - PrepareBuilder(); - result.hasOptionalDouble = true; - result.optionalDouble_ = value; - return this; - } - public Builder ClearOptionalDouble() { - PrepareBuilder(); - result.hasOptionalDouble = false; - result.optionalDouble_ = 0D; - return this; - } - - public bool HasOptionalBool { - get { return result.hasOptionalBool; } - } - public bool OptionalBool { - get { return result.OptionalBool; } - set { SetOptionalBool(value); } - } - public Builder SetOptionalBool(bool value) { - PrepareBuilder(); - result.hasOptionalBool = true; - result.optionalBool_ = value; - return this; - } - public Builder ClearOptionalBool() { - PrepareBuilder(); - result.hasOptionalBool = false; - result.optionalBool_ = false; - return this; - } - - public bool HasOptionalString { - get { return result.hasOptionalString; } - } - public string OptionalString { - get { return result.OptionalString; } - set { SetOptionalString(value); } - } - public Builder SetOptionalString(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOptionalString = true; - result.optionalString_ = value; - return this; - } - public Builder ClearOptionalString() { - PrepareBuilder(); - result.hasOptionalString = false; - result.optionalString_ = ""; - return this; - } - - public bool HasOptionalBytes { - get { return result.hasOptionalBytes; } - } - public pb::ByteString OptionalBytes { - get { return result.OptionalBytes; } - set { SetOptionalBytes(value); } - } - public Builder SetOptionalBytes(pb::ByteString value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOptionalBytes = true; - result.optionalBytes_ = value; - return this; - } - public Builder ClearOptionalBytes() { - PrepareBuilder(); - result.hasOptionalBytes = false; - result.optionalBytes_ = pb::ByteString.Empty; - return this; - } - - public bool HasOptionalGroup { - get { return result.hasOptionalGroup; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.OptionalGroup OptionalGroup { - get { return result.OptionalGroup; } - set { SetOptionalGroup(value); } - } - public Builder SetOptionalGroup(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.OptionalGroup value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOptionalGroup = true; - result.optionalGroup_ = value; - return this; - } - public Builder SetOptionalGroup(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.OptionalGroup.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasOptionalGroup = true; - result.optionalGroup_ = builderForValue.Build(); - return this; - } - public Builder MergeOptionalGroup(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.OptionalGroup value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasOptionalGroup && - result.optionalGroup_ != global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.OptionalGroup.DefaultInstance) { - result.optionalGroup_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.OptionalGroup.CreateBuilder(result.optionalGroup_).MergeFrom(value).BuildPartial(); - } else { - result.optionalGroup_ = value; - } - result.hasOptionalGroup = true; - return this; - } - public Builder ClearOptionalGroup() { - PrepareBuilder(); - result.hasOptionalGroup = false; - result.optionalGroup_ = null; - return this; - } - - public bool HasOptionalNestedMessage { - get { return result.hasOptionalNestedMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage OptionalNestedMessage { - get { return result.OptionalNestedMessage; } - set { SetOptionalNestedMessage(value); } - } - public Builder SetOptionalNestedMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOptionalNestedMessage = true; - result.optionalNestedMessage_ = value; - return this; - } - public Builder SetOptionalNestedMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasOptionalNestedMessage = true; - result.optionalNestedMessage_ = builderForValue.Build(); - return this; - } - public Builder MergeOptionalNestedMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasOptionalNestedMessage && - result.optionalNestedMessage_ != global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.DefaultInstance) { - result.optionalNestedMessage_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.CreateBuilder(result.optionalNestedMessage_).MergeFrom(value).BuildPartial(); - } else { - result.optionalNestedMessage_ = value; - } - result.hasOptionalNestedMessage = true; - return this; - } - public Builder ClearOptionalNestedMessage() { - PrepareBuilder(); - result.hasOptionalNestedMessage = false; - result.optionalNestedMessage_ = null; - return this; - } - - public bool HasOptionalForeignMessage { - get { return result.hasOptionalForeignMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignMessage OptionalForeignMessage { - get { return result.OptionalForeignMessage; } - set { SetOptionalForeignMessage(value); } - } - public Builder SetOptionalForeignMessage(global::Google.ProtocolBuffers.TestProtos.ForeignMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOptionalForeignMessage = true; - result.optionalForeignMessage_ = value; - return this; - } - public Builder SetOptionalForeignMessage(global::Google.ProtocolBuffers.TestProtos.ForeignMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasOptionalForeignMessage = true; - result.optionalForeignMessage_ = builderForValue.Build(); - return this; - } - public Builder MergeOptionalForeignMessage(global::Google.ProtocolBuffers.TestProtos.ForeignMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasOptionalForeignMessage && - result.optionalForeignMessage_ != global::Google.ProtocolBuffers.TestProtos.ForeignMessage.DefaultInstance) { - result.optionalForeignMessage_ = global::Google.ProtocolBuffers.TestProtos.ForeignMessage.CreateBuilder(result.optionalForeignMessage_).MergeFrom(value).BuildPartial(); - } else { - result.optionalForeignMessage_ = value; - } - result.hasOptionalForeignMessage = true; - return this; - } - public Builder ClearOptionalForeignMessage() { - PrepareBuilder(); - result.hasOptionalForeignMessage = false; - result.optionalForeignMessage_ = null; - return this; - } - - public bool HasOptionalImportMessage { - get { return result.hasOptionalImportMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.ImportMessage OptionalImportMessage { - get { return result.OptionalImportMessage; } - set { SetOptionalImportMessage(value); } - } - public Builder SetOptionalImportMessage(global::Google.ProtocolBuffers.TestProtos.ImportMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOptionalImportMessage = true; - result.optionalImportMessage_ = value; - return this; - } - public Builder SetOptionalImportMessage(global::Google.ProtocolBuffers.TestProtos.ImportMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasOptionalImportMessage = true; - result.optionalImportMessage_ = builderForValue.Build(); - return this; - } - public Builder MergeOptionalImportMessage(global::Google.ProtocolBuffers.TestProtos.ImportMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasOptionalImportMessage && - result.optionalImportMessage_ != global::Google.ProtocolBuffers.TestProtos.ImportMessage.DefaultInstance) { - result.optionalImportMessage_ = global::Google.ProtocolBuffers.TestProtos.ImportMessage.CreateBuilder(result.optionalImportMessage_).MergeFrom(value).BuildPartial(); - } else { - result.optionalImportMessage_ = value; - } - result.hasOptionalImportMessage = true; - return this; - } - public Builder ClearOptionalImportMessage() { - PrepareBuilder(); - result.hasOptionalImportMessage = false; - result.optionalImportMessage_ = null; - return this; - } - - public bool HasOptionalNestedEnum { - get { return result.hasOptionalNestedEnum; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedEnum OptionalNestedEnum { - get { return result.OptionalNestedEnum; } - set { SetOptionalNestedEnum(value); } - } - public Builder SetOptionalNestedEnum(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedEnum value) { - PrepareBuilder(); - result.hasOptionalNestedEnum = true; - result.optionalNestedEnum_ = value; - return this; - } - public Builder ClearOptionalNestedEnum() { - PrepareBuilder(); - result.hasOptionalNestedEnum = false; - result.optionalNestedEnum_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedEnum.FOO; - return this; - } - - public bool HasOptionalForeignEnum { - get { return result.hasOptionalForeignEnum; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignEnum OptionalForeignEnum { - get { return result.OptionalForeignEnum; } - set { SetOptionalForeignEnum(value); } - } - public Builder SetOptionalForeignEnum(global::Google.ProtocolBuffers.TestProtos.ForeignEnum value) { - PrepareBuilder(); - result.hasOptionalForeignEnum = true; - result.optionalForeignEnum_ = value; - return this; - } - public Builder ClearOptionalForeignEnum() { - PrepareBuilder(); - result.hasOptionalForeignEnum = false; - result.optionalForeignEnum_ = global::Google.ProtocolBuffers.TestProtos.ForeignEnum.FOREIGN_FOO; - return this; - } - - public bool HasOptionalImportEnum { - get { return result.hasOptionalImportEnum; } - } - public global::Google.ProtocolBuffers.TestProtos.ImportEnum OptionalImportEnum { - get { return result.OptionalImportEnum; } - set { SetOptionalImportEnum(value); } - } - public Builder SetOptionalImportEnum(global::Google.ProtocolBuffers.TestProtos.ImportEnum value) { - PrepareBuilder(); - result.hasOptionalImportEnum = true; - result.optionalImportEnum_ = value; - return this; - } - public Builder ClearOptionalImportEnum() { - PrepareBuilder(); - result.hasOptionalImportEnum = false; - result.optionalImportEnum_ = global::Google.ProtocolBuffers.TestProtos.ImportEnum.IMPORT_FOO; - return this; - } - - public bool HasOptionalStringPiece { - get { return result.hasOptionalStringPiece; } - } - public string OptionalStringPiece { - get { return result.OptionalStringPiece; } - set { SetOptionalStringPiece(value); } - } - public Builder SetOptionalStringPiece(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOptionalStringPiece = true; - result.optionalStringPiece_ = value; - return this; - } - public Builder ClearOptionalStringPiece() { - PrepareBuilder(); - result.hasOptionalStringPiece = false; - result.optionalStringPiece_ = ""; - return this; - } - - public bool HasOptionalCord { - get { return result.hasOptionalCord; } - } - public string OptionalCord { - get { return result.OptionalCord; } - set { SetOptionalCord(value); } - } - public Builder SetOptionalCord(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOptionalCord = true; - result.optionalCord_ = value; - return this; - } - public Builder ClearOptionalCord() { - PrepareBuilder(); - result.hasOptionalCord = false; - result.optionalCord_ = ""; - return this; - } - - public bool HasOptionalPublicImportMessage { - get { return result.hasOptionalPublicImportMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.PublicImportMessage OptionalPublicImportMessage { - get { return result.OptionalPublicImportMessage; } - set { SetOptionalPublicImportMessage(value); } - } - public Builder SetOptionalPublicImportMessage(global::Google.ProtocolBuffers.TestProtos.PublicImportMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOptionalPublicImportMessage = true; - result.optionalPublicImportMessage_ = value; - return this; - } - public Builder SetOptionalPublicImportMessage(global::Google.ProtocolBuffers.TestProtos.PublicImportMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasOptionalPublicImportMessage = true; - result.optionalPublicImportMessage_ = builderForValue.Build(); - return this; - } - public Builder MergeOptionalPublicImportMessage(global::Google.ProtocolBuffers.TestProtos.PublicImportMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasOptionalPublicImportMessage && - result.optionalPublicImportMessage_ != global::Google.ProtocolBuffers.TestProtos.PublicImportMessage.DefaultInstance) { - result.optionalPublicImportMessage_ = global::Google.ProtocolBuffers.TestProtos.PublicImportMessage.CreateBuilder(result.optionalPublicImportMessage_).MergeFrom(value).BuildPartial(); - } else { - result.optionalPublicImportMessage_ = value; - } - result.hasOptionalPublicImportMessage = true; - return this; - } - public Builder ClearOptionalPublicImportMessage() { - PrepareBuilder(); - result.hasOptionalPublicImportMessage = false; - result.optionalPublicImportMessage_ = null; - return this; - } - - public bool HasOptionalLazyMessage { - get { return result.hasOptionalLazyMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage OptionalLazyMessage { - get { return result.OptionalLazyMessage; } - set { SetOptionalLazyMessage(value); } - } - public Builder SetOptionalLazyMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOptionalLazyMessage = true; - result.optionalLazyMessage_ = value; - return this; - } - public Builder SetOptionalLazyMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasOptionalLazyMessage = true; - result.optionalLazyMessage_ = builderForValue.Build(); - return this; - } - public Builder MergeOptionalLazyMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasOptionalLazyMessage && - result.optionalLazyMessage_ != global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.DefaultInstance) { - result.optionalLazyMessage_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.CreateBuilder(result.optionalLazyMessage_).MergeFrom(value).BuildPartial(); - } else { - result.optionalLazyMessage_ = value; - } - result.hasOptionalLazyMessage = true; - return this; - } - public Builder ClearOptionalLazyMessage() { - PrepareBuilder(); - result.hasOptionalLazyMessage = false; - result.optionalLazyMessage_ = null; - return this; - } - - public pbc::IPopsicleList RepeatedInt32List { - get { return PrepareBuilder().repeatedInt32_; } - } - public int RepeatedInt32Count { - get { return result.RepeatedInt32Count; } - } - public int GetRepeatedInt32(int index) { - return result.GetRepeatedInt32(index); - } - public Builder SetRepeatedInt32(int index, int value) { - PrepareBuilder(); - result.repeatedInt32_[index] = value; - return this; - } - public Builder AddRepeatedInt32(int value) { - PrepareBuilder(); - result.repeatedInt32_.Add(value); - return this; - } - public Builder AddRangeRepeatedInt32(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedInt32_.Add(values); - return this; - } - public Builder ClearRepeatedInt32() { - PrepareBuilder(); - result.repeatedInt32_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedInt64List { - get { return PrepareBuilder().repeatedInt64_; } - } - public int RepeatedInt64Count { - get { return result.RepeatedInt64Count; } - } - public long GetRepeatedInt64(int index) { - return result.GetRepeatedInt64(index); - } - public Builder SetRepeatedInt64(int index, long value) { - PrepareBuilder(); - result.repeatedInt64_[index] = value; - return this; - } - public Builder AddRepeatedInt64(long value) { - PrepareBuilder(); - result.repeatedInt64_.Add(value); - return this; - } - public Builder AddRangeRepeatedInt64(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedInt64_.Add(values); - return this; - } - public Builder ClearRepeatedInt64() { - PrepareBuilder(); - result.repeatedInt64_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedUint32List { - get { return PrepareBuilder().repeatedUint32_; } - } - public int RepeatedUint32Count { - get { return result.RepeatedUint32Count; } - } - public uint GetRepeatedUint32(int index) { - return result.GetRepeatedUint32(index); - } - public Builder SetRepeatedUint32(int index, uint value) { - PrepareBuilder(); - result.repeatedUint32_[index] = value; - return this; - } - public Builder AddRepeatedUint32(uint value) { - PrepareBuilder(); - result.repeatedUint32_.Add(value); - return this; - } - public Builder AddRangeRepeatedUint32(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedUint32_.Add(values); - return this; - } - public Builder ClearRepeatedUint32() { - PrepareBuilder(); - result.repeatedUint32_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedUint64List { - get { return PrepareBuilder().repeatedUint64_; } - } - public int RepeatedUint64Count { - get { return result.RepeatedUint64Count; } - } - public ulong GetRepeatedUint64(int index) { - return result.GetRepeatedUint64(index); - } - public Builder SetRepeatedUint64(int index, ulong value) { - PrepareBuilder(); - result.repeatedUint64_[index] = value; - return this; - } - public Builder AddRepeatedUint64(ulong value) { - PrepareBuilder(); - result.repeatedUint64_.Add(value); - return this; - } - public Builder AddRangeRepeatedUint64(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedUint64_.Add(values); - return this; - } - public Builder ClearRepeatedUint64() { - PrepareBuilder(); - result.repeatedUint64_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedSint32List { - get { return PrepareBuilder().repeatedSint32_; } - } - public int RepeatedSint32Count { - get { return result.RepeatedSint32Count; } - } - public int GetRepeatedSint32(int index) { - return result.GetRepeatedSint32(index); - } - public Builder SetRepeatedSint32(int index, int value) { - PrepareBuilder(); - result.repeatedSint32_[index] = value; - return this; - } - public Builder AddRepeatedSint32(int value) { - PrepareBuilder(); - result.repeatedSint32_.Add(value); - return this; - } - public Builder AddRangeRepeatedSint32(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedSint32_.Add(values); - return this; - } - public Builder ClearRepeatedSint32() { - PrepareBuilder(); - result.repeatedSint32_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedSint64List { - get { return PrepareBuilder().repeatedSint64_; } - } - public int RepeatedSint64Count { - get { return result.RepeatedSint64Count; } - } - public long GetRepeatedSint64(int index) { - return result.GetRepeatedSint64(index); - } - public Builder SetRepeatedSint64(int index, long value) { - PrepareBuilder(); - result.repeatedSint64_[index] = value; - return this; - } - public Builder AddRepeatedSint64(long value) { - PrepareBuilder(); - result.repeatedSint64_.Add(value); - return this; - } - public Builder AddRangeRepeatedSint64(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedSint64_.Add(values); - return this; - } - public Builder ClearRepeatedSint64() { - PrepareBuilder(); - result.repeatedSint64_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedFixed32List { - get { return PrepareBuilder().repeatedFixed32_; } - } - public int RepeatedFixed32Count { - get { return result.RepeatedFixed32Count; } - } - public uint GetRepeatedFixed32(int index) { - return result.GetRepeatedFixed32(index); - } - public Builder SetRepeatedFixed32(int index, uint value) { - PrepareBuilder(); - result.repeatedFixed32_[index] = value; - return this; - } - public Builder AddRepeatedFixed32(uint value) { - PrepareBuilder(); - result.repeatedFixed32_.Add(value); - return this; - } - public Builder AddRangeRepeatedFixed32(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedFixed32_.Add(values); - return this; - } - public Builder ClearRepeatedFixed32() { - PrepareBuilder(); - result.repeatedFixed32_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedFixed64List { - get { return PrepareBuilder().repeatedFixed64_; } - } - public int RepeatedFixed64Count { - get { return result.RepeatedFixed64Count; } - } - public ulong GetRepeatedFixed64(int index) { - return result.GetRepeatedFixed64(index); - } - public Builder SetRepeatedFixed64(int index, ulong value) { - PrepareBuilder(); - result.repeatedFixed64_[index] = value; - return this; - } - public Builder AddRepeatedFixed64(ulong value) { - PrepareBuilder(); - result.repeatedFixed64_.Add(value); - return this; - } - public Builder AddRangeRepeatedFixed64(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedFixed64_.Add(values); - return this; - } - public Builder ClearRepeatedFixed64() { - PrepareBuilder(); - result.repeatedFixed64_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedSfixed32List { - get { return PrepareBuilder().repeatedSfixed32_; } - } - public int RepeatedSfixed32Count { - get { return result.RepeatedSfixed32Count; } - } - public int GetRepeatedSfixed32(int index) { - return result.GetRepeatedSfixed32(index); - } - public Builder SetRepeatedSfixed32(int index, int value) { - PrepareBuilder(); - result.repeatedSfixed32_[index] = value; - return this; - } - public Builder AddRepeatedSfixed32(int value) { - PrepareBuilder(); - result.repeatedSfixed32_.Add(value); - return this; - } - public Builder AddRangeRepeatedSfixed32(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedSfixed32_.Add(values); - return this; - } - public Builder ClearRepeatedSfixed32() { - PrepareBuilder(); - result.repeatedSfixed32_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedSfixed64List { - get { return PrepareBuilder().repeatedSfixed64_; } - } - public int RepeatedSfixed64Count { - get { return result.RepeatedSfixed64Count; } - } - public long GetRepeatedSfixed64(int index) { - return result.GetRepeatedSfixed64(index); - } - public Builder SetRepeatedSfixed64(int index, long value) { - PrepareBuilder(); - result.repeatedSfixed64_[index] = value; - return this; - } - public Builder AddRepeatedSfixed64(long value) { - PrepareBuilder(); - result.repeatedSfixed64_.Add(value); - return this; - } - public Builder AddRangeRepeatedSfixed64(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedSfixed64_.Add(values); - return this; - } - public Builder ClearRepeatedSfixed64() { - PrepareBuilder(); - result.repeatedSfixed64_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedFloatList { - get { return PrepareBuilder().repeatedFloat_; } - } - public int RepeatedFloatCount { - get { return result.RepeatedFloatCount; } - } - public float GetRepeatedFloat(int index) { - return result.GetRepeatedFloat(index); - } - public Builder SetRepeatedFloat(int index, float value) { - PrepareBuilder(); - result.repeatedFloat_[index] = value; - return this; - } - public Builder AddRepeatedFloat(float value) { - PrepareBuilder(); - result.repeatedFloat_.Add(value); - return this; - } - public Builder AddRangeRepeatedFloat(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedFloat_.Add(values); - return this; - } - public Builder ClearRepeatedFloat() { - PrepareBuilder(); - result.repeatedFloat_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedDoubleList { - get { return PrepareBuilder().repeatedDouble_; } - } - public int RepeatedDoubleCount { - get { return result.RepeatedDoubleCount; } - } - public double GetRepeatedDouble(int index) { - return result.GetRepeatedDouble(index); - } - public Builder SetRepeatedDouble(int index, double value) { - PrepareBuilder(); - result.repeatedDouble_[index] = value; - return this; - } - public Builder AddRepeatedDouble(double value) { - PrepareBuilder(); - result.repeatedDouble_.Add(value); - return this; - } - public Builder AddRangeRepeatedDouble(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedDouble_.Add(values); - return this; - } - public Builder ClearRepeatedDouble() { - PrepareBuilder(); - result.repeatedDouble_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedBoolList { - get { return PrepareBuilder().repeatedBool_; } - } - public int RepeatedBoolCount { - get { return result.RepeatedBoolCount; } - } - public bool GetRepeatedBool(int index) { - return result.GetRepeatedBool(index); - } - public Builder SetRepeatedBool(int index, bool value) { - PrepareBuilder(); - result.repeatedBool_[index] = value; - return this; - } - public Builder AddRepeatedBool(bool value) { - PrepareBuilder(); - result.repeatedBool_.Add(value); - return this; - } - public Builder AddRangeRepeatedBool(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedBool_.Add(values); - return this; - } - public Builder ClearRepeatedBool() { - PrepareBuilder(); - result.repeatedBool_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedStringList { - get { return PrepareBuilder().repeatedString_; } - } - public int RepeatedStringCount { - get { return result.RepeatedStringCount; } - } - public string GetRepeatedString(int index) { - return result.GetRepeatedString(index); - } - public Builder SetRepeatedString(int index, string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedString_[index] = value; - return this; - } - public Builder AddRepeatedString(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedString_.Add(value); - return this; - } - public Builder AddRangeRepeatedString(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedString_.Add(values); - return this; - } - public Builder ClearRepeatedString() { - PrepareBuilder(); - result.repeatedString_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedBytesList { - get { return PrepareBuilder().repeatedBytes_; } - } - public int RepeatedBytesCount { - get { return result.RepeatedBytesCount; } - } - public pb::ByteString GetRepeatedBytes(int index) { - return result.GetRepeatedBytes(index); - } - public Builder SetRepeatedBytes(int index, pb::ByteString value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedBytes_[index] = value; - return this; - } - public Builder AddRepeatedBytes(pb::ByteString value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedBytes_.Add(value); - return this; - } - public Builder AddRangeRepeatedBytes(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedBytes_.Add(values); - return this; - } - public Builder ClearRepeatedBytes() { - PrepareBuilder(); - result.repeatedBytes_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedGroupList { - get { return PrepareBuilder().repeatedGroup_; } - } - public int RepeatedGroupCount { - get { return result.RepeatedGroupCount; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup GetRepeatedGroup(int index) { - return result.GetRepeatedGroup(index); - } - public Builder SetRepeatedGroup(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedGroup_[index] = value; - return this; - } - public Builder SetRepeatedGroup(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.repeatedGroup_[index] = builderForValue.Build(); - return this; - } - public Builder AddRepeatedGroup(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedGroup_.Add(value); - return this; - } - public Builder AddRepeatedGroup(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.repeatedGroup_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeRepeatedGroup(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedGroup_.Add(values); - return this; - } - public Builder ClearRepeatedGroup() { - PrepareBuilder(); - result.repeatedGroup_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedNestedMessageList { - get { return PrepareBuilder().repeatedNestedMessage_; } - } - public int RepeatedNestedMessageCount { - get { return result.RepeatedNestedMessageCount; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage GetRepeatedNestedMessage(int index) { - return result.GetRepeatedNestedMessage(index); - } - public Builder SetRepeatedNestedMessage(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedNestedMessage_[index] = value; - return this; - } - public Builder SetRepeatedNestedMessage(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.repeatedNestedMessage_[index] = builderForValue.Build(); - return this; - } - public Builder AddRepeatedNestedMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedNestedMessage_.Add(value); - return this; - } - public Builder AddRepeatedNestedMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.repeatedNestedMessage_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeRepeatedNestedMessage(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedNestedMessage_.Add(values); - return this; - } - public Builder ClearRepeatedNestedMessage() { - PrepareBuilder(); - result.repeatedNestedMessage_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedForeignMessageList { - get { return PrepareBuilder().repeatedForeignMessage_; } - } - public int RepeatedForeignMessageCount { - get { return result.RepeatedForeignMessageCount; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignMessage GetRepeatedForeignMessage(int index) { - return result.GetRepeatedForeignMessage(index); - } - public Builder SetRepeatedForeignMessage(int index, global::Google.ProtocolBuffers.TestProtos.ForeignMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedForeignMessage_[index] = value; - return this; - } - public Builder SetRepeatedForeignMessage(int index, global::Google.ProtocolBuffers.TestProtos.ForeignMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.repeatedForeignMessage_[index] = builderForValue.Build(); - return this; - } - public Builder AddRepeatedForeignMessage(global::Google.ProtocolBuffers.TestProtos.ForeignMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedForeignMessage_.Add(value); - return this; - } - public Builder AddRepeatedForeignMessage(global::Google.ProtocolBuffers.TestProtos.ForeignMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.repeatedForeignMessage_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeRepeatedForeignMessage(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedForeignMessage_.Add(values); - return this; - } - public Builder ClearRepeatedForeignMessage() { - PrepareBuilder(); - result.repeatedForeignMessage_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedImportMessageList { - get { return PrepareBuilder().repeatedImportMessage_; } - } - public int RepeatedImportMessageCount { - get { return result.RepeatedImportMessageCount; } - } - public global::Google.ProtocolBuffers.TestProtos.ImportMessage GetRepeatedImportMessage(int index) { - return result.GetRepeatedImportMessage(index); - } - public Builder SetRepeatedImportMessage(int index, global::Google.ProtocolBuffers.TestProtos.ImportMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedImportMessage_[index] = value; - return this; - } - public Builder SetRepeatedImportMessage(int index, global::Google.ProtocolBuffers.TestProtos.ImportMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.repeatedImportMessage_[index] = builderForValue.Build(); - return this; - } - public Builder AddRepeatedImportMessage(global::Google.ProtocolBuffers.TestProtos.ImportMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedImportMessage_.Add(value); - return this; - } - public Builder AddRepeatedImportMessage(global::Google.ProtocolBuffers.TestProtos.ImportMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.repeatedImportMessage_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeRepeatedImportMessage(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedImportMessage_.Add(values); - return this; - } - public Builder ClearRepeatedImportMessage() { - PrepareBuilder(); - result.repeatedImportMessage_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedNestedEnumList { - get { return PrepareBuilder().repeatedNestedEnum_; } - } - public int RepeatedNestedEnumCount { - get { return result.RepeatedNestedEnumCount; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedEnum GetRepeatedNestedEnum(int index) { - return result.GetRepeatedNestedEnum(index); - } - public Builder SetRepeatedNestedEnum(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedEnum value) { - PrepareBuilder(); - result.repeatedNestedEnum_[index] = value; - return this; - } - public Builder AddRepeatedNestedEnum(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedEnum value) { - PrepareBuilder(); - result.repeatedNestedEnum_.Add(value); - return this; - } - public Builder AddRangeRepeatedNestedEnum(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedNestedEnum_.Add(values); - return this; - } - public Builder ClearRepeatedNestedEnum() { - PrepareBuilder(); - result.repeatedNestedEnum_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedForeignEnumList { - get { return PrepareBuilder().repeatedForeignEnum_; } - } - public int RepeatedForeignEnumCount { - get { return result.RepeatedForeignEnumCount; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignEnum GetRepeatedForeignEnum(int index) { - return result.GetRepeatedForeignEnum(index); - } - public Builder SetRepeatedForeignEnum(int index, global::Google.ProtocolBuffers.TestProtos.ForeignEnum value) { - PrepareBuilder(); - result.repeatedForeignEnum_[index] = value; - return this; - } - public Builder AddRepeatedForeignEnum(global::Google.ProtocolBuffers.TestProtos.ForeignEnum value) { - PrepareBuilder(); - result.repeatedForeignEnum_.Add(value); - return this; - } - public Builder AddRangeRepeatedForeignEnum(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedForeignEnum_.Add(values); - return this; - } - public Builder ClearRepeatedForeignEnum() { - PrepareBuilder(); - result.repeatedForeignEnum_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedImportEnumList { - get { return PrepareBuilder().repeatedImportEnum_; } - } - public int RepeatedImportEnumCount { - get { return result.RepeatedImportEnumCount; } - } - public global::Google.ProtocolBuffers.TestProtos.ImportEnum GetRepeatedImportEnum(int index) { - return result.GetRepeatedImportEnum(index); - } - public Builder SetRepeatedImportEnum(int index, global::Google.ProtocolBuffers.TestProtos.ImportEnum value) { - PrepareBuilder(); - result.repeatedImportEnum_[index] = value; - return this; - } - public Builder AddRepeatedImportEnum(global::Google.ProtocolBuffers.TestProtos.ImportEnum value) { - PrepareBuilder(); - result.repeatedImportEnum_.Add(value); - return this; - } - public Builder AddRangeRepeatedImportEnum(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedImportEnum_.Add(values); - return this; - } - public Builder ClearRepeatedImportEnum() { - PrepareBuilder(); - result.repeatedImportEnum_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedStringPieceList { - get { return PrepareBuilder().repeatedStringPiece_; } - } - public int RepeatedStringPieceCount { - get { return result.RepeatedStringPieceCount; } - } - public string GetRepeatedStringPiece(int index) { - return result.GetRepeatedStringPiece(index); - } - public Builder SetRepeatedStringPiece(int index, string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedStringPiece_[index] = value; - return this; - } - public Builder AddRepeatedStringPiece(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedStringPiece_.Add(value); - return this; - } - public Builder AddRangeRepeatedStringPiece(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedStringPiece_.Add(values); - return this; - } - public Builder ClearRepeatedStringPiece() { - PrepareBuilder(); - result.repeatedStringPiece_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedCordList { - get { return PrepareBuilder().repeatedCord_; } - } - public int RepeatedCordCount { - get { return result.RepeatedCordCount; } - } - public string GetRepeatedCord(int index) { - return result.GetRepeatedCord(index); - } - public Builder SetRepeatedCord(int index, string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedCord_[index] = value; - return this; - } - public Builder AddRepeatedCord(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedCord_.Add(value); - return this; - } - public Builder AddRangeRepeatedCord(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedCord_.Add(values); - return this; - } - public Builder ClearRepeatedCord() { - PrepareBuilder(); - result.repeatedCord_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedLazyMessageList { - get { return PrepareBuilder().repeatedLazyMessage_; } - } - public int RepeatedLazyMessageCount { - get { return result.RepeatedLazyMessageCount; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage GetRepeatedLazyMessage(int index) { - return result.GetRepeatedLazyMessage(index); - } - public Builder SetRepeatedLazyMessage(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedLazyMessage_[index] = value; - return this; - } - public Builder SetRepeatedLazyMessage(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.repeatedLazyMessage_[index] = builderForValue.Build(); - return this; - } - public Builder AddRepeatedLazyMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedLazyMessage_.Add(value); - return this; - } - public Builder AddRepeatedLazyMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.repeatedLazyMessage_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeRepeatedLazyMessage(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedLazyMessage_.Add(values); - return this; - } - public Builder ClearRepeatedLazyMessage() { - PrepareBuilder(); - result.repeatedLazyMessage_.Clear(); - return this; - } - - public bool HasDefaultInt32 { - get { return result.hasDefaultInt32; } - } - public int DefaultInt32 { - get { return result.DefaultInt32; } - set { SetDefaultInt32(value); } - } - public Builder SetDefaultInt32(int value) { - PrepareBuilder(); - result.hasDefaultInt32 = true; - result.defaultInt32_ = value; - return this; - } - public Builder ClearDefaultInt32() { - PrepareBuilder(); - result.hasDefaultInt32 = false; - result.defaultInt32_ = 41; - return this; - } - - public bool HasDefaultInt64 { - get { return result.hasDefaultInt64; } - } - public long DefaultInt64 { - get { return result.DefaultInt64; } - set { SetDefaultInt64(value); } - } - public Builder SetDefaultInt64(long value) { - PrepareBuilder(); - result.hasDefaultInt64 = true; - result.defaultInt64_ = value; - return this; - } - public Builder ClearDefaultInt64() { - PrepareBuilder(); - result.hasDefaultInt64 = false; - result.defaultInt64_ = 42L; - return this; - } - - public bool HasDefaultUint32 { - get { return result.hasDefaultUint32; } - } - public uint DefaultUint32 { - get { return result.DefaultUint32; } - set { SetDefaultUint32(value); } - } - public Builder SetDefaultUint32(uint value) { - PrepareBuilder(); - result.hasDefaultUint32 = true; - result.defaultUint32_ = value; - return this; - } - public Builder ClearDefaultUint32() { - PrepareBuilder(); - result.hasDefaultUint32 = false; - result.defaultUint32_ = 43; - return this; - } - - public bool HasDefaultUint64 { - get { return result.hasDefaultUint64; } - } - public ulong DefaultUint64 { - get { return result.DefaultUint64; } - set { SetDefaultUint64(value); } - } - public Builder SetDefaultUint64(ulong value) { - PrepareBuilder(); - result.hasDefaultUint64 = true; - result.defaultUint64_ = value; - return this; - } - public Builder ClearDefaultUint64() { - PrepareBuilder(); - result.hasDefaultUint64 = false; - result.defaultUint64_ = 44UL; - return this; - } - - public bool HasDefaultSint32 { - get { return result.hasDefaultSint32; } - } - public int DefaultSint32 { - get { return result.DefaultSint32; } - set { SetDefaultSint32(value); } - } - public Builder SetDefaultSint32(int value) { - PrepareBuilder(); - result.hasDefaultSint32 = true; - result.defaultSint32_ = value; - return this; - } - public Builder ClearDefaultSint32() { - PrepareBuilder(); - result.hasDefaultSint32 = false; - result.defaultSint32_ = -45; - return this; - } - - public bool HasDefaultSint64 { - get { return result.hasDefaultSint64; } - } - public long DefaultSint64 { - get { return result.DefaultSint64; } - set { SetDefaultSint64(value); } - } - public Builder SetDefaultSint64(long value) { - PrepareBuilder(); - result.hasDefaultSint64 = true; - result.defaultSint64_ = value; - return this; - } - public Builder ClearDefaultSint64() { - PrepareBuilder(); - result.hasDefaultSint64 = false; - result.defaultSint64_ = 46L; - return this; - } - - public bool HasDefaultFixed32 { - get { return result.hasDefaultFixed32; } - } - public uint DefaultFixed32 { - get { return result.DefaultFixed32; } - set { SetDefaultFixed32(value); } - } - public Builder SetDefaultFixed32(uint value) { - PrepareBuilder(); - result.hasDefaultFixed32 = true; - result.defaultFixed32_ = value; - return this; - } - public Builder ClearDefaultFixed32() { - PrepareBuilder(); - result.hasDefaultFixed32 = false; - result.defaultFixed32_ = 47; - return this; - } - - public bool HasDefaultFixed64 { - get { return result.hasDefaultFixed64; } - } - public ulong DefaultFixed64 { - get { return result.DefaultFixed64; } - set { SetDefaultFixed64(value); } - } - public Builder SetDefaultFixed64(ulong value) { - PrepareBuilder(); - result.hasDefaultFixed64 = true; - result.defaultFixed64_ = value; - return this; - } - public Builder ClearDefaultFixed64() { - PrepareBuilder(); - result.hasDefaultFixed64 = false; - result.defaultFixed64_ = 48UL; - return this; - } - - public bool HasDefaultSfixed32 { - get { return result.hasDefaultSfixed32; } - } - public int DefaultSfixed32 { - get { return result.DefaultSfixed32; } - set { SetDefaultSfixed32(value); } - } - public Builder SetDefaultSfixed32(int value) { - PrepareBuilder(); - result.hasDefaultSfixed32 = true; - result.defaultSfixed32_ = value; - return this; - } - public Builder ClearDefaultSfixed32() { - PrepareBuilder(); - result.hasDefaultSfixed32 = false; - result.defaultSfixed32_ = 49; - return this; - } - - public bool HasDefaultSfixed64 { - get { return result.hasDefaultSfixed64; } - } - public long DefaultSfixed64 { - get { return result.DefaultSfixed64; } - set { SetDefaultSfixed64(value); } - } - public Builder SetDefaultSfixed64(long value) { - PrepareBuilder(); - result.hasDefaultSfixed64 = true; - result.defaultSfixed64_ = value; - return this; - } - public Builder ClearDefaultSfixed64() { - PrepareBuilder(); - result.hasDefaultSfixed64 = false; - result.defaultSfixed64_ = -50L; - return this; - } - - public bool HasDefaultFloat { - get { return result.hasDefaultFloat; } - } - public float DefaultFloat { - get { return result.DefaultFloat; } - set { SetDefaultFloat(value); } - } - public Builder SetDefaultFloat(float value) { - PrepareBuilder(); - result.hasDefaultFloat = true; - result.defaultFloat_ = value; - return this; - } - public Builder ClearDefaultFloat() { - PrepareBuilder(); - result.hasDefaultFloat = false; - result.defaultFloat_ = 51.5F; - return this; - } - - public bool HasDefaultDouble { - get { return result.hasDefaultDouble; } - } - public double DefaultDouble { - get { return result.DefaultDouble; } - set { SetDefaultDouble(value); } - } - public Builder SetDefaultDouble(double value) { - PrepareBuilder(); - result.hasDefaultDouble = true; - result.defaultDouble_ = value; - return this; - } - public Builder ClearDefaultDouble() { - PrepareBuilder(); - result.hasDefaultDouble = false; - result.defaultDouble_ = 52000D; - return this; - } - - public bool HasDefaultBool { - get { return result.hasDefaultBool; } - } - public bool DefaultBool { - get { return result.DefaultBool; } - set { SetDefaultBool(value); } - } - public Builder SetDefaultBool(bool value) { - PrepareBuilder(); - result.hasDefaultBool = true; - result.defaultBool_ = value; - return this; - } - public Builder ClearDefaultBool() { - PrepareBuilder(); - result.hasDefaultBool = false; - result.defaultBool_ = true; - return this; - } - - public bool HasDefaultString { - get { return result.hasDefaultString; } - } - public string DefaultString { - get { return result.DefaultString; } - set { SetDefaultString(value); } - } - public Builder SetDefaultString(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasDefaultString = true; - result.defaultString_ = value; - return this; - } - public Builder ClearDefaultString() { - PrepareBuilder(); - result.hasDefaultString = false; - result.defaultString_ = "hello"; - return this; - } - - public bool HasDefaultBytes { - get { return result.hasDefaultBytes; } - } - public pb::ByteString DefaultBytes { - get { return result.DefaultBytes; } - set { SetDefaultBytes(value); } - } - public Builder SetDefaultBytes(pb::ByteString value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasDefaultBytes = true; - result.defaultBytes_ = value; - return this; - } - public Builder ClearDefaultBytes() { - PrepareBuilder(); - result.hasDefaultBytes = false; - result.defaultBytes_ = (pb::ByteString) global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Descriptor.Fields[65].DefaultValue; - return this; - } - - public bool HasDefaultNestedEnum { - get { return result.hasDefaultNestedEnum; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedEnum DefaultNestedEnum { - get { return result.DefaultNestedEnum; } - set { SetDefaultNestedEnum(value); } - } - public Builder SetDefaultNestedEnum(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedEnum value) { - PrepareBuilder(); - result.hasDefaultNestedEnum = true; - result.defaultNestedEnum_ = value; - return this; - } - public Builder ClearDefaultNestedEnum() { - PrepareBuilder(); - result.hasDefaultNestedEnum = false; - result.defaultNestedEnum_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedEnum.BAR; - return this; - } - - public bool HasDefaultForeignEnum { - get { return result.hasDefaultForeignEnum; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignEnum DefaultForeignEnum { - get { return result.DefaultForeignEnum; } - set { SetDefaultForeignEnum(value); } - } - public Builder SetDefaultForeignEnum(global::Google.ProtocolBuffers.TestProtos.ForeignEnum value) { - PrepareBuilder(); - result.hasDefaultForeignEnum = true; - result.defaultForeignEnum_ = value; - return this; - } - public Builder ClearDefaultForeignEnum() { - PrepareBuilder(); - result.hasDefaultForeignEnum = false; - result.defaultForeignEnum_ = global::Google.ProtocolBuffers.TestProtos.ForeignEnum.FOREIGN_BAR; - return this; - } - - public bool HasDefaultImportEnum { - get { return result.hasDefaultImportEnum; } - } - public global::Google.ProtocolBuffers.TestProtos.ImportEnum DefaultImportEnum { - get { return result.DefaultImportEnum; } - set { SetDefaultImportEnum(value); } - } - public Builder SetDefaultImportEnum(global::Google.ProtocolBuffers.TestProtos.ImportEnum value) { - PrepareBuilder(); - result.hasDefaultImportEnum = true; - result.defaultImportEnum_ = value; - return this; - } - public Builder ClearDefaultImportEnum() { - PrepareBuilder(); - result.hasDefaultImportEnum = false; - result.defaultImportEnum_ = global::Google.ProtocolBuffers.TestProtos.ImportEnum.IMPORT_BAR; - return this; - } - - public bool HasDefaultStringPiece { - get { return result.hasDefaultStringPiece; } - } - public string DefaultStringPiece { - get { return result.DefaultStringPiece; } - set { SetDefaultStringPiece(value); } - } - public Builder SetDefaultStringPiece(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasDefaultStringPiece = true; - result.defaultStringPiece_ = value; - return this; - } - public Builder ClearDefaultStringPiece() { - PrepareBuilder(); - result.hasDefaultStringPiece = false; - result.defaultStringPiece_ = "abc"; - return this; - } - - public bool HasDefaultCord { - get { return result.hasDefaultCord; } - } - public string DefaultCord { - get { return result.DefaultCord; } - set { SetDefaultCord(value); } - } - public Builder SetDefaultCord(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasDefaultCord = true; - result.defaultCord_ = value; - return this; - } - public Builder ClearDefaultCord() { - PrepareBuilder(); - result.hasDefaultCord = false; - result.defaultCord_ = "123"; - return this; - } - - public bool HasOneofUint32 { - get { return result.oneofFieldCase_ == OneofFieldOneofCase.OneofUint32; } - } - public uint OneofUint32 { - get { return result.oneofFieldCase_ == OneofFieldOneofCase.OneofUint32 ? (uint) result.oneofField_ : 0; } - set { SetOneofUint32(value); } - } - public Builder SetOneofUint32(uint value) { - PrepareBuilder(); - result.oneofField_ = value; - result.oneofFieldCase_ = OneofFieldOneofCase.OneofUint32; - return this; - } - public Builder ClearOneofUint32() { - PrepareBuilder(); - if (result.oneofFieldCase_ == OneofFieldOneofCase.OneofUint32) { - result.oneofFieldCase_ = OneofFieldOneofCase.None; - } - return this; - } - - public bool HasOneofNestedMessage { - get { return result.oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage OneofNestedMessage { - get { return result.oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage ? (global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage) result.oneofField_ : global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.DefaultInstance; } - set { SetOneofNestedMessage(value); } - } - public Builder SetOneofNestedMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.oneofFieldCase_ = OneofFieldOneofCase.OneofNestedMessage; - result.oneofField_ = value; - return this; - } - public Builder SetOneofNestedMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.oneofFieldCase_ = OneofFieldOneofCase.OneofNestedMessage; - result.oneofField_ = builderForValue.Build(); - return this; - } - public Builder MergeOneofNestedMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage && - result.OneofNestedMessage != global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.DefaultInstance) { - result.oneofField_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.CreateBuilder(result.OneofNestedMessage).MergeFrom(value).BuildPartial(); - } else { - result.oneofField_ = value; - } - result.oneofFieldCase_ = OneofFieldOneofCase.OneofNestedMessage; - return this; - } - public Builder ClearOneofNestedMessage() { - if (result.oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage) { - PrepareBuilder(); - result.oneofFieldCase_ = OneofFieldOneofCase.None; - result.oneofField_ = null; - } - return this; - } - - public bool HasOneofString { - get { return result.oneofFieldCase_ == OneofFieldOneofCase.OneofString; } - } - public string OneofString { - get { return result.oneofFieldCase_ == OneofFieldOneofCase.OneofString ? (string) result.oneofField_ : ""; } - set { SetOneofString(value); } - } - public Builder SetOneofString(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.oneofField_ = value; - result.oneofFieldCase_ = OneofFieldOneofCase.OneofString; - return this; - } - public Builder ClearOneofString() { - PrepareBuilder(); - if (result.oneofFieldCase_ == OneofFieldOneofCase.OneofString) { - result.oneofFieldCase_ = OneofFieldOneofCase.None; - } - return this; - } - - public bool HasOneofBytes { - get { return result.oneofFieldCase_ == OneofFieldOneofCase.OneofBytes; } - } - public pb::ByteString OneofBytes { - get { return result.oneofFieldCase_ == OneofFieldOneofCase.OneofBytes ? (pb::ByteString) result.oneofField_ : pb::ByteString.Empty; } - set { SetOneofBytes(value); } - } - public Builder SetOneofBytes(pb::ByteString value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.oneofField_ = value; - result.oneofFieldCase_ = OneofFieldOneofCase.OneofBytes; - return this; - } - public Builder ClearOneofBytes() { - PrepareBuilder(); - if (result.oneofFieldCase_ == OneofFieldOneofCase.OneofBytes) { - result.oneofFieldCase_ = OneofFieldOneofCase.None; - } - return this; - } - - public OneofFieldOneofCase OneofFieldCase { - get { return result.oneofFieldCase_; } - } - public Builder ClearOneofField() { - PrepareBuilder(); - result.oneofField_ = null; - result.oneofFieldCase_ = OneofFieldOneofCase.None; - return this; - } - } - static TestAllTypes() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class NestedTestAllTypes : pb::GeneratedMessage { - private NestedTestAllTypes() { } - private static readonly NestedTestAllTypes defaultInstance = new NestedTestAllTypes().MakeReadOnly(); - private static readonly string[] _nestedTestAllTypesFieldNames = new string[] { "child", "payload", "repeated_child" }; - private static readonly uint[] _nestedTestAllTypesFieldTags = new uint[] { 10, 18, 26 }; - public static NestedTestAllTypes DefaultInstance { - get { return defaultInstance; } - } - - public override NestedTestAllTypes DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override NestedTestAllTypes ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_NestedTestAllTypes__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_NestedTestAllTypes__FieldAccessorTable; } - } - - public const int ChildFieldNumber = 1; - private bool hasChild; - private global::Google.ProtocolBuffers.TestProtos.NestedTestAllTypes child_; - public bool HasChild { - get { return hasChild; } - } - public global::Google.ProtocolBuffers.TestProtos.NestedTestAllTypes Child { - get { return child_ ?? global::Google.ProtocolBuffers.TestProtos.NestedTestAllTypes.DefaultInstance; } - } - - public const int PayloadFieldNumber = 2; - private bool hasPayload; - private global::Google.ProtocolBuffers.TestProtos.TestAllTypes payload_; - public bool HasPayload { - get { return hasPayload; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes Payload { - get { return payload_ ?? global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance; } - } - - public const int RepeatedChildFieldNumber = 3; - private pbc::PopsicleList repeatedChild_ = new pbc::PopsicleList(); - public scg::IList RepeatedChildList { - get { return repeatedChild_; } - } - public int RepeatedChildCount { - get { return repeatedChild_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.NestedTestAllTypes GetRepeatedChild(int index) { - return repeatedChild_[index]; - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _nestedTestAllTypesFieldNames; - if (hasChild) { - output.WriteMessage(1, field_names[0], Child); - } - if (hasPayload) { - output.WriteMessage(2, field_names[1], Payload); - } - if (repeatedChild_.Count > 0) { - output.WriteMessageArray(3, field_names[2], repeatedChild_); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasChild) { - size += pb::CodedOutputStream.ComputeMessageSize(1, Child); - } - if (hasPayload) { - size += pb::CodedOutputStream.ComputeMessageSize(2, Payload); - } - foreach (global::Google.ProtocolBuffers.TestProtos.NestedTestAllTypes element in RepeatedChildList) { - size += pb::CodedOutputStream.ComputeMessageSize(3, element); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static NestedTestAllTypes ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static NestedTestAllTypes ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static NestedTestAllTypes ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static NestedTestAllTypes ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static NestedTestAllTypes ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static NestedTestAllTypes ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static NestedTestAllTypes ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static NestedTestAllTypes ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static NestedTestAllTypes ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static NestedTestAllTypes ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private NestedTestAllTypes MakeReadOnly() { - repeatedChild_.MakeReadOnly(); - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(NestedTestAllTypes prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(NestedTestAllTypes cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private NestedTestAllTypes result; - - private NestedTestAllTypes PrepareBuilder() { - if (resultIsReadOnly) { - NestedTestAllTypes original = result; - result = new NestedTestAllTypes(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override NestedTestAllTypes MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.NestedTestAllTypes.Descriptor; } - } - - public override NestedTestAllTypes DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.NestedTestAllTypes.DefaultInstance; } - } - - public override NestedTestAllTypes BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is NestedTestAllTypes) { - return MergeFrom((NestedTestAllTypes) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(NestedTestAllTypes other) { - if (other == global::Google.ProtocolBuffers.TestProtos.NestedTestAllTypes.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasChild) { - MergeChild(other.Child); - } - if (other.HasPayload) { - MergePayload(other.Payload); - } - if (other.repeatedChild_.Count != 0) { - result.repeatedChild_.Add(other.repeatedChild_); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_nestedTestAllTypesFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _nestedTestAllTypesFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 10: { - global::Google.ProtocolBuffers.TestProtos.NestedTestAllTypes.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.NestedTestAllTypes.CreateBuilder(); - if (result.hasChild) { - subBuilder.MergeFrom(Child); - } - input.ReadMessage(subBuilder, extensionRegistry); - Child = subBuilder.BuildPartial(); - break; - } - case 18: { - global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.CreateBuilder(); - if (result.hasPayload) { - subBuilder.MergeFrom(Payload); - } - input.ReadMessage(subBuilder, extensionRegistry); - Payload = subBuilder.BuildPartial(); - break; - } - case 26: { - input.ReadMessageArray(tag, field_name, result.repeatedChild_, global::Google.ProtocolBuffers.TestProtos.NestedTestAllTypes.DefaultInstance, extensionRegistry); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasChild { - get { return result.hasChild; } - } - public global::Google.ProtocolBuffers.TestProtos.NestedTestAllTypes Child { - get { return result.Child; } - set { SetChild(value); } - } - public Builder SetChild(global::Google.ProtocolBuffers.TestProtos.NestedTestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasChild = true; - result.child_ = value; - return this; - } - public Builder SetChild(global::Google.ProtocolBuffers.TestProtos.NestedTestAllTypes.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasChild = true; - result.child_ = builderForValue.Build(); - return this; - } - public Builder MergeChild(global::Google.ProtocolBuffers.TestProtos.NestedTestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasChild && - result.child_ != global::Google.ProtocolBuffers.TestProtos.NestedTestAllTypes.DefaultInstance) { - result.child_ = global::Google.ProtocolBuffers.TestProtos.NestedTestAllTypes.CreateBuilder(result.child_).MergeFrom(value).BuildPartial(); - } else { - result.child_ = value; - } - result.hasChild = true; - return this; - } - public Builder ClearChild() { - PrepareBuilder(); - result.hasChild = false; - result.child_ = null; - return this; - } - - public bool HasPayload { - get { return result.hasPayload; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes Payload { - get { return result.Payload; } - set { SetPayload(value); } - } - public Builder SetPayload(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasPayload = true; - result.payload_ = value; - return this; - } - public Builder SetPayload(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasPayload = true; - result.payload_ = builderForValue.Build(); - return this; - } - public Builder MergePayload(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasPayload && - result.payload_ != global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance) { - result.payload_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.CreateBuilder(result.payload_).MergeFrom(value).BuildPartial(); - } else { - result.payload_ = value; - } - result.hasPayload = true; - return this; - } - public Builder ClearPayload() { - PrepareBuilder(); - result.hasPayload = false; - result.payload_ = null; - return this; - } - - public pbc::IPopsicleList RepeatedChildList { - get { return PrepareBuilder().repeatedChild_; } - } - public int RepeatedChildCount { - get { return result.RepeatedChildCount; } - } - public global::Google.ProtocolBuffers.TestProtos.NestedTestAllTypes GetRepeatedChild(int index) { - return result.GetRepeatedChild(index); - } - public Builder SetRepeatedChild(int index, global::Google.ProtocolBuffers.TestProtos.NestedTestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedChild_[index] = value; - return this; - } - public Builder SetRepeatedChild(int index, global::Google.ProtocolBuffers.TestProtos.NestedTestAllTypes.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.repeatedChild_[index] = builderForValue.Build(); - return this; - } - public Builder AddRepeatedChild(global::Google.ProtocolBuffers.TestProtos.NestedTestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedChild_.Add(value); - return this; - } - public Builder AddRepeatedChild(global::Google.ProtocolBuffers.TestProtos.NestedTestAllTypes.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.repeatedChild_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeRepeatedChild(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedChild_.Add(values); - return this; - } - public Builder ClearRepeatedChild() { - PrepareBuilder(); - result.repeatedChild_.Clear(); - return this; - } - } - static NestedTestAllTypes() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestDeprecatedFields : pb::GeneratedMessage { - private TestDeprecatedFields() { } - private static readonly TestDeprecatedFields defaultInstance = new TestDeprecatedFields().MakeReadOnly(); - private static readonly string[] _testDeprecatedFieldsFieldNames = new string[] { "deprecated_int32" }; - private static readonly uint[] _testDeprecatedFieldsFieldTags = new uint[] { 8 }; - public static TestDeprecatedFields DefaultInstance { - get { return defaultInstance; } - } - - public override TestDeprecatedFields DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestDeprecatedFields ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestDeprecatedFields__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestDeprecatedFields__FieldAccessorTable; } - } - - public const int DeprecatedInt32FieldNumber = 1; - private bool hasDeprecatedInt32; - private int deprecatedInt32_; - [global::System.ObsoleteAttribute()] - public bool HasDeprecatedInt32 { - get { return hasDeprecatedInt32; } - } - [global::System.ObsoleteAttribute()] - public int DeprecatedInt32 { - get { return deprecatedInt32_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testDeprecatedFieldsFieldNames; - if (hasDeprecatedInt32) { - output.WriteInt32(1, field_names[0], DeprecatedInt32); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasDeprecatedInt32) { - size += pb::CodedOutputStream.ComputeInt32Size(1, DeprecatedInt32); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestDeprecatedFields ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestDeprecatedFields ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestDeprecatedFields ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestDeprecatedFields ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestDeprecatedFields ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestDeprecatedFields ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestDeprecatedFields ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestDeprecatedFields ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestDeprecatedFields ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestDeprecatedFields ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestDeprecatedFields MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestDeprecatedFields prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestDeprecatedFields cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestDeprecatedFields result; - - private TestDeprecatedFields PrepareBuilder() { - if (resultIsReadOnly) { - TestDeprecatedFields original = result; - result = new TestDeprecatedFields(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestDeprecatedFields MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestDeprecatedFields.Descriptor; } - } - - public override TestDeprecatedFields DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestDeprecatedFields.DefaultInstance; } - } - - public override TestDeprecatedFields BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestDeprecatedFields) { - return MergeFrom((TestDeprecatedFields) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestDeprecatedFields other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestDeprecatedFields.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasDeprecatedInt32) { - DeprecatedInt32 = other.DeprecatedInt32; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testDeprecatedFieldsFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testDeprecatedFieldsFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasDeprecatedInt32 = input.ReadInt32(ref result.deprecatedInt32_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - [global::System.ObsoleteAttribute()] - public bool HasDeprecatedInt32 { - get { return result.hasDeprecatedInt32; } - } - [global::System.ObsoleteAttribute()] - public int DeprecatedInt32 { - get { return result.DeprecatedInt32; } - set { SetDeprecatedInt32(value); } - } - [global::System.ObsoleteAttribute()] - public Builder SetDeprecatedInt32(int value) { - PrepareBuilder(); - result.hasDeprecatedInt32 = true; - result.deprecatedInt32_ = value; - return this; - } - [global::System.ObsoleteAttribute()] - public Builder ClearDeprecatedInt32() { - PrepareBuilder(); - result.hasDeprecatedInt32 = false; - result.deprecatedInt32_ = 0; - return this; - } - } - static TestDeprecatedFields() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class ForeignMessage : pb::GeneratedMessage { - private ForeignMessage() { } - private static readonly ForeignMessage defaultInstance = new ForeignMessage().MakeReadOnly(); - private static readonly string[] _foreignMessageFieldNames = new string[] { "c" }; - private static readonly uint[] _foreignMessageFieldTags = new uint[] { 8 }; - public static ForeignMessage DefaultInstance { - get { return defaultInstance; } - } - - public override ForeignMessage DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override ForeignMessage ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_ForeignMessage__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_ForeignMessage__FieldAccessorTable; } - } - - public const int CFieldNumber = 1; - private bool hasC; - private int c_; - public bool HasC { - get { return hasC; } - } - public int C { - get { return c_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _foreignMessageFieldNames; - if (hasC) { - output.WriteInt32(1, field_names[0], C); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasC) { - size += pb::CodedOutputStream.ComputeInt32Size(1, C); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static ForeignMessage ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static ForeignMessage ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static ForeignMessage ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static ForeignMessage ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static ForeignMessage ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static ForeignMessage ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static ForeignMessage ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static ForeignMessage ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static ForeignMessage ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static ForeignMessage ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private ForeignMessage MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(ForeignMessage prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(ForeignMessage cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private ForeignMessage result; - - private ForeignMessage PrepareBuilder() { - if (resultIsReadOnly) { - ForeignMessage original = result; - result = new ForeignMessage(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override ForeignMessage MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.ForeignMessage.Descriptor; } - } - - public override ForeignMessage DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.ForeignMessage.DefaultInstance; } - } - - public override ForeignMessage BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is ForeignMessage) { - return MergeFrom((ForeignMessage) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(ForeignMessage other) { - if (other == global::Google.ProtocolBuffers.TestProtos.ForeignMessage.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasC) { - C = other.C; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_foreignMessageFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _foreignMessageFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasC = input.ReadInt32(ref result.c_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasC { - get { return result.hasC; } - } - public int C { - get { return result.C; } - set { SetC(value); } - } - public Builder SetC(int value) { - PrepareBuilder(); - result.hasC = true; - result.c_ = value; - return this; - } - public Builder ClearC() { - PrepareBuilder(); - result.hasC = false; - result.c_ = 0; - return this; - } - } - static ForeignMessage() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestReservedFields : pb::GeneratedMessage { - private TestReservedFields() { } - private static readonly TestReservedFields defaultInstance = new TestReservedFields().MakeReadOnly(); - private static readonly string[] _testReservedFieldsFieldNames = new string[] { }; - private static readonly uint[] _testReservedFieldsFieldTags = new uint[] { }; - public static TestReservedFields DefaultInstance { - get { return defaultInstance; } - } - - public override TestReservedFields DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestReservedFields ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestReservedFields__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestReservedFields__FieldAccessorTable; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testReservedFieldsFieldNames; - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestReservedFields ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestReservedFields ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestReservedFields ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestReservedFields ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestReservedFields ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestReservedFields ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestReservedFields ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestReservedFields ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestReservedFields ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestReservedFields ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestReservedFields MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestReservedFields prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestReservedFields cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestReservedFields result; - - private TestReservedFields PrepareBuilder() { - if (resultIsReadOnly) { - TestReservedFields original = result; - result = new TestReservedFields(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestReservedFields MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestReservedFields.Descriptor; } - } - - public override TestReservedFields DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestReservedFields.DefaultInstance; } - } - - public override TestReservedFields BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestReservedFields) { - return MergeFrom((TestReservedFields) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestReservedFields other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestReservedFields.DefaultInstance) return this; - PrepareBuilder(); - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testReservedFieldsFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testReservedFieldsFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - } - static TestReservedFields() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestAllExtensions : pb::ExtendableMessage { - private TestAllExtensions() { } - private static readonly TestAllExtensions defaultInstance = new TestAllExtensions().MakeReadOnly(); - private static readonly string[] _testAllExtensionsFieldNames = new string[] { }; - private static readonly uint[] _testAllExtensionsFieldTags = new uint[] { }; - public static TestAllExtensions DefaultInstance { - get { return defaultInstance; } - } - - public override TestAllExtensions DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestAllExtensions ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestAllExtensions__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestAllExtensions__FieldAccessorTable; } - } - - public override bool IsInitialized { - get { - if (!ExtensionsAreInitialized) return false; - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testAllExtensionsFieldNames; - pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); - extensionWriter.WriteUntil(536870912, output); - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - size += ExtensionsSerializedSize; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestAllExtensions ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestAllExtensions ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestAllExtensions ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestAllExtensions ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestAllExtensions ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestAllExtensions ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestAllExtensions ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestAllExtensions ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestAllExtensions ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestAllExtensions ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestAllExtensions MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestAllExtensions prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::ExtendableBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestAllExtensions cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestAllExtensions result; - - private TestAllExtensions PrepareBuilder() { - if (resultIsReadOnly) { - TestAllExtensions original = result; - result = new TestAllExtensions(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestAllExtensions MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestAllExtensions.Descriptor; } - } - - public override TestAllExtensions DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestAllExtensions.DefaultInstance; } - } - - public override TestAllExtensions BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestAllExtensions) { - return MergeFrom((TestAllExtensions) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestAllExtensions other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestAllExtensions.DefaultInstance) return this; - PrepareBuilder(); - this.MergeExtensionFields(other); - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testAllExtensionsFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testAllExtensionsFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - } - static TestAllExtensions() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class OptionalGroup_extension : pb::GeneratedMessage { - private OptionalGroup_extension() { } - private static readonly OptionalGroup_extension defaultInstance = new OptionalGroup_extension().MakeReadOnly(); - private static readonly string[] _optionalGroupExtensionFieldNames = new string[] { "a" }; - private static readonly uint[] _optionalGroupExtensionFieldTags = new uint[] { 136 }; - public static OptionalGroup_extension DefaultInstance { - get { return defaultInstance; } - } - - public override OptionalGroup_extension DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override OptionalGroup_extension ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_OptionalGroup_extension__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_OptionalGroup_extension__FieldAccessorTable; } - } - - public const int AFieldNumber = 17; - private bool hasA; - private int a_; - public bool HasA { - get { return hasA; } - } - public int A { - get { return a_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _optionalGroupExtensionFieldNames; - if (hasA) { - output.WriteInt32(17, field_names[0], A); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(17, A); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static OptionalGroup_extension ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static OptionalGroup_extension ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static OptionalGroup_extension ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static OptionalGroup_extension ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static OptionalGroup_extension ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static OptionalGroup_extension ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static OptionalGroup_extension ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static OptionalGroup_extension ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static OptionalGroup_extension ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static OptionalGroup_extension ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private OptionalGroup_extension MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(OptionalGroup_extension prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(OptionalGroup_extension cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private OptionalGroup_extension result; - - private OptionalGroup_extension PrepareBuilder() { - if (resultIsReadOnly) { - OptionalGroup_extension original = result; - result = new OptionalGroup_extension(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override OptionalGroup_extension MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.OptionalGroup_extension.Descriptor; } - } - - public override OptionalGroup_extension DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.OptionalGroup_extension.DefaultInstance; } - } - - public override OptionalGroup_extension BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is OptionalGroup_extension) { - return MergeFrom((OptionalGroup_extension) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(OptionalGroup_extension other) { - if (other == global::Google.ProtocolBuffers.TestProtos.OptionalGroup_extension.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasA) { - A = other.A; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_optionalGroupExtensionFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _optionalGroupExtensionFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 136: { - result.hasA = input.ReadInt32(ref result.a_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasA { - get { return result.hasA; } - } - public int A { - get { return result.A; } - set { SetA(value); } - } - public Builder SetA(int value) { - PrepareBuilder(); - result.hasA = true; - result.a_ = value; - return this; - } - public Builder ClearA() { - PrepareBuilder(); - result.hasA = false; - result.a_ = 0; - return this; - } - } - static OptionalGroup_extension() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class RepeatedGroup_extension : pb::GeneratedMessage { - private RepeatedGroup_extension() { } - private static readonly RepeatedGroup_extension defaultInstance = new RepeatedGroup_extension().MakeReadOnly(); - private static readonly string[] _repeatedGroupExtensionFieldNames = new string[] { "a" }; - private static readonly uint[] _repeatedGroupExtensionFieldTags = new uint[] { 376 }; - public static RepeatedGroup_extension DefaultInstance { - get { return defaultInstance; } - } - - public override RepeatedGroup_extension DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override RepeatedGroup_extension ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_RepeatedGroup_extension__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_RepeatedGroup_extension__FieldAccessorTable; } - } - - public const int AFieldNumber = 47; - private bool hasA; - private int a_; - public bool HasA { - get { return hasA; } - } - public int A { - get { return a_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _repeatedGroupExtensionFieldNames; - if (hasA) { - output.WriteInt32(47, field_names[0], A); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(47, A); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static RepeatedGroup_extension ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static RepeatedGroup_extension ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static RepeatedGroup_extension ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static RepeatedGroup_extension ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static RepeatedGroup_extension ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static RepeatedGroup_extension ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static RepeatedGroup_extension ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static RepeatedGroup_extension ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static RepeatedGroup_extension ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static RepeatedGroup_extension ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private RepeatedGroup_extension MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(RepeatedGroup_extension prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(RepeatedGroup_extension cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private RepeatedGroup_extension result; - - private RepeatedGroup_extension PrepareBuilder() { - if (resultIsReadOnly) { - RepeatedGroup_extension original = result; - result = new RepeatedGroup_extension(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override RepeatedGroup_extension MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.RepeatedGroup_extension.Descriptor; } - } - - public override RepeatedGroup_extension DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.RepeatedGroup_extension.DefaultInstance; } - } - - public override RepeatedGroup_extension BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is RepeatedGroup_extension) { - return MergeFrom((RepeatedGroup_extension) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(RepeatedGroup_extension other) { - if (other == global::Google.ProtocolBuffers.TestProtos.RepeatedGroup_extension.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasA) { - A = other.A; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_repeatedGroupExtensionFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _repeatedGroupExtensionFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 376: { - result.hasA = input.ReadInt32(ref result.a_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasA { - get { return result.hasA; } - } - public int A { - get { return result.A; } - set { SetA(value); } - } - public Builder SetA(int value) { - PrepareBuilder(); - result.hasA = true; - result.a_ = value; - return this; - } - public Builder ClearA() { - PrepareBuilder(); - result.hasA = false; - result.a_ = 0; - return this; - } - } - static RepeatedGroup_extension() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestNestedExtension : pb::GeneratedMessage { - private TestNestedExtension() { } - private static readonly TestNestedExtension defaultInstance = new TestNestedExtension().MakeReadOnly(); - private static readonly string[] _testNestedExtensionFieldNames = new string[] { }; - private static readonly uint[] _testNestedExtensionFieldTags = new uint[] { }; - public static TestNestedExtension DefaultInstance { - get { return defaultInstance; } - } - - public override TestNestedExtension DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestNestedExtension ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestNestedExtension__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestNestedExtension__FieldAccessorTable; } - } - - public const int TestFieldNumber = 1002; - public static pb::GeneratedExtensionBase Test; - public const int NestedStringExtensionFieldNumber = 1003; - public static pb::GeneratedExtensionBase NestedStringExtension; - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testNestedExtensionFieldNames; - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestNestedExtension ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestNestedExtension ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestNestedExtension ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestNestedExtension ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestNestedExtension ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestNestedExtension ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestNestedExtension ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestNestedExtension ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestNestedExtension ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestNestedExtension ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestNestedExtension MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestNestedExtension prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestNestedExtension cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestNestedExtension result; - - private TestNestedExtension PrepareBuilder() { - if (resultIsReadOnly) { - TestNestedExtension original = result; - result = new TestNestedExtension(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestNestedExtension MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestNestedExtension.Descriptor; } - } - - public override TestNestedExtension DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestNestedExtension.DefaultInstance; } - } - - public override TestNestedExtension BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestNestedExtension) { - return MergeFrom((TestNestedExtension) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestNestedExtension other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestNestedExtension.DefaultInstance) return this; - PrepareBuilder(); - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testNestedExtensionFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testNestedExtensionFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - } - static TestNestedExtension() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestRequired : pb::GeneratedMessage { - private TestRequired() { } - private static readonly TestRequired defaultInstance = new TestRequired().MakeReadOnly(); - private static readonly string[] _testRequiredFieldNames = new string[] { "a", "b", "c", "dummy10", "dummy11", "dummy12", "dummy13", "dummy14", "dummy15", "dummy16", "dummy17", "dummy18", "dummy19", "dummy2", "dummy20", "dummy21", "dummy22", "dummy23", "dummy24", "dummy25", "dummy26", "dummy27", "dummy28", "dummy29", "dummy30", "dummy31", "dummy32", "dummy4", "dummy5", "dummy6", "dummy7", "dummy8", "dummy9" }; - private static readonly uint[] _testRequiredFieldTags = new uint[] { 8, 24, 264, 80, 88, 96, 104, 112, 120, 128, 136, 144, 152, 16, 160, 168, 176, 184, 192, 200, 208, 216, 224, 232, 240, 248, 256, 32, 40, 48, 56, 64, 72 }; - public static TestRequired DefaultInstance { - get { return defaultInstance; } - } - - public override TestRequired DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestRequired ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestRequired__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestRequired__FieldAccessorTable; } - } - - public const int SingleFieldNumber = 1000; - public static pb::GeneratedExtensionBase Single; - public const int MultiFieldNumber = 1001; - public static pb::GeneratedExtensionBase> Multi; - public const int AFieldNumber = 1; - private bool hasA; - private int a_; - public bool HasA { - get { return hasA; } - } - public int A { - get { return a_; } - } - - public const int Dummy2FieldNumber = 2; - private bool hasDummy2; - private int dummy2_; - public bool HasDummy2 { - get { return hasDummy2; } - } - public int Dummy2 { - get { return dummy2_; } - } - - public const int BFieldNumber = 3; - private bool hasB; - private int b_; - public bool HasB { - get { return hasB; } - } - public int B { - get { return b_; } - } - - public const int Dummy4FieldNumber = 4; - private bool hasDummy4; - private int dummy4_; - public bool HasDummy4 { - get { return hasDummy4; } - } - public int Dummy4 { - get { return dummy4_; } - } - - public const int Dummy5FieldNumber = 5; - private bool hasDummy5; - private int dummy5_; - public bool HasDummy5 { - get { return hasDummy5; } - } - public int Dummy5 { - get { return dummy5_; } - } - - public const int Dummy6FieldNumber = 6; - private bool hasDummy6; - private int dummy6_; - public bool HasDummy6 { - get { return hasDummy6; } - } - public int Dummy6 { - get { return dummy6_; } - } - - public const int Dummy7FieldNumber = 7; - private bool hasDummy7; - private int dummy7_; - public bool HasDummy7 { - get { return hasDummy7; } - } - public int Dummy7 { - get { return dummy7_; } - } - - public const int Dummy8FieldNumber = 8; - private bool hasDummy8; - private int dummy8_; - public bool HasDummy8 { - get { return hasDummy8; } - } - public int Dummy8 { - get { return dummy8_; } - } - - public const int Dummy9FieldNumber = 9; - private bool hasDummy9; - private int dummy9_; - public bool HasDummy9 { - get { return hasDummy9; } - } - public int Dummy9 { - get { return dummy9_; } - } - - public const int Dummy10FieldNumber = 10; - private bool hasDummy10; - private int dummy10_; - public bool HasDummy10 { - get { return hasDummy10; } - } - public int Dummy10 { - get { return dummy10_; } - } - - public const int Dummy11FieldNumber = 11; - private bool hasDummy11; - private int dummy11_; - public bool HasDummy11 { - get { return hasDummy11; } - } - public int Dummy11 { - get { return dummy11_; } - } - - public const int Dummy12FieldNumber = 12; - private bool hasDummy12; - private int dummy12_; - public bool HasDummy12 { - get { return hasDummy12; } - } - public int Dummy12 { - get { return dummy12_; } - } - - public const int Dummy13FieldNumber = 13; - private bool hasDummy13; - private int dummy13_; - public bool HasDummy13 { - get { return hasDummy13; } - } - public int Dummy13 { - get { return dummy13_; } - } - - public const int Dummy14FieldNumber = 14; - private bool hasDummy14; - private int dummy14_; - public bool HasDummy14 { - get { return hasDummy14; } - } - public int Dummy14 { - get { return dummy14_; } - } - - public const int Dummy15FieldNumber = 15; - private bool hasDummy15; - private int dummy15_; - public bool HasDummy15 { - get { return hasDummy15; } - } - public int Dummy15 { - get { return dummy15_; } - } - - public const int Dummy16FieldNumber = 16; - private bool hasDummy16; - private int dummy16_; - public bool HasDummy16 { - get { return hasDummy16; } - } - public int Dummy16 { - get { return dummy16_; } - } - - public const int Dummy17FieldNumber = 17; - private bool hasDummy17; - private int dummy17_; - public bool HasDummy17 { - get { return hasDummy17; } - } - public int Dummy17 { - get { return dummy17_; } - } - - public const int Dummy18FieldNumber = 18; - private bool hasDummy18; - private int dummy18_; - public bool HasDummy18 { - get { return hasDummy18; } - } - public int Dummy18 { - get { return dummy18_; } - } - - public const int Dummy19FieldNumber = 19; - private bool hasDummy19; - private int dummy19_; - public bool HasDummy19 { - get { return hasDummy19; } - } - public int Dummy19 { - get { return dummy19_; } - } - - public const int Dummy20FieldNumber = 20; - private bool hasDummy20; - private int dummy20_; - public bool HasDummy20 { - get { return hasDummy20; } - } - public int Dummy20 { - get { return dummy20_; } - } - - public const int Dummy21FieldNumber = 21; - private bool hasDummy21; - private int dummy21_; - public bool HasDummy21 { - get { return hasDummy21; } - } - public int Dummy21 { - get { return dummy21_; } - } - - public const int Dummy22FieldNumber = 22; - private bool hasDummy22; - private int dummy22_; - public bool HasDummy22 { - get { return hasDummy22; } - } - public int Dummy22 { - get { return dummy22_; } - } - - public const int Dummy23FieldNumber = 23; - private bool hasDummy23; - private int dummy23_; - public bool HasDummy23 { - get { return hasDummy23; } - } - public int Dummy23 { - get { return dummy23_; } - } - - public const int Dummy24FieldNumber = 24; - private bool hasDummy24; - private int dummy24_; - public bool HasDummy24 { - get { return hasDummy24; } - } - public int Dummy24 { - get { return dummy24_; } - } - - public const int Dummy25FieldNumber = 25; - private bool hasDummy25; - private int dummy25_; - public bool HasDummy25 { - get { return hasDummy25; } - } - public int Dummy25 { - get { return dummy25_; } - } - - public const int Dummy26FieldNumber = 26; - private bool hasDummy26; - private int dummy26_; - public bool HasDummy26 { - get { return hasDummy26; } - } - public int Dummy26 { - get { return dummy26_; } - } - - public const int Dummy27FieldNumber = 27; - private bool hasDummy27; - private int dummy27_; - public bool HasDummy27 { - get { return hasDummy27; } - } - public int Dummy27 { - get { return dummy27_; } - } - - public const int Dummy28FieldNumber = 28; - private bool hasDummy28; - private int dummy28_; - public bool HasDummy28 { - get { return hasDummy28; } - } - public int Dummy28 { - get { return dummy28_; } - } - - public const int Dummy29FieldNumber = 29; - private bool hasDummy29; - private int dummy29_; - public bool HasDummy29 { - get { return hasDummy29; } - } - public int Dummy29 { - get { return dummy29_; } - } - - public const int Dummy30FieldNumber = 30; - private bool hasDummy30; - private int dummy30_; - public bool HasDummy30 { - get { return hasDummy30; } - } - public int Dummy30 { - get { return dummy30_; } - } - - public const int Dummy31FieldNumber = 31; - private bool hasDummy31; - private int dummy31_; - public bool HasDummy31 { - get { return hasDummy31; } - } - public int Dummy31 { - get { return dummy31_; } - } - - public const int Dummy32FieldNumber = 32; - private bool hasDummy32; - private int dummy32_; - public bool HasDummy32 { - get { return hasDummy32; } - } - public int Dummy32 { - get { return dummy32_; } - } - - public const int CFieldNumber = 33; - private bool hasC; - private int c_; - public bool HasC { - get { return hasC; } - } - public int C { - get { return c_; } - } - - public override bool IsInitialized { - get { - if (!hasA) return false; - if (!hasB) return false; - if (!hasC) return false; - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testRequiredFieldNames; - if (hasA) { - output.WriteInt32(1, field_names[0], A); - } - if (hasDummy2) { - output.WriteInt32(2, field_names[13], Dummy2); - } - if (hasB) { - output.WriteInt32(3, field_names[1], B); - } - if (hasDummy4) { - output.WriteInt32(4, field_names[27], Dummy4); - } - if (hasDummy5) { - output.WriteInt32(5, field_names[28], Dummy5); - } - if (hasDummy6) { - output.WriteInt32(6, field_names[29], Dummy6); - } - if (hasDummy7) { - output.WriteInt32(7, field_names[30], Dummy7); - } - if (hasDummy8) { - output.WriteInt32(8, field_names[31], Dummy8); - } - if (hasDummy9) { - output.WriteInt32(9, field_names[32], Dummy9); - } - if (hasDummy10) { - output.WriteInt32(10, field_names[3], Dummy10); - } - if (hasDummy11) { - output.WriteInt32(11, field_names[4], Dummy11); - } - if (hasDummy12) { - output.WriteInt32(12, field_names[5], Dummy12); - } - if (hasDummy13) { - output.WriteInt32(13, field_names[6], Dummy13); - } - if (hasDummy14) { - output.WriteInt32(14, field_names[7], Dummy14); - } - if (hasDummy15) { - output.WriteInt32(15, field_names[8], Dummy15); - } - if (hasDummy16) { - output.WriteInt32(16, field_names[9], Dummy16); - } - if (hasDummy17) { - output.WriteInt32(17, field_names[10], Dummy17); - } - if (hasDummy18) { - output.WriteInt32(18, field_names[11], Dummy18); - } - if (hasDummy19) { - output.WriteInt32(19, field_names[12], Dummy19); - } - if (hasDummy20) { - output.WriteInt32(20, field_names[14], Dummy20); - } - if (hasDummy21) { - output.WriteInt32(21, field_names[15], Dummy21); - } - if (hasDummy22) { - output.WriteInt32(22, field_names[16], Dummy22); - } - if (hasDummy23) { - output.WriteInt32(23, field_names[17], Dummy23); - } - if (hasDummy24) { - output.WriteInt32(24, field_names[18], Dummy24); - } - if (hasDummy25) { - output.WriteInt32(25, field_names[19], Dummy25); - } - if (hasDummy26) { - output.WriteInt32(26, field_names[20], Dummy26); - } - if (hasDummy27) { - output.WriteInt32(27, field_names[21], Dummy27); - } - if (hasDummy28) { - output.WriteInt32(28, field_names[22], Dummy28); - } - if (hasDummy29) { - output.WriteInt32(29, field_names[23], Dummy29); - } - if (hasDummy30) { - output.WriteInt32(30, field_names[24], Dummy30); - } - if (hasDummy31) { - output.WriteInt32(31, field_names[25], Dummy31); - } - if (hasDummy32) { - output.WriteInt32(32, field_names[26], Dummy32); - } - if (hasC) { - output.WriteInt32(33, field_names[2], C); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(1, A); - } - if (hasDummy2) { - size += pb::CodedOutputStream.ComputeInt32Size(2, Dummy2); - } - if (hasB) { - size += pb::CodedOutputStream.ComputeInt32Size(3, B); - } - if (hasDummy4) { - size += pb::CodedOutputStream.ComputeInt32Size(4, Dummy4); - } - if (hasDummy5) { - size += pb::CodedOutputStream.ComputeInt32Size(5, Dummy5); - } - if (hasDummy6) { - size += pb::CodedOutputStream.ComputeInt32Size(6, Dummy6); - } - if (hasDummy7) { - size += pb::CodedOutputStream.ComputeInt32Size(7, Dummy7); - } - if (hasDummy8) { - size += pb::CodedOutputStream.ComputeInt32Size(8, Dummy8); - } - if (hasDummy9) { - size += pb::CodedOutputStream.ComputeInt32Size(9, Dummy9); - } - if (hasDummy10) { - size += pb::CodedOutputStream.ComputeInt32Size(10, Dummy10); - } - if (hasDummy11) { - size += pb::CodedOutputStream.ComputeInt32Size(11, Dummy11); - } - if (hasDummy12) { - size += pb::CodedOutputStream.ComputeInt32Size(12, Dummy12); - } - if (hasDummy13) { - size += pb::CodedOutputStream.ComputeInt32Size(13, Dummy13); - } - if (hasDummy14) { - size += pb::CodedOutputStream.ComputeInt32Size(14, Dummy14); - } - if (hasDummy15) { - size += pb::CodedOutputStream.ComputeInt32Size(15, Dummy15); - } - if (hasDummy16) { - size += pb::CodedOutputStream.ComputeInt32Size(16, Dummy16); - } - if (hasDummy17) { - size += pb::CodedOutputStream.ComputeInt32Size(17, Dummy17); - } - if (hasDummy18) { - size += pb::CodedOutputStream.ComputeInt32Size(18, Dummy18); - } - if (hasDummy19) { - size += pb::CodedOutputStream.ComputeInt32Size(19, Dummy19); - } - if (hasDummy20) { - size += pb::CodedOutputStream.ComputeInt32Size(20, Dummy20); - } - if (hasDummy21) { - size += pb::CodedOutputStream.ComputeInt32Size(21, Dummy21); - } - if (hasDummy22) { - size += pb::CodedOutputStream.ComputeInt32Size(22, Dummy22); - } - if (hasDummy23) { - size += pb::CodedOutputStream.ComputeInt32Size(23, Dummy23); - } - if (hasDummy24) { - size += pb::CodedOutputStream.ComputeInt32Size(24, Dummy24); - } - if (hasDummy25) { - size += pb::CodedOutputStream.ComputeInt32Size(25, Dummy25); - } - if (hasDummy26) { - size += pb::CodedOutputStream.ComputeInt32Size(26, Dummy26); - } - if (hasDummy27) { - size += pb::CodedOutputStream.ComputeInt32Size(27, Dummy27); - } - if (hasDummy28) { - size += pb::CodedOutputStream.ComputeInt32Size(28, Dummy28); - } - if (hasDummy29) { - size += pb::CodedOutputStream.ComputeInt32Size(29, Dummy29); - } - if (hasDummy30) { - size += pb::CodedOutputStream.ComputeInt32Size(30, Dummy30); - } - if (hasDummy31) { - size += pb::CodedOutputStream.ComputeInt32Size(31, Dummy31); - } - if (hasDummy32) { - size += pb::CodedOutputStream.ComputeInt32Size(32, Dummy32); - } - if (hasC) { - size += pb::CodedOutputStream.ComputeInt32Size(33, C); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestRequired ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestRequired ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestRequired ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestRequired ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestRequired ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestRequired ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestRequired ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestRequired ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestRequired ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestRequired ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestRequired MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestRequired prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestRequired cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestRequired result; - - private TestRequired PrepareBuilder() { - if (resultIsReadOnly) { - TestRequired original = result; - result = new TestRequired(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestRequired MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestRequired.Descriptor; } - } - - public override TestRequired DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestRequired.DefaultInstance; } - } - - public override TestRequired BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestRequired) { - return MergeFrom((TestRequired) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestRequired other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestRequired.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasA) { - A = other.A; - } - if (other.HasDummy2) { - Dummy2 = other.Dummy2; - } - if (other.HasB) { - B = other.B; - } - if (other.HasDummy4) { - Dummy4 = other.Dummy4; - } - if (other.HasDummy5) { - Dummy5 = other.Dummy5; - } - if (other.HasDummy6) { - Dummy6 = other.Dummy6; - } - if (other.HasDummy7) { - Dummy7 = other.Dummy7; - } - if (other.HasDummy8) { - Dummy8 = other.Dummy8; - } - if (other.HasDummy9) { - Dummy9 = other.Dummy9; - } - if (other.HasDummy10) { - Dummy10 = other.Dummy10; - } - if (other.HasDummy11) { - Dummy11 = other.Dummy11; - } - if (other.HasDummy12) { - Dummy12 = other.Dummy12; - } - if (other.HasDummy13) { - Dummy13 = other.Dummy13; - } - if (other.HasDummy14) { - Dummy14 = other.Dummy14; - } - if (other.HasDummy15) { - Dummy15 = other.Dummy15; - } - if (other.HasDummy16) { - Dummy16 = other.Dummy16; - } - if (other.HasDummy17) { - Dummy17 = other.Dummy17; - } - if (other.HasDummy18) { - Dummy18 = other.Dummy18; - } - if (other.HasDummy19) { - Dummy19 = other.Dummy19; - } - if (other.HasDummy20) { - Dummy20 = other.Dummy20; - } - if (other.HasDummy21) { - Dummy21 = other.Dummy21; - } - if (other.HasDummy22) { - Dummy22 = other.Dummy22; - } - if (other.HasDummy23) { - Dummy23 = other.Dummy23; - } - if (other.HasDummy24) { - Dummy24 = other.Dummy24; - } - if (other.HasDummy25) { - Dummy25 = other.Dummy25; - } - if (other.HasDummy26) { - Dummy26 = other.Dummy26; - } - if (other.HasDummy27) { - Dummy27 = other.Dummy27; - } - if (other.HasDummy28) { - Dummy28 = other.Dummy28; - } - if (other.HasDummy29) { - Dummy29 = other.Dummy29; - } - if (other.HasDummy30) { - Dummy30 = other.Dummy30; - } - if (other.HasDummy31) { - Dummy31 = other.Dummy31; - } - if (other.HasDummy32) { - Dummy32 = other.Dummy32; - } - if (other.HasC) { - C = other.C; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testRequiredFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testRequiredFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasA = input.ReadInt32(ref result.a_); - break; - } - case 16: { - result.hasDummy2 = input.ReadInt32(ref result.dummy2_); - break; - } - case 24: { - result.hasB = input.ReadInt32(ref result.b_); - break; - } - case 32: { - result.hasDummy4 = input.ReadInt32(ref result.dummy4_); - break; - } - case 40: { - result.hasDummy5 = input.ReadInt32(ref result.dummy5_); - break; - } - case 48: { - result.hasDummy6 = input.ReadInt32(ref result.dummy6_); - break; - } - case 56: { - result.hasDummy7 = input.ReadInt32(ref result.dummy7_); - break; - } - case 64: { - result.hasDummy8 = input.ReadInt32(ref result.dummy8_); - break; - } - case 72: { - result.hasDummy9 = input.ReadInt32(ref result.dummy9_); - break; - } - case 80: { - result.hasDummy10 = input.ReadInt32(ref result.dummy10_); - break; - } - case 88: { - result.hasDummy11 = input.ReadInt32(ref result.dummy11_); - break; - } - case 96: { - result.hasDummy12 = input.ReadInt32(ref result.dummy12_); - break; - } - case 104: { - result.hasDummy13 = input.ReadInt32(ref result.dummy13_); - break; - } - case 112: { - result.hasDummy14 = input.ReadInt32(ref result.dummy14_); - break; - } - case 120: { - result.hasDummy15 = input.ReadInt32(ref result.dummy15_); - break; - } - case 128: { - result.hasDummy16 = input.ReadInt32(ref result.dummy16_); - break; - } - case 136: { - result.hasDummy17 = input.ReadInt32(ref result.dummy17_); - break; - } - case 144: { - result.hasDummy18 = input.ReadInt32(ref result.dummy18_); - break; - } - case 152: { - result.hasDummy19 = input.ReadInt32(ref result.dummy19_); - break; - } - case 160: { - result.hasDummy20 = input.ReadInt32(ref result.dummy20_); - break; - } - case 168: { - result.hasDummy21 = input.ReadInt32(ref result.dummy21_); - break; - } - case 176: { - result.hasDummy22 = input.ReadInt32(ref result.dummy22_); - break; - } - case 184: { - result.hasDummy23 = input.ReadInt32(ref result.dummy23_); - break; - } - case 192: { - result.hasDummy24 = input.ReadInt32(ref result.dummy24_); - break; - } - case 200: { - result.hasDummy25 = input.ReadInt32(ref result.dummy25_); - break; - } - case 208: { - result.hasDummy26 = input.ReadInt32(ref result.dummy26_); - break; - } - case 216: { - result.hasDummy27 = input.ReadInt32(ref result.dummy27_); - break; - } - case 224: { - result.hasDummy28 = input.ReadInt32(ref result.dummy28_); - break; - } - case 232: { - result.hasDummy29 = input.ReadInt32(ref result.dummy29_); - break; - } - case 240: { - result.hasDummy30 = input.ReadInt32(ref result.dummy30_); - break; - } - case 248: { - result.hasDummy31 = input.ReadInt32(ref result.dummy31_); - break; - } - case 256: { - result.hasDummy32 = input.ReadInt32(ref result.dummy32_); - break; - } - case 264: { - result.hasC = input.ReadInt32(ref result.c_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasA { - get { return result.hasA; } - } - public int A { - get { return result.A; } - set { SetA(value); } - } - public Builder SetA(int value) { - PrepareBuilder(); - result.hasA = true; - result.a_ = value; - return this; - } - public Builder ClearA() { - PrepareBuilder(); - result.hasA = false; - result.a_ = 0; - return this; - } - - public bool HasDummy2 { - get { return result.hasDummy2; } - } - public int Dummy2 { - get { return result.Dummy2; } - set { SetDummy2(value); } - } - public Builder SetDummy2(int value) { - PrepareBuilder(); - result.hasDummy2 = true; - result.dummy2_ = value; - return this; - } - public Builder ClearDummy2() { - PrepareBuilder(); - result.hasDummy2 = false; - result.dummy2_ = 0; - return this; - } - - public bool HasB { - get { return result.hasB; } - } - public int B { - get { return result.B; } - set { SetB(value); } - } - public Builder SetB(int value) { - PrepareBuilder(); - result.hasB = true; - result.b_ = value; - return this; - } - public Builder ClearB() { - PrepareBuilder(); - result.hasB = false; - result.b_ = 0; - return this; - } - - public bool HasDummy4 { - get { return result.hasDummy4; } - } - public int Dummy4 { - get { return result.Dummy4; } - set { SetDummy4(value); } - } - public Builder SetDummy4(int value) { - PrepareBuilder(); - result.hasDummy4 = true; - result.dummy4_ = value; - return this; - } - public Builder ClearDummy4() { - PrepareBuilder(); - result.hasDummy4 = false; - result.dummy4_ = 0; - return this; - } - - public bool HasDummy5 { - get { return result.hasDummy5; } - } - public int Dummy5 { - get { return result.Dummy5; } - set { SetDummy5(value); } - } - public Builder SetDummy5(int value) { - PrepareBuilder(); - result.hasDummy5 = true; - result.dummy5_ = value; - return this; - } - public Builder ClearDummy5() { - PrepareBuilder(); - result.hasDummy5 = false; - result.dummy5_ = 0; - return this; - } - - public bool HasDummy6 { - get { return result.hasDummy6; } - } - public int Dummy6 { - get { return result.Dummy6; } - set { SetDummy6(value); } - } - public Builder SetDummy6(int value) { - PrepareBuilder(); - result.hasDummy6 = true; - result.dummy6_ = value; - return this; - } - public Builder ClearDummy6() { - PrepareBuilder(); - result.hasDummy6 = false; - result.dummy6_ = 0; - return this; - } - - public bool HasDummy7 { - get { return result.hasDummy7; } - } - public int Dummy7 { - get { return result.Dummy7; } - set { SetDummy7(value); } - } - public Builder SetDummy7(int value) { - PrepareBuilder(); - result.hasDummy7 = true; - result.dummy7_ = value; - return this; - } - public Builder ClearDummy7() { - PrepareBuilder(); - result.hasDummy7 = false; - result.dummy7_ = 0; - return this; - } - - public bool HasDummy8 { - get { return result.hasDummy8; } - } - public int Dummy8 { - get { return result.Dummy8; } - set { SetDummy8(value); } - } - public Builder SetDummy8(int value) { - PrepareBuilder(); - result.hasDummy8 = true; - result.dummy8_ = value; - return this; - } - public Builder ClearDummy8() { - PrepareBuilder(); - result.hasDummy8 = false; - result.dummy8_ = 0; - return this; - } - - public bool HasDummy9 { - get { return result.hasDummy9; } - } - public int Dummy9 { - get { return result.Dummy9; } - set { SetDummy9(value); } - } - public Builder SetDummy9(int value) { - PrepareBuilder(); - result.hasDummy9 = true; - result.dummy9_ = value; - return this; - } - public Builder ClearDummy9() { - PrepareBuilder(); - result.hasDummy9 = false; - result.dummy9_ = 0; - return this; - } - - public bool HasDummy10 { - get { return result.hasDummy10; } - } - public int Dummy10 { - get { return result.Dummy10; } - set { SetDummy10(value); } - } - public Builder SetDummy10(int value) { - PrepareBuilder(); - result.hasDummy10 = true; - result.dummy10_ = value; - return this; - } - public Builder ClearDummy10() { - PrepareBuilder(); - result.hasDummy10 = false; - result.dummy10_ = 0; - return this; - } - - public bool HasDummy11 { - get { return result.hasDummy11; } - } - public int Dummy11 { - get { return result.Dummy11; } - set { SetDummy11(value); } - } - public Builder SetDummy11(int value) { - PrepareBuilder(); - result.hasDummy11 = true; - result.dummy11_ = value; - return this; - } - public Builder ClearDummy11() { - PrepareBuilder(); - result.hasDummy11 = false; - result.dummy11_ = 0; - return this; - } - - public bool HasDummy12 { - get { return result.hasDummy12; } - } - public int Dummy12 { - get { return result.Dummy12; } - set { SetDummy12(value); } - } - public Builder SetDummy12(int value) { - PrepareBuilder(); - result.hasDummy12 = true; - result.dummy12_ = value; - return this; - } - public Builder ClearDummy12() { - PrepareBuilder(); - result.hasDummy12 = false; - result.dummy12_ = 0; - return this; - } - - public bool HasDummy13 { - get { return result.hasDummy13; } - } - public int Dummy13 { - get { return result.Dummy13; } - set { SetDummy13(value); } - } - public Builder SetDummy13(int value) { - PrepareBuilder(); - result.hasDummy13 = true; - result.dummy13_ = value; - return this; - } - public Builder ClearDummy13() { - PrepareBuilder(); - result.hasDummy13 = false; - result.dummy13_ = 0; - return this; - } - - public bool HasDummy14 { - get { return result.hasDummy14; } - } - public int Dummy14 { - get { return result.Dummy14; } - set { SetDummy14(value); } - } - public Builder SetDummy14(int value) { - PrepareBuilder(); - result.hasDummy14 = true; - result.dummy14_ = value; - return this; - } - public Builder ClearDummy14() { - PrepareBuilder(); - result.hasDummy14 = false; - result.dummy14_ = 0; - return this; - } - - public bool HasDummy15 { - get { return result.hasDummy15; } - } - public int Dummy15 { - get { return result.Dummy15; } - set { SetDummy15(value); } - } - public Builder SetDummy15(int value) { - PrepareBuilder(); - result.hasDummy15 = true; - result.dummy15_ = value; - return this; - } - public Builder ClearDummy15() { - PrepareBuilder(); - result.hasDummy15 = false; - result.dummy15_ = 0; - return this; - } - - public bool HasDummy16 { - get { return result.hasDummy16; } - } - public int Dummy16 { - get { return result.Dummy16; } - set { SetDummy16(value); } - } - public Builder SetDummy16(int value) { - PrepareBuilder(); - result.hasDummy16 = true; - result.dummy16_ = value; - return this; - } - public Builder ClearDummy16() { - PrepareBuilder(); - result.hasDummy16 = false; - result.dummy16_ = 0; - return this; - } - - public bool HasDummy17 { - get { return result.hasDummy17; } - } - public int Dummy17 { - get { return result.Dummy17; } - set { SetDummy17(value); } - } - public Builder SetDummy17(int value) { - PrepareBuilder(); - result.hasDummy17 = true; - result.dummy17_ = value; - return this; - } - public Builder ClearDummy17() { - PrepareBuilder(); - result.hasDummy17 = false; - result.dummy17_ = 0; - return this; - } - - public bool HasDummy18 { - get { return result.hasDummy18; } - } - public int Dummy18 { - get { return result.Dummy18; } - set { SetDummy18(value); } - } - public Builder SetDummy18(int value) { - PrepareBuilder(); - result.hasDummy18 = true; - result.dummy18_ = value; - return this; - } - public Builder ClearDummy18() { - PrepareBuilder(); - result.hasDummy18 = false; - result.dummy18_ = 0; - return this; - } - - public bool HasDummy19 { - get { return result.hasDummy19; } - } - public int Dummy19 { - get { return result.Dummy19; } - set { SetDummy19(value); } - } - public Builder SetDummy19(int value) { - PrepareBuilder(); - result.hasDummy19 = true; - result.dummy19_ = value; - return this; - } - public Builder ClearDummy19() { - PrepareBuilder(); - result.hasDummy19 = false; - result.dummy19_ = 0; - return this; - } - - public bool HasDummy20 { - get { return result.hasDummy20; } - } - public int Dummy20 { - get { return result.Dummy20; } - set { SetDummy20(value); } - } - public Builder SetDummy20(int value) { - PrepareBuilder(); - result.hasDummy20 = true; - result.dummy20_ = value; - return this; - } - public Builder ClearDummy20() { - PrepareBuilder(); - result.hasDummy20 = false; - result.dummy20_ = 0; - return this; - } - - public bool HasDummy21 { - get { return result.hasDummy21; } - } - public int Dummy21 { - get { return result.Dummy21; } - set { SetDummy21(value); } - } - public Builder SetDummy21(int value) { - PrepareBuilder(); - result.hasDummy21 = true; - result.dummy21_ = value; - return this; - } - public Builder ClearDummy21() { - PrepareBuilder(); - result.hasDummy21 = false; - result.dummy21_ = 0; - return this; - } - - public bool HasDummy22 { - get { return result.hasDummy22; } - } - public int Dummy22 { - get { return result.Dummy22; } - set { SetDummy22(value); } - } - public Builder SetDummy22(int value) { - PrepareBuilder(); - result.hasDummy22 = true; - result.dummy22_ = value; - return this; - } - public Builder ClearDummy22() { - PrepareBuilder(); - result.hasDummy22 = false; - result.dummy22_ = 0; - return this; - } - - public bool HasDummy23 { - get { return result.hasDummy23; } - } - public int Dummy23 { - get { return result.Dummy23; } - set { SetDummy23(value); } - } - public Builder SetDummy23(int value) { - PrepareBuilder(); - result.hasDummy23 = true; - result.dummy23_ = value; - return this; - } - public Builder ClearDummy23() { - PrepareBuilder(); - result.hasDummy23 = false; - result.dummy23_ = 0; - return this; - } - - public bool HasDummy24 { - get { return result.hasDummy24; } - } - public int Dummy24 { - get { return result.Dummy24; } - set { SetDummy24(value); } - } - public Builder SetDummy24(int value) { - PrepareBuilder(); - result.hasDummy24 = true; - result.dummy24_ = value; - return this; - } - public Builder ClearDummy24() { - PrepareBuilder(); - result.hasDummy24 = false; - result.dummy24_ = 0; - return this; - } - - public bool HasDummy25 { - get { return result.hasDummy25; } - } - public int Dummy25 { - get { return result.Dummy25; } - set { SetDummy25(value); } - } - public Builder SetDummy25(int value) { - PrepareBuilder(); - result.hasDummy25 = true; - result.dummy25_ = value; - return this; - } - public Builder ClearDummy25() { - PrepareBuilder(); - result.hasDummy25 = false; - result.dummy25_ = 0; - return this; - } - - public bool HasDummy26 { - get { return result.hasDummy26; } - } - public int Dummy26 { - get { return result.Dummy26; } - set { SetDummy26(value); } - } - public Builder SetDummy26(int value) { - PrepareBuilder(); - result.hasDummy26 = true; - result.dummy26_ = value; - return this; - } - public Builder ClearDummy26() { - PrepareBuilder(); - result.hasDummy26 = false; - result.dummy26_ = 0; - return this; - } - - public bool HasDummy27 { - get { return result.hasDummy27; } - } - public int Dummy27 { - get { return result.Dummy27; } - set { SetDummy27(value); } - } - public Builder SetDummy27(int value) { - PrepareBuilder(); - result.hasDummy27 = true; - result.dummy27_ = value; - return this; - } - public Builder ClearDummy27() { - PrepareBuilder(); - result.hasDummy27 = false; - result.dummy27_ = 0; - return this; - } - - public bool HasDummy28 { - get { return result.hasDummy28; } - } - public int Dummy28 { - get { return result.Dummy28; } - set { SetDummy28(value); } - } - public Builder SetDummy28(int value) { - PrepareBuilder(); - result.hasDummy28 = true; - result.dummy28_ = value; - return this; - } - public Builder ClearDummy28() { - PrepareBuilder(); - result.hasDummy28 = false; - result.dummy28_ = 0; - return this; - } - - public bool HasDummy29 { - get { return result.hasDummy29; } - } - public int Dummy29 { - get { return result.Dummy29; } - set { SetDummy29(value); } - } - public Builder SetDummy29(int value) { - PrepareBuilder(); - result.hasDummy29 = true; - result.dummy29_ = value; - return this; - } - public Builder ClearDummy29() { - PrepareBuilder(); - result.hasDummy29 = false; - result.dummy29_ = 0; - return this; - } - - public bool HasDummy30 { - get { return result.hasDummy30; } - } - public int Dummy30 { - get { return result.Dummy30; } - set { SetDummy30(value); } - } - public Builder SetDummy30(int value) { - PrepareBuilder(); - result.hasDummy30 = true; - result.dummy30_ = value; - return this; - } - public Builder ClearDummy30() { - PrepareBuilder(); - result.hasDummy30 = false; - result.dummy30_ = 0; - return this; - } - - public bool HasDummy31 { - get { return result.hasDummy31; } - } - public int Dummy31 { - get { return result.Dummy31; } - set { SetDummy31(value); } - } - public Builder SetDummy31(int value) { - PrepareBuilder(); - result.hasDummy31 = true; - result.dummy31_ = value; - return this; - } - public Builder ClearDummy31() { - PrepareBuilder(); - result.hasDummy31 = false; - result.dummy31_ = 0; - return this; - } - - public bool HasDummy32 { - get { return result.hasDummy32; } - } - public int Dummy32 { - get { return result.Dummy32; } - set { SetDummy32(value); } - } - public Builder SetDummy32(int value) { - PrepareBuilder(); - result.hasDummy32 = true; - result.dummy32_ = value; - return this; - } - public Builder ClearDummy32() { - PrepareBuilder(); - result.hasDummy32 = false; - result.dummy32_ = 0; - return this; - } - - public bool HasC { - get { return result.hasC; } - } - public int C { - get { return result.C; } - set { SetC(value); } - } - public Builder SetC(int value) { - PrepareBuilder(); - result.hasC = true; - result.c_ = value; - return this; - } - public Builder ClearC() { - PrepareBuilder(); - result.hasC = false; - result.c_ = 0; - return this; - } - } - static TestRequired() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestRequiredForeign : pb::GeneratedMessage { - private TestRequiredForeign() { } - private static readonly TestRequiredForeign defaultInstance = new TestRequiredForeign().MakeReadOnly(); - private static readonly string[] _testRequiredForeignFieldNames = new string[] { "dummy", "optional_message", "repeated_message" }; - private static readonly uint[] _testRequiredForeignFieldTags = new uint[] { 24, 10, 18 }; - public static TestRequiredForeign DefaultInstance { - get { return defaultInstance; } - } - - public override TestRequiredForeign DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestRequiredForeign ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestRequiredForeign__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestRequiredForeign__FieldAccessorTable; } - } - - public const int OptionalMessageFieldNumber = 1; - private bool hasOptionalMessage; - private global::Google.ProtocolBuffers.TestProtos.TestRequired optionalMessage_; - public bool HasOptionalMessage { - get { return hasOptionalMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestRequired OptionalMessage { - get { return optionalMessage_ ?? global::Google.ProtocolBuffers.TestProtos.TestRequired.DefaultInstance; } - } - - public const int RepeatedMessageFieldNumber = 2; - private pbc::PopsicleList repeatedMessage_ = new pbc::PopsicleList(); - public scg::IList RepeatedMessageList { - get { return repeatedMessage_; } - } - public int RepeatedMessageCount { - get { return repeatedMessage_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestRequired GetRepeatedMessage(int index) { - return repeatedMessage_[index]; - } - - public const int DummyFieldNumber = 3; - private bool hasDummy; - private int dummy_; - public bool HasDummy { - get { return hasDummy; } - } - public int Dummy { - get { return dummy_; } - } - - public override bool IsInitialized { - get { - if (HasOptionalMessage) { - if (!OptionalMessage.IsInitialized) return false; - } - foreach (global::Google.ProtocolBuffers.TestProtos.TestRequired element in RepeatedMessageList) { - if (!element.IsInitialized) return false; - } - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testRequiredForeignFieldNames; - if (hasOptionalMessage) { - output.WriteMessage(1, field_names[1], OptionalMessage); - } - if (repeatedMessage_.Count > 0) { - output.WriteMessageArray(2, field_names[2], repeatedMessage_); - } - if (hasDummy) { - output.WriteInt32(3, field_names[0], Dummy); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasOptionalMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(1, OptionalMessage); - } - foreach (global::Google.ProtocolBuffers.TestProtos.TestRequired element in RepeatedMessageList) { - size += pb::CodedOutputStream.ComputeMessageSize(2, element); - } - if (hasDummy) { - size += pb::CodedOutputStream.ComputeInt32Size(3, Dummy); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestRequiredForeign ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestRequiredForeign ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestRequiredForeign ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestRequiredForeign ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestRequiredForeign ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestRequiredForeign ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestRequiredForeign ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestRequiredForeign ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestRequiredForeign ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestRequiredForeign ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestRequiredForeign MakeReadOnly() { - repeatedMessage_.MakeReadOnly(); - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestRequiredForeign prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestRequiredForeign cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestRequiredForeign result; - - private TestRequiredForeign PrepareBuilder() { - if (resultIsReadOnly) { - TestRequiredForeign original = result; - result = new TestRequiredForeign(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestRequiredForeign MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestRequiredForeign.Descriptor; } - } - - public override TestRequiredForeign DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestRequiredForeign.DefaultInstance; } - } - - public override TestRequiredForeign BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestRequiredForeign) { - return MergeFrom((TestRequiredForeign) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestRequiredForeign other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestRequiredForeign.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasOptionalMessage) { - MergeOptionalMessage(other.OptionalMessage); - } - if (other.repeatedMessage_.Count != 0) { - result.repeatedMessage_.Add(other.repeatedMessage_); - } - if (other.HasDummy) { - Dummy = other.Dummy; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testRequiredForeignFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testRequiredForeignFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 10: { - global::Google.ProtocolBuffers.TestProtos.TestRequired.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestRequired.CreateBuilder(); - if (result.hasOptionalMessage) { - subBuilder.MergeFrom(OptionalMessage); - } - input.ReadMessage(subBuilder, extensionRegistry); - OptionalMessage = subBuilder.BuildPartial(); - break; - } - case 18: { - input.ReadMessageArray(tag, field_name, result.repeatedMessage_, global::Google.ProtocolBuffers.TestProtos.TestRequired.DefaultInstance, extensionRegistry); - break; - } - case 24: { - result.hasDummy = input.ReadInt32(ref result.dummy_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasOptionalMessage { - get { return result.hasOptionalMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestRequired OptionalMessage { - get { return result.OptionalMessage; } - set { SetOptionalMessage(value); } - } - public Builder SetOptionalMessage(global::Google.ProtocolBuffers.TestProtos.TestRequired value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOptionalMessage = true; - result.optionalMessage_ = value; - return this; - } - public Builder SetOptionalMessage(global::Google.ProtocolBuffers.TestProtos.TestRequired.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasOptionalMessage = true; - result.optionalMessage_ = builderForValue.Build(); - return this; - } - public Builder MergeOptionalMessage(global::Google.ProtocolBuffers.TestProtos.TestRequired value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasOptionalMessage && - result.optionalMessage_ != global::Google.ProtocolBuffers.TestProtos.TestRequired.DefaultInstance) { - result.optionalMessage_ = global::Google.ProtocolBuffers.TestProtos.TestRequired.CreateBuilder(result.optionalMessage_).MergeFrom(value).BuildPartial(); - } else { - result.optionalMessage_ = value; - } - result.hasOptionalMessage = true; - return this; - } - public Builder ClearOptionalMessage() { - PrepareBuilder(); - result.hasOptionalMessage = false; - result.optionalMessage_ = null; - return this; - } - - public pbc::IPopsicleList RepeatedMessageList { - get { return PrepareBuilder().repeatedMessage_; } - } - public int RepeatedMessageCount { - get { return result.RepeatedMessageCount; } - } - public global::Google.ProtocolBuffers.TestProtos.TestRequired GetRepeatedMessage(int index) { - return result.GetRepeatedMessage(index); - } - public Builder SetRepeatedMessage(int index, global::Google.ProtocolBuffers.TestProtos.TestRequired value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedMessage_[index] = value; - return this; - } - public Builder SetRepeatedMessage(int index, global::Google.ProtocolBuffers.TestProtos.TestRequired.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.repeatedMessage_[index] = builderForValue.Build(); - return this; - } - public Builder AddRepeatedMessage(global::Google.ProtocolBuffers.TestProtos.TestRequired value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedMessage_.Add(value); - return this; - } - public Builder AddRepeatedMessage(global::Google.ProtocolBuffers.TestProtos.TestRequired.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.repeatedMessage_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeRepeatedMessage(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedMessage_.Add(values); - return this; - } - public Builder ClearRepeatedMessage() { - PrepareBuilder(); - result.repeatedMessage_.Clear(); - return this; - } - - public bool HasDummy { - get { return result.hasDummy; } - } - public int Dummy { - get { return result.Dummy; } - set { SetDummy(value); } - } - public Builder SetDummy(int value) { - PrepareBuilder(); - result.hasDummy = true; - result.dummy_ = value; - return this; - } - public Builder ClearDummy() { - PrepareBuilder(); - result.hasDummy = false; - result.dummy_ = 0; - return this; - } - } - static TestRequiredForeign() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestForeignNested : pb::GeneratedMessage { - private TestForeignNested() { } - private static readonly TestForeignNested defaultInstance = new TestForeignNested().MakeReadOnly(); - private static readonly string[] _testForeignNestedFieldNames = new string[] { "foreign_nested" }; - private static readonly uint[] _testForeignNestedFieldTags = new uint[] { 10 }; - public static TestForeignNested DefaultInstance { - get { return defaultInstance; } - } - - public override TestForeignNested DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestForeignNested ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestForeignNested__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestForeignNested__FieldAccessorTable; } - } - - public const int ForeignNestedFieldNumber = 1; - private bool hasForeignNested; - private global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage foreignNested_; - public bool HasForeignNested { - get { return hasForeignNested; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage ForeignNested { - get { return foreignNested_ ?? global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.DefaultInstance; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testForeignNestedFieldNames; - if (hasForeignNested) { - output.WriteMessage(1, field_names[0], ForeignNested); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasForeignNested) { - size += pb::CodedOutputStream.ComputeMessageSize(1, ForeignNested); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestForeignNested ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestForeignNested ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestForeignNested ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestForeignNested ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestForeignNested ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestForeignNested ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestForeignNested ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestForeignNested ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestForeignNested ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestForeignNested ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestForeignNested MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestForeignNested prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestForeignNested cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestForeignNested result; - - private TestForeignNested PrepareBuilder() { - if (resultIsReadOnly) { - TestForeignNested original = result; - result = new TestForeignNested(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestForeignNested MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestForeignNested.Descriptor; } - } - - public override TestForeignNested DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestForeignNested.DefaultInstance; } - } - - public override TestForeignNested BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestForeignNested) { - return MergeFrom((TestForeignNested) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestForeignNested other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestForeignNested.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasForeignNested) { - MergeForeignNested(other.ForeignNested); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testForeignNestedFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testForeignNestedFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 10: { - global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.CreateBuilder(); - if (result.hasForeignNested) { - subBuilder.MergeFrom(ForeignNested); - } - input.ReadMessage(subBuilder, extensionRegistry); - ForeignNested = subBuilder.BuildPartial(); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasForeignNested { - get { return result.hasForeignNested; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage ForeignNested { - get { return result.ForeignNested; } - set { SetForeignNested(value); } - } - public Builder SetForeignNested(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasForeignNested = true; - result.foreignNested_ = value; - return this; - } - public Builder SetForeignNested(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasForeignNested = true; - result.foreignNested_ = builderForValue.Build(); - return this; - } - public Builder MergeForeignNested(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasForeignNested && - result.foreignNested_ != global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.DefaultInstance) { - result.foreignNested_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.CreateBuilder(result.foreignNested_).MergeFrom(value).BuildPartial(); - } else { - result.foreignNested_ = value; - } - result.hasForeignNested = true; - return this; - } - public Builder ClearForeignNested() { - PrepareBuilder(); - result.hasForeignNested = false; - result.foreignNested_ = null; - return this; - } - } - static TestForeignNested() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestEmptyMessage : pb::GeneratedMessage { - private TestEmptyMessage() { } - private static readonly TestEmptyMessage defaultInstance = new TestEmptyMessage().MakeReadOnly(); - private static readonly string[] _testEmptyMessageFieldNames = new string[] { }; - private static readonly uint[] _testEmptyMessageFieldTags = new uint[] { }; - public static TestEmptyMessage DefaultInstance { - get { return defaultInstance; } - } - - public override TestEmptyMessage DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestEmptyMessage ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestEmptyMessage__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestEmptyMessage__FieldAccessorTable; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testEmptyMessageFieldNames; - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestEmptyMessage ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestEmptyMessage ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestEmptyMessage ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestEmptyMessage ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestEmptyMessage ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestEmptyMessage ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestEmptyMessage ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestEmptyMessage ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestEmptyMessage ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestEmptyMessage ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestEmptyMessage MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestEmptyMessage prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestEmptyMessage cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestEmptyMessage result; - - private TestEmptyMessage PrepareBuilder() { - if (resultIsReadOnly) { - TestEmptyMessage original = result; - result = new TestEmptyMessage(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestEmptyMessage MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestEmptyMessage.Descriptor; } - } - - public override TestEmptyMessage DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestEmptyMessage.DefaultInstance; } - } - - public override TestEmptyMessage BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestEmptyMessage) { - return MergeFrom((TestEmptyMessage) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestEmptyMessage other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestEmptyMessage.DefaultInstance) return this; - PrepareBuilder(); - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testEmptyMessageFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testEmptyMessageFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - } - static TestEmptyMessage() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestEmptyMessageWithExtensions : pb::ExtendableMessage { - private TestEmptyMessageWithExtensions() { } - private static readonly TestEmptyMessageWithExtensions defaultInstance = new TestEmptyMessageWithExtensions().MakeReadOnly(); - private static readonly string[] _testEmptyMessageWithExtensionsFieldNames = new string[] { }; - private static readonly uint[] _testEmptyMessageWithExtensionsFieldTags = new uint[] { }; - public static TestEmptyMessageWithExtensions DefaultInstance { - get { return defaultInstance; } - } - - public override TestEmptyMessageWithExtensions DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestEmptyMessageWithExtensions ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestEmptyMessageWithExtensions__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestEmptyMessageWithExtensions__FieldAccessorTable; } - } - - public override bool IsInitialized { - get { - if (!ExtensionsAreInitialized) return false; - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testEmptyMessageWithExtensionsFieldNames; - pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); - extensionWriter.WriteUntil(536870912, output); - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - size += ExtensionsSerializedSize; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestEmptyMessageWithExtensions ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestEmptyMessageWithExtensions ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestEmptyMessageWithExtensions ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestEmptyMessageWithExtensions ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestEmptyMessageWithExtensions ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestEmptyMessageWithExtensions ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestEmptyMessageWithExtensions ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestEmptyMessageWithExtensions ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestEmptyMessageWithExtensions ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestEmptyMessageWithExtensions ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestEmptyMessageWithExtensions MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestEmptyMessageWithExtensions prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::ExtendableBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestEmptyMessageWithExtensions cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestEmptyMessageWithExtensions result; - - private TestEmptyMessageWithExtensions PrepareBuilder() { - if (resultIsReadOnly) { - TestEmptyMessageWithExtensions original = result; - result = new TestEmptyMessageWithExtensions(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestEmptyMessageWithExtensions MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestEmptyMessageWithExtensions.Descriptor; } - } - - public override TestEmptyMessageWithExtensions DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestEmptyMessageWithExtensions.DefaultInstance; } - } - - public override TestEmptyMessageWithExtensions BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestEmptyMessageWithExtensions) { - return MergeFrom((TestEmptyMessageWithExtensions) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestEmptyMessageWithExtensions other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestEmptyMessageWithExtensions.DefaultInstance) return this; - PrepareBuilder(); - this.MergeExtensionFields(other); - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testEmptyMessageWithExtensionsFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testEmptyMessageWithExtensionsFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - } - static TestEmptyMessageWithExtensions() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestMultipleExtensionRanges : pb::ExtendableMessage { - private TestMultipleExtensionRanges() { } - private static readonly TestMultipleExtensionRanges defaultInstance = new TestMultipleExtensionRanges().MakeReadOnly(); - private static readonly string[] _testMultipleExtensionRangesFieldNames = new string[] { }; - private static readonly uint[] _testMultipleExtensionRangesFieldTags = new uint[] { }; - public static TestMultipleExtensionRanges DefaultInstance { - get { return defaultInstance; } - } - - public override TestMultipleExtensionRanges DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestMultipleExtensionRanges ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestMultipleExtensionRanges__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestMultipleExtensionRanges__FieldAccessorTable; } - } - - public override bool IsInitialized { - get { - if (!ExtensionsAreInitialized) return false; - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testMultipleExtensionRangesFieldNames; - pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); - extensionWriter.WriteUntil(43, output); - extensionWriter.WriteUntil(4244, output); - extensionWriter.WriteUntil(536870912, output); - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - size += ExtensionsSerializedSize; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestMultipleExtensionRanges ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestMultipleExtensionRanges ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestMultipleExtensionRanges ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestMultipleExtensionRanges ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestMultipleExtensionRanges ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestMultipleExtensionRanges ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestMultipleExtensionRanges ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestMultipleExtensionRanges ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestMultipleExtensionRanges ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestMultipleExtensionRanges ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestMultipleExtensionRanges MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestMultipleExtensionRanges prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::ExtendableBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestMultipleExtensionRanges cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestMultipleExtensionRanges result; - - private TestMultipleExtensionRanges PrepareBuilder() { - if (resultIsReadOnly) { - TestMultipleExtensionRanges original = result; - result = new TestMultipleExtensionRanges(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestMultipleExtensionRanges MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestMultipleExtensionRanges.Descriptor; } - } - - public override TestMultipleExtensionRanges DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestMultipleExtensionRanges.DefaultInstance; } - } - - public override TestMultipleExtensionRanges BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestMultipleExtensionRanges) { - return MergeFrom((TestMultipleExtensionRanges) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestMultipleExtensionRanges other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestMultipleExtensionRanges.DefaultInstance) return this; - PrepareBuilder(); - this.MergeExtensionFields(other); - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testMultipleExtensionRangesFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testMultipleExtensionRangesFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - } - static TestMultipleExtensionRanges() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestReallyLargeTagNumber : pb::GeneratedMessage { - private TestReallyLargeTagNumber() { } - private static readonly TestReallyLargeTagNumber defaultInstance = new TestReallyLargeTagNumber().MakeReadOnly(); - private static readonly string[] _testReallyLargeTagNumberFieldNames = new string[] { "a", "bb" }; - private static readonly uint[] _testReallyLargeTagNumberFieldTags = new uint[] { 8, 2147483640 }; - public static TestReallyLargeTagNumber DefaultInstance { - get { return defaultInstance; } - } - - public override TestReallyLargeTagNumber DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestReallyLargeTagNumber ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestReallyLargeTagNumber__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestReallyLargeTagNumber__FieldAccessorTable; } - } - - public const int AFieldNumber = 1; - private bool hasA; - private int a_; - public bool HasA { - get { return hasA; } - } - public int A { - get { return a_; } - } - - public const int BbFieldNumber = 268435455; - private bool hasBb; - private int bb_; - public bool HasBb { - get { return hasBb; } - } - public int Bb { - get { return bb_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testReallyLargeTagNumberFieldNames; - if (hasA) { - output.WriteInt32(1, field_names[0], A); - } - if (hasBb) { - output.WriteInt32(268435455, field_names[1], Bb); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(1, A); - } - if (hasBb) { - size += pb::CodedOutputStream.ComputeInt32Size(268435455, Bb); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestReallyLargeTagNumber ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestReallyLargeTagNumber ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestReallyLargeTagNumber ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestReallyLargeTagNumber ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestReallyLargeTagNumber ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestReallyLargeTagNumber ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestReallyLargeTagNumber ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestReallyLargeTagNumber ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestReallyLargeTagNumber ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestReallyLargeTagNumber ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestReallyLargeTagNumber MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestReallyLargeTagNumber prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestReallyLargeTagNumber cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestReallyLargeTagNumber result; - - private TestReallyLargeTagNumber PrepareBuilder() { - if (resultIsReadOnly) { - TestReallyLargeTagNumber original = result; - result = new TestReallyLargeTagNumber(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestReallyLargeTagNumber MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestReallyLargeTagNumber.Descriptor; } - } - - public override TestReallyLargeTagNumber DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestReallyLargeTagNumber.DefaultInstance; } - } - - public override TestReallyLargeTagNumber BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestReallyLargeTagNumber) { - return MergeFrom((TestReallyLargeTagNumber) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestReallyLargeTagNumber other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestReallyLargeTagNumber.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasA) { - A = other.A; - } - if (other.HasBb) { - Bb = other.Bb; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testReallyLargeTagNumberFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testReallyLargeTagNumberFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasA = input.ReadInt32(ref result.a_); - break; - } - case 2147483640: { - result.hasBb = input.ReadInt32(ref result.bb_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasA { - get { return result.hasA; } - } - public int A { - get { return result.A; } - set { SetA(value); } - } - public Builder SetA(int value) { - PrepareBuilder(); - result.hasA = true; - result.a_ = value; - return this; - } - public Builder ClearA() { - PrepareBuilder(); - result.hasA = false; - result.a_ = 0; - return this; - } - - public bool HasBb { - get { return result.hasBb; } - } - public int Bb { - get { return result.Bb; } - set { SetBb(value); } - } - public Builder SetBb(int value) { - PrepareBuilder(); - result.hasBb = true; - result.bb_ = value; - return this; - } - public Builder ClearBb() { - PrepareBuilder(); - result.hasBb = false; - result.bb_ = 0; - return this; - } - } - static TestReallyLargeTagNumber() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestRecursiveMessage : pb::GeneratedMessage { - private TestRecursiveMessage() { } - private static readonly TestRecursiveMessage defaultInstance = new TestRecursiveMessage().MakeReadOnly(); - private static readonly string[] _testRecursiveMessageFieldNames = new string[] { "a", "i" }; - private static readonly uint[] _testRecursiveMessageFieldTags = new uint[] { 10, 16 }; - public static TestRecursiveMessage DefaultInstance { - get { return defaultInstance; } - } - - public override TestRecursiveMessage DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestRecursiveMessage ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestRecursiveMessage__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestRecursiveMessage__FieldAccessorTable; } - } - - public const int AFieldNumber = 1; - private bool hasA; - private global::Google.ProtocolBuffers.TestProtos.TestRecursiveMessage a_; - public bool HasA { - get { return hasA; } - } - public global::Google.ProtocolBuffers.TestProtos.TestRecursiveMessage A { - get { return a_ ?? global::Google.ProtocolBuffers.TestProtos.TestRecursiveMessage.DefaultInstance; } - } - - public const int IFieldNumber = 2; - private bool hasI; - private int i_; - public bool HasI { - get { return hasI; } - } - public int I { - get { return i_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testRecursiveMessageFieldNames; - if (hasA) { - output.WriteMessage(1, field_names[0], A); - } - if (hasI) { - output.WriteInt32(2, field_names[1], I); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeMessageSize(1, A); - } - if (hasI) { - size += pb::CodedOutputStream.ComputeInt32Size(2, I); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestRecursiveMessage ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestRecursiveMessage ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestRecursiveMessage ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestRecursiveMessage ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestRecursiveMessage ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestRecursiveMessage ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestRecursiveMessage ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestRecursiveMessage ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestRecursiveMessage ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestRecursiveMessage ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestRecursiveMessage MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestRecursiveMessage prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestRecursiveMessage cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestRecursiveMessage result; - - private TestRecursiveMessage PrepareBuilder() { - if (resultIsReadOnly) { - TestRecursiveMessage original = result; - result = new TestRecursiveMessage(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestRecursiveMessage MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestRecursiveMessage.Descriptor; } - } - - public override TestRecursiveMessage DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestRecursiveMessage.DefaultInstance; } - } - - public override TestRecursiveMessage BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestRecursiveMessage) { - return MergeFrom((TestRecursiveMessage) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestRecursiveMessage other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestRecursiveMessage.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasA) { - MergeA(other.A); - } - if (other.HasI) { - I = other.I; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testRecursiveMessageFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testRecursiveMessageFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 10: { - global::Google.ProtocolBuffers.TestProtos.TestRecursiveMessage.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestRecursiveMessage.CreateBuilder(); - if (result.hasA) { - subBuilder.MergeFrom(A); - } - input.ReadMessage(subBuilder, extensionRegistry); - A = subBuilder.BuildPartial(); - break; - } - case 16: { - result.hasI = input.ReadInt32(ref result.i_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasA { - get { return result.hasA; } - } - public global::Google.ProtocolBuffers.TestProtos.TestRecursiveMessage A { - get { return result.A; } - set { SetA(value); } - } - public Builder SetA(global::Google.ProtocolBuffers.TestProtos.TestRecursiveMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasA = true; - result.a_ = value; - return this; - } - public Builder SetA(global::Google.ProtocolBuffers.TestProtos.TestRecursiveMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasA = true; - result.a_ = builderForValue.Build(); - return this; - } - public Builder MergeA(global::Google.ProtocolBuffers.TestProtos.TestRecursiveMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasA && - result.a_ != global::Google.ProtocolBuffers.TestProtos.TestRecursiveMessage.DefaultInstance) { - result.a_ = global::Google.ProtocolBuffers.TestProtos.TestRecursiveMessage.CreateBuilder(result.a_).MergeFrom(value).BuildPartial(); - } else { - result.a_ = value; - } - result.hasA = true; - return this; - } - public Builder ClearA() { - PrepareBuilder(); - result.hasA = false; - result.a_ = null; - return this; - } - - public bool HasI { - get { return result.hasI; } - } - public int I { - get { return result.I; } - set { SetI(value); } - } - public Builder SetI(int value) { - PrepareBuilder(); - result.hasI = true; - result.i_ = value; - return this; - } - public Builder ClearI() { - PrepareBuilder(); - result.hasI = false; - result.i_ = 0; - return this; - } - } - static TestRecursiveMessage() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestMutualRecursionA : pb::GeneratedMessage { - private TestMutualRecursionA() { } - private static readonly TestMutualRecursionA defaultInstance = new TestMutualRecursionA().MakeReadOnly(); - private static readonly string[] _testMutualRecursionAFieldNames = new string[] { "bb" }; - private static readonly uint[] _testMutualRecursionAFieldTags = new uint[] { 10 }; - public static TestMutualRecursionA DefaultInstance { - get { return defaultInstance; } - } - - public override TestMutualRecursionA DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestMutualRecursionA ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestMutualRecursionA__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestMutualRecursionA__FieldAccessorTable; } - } - - public const int BbFieldNumber = 1; - private bool hasBb; - private global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionB bb_; - public bool HasBb { - get { return hasBb; } - } - public global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionB Bb { - get { return bb_ ?? global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionB.DefaultInstance; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testMutualRecursionAFieldNames; - if (hasBb) { - output.WriteMessage(1, field_names[0], Bb); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasBb) { - size += pb::CodedOutputStream.ComputeMessageSize(1, Bb); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestMutualRecursionA ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestMutualRecursionA ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestMutualRecursionA ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestMutualRecursionA ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestMutualRecursionA ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestMutualRecursionA ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestMutualRecursionA ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestMutualRecursionA ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestMutualRecursionA ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestMutualRecursionA ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestMutualRecursionA MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestMutualRecursionA prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestMutualRecursionA cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestMutualRecursionA result; - - private TestMutualRecursionA PrepareBuilder() { - if (resultIsReadOnly) { - TestMutualRecursionA original = result; - result = new TestMutualRecursionA(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestMutualRecursionA MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionA.Descriptor; } - } - - public override TestMutualRecursionA DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionA.DefaultInstance; } - } - - public override TestMutualRecursionA BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestMutualRecursionA) { - return MergeFrom((TestMutualRecursionA) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestMutualRecursionA other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionA.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasBb) { - MergeBb(other.Bb); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testMutualRecursionAFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testMutualRecursionAFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 10: { - global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionB.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionB.CreateBuilder(); - if (result.hasBb) { - subBuilder.MergeFrom(Bb); - } - input.ReadMessage(subBuilder, extensionRegistry); - Bb = subBuilder.BuildPartial(); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasBb { - get { return result.hasBb; } - } - public global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionB Bb { - get { return result.Bb; } - set { SetBb(value); } - } - public Builder SetBb(global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionB value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasBb = true; - result.bb_ = value; - return this; - } - public Builder SetBb(global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionB.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasBb = true; - result.bb_ = builderForValue.Build(); - return this; - } - public Builder MergeBb(global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionB value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasBb && - result.bb_ != global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionB.DefaultInstance) { - result.bb_ = global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionB.CreateBuilder(result.bb_).MergeFrom(value).BuildPartial(); - } else { - result.bb_ = value; - } - result.hasBb = true; - return this; - } - public Builder ClearBb() { - PrepareBuilder(); - result.hasBb = false; - result.bb_ = null; - return this; - } - } - static TestMutualRecursionA() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestMutualRecursionB : pb::GeneratedMessage { - private TestMutualRecursionB() { } - private static readonly TestMutualRecursionB defaultInstance = new TestMutualRecursionB().MakeReadOnly(); - private static readonly string[] _testMutualRecursionBFieldNames = new string[] { "a", "optional_int32" }; - private static readonly uint[] _testMutualRecursionBFieldTags = new uint[] { 10, 16 }; - public static TestMutualRecursionB DefaultInstance { - get { return defaultInstance; } - } - - public override TestMutualRecursionB DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestMutualRecursionB ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestMutualRecursionB__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestMutualRecursionB__FieldAccessorTable; } - } - - public const int AFieldNumber = 1; - private bool hasA; - private global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionA a_; - public bool HasA { - get { return hasA; } - } - public global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionA A { - get { return a_ ?? global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionA.DefaultInstance; } - } - - public const int OptionalInt32FieldNumber = 2; - private bool hasOptionalInt32; - private int optionalInt32_; - public bool HasOptionalInt32 { - get { return hasOptionalInt32; } - } - public int OptionalInt32 { - get { return optionalInt32_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testMutualRecursionBFieldNames; - if (hasA) { - output.WriteMessage(1, field_names[0], A); - } - if (hasOptionalInt32) { - output.WriteInt32(2, field_names[1], OptionalInt32); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeMessageSize(1, A); - } - if (hasOptionalInt32) { - size += pb::CodedOutputStream.ComputeInt32Size(2, OptionalInt32); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestMutualRecursionB ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestMutualRecursionB ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestMutualRecursionB ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestMutualRecursionB ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestMutualRecursionB ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestMutualRecursionB ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestMutualRecursionB ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestMutualRecursionB ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestMutualRecursionB ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestMutualRecursionB ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestMutualRecursionB MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestMutualRecursionB prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestMutualRecursionB cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestMutualRecursionB result; - - private TestMutualRecursionB PrepareBuilder() { - if (resultIsReadOnly) { - TestMutualRecursionB original = result; - result = new TestMutualRecursionB(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestMutualRecursionB MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionB.Descriptor; } - } - - public override TestMutualRecursionB DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionB.DefaultInstance; } - } - - public override TestMutualRecursionB BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestMutualRecursionB) { - return MergeFrom((TestMutualRecursionB) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestMutualRecursionB other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionB.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasA) { - MergeA(other.A); - } - if (other.HasOptionalInt32) { - OptionalInt32 = other.OptionalInt32; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testMutualRecursionBFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testMutualRecursionBFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 10: { - global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionA.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionA.CreateBuilder(); - if (result.hasA) { - subBuilder.MergeFrom(A); - } - input.ReadMessage(subBuilder, extensionRegistry); - A = subBuilder.BuildPartial(); - break; - } - case 16: { - result.hasOptionalInt32 = input.ReadInt32(ref result.optionalInt32_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasA { - get { return result.hasA; } - } - public global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionA A { - get { return result.A; } - set { SetA(value); } - } - public Builder SetA(global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionA value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasA = true; - result.a_ = value; - return this; - } - public Builder SetA(global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionA.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasA = true; - result.a_ = builderForValue.Build(); - return this; - } - public Builder MergeA(global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionA value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasA && - result.a_ != global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionA.DefaultInstance) { - result.a_ = global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionA.CreateBuilder(result.a_).MergeFrom(value).BuildPartial(); - } else { - result.a_ = value; - } - result.hasA = true; - return this; - } - public Builder ClearA() { - PrepareBuilder(); - result.hasA = false; - result.a_ = null; - return this; - } - - public bool HasOptionalInt32 { - get { return result.hasOptionalInt32; } - } - public int OptionalInt32 { - get { return result.OptionalInt32; } - set { SetOptionalInt32(value); } - } - public Builder SetOptionalInt32(int value) { - PrepareBuilder(); - result.hasOptionalInt32 = true; - result.optionalInt32_ = value; - return this; - } - public Builder ClearOptionalInt32() { - PrepareBuilder(); - result.hasOptionalInt32 = false; - result.optionalInt32_ = 0; - return this; - } - } - static TestMutualRecursionB() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestDupFieldNumber : pb::GeneratedMessage { - private TestDupFieldNumber() { } - private static readonly TestDupFieldNumber defaultInstance = new TestDupFieldNumber().MakeReadOnly(); - private static readonly string[] _testDupFieldNumberFieldNames = new string[] { "a", "bar", "foo" }; - private static readonly uint[] _testDupFieldNumberFieldTags = new uint[] { 8, 27, 19 }; - public static TestDupFieldNumber DefaultInstance { - get { return defaultInstance; } - } - - public override TestDupFieldNumber DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestDupFieldNumber ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestDupFieldNumber__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestDupFieldNumber__FieldAccessorTable; } - } - - #region Nested types - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class Types { - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Foo : pb::GeneratedMessage { - private Foo() { } - private static readonly Foo defaultInstance = new Foo().MakeReadOnly(); - private static readonly string[] _fooFieldNames = new string[] { "a" }; - private static readonly uint[] _fooFieldTags = new uint[] { 8 }; - public static Foo DefaultInstance { - get { return defaultInstance; } - } - - public override Foo DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override Foo ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestDupFieldNumber_Foo__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestDupFieldNumber_Foo__FieldAccessorTable; } - } - - public const int AFieldNumber = 1; - private bool hasA; - private int a_; - public bool HasA { - get { return hasA; } - } - public int A { - get { return a_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _fooFieldNames; - if (hasA) { - output.WriteInt32(1, field_names[0], A); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(1, A); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static Foo ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static Foo ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static Foo ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static Foo ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static Foo ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static Foo ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static Foo ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static Foo ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static Foo ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static Foo ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private Foo MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(Foo prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(Foo cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private Foo result; - - private Foo PrepareBuilder() { - if (resultIsReadOnly) { - Foo original = result; - result = new Foo(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override Foo MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Foo.Descriptor; } - } - - public override Foo DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Foo.DefaultInstance; } - } - - public override Foo BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is Foo) { - return MergeFrom((Foo) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(Foo other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Foo.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasA) { - A = other.A; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_fooFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _fooFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasA = input.ReadInt32(ref result.a_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasA { - get { return result.hasA; } - } - public int A { - get { return result.A; } - set { SetA(value); } - } - public Builder SetA(int value) { - PrepareBuilder(); - result.hasA = true; - result.a_ = value; - return this; - } - public Builder ClearA() { - PrepareBuilder(); - result.hasA = false; - result.a_ = 0; - return this; - } - } - static Foo() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Bar : pb::GeneratedMessage { - private Bar() { } - private static readonly Bar defaultInstance = new Bar().MakeReadOnly(); - private static readonly string[] _barFieldNames = new string[] { "a" }; - private static readonly uint[] _barFieldTags = new uint[] { 8 }; - public static Bar DefaultInstance { - get { return defaultInstance; } - } - - public override Bar DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override Bar ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestDupFieldNumber_Bar__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestDupFieldNumber_Bar__FieldAccessorTable; } - } - - public const int AFieldNumber = 1; - private bool hasA; - private int a_; - public bool HasA { - get { return hasA; } - } - public int A { - get { return a_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _barFieldNames; - if (hasA) { - output.WriteInt32(1, field_names[0], A); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(1, A); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static Bar ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static Bar ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static Bar ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static Bar ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static Bar ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static Bar ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static Bar ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static Bar ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static Bar ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static Bar ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private Bar MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(Bar prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(Bar cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private Bar result; - - private Bar PrepareBuilder() { - if (resultIsReadOnly) { - Bar original = result; - result = new Bar(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override Bar MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Bar.Descriptor; } - } - - public override Bar DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Bar.DefaultInstance; } - } - - public override Bar BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is Bar) { - return MergeFrom((Bar) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(Bar other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Bar.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasA) { - A = other.A; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_barFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _barFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasA = input.ReadInt32(ref result.a_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasA { - get { return result.hasA; } - } - public int A { - get { return result.A; } - set { SetA(value); } - } - public Builder SetA(int value) { - PrepareBuilder(); - result.hasA = true; - result.a_ = value; - return this; - } - public Builder ClearA() { - PrepareBuilder(); - result.hasA = false; - result.a_ = 0; - return this; - } - } - static Bar() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - } - #endregion - - public const int AFieldNumber = 1; - private bool hasA; - private int a_; - public bool HasA { - get { return hasA; } - } - public int A { - get { return a_; } - } - - public const int FooFieldNumber = 2; - private bool hasFoo; - private global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Foo foo_; - public bool HasFoo { - get { return hasFoo; } - } - public global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Foo Foo { - get { return foo_ ?? global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Foo.DefaultInstance; } - } - - public const int BarFieldNumber = 3; - private bool hasBar; - private global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Bar bar_; - public bool HasBar { - get { return hasBar; } - } - public global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Bar Bar { - get { return bar_ ?? global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Bar.DefaultInstance; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testDupFieldNumberFieldNames; - if (hasA) { - output.WriteInt32(1, field_names[0], A); - } - if (hasFoo) { - output.WriteGroup(2, field_names[2], Foo); - } - if (hasBar) { - output.WriteGroup(3, field_names[1], Bar); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(1, A); - } - if (hasFoo) { - size += pb::CodedOutputStream.ComputeGroupSize(2, Foo); - } - if (hasBar) { - size += pb::CodedOutputStream.ComputeGroupSize(3, Bar); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestDupFieldNumber ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestDupFieldNumber ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestDupFieldNumber ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestDupFieldNumber ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestDupFieldNumber ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestDupFieldNumber ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestDupFieldNumber ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestDupFieldNumber ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestDupFieldNumber ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestDupFieldNumber ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestDupFieldNumber MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestDupFieldNumber prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestDupFieldNumber cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestDupFieldNumber result; - - private TestDupFieldNumber PrepareBuilder() { - if (resultIsReadOnly) { - TestDupFieldNumber original = result; - result = new TestDupFieldNumber(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestDupFieldNumber MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Descriptor; } - } - - public override TestDupFieldNumber DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.DefaultInstance; } - } - - public override TestDupFieldNumber BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestDupFieldNumber) { - return MergeFrom((TestDupFieldNumber) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestDupFieldNumber other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasA) { - A = other.A; - } - if (other.HasFoo) { - MergeFoo(other.Foo); - } - if (other.HasBar) { - MergeBar(other.Bar); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testDupFieldNumberFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testDupFieldNumberFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasA = input.ReadInt32(ref result.a_); - break; - } - case 19: { - global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Foo.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Foo.CreateBuilder(); - if (result.hasFoo) { - subBuilder.MergeFrom(Foo); - } - input.ReadGroup(2, subBuilder, extensionRegistry); - Foo = subBuilder.BuildPartial(); - break; - } - case 27: { - global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Bar.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Bar.CreateBuilder(); - if (result.hasBar) { - subBuilder.MergeFrom(Bar); - } - input.ReadGroup(3, subBuilder, extensionRegistry); - Bar = subBuilder.BuildPartial(); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasA { - get { return result.hasA; } - } - public int A { - get { return result.A; } - set { SetA(value); } - } - public Builder SetA(int value) { - PrepareBuilder(); - result.hasA = true; - result.a_ = value; - return this; - } - public Builder ClearA() { - PrepareBuilder(); - result.hasA = false; - result.a_ = 0; - return this; - } - - public bool HasFoo { - get { return result.hasFoo; } - } - public global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Foo Foo { - get { return result.Foo; } - set { SetFoo(value); } - } - public Builder SetFoo(global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Foo value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasFoo = true; - result.foo_ = value; - return this; - } - public Builder SetFoo(global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Foo.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasFoo = true; - result.foo_ = builderForValue.Build(); - return this; - } - public Builder MergeFoo(global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Foo value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasFoo && - result.foo_ != global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Foo.DefaultInstance) { - result.foo_ = global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Foo.CreateBuilder(result.foo_).MergeFrom(value).BuildPartial(); - } else { - result.foo_ = value; - } - result.hasFoo = true; - return this; - } - public Builder ClearFoo() { - PrepareBuilder(); - result.hasFoo = false; - result.foo_ = null; - return this; - } - - public bool HasBar { - get { return result.hasBar; } - } - public global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Bar Bar { - get { return result.Bar; } - set { SetBar(value); } - } - public Builder SetBar(global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Bar value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasBar = true; - result.bar_ = value; - return this; - } - public Builder SetBar(global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Bar.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasBar = true; - result.bar_ = builderForValue.Build(); - return this; - } - public Builder MergeBar(global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Bar value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasBar && - result.bar_ != global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Bar.DefaultInstance) { - result.bar_ = global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Bar.CreateBuilder(result.bar_).MergeFrom(value).BuildPartial(); - } else { - result.bar_ = value; - } - result.hasBar = true; - return this; - } - public Builder ClearBar() { - PrepareBuilder(); - result.hasBar = false; - result.bar_ = null; - return this; - } - } - static TestDupFieldNumber() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestEagerMessage : pb::GeneratedMessage { - private TestEagerMessage() { } - private static readonly TestEagerMessage defaultInstance = new TestEagerMessage().MakeReadOnly(); - private static readonly string[] _testEagerMessageFieldNames = new string[] { "sub_message" }; - private static readonly uint[] _testEagerMessageFieldTags = new uint[] { 10 }; - public static TestEagerMessage DefaultInstance { - get { return defaultInstance; } - } - - public override TestEagerMessage DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestEagerMessage ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestEagerMessage__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestEagerMessage__FieldAccessorTable; } - } - - public const int SubMessageFieldNumber = 1; - private bool hasSubMessage; - private global::Google.ProtocolBuffers.TestProtos.TestAllTypes subMessage_; - public bool HasSubMessage { - get { return hasSubMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes SubMessage { - get { return subMessage_ ?? global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testEagerMessageFieldNames; - if (hasSubMessage) { - output.WriteMessage(1, field_names[0], SubMessage); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasSubMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(1, SubMessage); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestEagerMessage ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestEagerMessage ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestEagerMessage ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestEagerMessage ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestEagerMessage ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestEagerMessage ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestEagerMessage ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestEagerMessage ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestEagerMessage ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestEagerMessage ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestEagerMessage MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestEagerMessage prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestEagerMessage cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestEagerMessage result; - - private TestEagerMessage PrepareBuilder() { - if (resultIsReadOnly) { - TestEagerMessage original = result; - result = new TestEagerMessage(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestEagerMessage MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestEagerMessage.Descriptor; } - } - - public override TestEagerMessage DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestEagerMessage.DefaultInstance; } - } - - public override TestEagerMessage BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestEagerMessage) { - return MergeFrom((TestEagerMessage) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestEagerMessage other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestEagerMessage.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasSubMessage) { - MergeSubMessage(other.SubMessage); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testEagerMessageFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testEagerMessageFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 10: { - global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.CreateBuilder(); - if (result.hasSubMessage) { - subBuilder.MergeFrom(SubMessage); - } - input.ReadMessage(subBuilder, extensionRegistry); - SubMessage = subBuilder.BuildPartial(); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasSubMessage { - get { return result.hasSubMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes SubMessage { - get { return result.SubMessage; } - set { SetSubMessage(value); } - } - public Builder SetSubMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasSubMessage = true; - result.subMessage_ = value; - return this; - } - public Builder SetSubMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasSubMessage = true; - result.subMessage_ = builderForValue.Build(); - return this; - } - public Builder MergeSubMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasSubMessage && - result.subMessage_ != global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance) { - result.subMessage_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.CreateBuilder(result.subMessage_).MergeFrom(value).BuildPartial(); - } else { - result.subMessage_ = value; - } - result.hasSubMessage = true; - return this; - } - public Builder ClearSubMessage() { - PrepareBuilder(); - result.hasSubMessage = false; - result.subMessage_ = null; - return this; - } - } - static TestEagerMessage() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestLazyMessage : pb::GeneratedMessage { - private TestLazyMessage() { } - private static readonly TestLazyMessage defaultInstance = new TestLazyMessage().MakeReadOnly(); - private static readonly string[] _testLazyMessageFieldNames = new string[] { "sub_message" }; - private static readonly uint[] _testLazyMessageFieldTags = new uint[] { 10 }; - public static TestLazyMessage DefaultInstance { - get { return defaultInstance; } - } - - public override TestLazyMessage DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestLazyMessage ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestLazyMessage__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestLazyMessage__FieldAccessorTable; } - } - - public const int SubMessageFieldNumber = 1; - private bool hasSubMessage; - private global::Google.ProtocolBuffers.TestProtos.TestAllTypes subMessage_; - public bool HasSubMessage { - get { return hasSubMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes SubMessage { - get { return subMessage_ ?? global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testLazyMessageFieldNames; - if (hasSubMessage) { - output.WriteMessage(1, field_names[0], SubMessage); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasSubMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(1, SubMessage); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestLazyMessage ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestLazyMessage ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestLazyMessage ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestLazyMessage ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestLazyMessage ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestLazyMessage ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestLazyMessage ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestLazyMessage ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestLazyMessage ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestLazyMessage ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestLazyMessage MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestLazyMessage prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestLazyMessage cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestLazyMessage result; - - private TestLazyMessage PrepareBuilder() { - if (resultIsReadOnly) { - TestLazyMessage original = result; - result = new TestLazyMessage(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestLazyMessage MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestLazyMessage.Descriptor; } - } - - public override TestLazyMessage DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestLazyMessage.DefaultInstance; } - } - - public override TestLazyMessage BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestLazyMessage) { - return MergeFrom((TestLazyMessage) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestLazyMessage other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestLazyMessage.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasSubMessage) { - MergeSubMessage(other.SubMessage); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testLazyMessageFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testLazyMessageFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 10: { - global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.CreateBuilder(); - if (result.hasSubMessage) { - subBuilder.MergeFrom(SubMessage); - } - input.ReadMessage(subBuilder, extensionRegistry); - SubMessage = subBuilder.BuildPartial(); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasSubMessage { - get { return result.hasSubMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes SubMessage { - get { return result.SubMessage; } - set { SetSubMessage(value); } - } - public Builder SetSubMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasSubMessage = true; - result.subMessage_ = value; - return this; - } - public Builder SetSubMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasSubMessage = true; - result.subMessage_ = builderForValue.Build(); - return this; - } - public Builder MergeSubMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasSubMessage && - result.subMessage_ != global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance) { - result.subMessage_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.CreateBuilder(result.subMessage_).MergeFrom(value).BuildPartial(); - } else { - result.subMessage_ = value; - } - result.hasSubMessage = true; - return this; - } - public Builder ClearSubMessage() { - PrepareBuilder(); - result.hasSubMessage = false; - result.subMessage_ = null; - return this; - } - } - static TestLazyMessage() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestNestedMessageHasBits : pb::GeneratedMessage { - private TestNestedMessageHasBits() { } - private static readonly TestNestedMessageHasBits defaultInstance = new TestNestedMessageHasBits().MakeReadOnly(); - private static readonly string[] _testNestedMessageHasBitsFieldNames = new string[] { "optional_nested_message" }; - private static readonly uint[] _testNestedMessageHasBitsFieldTags = new uint[] { 10 }; - public static TestNestedMessageHasBits DefaultInstance { - get { return defaultInstance; } - } - - public override TestNestedMessageHasBits DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestNestedMessageHasBits ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestNestedMessageHasBits__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestNestedMessageHasBits__FieldAccessorTable; } - } - - #region Nested types - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class Types { - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class NestedMessage : pb::GeneratedMessage { - private NestedMessage() { } - private static readonly NestedMessage defaultInstance = new NestedMessage().MakeReadOnly(); - private static readonly string[] _nestedMessageFieldNames = new string[] { "nestedmessage_repeated_foreignmessage", "nestedmessage_repeated_int32" }; - private static readonly uint[] _nestedMessageFieldTags = new uint[] { 18, 8 }; - public static NestedMessage DefaultInstance { - get { return defaultInstance; } - } - - public override NestedMessage DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override NestedMessage ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestNestedMessageHasBits_NestedMessage__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestNestedMessageHasBits_NestedMessage__FieldAccessorTable; } - } - - public const int NestedmessageRepeatedInt32FieldNumber = 1; - private pbc::PopsicleList nestedmessageRepeatedInt32_ = new pbc::PopsicleList(); - public scg::IList NestedmessageRepeatedInt32List { - get { return pbc::Lists.AsReadOnly(nestedmessageRepeatedInt32_); } - } - public int NestedmessageRepeatedInt32Count { - get { return nestedmessageRepeatedInt32_.Count; } - } - public int GetNestedmessageRepeatedInt32(int index) { - return nestedmessageRepeatedInt32_[index]; - } - - public const int NestedmessageRepeatedForeignmessageFieldNumber = 2; - private pbc::PopsicleList nestedmessageRepeatedForeignmessage_ = new pbc::PopsicleList(); - public scg::IList NestedmessageRepeatedForeignmessageList { - get { return nestedmessageRepeatedForeignmessage_; } - } - public int NestedmessageRepeatedForeignmessageCount { - get { return nestedmessageRepeatedForeignmessage_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignMessage GetNestedmessageRepeatedForeignmessage(int index) { - return nestedmessageRepeatedForeignmessage_[index]; - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _nestedMessageFieldNames; - if (nestedmessageRepeatedInt32_.Count > 0) { - output.WriteInt32Array(1, field_names[1], nestedmessageRepeatedInt32_); - } - if (nestedmessageRepeatedForeignmessage_.Count > 0) { - output.WriteMessageArray(2, field_names[0], nestedmessageRepeatedForeignmessage_); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - { - int dataSize = 0; - foreach (int element in NestedmessageRepeatedInt32List) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); - } - size += dataSize; - size += 1 * nestedmessageRepeatedInt32_.Count; - } - foreach (global::Google.ProtocolBuffers.TestProtos.ForeignMessage element in NestedmessageRepeatedForeignmessageList) { - size += pb::CodedOutputStream.ComputeMessageSize(2, element); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static NestedMessage ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static NestedMessage ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static NestedMessage ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static NestedMessage ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static NestedMessage ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static NestedMessage ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static NestedMessage ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static NestedMessage ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static NestedMessage ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static NestedMessage ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private NestedMessage MakeReadOnly() { - nestedmessageRepeatedInt32_.MakeReadOnly(); - nestedmessageRepeatedForeignmessage_.MakeReadOnly(); - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(NestedMessage prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(NestedMessage cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private NestedMessage result; - - private NestedMessage PrepareBuilder() { - if (resultIsReadOnly) { - NestedMessage original = result; - result = new NestedMessage(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override NestedMessage MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestNestedMessageHasBits.Types.NestedMessage.Descriptor; } - } - - public override NestedMessage DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestNestedMessageHasBits.Types.NestedMessage.DefaultInstance; } - } - - public override NestedMessage BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is NestedMessage) { - return MergeFrom((NestedMessage) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(NestedMessage other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestNestedMessageHasBits.Types.NestedMessage.DefaultInstance) return this; - PrepareBuilder(); - if (other.nestedmessageRepeatedInt32_.Count != 0) { - result.nestedmessageRepeatedInt32_.Add(other.nestedmessageRepeatedInt32_); - } - if (other.nestedmessageRepeatedForeignmessage_.Count != 0) { - result.nestedmessageRepeatedForeignmessage_.Add(other.nestedmessageRepeatedForeignmessage_); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_nestedMessageFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _nestedMessageFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 10: - case 8: { - input.ReadInt32Array(tag, field_name, result.nestedmessageRepeatedInt32_); - break; - } - case 18: { - input.ReadMessageArray(tag, field_name, result.nestedmessageRepeatedForeignmessage_, global::Google.ProtocolBuffers.TestProtos.ForeignMessage.DefaultInstance, extensionRegistry); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public pbc::IPopsicleList NestedmessageRepeatedInt32List { - get { return PrepareBuilder().nestedmessageRepeatedInt32_; } - } - public int NestedmessageRepeatedInt32Count { - get { return result.NestedmessageRepeatedInt32Count; } - } - public int GetNestedmessageRepeatedInt32(int index) { - return result.GetNestedmessageRepeatedInt32(index); - } - public Builder SetNestedmessageRepeatedInt32(int index, int value) { - PrepareBuilder(); - result.nestedmessageRepeatedInt32_[index] = value; - return this; - } - public Builder AddNestedmessageRepeatedInt32(int value) { - PrepareBuilder(); - result.nestedmessageRepeatedInt32_.Add(value); - return this; - } - public Builder AddRangeNestedmessageRepeatedInt32(scg::IEnumerable values) { - PrepareBuilder(); - result.nestedmessageRepeatedInt32_.Add(values); - return this; - } - public Builder ClearNestedmessageRepeatedInt32() { - PrepareBuilder(); - result.nestedmessageRepeatedInt32_.Clear(); - return this; - } - - public pbc::IPopsicleList NestedmessageRepeatedForeignmessageList { - get { return PrepareBuilder().nestedmessageRepeatedForeignmessage_; } - } - public int NestedmessageRepeatedForeignmessageCount { - get { return result.NestedmessageRepeatedForeignmessageCount; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignMessage GetNestedmessageRepeatedForeignmessage(int index) { - return result.GetNestedmessageRepeatedForeignmessage(index); - } - public Builder SetNestedmessageRepeatedForeignmessage(int index, global::Google.ProtocolBuffers.TestProtos.ForeignMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.nestedmessageRepeatedForeignmessage_[index] = value; - return this; - } - public Builder SetNestedmessageRepeatedForeignmessage(int index, global::Google.ProtocolBuffers.TestProtos.ForeignMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.nestedmessageRepeatedForeignmessage_[index] = builderForValue.Build(); - return this; - } - public Builder AddNestedmessageRepeatedForeignmessage(global::Google.ProtocolBuffers.TestProtos.ForeignMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.nestedmessageRepeatedForeignmessage_.Add(value); - return this; - } - public Builder AddNestedmessageRepeatedForeignmessage(global::Google.ProtocolBuffers.TestProtos.ForeignMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.nestedmessageRepeatedForeignmessage_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeNestedmessageRepeatedForeignmessage(scg::IEnumerable values) { - PrepareBuilder(); - result.nestedmessageRepeatedForeignmessage_.Add(values); - return this; - } - public Builder ClearNestedmessageRepeatedForeignmessage() { - PrepareBuilder(); - result.nestedmessageRepeatedForeignmessage_.Clear(); - return this; - } - } - static NestedMessage() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - } - #endregion - - public const int OptionalNestedMessageFieldNumber = 1; - private bool hasOptionalNestedMessage; - private global::Google.ProtocolBuffers.TestProtos.TestNestedMessageHasBits.Types.NestedMessage optionalNestedMessage_; - public bool HasOptionalNestedMessage { - get { return hasOptionalNestedMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestNestedMessageHasBits.Types.NestedMessage OptionalNestedMessage { - get { return optionalNestedMessage_ ?? global::Google.ProtocolBuffers.TestProtos.TestNestedMessageHasBits.Types.NestedMessage.DefaultInstance; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testNestedMessageHasBitsFieldNames; - if (hasOptionalNestedMessage) { - output.WriteMessage(1, field_names[0], OptionalNestedMessage); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasOptionalNestedMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(1, OptionalNestedMessage); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestNestedMessageHasBits ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestNestedMessageHasBits ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestNestedMessageHasBits ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestNestedMessageHasBits ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestNestedMessageHasBits ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestNestedMessageHasBits ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestNestedMessageHasBits ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestNestedMessageHasBits ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestNestedMessageHasBits ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestNestedMessageHasBits ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestNestedMessageHasBits MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestNestedMessageHasBits prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestNestedMessageHasBits cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestNestedMessageHasBits result; - - private TestNestedMessageHasBits PrepareBuilder() { - if (resultIsReadOnly) { - TestNestedMessageHasBits original = result; - result = new TestNestedMessageHasBits(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestNestedMessageHasBits MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestNestedMessageHasBits.Descriptor; } - } - - public override TestNestedMessageHasBits DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestNestedMessageHasBits.DefaultInstance; } - } - - public override TestNestedMessageHasBits BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestNestedMessageHasBits) { - return MergeFrom((TestNestedMessageHasBits) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestNestedMessageHasBits other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestNestedMessageHasBits.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasOptionalNestedMessage) { - MergeOptionalNestedMessage(other.OptionalNestedMessage); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testNestedMessageHasBitsFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testNestedMessageHasBitsFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 10: { - global::Google.ProtocolBuffers.TestProtos.TestNestedMessageHasBits.Types.NestedMessage.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestNestedMessageHasBits.Types.NestedMessage.CreateBuilder(); - if (result.hasOptionalNestedMessage) { - subBuilder.MergeFrom(OptionalNestedMessage); - } - input.ReadMessage(subBuilder, extensionRegistry); - OptionalNestedMessage = subBuilder.BuildPartial(); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasOptionalNestedMessage { - get { return result.hasOptionalNestedMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestNestedMessageHasBits.Types.NestedMessage OptionalNestedMessage { - get { return result.OptionalNestedMessage; } - set { SetOptionalNestedMessage(value); } - } - public Builder SetOptionalNestedMessage(global::Google.ProtocolBuffers.TestProtos.TestNestedMessageHasBits.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOptionalNestedMessage = true; - result.optionalNestedMessage_ = value; - return this; - } - public Builder SetOptionalNestedMessage(global::Google.ProtocolBuffers.TestProtos.TestNestedMessageHasBits.Types.NestedMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasOptionalNestedMessage = true; - result.optionalNestedMessage_ = builderForValue.Build(); - return this; - } - public Builder MergeOptionalNestedMessage(global::Google.ProtocolBuffers.TestProtos.TestNestedMessageHasBits.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasOptionalNestedMessage && - result.optionalNestedMessage_ != global::Google.ProtocolBuffers.TestProtos.TestNestedMessageHasBits.Types.NestedMessage.DefaultInstance) { - result.optionalNestedMessage_ = global::Google.ProtocolBuffers.TestProtos.TestNestedMessageHasBits.Types.NestedMessage.CreateBuilder(result.optionalNestedMessage_).MergeFrom(value).BuildPartial(); - } else { - result.optionalNestedMessage_ = value; - } - result.hasOptionalNestedMessage = true; - return this; - } - public Builder ClearOptionalNestedMessage() { - PrepareBuilder(); - result.hasOptionalNestedMessage = false; - result.optionalNestedMessage_ = null; - return this; - } - } - static TestNestedMessageHasBits() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestCamelCaseFieldNames : pb::GeneratedMessage { - private TestCamelCaseFieldNames() { } - private static readonly TestCamelCaseFieldNames defaultInstance = new TestCamelCaseFieldNames().MakeReadOnly(); - private static readonly string[] _testCamelCaseFieldNamesFieldNames = new string[] { "CordField", "EnumField", "MessageField", "PrimitiveField", "RepeatedCordField", "RepeatedEnumField", "RepeatedMessageField", "RepeatedPrimitiveField", "RepeatedStringField", "RepeatedStringPieceField", "StringField", "StringPieceField" }; - private static readonly uint[] _testCamelCaseFieldNamesFieldTags = new uint[] { 50, 24, 34, 8, 98, 72, 82, 56, 66, 90, 18, 42 }; - public static TestCamelCaseFieldNames DefaultInstance { - get { return defaultInstance; } - } - - public override TestCamelCaseFieldNames DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestCamelCaseFieldNames ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestCamelCaseFieldNames__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestCamelCaseFieldNames__FieldAccessorTable; } - } - - public const int PrimitiveFieldFieldNumber = 1; - private bool hasPrimitiveField; - private int primitiveField_; - public bool HasPrimitiveField { - get { return hasPrimitiveField; } - } - public int PrimitiveField { - get { return primitiveField_; } - } - - public const int StringFieldFieldNumber = 2; - private bool hasStringField; - private string stringField_ = ""; - public bool HasStringField { - get { return hasStringField; } - } - public string StringField { - get { return stringField_; } - } - - public const int EnumFieldFieldNumber = 3; - private bool hasEnumField; - private global::Google.ProtocolBuffers.TestProtos.ForeignEnum enumField_ = global::Google.ProtocolBuffers.TestProtos.ForeignEnum.FOREIGN_FOO; - public bool HasEnumField { - get { return hasEnumField; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignEnum EnumField { - get { return enumField_; } - } - - public const int MessageFieldFieldNumber = 4; - private bool hasMessageField; - private global::Google.ProtocolBuffers.TestProtos.ForeignMessage messageField_; - public bool HasMessageField { - get { return hasMessageField; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignMessage MessageField { - get { return messageField_ ?? global::Google.ProtocolBuffers.TestProtos.ForeignMessage.DefaultInstance; } - } - - public const int StringPieceFieldFieldNumber = 5; - private bool hasStringPieceField; - private string stringPieceField_ = ""; - public bool HasStringPieceField { - get { return hasStringPieceField; } - } - public string StringPieceField { - get { return stringPieceField_; } - } - - public const int CordFieldFieldNumber = 6; - private bool hasCordField; - private string cordField_ = ""; - public bool HasCordField { - get { return hasCordField; } - } - public string CordField { - get { return cordField_; } - } - - public const int RepeatedPrimitiveFieldFieldNumber = 7; - private pbc::PopsicleList repeatedPrimitiveField_ = new pbc::PopsicleList(); - public scg::IList RepeatedPrimitiveFieldList { - get { return pbc::Lists.AsReadOnly(repeatedPrimitiveField_); } - } - public int RepeatedPrimitiveFieldCount { - get { return repeatedPrimitiveField_.Count; } - } - public int GetRepeatedPrimitiveField(int index) { - return repeatedPrimitiveField_[index]; - } - - public const int RepeatedStringFieldFieldNumber = 8; - private pbc::PopsicleList repeatedStringField_ = new pbc::PopsicleList(); - public scg::IList RepeatedStringFieldList { - get { return pbc::Lists.AsReadOnly(repeatedStringField_); } - } - public int RepeatedStringFieldCount { - get { return repeatedStringField_.Count; } - } - public string GetRepeatedStringField(int index) { - return repeatedStringField_[index]; - } - - public const int RepeatedEnumFieldFieldNumber = 9; - private pbc::PopsicleList repeatedEnumField_ = new pbc::PopsicleList(); - public scg::IList RepeatedEnumFieldList { - get { return pbc::Lists.AsReadOnly(repeatedEnumField_); } - } - public int RepeatedEnumFieldCount { - get { return repeatedEnumField_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignEnum GetRepeatedEnumField(int index) { - return repeatedEnumField_[index]; - } - - public const int RepeatedMessageFieldFieldNumber = 10; - private pbc::PopsicleList repeatedMessageField_ = new pbc::PopsicleList(); - public scg::IList RepeatedMessageFieldList { - get { return repeatedMessageField_; } - } - public int RepeatedMessageFieldCount { - get { return repeatedMessageField_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignMessage GetRepeatedMessageField(int index) { - return repeatedMessageField_[index]; - } - - public const int RepeatedStringPieceFieldFieldNumber = 11; - private pbc::PopsicleList repeatedStringPieceField_ = new pbc::PopsicleList(); - public scg::IList RepeatedStringPieceFieldList { - get { return pbc::Lists.AsReadOnly(repeatedStringPieceField_); } - } - public int RepeatedStringPieceFieldCount { - get { return repeatedStringPieceField_.Count; } - } - public string GetRepeatedStringPieceField(int index) { - return repeatedStringPieceField_[index]; - } - - public const int RepeatedCordFieldFieldNumber = 12; - private pbc::PopsicleList repeatedCordField_ = new pbc::PopsicleList(); - public scg::IList RepeatedCordFieldList { - get { return pbc::Lists.AsReadOnly(repeatedCordField_); } - } - public int RepeatedCordFieldCount { - get { return repeatedCordField_.Count; } - } - public string GetRepeatedCordField(int index) { - return repeatedCordField_[index]; - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testCamelCaseFieldNamesFieldNames; - if (hasPrimitiveField) { - output.WriteInt32(1, field_names[3], PrimitiveField); - } - if (hasStringField) { - output.WriteString(2, field_names[10], StringField); - } - if (hasEnumField) { - output.WriteEnum(3, field_names[1], (int) EnumField, EnumField); - } - if (hasMessageField) { - output.WriteMessage(4, field_names[2], MessageField); - } - if (hasStringPieceField) { - output.WriteString(5, field_names[11], StringPieceField); - } - if (hasCordField) { - output.WriteString(6, field_names[0], CordField); - } - if (repeatedPrimitiveField_.Count > 0) { - output.WriteInt32Array(7, field_names[7], repeatedPrimitiveField_); - } - if (repeatedStringField_.Count > 0) { - output.WriteStringArray(8, field_names[8], repeatedStringField_); - } - if (repeatedEnumField_.Count > 0) { - output.WriteEnumArray(9, field_names[5], repeatedEnumField_); - } - if (repeatedMessageField_.Count > 0) { - output.WriteMessageArray(10, field_names[6], repeatedMessageField_); - } - if (repeatedStringPieceField_.Count > 0) { - output.WriteStringArray(11, field_names[9], repeatedStringPieceField_); - } - if (repeatedCordField_.Count > 0) { - output.WriteStringArray(12, field_names[4], repeatedCordField_); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasPrimitiveField) { - size += pb::CodedOutputStream.ComputeInt32Size(1, PrimitiveField); - } - if (hasStringField) { - size += pb::CodedOutputStream.ComputeStringSize(2, StringField); - } - if (hasEnumField) { - size += pb::CodedOutputStream.ComputeEnumSize(3, (int) EnumField); - } - if (hasMessageField) { - size += pb::CodedOutputStream.ComputeMessageSize(4, MessageField); - } - if (hasStringPieceField) { - size += pb::CodedOutputStream.ComputeStringSize(5, StringPieceField); - } - if (hasCordField) { - size += pb::CodedOutputStream.ComputeStringSize(6, CordField); - } - { - int dataSize = 0; - foreach (int element in RepeatedPrimitiveFieldList) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); - } - size += dataSize; - size += 1 * repeatedPrimitiveField_.Count; - } - { - int dataSize = 0; - foreach (string element in RepeatedStringFieldList) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); - } - size += dataSize; - size += 1 * repeatedStringField_.Count; - } - { - int dataSize = 0; - if (repeatedEnumField_.Count > 0) { - foreach (global::Google.ProtocolBuffers.TestProtos.ForeignEnum element in repeatedEnumField_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 1 * repeatedEnumField_.Count; - } - } - foreach (global::Google.ProtocolBuffers.TestProtos.ForeignMessage element in RepeatedMessageFieldList) { - size += pb::CodedOutputStream.ComputeMessageSize(10, element); - } - { - int dataSize = 0; - foreach (string element in RepeatedStringPieceFieldList) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); - } - size += dataSize; - size += 1 * repeatedStringPieceField_.Count; - } - { - int dataSize = 0; - foreach (string element in RepeatedCordFieldList) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); - } - size += dataSize; - size += 1 * repeatedCordField_.Count; - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestCamelCaseFieldNames ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestCamelCaseFieldNames ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestCamelCaseFieldNames ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestCamelCaseFieldNames ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestCamelCaseFieldNames ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestCamelCaseFieldNames ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestCamelCaseFieldNames ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestCamelCaseFieldNames ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestCamelCaseFieldNames ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestCamelCaseFieldNames ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestCamelCaseFieldNames MakeReadOnly() { - repeatedPrimitiveField_.MakeReadOnly(); - repeatedStringField_.MakeReadOnly(); - repeatedEnumField_.MakeReadOnly(); - repeatedMessageField_.MakeReadOnly(); - repeatedStringPieceField_.MakeReadOnly(); - repeatedCordField_.MakeReadOnly(); - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestCamelCaseFieldNames prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestCamelCaseFieldNames cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestCamelCaseFieldNames result; - - private TestCamelCaseFieldNames PrepareBuilder() { - if (resultIsReadOnly) { - TestCamelCaseFieldNames original = result; - result = new TestCamelCaseFieldNames(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestCamelCaseFieldNames MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestCamelCaseFieldNames.Descriptor; } - } - - public override TestCamelCaseFieldNames DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestCamelCaseFieldNames.DefaultInstance; } - } - - public override TestCamelCaseFieldNames BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestCamelCaseFieldNames) { - return MergeFrom((TestCamelCaseFieldNames) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestCamelCaseFieldNames other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestCamelCaseFieldNames.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasPrimitiveField) { - PrimitiveField = other.PrimitiveField; - } - if (other.HasStringField) { - StringField = other.StringField; - } - if (other.HasEnumField) { - EnumField = other.EnumField; - } - if (other.HasMessageField) { - MergeMessageField(other.MessageField); - } - if (other.HasStringPieceField) { - StringPieceField = other.StringPieceField; - } - if (other.HasCordField) { - CordField = other.CordField; - } - if (other.repeatedPrimitiveField_.Count != 0) { - result.repeatedPrimitiveField_.Add(other.repeatedPrimitiveField_); - } - if (other.repeatedStringField_.Count != 0) { - result.repeatedStringField_.Add(other.repeatedStringField_); - } - if (other.repeatedEnumField_.Count != 0) { - result.repeatedEnumField_.Add(other.repeatedEnumField_); - } - if (other.repeatedMessageField_.Count != 0) { - result.repeatedMessageField_.Add(other.repeatedMessageField_); - } - if (other.repeatedStringPieceField_.Count != 0) { - result.repeatedStringPieceField_.Add(other.repeatedStringPieceField_); - } - if (other.repeatedCordField_.Count != 0) { - result.repeatedCordField_.Add(other.repeatedCordField_); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testCamelCaseFieldNamesFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testCamelCaseFieldNamesFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasPrimitiveField = input.ReadInt32(ref result.primitiveField_); - break; - } - case 18: { - result.hasStringField = input.ReadString(ref result.stringField_); - break; - } - case 24: { - object unknown; - if(input.ReadEnum(ref result.enumField_, out unknown)) { - result.hasEnumField = true; - } else if(unknown is int) { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - unknownFields.MergeVarintField(3, (ulong)(int)unknown); - } - break; - } - case 34: { - global::Google.ProtocolBuffers.TestProtos.ForeignMessage.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.ForeignMessage.CreateBuilder(); - if (result.hasMessageField) { - subBuilder.MergeFrom(MessageField); - } - input.ReadMessage(subBuilder, extensionRegistry); - MessageField = subBuilder.BuildPartial(); - break; - } - case 42: { - result.hasStringPieceField = input.ReadString(ref result.stringPieceField_); - break; - } - case 50: { - result.hasCordField = input.ReadString(ref result.cordField_); - break; - } - case 58: - case 56: { - input.ReadInt32Array(tag, field_name, result.repeatedPrimitiveField_); - break; - } - case 66: { - input.ReadStringArray(tag, field_name, result.repeatedStringField_); - break; - } - case 74: - case 72: { - scg::ICollection unknownItems; - input.ReadEnumArray(tag, field_name, result.repeatedEnumField_, out unknownItems); - if (unknownItems != null) { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - foreach (object rawValue in unknownItems) - if (rawValue is int) - unknownFields.MergeVarintField(9, (ulong)(int)rawValue); - } - break; - } - case 82: { - input.ReadMessageArray(tag, field_name, result.repeatedMessageField_, global::Google.ProtocolBuffers.TestProtos.ForeignMessage.DefaultInstance, extensionRegistry); - break; - } - case 90: { - input.ReadStringArray(tag, field_name, result.repeatedStringPieceField_); - break; - } - case 98: { - input.ReadStringArray(tag, field_name, result.repeatedCordField_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasPrimitiveField { - get { return result.hasPrimitiveField; } - } - public int PrimitiveField { - get { return result.PrimitiveField; } - set { SetPrimitiveField(value); } - } - public Builder SetPrimitiveField(int value) { - PrepareBuilder(); - result.hasPrimitiveField = true; - result.primitiveField_ = value; - return this; - } - public Builder ClearPrimitiveField() { - PrepareBuilder(); - result.hasPrimitiveField = false; - result.primitiveField_ = 0; - return this; - } - - public bool HasStringField { - get { return result.hasStringField; } - } - public string StringField { - get { return result.StringField; } - set { SetStringField(value); } - } - public Builder SetStringField(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasStringField = true; - result.stringField_ = value; - return this; - } - public Builder ClearStringField() { - PrepareBuilder(); - result.hasStringField = false; - result.stringField_ = ""; - return this; - } - - public bool HasEnumField { - get { return result.hasEnumField; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignEnum EnumField { - get { return result.EnumField; } - set { SetEnumField(value); } - } - public Builder SetEnumField(global::Google.ProtocolBuffers.TestProtos.ForeignEnum value) { - PrepareBuilder(); - result.hasEnumField = true; - result.enumField_ = value; - return this; - } - public Builder ClearEnumField() { - PrepareBuilder(); - result.hasEnumField = false; - result.enumField_ = global::Google.ProtocolBuffers.TestProtos.ForeignEnum.FOREIGN_FOO; - return this; - } - - public bool HasMessageField { - get { return result.hasMessageField; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignMessage MessageField { - get { return result.MessageField; } - set { SetMessageField(value); } - } - public Builder SetMessageField(global::Google.ProtocolBuffers.TestProtos.ForeignMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasMessageField = true; - result.messageField_ = value; - return this; - } - public Builder SetMessageField(global::Google.ProtocolBuffers.TestProtos.ForeignMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasMessageField = true; - result.messageField_ = builderForValue.Build(); - return this; - } - public Builder MergeMessageField(global::Google.ProtocolBuffers.TestProtos.ForeignMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasMessageField && - result.messageField_ != global::Google.ProtocolBuffers.TestProtos.ForeignMessage.DefaultInstance) { - result.messageField_ = global::Google.ProtocolBuffers.TestProtos.ForeignMessage.CreateBuilder(result.messageField_).MergeFrom(value).BuildPartial(); - } else { - result.messageField_ = value; - } - result.hasMessageField = true; - return this; - } - public Builder ClearMessageField() { - PrepareBuilder(); - result.hasMessageField = false; - result.messageField_ = null; - return this; - } - - public bool HasStringPieceField { - get { return result.hasStringPieceField; } - } - public string StringPieceField { - get { return result.StringPieceField; } - set { SetStringPieceField(value); } - } - public Builder SetStringPieceField(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasStringPieceField = true; - result.stringPieceField_ = value; - return this; - } - public Builder ClearStringPieceField() { - PrepareBuilder(); - result.hasStringPieceField = false; - result.stringPieceField_ = ""; - return this; - } - - public bool HasCordField { - get { return result.hasCordField; } - } - public string CordField { - get { return result.CordField; } - set { SetCordField(value); } - } - public Builder SetCordField(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasCordField = true; - result.cordField_ = value; - return this; - } - public Builder ClearCordField() { - PrepareBuilder(); - result.hasCordField = false; - result.cordField_ = ""; - return this; - } - - public pbc::IPopsicleList RepeatedPrimitiveFieldList { - get { return PrepareBuilder().repeatedPrimitiveField_; } - } - public int RepeatedPrimitiveFieldCount { - get { return result.RepeatedPrimitiveFieldCount; } - } - public int GetRepeatedPrimitiveField(int index) { - return result.GetRepeatedPrimitiveField(index); - } - public Builder SetRepeatedPrimitiveField(int index, int value) { - PrepareBuilder(); - result.repeatedPrimitiveField_[index] = value; - return this; - } - public Builder AddRepeatedPrimitiveField(int value) { - PrepareBuilder(); - result.repeatedPrimitiveField_.Add(value); - return this; - } - public Builder AddRangeRepeatedPrimitiveField(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedPrimitiveField_.Add(values); - return this; - } - public Builder ClearRepeatedPrimitiveField() { - PrepareBuilder(); - result.repeatedPrimitiveField_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedStringFieldList { - get { return PrepareBuilder().repeatedStringField_; } - } - public int RepeatedStringFieldCount { - get { return result.RepeatedStringFieldCount; } - } - public string GetRepeatedStringField(int index) { - return result.GetRepeatedStringField(index); - } - public Builder SetRepeatedStringField(int index, string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedStringField_[index] = value; - return this; - } - public Builder AddRepeatedStringField(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedStringField_.Add(value); - return this; - } - public Builder AddRangeRepeatedStringField(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedStringField_.Add(values); - return this; - } - public Builder ClearRepeatedStringField() { - PrepareBuilder(); - result.repeatedStringField_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedEnumFieldList { - get { return PrepareBuilder().repeatedEnumField_; } - } - public int RepeatedEnumFieldCount { - get { return result.RepeatedEnumFieldCount; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignEnum GetRepeatedEnumField(int index) { - return result.GetRepeatedEnumField(index); - } - public Builder SetRepeatedEnumField(int index, global::Google.ProtocolBuffers.TestProtos.ForeignEnum value) { - PrepareBuilder(); - result.repeatedEnumField_[index] = value; - return this; - } - public Builder AddRepeatedEnumField(global::Google.ProtocolBuffers.TestProtos.ForeignEnum value) { - PrepareBuilder(); - result.repeatedEnumField_.Add(value); - return this; - } - public Builder AddRangeRepeatedEnumField(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedEnumField_.Add(values); - return this; - } - public Builder ClearRepeatedEnumField() { - PrepareBuilder(); - result.repeatedEnumField_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedMessageFieldList { - get { return PrepareBuilder().repeatedMessageField_; } - } - public int RepeatedMessageFieldCount { - get { return result.RepeatedMessageFieldCount; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignMessage GetRepeatedMessageField(int index) { - return result.GetRepeatedMessageField(index); - } - public Builder SetRepeatedMessageField(int index, global::Google.ProtocolBuffers.TestProtos.ForeignMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedMessageField_[index] = value; - return this; - } - public Builder SetRepeatedMessageField(int index, global::Google.ProtocolBuffers.TestProtos.ForeignMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.repeatedMessageField_[index] = builderForValue.Build(); - return this; - } - public Builder AddRepeatedMessageField(global::Google.ProtocolBuffers.TestProtos.ForeignMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedMessageField_.Add(value); - return this; - } - public Builder AddRepeatedMessageField(global::Google.ProtocolBuffers.TestProtos.ForeignMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.repeatedMessageField_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeRepeatedMessageField(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedMessageField_.Add(values); - return this; - } - public Builder ClearRepeatedMessageField() { - PrepareBuilder(); - result.repeatedMessageField_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedStringPieceFieldList { - get { return PrepareBuilder().repeatedStringPieceField_; } - } - public int RepeatedStringPieceFieldCount { - get { return result.RepeatedStringPieceFieldCount; } - } - public string GetRepeatedStringPieceField(int index) { - return result.GetRepeatedStringPieceField(index); - } - public Builder SetRepeatedStringPieceField(int index, string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedStringPieceField_[index] = value; - return this; - } - public Builder AddRepeatedStringPieceField(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedStringPieceField_.Add(value); - return this; - } - public Builder AddRangeRepeatedStringPieceField(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedStringPieceField_.Add(values); - return this; - } - public Builder ClearRepeatedStringPieceField() { - PrepareBuilder(); - result.repeatedStringPieceField_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedCordFieldList { - get { return PrepareBuilder().repeatedCordField_; } - } - public int RepeatedCordFieldCount { - get { return result.RepeatedCordFieldCount; } - } - public string GetRepeatedCordField(int index) { - return result.GetRepeatedCordField(index); - } - public Builder SetRepeatedCordField(int index, string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedCordField_[index] = value; - return this; - } - public Builder AddRepeatedCordField(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedCordField_.Add(value); - return this; - } - public Builder AddRangeRepeatedCordField(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedCordField_.Add(values); - return this; - } - public Builder ClearRepeatedCordField() { - PrepareBuilder(); - result.repeatedCordField_.Clear(); - return this; - } - } - static TestCamelCaseFieldNames() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestFieldOrderings : pb::ExtendableMessage { - private TestFieldOrderings() { } - private static readonly TestFieldOrderings defaultInstance = new TestFieldOrderings().MakeReadOnly(); - private static readonly string[] _testFieldOrderingsFieldNames = new string[] { "my_float", "my_int", "my_string", "optional_nested_message" }; - private static readonly uint[] _testFieldOrderingsFieldTags = new uint[] { 813, 8, 90, 1602 }; - public static TestFieldOrderings DefaultInstance { - get { return defaultInstance; } - } - - public override TestFieldOrderings DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestFieldOrderings ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestFieldOrderings__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestFieldOrderings__FieldAccessorTable; } - } - - #region Nested types - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class Types { - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class NestedMessage : pb::GeneratedMessage { - private NestedMessage() { } - private static readonly NestedMessage defaultInstance = new NestedMessage().MakeReadOnly(); - private static readonly string[] _nestedMessageFieldNames = new string[] { "bb", "oo" }; - private static readonly uint[] _nestedMessageFieldTags = new uint[] { 8, 16 }; - public static NestedMessage DefaultInstance { - get { return defaultInstance; } - } - - public override NestedMessage DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override NestedMessage ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestFieldOrderings_NestedMessage__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestFieldOrderings_NestedMessage__FieldAccessorTable; } - } - - public const int OoFieldNumber = 2; - private bool hasOo; - private long oo_; - public bool HasOo { - get { return hasOo; } - } - public long Oo { - get { return oo_; } - } - - public const int BbFieldNumber = 1; - private bool hasBb; - private int bb_; - public bool HasBb { - get { return hasBb; } - } - public int Bb { - get { return bb_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _nestedMessageFieldNames; - if (hasBb) { - output.WriteInt32(1, field_names[0], Bb); - } - if (hasOo) { - output.WriteInt64(2, field_names[1], Oo); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasOo) { - size += pb::CodedOutputStream.ComputeInt64Size(2, Oo); - } - if (hasBb) { - size += pb::CodedOutputStream.ComputeInt32Size(1, Bb); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static NestedMessage ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static NestedMessage ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static NestedMessage ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static NestedMessage ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static NestedMessage ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static NestedMessage ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static NestedMessage ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static NestedMessage ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static NestedMessage ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static NestedMessage ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private NestedMessage MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(NestedMessage prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(NestedMessage cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private NestedMessage result; - - private NestedMessage PrepareBuilder() { - if (resultIsReadOnly) { - NestedMessage original = result; - result = new NestedMessage(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override NestedMessage MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestFieldOrderings.Types.NestedMessage.Descriptor; } - } - - public override NestedMessage DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestFieldOrderings.Types.NestedMessage.DefaultInstance; } - } - - public override NestedMessage BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is NestedMessage) { - return MergeFrom((NestedMessage) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(NestedMessage other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestFieldOrderings.Types.NestedMessage.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasOo) { - Oo = other.Oo; - } - if (other.HasBb) { - Bb = other.Bb; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_nestedMessageFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _nestedMessageFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasBb = input.ReadInt32(ref result.bb_); - break; - } - case 16: { - result.hasOo = input.ReadInt64(ref result.oo_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasOo { - get { return result.hasOo; } - } - public long Oo { - get { return result.Oo; } - set { SetOo(value); } - } - public Builder SetOo(long value) { - PrepareBuilder(); - result.hasOo = true; - result.oo_ = value; - return this; - } - public Builder ClearOo() { - PrepareBuilder(); - result.hasOo = false; - result.oo_ = 0L; - return this; - } - - public bool HasBb { - get { return result.hasBb; } - } - public int Bb { - get { return result.Bb; } - set { SetBb(value); } - } - public Builder SetBb(int value) { - PrepareBuilder(); - result.hasBb = true; - result.bb_ = value; - return this; - } - public Builder ClearBb() { - PrepareBuilder(); - result.hasBb = false; - result.bb_ = 0; - return this; - } - } - static NestedMessage() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - } - #endregion - - public const int MyStringFieldNumber = 11; - private bool hasMyString; - private string myString_ = ""; - public bool HasMyString { - get { return hasMyString; } - } - public string MyString { - get { return myString_; } - } - - public const int MyIntFieldNumber = 1; - private bool hasMyInt; - private long myInt_; - public bool HasMyInt { - get { return hasMyInt; } - } - public long MyInt { - get { return myInt_; } - } - - public const int MyFloatFieldNumber = 101; - private bool hasMyFloat; - private float myFloat_; - public bool HasMyFloat { - get { return hasMyFloat; } - } - public float MyFloat { - get { return myFloat_; } - } - - public const int OptionalNestedMessageFieldNumber = 200; - private bool hasOptionalNestedMessage; - private global::Google.ProtocolBuffers.TestProtos.TestFieldOrderings.Types.NestedMessage optionalNestedMessage_; - public bool HasOptionalNestedMessage { - get { return hasOptionalNestedMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestFieldOrderings.Types.NestedMessage OptionalNestedMessage { - get { return optionalNestedMessage_ ?? global::Google.ProtocolBuffers.TestProtos.TestFieldOrderings.Types.NestedMessage.DefaultInstance; } - } - - public override bool IsInitialized { - get { - if (!ExtensionsAreInitialized) return false; - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testFieldOrderingsFieldNames; - pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); - if (hasMyInt) { - output.WriteInt64(1, field_names[1], MyInt); - } - extensionWriter.WriteUntil(11, output); - if (hasMyString) { - output.WriteString(11, field_names[2], MyString); - } - extensionWriter.WriteUntil(101, output); - if (hasMyFloat) { - output.WriteFloat(101, field_names[0], MyFloat); - } - if (hasOptionalNestedMessage) { - output.WriteMessage(200, field_names[3], OptionalNestedMessage); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasMyString) { - size += pb::CodedOutputStream.ComputeStringSize(11, MyString); - } - if (hasMyInt) { - size += pb::CodedOutputStream.ComputeInt64Size(1, MyInt); - } - if (hasMyFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(101, MyFloat); - } - if (hasOptionalNestedMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(200, OptionalNestedMessage); - } - size += ExtensionsSerializedSize; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestFieldOrderings ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestFieldOrderings ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestFieldOrderings ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestFieldOrderings ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestFieldOrderings ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestFieldOrderings ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestFieldOrderings ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestFieldOrderings ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestFieldOrderings ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestFieldOrderings ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestFieldOrderings MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestFieldOrderings prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::ExtendableBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestFieldOrderings cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestFieldOrderings result; - - private TestFieldOrderings PrepareBuilder() { - if (resultIsReadOnly) { - TestFieldOrderings original = result; - result = new TestFieldOrderings(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestFieldOrderings MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestFieldOrderings.Descriptor; } - } - - public override TestFieldOrderings DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestFieldOrderings.DefaultInstance; } - } - - public override TestFieldOrderings BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestFieldOrderings) { - return MergeFrom((TestFieldOrderings) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestFieldOrderings other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestFieldOrderings.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasMyString) { - MyString = other.MyString; - } - if (other.HasMyInt) { - MyInt = other.MyInt; - } - if (other.HasMyFloat) { - MyFloat = other.MyFloat; - } - if (other.HasOptionalNestedMessage) { - MergeOptionalNestedMessage(other.OptionalNestedMessage); - } - this.MergeExtensionFields(other); - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testFieldOrderingsFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testFieldOrderingsFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasMyInt = input.ReadInt64(ref result.myInt_); - break; - } - case 90: { - result.hasMyString = input.ReadString(ref result.myString_); - break; - } - case 813: { - result.hasMyFloat = input.ReadFloat(ref result.myFloat_); - break; - } - case 1602: { - global::Google.ProtocolBuffers.TestProtos.TestFieldOrderings.Types.NestedMessage.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestFieldOrderings.Types.NestedMessage.CreateBuilder(); - if (result.hasOptionalNestedMessage) { - subBuilder.MergeFrom(OptionalNestedMessage); - } - input.ReadMessage(subBuilder, extensionRegistry); - OptionalNestedMessage = subBuilder.BuildPartial(); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasMyString { - get { return result.hasMyString; } - } - public string MyString { - get { return result.MyString; } - set { SetMyString(value); } - } - public Builder SetMyString(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasMyString = true; - result.myString_ = value; - return this; - } - public Builder ClearMyString() { - PrepareBuilder(); - result.hasMyString = false; - result.myString_ = ""; - return this; - } - - public bool HasMyInt { - get { return result.hasMyInt; } - } - public long MyInt { - get { return result.MyInt; } - set { SetMyInt(value); } - } - public Builder SetMyInt(long value) { - PrepareBuilder(); - result.hasMyInt = true; - result.myInt_ = value; - return this; - } - public Builder ClearMyInt() { - PrepareBuilder(); - result.hasMyInt = false; - result.myInt_ = 0L; - return this; - } - - public bool HasMyFloat { - get { return result.hasMyFloat; } - } - public float MyFloat { - get { return result.MyFloat; } - set { SetMyFloat(value); } - } - public Builder SetMyFloat(float value) { - PrepareBuilder(); - result.hasMyFloat = true; - result.myFloat_ = value; - return this; - } - public Builder ClearMyFloat() { - PrepareBuilder(); - result.hasMyFloat = false; - result.myFloat_ = 0F; - return this; - } - - public bool HasOptionalNestedMessage { - get { return result.hasOptionalNestedMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestFieldOrderings.Types.NestedMessage OptionalNestedMessage { - get { return result.OptionalNestedMessage; } - set { SetOptionalNestedMessage(value); } - } - public Builder SetOptionalNestedMessage(global::Google.ProtocolBuffers.TestProtos.TestFieldOrderings.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOptionalNestedMessage = true; - result.optionalNestedMessage_ = value; - return this; - } - public Builder SetOptionalNestedMessage(global::Google.ProtocolBuffers.TestProtos.TestFieldOrderings.Types.NestedMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasOptionalNestedMessage = true; - result.optionalNestedMessage_ = builderForValue.Build(); - return this; - } - public Builder MergeOptionalNestedMessage(global::Google.ProtocolBuffers.TestProtos.TestFieldOrderings.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasOptionalNestedMessage && - result.optionalNestedMessage_ != global::Google.ProtocolBuffers.TestProtos.TestFieldOrderings.Types.NestedMessage.DefaultInstance) { - result.optionalNestedMessage_ = global::Google.ProtocolBuffers.TestProtos.TestFieldOrderings.Types.NestedMessage.CreateBuilder(result.optionalNestedMessage_).MergeFrom(value).BuildPartial(); - } else { - result.optionalNestedMessage_ = value; - } - result.hasOptionalNestedMessage = true; - return this; - } - public Builder ClearOptionalNestedMessage() { - PrepareBuilder(); - result.hasOptionalNestedMessage = false; - result.optionalNestedMessage_ = null; - return this; - } - } - static TestFieldOrderings() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestExtremeDefaultValues : pb::GeneratedMessage { - private TestExtremeDefaultValues() { } - private static readonly TestExtremeDefaultValues defaultInstance = new TestExtremeDefaultValues().MakeReadOnly(); - private static readonly string[] _testExtremeDefaultValuesFieldNames = new string[] { "bytes_with_zero", "cord_with_zero", "cpp_trigraph", "escaped_bytes", "inf_double", "inf_float", "large_float", "large_uint32", "large_uint64", "nan_double", "nan_float", "neg_inf_double", "neg_inf_float", "negative_float", "negative_one_float", "one_float", "really_small_int32", "really_small_int64", "replacement_string", "small_float", "small_int32", "small_int64", "small_negative_float", "string_piece_with_zero", "string_with_zero", "utf8_string", "zero_float" }; - private static readonly uint[] _testExtremeDefaultValuesFieldTags = new uint[] { 194, 210, 162, 10, 113, 141, 101, 16, 24, 129, 157, 121, 149, 93, 85, 69, 168, 176, 218, 77, 32, 40, 109, 202, 186, 50, 61 }; - public static TestExtremeDefaultValues DefaultInstance { - get { return defaultInstance; } - } - - public override TestExtremeDefaultValues DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestExtremeDefaultValues ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestExtremeDefaultValues__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestExtremeDefaultValues__FieldAccessorTable; } - } - - public const int EscapedBytesFieldNumber = 1; - private bool hasEscapedBytes; - private pb::ByteString escapedBytes_ = (pb::ByteString) global::Google.ProtocolBuffers.TestProtos.TestExtremeDefaultValues.Descriptor.Fields[0].DefaultValue; - public bool HasEscapedBytes { - get { return hasEscapedBytes; } - } - public pb::ByteString EscapedBytes { - get { return escapedBytes_; } - } - - public const int LargeUint32FieldNumber = 2; - private bool hasLargeUint32; - private uint largeUint32_ = 4294967295; - public bool HasLargeUint32 { - get { return hasLargeUint32; } - } - public uint LargeUint32 { - get { return largeUint32_; } - } - - public const int LargeUint64FieldNumber = 3; - private bool hasLargeUint64; - private ulong largeUint64_ = 18446744073709551615UL; - public bool HasLargeUint64 { - get { return hasLargeUint64; } - } - public ulong LargeUint64 { - get { return largeUint64_; } - } - - public const int SmallInt32FieldNumber = 4; - private bool hasSmallInt32; - private int smallInt32_ = -2147483647; - public bool HasSmallInt32 { - get { return hasSmallInt32; } - } - public int SmallInt32 { - get { return smallInt32_; } - } - - public const int SmallInt64FieldNumber = 5; - private bool hasSmallInt64; - private long smallInt64_ = -9223372036854775807L; - public bool HasSmallInt64 { - get { return hasSmallInt64; } - } - public long SmallInt64 { - get { return smallInt64_; } - } - - public const int ReallySmallInt32FieldNumber = 21; - private bool hasReallySmallInt32; - private int reallySmallInt32_ = -2147483648; - public bool HasReallySmallInt32 { - get { return hasReallySmallInt32; } - } - public int ReallySmallInt32 { - get { return reallySmallInt32_; } - } - - public const int ReallySmallInt64FieldNumber = 22; - private bool hasReallySmallInt64; - private long reallySmallInt64_ = -9223372036854775808L; - public bool HasReallySmallInt64 { - get { return hasReallySmallInt64; } - } - public long ReallySmallInt64 { - get { return reallySmallInt64_; } - } - - public const int Utf8StringFieldNumber = 6; - private bool hasUtf8String; - private string utf8String_ = (string) global::Google.ProtocolBuffers.TestProtos.TestExtremeDefaultValues.Descriptor.Fields[7].DefaultValue; - public bool HasUtf8String { - get { return hasUtf8String; } - } - public string Utf8String { - get { return utf8String_; } - } - - public const int ZeroFloatFieldNumber = 7; - private bool hasZeroFloat; - private float zeroFloat_; - public bool HasZeroFloat { - get { return hasZeroFloat; } - } - public float ZeroFloat { - get { return zeroFloat_; } - } - - public const int OneFloatFieldNumber = 8; - private bool hasOneFloat; - private float oneFloat_ = 1F; - public bool HasOneFloat { - get { return hasOneFloat; } - } - public float OneFloat { - get { return oneFloat_; } - } - - public const int SmallFloatFieldNumber = 9; - private bool hasSmallFloat; - private float smallFloat_ = 1.5F; - public bool HasSmallFloat { - get { return hasSmallFloat; } - } - public float SmallFloat { - get { return smallFloat_; } - } - - public const int NegativeOneFloatFieldNumber = 10; - private bool hasNegativeOneFloat; - private float negativeOneFloat_ = -1F; - public bool HasNegativeOneFloat { - get { return hasNegativeOneFloat; } - } - public float NegativeOneFloat { - get { return negativeOneFloat_; } - } - - public const int NegativeFloatFieldNumber = 11; - private bool hasNegativeFloat; - private float negativeFloat_ = -1.5F; - public bool HasNegativeFloat { - get { return hasNegativeFloat; } - } - public float NegativeFloat { - get { return negativeFloat_; } - } - - public const int LargeFloatFieldNumber = 12; - private bool hasLargeFloat; - private float largeFloat_ = 2e+08F; - public bool HasLargeFloat { - get { return hasLargeFloat; } - } - public float LargeFloat { - get { return largeFloat_; } - } - - public const int SmallNegativeFloatFieldNumber = 13; - private bool hasSmallNegativeFloat; - private float smallNegativeFloat_ = -8e-28F; - public bool HasSmallNegativeFloat { - get { return hasSmallNegativeFloat; } - } - public float SmallNegativeFloat { - get { return smallNegativeFloat_; } - } - - public const int InfDoubleFieldNumber = 14; - private bool hasInfDouble; - private double infDouble_ = double.PositiveInfinity; - public bool HasInfDouble { - get { return hasInfDouble; } - } - public double InfDouble { - get { return infDouble_; } - } - - public const int NegInfDoubleFieldNumber = 15; - private bool hasNegInfDouble; - private double negInfDouble_ = double.NegativeInfinity; - public bool HasNegInfDouble { - get { return hasNegInfDouble; } - } - public double NegInfDouble { - get { return negInfDouble_; } - } - - public const int NanDoubleFieldNumber = 16; - private bool hasNanDouble; - private double nanDouble_ = double.NaN; - public bool HasNanDouble { - get { return hasNanDouble; } - } - public double NanDouble { - get { return nanDouble_; } - } - - public const int InfFloatFieldNumber = 17; - private bool hasInfFloat; - private float infFloat_ = float.PositiveInfinity; - public bool HasInfFloat { - get { return hasInfFloat; } - } - public float InfFloat { - get { return infFloat_; } - } - - public const int NegInfFloatFieldNumber = 18; - private bool hasNegInfFloat; - private float negInfFloat_ = float.NegativeInfinity; - public bool HasNegInfFloat { - get { return hasNegInfFloat; } - } - public float NegInfFloat { - get { return negInfFloat_; } - } - - public const int NanFloatFieldNumber = 19; - private bool hasNanFloat; - private float nanFloat_ = float.NaN; - public bool HasNanFloat { - get { return hasNanFloat; } - } - public float NanFloat { - get { return nanFloat_; } - } - - public const int CppTrigraphFieldNumber = 20; - private bool hasCppTrigraph; - private string cppTrigraph_ = "? ? ?? ?? ??? ??/ ??-"; - public bool HasCppTrigraph { - get { return hasCppTrigraph; } - } - public string CppTrigraph { - get { return cppTrigraph_; } - } - - public const int StringWithZeroFieldNumber = 23; - private bool hasStringWithZero; - private string stringWithZero_ = (string) global::Google.ProtocolBuffers.TestProtos.TestExtremeDefaultValues.Descriptor.Fields[22].DefaultValue; - public bool HasStringWithZero { - get { return hasStringWithZero; } - } - public string StringWithZero { - get { return stringWithZero_; } - } - - public const int BytesWithZeroFieldNumber = 24; - private bool hasBytesWithZero; - private pb::ByteString bytesWithZero_ = (pb::ByteString) global::Google.ProtocolBuffers.TestProtos.TestExtremeDefaultValues.Descriptor.Fields[23].DefaultValue; - public bool HasBytesWithZero { - get { return hasBytesWithZero; } - } - public pb::ByteString BytesWithZero { - get { return bytesWithZero_; } - } - - public const int StringPieceWithZeroFieldNumber = 25; - private bool hasStringPieceWithZero; - private string stringPieceWithZero_ = (string) global::Google.ProtocolBuffers.TestProtos.TestExtremeDefaultValues.Descriptor.Fields[24].DefaultValue; - public bool HasStringPieceWithZero { - get { return hasStringPieceWithZero; } - } - public string StringPieceWithZero { - get { return stringPieceWithZero_; } - } - - public const int CordWithZeroFieldNumber = 26; - private bool hasCordWithZero; - private string cordWithZero_ = (string) global::Google.ProtocolBuffers.TestProtos.TestExtremeDefaultValues.Descriptor.Fields[25].DefaultValue; - public bool HasCordWithZero { - get { return hasCordWithZero; } - } - public string CordWithZero { - get { return cordWithZero_; } - } - - public const int ReplacementStringFieldNumber = 27; - private bool hasReplacementString; - private string replacementString_ = "${unknown}"; - public bool HasReplacementString { - get { return hasReplacementString; } - } - public string ReplacementString { - get { return replacementString_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testExtremeDefaultValuesFieldNames; - if (hasEscapedBytes) { - output.WriteBytes(1, field_names[3], EscapedBytes); - } - if (hasLargeUint32) { - output.WriteUInt32(2, field_names[7], LargeUint32); - } - if (hasLargeUint64) { - output.WriteUInt64(3, field_names[8], LargeUint64); - } - if (hasSmallInt32) { - output.WriteInt32(4, field_names[20], SmallInt32); - } - if (hasSmallInt64) { - output.WriteInt64(5, field_names[21], SmallInt64); - } - if (hasUtf8String) { - output.WriteString(6, field_names[25], Utf8String); - } - if (hasZeroFloat) { - output.WriteFloat(7, field_names[26], ZeroFloat); - } - if (hasOneFloat) { - output.WriteFloat(8, field_names[15], OneFloat); - } - if (hasSmallFloat) { - output.WriteFloat(9, field_names[19], SmallFloat); - } - if (hasNegativeOneFloat) { - output.WriteFloat(10, field_names[14], NegativeOneFloat); - } - if (hasNegativeFloat) { - output.WriteFloat(11, field_names[13], NegativeFloat); - } - if (hasLargeFloat) { - output.WriteFloat(12, field_names[6], LargeFloat); - } - if (hasSmallNegativeFloat) { - output.WriteFloat(13, field_names[22], SmallNegativeFloat); - } - if (hasInfDouble) { - output.WriteDouble(14, field_names[4], InfDouble); - } - if (hasNegInfDouble) { - output.WriteDouble(15, field_names[11], NegInfDouble); - } - if (hasNanDouble) { - output.WriteDouble(16, field_names[9], NanDouble); - } - if (hasInfFloat) { - output.WriteFloat(17, field_names[5], InfFloat); - } - if (hasNegInfFloat) { - output.WriteFloat(18, field_names[12], NegInfFloat); - } - if (hasNanFloat) { - output.WriteFloat(19, field_names[10], NanFloat); - } - if (hasCppTrigraph) { - output.WriteString(20, field_names[2], CppTrigraph); - } - if (hasReallySmallInt32) { - output.WriteInt32(21, field_names[16], ReallySmallInt32); - } - if (hasReallySmallInt64) { - output.WriteInt64(22, field_names[17], ReallySmallInt64); - } - if (hasStringWithZero) { - output.WriteString(23, field_names[24], StringWithZero); - } - if (hasBytesWithZero) { - output.WriteBytes(24, field_names[0], BytesWithZero); - } - if (hasStringPieceWithZero) { - output.WriteString(25, field_names[23], StringPieceWithZero); - } - if (hasCordWithZero) { - output.WriteString(26, field_names[1], CordWithZero); - } - if (hasReplacementString) { - output.WriteString(27, field_names[18], ReplacementString); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasEscapedBytes) { - size += pb::CodedOutputStream.ComputeBytesSize(1, EscapedBytes); - } - if (hasLargeUint32) { - size += pb::CodedOutputStream.ComputeUInt32Size(2, LargeUint32); - } - if (hasLargeUint64) { - size += pb::CodedOutputStream.ComputeUInt64Size(3, LargeUint64); - } - if (hasSmallInt32) { - size += pb::CodedOutputStream.ComputeInt32Size(4, SmallInt32); - } - if (hasSmallInt64) { - size += pb::CodedOutputStream.ComputeInt64Size(5, SmallInt64); - } - if (hasReallySmallInt32) { - size += pb::CodedOutputStream.ComputeInt32Size(21, ReallySmallInt32); - } - if (hasReallySmallInt64) { - size += pb::CodedOutputStream.ComputeInt64Size(22, ReallySmallInt64); - } - if (hasUtf8String) { - size += pb::CodedOutputStream.ComputeStringSize(6, Utf8String); - } - if (hasZeroFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(7, ZeroFloat); - } - if (hasOneFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(8, OneFloat); - } - if (hasSmallFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(9, SmallFloat); - } - if (hasNegativeOneFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(10, NegativeOneFloat); - } - if (hasNegativeFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(11, NegativeFloat); - } - if (hasLargeFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(12, LargeFloat); - } - if (hasSmallNegativeFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(13, SmallNegativeFloat); - } - if (hasInfDouble) { - size += pb::CodedOutputStream.ComputeDoubleSize(14, InfDouble); - } - if (hasNegInfDouble) { - size += pb::CodedOutputStream.ComputeDoubleSize(15, NegInfDouble); - } - if (hasNanDouble) { - size += pb::CodedOutputStream.ComputeDoubleSize(16, NanDouble); - } - if (hasInfFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(17, InfFloat); - } - if (hasNegInfFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(18, NegInfFloat); - } - if (hasNanFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(19, NanFloat); - } - if (hasCppTrigraph) { - size += pb::CodedOutputStream.ComputeStringSize(20, CppTrigraph); - } - if (hasStringWithZero) { - size += pb::CodedOutputStream.ComputeStringSize(23, StringWithZero); - } - if (hasBytesWithZero) { - size += pb::CodedOutputStream.ComputeBytesSize(24, BytesWithZero); - } - if (hasStringPieceWithZero) { - size += pb::CodedOutputStream.ComputeStringSize(25, StringPieceWithZero); - } - if (hasCordWithZero) { - size += pb::CodedOutputStream.ComputeStringSize(26, CordWithZero); - } - if (hasReplacementString) { - size += pb::CodedOutputStream.ComputeStringSize(27, ReplacementString); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestExtremeDefaultValues ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestExtremeDefaultValues ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestExtremeDefaultValues ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestExtremeDefaultValues ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestExtremeDefaultValues ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestExtremeDefaultValues ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestExtremeDefaultValues ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestExtremeDefaultValues ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestExtremeDefaultValues ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestExtremeDefaultValues ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestExtremeDefaultValues MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestExtremeDefaultValues prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestExtremeDefaultValues cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestExtremeDefaultValues result; - - private TestExtremeDefaultValues PrepareBuilder() { - if (resultIsReadOnly) { - TestExtremeDefaultValues original = result; - result = new TestExtremeDefaultValues(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestExtremeDefaultValues MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestExtremeDefaultValues.Descriptor; } - } - - public override TestExtremeDefaultValues DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestExtremeDefaultValues.DefaultInstance; } - } - - public override TestExtremeDefaultValues BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestExtremeDefaultValues) { - return MergeFrom((TestExtremeDefaultValues) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestExtremeDefaultValues other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestExtremeDefaultValues.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasEscapedBytes) { - EscapedBytes = other.EscapedBytes; - } - if (other.HasLargeUint32) { - LargeUint32 = other.LargeUint32; - } - if (other.HasLargeUint64) { - LargeUint64 = other.LargeUint64; - } - if (other.HasSmallInt32) { - SmallInt32 = other.SmallInt32; - } - if (other.HasSmallInt64) { - SmallInt64 = other.SmallInt64; - } - if (other.HasReallySmallInt32) { - ReallySmallInt32 = other.ReallySmallInt32; - } - if (other.HasReallySmallInt64) { - ReallySmallInt64 = other.ReallySmallInt64; - } - if (other.HasUtf8String) { - Utf8String = other.Utf8String; - } - if (other.HasZeroFloat) { - ZeroFloat = other.ZeroFloat; - } - if (other.HasOneFloat) { - OneFloat = other.OneFloat; - } - if (other.HasSmallFloat) { - SmallFloat = other.SmallFloat; - } - if (other.HasNegativeOneFloat) { - NegativeOneFloat = other.NegativeOneFloat; - } - if (other.HasNegativeFloat) { - NegativeFloat = other.NegativeFloat; - } - if (other.HasLargeFloat) { - LargeFloat = other.LargeFloat; - } - if (other.HasSmallNegativeFloat) { - SmallNegativeFloat = other.SmallNegativeFloat; - } - if (other.HasInfDouble) { - InfDouble = other.InfDouble; - } - if (other.HasNegInfDouble) { - NegInfDouble = other.NegInfDouble; - } - if (other.HasNanDouble) { - NanDouble = other.NanDouble; - } - if (other.HasInfFloat) { - InfFloat = other.InfFloat; - } - if (other.HasNegInfFloat) { - NegInfFloat = other.NegInfFloat; - } - if (other.HasNanFloat) { - NanFloat = other.NanFloat; - } - if (other.HasCppTrigraph) { - CppTrigraph = other.CppTrigraph; - } - if (other.HasStringWithZero) { - StringWithZero = other.StringWithZero; - } - if (other.HasBytesWithZero) { - BytesWithZero = other.BytesWithZero; - } - if (other.HasStringPieceWithZero) { - StringPieceWithZero = other.StringPieceWithZero; - } - if (other.HasCordWithZero) { - CordWithZero = other.CordWithZero; - } - if (other.HasReplacementString) { - ReplacementString = other.ReplacementString; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testExtremeDefaultValuesFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testExtremeDefaultValuesFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 10: { - result.hasEscapedBytes = input.ReadBytes(ref result.escapedBytes_); - break; - } - case 16: { - result.hasLargeUint32 = input.ReadUInt32(ref result.largeUint32_); - break; - } - case 24: { - result.hasLargeUint64 = input.ReadUInt64(ref result.largeUint64_); - break; - } - case 32: { - result.hasSmallInt32 = input.ReadInt32(ref result.smallInt32_); - break; - } - case 40: { - result.hasSmallInt64 = input.ReadInt64(ref result.smallInt64_); - break; - } - case 50: { - result.hasUtf8String = input.ReadString(ref result.utf8String_); - break; - } - case 61: { - result.hasZeroFloat = input.ReadFloat(ref result.zeroFloat_); - break; - } - case 69: { - result.hasOneFloat = input.ReadFloat(ref result.oneFloat_); - break; - } - case 77: { - result.hasSmallFloat = input.ReadFloat(ref result.smallFloat_); - break; - } - case 85: { - result.hasNegativeOneFloat = input.ReadFloat(ref result.negativeOneFloat_); - break; - } - case 93: { - result.hasNegativeFloat = input.ReadFloat(ref result.negativeFloat_); - break; - } - case 101: { - result.hasLargeFloat = input.ReadFloat(ref result.largeFloat_); - break; - } - case 109: { - result.hasSmallNegativeFloat = input.ReadFloat(ref result.smallNegativeFloat_); - break; - } - case 113: { - result.hasInfDouble = input.ReadDouble(ref result.infDouble_); - break; - } - case 121: { - result.hasNegInfDouble = input.ReadDouble(ref result.negInfDouble_); - break; - } - case 129: { - result.hasNanDouble = input.ReadDouble(ref result.nanDouble_); - break; - } - case 141: { - result.hasInfFloat = input.ReadFloat(ref result.infFloat_); - break; - } - case 149: { - result.hasNegInfFloat = input.ReadFloat(ref result.negInfFloat_); - break; - } - case 157: { - result.hasNanFloat = input.ReadFloat(ref result.nanFloat_); - break; - } - case 162: { - result.hasCppTrigraph = input.ReadString(ref result.cppTrigraph_); - break; - } - case 168: { - result.hasReallySmallInt32 = input.ReadInt32(ref result.reallySmallInt32_); - break; - } - case 176: { - result.hasReallySmallInt64 = input.ReadInt64(ref result.reallySmallInt64_); - break; - } - case 186: { - result.hasStringWithZero = input.ReadString(ref result.stringWithZero_); - break; - } - case 194: { - result.hasBytesWithZero = input.ReadBytes(ref result.bytesWithZero_); - break; - } - case 202: { - result.hasStringPieceWithZero = input.ReadString(ref result.stringPieceWithZero_); - break; - } - case 210: { - result.hasCordWithZero = input.ReadString(ref result.cordWithZero_); - break; - } - case 218: { - result.hasReplacementString = input.ReadString(ref result.replacementString_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasEscapedBytes { - get { return result.hasEscapedBytes; } - } - public pb::ByteString EscapedBytes { - get { return result.EscapedBytes; } - set { SetEscapedBytes(value); } - } - public Builder SetEscapedBytes(pb::ByteString value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasEscapedBytes = true; - result.escapedBytes_ = value; - return this; - } - public Builder ClearEscapedBytes() { - PrepareBuilder(); - result.hasEscapedBytes = false; - result.escapedBytes_ = (pb::ByteString) global::Google.ProtocolBuffers.TestProtos.TestExtremeDefaultValues.Descriptor.Fields[0].DefaultValue; - return this; - } - - public bool HasLargeUint32 { - get { return result.hasLargeUint32; } - } - public uint LargeUint32 { - get { return result.LargeUint32; } - set { SetLargeUint32(value); } - } - public Builder SetLargeUint32(uint value) { - PrepareBuilder(); - result.hasLargeUint32 = true; - result.largeUint32_ = value; - return this; - } - public Builder ClearLargeUint32() { - PrepareBuilder(); - result.hasLargeUint32 = false; - result.largeUint32_ = 4294967295; - return this; - } - - public bool HasLargeUint64 { - get { return result.hasLargeUint64; } - } - public ulong LargeUint64 { - get { return result.LargeUint64; } - set { SetLargeUint64(value); } - } - public Builder SetLargeUint64(ulong value) { - PrepareBuilder(); - result.hasLargeUint64 = true; - result.largeUint64_ = value; - return this; - } - public Builder ClearLargeUint64() { - PrepareBuilder(); - result.hasLargeUint64 = false; - result.largeUint64_ = 18446744073709551615UL; - return this; - } - - public bool HasSmallInt32 { - get { return result.hasSmallInt32; } - } - public int SmallInt32 { - get { return result.SmallInt32; } - set { SetSmallInt32(value); } - } - public Builder SetSmallInt32(int value) { - PrepareBuilder(); - result.hasSmallInt32 = true; - result.smallInt32_ = value; - return this; - } - public Builder ClearSmallInt32() { - PrepareBuilder(); - result.hasSmallInt32 = false; - result.smallInt32_ = -2147483647; - return this; - } - - public bool HasSmallInt64 { - get { return result.hasSmallInt64; } - } - public long SmallInt64 { - get { return result.SmallInt64; } - set { SetSmallInt64(value); } - } - public Builder SetSmallInt64(long value) { - PrepareBuilder(); - result.hasSmallInt64 = true; - result.smallInt64_ = value; - return this; - } - public Builder ClearSmallInt64() { - PrepareBuilder(); - result.hasSmallInt64 = false; - result.smallInt64_ = -9223372036854775807L; - return this; - } - - public bool HasReallySmallInt32 { - get { return result.hasReallySmallInt32; } - } - public int ReallySmallInt32 { - get { return result.ReallySmallInt32; } - set { SetReallySmallInt32(value); } - } - public Builder SetReallySmallInt32(int value) { - PrepareBuilder(); - result.hasReallySmallInt32 = true; - result.reallySmallInt32_ = value; - return this; - } - public Builder ClearReallySmallInt32() { - PrepareBuilder(); - result.hasReallySmallInt32 = false; - result.reallySmallInt32_ = -2147483648; - return this; - } - - public bool HasReallySmallInt64 { - get { return result.hasReallySmallInt64; } - } - public long ReallySmallInt64 { - get { return result.ReallySmallInt64; } - set { SetReallySmallInt64(value); } - } - public Builder SetReallySmallInt64(long value) { - PrepareBuilder(); - result.hasReallySmallInt64 = true; - result.reallySmallInt64_ = value; - return this; - } - public Builder ClearReallySmallInt64() { - PrepareBuilder(); - result.hasReallySmallInt64 = false; - result.reallySmallInt64_ = -9223372036854775808L; - return this; - } - - public bool HasUtf8String { - get { return result.hasUtf8String; } - } - public string Utf8String { - get { return result.Utf8String; } - set { SetUtf8String(value); } - } - public Builder SetUtf8String(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasUtf8String = true; - result.utf8String_ = value; - return this; - } - public Builder ClearUtf8String() { - PrepareBuilder(); - result.hasUtf8String = false; - result.utf8String_ = (string) global::Google.ProtocolBuffers.TestProtos.TestExtremeDefaultValues.Descriptor.Fields[7].DefaultValue; - return this; - } - - public bool HasZeroFloat { - get { return result.hasZeroFloat; } - } - public float ZeroFloat { - get { return result.ZeroFloat; } - set { SetZeroFloat(value); } - } - public Builder SetZeroFloat(float value) { - PrepareBuilder(); - result.hasZeroFloat = true; - result.zeroFloat_ = value; - return this; - } - public Builder ClearZeroFloat() { - PrepareBuilder(); - result.hasZeroFloat = false; - result.zeroFloat_ = 0F; - return this; - } - - public bool HasOneFloat { - get { return result.hasOneFloat; } - } - public float OneFloat { - get { return result.OneFloat; } - set { SetOneFloat(value); } - } - public Builder SetOneFloat(float value) { - PrepareBuilder(); - result.hasOneFloat = true; - result.oneFloat_ = value; - return this; - } - public Builder ClearOneFloat() { - PrepareBuilder(); - result.hasOneFloat = false; - result.oneFloat_ = 1F; - return this; - } - - public bool HasSmallFloat { - get { return result.hasSmallFloat; } - } - public float SmallFloat { - get { return result.SmallFloat; } - set { SetSmallFloat(value); } - } - public Builder SetSmallFloat(float value) { - PrepareBuilder(); - result.hasSmallFloat = true; - result.smallFloat_ = value; - return this; - } - public Builder ClearSmallFloat() { - PrepareBuilder(); - result.hasSmallFloat = false; - result.smallFloat_ = 1.5F; - return this; - } - - public bool HasNegativeOneFloat { - get { return result.hasNegativeOneFloat; } - } - public float NegativeOneFloat { - get { return result.NegativeOneFloat; } - set { SetNegativeOneFloat(value); } - } - public Builder SetNegativeOneFloat(float value) { - PrepareBuilder(); - result.hasNegativeOneFloat = true; - result.negativeOneFloat_ = value; - return this; - } - public Builder ClearNegativeOneFloat() { - PrepareBuilder(); - result.hasNegativeOneFloat = false; - result.negativeOneFloat_ = -1F; - return this; - } - - public bool HasNegativeFloat { - get { return result.hasNegativeFloat; } - } - public float NegativeFloat { - get { return result.NegativeFloat; } - set { SetNegativeFloat(value); } - } - public Builder SetNegativeFloat(float value) { - PrepareBuilder(); - result.hasNegativeFloat = true; - result.negativeFloat_ = value; - return this; - } - public Builder ClearNegativeFloat() { - PrepareBuilder(); - result.hasNegativeFloat = false; - result.negativeFloat_ = -1.5F; - return this; - } - - public bool HasLargeFloat { - get { return result.hasLargeFloat; } - } - public float LargeFloat { - get { return result.LargeFloat; } - set { SetLargeFloat(value); } - } - public Builder SetLargeFloat(float value) { - PrepareBuilder(); - result.hasLargeFloat = true; - result.largeFloat_ = value; - return this; - } - public Builder ClearLargeFloat() { - PrepareBuilder(); - result.hasLargeFloat = false; - result.largeFloat_ = 2e+08F; - return this; - } - - public bool HasSmallNegativeFloat { - get { return result.hasSmallNegativeFloat; } - } - public float SmallNegativeFloat { - get { return result.SmallNegativeFloat; } - set { SetSmallNegativeFloat(value); } - } - public Builder SetSmallNegativeFloat(float value) { - PrepareBuilder(); - result.hasSmallNegativeFloat = true; - result.smallNegativeFloat_ = value; - return this; - } - public Builder ClearSmallNegativeFloat() { - PrepareBuilder(); - result.hasSmallNegativeFloat = false; - result.smallNegativeFloat_ = -8e-28F; - return this; - } - - public bool HasInfDouble { - get { return result.hasInfDouble; } - } - public double InfDouble { - get { return result.InfDouble; } - set { SetInfDouble(value); } - } - public Builder SetInfDouble(double value) { - PrepareBuilder(); - result.hasInfDouble = true; - result.infDouble_ = value; - return this; - } - public Builder ClearInfDouble() { - PrepareBuilder(); - result.hasInfDouble = false; - result.infDouble_ = double.PositiveInfinity; - return this; - } - - public bool HasNegInfDouble { - get { return result.hasNegInfDouble; } - } - public double NegInfDouble { - get { return result.NegInfDouble; } - set { SetNegInfDouble(value); } - } - public Builder SetNegInfDouble(double value) { - PrepareBuilder(); - result.hasNegInfDouble = true; - result.negInfDouble_ = value; - return this; - } - public Builder ClearNegInfDouble() { - PrepareBuilder(); - result.hasNegInfDouble = false; - result.negInfDouble_ = double.NegativeInfinity; - return this; - } - - public bool HasNanDouble { - get { return result.hasNanDouble; } - } - public double NanDouble { - get { return result.NanDouble; } - set { SetNanDouble(value); } - } - public Builder SetNanDouble(double value) { - PrepareBuilder(); - result.hasNanDouble = true; - result.nanDouble_ = value; - return this; - } - public Builder ClearNanDouble() { - PrepareBuilder(); - result.hasNanDouble = false; - result.nanDouble_ = double.NaN; - return this; - } - - public bool HasInfFloat { - get { return result.hasInfFloat; } - } - public float InfFloat { - get { return result.InfFloat; } - set { SetInfFloat(value); } - } - public Builder SetInfFloat(float value) { - PrepareBuilder(); - result.hasInfFloat = true; - result.infFloat_ = value; - return this; - } - public Builder ClearInfFloat() { - PrepareBuilder(); - result.hasInfFloat = false; - result.infFloat_ = float.PositiveInfinity; - return this; - } - - public bool HasNegInfFloat { - get { return result.hasNegInfFloat; } - } - public float NegInfFloat { - get { return result.NegInfFloat; } - set { SetNegInfFloat(value); } - } - public Builder SetNegInfFloat(float value) { - PrepareBuilder(); - result.hasNegInfFloat = true; - result.negInfFloat_ = value; - return this; - } - public Builder ClearNegInfFloat() { - PrepareBuilder(); - result.hasNegInfFloat = false; - result.negInfFloat_ = float.NegativeInfinity; - return this; - } - - public bool HasNanFloat { - get { return result.hasNanFloat; } - } - public float NanFloat { - get { return result.NanFloat; } - set { SetNanFloat(value); } - } - public Builder SetNanFloat(float value) { - PrepareBuilder(); - result.hasNanFloat = true; - result.nanFloat_ = value; - return this; - } - public Builder ClearNanFloat() { - PrepareBuilder(); - result.hasNanFloat = false; - result.nanFloat_ = float.NaN; - return this; - } - - public bool HasCppTrigraph { - get { return result.hasCppTrigraph; } - } - public string CppTrigraph { - get { return result.CppTrigraph; } - set { SetCppTrigraph(value); } - } - public Builder SetCppTrigraph(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasCppTrigraph = true; - result.cppTrigraph_ = value; - return this; - } - public Builder ClearCppTrigraph() { - PrepareBuilder(); - result.hasCppTrigraph = false; - result.cppTrigraph_ = "? ? ?? ?? ??? ??/ ??-"; - return this; - } - - public bool HasStringWithZero { - get { return result.hasStringWithZero; } - } - public string StringWithZero { - get { return result.StringWithZero; } - set { SetStringWithZero(value); } - } - public Builder SetStringWithZero(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasStringWithZero = true; - result.stringWithZero_ = value; - return this; - } - public Builder ClearStringWithZero() { - PrepareBuilder(); - result.hasStringWithZero = false; - result.stringWithZero_ = (string) global::Google.ProtocolBuffers.TestProtos.TestExtremeDefaultValues.Descriptor.Fields[22].DefaultValue; - return this; - } - - public bool HasBytesWithZero { - get { return result.hasBytesWithZero; } - } - public pb::ByteString BytesWithZero { - get { return result.BytesWithZero; } - set { SetBytesWithZero(value); } - } - public Builder SetBytesWithZero(pb::ByteString value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasBytesWithZero = true; - result.bytesWithZero_ = value; - return this; - } - public Builder ClearBytesWithZero() { - PrepareBuilder(); - result.hasBytesWithZero = false; - result.bytesWithZero_ = (pb::ByteString) global::Google.ProtocolBuffers.TestProtos.TestExtremeDefaultValues.Descriptor.Fields[23].DefaultValue; - return this; - } - - public bool HasStringPieceWithZero { - get { return result.hasStringPieceWithZero; } - } - public string StringPieceWithZero { - get { return result.StringPieceWithZero; } - set { SetStringPieceWithZero(value); } - } - public Builder SetStringPieceWithZero(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasStringPieceWithZero = true; - result.stringPieceWithZero_ = value; - return this; - } - public Builder ClearStringPieceWithZero() { - PrepareBuilder(); - result.hasStringPieceWithZero = false; - result.stringPieceWithZero_ = (string) global::Google.ProtocolBuffers.TestProtos.TestExtremeDefaultValues.Descriptor.Fields[24].DefaultValue; - return this; - } - - public bool HasCordWithZero { - get { return result.hasCordWithZero; } - } - public string CordWithZero { - get { return result.CordWithZero; } - set { SetCordWithZero(value); } - } - public Builder SetCordWithZero(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasCordWithZero = true; - result.cordWithZero_ = value; - return this; - } - public Builder ClearCordWithZero() { - PrepareBuilder(); - result.hasCordWithZero = false; - result.cordWithZero_ = (string) global::Google.ProtocolBuffers.TestProtos.TestExtremeDefaultValues.Descriptor.Fields[25].DefaultValue; - return this; - } - - public bool HasReplacementString { - get { return result.hasReplacementString; } - } - public string ReplacementString { - get { return result.ReplacementString; } - set { SetReplacementString(value); } - } - public Builder SetReplacementString(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasReplacementString = true; - result.replacementString_ = value; - return this; - } - public Builder ClearReplacementString() { - PrepareBuilder(); - result.hasReplacementString = false; - result.replacementString_ = "${unknown}"; - return this; - } - } - static TestExtremeDefaultValues() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class SparseEnumMessage : pb::GeneratedMessage { - private SparseEnumMessage() { } - private static readonly SparseEnumMessage defaultInstance = new SparseEnumMessage().MakeReadOnly(); - private static readonly string[] _sparseEnumMessageFieldNames = new string[] { "sparse_enum" }; - private static readonly uint[] _sparseEnumMessageFieldTags = new uint[] { 8 }; - public static SparseEnumMessage DefaultInstance { - get { return defaultInstance; } - } - - public override SparseEnumMessage DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override SparseEnumMessage ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_SparseEnumMessage__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_SparseEnumMessage__FieldAccessorTable; } - } - - public const int SparseEnumFieldNumber = 1; - private bool hasSparseEnum; - private global::Google.ProtocolBuffers.TestProtos.TestSparseEnum sparseEnum_ = global::Google.ProtocolBuffers.TestProtos.TestSparseEnum.SPARSE_A; - public bool HasSparseEnum { - get { return hasSparseEnum; } - } - public global::Google.ProtocolBuffers.TestProtos.TestSparseEnum SparseEnum { - get { return sparseEnum_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _sparseEnumMessageFieldNames; - if (hasSparseEnum) { - output.WriteEnum(1, field_names[0], (int) SparseEnum, SparseEnum); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasSparseEnum) { - size += pb::CodedOutputStream.ComputeEnumSize(1, (int) SparseEnum); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static SparseEnumMessage ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static SparseEnumMessage ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static SparseEnumMessage ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static SparseEnumMessage ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static SparseEnumMessage ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static SparseEnumMessage ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static SparseEnumMessage ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static SparseEnumMessage ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static SparseEnumMessage ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static SparseEnumMessage ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private SparseEnumMessage MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(SparseEnumMessage prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(SparseEnumMessage cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private SparseEnumMessage result; - - private SparseEnumMessage PrepareBuilder() { - if (resultIsReadOnly) { - SparseEnumMessage original = result; - result = new SparseEnumMessage(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override SparseEnumMessage MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.SparseEnumMessage.Descriptor; } - } - - public override SparseEnumMessage DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.SparseEnumMessage.DefaultInstance; } - } - - public override SparseEnumMessage BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is SparseEnumMessage) { - return MergeFrom((SparseEnumMessage) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(SparseEnumMessage other) { - if (other == global::Google.ProtocolBuffers.TestProtos.SparseEnumMessage.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasSparseEnum) { - SparseEnum = other.SparseEnum; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_sparseEnumMessageFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _sparseEnumMessageFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - object unknown; - if(input.ReadEnum(ref result.sparseEnum_, out unknown)) { - result.hasSparseEnum = true; - } else if(unknown is int) { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - unknownFields.MergeVarintField(1, (ulong)(int)unknown); - } - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasSparseEnum { - get { return result.hasSparseEnum; } - } - public global::Google.ProtocolBuffers.TestProtos.TestSparseEnum SparseEnum { - get { return result.SparseEnum; } - set { SetSparseEnum(value); } - } - public Builder SetSparseEnum(global::Google.ProtocolBuffers.TestProtos.TestSparseEnum value) { - PrepareBuilder(); - result.hasSparseEnum = true; - result.sparseEnum_ = value; - return this; - } - public Builder ClearSparseEnum() { - PrepareBuilder(); - result.hasSparseEnum = false; - result.sparseEnum_ = global::Google.ProtocolBuffers.TestProtos.TestSparseEnum.SPARSE_A; - return this; - } - } - static SparseEnumMessage() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class OneString : pb::GeneratedMessage { - private OneString() { } - private static readonly OneString defaultInstance = new OneString().MakeReadOnly(); - private static readonly string[] _oneStringFieldNames = new string[] { "data" }; - private static readonly uint[] _oneStringFieldTags = new uint[] { 10 }; - public static OneString DefaultInstance { - get { return defaultInstance; } - } - - public override OneString DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override OneString ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_OneString__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_OneString__FieldAccessorTable; } - } - - public const int DataFieldNumber = 1; - private bool hasData; - private string data_ = ""; - public bool HasData { - get { return hasData; } - } - public string Data { - get { return data_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _oneStringFieldNames; - if (hasData) { - output.WriteString(1, field_names[0], Data); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasData) { - size += pb::CodedOutputStream.ComputeStringSize(1, Data); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static OneString ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static OneString ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static OneString ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static OneString ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static OneString ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static OneString ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static OneString ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static OneString ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static OneString ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static OneString ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private OneString MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(OneString prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(OneString cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private OneString result; - - private OneString PrepareBuilder() { - if (resultIsReadOnly) { - OneString original = result; - result = new OneString(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override OneString MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.OneString.Descriptor; } - } - - public override OneString DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.OneString.DefaultInstance; } - } - - public override OneString BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is OneString) { - return MergeFrom((OneString) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(OneString other) { - if (other == global::Google.ProtocolBuffers.TestProtos.OneString.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasData) { - Data = other.Data; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_oneStringFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _oneStringFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 10: { - result.hasData = input.ReadString(ref result.data_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasData { - get { return result.hasData; } - } - public string Data { - get { return result.Data; } - set { SetData(value); } - } - public Builder SetData(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasData = true; - result.data_ = value; - return this; - } - public Builder ClearData() { - PrepareBuilder(); - result.hasData = false; - result.data_ = ""; - return this; - } - } - static OneString() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MoreString : pb::GeneratedMessage { - private MoreString() { } - private static readonly MoreString defaultInstance = new MoreString().MakeReadOnly(); - private static readonly string[] _moreStringFieldNames = new string[] { "data" }; - private static readonly uint[] _moreStringFieldTags = new uint[] { 10 }; - public static MoreString DefaultInstance { - get { return defaultInstance; } - } - - public override MoreString DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override MoreString ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_MoreString__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_MoreString__FieldAccessorTable; } - } - - public const int DataFieldNumber = 1; - private pbc::PopsicleList data_ = new pbc::PopsicleList(); - public scg::IList DataList { - get { return pbc::Lists.AsReadOnly(data_); } - } - public int DataCount { - get { return data_.Count; } - } - public string GetData(int index) { - return data_[index]; - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _moreStringFieldNames; - if (data_.Count > 0) { - output.WriteStringArray(1, field_names[0], data_); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - { - int dataSize = 0; - foreach (string element in DataList) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); - } - size += dataSize; - size += 1 * data_.Count; - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static MoreString ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static MoreString ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static MoreString ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static MoreString ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static MoreString ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static MoreString ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static MoreString ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static MoreString ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static MoreString ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static MoreString ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private MoreString MakeReadOnly() { - data_.MakeReadOnly(); - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(MoreString prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(MoreString cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private MoreString result; - - private MoreString PrepareBuilder() { - if (resultIsReadOnly) { - MoreString original = result; - result = new MoreString(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override MoreString MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.MoreString.Descriptor; } - } - - public override MoreString DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.MoreString.DefaultInstance; } - } - - public override MoreString BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is MoreString) { - return MergeFrom((MoreString) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(MoreString other) { - if (other == global::Google.ProtocolBuffers.TestProtos.MoreString.DefaultInstance) return this; - PrepareBuilder(); - if (other.data_.Count != 0) { - result.data_.Add(other.data_); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_moreStringFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _moreStringFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 10: { - input.ReadStringArray(tag, field_name, result.data_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public pbc::IPopsicleList DataList { - get { return PrepareBuilder().data_; } - } - public int DataCount { - get { return result.DataCount; } - } - public string GetData(int index) { - return result.GetData(index); - } - public Builder SetData(int index, string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.data_[index] = value; - return this; - } - public Builder AddData(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.data_.Add(value); - return this; - } - public Builder AddRangeData(scg::IEnumerable values) { - PrepareBuilder(); - result.data_.Add(values); - return this; - } - public Builder ClearData() { - PrepareBuilder(); - result.data_.Clear(); - return this; - } - } - static MoreString() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class OneBytes : pb::GeneratedMessage { - private OneBytes() { } - private static readonly OneBytes defaultInstance = new OneBytes().MakeReadOnly(); - private static readonly string[] _oneBytesFieldNames = new string[] { "data" }; - private static readonly uint[] _oneBytesFieldTags = new uint[] { 10 }; - public static OneBytes DefaultInstance { - get { return defaultInstance; } - } - - public override OneBytes DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override OneBytes ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_OneBytes__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_OneBytes__FieldAccessorTable; } - } - - public const int DataFieldNumber = 1; - private bool hasData; - private pb::ByteString data_ = pb::ByteString.Empty; - public bool HasData { - get { return hasData; } - } - public pb::ByteString Data { - get { return data_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _oneBytesFieldNames; - if (hasData) { - output.WriteBytes(1, field_names[0], Data); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasData) { - size += pb::CodedOutputStream.ComputeBytesSize(1, Data); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static OneBytes ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static OneBytes ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static OneBytes ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static OneBytes ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static OneBytes ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static OneBytes ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static OneBytes ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static OneBytes ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static OneBytes ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static OneBytes ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private OneBytes MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(OneBytes prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(OneBytes cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private OneBytes result; - - private OneBytes PrepareBuilder() { - if (resultIsReadOnly) { - OneBytes original = result; - result = new OneBytes(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override OneBytes MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.OneBytes.Descriptor; } - } - - public override OneBytes DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.OneBytes.DefaultInstance; } - } - - public override OneBytes BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is OneBytes) { - return MergeFrom((OneBytes) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(OneBytes other) { - if (other == global::Google.ProtocolBuffers.TestProtos.OneBytes.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasData) { - Data = other.Data; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_oneBytesFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _oneBytesFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 10: { - result.hasData = input.ReadBytes(ref result.data_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasData { - get { return result.hasData; } - } - public pb::ByteString Data { - get { return result.Data; } - set { SetData(value); } - } - public Builder SetData(pb::ByteString value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasData = true; - result.data_ = value; - return this; - } - public Builder ClearData() { - PrepareBuilder(); - result.hasData = false; - result.data_ = pb::ByteString.Empty; - return this; - } - } - static OneBytes() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MoreBytes : pb::GeneratedMessage { - private MoreBytes() { } - private static readonly MoreBytes defaultInstance = new MoreBytes().MakeReadOnly(); - private static readonly string[] _moreBytesFieldNames = new string[] { "data" }; - private static readonly uint[] _moreBytesFieldTags = new uint[] { 10 }; - public static MoreBytes DefaultInstance { - get { return defaultInstance; } - } - - public override MoreBytes DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override MoreBytes ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_MoreBytes__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_MoreBytes__FieldAccessorTable; } - } - - public const int DataFieldNumber = 1; - private pbc::PopsicleList data_ = new pbc::PopsicleList(); - public scg::IList DataList { - get { return pbc::Lists.AsReadOnly(data_); } - } - public int DataCount { - get { return data_.Count; } - } - public pb::ByteString GetData(int index) { - return data_[index]; - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _moreBytesFieldNames; - if (data_.Count > 0) { - output.WriteBytesArray(1, field_names[0], data_); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - { - int dataSize = 0; - foreach (pb::ByteString element in DataList) { - dataSize += pb::CodedOutputStream.ComputeBytesSizeNoTag(element); - } - size += dataSize; - size += 1 * data_.Count; - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static MoreBytes ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static MoreBytes ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static MoreBytes ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static MoreBytes ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static MoreBytes ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static MoreBytes ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static MoreBytes ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static MoreBytes ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static MoreBytes ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static MoreBytes ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private MoreBytes MakeReadOnly() { - data_.MakeReadOnly(); - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(MoreBytes prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(MoreBytes cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private MoreBytes result; - - private MoreBytes PrepareBuilder() { - if (resultIsReadOnly) { - MoreBytes original = result; - result = new MoreBytes(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override MoreBytes MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.MoreBytes.Descriptor; } - } - - public override MoreBytes DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.MoreBytes.DefaultInstance; } - } - - public override MoreBytes BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is MoreBytes) { - return MergeFrom((MoreBytes) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(MoreBytes other) { - if (other == global::Google.ProtocolBuffers.TestProtos.MoreBytes.DefaultInstance) return this; - PrepareBuilder(); - if (other.data_.Count != 0) { - result.data_.Add(other.data_); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_moreBytesFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _moreBytesFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 10: { - input.ReadBytesArray(tag, field_name, result.data_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public pbc::IPopsicleList DataList { - get { return PrepareBuilder().data_; } - } - public int DataCount { - get { return result.DataCount; } - } - public pb::ByteString GetData(int index) { - return result.GetData(index); - } - public Builder SetData(int index, pb::ByteString value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.data_[index] = value; - return this; - } - public Builder AddData(pb::ByteString value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.data_.Add(value); - return this; - } - public Builder AddRangeData(scg::IEnumerable values) { - PrepareBuilder(); - result.data_.Add(values); - return this; - } - public Builder ClearData() { - PrepareBuilder(); - result.data_.Clear(); - return this; - } - } - static MoreBytes() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Int32Message : pb::GeneratedMessage { - private Int32Message() { } - private static readonly Int32Message defaultInstance = new Int32Message().MakeReadOnly(); - private static readonly string[] _int32MessageFieldNames = new string[] { "data" }; - private static readonly uint[] _int32MessageFieldTags = new uint[] { 8 }; - public static Int32Message DefaultInstance { - get { return defaultInstance; } - } - - public override Int32Message DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override Int32Message ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_Int32Message__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_Int32Message__FieldAccessorTable; } - } - - public const int DataFieldNumber = 1; - private bool hasData; - private int data_; - public bool HasData { - get { return hasData; } - } - public int Data { - get { return data_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _int32MessageFieldNames; - if (hasData) { - output.WriteInt32(1, field_names[0], Data); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasData) { - size += pb::CodedOutputStream.ComputeInt32Size(1, Data); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static Int32Message ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static Int32Message ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static Int32Message ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static Int32Message ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static Int32Message ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static Int32Message ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static Int32Message ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static Int32Message ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static Int32Message ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static Int32Message ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private Int32Message MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(Int32Message prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(Int32Message cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private Int32Message result; - - private Int32Message PrepareBuilder() { - if (resultIsReadOnly) { - Int32Message original = result; - result = new Int32Message(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override Int32Message MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.Int32Message.Descriptor; } - } - - public override Int32Message DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.Int32Message.DefaultInstance; } - } - - public override Int32Message BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is Int32Message) { - return MergeFrom((Int32Message) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(Int32Message other) { - if (other == global::Google.ProtocolBuffers.TestProtos.Int32Message.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasData) { - Data = other.Data; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_int32MessageFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _int32MessageFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasData = input.ReadInt32(ref result.data_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasData { - get { return result.hasData; } - } - public int Data { - get { return result.Data; } - set { SetData(value); } - } - public Builder SetData(int value) { - PrepareBuilder(); - result.hasData = true; - result.data_ = value; - return this; - } - public Builder ClearData() { - PrepareBuilder(); - result.hasData = false; - result.data_ = 0; - return this; - } - } - static Int32Message() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Uint32Message : pb::GeneratedMessage { - private Uint32Message() { } - private static readonly Uint32Message defaultInstance = new Uint32Message().MakeReadOnly(); - private static readonly string[] _uint32MessageFieldNames = new string[] { "data" }; - private static readonly uint[] _uint32MessageFieldTags = new uint[] { 8 }; - public static Uint32Message DefaultInstance { - get { return defaultInstance; } - } - - public override Uint32Message DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override Uint32Message ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_Uint32Message__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_Uint32Message__FieldAccessorTable; } - } - - public const int DataFieldNumber = 1; - private bool hasData; - private uint data_; - public bool HasData { - get { return hasData; } - } - public uint Data { - get { return data_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _uint32MessageFieldNames; - if (hasData) { - output.WriteUInt32(1, field_names[0], Data); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasData) { - size += pb::CodedOutputStream.ComputeUInt32Size(1, Data); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static Uint32Message ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static Uint32Message ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static Uint32Message ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static Uint32Message ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static Uint32Message ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static Uint32Message ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static Uint32Message ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static Uint32Message ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static Uint32Message ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static Uint32Message ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private Uint32Message MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(Uint32Message prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(Uint32Message cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private Uint32Message result; - - private Uint32Message PrepareBuilder() { - if (resultIsReadOnly) { - Uint32Message original = result; - result = new Uint32Message(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override Uint32Message MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.Uint32Message.Descriptor; } - } - - public override Uint32Message DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.Uint32Message.DefaultInstance; } - } - - public override Uint32Message BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is Uint32Message) { - return MergeFrom((Uint32Message) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(Uint32Message other) { - if (other == global::Google.ProtocolBuffers.TestProtos.Uint32Message.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasData) { - Data = other.Data; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_uint32MessageFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _uint32MessageFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasData = input.ReadUInt32(ref result.data_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasData { - get { return result.hasData; } - } - public uint Data { - get { return result.Data; } - set { SetData(value); } - } - public Builder SetData(uint value) { - PrepareBuilder(); - result.hasData = true; - result.data_ = value; - return this; - } - public Builder ClearData() { - PrepareBuilder(); - result.hasData = false; - result.data_ = 0; - return this; - } - } - static Uint32Message() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Int64Message : pb::GeneratedMessage { - private Int64Message() { } - private static readonly Int64Message defaultInstance = new Int64Message().MakeReadOnly(); - private static readonly string[] _int64MessageFieldNames = new string[] { "data" }; - private static readonly uint[] _int64MessageFieldTags = new uint[] { 8 }; - public static Int64Message DefaultInstance { - get { return defaultInstance; } - } - - public override Int64Message DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override Int64Message ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_Int64Message__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_Int64Message__FieldAccessorTable; } - } - - public const int DataFieldNumber = 1; - private bool hasData; - private long data_; - public bool HasData { - get { return hasData; } - } - public long Data { - get { return data_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _int64MessageFieldNames; - if (hasData) { - output.WriteInt64(1, field_names[0], Data); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasData) { - size += pb::CodedOutputStream.ComputeInt64Size(1, Data); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static Int64Message ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static Int64Message ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static Int64Message ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static Int64Message ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static Int64Message ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static Int64Message ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static Int64Message ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static Int64Message ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static Int64Message ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static Int64Message ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private Int64Message MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(Int64Message prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(Int64Message cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private Int64Message result; - - private Int64Message PrepareBuilder() { - if (resultIsReadOnly) { - Int64Message original = result; - result = new Int64Message(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override Int64Message MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.Int64Message.Descriptor; } - } - - public override Int64Message DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.Int64Message.DefaultInstance; } - } - - public override Int64Message BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is Int64Message) { - return MergeFrom((Int64Message) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(Int64Message other) { - if (other == global::Google.ProtocolBuffers.TestProtos.Int64Message.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasData) { - Data = other.Data; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_int64MessageFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _int64MessageFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasData = input.ReadInt64(ref result.data_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasData { - get { return result.hasData; } - } - public long Data { - get { return result.Data; } - set { SetData(value); } - } - public Builder SetData(long value) { - PrepareBuilder(); - result.hasData = true; - result.data_ = value; - return this; - } - public Builder ClearData() { - PrepareBuilder(); - result.hasData = false; - result.data_ = 0L; - return this; - } - } - static Int64Message() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Uint64Message : pb::GeneratedMessage { - private Uint64Message() { } - private static readonly Uint64Message defaultInstance = new Uint64Message().MakeReadOnly(); - private static readonly string[] _uint64MessageFieldNames = new string[] { "data" }; - private static readonly uint[] _uint64MessageFieldTags = new uint[] { 8 }; - public static Uint64Message DefaultInstance { - get { return defaultInstance; } - } - - public override Uint64Message DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override Uint64Message ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_Uint64Message__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_Uint64Message__FieldAccessorTable; } - } - - public const int DataFieldNumber = 1; - private bool hasData; - private ulong data_; - public bool HasData { - get { return hasData; } - } - public ulong Data { - get { return data_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _uint64MessageFieldNames; - if (hasData) { - output.WriteUInt64(1, field_names[0], Data); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasData) { - size += pb::CodedOutputStream.ComputeUInt64Size(1, Data); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static Uint64Message ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static Uint64Message ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static Uint64Message ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static Uint64Message ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static Uint64Message ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static Uint64Message ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static Uint64Message ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static Uint64Message ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static Uint64Message ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static Uint64Message ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private Uint64Message MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(Uint64Message prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(Uint64Message cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private Uint64Message result; - - private Uint64Message PrepareBuilder() { - if (resultIsReadOnly) { - Uint64Message original = result; - result = new Uint64Message(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override Uint64Message MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.Uint64Message.Descriptor; } - } - - public override Uint64Message DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.Uint64Message.DefaultInstance; } - } - - public override Uint64Message BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is Uint64Message) { - return MergeFrom((Uint64Message) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(Uint64Message other) { - if (other == global::Google.ProtocolBuffers.TestProtos.Uint64Message.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasData) { - Data = other.Data; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_uint64MessageFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _uint64MessageFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasData = input.ReadUInt64(ref result.data_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasData { - get { return result.hasData; } - } - public ulong Data { - get { return result.Data; } - set { SetData(value); } - } - public Builder SetData(ulong value) { - PrepareBuilder(); - result.hasData = true; - result.data_ = value; - return this; - } - public Builder ClearData() { - PrepareBuilder(); - result.hasData = false; - result.data_ = 0UL; - return this; - } - } - static Uint64Message() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class BoolMessage : pb::GeneratedMessage { - private BoolMessage() { } - private static readonly BoolMessage defaultInstance = new BoolMessage().MakeReadOnly(); - private static readonly string[] _boolMessageFieldNames = new string[] { "data" }; - private static readonly uint[] _boolMessageFieldTags = new uint[] { 8 }; - public static BoolMessage DefaultInstance { - get { return defaultInstance; } - } - - public override BoolMessage DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override BoolMessage ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_BoolMessage__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_BoolMessage__FieldAccessorTable; } - } - - public const int DataFieldNumber = 1; - private bool hasData; - private bool data_; - public bool HasData { - get { return hasData; } - } - public bool Data { - get { return data_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _boolMessageFieldNames; - if (hasData) { - output.WriteBool(1, field_names[0], Data); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasData) { - size += pb::CodedOutputStream.ComputeBoolSize(1, Data); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static BoolMessage ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static BoolMessage ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static BoolMessage ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static BoolMessage ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static BoolMessage ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static BoolMessage ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static BoolMessage ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static BoolMessage ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static BoolMessage ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static BoolMessage ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private BoolMessage MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(BoolMessage prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(BoolMessage cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private BoolMessage result; - - private BoolMessage PrepareBuilder() { - if (resultIsReadOnly) { - BoolMessage original = result; - result = new BoolMessage(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override BoolMessage MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.BoolMessage.Descriptor; } - } - - public override BoolMessage DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.BoolMessage.DefaultInstance; } - } - - public override BoolMessage BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is BoolMessage) { - return MergeFrom((BoolMessage) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(BoolMessage other) { - if (other == global::Google.ProtocolBuffers.TestProtos.BoolMessage.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasData) { - Data = other.Data; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_boolMessageFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _boolMessageFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasData = input.ReadBool(ref result.data_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasData { - get { return result.hasData; } - } - public bool Data { - get { return result.Data; } - set { SetData(value); } - } - public Builder SetData(bool value) { - PrepareBuilder(); - result.hasData = true; - result.data_ = value; - return this; - } - public Builder ClearData() { - PrepareBuilder(); - result.hasData = false; - result.data_ = false; - return this; - } - } - static BoolMessage() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestOneof : pb::GeneratedMessage { - private TestOneof() { } - private static readonly TestOneof defaultInstance = new TestOneof().MakeReadOnly(); - private static readonly string[] _testOneofFieldNames = new string[] { "foo_int", "foo_message", "foo_string", "foogroup" }; - private static readonly uint[] _testOneofFieldTags = new uint[] { 8, 26, 18, 35 }; - public static TestOneof DefaultInstance { - get { return defaultInstance; } - } - - public override TestOneof DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestOneof ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestOneof__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestOneof__FieldAccessorTable; } - } - - #region Nested types - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class Types { - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class FooGroup : pb::GeneratedMessage { - private FooGroup() { } - private static readonly FooGroup defaultInstance = new FooGroup().MakeReadOnly(); - private static readonly string[] _fooGroupFieldNames = new string[] { "a", "b" }; - private static readonly uint[] _fooGroupFieldTags = new uint[] { 40, 50 }; - public static FooGroup DefaultInstance { - get { return defaultInstance; } - } - - public override FooGroup DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override FooGroup ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestOneof_FooGroup__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestOneof_FooGroup__FieldAccessorTable; } - } - - public const int AFieldNumber = 5; - private bool hasA; - private int a_; - public bool HasA { - get { return hasA; } - } - public int A { - get { return a_; } - } - - public const int BFieldNumber = 6; - private bool hasB; - private string b_ = ""; - public bool HasB { - get { return hasB; } - } - public string B { - get { return b_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _fooGroupFieldNames; - if (hasA) { - output.WriteInt32(5, field_names[0], A); - } - if (hasB) { - output.WriteString(6, field_names[1], B); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(5, A); - } - if (hasB) { - size += pb::CodedOutputStream.ComputeStringSize(6, B); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static FooGroup ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static FooGroup ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static FooGroup ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static FooGroup ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static FooGroup ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static FooGroup ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static FooGroup ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static FooGroup ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static FooGroup ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static FooGroup ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private FooGroup MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(FooGroup prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(FooGroup cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private FooGroup result; - - private FooGroup PrepareBuilder() { - if (resultIsReadOnly) { - FooGroup original = result; - result = new FooGroup(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override FooGroup MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestOneof.Types.FooGroup.Descriptor; } - } - - public override FooGroup DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestOneof.Types.FooGroup.DefaultInstance; } - } - - public override FooGroup BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is FooGroup) { - return MergeFrom((FooGroup) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(FooGroup other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestOneof.Types.FooGroup.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasA) { - A = other.A; - } - if (other.HasB) { - B = other.B; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_fooGroupFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _fooGroupFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 40: { - result.hasA = input.ReadInt32(ref result.a_); - break; - } - case 50: { - result.hasB = input.ReadString(ref result.b_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasA { - get { return result.hasA; } - } - public int A { - get { return result.A; } - set { SetA(value); } - } - public Builder SetA(int value) { - PrepareBuilder(); - result.hasA = true; - result.a_ = value; - return this; - } - public Builder ClearA() { - PrepareBuilder(); - result.hasA = false; - result.a_ = 0; - return this; - } - - public bool HasB { - get { return result.hasB; } - } - public string B { - get { return result.B; } - set { SetB(value); } - } - public Builder SetB(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasB = true; - result.b_ = value; - return this; - } - public Builder ClearB() { - PrepareBuilder(); - result.hasB = false; - result.b_ = ""; - return this; - } - } - static FooGroup() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - } - #endregion - - private object foo_; - public enum FooOneofCase { - FooInt = 1, - FooString = 2, - FooMessage = 3, - FooGroup = 4, - None = 0, - } - private FooOneofCase fooCase_ = FooOneofCase.None; - public FooOneofCase FooCase { - get { return fooCase_; } - } - - public const int FooIntFieldNumber = 1; - public bool HasFooInt { - get { return fooCase_ == FooOneofCase.FooInt; } - } - public int FooInt { - get { return fooCase_ == FooOneofCase.FooInt ? (int) foo_ : 0; } - } - - public const int FooStringFieldNumber = 2; - public bool HasFooString { - get { return fooCase_ == FooOneofCase.FooString; } - } - public string FooString { - get { return fooCase_ == FooOneofCase.FooString ? (string) foo_ : ""; } - } - - public const int FooMessageFieldNumber = 3; - public bool HasFooMessage { - get { return fooCase_ == FooOneofCase.FooMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes FooMessage { - get { return fooCase_ == FooOneofCase.FooMessage ? (global::Google.ProtocolBuffers.TestProtos.TestAllTypes) foo_ : global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance; } - } - - public const int FooGroupFieldNumber = 4; - public bool HasFooGroup { - get { return fooCase_ == FooOneofCase.FooGroup; } - } - public global::Google.ProtocolBuffers.TestProtos.TestOneof.Types.FooGroup FooGroup { - get { return fooCase_ == FooOneofCase.FooGroup ? (global::Google.ProtocolBuffers.TestProtos.TestOneof.Types.FooGroup) foo_ : global::Google.ProtocolBuffers.TestProtos.TestOneof.Types.FooGroup.DefaultInstance; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testOneofFieldNames; - if (fooCase_ == FooOneofCase.FooInt) { - output.WriteInt32(1, field_names[0], FooInt); - } - if (fooCase_ == FooOneofCase.FooString) { - output.WriteString(2, field_names[2], FooString); - } - if (fooCase_ == FooOneofCase.FooMessage) { - output.WriteMessage(3, field_names[1], FooMessage); - } - if (fooCase_ == FooOneofCase.FooGroup) { - output.WriteGroup(4, field_names[3], FooGroup); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (fooCase_ == FooOneofCase.FooInt) { - size += pb::CodedOutputStream.ComputeInt32Size(1, FooInt); - } - if (fooCase_ == FooOneofCase.FooString) { - size += pb::CodedOutputStream.ComputeStringSize(2, FooString); - } - if (fooCase_ == FooOneofCase.FooMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(3, FooMessage); - } - if (fooCase_ == FooOneofCase.FooGroup) { - size += pb::CodedOutputStream.ComputeGroupSize(4, FooGroup); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestOneof ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestOneof ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestOneof ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestOneof ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestOneof ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestOneof ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestOneof ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestOneof ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestOneof ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestOneof ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestOneof MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestOneof prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestOneof cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestOneof result; - - private TestOneof PrepareBuilder() { - if (resultIsReadOnly) { - TestOneof original = result; - result = new TestOneof(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestOneof MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestOneof.Descriptor; } - } - - public override TestOneof DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestOneof.DefaultInstance; } - } - - public override TestOneof BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestOneof) { - return MergeFrom((TestOneof) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestOneof other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestOneof.DefaultInstance) return this; - PrepareBuilder(); - switch (other.FooCase) { - case FooOneofCase.FooInt: { - SetFooInt(other.FooInt); - break; - } - case FooOneofCase.FooString: { - SetFooString(other.FooString); - break; - } - case FooOneofCase.FooMessage: { - MergeFooMessage(other.FooMessage); - break; - } - case FooOneofCase.FooGroup: { - MergeFooGroup(other.FooGroup); - break; - } - case FooOneofCase.None: { break; } - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testOneofFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testOneofFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - int value = 0; - if (input.ReadInt32(ref value)) { - result.foo_ = value; - result.fooCase_ = FooOneofCase.FooInt; - } - break; - } - case 18: { - string value = ""; - if (input.ReadString(ref value)) { - result.foo_ = value; - result.fooCase_ = FooOneofCase.FooString; - } - break; - } - case 26: { - global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.CreateBuilder(); - if (result.fooCase_ == FooOneofCase.FooMessage) { - subBuilder.MergeFrom(FooMessage); - } - input.ReadMessage(subBuilder, extensionRegistry); - result.foo_ = subBuilder.BuildPartial(); - result.fooCase_ = FooOneofCase.FooMessage; - break; - } - case 35: { - global::Google.ProtocolBuffers.TestProtos.TestOneof.Types.FooGroup.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestOneof.Types.FooGroup.CreateBuilder(); - if (result.fooCase_ == FooOneofCase.FooGroup) { - subBuilder.MergeFrom(FooGroup); - } - input.ReadGroup(4, subBuilder, extensionRegistry); - result.foo_ = subBuilder.BuildPartial(); - result.fooCase_ = FooOneofCase.FooGroup; - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasFooInt { - get { return result.fooCase_ == FooOneofCase.FooInt; } - } - public int FooInt { - get { return result.fooCase_ == FooOneofCase.FooInt ? (int) result.foo_ : 0; } - set { SetFooInt(value); } - } - public Builder SetFooInt(int value) { - PrepareBuilder(); - result.foo_ = value; - result.fooCase_ = FooOneofCase.FooInt; - return this; - } - public Builder ClearFooInt() { - PrepareBuilder(); - if (result.fooCase_ == FooOneofCase.FooInt) { - result.fooCase_ = FooOneofCase.None; - } - return this; - } - - public bool HasFooString { - get { return result.fooCase_ == FooOneofCase.FooString; } - } - public string FooString { - get { return result.fooCase_ == FooOneofCase.FooString ? (string) result.foo_ : ""; } - set { SetFooString(value); } - } - public Builder SetFooString(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.foo_ = value; - result.fooCase_ = FooOneofCase.FooString; - return this; - } - public Builder ClearFooString() { - PrepareBuilder(); - if (result.fooCase_ == FooOneofCase.FooString) { - result.fooCase_ = FooOneofCase.None; - } - return this; - } - - public bool HasFooMessage { - get { return result.fooCase_ == FooOneofCase.FooMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes FooMessage { - get { return result.fooCase_ == FooOneofCase.FooMessage ? (global::Google.ProtocolBuffers.TestProtos.TestAllTypes) result.foo_ : global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance; } - set { SetFooMessage(value); } - } - public Builder SetFooMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.fooCase_ = FooOneofCase.FooMessage; - result.foo_ = value; - return this; - } - public Builder SetFooMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.fooCase_ = FooOneofCase.FooMessage; - result.foo_ = builderForValue.Build(); - return this; - } - public Builder MergeFooMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.fooCase_ == FooOneofCase.FooMessage && - result.FooMessage != global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance) { - result.foo_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.CreateBuilder(result.FooMessage).MergeFrom(value).BuildPartial(); - } else { - result.foo_ = value; - } - result.fooCase_ = FooOneofCase.FooMessage; - return this; - } - public Builder ClearFooMessage() { - if (result.fooCase_ == FooOneofCase.FooMessage) { - PrepareBuilder(); - result.fooCase_ = FooOneofCase.None; - result.foo_ = null; - } - return this; - } - - public bool HasFooGroup { - get { return result.fooCase_ == FooOneofCase.FooGroup; } - } - public global::Google.ProtocolBuffers.TestProtos.TestOneof.Types.FooGroup FooGroup { - get { return result.fooCase_ == FooOneofCase.FooGroup ? (global::Google.ProtocolBuffers.TestProtos.TestOneof.Types.FooGroup) result.foo_ : global::Google.ProtocolBuffers.TestProtos.TestOneof.Types.FooGroup.DefaultInstance; } - set { SetFooGroup(value); } - } - public Builder SetFooGroup(global::Google.ProtocolBuffers.TestProtos.TestOneof.Types.FooGroup value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.fooCase_ = FooOneofCase.FooGroup; - result.foo_ = value; - return this; - } - public Builder SetFooGroup(global::Google.ProtocolBuffers.TestProtos.TestOneof.Types.FooGroup.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.fooCase_ = FooOneofCase.FooGroup; - result.foo_ = builderForValue.Build(); - return this; - } - public Builder MergeFooGroup(global::Google.ProtocolBuffers.TestProtos.TestOneof.Types.FooGroup value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.fooCase_ == FooOneofCase.FooGroup && - result.FooGroup != global::Google.ProtocolBuffers.TestProtos.TestOneof.Types.FooGroup.DefaultInstance) { - result.foo_ = global::Google.ProtocolBuffers.TestProtos.TestOneof.Types.FooGroup.CreateBuilder(result.FooGroup).MergeFrom(value).BuildPartial(); - } else { - result.foo_ = value; - } - result.fooCase_ = FooOneofCase.FooGroup; - return this; - } - public Builder ClearFooGroup() { - if (result.fooCase_ == FooOneofCase.FooGroup) { - PrepareBuilder(); - result.fooCase_ = FooOneofCase.None; - result.foo_ = null; - } - return this; - } - - public FooOneofCase FooCase { - get { return result.fooCase_; } - } - public Builder ClearFoo() { - PrepareBuilder(); - result.foo_ = null; - result.fooCase_ = FooOneofCase.None; - return this; - } - } - static TestOneof() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestOneofBackwardsCompatible : pb::GeneratedMessage { - private TestOneofBackwardsCompatible() { } - private static readonly TestOneofBackwardsCompatible defaultInstance = new TestOneofBackwardsCompatible().MakeReadOnly(); - private static readonly string[] _testOneofBackwardsCompatibleFieldNames = new string[] { "foo_int", "foo_message", "foo_string", "foogroup" }; - private static readonly uint[] _testOneofBackwardsCompatibleFieldTags = new uint[] { 8, 26, 18, 35 }; - public static TestOneofBackwardsCompatible DefaultInstance { - get { return defaultInstance; } - } - - public override TestOneofBackwardsCompatible DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestOneofBackwardsCompatible ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestOneofBackwardsCompatible__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestOneofBackwardsCompatible__FieldAccessorTable; } - } - - #region Nested types - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class Types { - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class FooGroup : pb::GeneratedMessage { - private FooGroup() { } - private static readonly FooGroup defaultInstance = new FooGroup().MakeReadOnly(); - private static readonly string[] _fooGroupFieldNames = new string[] { "a", "b" }; - private static readonly uint[] _fooGroupFieldTags = new uint[] { 40, 50 }; - public static FooGroup DefaultInstance { - get { return defaultInstance; } - } - - public override FooGroup DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override FooGroup ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestOneofBackwardsCompatible_FooGroup__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestOneofBackwardsCompatible_FooGroup__FieldAccessorTable; } - } - - public const int AFieldNumber = 5; - private bool hasA; - private int a_; - public bool HasA { - get { return hasA; } - } - public int A { - get { return a_; } - } - - public const int BFieldNumber = 6; - private bool hasB; - private string b_ = ""; - public bool HasB { - get { return hasB; } - } - public string B { - get { return b_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _fooGroupFieldNames; - if (hasA) { - output.WriteInt32(5, field_names[0], A); - } - if (hasB) { - output.WriteString(6, field_names[1], B); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(5, A); - } - if (hasB) { - size += pb::CodedOutputStream.ComputeStringSize(6, B); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static FooGroup ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static FooGroup ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static FooGroup ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static FooGroup ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static FooGroup ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static FooGroup ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static FooGroup ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static FooGroup ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static FooGroup ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static FooGroup ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private FooGroup MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(FooGroup prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(FooGroup cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private FooGroup result; - - private FooGroup PrepareBuilder() { - if (resultIsReadOnly) { - FooGroup original = result; - result = new FooGroup(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override FooGroup MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestOneofBackwardsCompatible.Types.FooGroup.Descriptor; } - } - - public override FooGroup DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestOneofBackwardsCompatible.Types.FooGroup.DefaultInstance; } - } - - public override FooGroup BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is FooGroup) { - return MergeFrom((FooGroup) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(FooGroup other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestOneofBackwardsCompatible.Types.FooGroup.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasA) { - A = other.A; - } - if (other.HasB) { - B = other.B; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_fooGroupFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _fooGroupFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 40: { - result.hasA = input.ReadInt32(ref result.a_); - break; - } - case 50: { - result.hasB = input.ReadString(ref result.b_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasA { - get { return result.hasA; } - } - public int A { - get { return result.A; } - set { SetA(value); } - } - public Builder SetA(int value) { - PrepareBuilder(); - result.hasA = true; - result.a_ = value; - return this; - } - public Builder ClearA() { - PrepareBuilder(); - result.hasA = false; - result.a_ = 0; - return this; - } - - public bool HasB { - get { return result.hasB; } - } - public string B { - get { return result.B; } - set { SetB(value); } - } - public Builder SetB(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasB = true; - result.b_ = value; - return this; - } - public Builder ClearB() { - PrepareBuilder(); - result.hasB = false; - result.b_ = ""; - return this; - } - } - static FooGroup() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - } - #endregion - - public const int FooIntFieldNumber = 1; - private bool hasFooInt; - private int fooInt_; - public bool HasFooInt { - get { return hasFooInt; } - } - public int FooInt { - get { return fooInt_; } - } - - public const int FooStringFieldNumber = 2; - private bool hasFooString; - private string fooString_ = ""; - public bool HasFooString { - get { return hasFooString; } - } - public string FooString { - get { return fooString_; } - } - - public const int FooMessageFieldNumber = 3; - private bool hasFooMessage; - private global::Google.ProtocolBuffers.TestProtos.TestAllTypes fooMessage_; - public bool HasFooMessage { - get { return hasFooMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes FooMessage { - get { return fooMessage_ ?? global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance; } - } - - public const int FooGroupFieldNumber = 4; - private bool hasFooGroup; - private global::Google.ProtocolBuffers.TestProtos.TestOneofBackwardsCompatible.Types.FooGroup fooGroup_; - public bool HasFooGroup { - get { return hasFooGroup; } - } - public global::Google.ProtocolBuffers.TestProtos.TestOneofBackwardsCompatible.Types.FooGroup FooGroup { - get { return fooGroup_ ?? global::Google.ProtocolBuffers.TestProtos.TestOneofBackwardsCompatible.Types.FooGroup.DefaultInstance; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testOneofBackwardsCompatibleFieldNames; - if (hasFooInt) { - output.WriteInt32(1, field_names[0], FooInt); - } - if (hasFooString) { - output.WriteString(2, field_names[2], FooString); - } - if (hasFooMessage) { - output.WriteMessage(3, field_names[1], FooMessage); - } - if (hasFooGroup) { - output.WriteGroup(4, field_names[3], FooGroup); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasFooInt) { - size += pb::CodedOutputStream.ComputeInt32Size(1, FooInt); - } - if (hasFooString) { - size += pb::CodedOutputStream.ComputeStringSize(2, FooString); - } - if (hasFooMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(3, FooMessage); - } - if (hasFooGroup) { - size += pb::CodedOutputStream.ComputeGroupSize(4, FooGroup); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestOneofBackwardsCompatible ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestOneofBackwardsCompatible ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestOneofBackwardsCompatible ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestOneofBackwardsCompatible ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestOneofBackwardsCompatible ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestOneofBackwardsCompatible ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestOneofBackwardsCompatible ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestOneofBackwardsCompatible ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestOneofBackwardsCompatible ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestOneofBackwardsCompatible ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestOneofBackwardsCompatible MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestOneofBackwardsCompatible prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestOneofBackwardsCompatible cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestOneofBackwardsCompatible result; - - private TestOneofBackwardsCompatible PrepareBuilder() { - if (resultIsReadOnly) { - TestOneofBackwardsCompatible original = result; - result = new TestOneofBackwardsCompatible(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestOneofBackwardsCompatible MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestOneofBackwardsCompatible.Descriptor; } - } - - public override TestOneofBackwardsCompatible DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestOneofBackwardsCompatible.DefaultInstance; } - } - - public override TestOneofBackwardsCompatible BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestOneofBackwardsCompatible) { - return MergeFrom((TestOneofBackwardsCompatible) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestOneofBackwardsCompatible other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestOneofBackwardsCompatible.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasFooInt) { - FooInt = other.FooInt; - } - if (other.HasFooString) { - FooString = other.FooString; - } - if (other.HasFooMessage) { - MergeFooMessage(other.FooMessage); - } - if (other.HasFooGroup) { - MergeFooGroup(other.FooGroup); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testOneofBackwardsCompatibleFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testOneofBackwardsCompatibleFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasFooInt = input.ReadInt32(ref result.fooInt_); - break; - } - case 18: { - result.hasFooString = input.ReadString(ref result.fooString_); - break; - } - case 26: { - global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.CreateBuilder(); - if (result.hasFooMessage) { - subBuilder.MergeFrom(FooMessage); - } - input.ReadMessage(subBuilder, extensionRegistry); - FooMessage = subBuilder.BuildPartial(); - break; - } - case 35: { - global::Google.ProtocolBuffers.TestProtos.TestOneofBackwardsCompatible.Types.FooGroup.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestOneofBackwardsCompatible.Types.FooGroup.CreateBuilder(); - if (result.hasFooGroup) { - subBuilder.MergeFrom(FooGroup); - } - input.ReadGroup(4, subBuilder, extensionRegistry); - FooGroup = subBuilder.BuildPartial(); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasFooInt { - get { return result.hasFooInt; } - } - public int FooInt { - get { return result.FooInt; } - set { SetFooInt(value); } - } - public Builder SetFooInt(int value) { - PrepareBuilder(); - result.hasFooInt = true; - result.fooInt_ = value; - return this; - } - public Builder ClearFooInt() { - PrepareBuilder(); - result.hasFooInt = false; - result.fooInt_ = 0; - return this; - } - - public bool HasFooString { - get { return result.hasFooString; } - } - public string FooString { - get { return result.FooString; } - set { SetFooString(value); } - } - public Builder SetFooString(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasFooString = true; - result.fooString_ = value; - return this; - } - public Builder ClearFooString() { - PrepareBuilder(); - result.hasFooString = false; - result.fooString_ = ""; - return this; - } - - public bool HasFooMessage { - get { return result.hasFooMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes FooMessage { - get { return result.FooMessage; } - set { SetFooMessage(value); } - } - public Builder SetFooMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasFooMessage = true; - result.fooMessage_ = value; - return this; - } - public Builder SetFooMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasFooMessage = true; - result.fooMessage_ = builderForValue.Build(); - return this; - } - public Builder MergeFooMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasFooMessage && - result.fooMessage_ != global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance) { - result.fooMessage_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.CreateBuilder(result.fooMessage_).MergeFrom(value).BuildPartial(); - } else { - result.fooMessage_ = value; - } - result.hasFooMessage = true; - return this; - } - public Builder ClearFooMessage() { - PrepareBuilder(); - result.hasFooMessage = false; - result.fooMessage_ = null; - return this; - } - - public bool HasFooGroup { - get { return result.hasFooGroup; } - } - public global::Google.ProtocolBuffers.TestProtos.TestOneofBackwardsCompatible.Types.FooGroup FooGroup { - get { return result.FooGroup; } - set { SetFooGroup(value); } - } - public Builder SetFooGroup(global::Google.ProtocolBuffers.TestProtos.TestOneofBackwardsCompatible.Types.FooGroup value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasFooGroup = true; - result.fooGroup_ = value; - return this; - } - public Builder SetFooGroup(global::Google.ProtocolBuffers.TestProtos.TestOneofBackwardsCompatible.Types.FooGroup.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasFooGroup = true; - result.fooGroup_ = builderForValue.Build(); - return this; - } - public Builder MergeFooGroup(global::Google.ProtocolBuffers.TestProtos.TestOneofBackwardsCompatible.Types.FooGroup value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasFooGroup && - result.fooGroup_ != global::Google.ProtocolBuffers.TestProtos.TestOneofBackwardsCompatible.Types.FooGroup.DefaultInstance) { - result.fooGroup_ = global::Google.ProtocolBuffers.TestProtos.TestOneofBackwardsCompatible.Types.FooGroup.CreateBuilder(result.fooGroup_).MergeFrom(value).BuildPartial(); - } else { - result.fooGroup_ = value; - } - result.hasFooGroup = true; - return this; - } - public Builder ClearFooGroup() { - PrepareBuilder(); - result.hasFooGroup = false; - result.fooGroup_ = null; - return this; - } - } - static TestOneofBackwardsCompatible() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestOneof2 : pb::GeneratedMessage { - private TestOneof2() { } - private static readonly TestOneof2 defaultInstance = new TestOneof2().MakeReadOnly(); - private static readonly string[] _testOneof2FieldNames = new string[] { "bar_bytes", "bar_cord", "bar_enum", "bar_int", "bar_string", "bar_string_piece", "baz_int", "baz_string", "foo_bytes", "foo_cord", "foo_enum", "foo_int", "foo_lazy_message", "foo_message", "foo_string", "foo_string_piece", "foogroup" }; - private static readonly uint[] _testOneof2FieldTags = new uint[] { 130, 114, 136, 96, 106, 122, 144, 154, 42, 26, 48, 8, 90, 58, 18, 34, 67 }; - public static TestOneof2 DefaultInstance { - get { return defaultInstance; } - } - - public override TestOneof2 DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestOneof2 ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestOneof2__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestOneof2__FieldAccessorTable; } - } - - #region Nested types - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class Types { - public enum NestedEnum { - FOO = 1, - BAR = 2, - BAZ = 3, - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class FooGroup : pb::GeneratedMessage { - private FooGroup() { } - private static readonly FooGroup defaultInstance = new FooGroup().MakeReadOnly(); - private static readonly string[] _fooGroupFieldNames = new string[] { "a", "b" }; - private static readonly uint[] _fooGroupFieldTags = new uint[] { 72, 82 }; - public static FooGroup DefaultInstance { - get { return defaultInstance; } - } - - public override FooGroup DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override FooGroup ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestOneof2_FooGroup__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestOneof2_FooGroup__FieldAccessorTable; } - } - - public const int AFieldNumber = 9; - private bool hasA; - private int a_; - public bool HasA { - get { return hasA; } - } - public int A { - get { return a_; } - } - - public const int BFieldNumber = 10; - private bool hasB; - private string b_ = ""; - public bool HasB { - get { return hasB; } - } - public string B { - get { return b_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _fooGroupFieldNames; - if (hasA) { - output.WriteInt32(9, field_names[0], A); - } - if (hasB) { - output.WriteString(10, field_names[1], B); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(9, A); - } - if (hasB) { - size += pb::CodedOutputStream.ComputeStringSize(10, B); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static FooGroup ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static FooGroup ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static FooGroup ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static FooGroup ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static FooGroup ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static FooGroup ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static FooGroup ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static FooGroup ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static FooGroup ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static FooGroup ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private FooGroup MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(FooGroup prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(FooGroup cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private FooGroup result; - - private FooGroup PrepareBuilder() { - if (resultIsReadOnly) { - FooGroup original = result; - result = new FooGroup(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override FooGroup MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.FooGroup.Descriptor; } - } - - public override FooGroup DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.FooGroup.DefaultInstance; } - } - - public override FooGroup BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is FooGroup) { - return MergeFrom((FooGroup) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(FooGroup other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.FooGroup.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasA) { - A = other.A; - } - if (other.HasB) { - B = other.B; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_fooGroupFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _fooGroupFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 72: { - result.hasA = input.ReadInt32(ref result.a_); - break; - } - case 82: { - result.hasB = input.ReadString(ref result.b_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasA { - get { return result.hasA; } - } - public int A { - get { return result.A; } - set { SetA(value); } - } - public Builder SetA(int value) { - PrepareBuilder(); - result.hasA = true; - result.a_ = value; - return this; - } - public Builder ClearA() { - PrepareBuilder(); - result.hasA = false; - result.a_ = 0; - return this; - } - - public bool HasB { - get { return result.hasB; } - } - public string B { - get { return result.B; } - set { SetB(value); } - } - public Builder SetB(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasB = true; - result.b_ = value; - return this; - } - public Builder ClearB() { - PrepareBuilder(); - result.hasB = false; - result.b_ = ""; - return this; - } - } - static FooGroup() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class NestedMessage : pb::GeneratedMessage { - private NestedMessage() { } - private static readonly NestedMessage defaultInstance = new NestedMessage().MakeReadOnly(); - private static readonly string[] _nestedMessageFieldNames = new string[] { "corge_int", "qux_int" }; - private static readonly uint[] _nestedMessageFieldTags = new uint[] { 16, 8 }; - public static NestedMessage DefaultInstance { - get { return defaultInstance; } - } - - public override NestedMessage DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override NestedMessage ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestOneof2_NestedMessage__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestOneof2_NestedMessage__FieldAccessorTable; } - } - - public const int QuxIntFieldNumber = 1; - private bool hasQuxInt; - private long quxInt_; - public bool HasQuxInt { - get { return hasQuxInt; } - } - public long QuxInt { - get { return quxInt_; } - } - - public const int CorgeIntFieldNumber = 2; - private pbc::PopsicleList corgeInt_ = new pbc::PopsicleList(); - public scg::IList CorgeIntList { - get { return pbc::Lists.AsReadOnly(corgeInt_); } - } - public int CorgeIntCount { - get { return corgeInt_.Count; } - } - public int GetCorgeInt(int index) { - return corgeInt_[index]; - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _nestedMessageFieldNames; - if (hasQuxInt) { - output.WriteInt64(1, field_names[1], QuxInt); - } - if (corgeInt_.Count > 0) { - output.WriteInt32Array(2, field_names[0], corgeInt_); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasQuxInt) { - size += pb::CodedOutputStream.ComputeInt64Size(1, QuxInt); - } - { - int dataSize = 0; - foreach (int element in CorgeIntList) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); - } - size += dataSize; - size += 1 * corgeInt_.Count; - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static NestedMessage ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static NestedMessage ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static NestedMessage ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static NestedMessage ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static NestedMessage ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static NestedMessage ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static NestedMessage ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static NestedMessage ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static NestedMessage ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static NestedMessage ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private NestedMessage MakeReadOnly() { - corgeInt_.MakeReadOnly(); - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(NestedMessage prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(NestedMessage cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private NestedMessage result; - - private NestedMessage PrepareBuilder() { - if (resultIsReadOnly) { - NestedMessage original = result; - result = new NestedMessage(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override NestedMessage MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage.Descriptor; } - } - - public override NestedMessage DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage.DefaultInstance; } - } - - public override NestedMessage BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is NestedMessage) { - return MergeFrom((NestedMessage) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(NestedMessage other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasQuxInt) { - QuxInt = other.QuxInt; - } - if (other.corgeInt_.Count != 0) { - result.corgeInt_.Add(other.corgeInt_); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_nestedMessageFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _nestedMessageFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasQuxInt = input.ReadInt64(ref result.quxInt_); - break; - } - case 18: - case 16: { - input.ReadInt32Array(tag, field_name, result.corgeInt_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasQuxInt { - get { return result.hasQuxInt; } - } - public long QuxInt { - get { return result.QuxInt; } - set { SetQuxInt(value); } - } - public Builder SetQuxInt(long value) { - PrepareBuilder(); - result.hasQuxInt = true; - result.quxInt_ = value; - return this; - } - public Builder ClearQuxInt() { - PrepareBuilder(); - result.hasQuxInt = false; - result.quxInt_ = 0L; - return this; - } - - public pbc::IPopsicleList CorgeIntList { - get { return PrepareBuilder().corgeInt_; } - } - public int CorgeIntCount { - get { return result.CorgeIntCount; } - } - public int GetCorgeInt(int index) { - return result.GetCorgeInt(index); - } - public Builder SetCorgeInt(int index, int value) { - PrepareBuilder(); - result.corgeInt_[index] = value; - return this; - } - public Builder AddCorgeInt(int value) { - PrepareBuilder(); - result.corgeInt_.Add(value); - return this; - } - public Builder AddRangeCorgeInt(scg::IEnumerable values) { - PrepareBuilder(); - result.corgeInt_.Add(values); - return this; - } - public Builder ClearCorgeInt() { - PrepareBuilder(); - result.corgeInt_.Clear(); - return this; - } - } - static NestedMessage() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - } - #endregion - - private object foo_; - public enum FooOneofCase { - FooInt = 1, - FooString = 2, - FooCord = 3, - FooStringPiece = 4, - FooBytes = 5, - FooEnum = 6, - FooMessage = 7, - FooGroup = 8, - FooLazyMessage = 11, - None = 0, - } - private FooOneofCase fooCase_ = FooOneofCase.None; - public FooOneofCase FooCase { - get { return fooCase_; } - } - - private object bar_; - public enum BarOneofCase { - BarInt = 12, - BarString = 13, - BarCord = 14, - BarStringPiece = 15, - BarBytes = 16, - BarEnum = 17, - None = 0, - } - private BarOneofCase barCase_ = BarOneofCase.None; - public BarOneofCase BarCase { - get { return barCase_; } - } - - public const int FooIntFieldNumber = 1; - public bool HasFooInt { - get { return fooCase_ == FooOneofCase.FooInt; } - } - public int FooInt { - get { return fooCase_ == FooOneofCase.FooInt ? (int) foo_ : 0; } - } - - public const int FooStringFieldNumber = 2; - public bool HasFooString { - get { return fooCase_ == FooOneofCase.FooString; } - } - public string FooString { - get { return fooCase_ == FooOneofCase.FooString ? (string) foo_ : ""; } - } - - public const int FooCordFieldNumber = 3; - public bool HasFooCord { - get { return fooCase_ == FooOneofCase.FooCord; } - } - public string FooCord { - get { return fooCase_ == FooOneofCase.FooCord ? (string) foo_ : ""; } - } - - public const int FooStringPieceFieldNumber = 4; - public bool HasFooStringPiece { - get { return fooCase_ == FooOneofCase.FooStringPiece; } - } - public string FooStringPiece { - get { return fooCase_ == FooOneofCase.FooStringPiece ? (string) foo_ : ""; } - } - - public const int FooBytesFieldNumber = 5; - public bool HasFooBytes { - get { return fooCase_ == FooOneofCase.FooBytes; } - } - public pb::ByteString FooBytes { - get { return fooCase_ == FooOneofCase.FooBytes ? (pb::ByteString) foo_ : pb::ByteString.Empty; } - } - - public const int FooEnumFieldNumber = 6; - public bool HasFooEnum { - get { return fooCase_ == FooOneofCase.FooEnum; } - } - public global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedEnum FooEnum { - get { return fooCase_ == FooOneofCase.FooEnum ? (global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedEnum) foo_ : global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedEnum.FOO; } - } - - public const int FooMessageFieldNumber = 7; - public bool HasFooMessage { - get { return fooCase_ == FooOneofCase.FooMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage FooMessage { - get { return fooCase_ == FooOneofCase.FooMessage ? (global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage) foo_ : global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage.DefaultInstance; } - } - - public const int FooGroupFieldNumber = 8; - public bool HasFooGroup { - get { return fooCase_ == FooOneofCase.FooGroup; } - } - public global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.FooGroup FooGroup { - get { return fooCase_ == FooOneofCase.FooGroup ? (global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.FooGroup) foo_ : global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.FooGroup.DefaultInstance; } - } - - public const int FooLazyMessageFieldNumber = 11; - public bool HasFooLazyMessage { - get { return fooCase_ == FooOneofCase.FooLazyMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage FooLazyMessage { - get { return fooCase_ == FooOneofCase.FooLazyMessage ? (global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage) foo_ : global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage.DefaultInstance; } - } - - public const int BarIntFieldNumber = 12; - public bool HasBarInt { - get { return barCase_ == BarOneofCase.BarInt; } - } - public int BarInt { - get { return barCase_ == BarOneofCase.BarInt ? (int) bar_ : 5; } - } - - public const int BarStringFieldNumber = 13; - public bool HasBarString { - get { return barCase_ == BarOneofCase.BarString; } - } - public string BarString { - get { return barCase_ == BarOneofCase.BarString ? (string) bar_ : "STRING"; } - } - - public const int BarCordFieldNumber = 14; - public bool HasBarCord { - get { return barCase_ == BarOneofCase.BarCord; } - } - public string BarCord { - get { return barCase_ == BarOneofCase.BarCord ? (string) bar_ : "CORD"; } - } - - public const int BarStringPieceFieldNumber = 15; - public bool HasBarStringPiece { - get { return barCase_ == BarOneofCase.BarStringPiece; } - } - public string BarStringPiece { - get { return barCase_ == BarOneofCase.BarStringPiece ? (string) bar_ : "SPIECE"; } - } - - public const int BarBytesFieldNumber = 16; - public bool HasBarBytes { - get { return barCase_ == BarOneofCase.BarBytes; } - } - public pb::ByteString BarBytes { - get { return barCase_ == BarOneofCase.BarBytes ? (pb::ByteString) bar_ : (pb::ByteString) global::Google.ProtocolBuffers.TestProtos.TestOneof2.Descriptor.Fields[13].DefaultValue; } - } - - public const int BarEnumFieldNumber = 17; - public bool HasBarEnum { - get { return barCase_ == BarOneofCase.BarEnum; } - } - public global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedEnum BarEnum { - get { return barCase_ == BarOneofCase.BarEnum ? (global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedEnum) bar_ : global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedEnum.BAR; } - } - - public const int BazIntFieldNumber = 18; - private bool hasBazInt; - private int bazInt_; - public bool HasBazInt { - get { return hasBazInt; } - } - public int BazInt { - get { return bazInt_; } - } - - public const int BazStringFieldNumber = 19; - private bool hasBazString; - private string bazString_ = "BAZ"; - public bool HasBazString { - get { return hasBazString; } - } - public string BazString { - get { return bazString_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testOneof2FieldNames; - if (fooCase_ == FooOneofCase.FooInt) { - output.WriteInt32(1, field_names[11], FooInt); - } - if (fooCase_ == FooOneofCase.FooString) { - output.WriteString(2, field_names[14], FooString); - } - if (fooCase_ == FooOneofCase.FooCord) { - output.WriteString(3, field_names[9], FooCord); - } - if (fooCase_ == FooOneofCase.FooStringPiece) { - output.WriteString(4, field_names[15], FooStringPiece); - } - if (fooCase_ == FooOneofCase.FooBytes) { - output.WriteBytes(5, field_names[8], FooBytes); - } - if (fooCase_ == FooOneofCase.FooEnum) { - output.WriteEnum(6, field_names[10], (int) FooEnum, FooEnum); - } - if (fooCase_ == FooOneofCase.FooMessage) { - output.WriteMessage(7, field_names[13], FooMessage); - } - if (fooCase_ == FooOneofCase.FooGroup) { - output.WriteGroup(8, field_names[16], FooGroup); - } - if (fooCase_ == FooOneofCase.FooLazyMessage) { - output.WriteMessage(11, field_names[12], FooLazyMessage); - } - if (barCase_ == BarOneofCase.BarInt) { - output.WriteInt32(12, field_names[3], BarInt); - } - if (barCase_ == BarOneofCase.BarString) { - output.WriteString(13, field_names[4], BarString); - } - if (barCase_ == BarOneofCase.BarCord) { - output.WriteString(14, field_names[1], BarCord); - } - if (barCase_ == BarOneofCase.BarStringPiece) { - output.WriteString(15, field_names[5], BarStringPiece); - } - if (barCase_ == BarOneofCase.BarBytes) { - output.WriteBytes(16, field_names[0], BarBytes); - } - if (barCase_ == BarOneofCase.BarEnum) { - output.WriteEnum(17, field_names[2], (int) BarEnum, BarEnum); - } - if (hasBazInt) { - output.WriteInt32(18, field_names[6], BazInt); - } - if (hasBazString) { - output.WriteString(19, field_names[7], BazString); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (fooCase_ == FooOneofCase.FooInt) { - size += pb::CodedOutputStream.ComputeInt32Size(1, FooInt); - } - if (fooCase_ == FooOneofCase.FooString) { - size += pb::CodedOutputStream.ComputeStringSize(2, FooString); - } - if (fooCase_ == FooOneofCase.FooCord) { - size += pb::CodedOutputStream.ComputeStringSize(3, FooCord); - } - if (fooCase_ == FooOneofCase.FooStringPiece) { - size += pb::CodedOutputStream.ComputeStringSize(4, FooStringPiece); - } - if (fooCase_ == FooOneofCase.FooBytes) { - size += pb::CodedOutputStream.ComputeBytesSize(5, FooBytes); - } - if (fooCase_ == FooOneofCase.FooEnum) { - size += pb::CodedOutputStream.ComputeEnumSize(6, (int) FooEnum); - } - if (fooCase_ == FooOneofCase.FooMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(7, FooMessage); - } - if (fooCase_ == FooOneofCase.FooGroup) { - size += pb::CodedOutputStream.ComputeGroupSize(8, FooGroup); - } - if (fooCase_ == FooOneofCase.FooLazyMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(11, FooLazyMessage); - } - if (barCase_ == BarOneofCase.BarInt) { - size += pb::CodedOutputStream.ComputeInt32Size(12, BarInt); - } - if (barCase_ == BarOneofCase.BarString) { - size += pb::CodedOutputStream.ComputeStringSize(13, BarString); - } - if (barCase_ == BarOneofCase.BarCord) { - size += pb::CodedOutputStream.ComputeStringSize(14, BarCord); - } - if (barCase_ == BarOneofCase.BarStringPiece) { - size += pb::CodedOutputStream.ComputeStringSize(15, BarStringPiece); - } - if (barCase_ == BarOneofCase.BarBytes) { - size += pb::CodedOutputStream.ComputeBytesSize(16, BarBytes); - } - if (barCase_ == BarOneofCase.BarEnum) { - size += pb::CodedOutputStream.ComputeEnumSize(17, (int) BarEnum); - } - if (hasBazInt) { - size += pb::CodedOutputStream.ComputeInt32Size(18, BazInt); - } - if (hasBazString) { - size += pb::CodedOutputStream.ComputeStringSize(19, BazString); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestOneof2 ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestOneof2 ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestOneof2 ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestOneof2 ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestOneof2 ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestOneof2 ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestOneof2 ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestOneof2 ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestOneof2 ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestOneof2 ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestOneof2 MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestOneof2 prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestOneof2 cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestOneof2 result; - - private TestOneof2 PrepareBuilder() { - if (resultIsReadOnly) { - TestOneof2 original = result; - result = new TestOneof2(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestOneof2 MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestOneof2.Descriptor; } - } - - public override TestOneof2 DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestOneof2.DefaultInstance; } - } - - public override TestOneof2 BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestOneof2) { - return MergeFrom((TestOneof2) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestOneof2 other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestOneof2.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasBazInt) { - BazInt = other.BazInt; - } - if (other.HasBazString) { - BazString = other.BazString; - } - switch (other.FooCase) { - case FooOneofCase.FooInt: { - SetFooInt(other.FooInt); - break; - } - case FooOneofCase.FooString: { - SetFooString(other.FooString); - break; - } - case FooOneofCase.FooCord: { - SetFooCord(other.FooCord); - break; - } - case FooOneofCase.FooStringPiece: { - SetFooStringPiece(other.FooStringPiece); - break; - } - case FooOneofCase.FooBytes: { - SetFooBytes(other.FooBytes); - break; - } - case FooOneofCase.FooEnum: { - SetFooEnum(other.FooEnum); - break; - } - case FooOneofCase.FooMessage: { - MergeFooMessage(other.FooMessage); - break; - } - case FooOneofCase.FooGroup: { - MergeFooGroup(other.FooGroup); - break; - } - case FooOneofCase.FooLazyMessage: { - MergeFooLazyMessage(other.FooLazyMessage); - break; - } - case FooOneofCase.None: { break; } - } - switch (other.BarCase) { - case BarOneofCase.BarInt: { - SetBarInt(other.BarInt); - break; - } - case BarOneofCase.BarString: { - SetBarString(other.BarString); - break; - } - case BarOneofCase.BarCord: { - SetBarCord(other.BarCord); - break; - } - case BarOneofCase.BarStringPiece: { - SetBarStringPiece(other.BarStringPiece); - break; - } - case BarOneofCase.BarBytes: { - SetBarBytes(other.BarBytes); - break; - } - case BarOneofCase.BarEnum: { - SetBarEnum(other.BarEnum); - break; - } - case BarOneofCase.None: { break; } - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testOneof2FieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testOneof2FieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - int value = 0; - if (input.ReadInt32(ref value)) { - result.foo_ = value; - result.fooCase_ = FooOneofCase.FooInt; - } - break; - } - case 18: { - string value = ""; - if (input.ReadString(ref value)) { - result.foo_ = value; - result.fooCase_ = FooOneofCase.FooString; - } - break; - } - case 26: { - string value = ""; - if (input.ReadString(ref value)) { - result.foo_ = value; - result.fooCase_ = FooOneofCase.FooCord; - } - break; - } - case 34: { - string value = ""; - if (input.ReadString(ref value)) { - result.foo_ = value; - result.fooCase_ = FooOneofCase.FooStringPiece; - } - break; - } - case 42: { - pb::ByteString value = pb::ByteString.Empty; - if (input.ReadBytes(ref value)) { - result.foo_ = value; - result.fooCase_ = FooOneofCase.FooBytes; - } - break; - } - case 48: { - object unknown; - global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedEnum enumValue = global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedEnum.FOO; - if(input.ReadEnum(ref enumValue, out unknown)) { - result.foo_ = enumValue; - result.fooCase_ = FooOneofCase.FooEnum; - } else if(unknown is int) { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - unknownFields.MergeVarintField(6, (ulong)(int)unknown); - } - break; - } - case 58: { - global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage.CreateBuilder(); - if (result.fooCase_ == FooOneofCase.FooMessage) { - subBuilder.MergeFrom(FooMessage); - } - input.ReadMessage(subBuilder, extensionRegistry); - result.foo_ = subBuilder.BuildPartial(); - result.fooCase_ = FooOneofCase.FooMessage; - break; - } - case 67: { - global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.FooGroup.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.FooGroup.CreateBuilder(); - if (result.fooCase_ == FooOneofCase.FooGroup) { - subBuilder.MergeFrom(FooGroup); - } - input.ReadGroup(8, subBuilder, extensionRegistry); - result.foo_ = subBuilder.BuildPartial(); - result.fooCase_ = FooOneofCase.FooGroup; - break; - } - case 90: { - global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage.CreateBuilder(); - if (result.fooCase_ == FooOneofCase.FooLazyMessage) { - subBuilder.MergeFrom(FooLazyMessage); - } - input.ReadMessage(subBuilder, extensionRegistry); - result.foo_ = subBuilder.BuildPartial(); - result.fooCase_ = FooOneofCase.FooLazyMessage; - break; - } - case 96: { - int value = 5; - if (input.ReadInt32(ref value)) { - result.bar_ = value; - result.barCase_ = BarOneofCase.BarInt; - } - break; - } - case 106: { - string value = "STRING"; - if (input.ReadString(ref value)) { - result.bar_ = value; - result.barCase_ = BarOneofCase.BarString; - } - break; - } - case 114: { - string value = "CORD"; - if (input.ReadString(ref value)) { - result.bar_ = value; - result.barCase_ = BarOneofCase.BarCord; - } - break; - } - case 122: { - string value = "SPIECE"; - if (input.ReadString(ref value)) { - result.bar_ = value; - result.barCase_ = BarOneofCase.BarStringPiece; - } - break; - } - case 130: { - pb::ByteString value = (pb::ByteString) global::Google.ProtocolBuffers.TestProtos.TestOneof2.Descriptor.Fields[13].DefaultValue; - if (input.ReadBytes(ref value)) { - result.bar_ = value; - result.barCase_ = BarOneofCase.BarBytes; - } - break; - } - case 136: { - object unknown; - global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedEnum enumValue = global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedEnum.BAR; - if(input.ReadEnum(ref enumValue, out unknown)) { - result.bar_ = enumValue; - result.barCase_ = BarOneofCase.BarEnum; - } else if(unknown is int) { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - unknownFields.MergeVarintField(17, (ulong)(int)unknown); - } - break; - } - case 144: { - result.hasBazInt = input.ReadInt32(ref result.bazInt_); - break; - } - case 154: { - result.hasBazString = input.ReadString(ref result.bazString_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasFooInt { - get { return result.fooCase_ == FooOneofCase.FooInt; } - } - public int FooInt { - get { return result.fooCase_ == FooOneofCase.FooInt ? (int) result.foo_ : 0; } - set { SetFooInt(value); } - } - public Builder SetFooInt(int value) { - PrepareBuilder(); - result.foo_ = value; - result.fooCase_ = FooOneofCase.FooInt; - return this; - } - public Builder ClearFooInt() { - PrepareBuilder(); - if (result.fooCase_ == FooOneofCase.FooInt) { - result.fooCase_ = FooOneofCase.None; - } - return this; - } - - public bool HasFooString { - get { return result.fooCase_ == FooOneofCase.FooString; } - } - public string FooString { - get { return result.fooCase_ == FooOneofCase.FooString ? (string) result.foo_ : ""; } - set { SetFooString(value); } - } - public Builder SetFooString(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.foo_ = value; - result.fooCase_ = FooOneofCase.FooString; - return this; - } - public Builder ClearFooString() { - PrepareBuilder(); - if (result.fooCase_ == FooOneofCase.FooString) { - result.fooCase_ = FooOneofCase.None; - } - return this; - } - - public bool HasFooCord { - get { return result.fooCase_ == FooOneofCase.FooCord; } - } - public string FooCord { - get { return result.fooCase_ == FooOneofCase.FooCord ? (string) result.foo_ : ""; } - set { SetFooCord(value); } - } - public Builder SetFooCord(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.foo_ = value; - result.fooCase_ = FooOneofCase.FooCord; - return this; - } - public Builder ClearFooCord() { - PrepareBuilder(); - if (result.fooCase_ == FooOneofCase.FooCord) { - result.fooCase_ = FooOneofCase.None; - } - return this; - } - - public bool HasFooStringPiece { - get { return result.fooCase_ == FooOneofCase.FooStringPiece; } - } - public string FooStringPiece { - get { return result.fooCase_ == FooOneofCase.FooStringPiece ? (string) result.foo_ : ""; } - set { SetFooStringPiece(value); } - } - public Builder SetFooStringPiece(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.foo_ = value; - result.fooCase_ = FooOneofCase.FooStringPiece; - return this; - } - public Builder ClearFooStringPiece() { - PrepareBuilder(); - if (result.fooCase_ == FooOneofCase.FooStringPiece) { - result.fooCase_ = FooOneofCase.None; - } - return this; - } - - public bool HasFooBytes { - get { return result.fooCase_ == FooOneofCase.FooBytes; } - } - public pb::ByteString FooBytes { - get { return result.fooCase_ == FooOneofCase.FooBytes ? (pb::ByteString) result.foo_ : pb::ByteString.Empty; } - set { SetFooBytes(value); } - } - public Builder SetFooBytes(pb::ByteString value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.foo_ = value; - result.fooCase_ = FooOneofCase.FooBytes; - return this; - } - public Builder ClearFooBytes() { - PrepareBuilder(); - if (result.fooCase_ == FooOneofCase.FooBytes) { - result.fooCase_ = FooOneofCase.None; - } - return this; - } - - public bool HasFooEnum { - get { return result.fooCase_ == FooOneofCase.FooEnum; } - } - public global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedEnum FooEnum { - get { return result.fooCase_ == FooOneofCase.FooEnum ? (global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedEnum) result.foo_ : global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedEnum.FOO; } - set { SetFooEnum(value); } - } - public Builder SetFooEnum(global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedEnum value) { - PrepareBuilder(); - result.foo_ = value; - result.fooCase_ = FooOneofCase.FooEnum; - return this; - } - public Builder ClearFooEnum() { - PrepareBuilder(); - if (result.fooCase_ == FooOneofCase.FooEnum) { - result.fooCase_ = FooOneofCase.None; - } - return this; - } - - public bool HasFooMessage { - get { return result.fooCase_ == FooOneofCase.FooMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage FooMessage { - get { return result.fooCase_ == FooOneofCase.FooMessage ? (global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage) result.foo_ : global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage.DefaultInstance; } - set { SetFooMessage(value); } - } - public Builder SetFooMessage(global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.fooCase_ = FooOneofCase.FooMessage; - result.foo_ = value; - return this; - } - public Builder SetFooMessage(global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.fooCase_ = FooOneofCase.FooMessage; - result.foo_ = builderForValue.Build(); - return this; - } - public Builder MergeFooMessage(global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.fooCase_ == FooOneofCase.FooMessage && - result.FooMessage != global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage.DefaultInstance) { - result.foo_ = global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage.CreateBuilder(result.FooMessage).MergeFrom(value).BuildPartial(); - } else { - result.foo_ = value; - } - result.fooCase_ = FooOneofCase.FooMessage; - return this; - } - public Builder ClearFooMessage() { - if (result.fooCase_ == FooOneofCase.FooMessage) { - PrepareBuilder(); - result.fooCase_ = FooOneofCase.None; - result.foo_ = null; - } - return this; - } - - public bool HasFooGroup { - get { return result.fooCase_ == FooOneofCase.FooGroup; } - } - public global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.FooGroup FooGroup { - get { return result.fooCase_ == FooOneofCase.FooGroup ? (global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.FooGroup) result.foo_ : global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.FooGroup.DefaultInstance; } - set { SetFooGroup(value); } - } - public Builder SetFooGroup(global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.FooGroup value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.fooCase_ = FooOneofCase.FooGroup; - result.foo_ = value; - return this; - } - public Builder SetFooGroup(global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.FooGroup.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.fooCase_ = FooOneofCase.FooGroup; - result.foo_ = builderForValue.Build(); - return this; - } - public Builder MergeFooGroup(global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.FooGroup value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.fooCase_ == FooOneofCase.FooGroup && - result.FooGroup != global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.FooGroup.DefaultInstance) { - result.foo_ = global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.FooGroup.CreateBuilder(result.FooGroup).MergeFrom(value).BuildPartial(); - } else { - result.foo_ = value; - } - result.fooCase_ = FooOneofCase.FooGroup; - return this; - } - public Builder ClearFooGroup() { - if (result.fooCase_ == FooOneofCase.FooGroup) { - PrepareBuilder(); - result.fooCase_ = FooOneofCase.None; - result.foo_ = null; - } - return this; - } - - public bool HasFooLazyMessage { - get { return result.fooCase_ == FooOneofCase.FooLazyMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage FooLazyMessage { - get { return result.fooCase_ == FooOneofCase.FooLazyMessage ? (global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage) result.foo_ : global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage.DefaultInstance; } - set { SetFooLazyMessage(value); } - } - public Builder SetFooLazyMessage(global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.fooCase_ = FooOneofCase.FooLazyMessage; - result.foo_ = value; - return this; - } - public Builder SetFooLazyMessage(global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.fooCase_ = FooOneofCase.FooLazyMessage; - result.foo_ = builderForValue.Build(); - return this; - } - public Builder MergeFooLazyMessage(global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.fooCase_ == FooOneofCase.FooLazyMessage && - result.FooLazyMessage != global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage.DefaultInstance) { - result.foo_ = global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage.CreateBuilder(result.FooLazyMessage).MergeFrom(value).BuildPartial(); - } else { - result.foo_ = value; - } - result.fooCase_ = FooOneofCase.FooLazyMessage; - return this; - } - public Builder ClearFooLazyMessage() { - if (result.fooCase_ == FooOneofCase.FooLazyMessage) { - PrepareBuilder(); - result.fooCase_ = FooOneofCase.None; - result.foo_ = null; - } - return this; - } - - public bool HasBarInt { - get { return result.barCase_ == BarOneofCase.BarInt; } - } - public int BarInt { - get { return result.barCase_ == BarOneofCase.BarInt ? (int) result.bar_ : 5; } - set { SetBarInt(value); } - } - public Builder SetBarInt(int value) { - PrepareBuilder(); - result.bar_ = value; - result.barCase_ = BarOneofCase.BarInt; - return this; - } - public Builder ClearBarInt() { - PrepareBuilder(); - if (result.barCase_ == BarOneofCase.BarInt) { - result.barCase_ = BarOneofCase.None; - } - return this; - } - - public bool HasBarString { - get { return result.barCase_ == BarOneofCase.BarString; } - } - public string BarString { - get { return result.barCase_ == BarOneofCase.BarString ? (string) result.bar_ : "STRING"; } - set { SetBarString(value); } - } - public Builder SetBarString(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.bar_ = value; - result.barCase_ = BarOneofCase.BarString; - return this; - } - public Builder ClearBarString() { - PrepareBuilder(); - if (result.barCase_ == BarOneofCase.BarString) { - result.barCase_ = BarOneofCase.None; - } - return this; - } - - public bool HasBarCord { - get { return result.barCase_ == BarOneofCase.BarCord; } - } - public string BarCord { - get { return result.barCase_ == BarOneofCase.BarCord ? (string) result.bar_ : "CORD"; } - set { SetBarCord(value); } - } - public Builder SetBarCord(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.bar_ = value; - result.barCase_ = BarOneofCase.BarCord; - return this; - } - public Builder ClearBarCord() { - PrepareBuilder(); - if (result.barCase_ == BarOneofCase.BarCord) { - result.barCase_ = BarOneofCase.None; - } - return this; - } - - public bool HasBarStringPiece { - get { return result.barCase_ == BarOneofCase.BarStringPiece; } - } - public string BarStringPiece { - get { return result.barCase_ == BarOneofCase.BarStringPiece ? (string) result.bar_ : "SPIECE"; } - set { SetBarStringPiece(value); } - } - public Builder SetBarStringPiece(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.bar_ = value; - result.barCase_ = BarOneofCase.BarStringPiece; - return this; - } - public Builder ClearBarStringPiece() { - PrepareBuilder(); - if (result.barCase_ == BarOneofCase.BarStringPiece) { - result.barCase_ = BarOneofCase.None; - } - return this; - } - - public bool HasBarBytes { - get { return result.barCase_ == BarOneofCase.BarBytes; } - } - public pb::ByteString BarBytes { - get { return result.barCase_ == BarOneofCase.BarBytes ? (pb::ByteString) result.bar_ : (pb::ByteString) global::Google.ProtocolBuffers.TestProtos.TestOneof2.Descriptor.Fields[13].DefaultValue; } - set { SetBarBytes(value); } - } - public Builder SetBarBytes(pb::ByteString value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.bar_ = value; - result.barCase_ = BarOneofCase.BarBytes; - return this; - } - public Builder ClearBarBytes() { - PrepareBuilder(); - if (result.barCase_ == BarOneofCase.BarBytes) { - result.barCase_ = BarOneofCase.None; - } - return this; - } - - public bool HasBarEnum { - get { return result.barCase_ == BarOneofCase.BarEnum; } - } - public global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedEnum BarEnum { - get { return result.barCase_ == BarOneofCase.BarEnum ? (global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedEnum) result.bar_ : global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedEnum.BAR; } - set { SetBarEnum(value); } - } - public Builder SetBarEnum(global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedEnum value) { - PrepareBuilder(); - result.bar_ = value; - result.barCase_ = BarOneofCase.BarEnum; - return this; - } - public Builder ClearBarEnum() { - PrepareBuilder(); - if (result.barCase_ == BarOneofCase.BarEnum) { - result.barCase_ = BarOneofCase.None; - } - return this; - } - - public bool HasBazInt { - get { return result.hasBazInt; } - } - public int BazInt { - get { return result.BazInt; } - set { SetBazInt(value); } - } - public Builder SetBazInt(int value) { - PrepareBuilder(); - result.hasBazInt = true; - result.bazInt_ = value; - return this; - } - public Builder ClearBazInt() { - PrepareBuilder(); - result.hasBazInt = false; - result.bazInt_ = 0; - return this; - } - - public bool HasBazString { - get { return result.hasBazString; } - } - public string BazString { - get { return result.BazString; } - set { SetBazString(value); } - } - public Builder SetBazString(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasBazString = true; - result.bazString_ = value; - return this; - } - public Builder ClearBazString() { - PrepareBuilder(); - result.hasBazString = false; - result.bazString_ = "BAZ"; - return this; - } - - public FooOneofCase FooCase { - get { return result.fooCase_; } - } - public Builder ClearFoo() { - PrepareBuilder(); - result.foo_ = null; - result.fooCase_ = FooOneofCase.None; - return this; - } - - public BarOneofCase BarCase { - get { return result.barCase_; } - } - public Builder ClearBar() { - PrepareBuilder(); - result.bar_ = null; - result.barCase_ = BarOneofCase.None; - return this; - } - } - static TestOneof2() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestRequiredOneof : pb::GeneratedMessage { - private TestRequiredOneof() { } - private static readonly TestRequiredOneof defaultInstance = new TestRequiredOneof().MakeReadOnly(); - private static readonly string[] _testRequiredOneofFieldNames = new string[] { "foo_int", "foo_message", "foo_string" }; - private static readonly uint[] _testRequiredOneofFieldTags = new uint[] { 8, 26, 18 }; - public static TestRequiredOneof DefaultInstance { - get { return defaultInstance; } - } - - public override TestRequiredOneof DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestRequiredOneof ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestRequiredOneof__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestRequiredOneof__FieldAccessorTable; } - } - - #region Nested types - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class Types { - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class NestedMessage : pb::GeneratedMessage { - private NestedMessage() { } - private static readonly NestedMessage defaultInstance = new NestedMessage().MakeReadOnly(); - private static readonly string[] _nestedMessageFieldNames = new string[] { "required_double" }; - private static readonly uint[] _nestedMessageFieldTags = new uint[] { 9 }; - public static NestedMessage DefaultInstance { - get { return defaultInstance; } - } - - public override NestedMessage DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override NestedMessage ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestRequiredOneof_NestedMessage__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestRequiredOneof_NestedMessage__FieldAccessorTable; } - } - - public const int RequiredDoubleFieldNumber = 1; - private bool hasRequiredDouble; - private double requiredDouble_; - public bool HasRequiredDouble { - get { return hasRequiredDouble; } - } - public double RequiredDouble { - get { return requiredDouble_; } - } - - public override bool IsInitialized { - get { - if (!hasRequiredDouble) return false; - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _nestedMessageFieldNames; - if (hasRequiredDouble) { - output.WriteDouble(1, field_names[0], RequiredDouble); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasRequiredDouble) { - size += pb::CodedOutputStream.ComputeDoubleSize(1, RequiredDouble); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static NestedMessage ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static NestedMessage ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static NestedMessage ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static NestedMessage ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static NestedMessage ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static NestedMessage ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static NestedMessage ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static NestedMessage ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static NestedMessage ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static NestedMessage ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private NestedMessage MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(NestedMessage prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(NestedMessage cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private NestedMessage result; - - private NestedMessage PrepareBuilder() { - if (resultIsReadOnly) { - NestedMessage original = result; - result = new NestedMessage(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override NestedMessage MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestRequiredOneof.Types.NestedMessage.Descriptor; } - } - - public override NestedMessage DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestRequiredOneof.Types.NestedMessage.DefaultInstance; } - } - - public override NestedMessage BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is NestedMessage) { - return MergeFrom((NestedMessage) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(NestedMessage other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestRequiredOneof.Types.NestedMessage.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasRequiredDouble) { - RequiredDouble = other.RequiredDouble; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_nestedMessageFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _nestedMessageFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 9: { - result.hasRequiredDouble = input.ReadDouble(ref result.requiredDouble_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasRequiredDouble { - get { return result.hasRequiredDouble; } - } - public double RequiredDouble { - get { return result.RequiredDouble; } - set { SetRequiredDouble(value); } - } - public Builder SetRequiredDouble(double value) { - PrepareBuilder(); - result.hasRequiredDouble = true; - result.requiredDouble_ = value; - return this; - } - public Builder ClearRequiredDouble() { - PrepareBuilder(); - result.hasRequiredDouble = false; - result.requiredDouble_ = 0D; - return this; - } - } - static NestedMessage() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - } - #endregion - - private object foo_; - public enum FooOneofCase { - FooInt = 1, - FooString = 2, - FooMessage = 3, - None = 0, - } - private FooOneofCase fooCase_ = FooOneofCase.None; - public FooOneofCase FooCase { - get { return fooCase_; } - } - - public const int FooIntFieldNumber = 1; - public bool HasFooInt { - get { return fooCase_ == FooOneofCase.FooInt; } - } - public int FooInt { - get { return fooCase_ == FooOneofCase.FooInt ? (int) foo_ : 0; } - } - - public const int FooStringFieldNumber = 2; - public bool HasFooString { - get { return fooCase_ == FooOneofCase.FooString; } - } - public string FooString { - get { return fooCase_ == FooOneofCase.FooString ? (string) foo_ : ""; } - } - - public const int FooMessageFieldNumber = 3; - public bool HasFooMessage { - get { return fooCase_ == FooOneofCase.FooMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestRequiredOneof.Types.NestedMessage FooMessage { - get { return fooCase_ == FooOneofCase.FooMessage ? (global::Google.ProtocolBuffers.TestProtos.TestRequiredOneof.Types.NestedMessage) foo_ : global::Google.ProtocolBuffers.TestProtos.TestRequiredOneof.Types.NestedMessage.DefaultInstance; } - } - - public override bool IsInitialized { - get { - if (HasFooMessage) { - if (!FooMessage.IsInitialized) return false; - } - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testRequiredOneofFieldNames; - if (fooCase_ == FooOneofCase.FooInt) { - output.WriteInt32(1, field_names[0], FooInt); - } - if (fooCase_ == FooOneofCase.FooString) { - output.WriteString(2, field_names[2], FooString); - } - if (fooCase_ == FooOneofCase.FooMessage) { - output.WriteMessage(3, field_names[1], FooMessage); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (fooCase_ == FooOneofCase.FooInt) { - size += pb::CodedOutputStream.ComputeInt32Size(1, FooInt); - } - if (fooCase_ == FooOneofCase.FooString) { - size += pb::CodedOutputStream.ComputeStringSize(2, FooString); - } - if (fooCase_ == FooOneofCase.FooMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(3, FooMessage); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestRequiredOneof ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestRequiredOneof ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestRequiredOneof ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestRequiredOneof ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestRequiredOneof ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestRequiredOneof ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestRequiredOneof ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestRequiredOneof ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestRequiredOneof ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestRequiredOneof ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestRequiredOneof MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestRequiredOneof prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestRequiredOneof cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestRequiredOneof result; - - private TestRequiredOneof PrepareBuilder() { - if (resultIsReadOnly) { - TestRequiredOneof original = result; - result = new TestRequiredOneof(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestRequiredOneof MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestRequiredOneof.Descriptor; } - } - - public override TestRequiredOneof DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestRequiredOneof.DefaultInstance; } - } - - public override TestRequiredOneof BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestRequiredOneof) { - return MergeFrom((TestRequiredOneof) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestRequiredOneof other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestRequiredOneof.DefaultInstance) return this; - PrepareBuilder(); - switch (other.FooCase) { - case FooOneofCase.FooInt: { - SetFooInt(other.FooInt); - break; - } - case FooOneofCase.FooString: { - SetFooString(other.FooString); - break; - } - case FooOneofCase.FooMessage: { - MergeFooMessage(other.FooMessage); - break; - } - case FooOneofCase.None: { break; } - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testRequiredOneofFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testRequiredOneofFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - int value = 0; - if (input.ReadInt32(ref value)) { - result.foo_ = value; - result.fooCase_ = FooOneofCase.FooInt; - } - break; - } - case 18: { - string value = ""; - if (input.ReadString(ref value)) { - result.foo_ = value; - result.fooCase_ = FooOneofCase.FooString; - } - break; - } - case 26: { - global::Google.ProtocolBuffers.TestProtos.TestRequiredOneof.Types.NestedMessage.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestRequiredOneof.Types.NestedMessage.CreateBuilder(); - if (result.fooCase_ == FooOneofCase.FooMessage) { - subBuilder.MergeFrom(FooMessage); - } - input.ReadMessage(subBuilder, extensionRegistry); - result.foo_ = subBuilder.BuildPartial(); - result.fooCase_ = FooOneofCase.FooMessage; - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasFooInt { - get { return result.fooCase_ == FooOneofCase.FooInt; } - } - public int FooInt { - get { return result.fooCase_ == FooOneofCase.FooInt ? (int) result.foo_ : 0; } - set { SetFooInt(value); } - } - public Builder SetFooInt(int value) { - PrepareBuilder(); - result.foo_ = value; - result.fooCase_ = FooOneofCase.FooInt; - return this; - } - public Builder ClearFooInt() { - PrepareBuilder(); - if (result.fooCase_ == FooOneofCase.FooInt) { - result.fooCase_ = FooOneofCase.None; - } - return this; - } - - public bool HasFooString { - get { return result.fooCase_ == FooOneofCase.FooString; } - } - public string FooString { - get { return result.fooCase_ == FooOneofCase.FooString ? (string) result.foo_ : ""; } - set { SetFooString(value); } - } - public Builder SetFooString(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.foo_ = value; - result.fooCase_ = FooOneofCase.FooString; - return this; - } - public Builder ClearFooString() { - PrepareBuilder(); - if (result.fooCase_ == FooOneofCase.FooString) { - result.fooCase_ = FooOneofCase.None; - } - return this; - } - - public bool HasFooMessage { - get { return result.fooCase_ == FooOneofCase.FooMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestRequiredOneof.Types.NestedMessage FooMessage { - get { return result.fooCase_ == FooOneofCase.FooMessage ? (global::Google.ProtocolBuffers.TestProtos.TestRequiredOneof.Types.NestedMessage) result.foo_ : global::Google.ProtocolBuffers.TestProtos.TestRequiredOneof.Types.NestedMessage.DefaultInstance; } - set { SetFooMessage(value); } - } - public Builder SetFooMessage(global::Google.ProtocolBuffers.TestProtos.TestRequiredOneof.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.fooCase_ = FooOneofCase.FooMessage; - result.foo_ = value; - return this; - } - public Builder SetFooMessage(global::Google.ProtocolBuffers.TestProtos.TestRequiredOneof.Types.NestedMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.fooCase_ = FooOneofCase.FooMessage; - result.foo_ = builderForValue.Build(); - return this; - } - public Builder MergeFooMessage(global::Google.ProtocolBuffers.TestProtos.TestRequiredOneof.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.fooCase_ == FooOneofCase.FooMessage && - result.FooMessage != global::Google.ProtocolBuffers.TestProtos.TestRequiredOneof.Types.NestedMessage.DefaultInstance) { - result.foo_ = global::Google.ProtocolBuffers.TestProtos.TestRequiredOneof.Types.NestedMessage.CreateBuilder(result.FooMessage).MergeFrom(value).BuildPartial(); - } else { - result.foo_ = value; - } - result.fooCase_ = FooOneofCase.FooMessage; - return this; - } - public Builder ClearFooMessage() { - if (result.fooCase_ == FooOneofCase.FooMessage) { - PrepareBuilder(); - result.fooCase_ = FooOneofCase.None; - result.foo_ = null; - } - return this; - } - - public FooOneofCase FooCase { - get { return result.fooCase_; } - } - public Builder ClearFoo() { - PrepareBuilder(); - result.foo_ = null; - result.fooCase_ = FooOneofCase.None; - return this; - } - } - static TestRequiredOneof() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestPackedTypes : pb::GeneratedMessage { - private TestPackedTypes() { } - private static readonly TestPackedTypes defaultInstance = new TestPackedTypes().MakeReadOnly(); - private static readonly string[] _testPackedTypesFieldNames = new string[] { "packed_bool", "packed_double", "packed_enum", "packed_fixed32", "packed_fixed64", "packed_float", "packed_int32", "packed_int64", "packed_sfixed32", "packed_sfixed64", "packed_sint32", "packed_sint64", "packed_uint32", "packed_uint64" }; - private static readonly uint[] _testPackedTypesFieldTags = new uint[] { 818, 810, 826, 770, 778, 802, 722, 730, 786, 794, 754, 762, 738, 746 }; - public static TestPackedTypes DefaultInstance { - get { return defaultInstance; } - } - - public override TestPackedTypes DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestPackedTypes ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestPackedTypes__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestPackedTypes__FieldAccessorTable; } - } - - public const int PackedInt32FieldNumber = 90; - private int packedInt32MemoizedSerializedSize; - private pbc::PopsicleList packedInt32_ = new pbc::PopsicleList(); - public scg::IList PackedInt32List { - get { return pbc::Lists.AsReadOnly(packedInt32_); } - } - public int PackedInt32Count { - get { return packedInt32_.Count; } - } - public int GetPackedInt32(int index) { - return packedInt32_[index]; - } - - public const int PackedInt64FieldNumber = 91; - private int packedInt64MemoizedSerializedSize; - private pbc::PopsicleList packedInt64_ = new pbc::PopsicleList(); - public scg::IList PackedInt64List { - get { return pbc::Lists.AsReadOnly(packedInt64_); } - } - public int PackedInt64Count { - get { return packedInt64_.Count; } - } - public long GetPackedInt64(int index) { - return packedInt64_[index]; - } - - public const int PackedUint32FieldNumber = 92; - private int packedUint32MemoizedSerializedSize; - private pbc::PopsicleList packedUint32_ = new pbc::PopsicleList(); - public scg::IList PackedUint32List { - get { return pbc::Lists.AsReadOnly(packedUint32_); } - } - public int PackedUint32Count { - get { return packedUint32_.Count; } - } - public uint GetPackedUint32(int index) { - return packedUint32_[index]; - } - - public const int PackedUint64FieldNumber = 93; - private int packedUint64MemoizedSerializedSize; - private pbc::PopsicleList packedUint64_ = new pbc::PopsicleList(); - public scg::IList PackedUint64List { - get { return pbc::Lists.AsReadOnly(packedUint64_); } - } - public int PackedUint64Count { - get { return packedUint64_.Count; } - } - public ulong GetPackedUint64(int index) { - return packedUint64_[index]; - } - - public const int PackedSint32FieldNumber = 94; - private int packedSint32MemoizedSerializedSize; - private pbc::PopsicleList packedSint32_ = new pbc::PopsicleList(); - public scg::IList PackedSint32List { - get { return pbc::Lists.AsReadOnly(packedSint32_); } - } - public int PackedSint32Count { - get { return packedSint32_.Count; } - } - public int GetPackedSint32(int index) { - return packedSint32_[index]; - } - - public const int PackedSint64FieldNumber = 95; - private int packedSint64MemoizedSerializedSize; - private pbc::PopsicleList packedSint64_ = new pbc::PopsicleList(); - public scg::IList PackedSint64List { - get { return pbc::Lists.AsReadOnly(packedSint64_); } - } - public int PackedSint64Count { - get { return packedSint64_.Count; } - } - public long GetPackedSint64(int index) { - return packedSint64_[index]; - } - - public const int PackedFixed32FieldNumber = 96; - private int packedFixed32MemoizedSerializedSize; - private pbc::PopsicleList packedFixed32_ = new pbc::PopsicleList(); - public scg::IList PackedFixed32List { - get { return pbc::Lists.AsReadOnly(packedFixed32_); } - } - public int PackedFixed32Count { - get { return packedFixed32_.Count; } - } - public uint GetPackedFixed32(int index) { - return packedFixed32_[index]; - } - - public const int PackedFixed64FieldNumber = 97; - private int packedFixed64MemoizedSerializedSize; - private pbc::PopsicleList packedFixed64_ = new pbc::PopsicleList(); - public scg::IList PackedFixed64List { - get { return pbc::Lists.AsReadOnly(packedFixed64_); } - } - public int PackedFixed64Count { - get { return packedFixed64_.Count; } - } - public ulong GetPackedFixed64(int index) { - return packedFixed64_[index]; - } - - public const int PackedSfixed32FieldNumber = 98; - private int packedSfixed32MemoizedSerializedSize; - private pbc::PopsicleList packedSfixed32_ = new pbc::PopsicleList(); - public scg::IList PackedSfixed32List { - get { return pbc::Lists.AsReadOnly(packedSfixed32_); } - } - public int PackedSfixed32Count { - get { return packedSfixed32_.Count; } - } - public int GetPackedSfixed32(int index) { - return packedSfixed32_[index]; - } - - public const int PackedSfixed64FieldNumber = 99; - private int packedSfixed64MemoizedSerializedSize; - private pbc::PopsicleList packedSfixed64_ = new pbc::PopsicleList(); - public scg::IList PackedSfixed64List { - get { return pbc::Lists.AsReadOnly(packedSfixed64_); } - } - public int PackedSfixed64Count { - get { return packedSfixed64_.Count; } - } - public long GetPackedSfixed64(int index) { - return packedSfixed64_[index]; - } - - public const int PackedFloatFieldNumber = 100; - private int packedFloatMemoizedSerializedSize; - private pbc::PopsicleList packedFloat_ = new pbc::PopsicleList(); - public scg::IList PackedFloatList { - get { return pbc::Lists.AsReadOnly(packedFloat_); } - } - public int PackedFloatCount { - get { return packedFloat_.Count; } - } - public float GetPackedFloat(int index) { - return packedFloat_[index]; - } - - public const int PackedDoubleFieldNumber = 101; - private int packedDoubleMemoizedSerializedSize; - private pbc::PopsicleList packedDouble_ = new pbc::PopsicleList(); - public scg::IList PackedDoubleList { - get { return pbc::Lists.AsReadOnly(packedDouble_); } - } - public int PackedDoubleCount { - get { return packedDouble_.Count; } - } - public double GetPackedDouble(int index) { - return packedDouble_[index]; - } - - public const int PackedBoolFieldNumber = 102; - private int packedBoolMemoizedSerializedSize; - private pbc::PopsicleList packedBool_ = new pbc::PopsicleList(); - public scg::IList PackedBoolList { - get { return pbc::Lists.AsReadOnly(packedBool_); } - } - public int PackedBoolCount { - get { return packedBool_.Count; } - } - public bool GetPackedBool(int index) { - return packedBool_[index]; - } - - public const int PackedEnumFieldNumber = 103; - private int packedEnumMemoizedSerializedSize; - private pbc::PopsicleList packedEnum_ = new pbc::PopsicleList(); - public scg::IList PackedEnumList { - get { return pbc::Lists.AsReadOnly(packedEnum_); } - } - public int PackedEnumCount { - get { return packedEnum_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignEnum GetPackedEnum(int index) { - return packedEnum_[index]; - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testPackedTypesFieldNames; - if (packedInt32_.Count > 0) { - output.WritePackedInt32Array(90, field_names[6], packedInt32MemoizedSerializedSize, packedInt32_); - } - if (packedInt64_.Count > 0) { - output.WritePackedInt64Array(91, field_names[7], packedInt64MemoizedSerializedSize, packedInt64_); - } - if (packedUint32_.Count > 0) { - output.WritePackedUInt32Array(92, field_names[12], packedUint32MemoizedSerializedSize, packedUint32_); - } - if (packedUint64_.Count > 0) { - output.WritePackedUInt64Array(93, field_names[13], packedUint64MemoizedSerializedSize, packedUint64_); - } - if (packedSint32_.Count > 0) { - output.WritePackedSInt32Array(94, field_names[10], packedSint32MemoizedSerializedSize, packedSint32_); - } - if (packedSint64_.Count > 0) { - output.WritePackedSInt64Array(95, field_names[11], packedSint64MemoizedSerializedSize, packedSint64_); - } - if (packedFixed32_.Count > 0) { - output.WritePackedFixed32Array(96, field_names[3], packedFixed32MemoizedSerializedSize, packedFixed32_); - } - if (packedFixed64_.Count > 0) { - output.WritePackedFixed64Array(97, field_names[4], packedFixed64MemoizedSerializedSize, packedFixed64_); - } - if (packedSfixed32_.Count > 0) { - output.WritePackedSFixed32Array(98, field_names[8], packedSfixed32MemoizedSerializedSize, packedSfixed32_); - } - if (packedSfixed64_.Count > 0) { - output.WritePackedSFixed64Array(99, field_names[9], packedSfixed64MemoizedSerializedSize, packedSfixed64_); - } - if (packedFloat_.Count > 0) { - output.WritePackedFloatArray(100, field_names[5], packedFloatMemoizedSerializedSize, packedFloat_); - } - if (packedDouble_.Count > 0) { - output.WritePackedDoubleArray(101, field_names[1], packedDoubleMemoizedSerializedSize, packedDouble_); - } - if (packedBool_.Count > 0) { - output.WritePackedBoolArray(102, field_names[0], packedBoolMemoizedSerializedSize, packedBool_); - } - if (packedEnum_.Count > 0) { - output.WritePackedEnumArray(103, field_names[2], packedEnumMemoizedSerializedSize, packedEnum_); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - { - int dataSize = 0; - foreach (int element in PackedInt32List) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); - } - size += dataSize; - if (packedInt32_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedInt32MemoizedSerializedSize = dataSize; - } - { - int dataSize = 0; - foreach (long element in PackedInt64List) { - dataSize += pb::CodedOutputStream.ComputeInt64SizeNoTag(element); - } - size += dataSize; - if (packedInt64_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedInt64MemoizedSerializedSize = dataSize; - } - { - int dataSize = 0; - foreach (uint element in PackedUint32List) { - dataSize += pb::CodedOutputStream.ComputeUInt32SizeNoTag(element); - } - size += dataSize; - if (packedUint32_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedUint32MemoizedSerializedSize = dataSize; - } - { - int dataSize = 0; - foreach (ulong element in PackedUint64List) { - dataSize += pb::CodedOutputStream.ComputeUInt64SizeNoTag(element); - } - size += dataSize; - if (packedUint64_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedUint64MemoizedSerializedSize = dataSize; - } - { - int dataSize = 0; - foreach (int element in PackedSint32List) { - dataSize += pb::CodedOutputStream.ComputeSInt32SizeNoTag(element); - } - size += dataSize; - if (packedSint32_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedSint32MemoizedSerializedSize = dataSize; - } - { - int dataSize = 0; - foreach (long element in PackedSint64List) { - dataSize += pb::CodedOutputStream.ComputeSInt64SizeNoTag(element); - } - size += dataSize; - if (packedSint64_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedSint64MemoizedSerializedSize = dataSize; - } - { - int dataSize = 0; - dataSize = 4 * packedFixed32_.Count; - size += dataSize; - if (packedFixed32_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedFixed32MemoizedSerializedSize = dataSize; - } - { - int dataSize = 0; - dataSize = 8 * packedFixed64_.Count; - size += dataSize; - if (packedFixed64_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedFixed64MemoizedSerializedSize = dataSize; - } - { - int dataSize = 0; - dataSize = 4 * packedSfixed32_.Count; - size += dataSize; - if (packedSfixed32_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedSfixed32MemoizedSerializedSize = dataSize; - } - { - int dataSize = 0; - dataSize = 8 * packedSfixed64_.Count; - size += dataSize; - if (packedSfixed64_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedSfixed64MemoizedSerializedSize = dataSize; - } - { - int dataSize = 0; - dataSize = 4 * packedFloat_.Count; - size += dataSize; - if (packedFloat_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedFloatMemoizedSerializedSize = dataSize; - } - { - int dataSize = 0; - dataSize = 8 * packedDouble_.Count; - size += dataSize; - if (packedDouble_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedDoubleMemoizedSerializedSize = dataSize; - } - { - int dataSize = 0; - dataSize = 1 * packedBool_.Count; - size += dataSize; - if (packedBool_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedBoolMemoizedSerializedSize = dataSize; - } - { - int dataSize = 0; - if (packedEnum_.Count > 0) { - foreach (global::Google.ProtocolBuffers.TestProtos.ForeignEnum element in packedEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 2; - size += pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize); - } - packedEnumMemoizedSerializedSize = dataSize; - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestPackedTypes ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestPackedTypes ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestPackedTypes ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestPackedTypes ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestPackedTypes ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestPackedTypes ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestPackedTypes ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestPackedTypes ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestPackedTypes ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestPackedTypes ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestPackedTypes MakeReadOnly() { - packedInt32_.MakeReadOnly(); - packedInt64_.MakeReadOnly(); - packedUint32_.MakeReadOnly(); - packedUint64_.MakeReadOnly(); - packedSint32_.MakeReadOnly(); - packedSint64_.MakeReadOnly(); - packedFixed32_.MakeReadOnly(); - packedFixed64_.MakeReadOnly(); - packedSfixed32_.MakeReadOnly(); - packedSfixed64_.MakeReadOnly(); - packedFloat_.MakeReadOnly(); - packedDouble_.MakeReadOnly(); - packedBool_.MakeReadOnly(); - packedEnum_.MakeReadOnly(); - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestPackedTypes prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestPackedTypes cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestPackedTypes result; - - private TestPackedTypes PrepareBuilder() { - if (resultIsReadOnly) { - TestPackedTypes original = result; - result = new TestPackedTypes(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestPackedTypes MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestPackedTypes.Descriptor; } - } - - public override TestPackedTypes DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestPackedTypes.DefaultInstance; } - } - - public override TestPackedTypes BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestPackedTypes) { - return MergeFrom((TestPackedTypes) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestPackedTypes other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestPackedTypes.DefaultInstance) return this; - PrepareBuilder(); - if (other.packedInt32_.Count != 0) { - result.packedInt32_.Add(other.packedInt32_); - } - if (other.packedInt64_.Count != 0) { - result.packedInt64_.Add(other.packedInt64_); - } - if (other.packedUint32_.Count != 0) { - result.packedUint32_.Add(other.packedUint32_); - } - if (other.packedUint64_.Count != 0) { - result.packedUint64_.Add(other.packedUint64_); - } - if (other.packedSint32_.Count != 0) { - result.packedSint32_.Add(other.packedSint32_); - } - if (other.packedSint64_.Count != 0) { - result.packedSint64_.Add(other.packedSint64_); - } - if (other.packedFixed32_.Count != 0) { - result.packedFixed32_.Add(other.packedFixed32_); - } - if (other.packedFixed64_.Count != 0) { - result.packedFixed64_.Add(other.packedFixed64_); - } - if (other.packedSfixed32_.Count != 0) { - result.packedSfixed32_.Add(other.packedSfixed32_); - } - if (other.packedSfixed64_.Count != 0) { - result.packedSfixed64_.Add(other.packedSfixed64_); - } - if (other.packedFloat_.Count != 0) { - result.packedFloat_.Add(other.packedFloat_); - } - if (other.packedDouble_.Count != 0) { - result.packedDouble_.Add(other.packedDouble_); - } - if (other.packedBool_.Count != 0) { - result.packedBool_.Add(other.packedBool_); - } - if (other.packedEnum_.Count != 0) { - result.packedEnum_.Add(other.packedEnum_); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testPackedTypesFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testPackedTypesFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 722: - case 720: { - input.ReadInt32Array(tag, field_name, result.packedInt32_); - break; - } - case 730: - case 728: { - input.ReadInt64Array(tag, field_name, result.packedInt64_); - break; - } - case 738: - case 736: { - input.ReadUInt32Array(tag, field_name, result.packedUint32_); - break; - } - case 746: - case 744: { - input.ReadUInt64Array(tag, field_name, result.packedUint64_); - break; - } - case 754: - case 752: { - input.ReadSInt32Array(tag, field_name, result.packedSint32_); - break; - } - case 762: - case 760: { - input.ReadSInt64Array(tag, field_name, result.packedSint64_); - break; - } - case 770: - case 773: { - input.ReadFixed32Array(tag, field_name, result.packedFixed32_); - break; - } - case 778: - case 777: { - input.ReadFixed64Array(tag, field_name, result.packedFixed64_); - break; - } - case 786: - case 789: { - input.ReadSFixed32Array(tag, field_name, result.packedSfixed32_); - break; - } - case 794: - case 793: { - input.ReadSFixed64Array(tag, field_name, result.packedSfixed64_); - break; - } - case 802: - case 805: { - input.ReadFloatArray(tag, field_name, result.packedFloat_); - break; - } - case 810: - case 809: { - input.ReadDoubleArray(tag, field_name, result.packedDouble_); - break; - } - case 818: - case 816: { - input.ReadBoolArray(tag, field_name, result.packedBool_); - break; - } - case 826: - case 824: { - scg::ICollection unknownItems; - input.ReadEnumArray(tag, field_name, result.packedEnum_, out unknownItems); - if (unknownItems != null) { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - foreach (object rawValue in unknownItems) - if (rawValue is int) - unknownFields.MergeVarintField(103, (ulong)(int)rawValue); - } - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public pbc::IPopsicleList PackedInt32List { - get { return PrepareBuilder().packedInt32_; } - } - public int PackedInt32Count { - get { return result.PackedInt32Count; } - } - public int GetPackedInt32(int index) { - return result.GetPackedInt32(index); - } - public Builder SetPackedInt32(int index, int value) { - PrepareBuilder(); - result.packedInt32_[index] = value; - return this; - } - public Builder AddPackedInt32(int value) { - PrepareBuilder(); - result.packedInt32_.Add(value); - return this; - } - public Builder AddRangePackedInt32(scg::IEnumerable values) { - PrepareBuilder(); - result.packedInt32_.Add(values); - return this; - } - public Builder ClearPackedInt32() { - PrepareBuilder(); - result.packedInt32_.Clear(); - return this; - } - - public pbc::IPopsicleList PackedInt64List { - get { return PrepareBuilder().packedInt64_; } - } - public int PackedInt64Count { - get { return result.PackedInt64Count; } - } - public long GetPackedInt64(int index) { - return result.GetPackedInt64(index); - } - public Builder SetPackedInt64(int index, long value) { - PrepareBuilder(); - result.packedInt64_[index] = value; - return this; - } - public Builder AddPackedInt64(long value) { - PrepareBuilder(); - result.packedInt64_.Add(value); - return this; - } - public Builder AddRangePackedInt64(scg::IEnumerable values) { - PrepareBuilder(); - result.packedInt64_.Add(values); - return this; - } - public Builder ClearPackedInt64() { - PrepareBuilder(); - result.packedInt64_.Clear(); - return this; - } - - public pbc::IPopsicleList PackedUint32List { - get { return PrepareBuilder().packedUint32_; } - } - public int PackedUint32Count { - get { return result.PackedUint32Count; } - } - public uint GetPackedUint32(int index) { - return result.GetPackedUint32(index); - } - public Builder SetPackedUint32(int index, uint value) { - PrepareBuilder(); - result.packedUint32_[index] = value; - return this; - } - public Builder AddPackedUint32(uint value) { - PrepareBuilder(); - result.packedUint32_.Add(value); - return this; - } - public Builder AddRangePackedUint32(scg::IEnumerable values) { - PrepareBuilder(); - result.packedUint32_.Add(values); - return this; - } - public Builder ClearPackedUint32() { - PrepareBuilder(); - result.packedUint32_.Clear(); - return this; - } - - public pbc::IPopsicleList PackedUint64List { - get { return PrepareBuilder().packedUint64_; } - } - public int PackedUint64Count { - get { return result.PackedUint64Count; } - } - public ulong GetPackedUint64(int index) { - return result.GetPackedUint64(index); - } - public Builder SetPackedUint64(int index, ulong value) { - PrepareBuilder(); - result.packedUint64_[index] = value; - return this; - } - public Builder AddPackedUint64(ulong value) { - PrepareBuilder(); - result.packedUint64_.Add(value); - return this; - } - public Builder AddRangePackedUint64(scg::IEnumerable values) { - PrepareBuilder(); - result.packedUint64_.Add(values); - return this; - } - public Builder ClearPackedUint64() { - PrepareBuilder(); - result.packedUint64_.Clear(); - return this; - } - - public pbc::IPopsicleList PackedSint32List { - get { return PrepareBuilder().packedSint32_; } - } - public int PackedSint32Count { - get { return result.PackedSint32Count; } - } - public int GetPackedSint32(int index) { - return result.GetPackedSint32(index); - } - public Builder SetPackedSint32(int index, int value) { - PrepareBuilder(); - result.packedSint32_[index] = value; - return this; - } - public Builder AddPackedSint32(int value) { - PrepareBuilder(); - result.packedSint32_.Add(value); - return this; - } - public Builder AddRangePackedSint32(scg::IEnumerable values) { - PrepareBuilder(); - result.packedSint32_.Add(values); - return this; - } - public Builder ClearPackedSint32() { - PrepareBuilder(); - result.packedSint32_.Clear(); - return this; - } - - public pbc::IPopsicleList PackedSint64List { - get { return PrepareBuilder().packedSint64_; } - } - public int PackedSint64Count { - get { return result.PackedSint64Count; } - } - public long GetPackedSint64(int index) { - return result.GetPackedSint64(index); - } - public Builder SetPackedSint64(int index, long value) { - PrepareBuilder(); - result.packedSint64_[index] = value; - return this; - } - public Builder AddPackedSint64(long value) { - PrepareBuilder(); - result.packedSint64_.Add(value); - return this; - } - public Builder AddRangePackedSint64(scg::IEnumerable values) { - PrepareBuilder(); - result.packedSint64_.Add(values); - return this; - } - public Builder ClearPackedSint64() { - PrepareBuilder(); - result.packedSint64_.Clear(); - return this; - } - - public pbc::IPopsicleList PackedFixed32List { - get { return PrepareBuilder().packedFixed32_; } - } - public int PackedFixed32Count { - get { return result.PackedFixed32Count; } - } - public uint GetPackedFixed32(int index) { - return result.GetPackedFixed32(index); - } - public Builder SetPackedFixed32(int index, uint value) { - PrepareBuilder(); - result.packedFixed32_[index] = value; - return this; - } - public Builder AddPackedFixed32(uint value) { - PrepareBuilder(); - result.packedFixed32_.Add(value); - return this; - } - public Builder AddRangePackedFixed32(scg::IEnumerable values) { - PrepareBuilder(); - result.packedFixed32_.Add(values); - return this; - } - public Builder ClearPackedFixed32() { - PrepareBuilder(); - result.packedFixed32_.Clear(); - return this; - } - - public pbc::IPopsicleList PackedFixed64List { - get { return PrepareBuilder().packedFixed64_; } - } - public int PackedFixed64Count { - get { return result.PackedFixed64Count; } - } - public ulong GetPackedFixed64(int index) { - return result.GetPackedFixed64(index); - } - public Builder SetPackedFixed64(int index, ulong value) { - PrepareBuilder(); - result.packedFixed64_[index] = value; - return this; - } - public Builder AddPackedFixed64(ulong value) { - PrepareBuilder(); - result.packedFixed64_.Add(value); - return this; - } - public Builder AddRangePackedFixed64(scg::IEnumerable values) { - PrepareBuilder(); - result.packedFixed64_.Add(values); - return this; - } - public Builder ClearPackedFixed64() { - PrepareBuilder(); - result.packedFixed64_.Clear(); - return this; - } - - public pbc::IPopsicleList PackedSfixed32List { - get { return PrepareBuilder().packedSfixed32_; } - } - public int PackedSfixed32Count { - get { return result.PackedSfixed32Count; } - } - public int GetPackedSfixed32(int index) { - return result.GetPackedSfixed32(index); - } - public Builder SetPackedSfixed32(int index, int value) { - PrepareBuilder(); - result.packedSfixed32_[index] = value; - return this; - } - public Builder AddPackedSfixed32(int value) { - PrepareBuilder(); - result.packedSfixed32_.Add(value); - return this; - } - public Builder AddRangePackedSfixed32(scg::IEnumerable values) { - PrepareBuilder(); - result.packedSfixed32_.Add(values); - return this; - } - public Builder ClearPackedSfixed32() { - PrepareBuilder(); - result.packedSfixed32_.Clear(); - return this; - } - - public pbc::IPopsicleList PackedSfixed64List { - get { return PrepareBuilder().packedSfixed64_; } - } - public int PackedSfixed64Count { - get { return result.PackedSfixed64Count; } - } - public long GetPackedSfixed64(int index) { - return result.GetPackedSfixed64(index); - } - public Builder SetPackedSfixed64(int index, long value) { - PrepareBuilder(); - result.packedSfixed64_[index] = value; - return this; - } - public Builder AddPackedSfixed64(long value) { - PrepareBuilder(); - result.packedSfixed64_.Add(value); - return this; - } - public Builder AddRangePackedSfixed64(scg::IEnumerable values) { - PrepareBuilder(); - result.packedSfixed64_.Add(values); - return this; - } - public Builder ClearPackedSfixed64() { - PrepareBuilder(); - result.packedSfixed64_.Clear(); - return this; - } - - public pbc::IPopsicleList PackedFloatList { - get { return PrepareBuilder().packedFloat_; } - } - public int PackedFloatCount { - get { return result.PackedFloatCount; } - } - public float GetPackedFloat(int index) { - return result.GetPackedFloat(index); - } - public Builder SetPackedFloat(int index, float value) { - PrepareBuilder(); - result.packedFloat_[index] = value; - return this; - } - public Builder AddPackedFloat(float value) { - PrepareBuilder(); - result.packedFloat_.Add(value); - return this; - } - public Builder AddRangePackedFloat(scg::IEnumerable values) { - PrepareBuilder(); - result.packedFloat_.Add(values); - return this; - } - public Builder ClearPackedFloat() { - PrepareBuilder(); - result.packedFloat_.Clear(); - return this; - } - - public pbc::IPopsicleList PackedDoubleList { - get { return PrepareBuilder().packedDouble_; } - } - public int PackedDoubleCount { - get { return result.PackedDoubleCount; } - } - public double GetPackedDouble(int index) { - return result.GetPackedDouble(index); - } - public Builder SetPackedDouble(int index, double value) { - PrepareBuilder(); - result.packedDouble_[index] = value; - return this; - } - public Builder AddPackedDouble(double value) { - PrepareBuilder(); - result.packedDouble_.Add(value); - return this; - } - public Builder AddRangePackedDouble(scg::IEnumerable values) { - PrepareBuilder(); - result.packedDouble_.Add(values); - return this; - } - public Builder ClearPackedDouble() { - PrepareBuilder(); - result.packedDouble_.Clear(); - return this; - } - - public pbc::IPopsicleList PackedBoolList { - get { return PrepareBuilder().packedBool_; } - } - public int PackedBoolCount { - get { return result.PackedBoolCount; } - } - public bool GetPackedBool(int index) { - return result.GetPackedBool(index); - } - public Builder SetPackedBool(int index, bool value) { - PrepareBuilder(); - result.packedBool_[index] = value; - return this; - } - public Builder AddPackedBool(bool value) { - PrepareBuilder(); - result.packedBool_.Add(value); - return this; - } - public Builder AddRangePackedBool(scg::IEnumerable values) { - PrepareBuilder(); - result.packedBool_.Add(values); - return this; - } - public Builder ClearPackedBool() { - PrepareBuilder(); - result.packedBool_.Clear(); - return this; - } - - public pbc::IPopsicleList PackedEnumList { - get { return PrepareBuilder().packedEnum_; } - } - public int PackedEnumCount { - get { return result.PackedEnumCount; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignEnum GetPackedEnum(int index) { - return result.GetPackedEnum(index); - } - public Builder SetPackedEnum(int index, global::Google.ProtocolBuffers.TestProtos.ForeignEnum value) { - PrepareBuilder(); - result.packedEnum_[index] = value; - return this; - } - public Builder AddPackedEnum(global::Google.ProtocolBuffers.TestProtos.ForeignEnum value) { - PrepareBuilder(); - result.packedEnum_.Add(value); - return this; - } - public Builder AddRangePackedEnum(scg::IEnumerable values) { - PrepareBuilder(); - result.packedEnum_.Add(values); - return this; - } - public Builder ClearPackedEnum() { - PrepareBuilder(); - result.packedEnum_.Clear(); - return this; - } - } - static TestPackedTypes() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestUnpackedTypes : pb::GeneratedMessage { - private TestUnpackedTypes() { } - private static readonly TestUnpackedTypes defaultInstance = new TestUnpackedTypes().MakeReadOnly(); - private static readonly string[] _testUnpackedTypesFieldNames = new string[] { "unpacked_bool", "unpacked_double", "unpacked_enum", "unpacked_fixed32", "unpacked_fixed64", "unpacked_float", "unpacked_int32", "unpacked_int64", "unpacked_sfixed32", "unpacked_sfixed64", "unpacked_sint32", "unpacked_sint64", "unpacked_uint32", "unpacked_uint64" }; - private static readonly uint[] _testUnpackedTypesFieldTags = new uint[] { 816, 809, 824, 773, 777, 805, 720, 728, 789, 793, 752, 760, 736, 744 }; - public static TestUnpackedTypes DefaultInstance { - get { return defaultInstance; } - } - - public override TestUnpackedTypes DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestUnpackedTypes ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestUnpackedTypes__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestUnpackedTypes__FieldAccessorTable; } - } - - public const int UnpackedInt32FieldNumber = 90; - private pbc::PopsicleList unpackedInt32_ = new pbc::PopsicleList(); - public scg::IList UnpackedInt32List { - get { return pbc::Lists.AsReadOnly(unpackedInt32_); } - } - public int UnpackedInt32Count { - get { return unpackedInt32_.Count; } - } - public int GetUnpackedInt32(int index) { - return unpackedInt32_[index]; - } - - public const int UnpackedInt64FieldNumber = 91; - private pbc::PopsicleList unpackedInt64_ = new pbc::PopsicleList(); - public scg::IList UnpackedInt64List { - get { return pbc::Lists.AsReadOnly(unpackedInt64_); } - } - public int UnpackedInt64Count { - get { return unpackedInt64_.Count; } - } - public long GetUnpackedInt64(int index) { - return unpackedInt64_[index]; - } - - public const int UnpackedUint32FieldNumber = 92; - private pbc::PopsicleList unpackedUint32_ = new pbc::PopsicleList(); - public scg::IList UnpackedUint32List { - get { return pbc::Lists.AsReadOnly(unpackedUint32_); } - } - public int UnpackedUint32Count { - get { return unpackedUint32_.Count; } - } - public uint GetUnpackedUint32(int index) { - return unpackedUint32_[index]; - } - - public const int UnpackedUint64FieldNumber = 93; - private pbc::PopsicleList unpackedUint64_ = new pbc::PopsicleList(); - public scg::IList UnpackedUint64List { - get { return pbc::Lists.AsReadOnly(unpackedUint64_); } - } - public int UnpackedUint64Count { - get { return unpackedUint64_.Count; } - } - public ulong GetUnpackedUint64(int index) { - return unpackedUint64_[index]; - } - - public const int UnpackedSint32FieldNumber = 94; - private pbc::PopsicleList unpackedSint32_ = new pbc::PopsicleList(); - public scg::IList UnpackedSint32List { - get { return pbc::Lists.AsReadOnly(unpackedSint32_); } - } - public int UnpackedSint32Count { - get { return unpackedSint32_.Count; } - } - public int GetUnpackedSint32(int index) { - return unpackedSint32_[index]; - } - - public const int UnpackedSint64FieldNumber = 95; - private pbc::PopsicleList unpackedSint64_ = new pbc::PopsicleList(); - public scg::IList UnpackedSint64List { - get { return pbc::Lists.AsReadOnly(unpackedSint64_); } - } - public int UnpackedSint64Count { - get { return unpackedSint64_.Count; } - } - public long GetUnpackedSint64(int index) { - return unpackedSint64_[index]; - } - - public const int UnpackedFixed32FieldNumber = 96; - private pbc::PopsicleList unpackedFixed32_ = new pbc::PopsicleList(); - public scg::IList UnpackedFixed32List { - get { return pbc::Lists.AsReadOnly(unpackedFixed32_); } - } - public int UnpackedFixed32Count { - get { return unpackedFixed32_.Count; } - } - public uint GetUnpackedFixed32(int index) { - return unpackedFixed32_[index]; - } - - public const int UnpackedFixed64FieldNumber = 97; - private pbc::PopsicleList unpackedFixed64_ = new pbc::PopsicleList(); - public scg::IList UnpackedFixed64List { - get { return pbc::Lists.AsReadOnly(unpackedFixed64_); } - } - public int UnpackedFixed64Count { - get { return unpackedFixed64_.Count; } - } - public ulong GetUnpackedFixed64(int index) { - return unpackedFixed64_[index]; - } - - public const int UnpackedSfixed32FieldNumber = 98; - private pbc::PopsicleList unpackedSfixed32_ = new pbc::PopsicleList(); - public scg::IList UnpackedSfixed32List { - get { return pbc::Lists.AsReadOnly(unpackedSfixed32_); } - } - public int UnpackedSfixed32Count { - get { return unpackedSfixed32_.Count; } - } - public int GetUnpackedSfixed32(int index) { - return unpackedSfixed32_[index]; - } - - public const int UnpackedSfixed64FieldNumber = 99; - private pbc::PopsicleList unpackedSfixed64_ = new pbc::PopsicleList(); - public scg::IList UnpackedSfixed64List { - get { return pbc::Lists.AsReadOnly(unpackedSfixed64_); } - } - public int UnpackedSfixed64Count { - get { return unpackedSfixed64_.Count; } - } - public long GetUnpackedSfixed64(int index) { - return unpackedSfixed64_[index]; - } - - public const int UnpackedFloatFieldNumber = 100; - private pbc::PopsicleList unpackedFloat_ = new pbc::PopsicleList(); - public scg::IList UnpackedFloatList { - get { return pbc::Lists.AsReadOnly(unpackedFloat_); } - } - public int UnpackedFloatCount { - get { return unpackedFloat_.Count; } - } - public float GetUnpackedFloat(int index) { - return unpackedFloat_[index]; - } - - public const int UnpackedDoubleFieldNumber = 101; - private pbc::PopsicleList unpackedDouble_ = new pbc::PopsicleList(); - public scg::IList UnpackedDoubleList { - get { return pbc::Lists.AsReadOnly(unpackedDouble_); } - } - public int UnpackedDoubleCount { - get { return unpackedDouble_.Count; } - } - public double GetUnpackedDouble(int index) { - return unpackedDouble_[index]; - } - - public const int UnpackedBoolFieldNumber = 102; - private pbc::PopsicleList unpackedBool_ = new pbc::PopsicleList(); - public scg::IList UnpackedBoolList { - get { return pbc::Lists.AsReadOnly(unpackedBool_); } - } - public int UnpackedBoolCount { - get { return unpackedBool_.Count; } - } - public bool GetUnpackedBool(int index) { - return unpackedBool_[index]; - } - - public const int UnpackedEnumFieldNumber = 103; - private pbc::PopsicleList unpackedEnum_ = new pbc::PopsicleList(); - public scg::IList UnpackedEnumList { - get { return pbc::Lists.AsReadOnly(unpackedEnum_); } - } - public int UnpackedEnumCount { - get { return unpackedEnum_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignEnum GetUnpackedEnum(int index) { - return unpackedEnum_[index]; - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testUnpackedTypesFieldNames; - if (unpackedInt32_.Count > 0) { - output.WriteInt32Array(90, field_names[6], unpackedInt32_); - } - if (unpackedInt64_.Count > 0) { - output.WriteInt64Array(91, field_names[7], unpackedInt64_); - } - if (unpackedUint32_.Count > 0) { - output.WriteUInt32Array(92, field_names[12], unpackedUint32_); - } - if (unpackedUint64_.Count > 0) { - output.WriteUInt64Array(93, field_names[13], unpackedUint64_); - } - if (unpackedSint32_.Count > 0) { - output.WriteSInt32Array(94, field_names[10], unpackedSint32_); - } - if (unpackedSint64_.Count > 0) { - output.WriteSInt64Array(95, field_names[11], unpackedSint64_); - } - if (unpackedFixed32_.Count > 0) { - output.WriteFixed32Array(96, field_names[3], unpackedFixed32_); - } - if (unpackedFixed64_.Count > 0) { - output.WriteFixed64Array(97, field_names[4], unpackedFixed64_); - } - if (unpackedSfixed32_.Count > 0) { - output.WriteSFixed32Array(98, field_names[8], unpackedSfixed32_); - } - if (unpackedSfixed64_.Count > 0) { - output.WriteSFixed64Array(99, field_names[9], unpackedSfixed64_); - } - if (unpackedFloat_.Count > 0) { - output.WriteFloatArray(100, field_names[5], unpackedFloat_); - } - if (unpackedDouble_.Count > 0) { - output.WriteDoubleArray(101, field_names[1], unpackedDouble_); - } - if (unpackedBool_.Count > 0) { - output.WriteBoolArray(102, field_names[0], unpackedBool_); - } - if (unpackedEnum_.Count > 0) { - output.WriteEnumArray(103, field_names[2], unpackedEnum_); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - { - int dataSize = 0; - foreach (int element in UnpackedInt32List) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); - } - size += dataSize; - size += 2 * unpackedInt32_.Count; - } - { - int dataSize = 0; - foreach (long element in UnpackedInt64List) { - dataSize += pb::CodedOutputStream.ComputeInt64SizeNoTag(element); - } - size += dataSize; - size += 2 * unpackedInt64_.Count; - } - { - int dataSize = 0; - foreach (uint element in UnpackedUint32List) { - dataSize += pb::CodedOutputStream.ComputeUInt32SizeNoTag(element); - } - size += dataSize; - size += 2 * unpackedUint32_.Count; - } - { - int dataSize = 0; - foreach (ulong element in UnpackedUint64List) { - dataSize += pb::CodedOutputStream.ComputeUInt64SizeNoTag(element); - } - size += dataSize; - size += 2 * unpackedUint64_.Count; - } - { - int dataSize = 0; - foreach (int element in UnpackedSint32List) { - dataSize += pb::CodedOutputStream.ComputeSInt32SizeNoTag(element); - } - size += dataSize; - size += 2 * unpackedSint32_.Count; - } - { - int dataSize = 0; - foreach (long element in UnpackedSint64List) { - dataSize += pb::CodedOutputStream.ComputeSInt64SizeNoTag(element); - } - size += dataSize; - size += 2 * unpackedSint64_.Count; - } - { - int dataSize = 0; - dataSize = 4 * unpackedFixed32_.Count; - size += dataSize; - size += 2 * unpackedFixed32_.Count; - } - { - int dataSize = 0; - dataSize = 8 * unpackedFixed64_.Count; - size += dataSize; - size += 2 * unpackedFixed64_.Count; - } - { - int dataSize = 0; - dataSize = 4 * unpackedSfixed32_.Count; - size += dataSize; - size += 2 * unpackedSfixed32_.Count; - } - { - int dataSize = 0; - dataSize = 8 * unpackedSfixed64_.Count; - size += dataSize; - size += 2 * unpackedSfixed64_.Count; - } - { - int dataSize = 0; - dataSize = 4 * unpackedFloat_.Count; - size += dataSize; - size += 2 * unpackedFloat_.Count; - } - { - int dataSize = 0; - dataSize = 8 * unpackedDouble_.Count; - size += dataSize; - size += 2 * unpackedDouble_.Count; - } - { - int dataSize = 0; - dataSize = 1 * unpackedBool_.Count; - size += dataSize; - size += 2 * unpackedBool_.Count; - } - { - int dataSize = 0; - if (unpackedEnum_.Count > 0) { - foreach (global::Google.ProtocolBuffers.TestProtos.ForeignEnum element in unpackedEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 2 * unpackedEnum_.Count; - } - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestUnpackedTypes ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestUnpackedTypes ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestUnpackedTypes ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestUnpackedTypes ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestUnpackedTypes ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestUnpackedTypes ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestUnpackedTypes ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestUnpackedTypes ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestUnpackedTypes ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestUnpackedTypes ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestUnpackedTypes MakeReadOnly() { - unpackedInt32_.MakeReadOnly(); - unpackedInt64_.MakeReadOnly(); - unpackedUint32_.MakeReadOnly(); - unpackedUint64_.MakeReadOnly(); - unpackedSint32_.MakeReadOnly(); - unpackedSint64_.MakeReadOnly(); - unpackedFixed32_.MakeReadOnly(); - unpackedFixed64_.MakeReadOnly(); - unpackedSfixed32_.MakeReadOnly(); - unpackedSfixed64_.MakeReadOnly(); - unpackedFloat_.MakeReadOnly(); - unpackedDouble_.MakeReadOnly(); - unpackedBool_.MakeReadOnly(); - unpackedEnum_.MakeReadOnly(); - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestUnpackedTypes prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestUnpackedTypes cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestUnpackedTypes result; - - private TestUnpackedTypes PrepareBuilder() { - if (resultIsReadOnly) { - TestUnpackedTypes original = result; - result = new TestUnpackedTypes(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestUnpackedTypes MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestUnpackedTypes.Descriptor; } - } - - public override TestUnpackedTypes DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestUnpackedTypes.DefaultInstance; } - } - - public override TestUnpackedTypes BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestUnpackedTypes) { - return MergeFrom((TestUnpackedTypes) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestUnpackedTypes other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestUnpackedTypes.DefaultInstance) return this; - PrepareBuilder(); - if (other.unpackedInt32_.Count != 0) { - result.unpackedInt32_.Add(other.unpackedInt32_); - } - if (other.unpackedInt64_.Count != 0) { - result.unpackedInt64_.Add(other.unpackedInt64_); - } - if (other.unpackedUint32_.Count != 0) { - result.unpackedUint32_.Add(other.unpackedUint32_); - } - if (other.unpackedUint64_.Count != 0) { - result.unpackedUint64_.Add(other.unpackedUint64_); - } - if (other.unpackedSint32_.Count != 0) { - result.unpackedSint32_.Add(other.unpackedSint32_); - } - if (other.unpackedSint64_.Count != 0) { - result.unpackedSint64_.Add(other.unpackedSint64_); - } - if (other.unpackedFixed32_.Count != 0) { - result.unpackedFixed32_.Add(other.unpackedFixed32_); - } - if (other.unpackedFixed64_.Count != 0) { - result.unpackedFixed64_.Add(other.unpackedFixed64_); - } - if (other.unpackedSfixed32_.Count != 0) { - result.unpackedSfixed32_.Add(other.unpackedSfixed32_); - } - if (other.unpackedSfixed64_.Count != 0) { - result.unpackedSfixed64_.Add(other.unpackedSfixed64_); - } - if (other.unpackedFloat_.Count != 0) { - result.unpackedFloat_.Add(other.unpackedFloat_); - } - if (other.unpackedDouble_.Count != 0) { - result.unpackedDouble_.Add(other.unpackedDouble_); - } - if (other.unpackedBool_.Count != 0) { - result.unpackedBool_.Add(other.unpackedBool_); - } - if (other.unpackedEnum_.Count != 0) { - result.unpackedEnum_.Add(other.unpackedEnum_); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testUnpackedTypesFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testUnpackedTypesFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 722: - case 720: { - input.ReadInt32Array(tag, field_name, result.unpackedInt32_); - break; - } - case 730: - case 728: { - input.ReadInt64Array(tag, field_name, result.unpackedInt64_); - break; - } - case 738: - case 736: { - input.ReadUInt32Array(tag, field_name, result.unpackedUint32_); - break; - } - case 746: - case 744: { - input.ReadUInt64Array(tag, field_name, result.unpackedUint64_); - break; - } - case 754: - case 752: { - input.ReadSInt32Array(tag, field_name, result.unpackedSint32_); - break; - } - case 762: - case 760: { - input.ReadSInt64Array(tag, field_name, result.unpackedSint64_); - break; - } - case 770: - case 773: { - input.ReadFixed32Array(tag, field_name, result.unpackedFixed32_); - break; - } - case 778: - case 777: { - input.ReadFixed64Array(tag, field_name, result.unpackedFixed64_); - break; - } - case 786: - case 789: { - input.ReadSFixed32Array(tag, field_name, result.unpackedSfixed32_); - break; - } - case 794: - case 793: { - input.ReadSFixed64Array(tag, field_name, result.unpackedSfixed64_); - break; - } - case 802: - case 805: { - input.ReadFloatArray(tag, field_name, result.unpackedFloat_); - break; - } - case 810: - case 809: { - input.ReadDoubleArray(tag, field_name, result.unpackedDouble_); - break; - } - case 818: - case 816: { - input.ReadBoolArray(tag, field_name, result.unpackedBool_); - break; - } - case 826: - case 824: { - scg::ICollection unknownItems; - input.ReadEnumArray(tag, field_name, result.unpackedEnum_, out unknownItems); - if (unknownItems != null) { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - foreach (object rawValue in unknownItems) - if (rawValue is int) - unknownFields.MergeVarintField(103, (ulong)(int)rawValue); - } - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public pbc::IPopsicleList UnpackedInt32List { - get { return PrepareBuilder().unpackedInt32_; } - } - public int UnpackedInt32Count { - get { return result.UnpackedInt32Count; } - } - public int GetUnpackedInt32(int index) { - return result.GetUnpackedInt32(index); - } - public Builder SetUnpackedInt32(int index, int value) { - PrepareBuilder(); - result.unpackedInt32_[index] = value; - return this; - } - public Builder AddUnpackedInt32(int value) { - PrepareBuilder(); - result.unpackedInt32_.Add(value); - return this; - } - public Builder AddRangeUnpackedInt32(scg::IEnumerable values) { - PrepareBuilder(); - result.unpackedInt32_.Add(values); - return this; - } - public Builder ClearUnpackedInt32() { - PrepareBuilder(); - result.unpackedInt32_.Clear(); - return this; - } - - public pbc::IPopsicleList UnpackedInt64List { - get { return PrepareBuilder().unpackedInt64_; } - } - public int UnpackedInt64Count { - get { return result.UnpackedInt64Count; } - } - public long GetUnpackedInt64(int index) { - return result.GetUnpackedInt64(index); - } - public Builder SetUnpackedInt64(int index, long value) { - PrepareBuilder(); - result.unpackedInt64_[index] = value; - return this; - } - public Builder AddUnpackedInt64(long value) { - PrepareBuilder(); - result.unpackedInt64_.Add(value); - return this; - } - public Builder AddRangeUnpackedInt64(scg::IEnumerable values) { - PrepareBuilder(); - result.unpackedInt64_.Add(values); - return this; - } - public Builder ClearUnpackedInt64() { - PrepareBuilder(); - result.unpackedInt64_.Clear(); - return this; - } - - public pbc::IPopsicleList UnpackedUint32List { - get { return PrepareBuilder().unpackedUint32_; } - } - public int UnpackedUint32Count { - get { return result.UnpackedUint32Count; } - } - public uint GetUnpackedUint32(int index) { - return result.GetUnpackedUint32(index); - } - public Builder SetUnpackedUint32(int index, uint value) { - PrepareBuilder(); - result.unpackedUint32_[index] = value; - return this; - } - public Builder AddUnpackedUint32(uint value) { - PrepareBuilder(); - result.unpackedUint32_.Add(value); - return this; - } - public Builder AddRangeUnpackedUint32(scg::IEnumerable values) { - PrepareBuilder(); - result.unpackedUint32_.Add(values); - return this; - } - public Builder ClearUnpackedUint32() { - PrepareBuilder(); - result.unpackedUint32_.Clear(); - return this; - } - - public pbc::IPopsicleList UnpackedUint64List { - get { return PrepareBuilder().unpackedUint64_; } - } - public int UnpackedUint64Count { - get { return result.UnpackedUint64Count; } - } - public ulong GetUnpackedUint64(int index) { - return result.GetUnpackedUint64(index); - } - public Builder SetUnpackedUint64(int index, ulong value) { - PrepareBuilder(); - result.unpackedUint64_[index] = value; - return this; - } - public Builder AddUnpackedUint64(ulong value) { - PrepareBuilder(); - result.unpackedUint64_.Add(value); - return this; - } - public Builder AddRangeUnpackedUint64(scg::IEnumerable values) { - PrepareBuilder(); - result.unpackedUint64_.Add(values); - return this; - } - public Builder ClearUnpackedUint64() { - PrepareBuilder(); - result.unpackedUint64_.Clear(); - return this; - } - - public pbc::IPopsicleList UnpackedSint32List { - get { return PrepareBuilder().unpackedSint32_; } - } - public int UnpackedSint32Count { - get { return result.UnpackedSint32Count; } - } - public int GetUnpackedSint32(int index) { - return result.GetUnpackedSint32(index); - } - public Builder SetUnpackedSint32(int index, int value) { - PrepareBuilder(); - result.unpackedSint32_[index] = value; - return this; - } - public Builder AddUnpackedSint32(int value) { - PrepareBuilder(); - result.unpackedSint32_.Add(value); - return this; - } - public Builder AddRangeUnpackedSint32(scg::IEnumerable values) { - PrepareBuilder(); - result.unpackedSint32_.Add(values); - return this; - } - public Builder ClearUnpackedSint32() { - PrepareBuilder(); - result.unpackedSint32_.Clear(); - return this; - } - - public pbc::IPopsicleList UnpackedSint64List { - get { return PrepareBuilder().unpackedSint64_; } - } - public int UnpackedSint64Count { - get { return result.UnpackedSint64Count; } - } - public long GetUnpackedSint64(int index) { - return result.GetUnpackedSint64(index); - } - public Builder SetUnpackedSint64(int index, long value) { - PrepareBuilder(); - result.unpackedSint64_[index] = value; - return this; - } - public Builder AddUnpackedSint64(long value) { - PrepareBuilder(); - result.unpackedSint64_.Add(value); - return this; - } - public Builder AddRangeUnpackedSint64(scg::IEnumerable values) { - PrepareBuilder(); - result.unpackedSint64_.Add(values); - return this; - } - public Builder ClearUnpackedSint64() { - PrepareBuilder(); - result.unpackedSint64_.Clear(); - return this; - } - - public pbc::IPopsicleList UnpackedFixed32List { - get { return PrepareBuilder().unpackedFixed32_; } - } - public int UnpackedFixed32Count { - get { return result.UnpackedFixed32Count; } - } - public uint GetUnpackedFixed32(int index) { - return result.GetUnpackedFixed32(index); - } - public Builder SetUnpackedFixed32(int index, uint value) { - PrepareBuilder(); - result.unpackedFixed32_[index] = value; - return this; - } - public Builder AddUnpackedFixed32(uint value) { - PrepareBuilder(); - result.unpackedFixed32_.Add(value); - return this; - } - public Builder AddRangeUnpackedFixed32(scg::IEnumerable values) { - PrepareBuilder(); - result.unpackedFixed32_.Add(values); - return this; - } - public Builder ClearUnpackedFixed32() { - PrepareBuilder(); - result.unpackedFixed32_.Clear(); - return this; - } - - public pbc::IPopsicleList UnpackedFixed64List { - get { return PrepareBuilder().unpackedFixed64_; } - } - public int UnpackedFixed64Count { - get { return result.UnpackedFixed64Count; } - } - public ulong GetUnpackedFixed64(int index) { - return result.GetUnpackedFixed64(index); - } - public Builder SetUnpackedFixed64(int index, ulong value) { - PrepareBuilder(); - result.unpackedFixed64_[index] = value; - return this; - } - public Builder AddUnpackedFixed64(ulong value) { - PrepareBuilder(); - result.unpackedFixed64_.Add(value); - return this; - } - public Builder AddRangeUnpackedFixed64(scg::IEnumerable values) { - PrepareBuilder(); - result.unpackedFixed64_.Add(values); - return this; - } - public Builder ClearUnpackedFixed64() { - PrepareBuilder(); - result.unpackedFixed64_.Clear(); - return this; - } - - public pbc::IPopsicleList UnpackedSfixed32List { - get { return PrepareBuilder().unpackedSfixed32_; } - } - public int UnpackedSfixed32Count { - get { return result.UnpackedSfixed32Count; } - } - public int GetUnpackedSfixed32(int index) { - return result.GetUnpackedSfixed32(index); - } - public Builder SetUnpackedSfixed32(int index, int value) { - PrepareBuilder(); - result.unpackedSfixed32_[index] = value; - return this; - } - public Builder AddUnpackedSfixed32(int value) { - PrepareBuilder(); - result.unpackedSfixed32_.Add(value); - return this; - } - public Builder AddRangeUnpackedSfixed32(scg::IEnumerable values) { - PrepareBuilder(); - result.unpackedSfixed32_.Add(values); - return this; - } - public Builder ClearUnpackedSfixed32() { - PrepareBuilder(); - result.unpackedSfixed32_.Clear(); - return this; - } - - public pbc::IPopsicleList UnpackedSfixed64List { - get { return PrepareBuilder().unpackedSfixed64_; } - } - public int UnpackedSfixed64Count { - get { return result.UnpackedSfixed64Count; } - } - public long GetUnpackedSfixed64(int index) { - return result.GetUnpackedSfixed64(index); - } - public Builder SetUnpackedSfixed64(int index, long value) { - PrepareBuilder(); - result.unpackedSfixed64_[index] = value; - return this; - } - public Builder AddUnpackedSfixed64(long value) { - PrepareBuilder(); - result.unpackedSfixed64_.Add(value); - return this; - } - public Builder AddRangeUnpackedSfixed64(scg::IEnumerable values) { - PrepareBuilder(); - result.unpackedSfixed64_.Add(values); - return this; - } - public Builder ClearUnpackedSfixed64() { - PrepareBuilder(); - result.unpackedSfixed64_.Clear(); - return this; - } - - public pbc::IPopsicleList UnpackedFloatList { - get { return PrepareBuilder().unpackedFloat_; } - } - public int UnpackedFloatCount { - get { return result.UnpackedFloatCount; } - } - public float GetUnpackedFloat(int index) { - return result.GetUnpackedFloat(index); - } - public Builder SetUnpackedFloat(int index, float value) { - PrepareBuilder(); - result.unpackedFloat_[index] = value; - return this; - } - public Builder AddUnpackedFloat(float value) { - PrepareBuilder(); - result.unpackedFloat_.Add(value); - return this; - } - public Builder AddRangeUnpackedFloat(scg::IEnumerable values) { - PrepareBuilder(); - result.unpackedFloat_.Add(values); - return this; - } - public Builder ClearUnpackedFloat() { - PrepareBuilder(); - result.unpackedFloat_.Clear(); - return this; - } - - public pbc::IPopsicleList UnpackedDoubleList { - get { return PrepareBuilder().unpackedDouble_; } - } - public int UnpackedDoubleCount { - get { return result.UnpackedDoubleCount; } - } - public double GetUnpackedDouble(int index) { - return result.GetUnpackedDouble(index); - } - public Builder SetUnpackedDouble(int index, double value) { - PrepareBuilder(); - result.unpackedDouble_[index] = value; - return this; - } - public Builder AddUnpackedDouble(double value) { - PrepareBuilder(); - result.unpackedDouble_.Add(value); - return this; - } - public Builder AddRangeUnpackedDouble(scg::IEnumerable values) { - PrepareBuilder(); - result.unpackedDouble_.Add(values); - return this; - } - public Builder ClearUnpackedDouble() { - PrepareBuilder(); - result.unpackedDouble_.Clear(); - return this; - } - - public pbc::IPopsicleList UnpackedBoolList { - get { return PrepareBuilder().unpackedBool_; } - } - public int UnpackedBoolCount { - get { return result.UnpackedBoolCount; } - } - public bool GetUnpackedBool(int index) { - return result.GetUnpackedBool(index); - } - public Builder SetUnpackedBool(int index, bool value) { - PrepareBuilder(); - result.unpackedBool_[index] = value; - return this; - } - public Builder AddUnpackedBool(bool value) { - PrepareBuilder(); - result.unpackedBool_.Add(value); - return this; - } - public Builder AddRangeUnpackedBool(scg::IEnumerable values) { - PrepareBuilder(); - result.unpackedBool_.Add(values); - return this; - } - public Builder ClearUnpackedBool() { - PrepareBuilder(); - result.unpackedBool_.Clear(); - return this; - } - - public pbc::IPopsicleList UnpackedEnumList { - get { return PrepareBuilder().unpackedEnum_; } - } - public int UnpackedEnumCount { - get { return result.UnpackedEnumCount; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignEnum GetUnpackedEnum(int index) { - return result.GetUnpackedEnum(index); - } - public Builder SetUnpackedEnum(int index, global::Google.ProtocolBuffers.TestProtos.ForeignEnum value) { - PrepareBuilder(); - result.unpackedEnum_[index] = value; - return this; - } - public Builder AddUnpackedEnum(global::Google.ProtocolBuffers.TestProtos.ForeignEnum value) { - PrepareBuilder(); - result.unpackedEnum_.Add(value); - return this; - } - public Builder AddRangeUnpackedEnum(scg::IEnumerable values) { - PrepareBuilder(); - result.unpackedEnum_.Add(values); - return this; - } - public Builder ClearUnpackedEnum() { - PrepareBuilder(); - result.unpackedEnum_.Clear(); - return this; - } - } - static TestUnpackedTypes() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestPackedExtensions : pb::ExtendableMessage { - private TestPackedExtensions() { } - private static readonly TestPackedExtensions defaultInstance = new TestPackedExtensions().MakeReadOnly(); - private static readonly string[] _testPackedExtensionsFieldNames = new string[] { }; - private static readonly uint[] _testPackedExtensionsFieldTags = new uint[] { }; - public static TestPackedExtensions DefaultInstance { - get { return defaultInstance; } - } - - public override TestPackedExtensions DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestPackedExtensions ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestPackedExtensions__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestPackedExtensions__FieldAccessorTable; } - } - - public override bool IsInitialized { - get { - if (!ExtensionsAreInitialized) return false; - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testPackedExtensionsFieldNames; - pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); - extensionWriter.WriteUntil(536870912, output); - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - size += ExtensionsSerializedSize; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestPackedExtensions ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestPackedExtensions ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestPackedExtensions ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestPackedExtensions ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestPackedExtensions ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestPackedExtensions ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestPackedExtensions ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestPackedExtensions ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestPackedExtensions ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestPackedExtensions ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestPackedExtensions MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestPackedExtensions prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::ExtendableBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestPackedExtensions cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestPackedExtensions result; - - private TestPackedExtensions PrepareBuilder() { - if (resultIsReadOnly) { - TestPackedExtensions original = result; - result = new TestPackedExtensions(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestPackedExtensions MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestPackedExtensions.Descriptor; } - } - - public override TestPackedExtensions DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestPackedExtensions.DefaultInstance; } - } - - public override TestPackedExtensions BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestPackedExtensions) { - return MergeFrom((TestPackedExtensions) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestPackedExtensions other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestPackedExtensions.DefaultInstance) return this; - PrepareBuilder(); - this.MergeExtensionFields(other); - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testPackedExtensionsFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testPackedExtensionsFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - } - static TestPackedExtensions() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestUnpackedExtensions : pb::ExtendableMessage { - private TestUnpackedExtensions() { } - private static readonly TestUnpackedExtensions defaultInstance = new TestUnpackedExtensions().MakeReadOnly(); - private static readonly string[] _testUnpackedExtensionsFieldNames = new string[] { }; - private static readonly uint[] _testUnpackedExtensionsFieldTags = new uint[] { }; - public static TestUnpackedExtensions DefaultInstance { - get { return defaultInstance; } - } - - public override TestUnpackedExtensions DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestUnpackedExtensions ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestUnpackedExtensions__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestUnpackedExtensions__FieldAccessorTable; } - } - - public override bool IsInitialized { - get { - if (!ExtensionsAreInitialized) return false; - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testUnpackedExtensionsFieldNames; - pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); - extensionWriter.WriteUntil(536870912, output); - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - size += ExtensionsSerializedSize; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestUnpackedExtensions ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestUnpackedExtensions ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestUnpackedExtensions ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestUnpackedExtensions ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestUnpackedExtensions ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestUnpackedExtensions ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestUnpackedExtensions ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestUnpackedExtensions ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestUnpackedExtensions ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestUnpackedExtensions ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestUnpackedExtensions MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestUnpackedExtensions prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::ExtendableBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestUnpackedExtensions cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestUnpackedExtensions result; - - private TestUnpackedExtensions PrepareBuilder() { - if (resultIsReadOnly) { - TestUnpackedExtensions original = result; - result = new TestUnpackedExtensions(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestUnpackedExtensions MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestUnpackedExtensions.Descriptor; } - } - - public override TestUnpackedExtensions DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestUnpackedExtensions.DefaultInstance; } - } - - public override TestUnpackedExtensions BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestUnpackedExtensions) { - return MergeFrom((TestUnpackedExtensions) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestUnpackedExtensions other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestUnpackedExtensions.DefaultInstance) return this; - PrepareBuilder(); - this.MergeExtensionFields(other); - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testUnpackedExtensionsFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testUnpackedExtensionsFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - } - static TestUnpackedExtensions() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestDynamicExtensions : pb::GeneratedMessage { - private TestDynamicExtensions() { } - private static readonly TestDynamicExtensions defaultInstance = new TestDynamicExtensions().MakeReadOnly(); - private static readonly string[] _testDynamicExtensionsFieldNames = new string[] { "dynamic_enum_extension", "dynamic_message_extension", "enum_extension", "message_extension", "packed_extension", "repeated_extension", "scalar_extension" }; - private static readonly uint[] _testDynamicExtensionsFieldTags = new uint[] { 16016, 16034, 16008, 16026, 16050, 16042, 16005 }; - public static TestDynamicExtensions DefaultInstance { - get { return defaultInstance; } - } - - public override TestDynamicExtensions DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestDynamicExtensions ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestDynamicExtensions__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestDynamicExtensions__FieldAccessorTable; } - } - - #region Nested types - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class Types { - public enum DynamicEnumType { - DYNAMIC_FOO = 2200, - DYNAMIC_BAR = 2201, - DYNAMIC_BAZ = 2202, - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class DynamicMessageType : pb::GeneratedMessage { - private DynamicMessageType() { } - private static readonly DynamicMessageType defaultInstance = new DynamicMessageType().MakeReadOnly(); - private static readonly string[] _dynamicMessageTypeFieldNames = new string[] { "dynamic_field" }; - private static readonly uint[] _dynamicMessageTypeFieldTags = new uint[] { 16800 }; - public static DynamicMessageType DefaultInstance { - get { return defaultInstance; } - } - - public override DynamicMessageType DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override DynamicMessageType ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestDynamicExtensions_DynamicMessageType__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestDynamicExtensions_DynamicMessageType__FieldAccessorTable; } - } - - public const int DynamicFieldFieldNumber = 2100; - private bool hasDynamicField; - private int dynamicField_; - public bool HasDynamicField { - get { return hasDynamicField; } - } - public int DynamicField { - get { return dynamicField_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _dynamicMessageTypeFieldNames; - if (hasDynamicField) { - output.WriteInt32(2100, field_names[0], DynamicField); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasDynamicField) { - size += pb::CodedOutputStream.ComputeInt32Size(2100, DynamicField); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static DynamicMessageType ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static DynamicMessageType ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static DynamicMessageType ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static DynamicMessageType ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static DynamicMessageType ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static DynamicMessageType ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static DynamicMessageType ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static DynamicMessageType ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static DynamicMessageType ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static DynamicMessageType ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private DynamicMessageType MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(DynamicMessageType prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(DynamicMessageType cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private DynamicMessageType result; - - private DynamicMessageType PrepareBuilder() { - if (resultIsReadOnly) { - DynamicMessageType original = result; - result = new DynamicMessageType(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override DynamicMessageType MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.Types.DynamicMessageType.Descriptor; } - } - - public override DynamicMessageType DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.Types.DynamicMessageType.DefaultInstance; } - } - - public override DynamicMessageType BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is DynamicMessageType) { - return MergeFrom((DynamicMessageType) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(DynamicMessageType other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.Types.DynamicMessageType.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasDynamicField) { - DynamicField = other.DynamicField; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_dynamicMessageTypeFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _dynamicMessageTypeFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 16800: { - result.hasDynamicField = input.ReadInt32(ref result.dynamicField_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasDynamicField { - get { return result.hasDynamicField; } - } - public int DynamicField { - get { return result.DynamicField; } - set { SetDynamicField(value); } - } - public Builder SetDynamicField(int value) { - PrepareBuilder(); - result.hasDynamicField = true; - result.dynamicField_ = value; - return this; - } - public Builder ClearDynamicField() { - PrepareBuilder(); - result.hasDynamicField = false; - result.dynamicField_ = 0; - return this; - } - } - static DynamicMessageType() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - } - #endregion - - public const int ScalarExtensionFieldNumber = 2000; - private bool hasScalarExtension; - private uint scalarExtension_; - public bool HasScalarExtension { - get { return hasScalarExtension; } - } - public uint ScalarExtension { - get { return scalarExtension_; } - } - - public const int EnumExtensionFieldNumber = 2001; - private bool hasEnumExtension; - private global::Google.ProtocolBuffers.TestProtos.ForeignEnum enumExtension_ = global::Google.ProtocolBuffers.TestProtos.ForeignEnum.FOREIGN_FOO; - public bool HasEnumExtension { - get { return hasEnumExtension; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignEnum EnumExtension { - get { return enumExtension_; } - } - - public const int DynamicEnumExtensionFieldNumber = 2002; - private bool hasDynamicEnumExtension; - private global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.Types.DynamicEnumType dynamicEnumExtension_ = global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.Types.DynamicEnumType.DYNAMIC_FOO; - public bool HasDynamicEnumExtension { - get { return hasDynamicEnumExtension; } - } - public global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.Types.DynamicEnumType DynamicEnumExtension { - get { return dynamicEnumExtension_; } - } - - public const int MessageExtensionFieldNumber = 2003; - private bool hasMessageExtension; - private global::Google.ProtocolBuffers.TestProtos.ForeignMessage messageExtension_; - public bool HasMessageExtension { - get { return hasMessageExtension; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignMessage MessageExtension { - get { return messageExtension_ ?? global::Google.ProtocolBuffers.TestProtos.ForeignMessage.DefaultInstance; } - } - - public const int DynamicMessageExtensionFieldNumber = 2004; - private bool hasDynamicMessageExtension; - private global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.Types.DynamicMessageType dynamicMessageExtension_; - public bool HasDynamicMessageExtension { - get { return hasDynamicMessageExtension; } - } - public global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.Types.DynamicMessageType DynamicMessageExtension { - get { return dynamicMessageExtension_ ?? global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.Types.DynamicMessageType.DefaultInstance; } - } - - public const int RepeatedExtensionFieldNumber = 2005; - private pbc::PopsicleList repeatedExtension_ = new pbc::PopsicleList(); - public scg::IList RepeatedExtensionList { - get { return pbc::Lists.AsReadOnly(repeatedExtension_); } - } - public int RepeatedExtensionCount { - get { return repeatedExtension_.Count; } - } - public string GetRepeatedExtension(int index) { - return repeatedExtension_[index]; - } - - public const int PackedExtensionFieldNumber = 2006; - private int packedExtensionMemoizedSerializedSize; - private pbc::PopsicleList packedExtension_ = new pbc::PopsicleList(); - public scg::IList PackedExtensionList { - get { return pbc::Lists.AsReadOnly(packedExtension_); } - } - public int PackedExtensionCount { - get { return packedExtension_.Count; } - } - public int GetPackedExtension(int index) { - return packedExtension_[index]; - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testDynamicExtensionsFieldNames; - if (hasScalarExtension) { - output.WriteFixed32(2000, field_names[6], ScalarExtension); - } - if (hasEnumExtension) { - output.WriteEnum(2001, field_names[2], (int) EnumExtension, EnumExtension); - } - if (hasDynamicEnumExtension) { - output.WriteEnum(2002, field_names[0], (int) DynamicEnumExtension, DynamicEnumExtension); - } - if (hasMessageExtension) { - output.WriteMessage(2003, field_names[3], MessageExtension); - } - if (hasDynamicMessageExtension) { - output.WriteMessage(2004, field_names[1], DynamicMessageExtension); - } - if (repeatedExtension_.Count > 0) { - output.WriteStringArray(2005, field_names[5], repeatedExtension_); - } - if (packedExtension_.Count > 0) { - output.WritePackedSInt32Array(2006, field_names[4], packedExtensionMemoizedSerializedSize, packedExtension_); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasScalarExtension) { - size += pb::CodedOutputStream.ComputeFixed32Size(2000, ScalarExtension); - } - if (hasEnumExtension) { - size += pb::CodedOutputStream.ComputeEnumSize(2001, (int) EnumExtension); - } - if (hasDynamicEnumExtension) { - size += pb::CodedOutputStream.ComputeEnumSize(2002, (int) DynamicEnumExtension); - } - if (hasMessageExtension) { - size += pb::CodedOutputStream.ComputeMessageSize(2003, MessageExtension); - } - if (hasDynamicMessageExtension) { - size += pb::CodedOutputStream.ComputeMessageSize(2004, DynamicMessageExtension); - } - { - int dataSize = 0; - foreach (string element in RepeatedExtensionList) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedExtension_.Count; - } - { - int dataSize = 0; - foreach (int element in PackedExtensionList) { - dataSize += pb::CodedOutputStream.ComputeSInt32SizeNoTag(element); - } - size += dataSize; - if (packedExtension_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedExtensionMemoizedSerializedSize = dataSize; - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestDynamicExtensions ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestDynamicExtensions ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestDynamicExtensions ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestDynamicExtensions ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestDynamicExtensions ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestDynamicExtensions ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestDynamicExtensions ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestDynamicExtensions ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestDynamicExtensions ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestDynamicExtensions ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestDynamicExtensions MakeReadOnly() { - repeatedExtension_.MakeReadOnly(); - packedExtension_.MakeReadOnly(); - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestDynamicExtensions prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestDynamicExtensions cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestDynamicExtensions result; - - private TestDynamicExtensions PrepareBuilder() { - if (resultIsReadOnly) { - TestDynamicExtensions original = result; - result = new TestDynamicExtensions(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestDynamicExtensions MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.Descriptor; } - } - - public override TestDynamicExtensions DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.DefaultInstance; } - } - - public override TestDynamicExtensions BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestDynamicExtensions) { - return MergeFrom((TestDynamicExtensions) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestDynamicExtensions other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasScalarExtension) { - ScalarExtension = other.ScalarExtension; - } - if (other.HasEnumExtension) { - EnumExtension = other.EnumExtension; - } - if (other.HasDynamicEnumExtension) { - DynamicEnumExtension = other.DynamicEnumExtension; - } - if (other.HasMessageExtension) { - MergeMessageExtension(other.MessageExtension); - } - if (other.HasDynamicMessageExtension) { - MergeDynamicMessageExtension(other.DynamicMessageExtension); - } - if (other.repeatedExtension_.Count != 0) { - result.repeatedExtension_.Add(other.repeatedExtension_); - } - if (other.packedExtension_.Count != 0) { - result.packedExtension_.Add(other.packedExtension_); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testDynamicExtensionsFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testDynamicExtensionsFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 16005: { - result.hasScalarExtension = input.ReadFixed32(ref result.scalarExtension_); - break; - } - case 16008: { - object unknown; - if(input.ReadEnum(ref result.enumExtension_, out unknown)) { - result.hasEnumExtension = true; - } else if(unknown is int) { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - unknownFields.MergeVarintField(2001, (ulong)(int)unknown); - } - break; - } - case 16016: { - object unknown; - if(input.ReadEnum(ref result.dynamicEnumExtension_, out unknown)) { - result.hasDynamicEnumExtension = true; - } else if(unknown is int) { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - unknownFields.MergeVarintField(2002, (ulong)(int)unknown); - } - break; - } - case 16026: { - global::Google.ProtocolBuffers.TestProtos.ForeignMessage.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.ForeignMessage.CreateBuilder(); - if (result.hasMessageExtension) { - subBuilder.MergeFrom(MessageExtension); - } - input.ReadMessage(subBuilder, extensionRegistry); - MessageExtension = subBuilder.BuildPartial(); - break; - } - case 16034: { - global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.Types.DynamicMessageType.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.Types.DynamicMessageType.CreateBuilder(); - if (result.hasDynamicMessageExtension) { - subBuilder.MergeFrom(DynamicMessageExtension); - } - input.ReadMessage(subBuilder, extensionRegistry); - DynamicMessageExtension = subBuilder.BuildPartial(); - break; - } - case 16042: { - input.ReadStringArray(tag, field_name, result.repeatedExtension_); - break; - } - case 16050: - case 16048: { - input.ReadSInt32Array(tag, field_name, result.packedExtension_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasScalarExtension { - get { return result.hasScalarExtension; } - } - public uint ScalarExtension { - get { return result.ScalarExtension; } - set { SetScalarExtension(value); } - } - public Builder SetScalarExtension(uint value) { - PrepareBuilder(); - result.hasScalarExtension = true; - result.scalarExtension_ = value; - return this; - } - public Builder ClearScalarExtension() { - PrepareBuilder(); - result.hasScalarExtension = false; - result.scalarExtension_ = 0; - return this; - } - - public bool HasEnumExtension { - get { return result.hasEnumExtension; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignEnum EnumExtension { - get { return result.EnumExtension; } - set { SetEnumExtension(value); } - } - public Builder SetEnumExtension(global::Google.ProtocolBuffers.TestProtos.ForeignEnum value) { - PrepareBuilder(); - result.hasEnumExtension = true; - result.enumExtension_ = value; - return this; - } - public Builder ClearEnumExtension() { - PrepareBuilder(); - result.hasEnumExtension = false; - result.enumExtension_ = global::Google.ProtocolBuffers.TestProtos.ForeignEnum.FOREIGN_FOO; - return this; - } - - public bool HasDynamicEnumExtension { - get { return result.hasDynamicEnumExtension; } - } - public global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.Types.DynamicEnumType DynamicEnumExtension { - get { return result.DynamicEnumExtension; } - set { SetDynamicEnumExtension(value); } - } - public Builder SetDynamicEnumExtension(global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.Types.DynamicEnumType value) { - PrepareBuilder(); - result.hasDynamicEnumExtension = true; - result.dynamicEnumExtension_ = value; - return this; - } - public Builder ClearDynamicEnumExtension() { - PrepareBuilder(); - result.hasDynamicEnumExtension = false; - result.dynamicEnumExtension_ = global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.Types.DynamicEnumType.DYNAMIC_FOO; - return this; - } - - public bool HasMessageExtension { - get { return result.hasMessageExtension; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignMessage MessageExtension { - get { return result.MessageExtension; } - set { SetMessageExtension(value); } - } - public Builder SetMessageExtension(global::Google.ProtocolBuffers.TestProtos.ForeignMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasMessageExtension = true; - result.messageExtension_ = value; - return this; - } - public Builder SetMessageExtension(global::Google.ProtocolBuffers.TestProtos.ForeignMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasMessageExtension = true; - result.messageExtension_ = builderForValue.Build(); - return this; - } - public Builder MergeMessageExtension(global::Google.ProtocolBuffers.TestProtos.ForeignMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasMessageExtension && - result.messageExtension_ != global::Google.ProtocolBuffers.TestProtos.ForeignMessage.DefaultInstance) { - result.messageExtension_ = global::Google.ProtocolBuffers.TestProtos.ForeignMessage.CreateBuilder(result.messageExtension_).MergeFrom(value).BuildPartial(); - } else { - result.messageExtension_ = value; - } - result.hasMessageExtension = true; - return this; - } - public Builder ClearMessageExtension() { - PrepareBuilder(); - result.hasMessageExtension = false; - result.messageExtension_ = null; - return this; - } - - public bool HasDynamicMessageExtension { - get { return result.hasDynamicMessageExtension; } - } - public global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.Types.DynamicMessageType DynamicMessageExtension { - get { return result.DynamicMessageExtension; } - set { SetDynamicMessageExtension(value); } - } - public Builder SetDynamicMessageExtension(global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.Types.DynamicMessageType value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasDynamicMessageExtension = true; - result.dynamicMessageExtension_ = value; - return this; - } - public Builder SetDynamicMessageExtension(global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.Types.DynamicMessageType.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasDynamicMessageExtension = true; - result.dynamicMessageExtension_ = builderForValue.Build(); - return this; - } - public Builder MergeDynamicMessageExtension(global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.Types.DynamicMessageType value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasDynamicMessageExtension && - result.dynamicMessageExtension_ != global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.Types.DynamicMessageType.DefaultInstance) { - result.dynamicMessageExtension_ = global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.Types.DynamicMessageType.CreateBuilder(result.dynamicMessageExtension_).MergeFrom(value).BuildPartial(); - } else { - result.dynamicMessageExtension_ = value; - } - result.hasDynamicMessageExtension = true; - return this; - } - public Builder ClearDynamicMessageExtension() { - PrepareBuilder(); - result.hasDynamicMessageExtension = false; - result.dynamicMessageExtension_ = null; - return this; - } - - public pbc::IPopsicleList RepeatedExtensionList { - get { return PrepareBuilder().repeatedExtension_; } - } - public int RepeatedExtensionCount { - get { return result.RepeatedExtensionCount; } - } - public string GetRepeatedExtension(int index) { - return result.GetRepeatedExtension(index); - } - public Builder SetRepeatedExtension(int index, string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedExtension_[index] = value; - return this; - } - public Builder AddRepeatedExtension(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedExtension_.Add(value); - return this; - } - public Builder AddRangeRepeatedExtension(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedExtension_.Add(values); - return this; - } - public Builder ClearRepeatedExtension() { - PrepareBuilder(); - result.repeatedExtension_.Clear(); - return this; - } - - public pbc::IPopsicleList PackedExtensionList { - get { return PrepareBuilder().packedExtension_; } - } - public int PackedExtensionCount { - get { return result.PackedExtensionCount; } - } - public int GetPackedExtension(int index) { - return result.GetPackedExtension(index); - } - public Builder SetPackedExtension(int index, int value) { - PrepareBuilder(); - result.packedExtension_[index] = value; - return this; - } - public Builder AddPackedExtension(int value) { - PrepareBuilder(); - result.packedExtension_.Add(value); - return this; - } - public Builder AddRangePackedExtension(scg::IEnumerable values) { - PrepareBuilder(); - result.packedExtension_.Add(values); - return this; - } - public Builder ClearPackedExtension() { - PrepareBuilder(); - result.packedExtension_.Clear(); - return this; - } - } - static TestDynamicExtensions() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestRepeatedScalarDifferentTagSizes : pb::GeneratedMessage { - private TestRepeatedScalarDifferentTagSizes() { } - private static readonly TestRepeatedScalarDifferentTagSizes defaultInstance = new TestRepeatedScalarDifferentTagSizes().MakeReadOnly(); - private static readonly string[] _testRepeatedScalarDifferentTagSizesFieldNames = new string[] { "repeated_fixed32", "repeated_fixed64", "repeated_float", "repeated_int32", "repeated_int64", "repeated_uint64" }; - private static readonly uint[] _testRepeatedScalarDifferentTagSizesFieldTags = new uint[] { 101, 16369, 2097141, 104, 16376, 2097144 }; - public static TestRepeatedScalarDifferentTagSizes DefaultInstance { - get { return defaultInstance; } - } - - public override TestRepeatedScalarDifferentTagSizes DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestRepeatedScalarDifferentTagSizes ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestRepeatedScalarDifferentTagSizes__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestRepeatedScalarDifferentTagSizes__FieldAccessorTable; } - } - - public const int RepeatedFixed32FieldNumber = 12; - private pbc::PopsicleList repeatedFixed32_ = new pbc::PopsicleList(); - public scg::IList RepeatedFixed32List { - get { return pbc::Lists.AsReadOnly(repeatedFixed32_); } - } - public int RepeatedFixed32Count { - get { return repeatedFixed32_.Count; } - } - public uint GetRepeatedFixed32(int index) { - return repeatedFixed32_[index]; - } - - public const int RepeatedInt32FieldNumber = 13; - private pbc::PopsicleList repeatedInt32_ = new pbc::PopsicleList(); - public scg::IList RepeatedInt32List { - get { return pbc::Lists.AsReadOnly(repeatedInt32_); } - } - public int RepeatedInt32Count { - get { return repeatedInt32_.Count; } - } - public int GetRepeatedInt32(int index) { - return repeatedInt32_[index]; - } - - public const int RepeatedFixed64FieldNumber = 2046; - private pbc::PopsicleList repeatedFixed64_ = new pbc::PopsicleList(); - public scg::IList RepeatedFixed64List { - get { return pbc::Lists.AsReadOnly(repeatedFixed64_); } - } - public int RepeatedFixed64Count { - get { return repeatedFixed64_.Count; } - } - public ulong GetRepeatedFixed64(int index) { - return repeatedFixed64_[index]; - } - - public const int RepeatedInt64FieldNumber = 2047; - private pbc::PopsicleList repeatedInt64_ = new pbc::PopsicleList(); - public scg::IList RepeatedInt64List { - get { return pbc::Lists.AsReadOnly(repeatedInt64_); } - } - public int RepeatedInt64Count { - get { return repeatedInt64_.Count; } - } - public long GetRepeatedInt64(int index) { - return repeatedInt64_[index]; - } - - public const int RepeatedFloatFieldNumber = 262142; - private pbc::PopsicleList repeatedFloat_ = new pbc::PopsicleList(); - public scg::IList RepeatedFloatList { - get { return pbc::Lists.AsReadOnly(repeatedFloat_); } - } - public int RepeatedFloatCount { - get { return repeatedFloat_.Count; } - } - public float GetRepeatedFloat(int index) { - return repeatedFloat_[index]; - } - - public const int RepeatedUint64FieldNumber = 262143; - private pbc::PopsicleList repeatedUint64_ = new pbc::PopsicleList(); - public scg::IList RepeatedUint64List { - get { return pbc::Lists.AsReadOnly(repeatedUint64_); } - } - public int RepeatedUint64Count { - get { return repeatedUint64_.Count; } - } - public ulong GetRepeatedUint64(int index) { - return repeatedUint64_[index]; - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testRepeatedScalarDifferentTagSizesFieldNames; - if (repeatedFixed32_.Count > 0) { - output.WriteFixed32Array(12, field_names[0], repeatedFixed32_); - } - if (repeatedInt32_.Count > 0) { - output.WriteInt32Array(13, field_names[3], repeatedInt32_); - } - if (repeatedFixed64_.Count > 0) { - output.WriteFixed64Array(2046, field_names[1], repeatedFixed64_); - } - if (repeatedInt64_.Count > 0) { - output.WriteInt64Array(2047, field_names[4], repeatedInt64_); - } - if (repeatedFloat_.Count > 0) { - output.WriteFloatArray(262142, field_names[2], repeatedFloat_); - } - if (repeatedUint64_.Count > 0) { - output.WriteUInt64Array(262143, field_names[5], repeatedUint64_); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - { - int dataSize = 0; - dataSize = 4 * repeatedFixed32_.Count; - size += dataSize; - size += 1 * repeatedFixed32_.Count; - } - { - int dataSize = 0; - foreach (int element in RepeatedInt32List) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); - } - size += dataSize; - size += 1 * repeatedInt32_.Count; - } - { - int dataSize = 0; - dataSize = 8 * repeatedFixed64_.Count; - size += dataSize; - size += 2 * repeatedFixed64_.Count; - } - { - int dataSize = 0; - foreach (long element in RepeatedInt64List) { - dataSize += pb::CodedOutputStream.ComputeInt64SizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedInt64_.Count; - } - { - int dataSize = 0; - dataSize = 4 * repeatedFloat_.Count; - size += dataSize; - size += 3 * repeatedFloat_.Count; - } - { - int dataSize = 0; - foreach (ulong element in RepeatedUint64List) { - dataSize += pb::CodedOutputStream.ComputeUInt64SizeNoTag(element); - } - size += dataSize; - size += 3 * repeatedUint64_.Count; - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestRepeatedScalarDifferentTagSizes ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestRepeatedScalarDifferentTagSizes ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestRepeatedScalarDifferentTagSizes ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestRepeatedScalarDifferentTagSizes ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestRepeatedScalarDifferentTagSizes ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestRepeatedScalarDifferentTagSizes ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestRepeatedScalarDifferentTagSizes ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestRepeatedScalarDifferentTagSizes ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestRepeatedScalarDifferentTagSizes ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestRepeatedScalarDifferentTagSizes ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestRepeatedScalarDifferentTagSizes MakeReadOnly() { - repeatedFixed32_.MakeReadOnly(); - repeatedInt32_.MakeReadOnly(); - repeatedFixed64_.MakeReadOnly(); - repeatedInt64_.MakeReadOnly(); - repeatedFloat_.MakeReadOnly(); - repeatedUint64_.MakeReadOnly(); - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestRepeatedScalarDifferentTagSizes prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestRepeatedScalarDifferentTagSizes cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestRepeatedScalarDifferentTagSizes result; - - private TestRepeatedScalarDifferentTagSizes PrepareBuilder() { - if (resultIsReadOnly) { - TestRepeatedScalarDifferentTagSizes original = result; - result = new TestRepeatedScalarDifferentTagSizes(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestRepeatedScalarDifferentTagSizes MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestRepeatedScalarDifferentTagSizes.Descriptor; } - } - - public override TestRepeatedScalarDifferentTagSizes DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestRepeatedScalarDifferentTagSizes.DefaultInstance; } - } - - public override TestRepeatedScalarDifferentTagSizes BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestRepeatedScalarDifferentTagSizes) { - return MergeFrom((TestRepeatedScalarDifferentTagSizes) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestRepeatedScalarDifferentTagSizes other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestRepeatedScalarDifferentTagSizes.DefaultInstance) return this; - PrepareBuilder(); - if (other.repeatedFixed32_.Count != 0) { - result.repeatedFixed32_.Add(other.repeatedFixed32_); - } - if (other.repeatedInt32_.Count != 0) { - result.repeatedInt32_.Add(other.repeatedInt32_); - } - if (other.repeatedFixed64_.Count != 0) { - result.repeatedFixed64_.Add(other.repeatedFixed64_); - } - if (other.repeatedInt64_.Count != 0) { - result.repeatedInt64_.Add(other.repeatedInt64_); - } - if (other.repeatedFloat_.Count != 0) { - result.repeatedFloat_.Add(other.repeatedFloat_); - } - if (other.repeatedUint64_.Count != 0) { - result.repeatedUint64_.Add(other.repeatedUint64_); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testRepeatedScalarDifferentTagSizesFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testRepeatedScalarDifferentTagSizesFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 98: - case 101: { - input.ReadFixed32Array(tag, field_name, result.repeatedFixed32_); - break; - } - case 106: - case 104: { - input.ReadInt32Array(tag, field_name, result.repeatedInt32_); - break; - } - case 16370: - case 16369: { - input.ReadFixed64Array(tag, field_name, result.repeatedFixed64_); - break; - } - case 16378: - case 16376: { - input.ReadInt64Array(tag, field_name, result.repeatedInt64_); - break; - } - case 2097138: - case 2097141: { - input.ReadFloatArray(tag, field_name, result.repeatedFloat_); - break; - } - case 2097146: - case 2097144: { - input.ReadUInt64Array(tag, field_name, result.repeatedUint64_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public pbc::IPopsicleList RepeatedFixed32List { - get { return PrepareBuilder().repeatedFixed32_; } - } - public int RepeatedFixed32Count { - get { return result.RepeatedFixed32Count; } - } - public uint GetRepeatedFixed32(int index) { - return result.GetRepeatedFixed32(index); - } - public Builder SetRepeatedFixed32(int index, uint value) { - PrepareBuilder(); - result.repeatedFixed32_[index] = value; - return this; - } - public Builder AddRepeatedFixed32(uint value) { - PrepareBuilder(); - result.repeatedFixed32_.Add(value); - return this; - } - public Builder AddRangeRepeatedFixed32(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedFixed32_.Add(values); - return this; - } - public Builder ClearRepeatedFixed32() { - PrepareBuilder(); - result.repeatedFixed32_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedInt32List { - get { return PrepareBuilder().repeatedInt32_; } - } - public int RepeatedInt32Count { - get { return result.RepeatedInt32Count; } - } - public int GetRepeatedInt32(int index) { - return result.GetRepeatedInt32(index); - } - public Builder SetRepeatedInt32(int index, int value) { - PrepareBuilder(); - result.repeatedInt32_[index] = value; - return this; - } - public Builder AddRepeatedInt32(int value) { - PrepareBuilder(); - result.repeatedInt32_.Add(value); - return this; - } - public Builder AddRangeRepeatedInt32(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedInt32_.Add(values); - return this; - } - public Builder ClearRepeatedInt32() { - PrepareBuilder(); - result.repeatedInt32_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedFixed64List { - get { return PrepareBuilder().repeatedFixed64_; } - } - public int RepeatedFixed64Count { - get { return result.RepeatedFixed64Count; } - } - public ulong GetRepeatedFixed64(int index) { - return result.GetRepeatedFixed64(index); - } - public Builder SetRepeatedFixed64(int index, ulong value) { - PrepareBuilder(); - result.repeatedFixed64_[index] = value; - return this; - } - public Builder AddRepeatedFixed64(ulong value) { - PrepareBuilder(); - result.repeatedFixed64_.Add(value); - return this; - } - public Builder AddRangeRepeatedFixed64(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedFixed64_.Add(values); - return this; - } - public Builder ClearRepeatedFixed64() { - PrepareBuilder(); - result.repeatedFixed64_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedInt64List { - get { return PrepareBuilder().repeatedInt64_; } - } - public int RepeatedInt64Count { - get { return result.RepeatedInt64Count; } - } - public long GetRepeatedInt64(int index) { - return result.GetRepeatedInt64(index); - } - public Builder SetRepeatedInt64(int index, long value) { - PrepareBuilder(); - result.repeatedInt64_[index] = value; - return this; - } - public Builder AddRepeatedInt64(long value) { - PrepareBuilder(); - result.repeatedInt64_.Add(value); - return this; - } - public Builder AddRangeRepeatedInt64(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedInt64_.Add(values); - return this; - } - public Builder ClearRepeatedInt64() { - PrepareBuilder(); - result.repeatedInt64_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedFloatList { - get { return PrepareBuilder().repeatedFloat_; } - } - public int RepeatedFloatCount { - get { return result.RepeatedFloatCount; } - } - public float GetRepeatedFloat(int index) { - return result.GetRepeatedFloat(index); - } - public Builder SetRepeatedFloat(int index, float value) { - PrepareBuilder(); - result.repeatedFloat_[index] = value; - return this; - } - public Builder AddRepeatedFloat(float value) { - PrepareBuilder(); - result.repeatedFloat_.Add(value); - return this; - } - public Builder AddRangeRepeatedFloat(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedFloat_.Add(values); - return this; - } - public Builder ClearRepeatedFloat() { - PrepareBuilder(); - result.repeatedFloat_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedUint64List { - get { return PrepareBuilder().repeatedUint64_; } - } - public int RepeatedUint64Count { - get { return result.RepeatedUint64Count; } - } - public ulong GetRepeatedUint64(int index) { - return result.GetRepeatedUint64(index); - } - public Builder SetRepeatedUint64(int index, ulong value) { - PrepareBuilder(); - result.repeatedUint64_[index] = value; - return this; - } - public Builder AddRepeatedUint64(ulong value) { - PrepareBuilder(); - result.repeatedUint64_.Add(value); - return this; - } - public Builder AddRangeRepeatedUint64(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedUint64_.Add(values); - return this; - } - public Builder ClearRepeatedUint64() { - PrepareBuilder(); - result.repeatedUint64_.Clear(); - return this; - } - } - static TestRepeatedScalarDifferentTagSizes() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestParsingMerge : pb::ExtendableMessage { - private TestParsingMerge() { } - private static readonly TestParsingMerge defaultInstance = new TestParsingMerge().MakeReadOnly(); - private static readonly string[] _testParsingMergeFieldNames = new string[] { "optional_all_types", "optionalgroup", "repeated_all_types", "repeatedgroup", "required_all_types" }; - private static readonly uint[] _testParsingMergeFieldTags = new uint[] { 18, 83, 26, 163, 10 }; - public static TestParsingMerge DefaultInstance { - get { return defaultInstance; } - } - - public override TestParsingMerge DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestParsingMerge ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestParsingMerge__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestParsingMerge__FieldAccessorTable; } - } - - public const int OptionalExtFieldNumber = 1000; - public static pb::GeneratedExtensionBase OptionalExt; - public const int RepeatedExtFieldNumber = 1001; - public static pb::GeneratedExtensionBase> RepeatedExt; - #region Nested types - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class Types { - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class RepeatedFieldsGenerator : pb::GeneratedMessage { - private RepeatedFieldsGenerator() { } - private static readonly RepeatedFieldsGenerator defaultInstance = new RepeatedFieldsGenerator().MakeReadOnly(); - private static readonly string[] _repeatedFieldsGeneratorFieldNames = new string[] { "ext1", "ext2", "field1", "field2", "field3", "group1", "group2" }; - private static readonly uint[] _repeatedFieldsGeneratorFieldTags = new uint[] { 8002, 8010, 10, 18, 26, 83, 163 }; - public static RepeatedFieldsGenerator DefaultInstance { - get { return defaultInstance; } - } - - public override RepeatedFieldsGenerator DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override RepeatedFieldsGenerator ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestParsingMerge_RepeatedFieldsGenerator__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestParsingMerge_RepeatedFieldsGenerator__FieldAccessorTable; } - } - - #region Nested types - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class Types { - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Group1 : pb::GeneratedMessage { - private Group1() { } - private static readonly Group1 defaultInstance = new Group1().MakeReadOnly(); - private static readonly string[] _group1FieldNames = new string[] { "field1" }; - private static readonly uint[] _group1FieldTags = new uint[] { 90 }; - public static Group1 DefaultInstance { - get { return defaultInstance; } - } - - public override Group1 DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override Group1 ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestParsingMerge_RepeatedFieldsGenerator_Group1__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestParsingMerge_RepeatedFieldsGenerator_Group1__FieldAccessorTable; } - } - - public const int Field1FieldNumber = 11; - private bool hasField1; - private global::Google.ProtocolBuffers.TestProtos.TestAllTypes field1_; - public bool HasField1 { - get { return hasField1; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes Field1 { - get { return field1_ ?? global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _group1FieldNames; - if (hasField1) { - output.WriteMessage(11, field_names[0], Field1); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasField1) { - size += pb::CodedOutputStream.ComputeMessageSize(11, Field1); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static Group1 ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static Group1 ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static Group1 ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static Group1 ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static Group1 ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static Group1 ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static Group1 ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static Group1 ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static Group1 ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static Group1 ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private Group1 MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(Group1 prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(Group1 cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private Group1 result; - - private Group1 PrepareBuilder() { - if (resultIsReadOnly) { - Group1 original = result; - result = new Group1(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override Group1 MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedFieldsGenerator.Types.Group1.Descriptor; } - } - - public override Group1 DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedFieldsGenerator.Types.Group1.DefaultInstance; } - } - - public override Group1 BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is Group1) { - return MergeFrom((Group1) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(Group1 other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedFieldsGenerator.Types.Group1.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasField1) { - MergeField1(other.Field1); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_group1FieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _group1FieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 90: { - global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.CreateBuilder(); - if (result.hasField1) { - subBuilder.MergeFrom(Field1); - } - input.ReadMessage(subBuilder, extensionRegistry); - Field1 = subBuilder.BuildPartial(); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasField1 { - get { return result.hasField1; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes Field1 { - get { return result.Field1; } - set { SetField1(value); } - } - public Builder SetField1(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasField1 = true; - result.field1_ = value; - return this; - } - public Builder SetField1(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasField1 = true; - result.field1_ = builderForValue.Build(); - return this; - } - public Builder MergeField1(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasField1 && - result.field1_ != global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance) { - result.field1_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.CreateBuilder(result.field1_).MergeFrom(value).BuildPartial(); - } else { - result.field1_ = value; - } - result.hasField1 = true; - return this; - } - public Builder ClearField1() { - PrepareBuilder(); - result.hasField1 = false; - result.field1_ = null; - return this; - } - } - static Group1() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Group2 : pb::GeneratedMessage { - private Group2() { } - private static readonly Group2 defaultInstance = new Group2().MakeReadOnly(); - private static readonly string[] _group2FieldNames = new string[] { "field1" }; - private static readonly uint[] _group2FieldTags = new uint[] { 170 }; - public static Group2 DefaultInstance { - get { return defaultInstance; } - } - - public override Group2 DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override Group2 ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestParsingMerge_RepeatedFieldsGenerator_Group2__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestParsingMerge_RepeatedFieldsGenerator_Group2__FieldAccessorTable; } - } - - public const int Field1FieldNumber = 21; - private bool hasField1; - private global::Google.ProtocolBuffers.TestProtos.TestAllTypes field1_; - public bool HasField1 { - get { return hasField1; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes Field1 { - get { return field1_ ?? global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _group2FieldNames; - if (hasField1) { - output.WriteMessage(21, field_names[0], Field1); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasField1) { - size += pb::CodedOutputStream.ComputeMessageSize(21, Field1); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static Group2 ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static Group2 ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static Group2 ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static Group2 ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static Group2 ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static Group2 ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static Group2 ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static Group2 ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static Group2 ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static Group2 ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private Group2 MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(Group2 prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(Group2 cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private Group2 result; - - private Group2 PrepareBuilder() { - if (resultIsReadOnly) { - Group2 original = result; - result = new Group2(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override Group2 MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedFieldsGenerator.Types.Group2.Descriptor; } - } - - public override Group2 DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedFieldsGenerator.Types.Group2.DefaultInstance; } - } - - public override Group2 BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is Group2) { - return MergeFrom((Group2) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(Group2 other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedFieldsGenerator.Types.Group2.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasField1) { - MergeField1(other.Field1); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_group2FieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _group2FieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 170: { - global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.CreateBuilder(); - if (result.hasField1) { - subBuilder.MergeFrom(Field1); - } - input.ReadMessage(subBuilder, extensionRegistry); - Field1 = subBuilder.BuildPartial(); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasField1 { - get { return result.hasField1; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes Field1 { - get { return result.Field1; } - set { SetField1(value); } - } - public Builder SetField1(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasField1 = true; - result.field1_ = value; - return this; - } - public Builder SetField1(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasField1 = true; - result.field1_ = builderForValue.Build(); - return this; - } - public Builder MergeField1(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasField1 && - result.field1_ != global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance) { - result.field1_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.CreateBuilder(result.field1_).MergeFrom(value).BuildPartial(); - } else { - result.field1_ = value; - } - result.hasField1 = true; - return this; - } - public Builder ClearField1() { - PrepareBuilder(); - result.hasField1 = false; - result.field1_ = null; - return this; - } - } - static Group2() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - } - #endregion - - public const int Field1FieldNumber = 1; - private pbc::PopsicleList field1_ = new pbc::PopsicleList(); - public scg::IList Field1List { - get { return field1_; } - } - public int Field1Count { - get { return field1_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes GetField1(int index) { - return field1_[index]; - } - - public const int Field2FieldNumber = 2; - private pbc::PopsicleList field2_ = new pbc::PopsicleList(); - public scg::IList Field2List { - get { return field2_; } - } - public int Field2Count { - get { return field2_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes GetField2(int index) { - return field2_[index]; - } - - public const int Field3FieldNumber = 3; - private pbc::PopsicleList field3_ = new pbc::PopsicleList(); - public scg::IList Field3List { - get { return field3_; } - } - public int Field3Count { - get { return field3_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes GetField3(int index) { - return field3_[index]; - } - - public const int Group1FieldNumber = 10; - private pbc::PopsicleList group1_ = new pbc::PopsicleList(); - public scg::IList Group1List { - get { return group1_; } - } - public int Group1Count { - get { return group1_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedFieldsGenerator.Types.Group1 GetGroup1(int index) { - return group1_[index]; - } - - public const int Group2FieldNumber = 20; - private pbc::PopsicleList group2_ = new pbc::PopsicleList(); - public scg::IList Group2List { - get { return group2_; } - } - public int Group2Count { - get { return group2_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedFieldsGenerator.Types.Group2 GetGroup2(int index) { - return group2_[index]; - } - - public const int Ext1FieldNumber = 1000; - private pbc::PopsicleList ext1_ = new pbc::PopsicleList(); - public scg::IList Ext1List { - get { return ext1_; } - } - public int Ext1Count { - get { return ext1_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes GetExt1(int index) { - return ext1_[index]; - } - - public const int Ext2FieldNumber = 1001; - private pbc::PopsicleList ext2_ = new pbc::PopsicleList(); - public scg::IList Ext2List { - get { return ext2_; } - } - public int Ext2Count { - get { return ext2_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes GetExt2(int index) { - return ext2_[index]; - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _repeatedFieldsGeneratorFieldNames; - if (field1_.Count > 0) { - output.WriteMessageArray(1, field_names[2], field1_); - } - if (field2_.Count > 0) { - output.WriteMessageArray(2, field_names[3], field2_); - } - if (field3_.Count > 0) { - output.WriteMessageArray(3, field_names[4], field3_); - } - if (group1_.Count > 0) { - output.WriteGroupArray(10, field_names[5], group1_); - } - if (group2_.Count > 0) { - output.WriteGroupArray(20, field_names[6], group2_); - } - if (ext1_.Count > 0) { - output.WriteMessageArray(1000, field_names[0], ext1_); - } - if (ext2_.Count > 0) { - output.WriteMessageArray(1001, field_names[1], ext2_); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypes element in Field1List) { - size += pb::CodedOutputStream.ComputeMessageSize(1, element); - } - foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypes element in Field2List) { - size += pb::CodedOutputStream.ComputeMessageSize(2, element); - } - foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypes element in Field3List) { - size += pb::CodedOutputStream.ComputeMessageSize(3, element); - } - foreach (global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedFieldsGenerator.Types.Group1 element in Group1List) { - size += pb::CodedOutputStream.ComputeGroupSize(10, element); - } - foreach (global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedFieldsGenerator.Types.Group2 element in Group2List) { - size += pb::CodedOutputStream.ComputeGroupSize(20, element); - } - foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypes element in Ext1List) { - size += pb::CodedOutputStream.ComputeMessageSize(1000, element); - } - foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypes element in Ext2List) { - size += pb::CodedOutputStream.ComputeMessageSize(1001, element); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static RepeatedFieldsGenerator ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static RepeatedFieldsGenerator ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static RepeatedFieldsGenerator ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static RepeatedFieldsGenerator ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static RepeatedFieldsGenerator ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static RepeatedFieldsGenerator ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static RepeatedFieldsGenerator ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static RepeatedFieldsGenerator ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static RepeatedFieldsGenerator ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static RepeatedFieldsGenerator ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private RepeatedFieldsGenerator MakeReadOnly() { - field1_.MakeReadOnly(); - field2_.MakeReadOnly(); - field3_.MakeReadOnly(); - group1_.MakeReadOnly(); - group2_.MakeReadOnly(); - ext1_.MakeReadOnly(); - ext2_.MakeReadOnly(); - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(RepeatedFieldsGenerator prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(RepeatedFieldsGenerator cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private RepeatedFieldsGenerator result; - - private RepeatedFieldsGenerator PrepareBuilder() { - if (resultIsReadOnly) { - RepeatedFieldsGenerator original = result; - result = new RepeatedFieldsGenerator(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override RepeatedFieldsGenerator MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedFieldsGenerator.Descriptor; } - } - - public override RepeatedFieldsGenerator DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedFieldsGenerator.DefaultInstance; } - } - - public override RepeatedFieldsGenerator BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is RepeatedFieldsGenerator) { - return MergeFrom((RepeatedFieldsGenerator) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(RepeatedFieldsGenerator other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedFieldsGenerator.DefaultInstance) return this; - PrepareBuilder(); - if (other.field1_.Count != 0) { - result.field1_.Add(other.field1_); - } - if (other.field2_.Count != 0) { - result.field2_.Add(other.field2_); - } - if (other.field3_.Count != 0) { - result.field3_.Add(other.field3_); - } - if (other.group1_.Count != 0) { - result.group1_.Add(other.group1_); - } - if (other.group2_.Count != 0) { - result.group2_.Add(other.group2_); - } - if (other.ext1_.Count != 0) { - result.ext1_.Add(other.ext1_); - } - if (other.ext2_.Count != 0) { - result.ext2_.Add(other.ext2_); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_repeatedFieldsGeneratorFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _repeatedFieldsGeneratorFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 10: { - input.ReadMessageArray(tag, field_name, result.field1_, global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance, extensionRegistry); - break; - } - case 18: { - input.ReadMessageArray(tag, field_name, result.field2_, global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance, extensionRegistry); - break; - } - case 26: { - input.ReadMessageArray(tag, field_name, result.field3_, global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance, extensionRegistry); - break; - } - case 83: { - input.ReadGroupArray(tag, field_name, result.group1_, global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedFieldsGenerator.Types.Group1.DefaultInstance, extensionRegistry); - break; - } - case 163: { - input.ReadGroupArray(tag, field_name, result.group2_, global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedFieldsGenerator.Types.Group2.DefaultInstance, extensionRegistry); - break; - } - case 8002: { - input.ReadMessageArray(tag, field_name, result.ext1_, global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance, extensionRegistry); - break; - } - case 8010: { - input.ReadMessageArray(tag, field_name, result.ext2_, global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance, extensionRegistry); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public pbc::IPopsicleList Field1List { - get { return PrepareBuilder().field1_; } - } - public int Field1Count { - get { return result.Field1Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes GetField1(int index) { - return result.GetField1(index); - } - public Builder SetField1(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.field1_[index] = value; - return this; - } - public Builder SetField1(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.field1_[index] = builderForValue.Build(); - return this; - } - public Builder AddField1(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.field1_.Add(value); - return this; - } - public Builder AddField1(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.field1_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeField1(scg::IEnumerable values) { - PrepareBuilder(); - result.field1_.Add(values); - return this; - } - public Builder ClearField1() { - PrepareBuilder(); - result.field1_.Clear(); - return this; - } - - public pbc::IPopsicleList Field2List { - get { return PrepareBuilder().field2_; } - } - public int Field2Count { - get { return result.Field2Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes GetField2(int index) { - return result.GetField2(index); - } - public Builder SetField2(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.field2_[index] = value; - return this; - } - public Builder SetField2(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.field2_[index] = builderForValue.Build(); - return this; - } - public Builder AddField2(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.field2_.Add(value); - return this; - } - public Builder AddField2(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.field2_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeField2(scg::IEnumerable values) { - PrepareBuilder(); - result.field2_.Add(values); - return this; - } - public Builder ClearField2() { - PrepareBuilder(); - result.field2_.Clear(); - return this; - } - - public pbc::IPopsicleList Field3List { - get { return PrepareBuilder().field3_; } - } - public int Field3Count { - get { return result.Field3Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes GetField3(int index) { - return result.GetField3(index); - } - public Builder SetField3(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.field3_[index] = value; - return this; - } - public Builder SetField3(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.field3_[index] = builderForValue.Build(); - return this; - } - public Builder AddField3(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.field3_.Add(value); - return this; - } - public Builder AddField3(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.field3_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeField3(scg::IEnumerable values) { - PrepareBuilder(); - result.field3_.Add(values); - return this; - } - public Builder ClearField3() { - PrepareBuilder(); - result.field3_.Clear(); - return this; - } - - public pbc::IPopsicleList Group1List { - get { return PrepareBuilder().group1_; } - } - public int Group1Count { - get { return result.Group1Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedFieldsGenerator.Types.Group1 GetGroup1(int index) { - return result.GetGroup1(index); - } - public Builder SetGroup1(int index, global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedFieldsGenerator.Types.Group1 value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.group1_[index] = value; - return this; - } - public Builder SetGroup1(int index, global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedFieldsGenerator.Types.Group1.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.group1_[index] = builderForValue.Build(); - return this; - } - public Builder AddGroup1(global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedFieldsGenerator.Types.Group1 value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.group1_.Add(value); - return this; - } - public Builder AddGroup1(global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedFieldsGenerator.Types.Group1.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.group1_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeGroup1(scg::IEnumerable values) { - PrepareBuilder(); - result.group1_.Add(values); - return this; - } - public Builder ClearGroup1() { - PrepareBuilder(); - result.group1_.Clear(); - return this; - } - - public pbc::IPopsicleList Group2List { - get { return PrepareBuilder().group2_; } - } - public int Group2Count { - get { return result.Group2Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedFieldsGenerator.Types.Group2 GetGroup2(int index) { - return result.GetGroup2(index); - } - public Builder SetGroup2(int index, global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedFieldsGenerator.Types.Group2 value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.group2_[index] = value; - return this; - } - public Builder SetGroup2(int index, global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedFieldsGenerator.Types.Group2.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.group2_[index] = builderForValue.Build(); - return this; - } - public Builder AddGroup2(global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedFieldsGenerator.Types.Group2 value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.group2_.Add(value); - return this; - } - public Builder AddGroup2(global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedFieldsGenerator.Types.Group2.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.group2_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeGroup2(scg::IEnumerable values) { - PrepareBuilder(); - result.group2_.Add(values); - return this; - } - public Builder ClearGroup2() { - PrepareBuilder(); - result.group2_.Clear(); - return this; - } - - public pbc::IPopsicleList Ext1List { - get { return PrepareBuilder().ext1_; } - } - public int Ext1Count { - get { return result.Ext1Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes GetExt1(int index) { - return result.GetExt1(index); - } - public Builder SetExt1(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.ext1_[index] = value; - return this; - } - public Builder SetExt1(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.ext1_[index] = builderForValue.Build(); - return this; - } - public Builder AddExt1(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.ext1_.Add(value); - return this; - } - public Builder AddExt1(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.ext1_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeExt1(scg::IEnumerable values) { - PrepareBuilder(); - result.ext1_.Add(values); - return this; - } - public Builder ClearExt1() { - PrepareBuilder(); - result.ext1_.Clear(); - return this; - } - - public pbc::IPopsicleList Ext2List { - get { return PrepareBuilder().ext2_; } - } - public int Ext2Count { - get { return result.Ext2Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes GetExt2(int index) { - return result.GetExt2(index); - } - public Builder SetExt2(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.ext2_[index] = value; - return this; - } - public Builder SetExt2(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.ext2_[index] = builderForValue.Build(); - return this; - } - public Builder AddExt2(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.ext2_.Add(value); - return this; - } - public Builder AddExt2(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.ext2_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeExt2(scg::IEnumerable values) { - PrepareBuilder(); - result.ext2_.Add(values); - return this; - } - public Builder ClearExt2() { - PrepareBuilder(); - result.ext2_.Clear(); - return this; - } - } - static RepeatedFieldsGenerator() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class OptionalGroup : pb::GeneratedMessage { - private OptionalGroup() { } - private static readonly OptionalGroup defaultInstance = new OptionalGroup().MakeReadOnly(); - private static readonly string[] _optionalGroupFieldNames = new string[] { "optional_group_all_types" }; - private static readonly uint[] _optionalGroupFieldTags = new uint[] { 90 }; - public static OptionalGroup DefaultInstance { - get { return defaultInstance; } - } - - public override OptionalGroup DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override OptionalGroup ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestParsingMerge_OptionalGroup__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestParsingMerge_OptionalGroup__FieldAccessorTable; } - } - - public const int OptionalGroupAllTypesFieldNumber = 11; - private bool hasOptionalGroupAllTypes; - private global::Google.ProtocolBuffers.TestProtos.TestAllTypes optionalGroupAllTypes_; - public bool HasOptionalGroupAllTypes { - get { return hasOptionalGroupAllTypes; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes OptionalGroupAllTypes { - get { return optionalGroupAllTypes_ ?? global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _optionalGroupFieldNames; - if (hasOptionalGroupAllTypes) { - output.WriteMessage(11, field_names[0], OptionalGroupAllTypes); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasOptionalGroupAllTypes) { - size += pb::CodedOutputStream.ComputeMessageSize(11, OptionalGroupAllTypes); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static OptionalGroup ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static OptionalGroup ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static OptionalGroup ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static OptionalGroup ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static OptionalGroup ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static OptionalGroup ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static OptionalGroup ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static OptionalGroup ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static OptionalGroup ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static OptionalGroup ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private OptionalGroup MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(OptionalGroup prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(OptionalGroup cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private OptionalGroup result; - - private OptionalGroup PrepareBuilder() { - if (resultIsReadOnly) { - OptionalGroup original = result; - result = new OptionalGroup(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override OptionalGroup MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.OptionalGroup.Descriptor; } - } - - public override OptionalGroup DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.OptionalGroup.DefaultInstance; } - } - - public override OptionalGroup BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is OptionalGroup) { - return MergeFrom((OptionalGroup) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(OptionalGroup other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.OptionalGroup.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasOptionalGroupAllTypes) { - MergeOptionalGroupAllTypes(other.OptionalGroupAllTypes); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_optionalGroupFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _optionalGroupFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 90: { - global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.CreateBuilder(); - if (result.hasOptionalGroupAllTypes) { - subBuilder.MergeFrom(OptionalGroupAllTypes); - } - input.ReadMessage(subBuilder, extensionRegistry); - OptionalGroupAllTypes = subBuilder.BuildPartial(); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasOptionalGroupAllTypes { - get { return result.hasOptionalGroupAllTypes; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes OptionalGroupAllTypes { - get { return result.OptionalGroupAllTypes; } - set { SetOptionalGroupAllTypes(value); } - } - public Builder SetOptionalGroupAllTypes(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOptionalGroupAllTypes = true; - result.optionalGroupAllTypes_ = value; - return this; - } - public Builder SetOptionalGroupAllTypes(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasOptionalGroupAllTypes = true; - result.optionalGroupAllTypes_ = builderForValue.Build(); - return this; - } - public Builder MergeOptionalGroupAllTypes(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasOptionalGroupAllTypes && - result.optionalGroupAllTypes_ != global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance) { - result.optionalGroupAllTypes_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.CreateBuilder(result.optionalGroupAllTypes_).MergeFrom(value).BuildPartial(); - } else { - result.optionalGroupAllTypes_ = value; - } - result.hasOptionalGroupAllTypes = true; - return this; - } - public Builder ClearOptionalGroupAllTypes() { - PrepareBuilder(); - result.hasOptionalGroupAllTypes = false; - result.optionalGroupAllTypes_ = null; - return this; - } - } - static OptionalGroup() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class RepeatedGroup : pb::GeneratedMessage { - private RepeatedGroup() { } - private static readonly RepeatedGroup defaultInstance = new RepeatedGroup().MakeReadOnly(); - private static readonly string[] _repeatedGroupFieldNames = new string[] { "repeated_group_all_types" }; - private static readonly uint[] _repeatedGroupFieldTags = new uint[] { 170 }; - public static RepeatedGroup DefaultInstance { - get { return defaultInstance; } - } - - public override RepeatedGroup DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override RepeatedGroup ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestParsingMerge_RepeatedGroup__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestParsingMerge_RepeatedGroup__FieldAccessorTable; } - } - - public const int RepeatedGroupAllTypesFieldNumber = 21; - private bool hasRepeatedGroupAllTypes; - private global::Google.ProtocolBuffers.TestProtos.TestAllTypes repeatedGroupAllTypes_; - public bool HasRepeatedGroupAllTypes { - get { return hasRepeatedGroupAllTypes; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes RepeatedGroupAllTypes { - get { return repeatedGroupAllTypes_ ?? global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _repeatedGroupFieldNames; - if (hasRepeatedGroupAllTypes) { - output.WriteMessage(21, field_names[0], RepeatedGroupAllTypes); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasRepeatedGroupAllTypes) { - size += pb::CodedOutputStream.ComputeMessageSize(21, RepeatedGroupAllTypes); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static RepeatedGroup ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static RepeatedGroup ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static RepeatedGroup ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static RepeatedGroup ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static RepeatedGroup ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static RepeatedGroup ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static RepeatedGroup ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static RepeatedGroup ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static RepeatedGroup ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static RepeatedGroup ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private RepeatedGroup MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(RepeatedGroup prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(RepeatedGroup cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private RepeatedGroup result; - - private RepeatedGroup PrepareBuilder() { - if (resultIsReadOnly) { - RepeatedGroup original = result; - result = new RepeatedGroup(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override RepeatedGroup MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedGroup.Descriptor; } - } - - public override RepeatedGroup DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedGroup.DefaultInstance; } - } - - public override RepeatedGroup BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is RepeatedGroup) { - return MergeFrom((RepeatedGroup) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(RepeatedGroup other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedGroup.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasRepeatedGroupAllTypes) { - MergeRepeatedGroupAllTypes(other.RepeatedGroupAllTypes); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_repeatedGroupFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _repeatedGroupFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 170: { - global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.CreateBuilder(); - if (result.hasRepeatedGroupAllTypes) { - subBuilder.MergeFrom(RepeatedGroupAllTypes); - } - input.ReadMessage(subBuilder, extensionRegistry); - RepeatedGroupAllTypes = subBuilder.BuildPartial(); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasRepeatedGroupAllTypes { - get { return result.hasRepeatedGroupAllTypes; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes RepeatedGroupAllTypes { - get { return result.RepeatedGroupAllTypes; } - set { SetRepeatedGroupAllTypes(value); } - } - public Builder SetRepeatedGroupAllTypes(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasRepeatedGroupAllTypes = true; - result.repeatedGroupAllTypes_ = value; - return this; - } - public Builder SetRepeatedGroupAllTypes(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasRepeatedGroupAllTypes = true; - result.repeatedGroupAllTypes_ = builderForValue.Build(); - return this; - } - public Builder MergeRepeatedGroupAllTypes(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasRepeatedGroupAllTypes && - result.repeatedGroupAllTypes_ != global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance) { - result.repeatedGroupAllTypes_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.CreateBuilder(result.repeatedGroupAllTypes_).MergeFrom(value).BuildPartial(); - } else { - result.repeatedGroupAllTypes_ = value; - } - result.hasRepeatedGroupAllTypes = true; - return this; - } - public Builder ClearRepeatedGroupAllTypes() { - PrepareBuilder(); - result.hasRepeatedGroupAllTypes = false; - result.repeatedGroupAllTypes_ = null; - return this; - } - } - static RepeatedGroup() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - } - #endregion - - public const int RequiredAllTypesFieldNumber = 1; - private bool hasRequiredAllTypes; - private global::Google.ProtocolBuffers.TestProtos.TestAllTypes requiredAllTypes_; - public bool HasRequiredAllTypes { - get { return hasRequiredAllTypes; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes RequiredAllTypes { - get { return requiredAllTypes_ ?? global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance; } - } - - public const int OptionalAllTypesFieldNumber = 2; - private bool hasOptionalAllTypes; - private global::Google.ProtocolBuffers.TestProtos.TestAllTypes optionalAllTypes_; - public bool HasOptionalAllTypes { - get { return hasOptionalAllTypes; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes OptionalAllTypes { - get { return optionalAllTypes_ ?? global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance; } - } - - public const int RepeatedAllTypesFieldNumber = 3; - private pbc::PopsicleList repeatedAllTypes_ = new pbc::PopsicleList(); - public scg::IList RepeatedAllTypesList { - get { return repeatedAllTypes_; } - } - public int RepeatedAllTypesCount { - get { return repeatedAllTypes_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes GetRepeatedAllTypes(int index) { - return repeatedAllTypes_[index]; - } - - public const int OptionalGroupFieldNumber = 10; - private bool hasOptionalGroup; - private global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.OptionalGroup optionalGroup_; - public bool HasOptionalGroup { - get { return hasOptionalGroup; } - } - public global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.OptionalGroup OptionalGroup { - get { return optionalGroup_ ?? global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.OptionalGroup.DefaultInstance; } - } - - public const int RepeatedGroupFieldNumber = 20; - private pbc::PopsicleList repeatedGroup_ = new pbc::PopsicleList(); - public scg::IList RepeatedGroupList { - get { return repeatedGroup_; } - } - public int RepeatedGroupCount { - get { return repeatedGroup_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedGroup GetRepeatedGroup(int index) { - return repeatedGroup_[index]; - } - - public override bool IsInitialized { - get { - if (!hasRequiredAllTypes) return false; - if (!ExtensionsAreInitialized) return false; - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testParsingMergeFieldNames; - pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); - if (hasRequiredAllTypes) { - output.WriteMessage(1, field_names[4], RequiredAllTypes); - } - if (hasOptionalAllTypes) { - output.WriteMessage(2, field_names[0], OptionalAllTypes); - } - if (repeatedAllTypes_.Count > 0) { - output.WriteMessageArray(3, field_names[2], repeatedAllTypes_); - } - if (hasOptionalGroup) { - output.WriteGroup(10, field_names[1], OptionalGroup); - } - if (repeatedGroup_.Count > 0) { - output.WriteGroupArray(20, field_names[3], repeatedGroup_); - } - extensionWriter.WriteUntil(536870912, output); - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasRequiredAllTypes) { - size += pb::CodedOutputStream.ComputeMessageSize(1, RequiredAllTypes); - } - if (hasOptionalAllTypes) { - size += pb::CodedOutputStream.ComputeMessageSize(2, OptionalAllTypes); - } - foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypes element in RepeatedAllTypesList) { - size += pb::CodedOutputStream.ComputeMessageSize(3, element); - } - if (hasOptionalGroup) { - size += pb::CodedOutputStream.ComputeGroupSize(10, OptionalGroup); - } - foreach (global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedGroup element in RepeatedGroupList) { - size += pb::CodedOutputStream.ComputeGroupSize(20, element); - } - size += ExtensionsSerializedSize; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestParsingMerge ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestParsingMerge ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestParsingMerge ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestParsingMerge ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestParsingMerge ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestParsingMerge ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestParsingMerge ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestParsingMerge ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestParsingMerge ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestParsingMerge ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestParsingMerge MakeReadOnly() { - repeatedAllTypes_.MakeReadOnly(); - repeatedGroup_.MakeReadOnly(); - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestParsingMerge prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::ExtendableBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestParsingMerge cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestParsingMerge result; - - private TestParsingMerge PrepareBuilder() { - if (resultIsReadOnly) { - TestParsingMerge original = result; - result = new TestParsingMerge(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestParsingMerge MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Descriptor; } - } - - public override TestParsingMerge DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.DefaultInstance; } - } - - public override TestParsingMerge BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestParsingMerge) { - return MergeFrom((TestParsingMerge) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestParsingMerge other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasRequiredAllTypes) { - MergeRequiredAllTypes(other.RequiredAllTypes); - } - if (other.HasOptionalAllTypes) { - MergeOptionalAllTypes(other.OptionalAllTypes); - } - if (other.repeatedAllTypes_.Count != 0) { - result.repeatedAllTypes_.Add(other.repeatedAllTypes_); - } - if (other.HasOptionalGroup) { - MergeOptionalGroup(other.OptionalGroup); - } - if (other.repeatedGroup_.Count != 0) { - result.repeatedGroup_.Add(other.repeatedGroup_); - } - this.MergeExtensionFields(other); - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testParsingMergeFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testParsingMergeFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 10: { - global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.CreateBuilder(); - if (result.hasRequiredAllTypes) { - subBuilder.MergeFrom(RequiredAllTypes); - } - input.ReadMessage(subBuilder, extensionRegistry); - RequiredAllTypes = subBuilder.BuildPartial(); - break; - } - case 18: { - global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.CreateBuilder(); - if (result.hasOptionalAllTypes) { - subBuilder.MergeFrom(OptionalAllTypes); - } - input.ReadMessage(subBuilder, extensionRegistry); - OptionalAllTypes = subBuilder.BuildPartial(); - break; - } - case 26: { - input.ReadMessageArray(tag, field_name, result.repeatedAllTypes_, global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance, extensionRegistry); - break; - } - case 83: { - global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.OptionalGroup.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.OptionalGroup.CreateBuilder(); - if (result.hasOptionalGroup) { - subBuilder.MergeFrom(OptionalGroup); - } - input.ReadGroup(10, subBuilder, extensionRegistry); - OptionalGroup = subBuilder.BuildPartial(); - break; - } - case 163: { - input.ReadGroupArray(tag, field_name, result.repeatedGroup_, global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedGroup.DefaultInstance, extensionRegistry); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasRequiredAllTypes { - get { return result.hasRequiredAllTypes; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes RequiredAllTypes { - get { return result.RequiredAllTypes; } - set { SetRequiredAllTypes(value); } - } - public Builder SetRequiredAllTypes(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasRequiredAllTypes = true; - result.requiredAllTypes_ = value; - return this; - } - public Builder SetRequiredAllTypes(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasRequiredAllTypes = true; - result.requiredAllTypes_ = builderForValue.Build(); - return this; - } - public Builder MergeRequiredAllTypes(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasRequiredAllTypes && - result.requiredAllTypes_ != global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance) { - result.requiredAllTypes_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.CreateBuilder(result.requiredAllTypes_).MergeFrom(value).BuildPartial(); - } else { - result.requiredAllTypes_ = value; - } - result.hasRequiredAllTypes = true; - return this; - } - public Builder ClearRequiredAllTypes() { - PrepareBuilder(); - result.hasRequiredAllTypes = false; - result.requiredAllTypes_ = null; - return this; - } - - public bool HasOptionalAllTypes { - get { return result.hasOptionalAllTypes; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes OptionalAllTypes { - get { return result.OptionalAllTypes; } - set { SetOptionalAllTypes(value); } - } - public Builder SetOptionalAllTypes(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOptionalAllTypes = true; - result.optionalAllTypes_ = value; - return this; - } - public Builder SetOptionalAllTypes(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasOptionalAllTypes = true; - result.optionalAllTypes_ = builderForValue.Build(); - return this; - } - public Builder MergeOptionalAllTypes(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasOptionalAllTypes && - result.optionalAllTypes_ != global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance) { - result.optionalAllTypes_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.CreateBuilder(result.optionalAllTypes_).MergeFrom(value).BuildPartial(); - } else { - result.optionalAllTypes_ = value; - } - result.hasOptionalAllTypes = true; - return this; - } - public Builder ClearOptionalAllTypes() { - PrepareBuilder(); - result.hasOptionalAllTypes = false; - result.optionalAllTypes_ = null; - return this; - } - - public pbc::IPopsicleList RepeatedAllTypesList { - get { return PrepareBuilder().repeatedAllTypes_; } - } - public int RepeatedAllTypesCount { - get { return result.RepeatedAllTypesCount; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes GetRepeatedAllTypes(int index) { - return result.GetRepeatedAllTypes(index); - } - public Builder SetRepeatedAllTypes(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedAllTypes_[index] = value; - return this; - } - public Builder SetRepeatedAllTypes(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.repeatedAllTypes_[index] = builderForValue.Build(); - return this; - } - public Builder AddRepeatedAllTypes(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedAllTypes_.Add(value); - return this; - } - public Builder AddRepeatedAllTypes(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.repeatedAllTypes_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeRepeatedAllTypes(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedAllTypes_.Add(values); - return this; - } - public Builder ClearRepeatedAllTypes() { - PrepareBuilder(); - result.repeatedAllTypes_.Clear(); - return this; - } - - public bool HasOptionalGroup { - get { return result.hasOptionalGroup; } - } - public global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.OptionalGroup OptionalGroup { - get { return result.OptionalGroup; } - set { SetOptionalGroup(value); } - } - public Builder SetOptionalGroup(global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.OptionalGroup value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOptionalGroup = true; - result.optionalGroup_ = value; - return this; - } - public Builder SetOptionalGroup(global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.OptionalGroup.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasOptionalGroup = true; - result.optionalGroup_ = builderForValue.Build(); - return this; - } - public Builder MergeOptionalGroup(global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.OptionalGroup value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasOptionalGroup && - result.optionalGroup_ != global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.OptionalGroup.DefaultInstance) { - result.optionalGroup_ = global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.OptionalGroup.CreateBuilder(result.optionalGroup_).MergeFrom(value).BuildPartial(); - } else { - result.optionalGroup_ = value; - } - result.hasOptionalGroup = true; - return this; - } - public Builder ClearOptionalGroup() { - PrepareBuilder(); - result.hasOptionalGroup = false; - result.optionalGroup_ = null; - return this; - } - - public pbc::IPopsicleList RepeatedGroupList { - get { return PrepareBuilder().repeatedGroup_; } - } - public int RepeatedGroupCount { - get { return result.RepeatedGroupCount; } - } - public global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedGroup GetRepeatedGroup(int index) { - return result.GetRepeatedGroup(index); - } - public Builder SetRepeatedGroup(int index, global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedGroup value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedGroup_[index] = value; - return this; - } - public Builder SetRepeatedGroup(int index, global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedGroup.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.repeatedGroup_[index] = builderForValue.Build(); - return this; - } - public Builder AddRepeatedGroup(global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedGroup value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedGroup_.Add(value); - return this; - } - public Builder AddRepeatedGroup(global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedGroup.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.repeatedGroup_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeRepeatedGroup(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedGroup_.Add(values); - return this; - } - public Builder ClearRepeatedGroup() { - PrepareBuilder(); - result.repeatedGroup_.Clear(); - return this; - } - } - static TestParsingMerge() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestCommentInjectionMessage : pb::GeneratedMessage { - private TestCommentInjectionMessage() { } - private static readonly TestCommentInjectionMessage defaultInstance = new TestCommentInjectionMessage().MakeReadOnly(); - private static readonly string[] _testCommentInjectionMessageFieldNames = new string[] { "a" }; - private static readonly uint[] _testCommentInjectionMessageFieldTags = new uint[] { 10 }; - public static TestCommentInjectionMessage DefaultInstance { - get { return defaultInstance; } - } - - public override TestCommentInjectionMessage DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestCommentInjectionMessage ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestCommentInjectionMessage__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestCommentInjectionMessage__FieldAccessorTable; } - } - - public const int AFieldNumber = 1; - private bool hasA; - private string a_ = "*/ <- Neither should this."; - public bool HasA { - get { return hasA; } - } - public string A { - get { return a_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testCommentInjectionMessageFieldNames; - if (hasA) { - output.WriteString(1, field_names[0], A); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeStringSize(1, A); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestCommentInjectionMessage ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestCommentInjectionMessage ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestCommentInjectionMessage ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestCommentInjectionMessage ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestCommentInjectionMessage ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestCommentInjectionMessage ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestCommentInjectionMessage ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestCommentInjectionMessage ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestCommentInjectionMessage ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestCommentInjectionMessage ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestCommentInjectionMessage MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestCommentInjectionMessage prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestCommentInjectionMessage cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestCommentInjectionMessage result; - - private TestCommentInjectionMessage PrepareBuilder() { - if (resultIsReadOnly) { - TestCommentInjectionMessage original = result; - result = new TestCommentInjectionMessage(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestCommentInjectionMessage MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestCommentInjectionMessage.Descriptor; } - } - - public override TestCommentInjectionMessage DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestCommentInjectionMessage.DefaultInstance; } - } - - public override TestCommentInjectionMessage BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestCommentInjectionMessage) { - return MergeFrom((TestCommentInjectionMessage) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestCommentInjectionMessage other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestCommentInjectionMessage.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasA) { - A = other.A; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testCommentInjectionMessageFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testCommentInjectionMessageFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 10: { - result.hasA = input.ReadString(ref result.a_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasA { - get { return result.hasA; } - } - public string A { - get { return result.A; } - set { SetA(value); } - } - public Builder SetA(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasA = true; - result.a_ = value; - return this; - } - public Builder ClearA() { - PrepareBuilder(); - result.hasA = false; - result.a_ = "*/ <- Neither should this."; - return this; - } - } - static TestCommentInjectionMessage() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class FooRequest : pb::GeneratedMessage { - private FooRequest() { } - private static readonly FooRequest defaultInstance = new FooRequest().MakeReadOnly(); - private static readonly string[] _fooRequestFieldNames = new string[] { }; - private static readonly uint[] _fooRequestFieldTags = new uint[] { }; - public static FooRequest DefaultInstance { - get { return defaultInstance; } - } - - public override FooRequest DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override FooRequest ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_FooRequest__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_FooRequest__FieldAccessorTable; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _fooRequestFieldNames; - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static FooRequest ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static FooRequest ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static FooRequest ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static FooRequest ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static FooRequest ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static FooRequest ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static FooRequest ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static FooRequest ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static FooRequest ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static FooRequest ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private FooRequest MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(FooRequest prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(FooRequest cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private FooRequest result; - - private FooRequest PrepareBuilder() { - if (resultIsReadOnly) { - FooRequest original = result; - result = new FooRequest(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override FooRequest MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.FooRequest.Descriptor; } - } - - public override FooRequest DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.FooRequest.DefaultInstance; } - } - - public override FooRequest BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is FooRequest) { - return MergeFrom((FooRequest) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(FooRequest other) { - if (other == global::Google.ProtocolBuffers.TestProtos.FooRequest.DefaultInstance) return this; - PrepareBuilder(); - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_fooRequestFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _fooRequestFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - } - static FooRequest() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class FooResponse : pb::GeneratedMessage { - private FooResponse() { } - private static readonly FooResponse defaultInstance = new FooResponse().MakeReadOnly(); - private static readonly string[] _fooResponseFieldNames = new string[] { }; - private static readonly uint[] _fooResponseFieldTags = new uint[] { }; - public static FooResponse DefaultInstance { - get { return defaultInstance; } - } - - public override FooResponse DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override FooResponse ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_FooResponse__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_FooResponse__FieldAccessorTable; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _fooResponseFieldNames; - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static FooResponse ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static FooResponse ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static FooResponse ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static FooResponse ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static FooResponse ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static FooResponse ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static FooResponse ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static FooResponse ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static FooResponse ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static FooResponse ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private FooResponse MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(FooResponse prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(FooResponse cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private FooResponse result; - - private FooResponse PrepareBuilder() { - if (resultIsReadOnly) { - FooResponse original = result; - result = new FooResponse(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override FooResponse MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.FooResponse.Descriptor; } - } - - public override FooResponse DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.FooResponse.DefaultInstance; } - } - - public override FooResponse BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is FooResponse) { - return MergeFrom((FooResponse) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(FooResponse other) { - if (other == global::Google.ProtocolBuffers.TestProtos.FooResponse.DefaultInstance) return this; - PrepareBuilder(); - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_fooResponseFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _fooResponseFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - } - static FooResponse() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class FooClientMessage : pb::GeneratedMessage { - private FooClientMessage() { } - private static readonly FooClientMessage defaultInstance = new FooClientMessage().MakeReadOnly(); - private static readonly string[] _fooClientMessageFieldNames = new string[] { }; - private static readonly uint[] _fooClientMessageFieldTags = new uint[] { }; - public static FooClientMessage DefaultInstance { - get { return defaultInstance; } - } - - public override FooClientMessage DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override FooClientMessage ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_FooClientMessage__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_FooClientMessage__FieldAccessorTable; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _fooClientMessageFieldNames; - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static FooClientMessage ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static FooClientMessage ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static FooClientMessage ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static FooClientMessage ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static FooClientMessage ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static FooClientMessage ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static FooClientMessage ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static FooClientMessage ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static FooClientMessage ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static FooClientMessage ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private FooClientMessage MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(FooClientMessage prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(FooClientMessage cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private FooClientMessage result; - - private FooClientMessage PrepareBuilder() { - if (resultIsReadOnly) { - FooClientMessage original = result; - result = new FooClientMessage(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override FooClientMessage MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.FooClientMessage.Descriptor; } - } - - public override FooClientMessage DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.FooClientMessage.DefaultInstance; } - } - - public override FooClientMessage BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is FooClientMessage) { - return MergeFrom((FooClientMessage) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(FooClientMessage other) { - if (other == global::Google.ProtocolBuffers.TestProtos.FooClientMessage.DefaultInstance) return this; - PrepareBuilder(); - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_fooClientMessageFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _fooClientMessageFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - } - static FooClientMessage() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class FooServerMessage : pb::GeneratedMessage { - private FooServerMessage() { } - private static readonly FooServerMessage defaultInstance = new FooServerMessage().MakeReadOnly(); - private static readonly string[] _fooServerMessageFieldNames = new string[] { }; - private static readonly uint[] _fooServerMessageFieldTags = new uint[] { }; - public static FooServerMessage DefaultInstance { - get { return defaultInstance; } - } - - public override FooServerMessage DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override FooServerMessage ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_FooServerMessage__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_FooServerMessage__FieldAccessorTable; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _fooServerMessageFieldNames; - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static FooServerMessage ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static FooServerMessage ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static FooServerMessage ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static FooServerMessage ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static FooServerMessage ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static FooServerMessage ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static FooServerMessage ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static FooServerMessage ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static FooServerMessage ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static FooServerMessage ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private FooServerMessage MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(FooServerMessage prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(FooServerMessage cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private FooServerMessage result; - - private FooServerMessage PrepareBuilder() { - if (resultIsReadOnly) { - FooServerMessage original = result; - result = new FooServerMessage(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override FooServerMessage MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.FooServerMessage.Descriptor; } - } - - public override FooServerMessage DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.FooServerMessage.DefaultInstance; } - } - - public override FooServerMessage BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is FooServerMessage) { - return MergeFrom((FooServerMessage) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(FooServerMessage other) { - if (other == global::Google.ProtocolBuffers.TestProtos.FooServerMessage.DefaultInstance) return this; - PrepareBuilder(); - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_fooServerMessageFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _fooServerMessageFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - } - static FooServerMessage() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class BarRequest : pb::GeneratedMessage { - private BarRequest() { } - private static readonly BarRequest defaultInstance = new BarRequest().MakeReadOnly(); - private static readonly string[] _barRequestFieldNames = new string[] { }; - private static readonly uint[] _barRequestFieldTags = new uint[] { }; - public static BarRequest DefaultInstance { - get { return defaultInstance; } - } - - public override BarRequest DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override BarRequest ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_BarRequest__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_BarRequest__FieldAccessorTable; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _barRequestFieldNames; - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static BarRequest ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static BarRequest ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static BarRequest ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static BarRequest ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static BarRequest ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static BarRequest ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static BarRequest ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static BarRequest ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static BarRequest ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static BarRequest ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private BarRequest MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(BarRequest prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(BarRequest cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private BarRequest result; - - private BarRequest PrepareBuilder() { - if (resultIsReadOnly) { - BarRequest original = result; - result = new BarRequest(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override BarRequest MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.BarRequest.Descriptor; } - } - - public override BarRequest DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.BarRequest.DefaultInstance; } - } - - public override BarRequest BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is BarRequest) { - return MergeFrom((BarRequest) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(BarRequest other) { - if (other == global::Google.ProtocolBuffers.TestProtos.BarRequest.DefaultInstance) return this; - PrepareBuilder(); - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_barRequestFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _barRequestFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - } - static BarRequest() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class BarResponse : pb::GeneratedMessage { - private BarResponse() { } - private static readonly BarResponse defaultInstance = new BarResponse().MakeReadOnly(); - private static readonly string[] _barResponseFieldNames = new string[] { }; - private static readonly uint[] _barResponseFieldTags = new uint[] { }; - public static BarResponse DefaultInstance { - get { return defaultInstance; } - } - - public override BarResponse DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override BarResponse ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_BarResponse__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_BarResponse__FieldAccessorTable; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _barResponseFieldNames; - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static BarResponse ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static BarResponse ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static BarResponse ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static BarResponse ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static BarResponse ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static BarResponse ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static BarResponse ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static BarResponse ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static BarResponse ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static BarResponse ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private BarResponse MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(BarResponse prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(BarResponse cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private BarResponse result; - - private BarResponse PrepareBuilder() { - if (resultIsReadOnly) { - BarResponse original = result; - result = new BarResponse(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override BarResponse MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.BarResponse.Descriptor; } - } - - public override BarResponse DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.BarResponse.DefaultInstance; } - } - - public override BarResponse BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is BarResponse) { - return MergeFrom((BarResponse) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(BarResponse other) { - if (other == global::Google.ProtocolBuffers.TestProtos.BarResponse.DefaultInstance) return this; - PrepareBuilder(); - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_barResponseFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _barResponseFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - } - static BarResponse() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - #endregion - -} - -#endregion Designer generated code diff --git a/csharp/src/ProtocolBuffersLite.Test/TestProtos/UnittestExtrasFull.cs b/csharp/src/ProtocolBuffersLite.Test/TestProtos/UnittestExtrasFull.cs deleted file mode 100644 index 73c4b182..00000000 --- a/csharp/src/ProtocolBuffersLite.Test/TestProtos/UnittestExtrasFull.cs +++ /dev/null @@ -1,2138 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: unittest_extras_full.proto -#pragma warning disable 1591, 0612, 3021 -#region Designer generated code - -using pb = global::Google.ProtocolBuffers; -using pbc = global::Google.ProtocolBuffers.Collections; -using pbd = global::Google.ProtocolBuffers.Descriptors; -using scg = global::System.Collections.Generic; -namespace Google.ProtocolBuffers.TestProtos { - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class UnittestExtrasFull { - - #region Extension registration - public static void RegisterAllExtensions(pb::ExtensionRegistry registry) { - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestExtrasFull.EmployeeId); - } - #endregion - #region Extensions - public const int EmployeeIdFieldNumber = 126; - public static pb::GeneratedExtensionBase EmployeeId; - #endregion - - #region Static variables - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_extra_TestInteropPerson__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_extra_TestInteropPerson__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_extra_TestInteropPerson_PhoneNumber__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_extra_TestInteropPerson_PhoneNumber__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_extra_TestInteropPerson_Addresses__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_extra_TestInteropPerson_Addresses__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_extra_TestInteropEmployeeId__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_extra_TestInteropEmployeeId__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_extra_TestMissingFieldsA__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_extra_TestMissingFieldsA__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_extra_TestMissingFieldsA_SubA__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_extra_TestMissingFieldsA_SubA__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_extra_TestMissingFieldsB__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_extra_TestMissingFieldsB__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_extra_TestMissingFieldsB_SubB__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_extra_TestMissingFieldsB_SubB__FieldAccessorTable; - #endregion - #region Descriptor - public static pbd::FileDescriptor Descriptor { - get { return descriptor; } - } - private static pbd::FileDescriptor descriptor; - - static UnittestExtrasFull() { - byte[] descriptorData = global::System.Convert.FromBase64String( - string.Concat( - "Chp1bml0dGVzdF9leHRyYXNfZnVsbC5wcm90bxIXcHJvdG9idWZfdW5pdHRl", - "c3RfZXh0cmEi1gMKEVRlc3RJbnRlcm9wUGVyc29uEgwKBG5hbWUYASACKAkS", - "CgoCaWQYAiACKAUSDQoFZW1haWwYAyABKAkSEQoFY29kZXMYCiADKAVCAhAB", - "EkUKBXBob25lGAQgAygLMjYucHJvdG9idWZfdW5pdHRlc3RfZXh0cmEuVGVz", - "dEludGVyb3BQZXJzb24uUGhvbmVOdW1iZXISRwoJYWRkcmVzc2VzGAUgAygK", - "MjQucHJvdG9idWZfdW5pdHRlc3RfZXh0cmEuVGVzdEludGVyb3BQZXJzb24u", - "QWRkcmVzc2VzGmcKC1Bob25lTnVtYmVyEg4KBm51bWJlchgBIAIoCRJICgR0", - "eXBlGAIgASgOMjQucHJvdG9idWZfdW5pdHRlc3RfZXh0cmEuVGVzdEludGVy", - "b3BQZXJzb24uUGhvbmVUeXBlOgRIT01FGlgKCUFkZHJlc3NlcxIPCgdhZGRy", - "ZXNzGAEgAigJEhAKCGFkZHJlc3MyGAIgASgJEgwKBGNpdHkYAyACKAkSDQoF", - "c3RhdGUYBCACKAkSCwoDemlwGAUgAigHIisKCVBob25lVHlwZRIKCgZNT0JJ", - "TEUQABIICgRIT01FEAESCAoEV09SSxACKgUIZBDIASInChVUZXN0SW50ZXJv", - "cEVtcGxveWVlSWQSDgoGbnVtYmVyGAEgAigJIqUBChJUZXN0TWlzc2luZ0Zp", - "ZWxkc0ESDAoEbmFtZRgBIAIoCRIKCgJpZBgCIAIoBRINCgVlbWFpbBgDIAEo", - "CRI/CgV0ZXN0QRgLIAEoCzIwLnByb3RvYnVmX3VuaXR0ZXN0X2V4dHJhLlRl", - "c3RNaXNzaW5nRmllbGRzQS5TdWJBGiUKBFN1YkESDQoFY291bnQYBSACKAUS", - "DgoGdmFsdWVzGAYgAygJIpgBChJUZXN0TWlzc2luZ0ZpZWxkc0ISDAoEbmFt", - "ZRgBIAIoCRIKCgJpZBgCIAIoBRIPCgd3ZWJzaXRlGAQgASgJEj8KBXRlc3RC", - "GAwgASgLMjAucHJvdG9idWZfdW5pdHRlc3RfZXh0cmEuVGVzdE1pc3NpbmdG", - "aWVsZHNCLlN1YkIaFgoEU3ViQhIOCgZ2YWx1ZXMYByADKAk6bwoLZW1wbG95", - "ZWVfaWQSKi5wcm90b2J1Zl91bml0dGVzdF9leHRyYS5UZXN0SW50ZXJvcFBl", - "cnNvbhh+IAEoCzIuLnByb3RvYnVmX3VuaXR0ZXN0X2V4dHJhLlRlc3RJbnRl", - "cm9wRW1wbG95ZWVJZEI7ChNjb20uZ29vZ2xlLnByb3RvYnVmSAKqAiFHb29n", - "bGUuUHJvdG9jb2xCdWZmZXJzLlRlc3RQcm90b3M=")); - pbd::FileDescriptor.InternalDescriptorAssigner assigner = delegate(pbd::FileDescriptor root) { - descriptor = root; - internal__static_protobuf_unittest_extra_TestInteropPerson__Descriptor = Descriptor.MessageTypes[0]; - internal__static_protobuf_unittest_extra_TestInteropPerson__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_extra_TestInteropPerson__Descriptor, - new string[] { "Name", "Id", "Email", "Codes", "Phone", "Addresses", }); - internal__static_protobuf_unittest_extra_TestInteropPerson_PhoneNumber__Descriptor = internal__static_protobuf_unittest_extra_TestInteropPerson__Descriptor.NestedTypes[0]; - internal__static_protobuf_unittest_extra_TestInteropPerson_PhoneNumber__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_extra_TestInteropPerson_PhoneNumber__Descriptor, - new string[] { "Number", "Type", }); - internal__static_protobuf_unittest_extra_TestInteropPerson_Addresses__Descriptor = internal__static_protobuf_unittest_extra_TestInteropPerson__Descriptor.NestedTypes[1]; - internal__static_protobuf_unittest_extra_TestInteropPerson_Addresses__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_extra_TestInteropPerson_Addresses__Descriptor, - new string[] { "Address", "Address2", "City", "State", "Zip", }); - internal__static_protobuf_unittest_extra_TestInteropEmployeeId__Descriptor = Descriptor.MessageTypes[1]; - internal__static_protobuf_unittest_extra_TestInteropEmployeeId__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_extra_TestInteropEmployeeId__Descriptor, - new string[] { "Number", }); - internal__static_protobuf_unittest_extra_TestMissingFieldsA__Descriptor = Descriptor.MessageTypes[2]; - internal__static_protobuf_unittest_extra_TestMissingFieldsA__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_extra_TestMissingFieldsA__Descriptor, - new string[] { "Name", "Id", "Email", "TestA", }); - internal__static_protobuf_unittest_extra_TestMissingFieldsA_SubA__Descriptor = internal__static_protobuf_unittest_extra_TestMissingFieldsA__Descriptor.NestedTypes[0]; - internal__static_protobuf_unittest_extra_TestMissingFieldsA_SubA__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_extra_TestMissingFieldsA_SubA__Descriptor, - new string[] { "Count", "Values", }); - internal__static_protobuf_unittest_extra_TestMissingFieldsB__Descriptor = Descriptor.MessageTypes[3]; - internal__static_protobuf_unittest_extra_TestMissingFieldsB__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_extra_TestMissingFieldsB__Descriptor, - new string[] { "Name", "Id", "Website", "TestB", }); - internal__static_protobuf_unittest_extra_TestMissingFieldsB_SubB__Descriptor = internal__static_protobuf_unittest_extra_TestMissingFieldsB__Descriptor.NestedTypes[0]; - internal__static_protobuf_unittest_extra_TestMissingFieldsB_SubB__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_extra_TestMissingFieldsB_SubB__Descriptor, - new string[] { "Values", }); - global::Google.ProtocolBuffers.TestProtos.UnittestExtrasFull.EmployeeId = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.UnittestExtrasFull.Descriptor.Extensions[0]); - pb::ExtensionRegistry registry = pb::ExtensionRegistry.CreateInstance(); - RegisterAllExtensions(registry); - return registry; - }; - pbd::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, - new pbd::FileDescriptor[] { - }, assigner); - } - #endregion - - } - #region Messages - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestInteropPerson : pb::ExtendableMessage { - private TestInteropPerson() { } - private static readonly TestInteropPerson defaultInstance = new TestInteropPerson().MakeReadOnly(); - public static TestInteropPerson DefaultInstance { - get { return defaultInstance; } - } - - public override TestInteropPerson DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestInteropPerson ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.UnittestExtrasFull.internal__static_protobuf_unittest_extra_TestInteropPerson__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.UnittestExtrasFull.internal__static_protobuf_unittest_extra_TestInteropPerson__FieldAccessorTable; } - } - - #region Nested types - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class Types { - public enum PhoneType { - MOBILE = 0, - HOME = 1, - WORK = 2, - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class PhoneNumber : pb::GeneratedMessage { - private PhoneNumber() { } - private static readonly PhoneNumber defaultInstance = new PhoneNumber().MakeReadOnly(); - public static PhoneNumber DefaultInstance { - get { return defaultInstance; } - } - - public override PhoneNumber DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override PhoneNumber ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.UnittestExtrasFull.internal__static_protobuf_unittest_extra_TestInteropPerson_PhoneNumber__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.UnittestExtrasFull.internal__static_protobuf_unittest_extra_TestInteropPerson_PhoneNumber__FieldAccessorTable; } - } - - public const int NumberFieldNumber = 1; - private bool hasNumber; - private string number_ = ""; - public bool HasNumber { - get { return hasNumber; } - } - public string Number { - get { return number_; } - } - - public const int TypeFieldNumber = 2; - private bool hasType; - private global::Google.ProtocolBuffers.TestProtos.TestInteropPerson.Types.PhoneType type_ = global::Google.ProtocolBuffers.TestProtos.TestInteropPerson.Types.PhoneType.HOME; - public bool HasType { - get { return hasType; } - } - public global::Google.ProtocolBuffers.TestProtos.TestInteropPerson.Types.PhoneType Type { - get { return type_; } - } - - public static PhoneNumber ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static PhoneNumber ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static PhoneNumber ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static PhoneNumber ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static PhoneNumber ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static PhoneNumber ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static PhoneNumber ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static PhoneNumber ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static PhoneNumber ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static PhoneNumber ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private PhoneNumber MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(PhoneNumber prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(PhoneNumber cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private PhoneNumber result; - - private PhoneNumber PrepareBuilder() { - if (resultIsReadOnly) { - PhoneNumber original = result; - result = new PhoneNumber(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override PhoneNumber MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestInteropPerson.Types.PhoneNumber.Descriptor; } - } - - public override PhoneNumber DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestInteropPerson.Types.PhoneNumber.DefaultInstance; } - } - - public override PhoneNumber BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - - public bool HasNumber { - get { return result.hasNumber; } - } - public string Number { - get { return result.Number; } - set { SetNumber(value); } - } - public Builder SetNumber(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasNumber = true; - result.number_ = value; - return this; - } - public Builder ClearNumber() { - PrepareBuilder(); - result.hasNumber = false; - result.number_ = ""; - return this; - } - - public bool HasType { - get { return result.hasType; } - } - public global::Google.ProtocolBuffers.TestProtos.TestInteropPerson.Types.PhoneType Type { - get { return result.Type; } - set { SetType(value); } - } - public Builder SetType(global::Google.ProtocolBuffers.TestProtos.TestInteropPerson.Types.PhoneType value) { - PrepareBuilder(); - result.hasType = true; - result.type_ = value; - return this; - } - public Builder ClearType() { - PrepareBuilder(); - result.hasType = false; - result.type_ = global::Google.ProtocolBuffers.TestProtos.TestInteropPerson.Types.PhoneType.HOME; - return this; - } - } - static PhoneNumber() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.UnittestExtrasFull.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Addresses : pb::GeneratedMessage { - private Addresses() { } - private static readonly Addresses defaultInstance = new Addresses().MakeReadOnly(); - public static Addresses DefaultInstance { - get { return defaultInstance; } - } - - public override Addresses DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override Addresses ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.UnittestExtrasFull.internal__static_protobuf_unittest_extra_TestInteropPerson_Addresses__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.UnittestExtrasFull.internal__static_protobuf_unittest_extra_TestInteropPerson_Addresses__FieldAccessorTable; } - } - - public const int AddressFieldNumber = 1; - private bool hasAddress; - private string address_ = ""; - public bool HasAddress { - get { return hasAddress; } - } - public string Address { - get { return address_; } - } - - public const int Address2FieldNumber = 2; - private bool hasAddress2; - private string address2_ = ""; - public bool HasAddress2 { - get { return hasAddress2; } - } - public string Address2 { - get { return address2_; } - } - - public const int CityFieldNumber = 3; - private bool hasCity; - private string city_ = ""; - public bool HasCity { - get { return hasCity; } - } - public string City { - get { return city_; } - } - - public const int StateFieldNumber = 4; - private bool hasState; - private string state_ = ""; - public bool HasState { - get { return hasState; } - } - public string State { - get { return state_; } - } - - public const int ZipFieldNumber = 5; - private bool hasZip; - private uint zip_; - public bool HasZip { - get { return hasZip; } - } - public uint Zip { - get { return zip_; } - } - - public static Addresses ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static Addresses ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static Addresses ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static Addresses ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static Addresses ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static Addresses ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static Addresses ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static Addresses ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static Addresses ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static Addresses ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private Addresses MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(Addresses prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(Addresses cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private Addresses result; - - private Addresses PrepareBuilder() { - if (resultIsReadOnly) { - Addresses original = result; - result = new Addresses(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override Addresses MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestInteropPerson.Types.Addresses.Descriptor; } - } - - public override Addresses DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestInteropPerson.Types.Addresses.DefaultInstance; } - } - - public override Addresses BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - - public bool HasAddress { - get { return result.hasAddress; } - } - public string Address { - get { return result.Address; } - set { SetAddress(value); } - } - public Builder SetAddress(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasAddress = true; - result.address_ = value; - return this; - } - public Builder ClearAddress() { - PrepareBuilder(); - result.hasAddress = false; - result.address_ = ""; - return this; - } - - public bool HasAddress2 { - get { return result.hasAddress2; } - } - public string Address2 { - get { return result.Address2; } - set { SetAddress2(value); } - } - public Builder SetAddress2(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasAddress2 = true; - result.address2_ = value; - return this; - } - public Builder ClearAddress2() { - PrepareBuilder(); - result.hasAddress2 = false; - result.address2_ = ""; - return this; - } - - public bool HasCity { - get { return result.hasCity; } - } - public string City { - get { return result.City; } - set { SetCity(value); } - } - public Builder SetCity(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasCity = true; - result.city_ = value; - return this; - } - public Builder ClearCity() { - PrepareBuilder(); - result.hasCity = false; - result.city_ = ""; - return this; - } - - public bool HasState { - get { return result.hasState; } - } - public string State { - get { return result.State; } - set { SetState(value); } - } - public Builder SetState(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasState = true; - result.state_ = value; - return this; - } - public Builder ClearState() { - PrepareBuilder(); - result.hasState = false; - result.state_ = ""; - return this; - } - - public bool HasZip { - get { return result.hasZip; } - } - public uint Zip { - get { return result.Zip; } - set { SetZip(value); } - } - public Builder SetZip(uint value) { - PrepareBuilder(); - result.hasZip = true; - result.zip_ = value; - return this; - } - public Builder ClearZip() { - PrepareBuilder(); - result.hasZip = false; - result.zip_ = 0; - return this; - } - } - static Addresses() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.UnittestExtrasFull.Descriptor, null); - } - } - - } - #endregion - - public const int NameFieldNumber = 1; - private bool hasName; - private string name_ = ""; - public bool HasName { - get { return hasName; } - } - public string Name { - get { return name_; } - } - - public const int IdFieldNumber = 2; - private bool hasId; - private int id_; - public bool HasId { - get { return hasId; } - } - public int Id { - get { return id_; } - } - - public const int EmailFieldNumber = 3; - private bool hasEmail; - private string email_ = ""; - public bool HasEmail { - get { return hasEmail; } - } - public string Email { - get { return email_; } - } - - public const int CodesFieldNumber = 10; - private pbc::PopsicleList codes_ = new pbc::PopsicleList(); - public scg::IList CodesList { - get { return pbc::Lists.AsReadOnly(codes_); } - } - public int CodesCount { - get { return codes_.Count; } - } - public int GetCodes(int index) { - return codes_[index]; - } - - public const int PhoneFieldNumber = 4; - private pbc::PopsicleList phone_ = new pbc::PopsicleList(); - public scg::IList PhoneList { - get { return phone_; } - } - public int PhoneCount { - get { return phone_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestInteropPerson.Types.PhoneNumber GetPhone(int index) { - return phone_[index]; - } - - public const int AddressesFieldNumber = 5; - private pbc::PopsicleList addresses_ = new pbc::PopsicleList(); - public scg::IList AddressesList { - get { return addresses_; } - } - public int AddressesCount { - get { return addresses_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestInteropPerson.Types.Addresses GetAddresses(int index) { - return addresses_[index]; - } - - public static TestInteropPerson ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestInteropPerson ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestInteropPerson ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestInteropPerson ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestInteropPerson ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestInteropPerson ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestInteropPerson ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestInteropPerson ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestInteropPerson ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestInteropPerson ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestInteropPerson MakeReadOnly() { - codes_.MakeReadOnly(); - phone_.MakeReadOnly(); - addresses_.MakeReadOnly(); - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestInteropPerson prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::ExtendableBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestInteropPerson cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestInteropPerson result; - - private TestInteropPerson PrepareBuilder() { - if (resultIsReadOnly) { - TestInteropPerson original = result; - result = new TestInteropPerson(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestInteropPerson MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestInteropPerson.Descriptor; } - } - - public override TestInteropPerson DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestInteropPerson.DefaultInstance; } - } - - public override TestInteropPerson BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - - public bool HasName { - get { return result.hasName; } - } - public string Name { - get { return result.Name; } - set { SetName(value); } - } - public Builder SetName(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasName = true; - result.name_ = value; - return this; - } - public Builder ClearName() { - PrepareBuilder(); - result.hasName = false; - result.name_ = ""; - return this; - } - - public bool HasId { - get { return result.hasId; } - } - public int Id { - get { return result.Id; } - set { SetId(value); } - } - public Builder SetId(int value) { - PrepareBuilder(); - result.hasId = true; - result.id_ = value; - return this; - } - public Builder ClearId() { - PrepareBuilder(); - result.hasId = false; - result.id_ = 0; - return this; - } - - public bool HasEmail { - get { return result.hasEmail; } - } - public string Email { - get { return result.Email; } - set { SetEmail(value); } - } - public Builder SetEmail(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasEmail = true; - result.email_ = value; - return this; - } - public Builder ClearEmail() { - PrepareBuilder(); - result.hasEmail = false; - result.email_ = ""; - return this; - } - - public pbc::IPopsicleList CodesList { - get { return PrepareBuilder().codes_; } - } - public int CodesCount { - get { return result.CodesCount; } - } - public int GetCodes(int index) { - return result.GetCodes(index); - } - public Builder SetCodes(int index, int value) { - PrepareBuilder(); - result.codes_[index] = value; - return this; - } - public Builder AddCodes(int value) { - PrepareBuilder(); - result.codes_.Add(value); - return this; - } - public Builder AddRangeCodes(scg::IEnumerable values) { - PrepareBuilder(); - result.codes_.Add(values); - return this; - } - public Builder ClearCodes() { - PrepareBuilder(); - result.codes_.Clear(); - return this; - } - - public pbc::IPopsicleList PhoneList { - get { return PrepareBuilder().phone_; } - } - public int PhoneCount { - get { return result.PhoneCount; } - } - public global::Google.ProtocolBuffers.TestProtos.TestInteropPerson.Types.PhoneNumber GetPhone(int index) { - return result.GetPhone(index); - } - public Builder SetPhone(int index, global::Google.ProtocolBuffers.TestProtos.TestInteropPerson.Types.PhoneNumber value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.phone_[index] = value; - return this; - } - public Builder SetPhone(int index, global::Google.ProtocolBuffers.TestProtos.TestInteropPerson.Types.PhoneNumber.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.phone_[index] = builderForValue.Build(); - return this; - } - public Builder AddPhone(global::Google.ProtocolBuffers.TestProtos.TestInteropPerson.Types.PhoneNumber value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.phone_.Add(value); - return this; - } - public Builder AddPhone(global::Google.ProtocolBuffers.TestProtos.TestInteropPerson.Types.PhoneNumber.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.phone_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangePhone(scg::IEnumerable values) { - PrepareBuilder(); - result.phone_.Add(values); - return this; - } - public Builder ClearPhone() { - PrepareBuilder(); - result.phone_.Clear(); - return this; - } - - public pbc::IPopsicleList AddressesList { - get { return PrepareBuilder().addresses_; } - } - public int AddressesCount { - get { return result.AddressesCount; } - } - public global::Google.ProtocolBuffers.TestProtos.TestInteropPerson.Types.Addresses GetAddresses(int index) { - return result.GetAddresses(index); - } - public Builder SetAddresses(int index, global::Google.ProtocolBuffers.TestProtos.TestInteropPerson.Types.Addresses value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.addresses_[index] = value; - return this; - } - public Builder SetAddresses(int index, global::Google.ProtocolBuffers.TestProtos.TestInteropPerson.Types.Addresses.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.addresses_[index] = builderForValue.Build(); - return this; - } - public Builder AddAddresses(global::Google.ProtocolBuffers.TestProtos.TestInteropPerson.Types.Addresses value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.addresses_.Add(value); - return this; - } - public Builder AddAddresses(global::Google.ProtocolBuffers.TestProtos.TestInteropPerson.Types.Addresses.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.addresses_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeAddresses(scg::IEnumerable values) { - PrepareBuilder(); - result.addresses_.Add(values); - return this; - } - public Builder ClearAddresses() { - PrepareBuilder(); - result.addresses_.Clear(); - return this; - } - } - static TestInteropPerson() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.UnittestExtrasFull.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestInteropEmployeeId : pb::GeneratedMessage { - private TestInteropEmployeeId() { } - private static readonly TestInteropEmployeeId defaultInstance = new TestInteropEmployeeId().MakeReadOnly(); - public static TestInteropEmployeeId DefaultInstance { - get { return defaultInstance; } - } - - public override TestInteropEmployeeId DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestInteropEmployeeId ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.UnittestExtrasFull.internal__static_protobuf_unittest_extra_TestInteropEmployeeId__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.UnittestExtrasFull.internal__static_protobuf_unittest_extra_TestInteropEmployeeId__FieldAccessorTable; } - } - - public const int NumberFieldNumber = 1; - private bool hasNumber; - private string number_ = ""; - public bool HasNumber { - get { return hasNumber; } - } - public string Number { - get { return number_; } - } - - public static TestInteropEmployeeId ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestInteropEmployeeId ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestInteropEmployeeId ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestInteropEmployeeId ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestInteropEmployeeId ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestInteropEmployeeId ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestInteropEmployeeId ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestInteropEmployeeId ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestInteropEmployeeId ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestInteropEmployeeId ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestInteropEmployeeId MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestInteropEmployeeId prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestInteropEmployeeId cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestInteropEmployeeId result; - - private TestInteropEmployeeId PrepareBuilder() { - if (resultIsReadOnly) { - TestInteropEmployeeId original = result; - result = new TestInteropEmployeeId(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestInteropEmployeeId MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestInteropEmployeeId.Descriptor; } - } - - public override TestInteropEmployeeId DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestInteropEmployeeId.DefaultInstance; } - } - - public override TestInteropEmployeeId BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - - public bool HasNumber { - get { return result.hasNumber; } - } - public string Number { - get { return result.Number; } - set { SetNumber(value); } - } - public Builder SetNumber(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasNumber = true; - result.number_ = value; - return this; - } - public Builder ClearNumber() { - PrepareBuilder(); - result.hasNumber = false; - result.number_ = ""; - return this; - } - } - static TestInteropEmployeeId() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.UnittestExtrasFull.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestMissingFieldsA : pb::GeneratedMessage { - private TestMissingFieldsA() { } - private static readonly TestMissingFieldsA defaultInstance = new TestMissingFieldsA().MakeReadOnly(); - public static TestMissingFieldsA DefaultInstance { - get { return defaultInstance; } - } - - public override TestMissingFieldsA DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestMissingFieldsA ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.UnittestExtrasFull.internal__static_protobuf_unittest_extra_TestMissingFieldsA__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.UnittestExtrasFull.internal__static_protobuf_unittest_extra_TestMissingFieldsA__FieldAccessorTable; } - } - - #region Nested types - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class Types { - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class SubA : pb::GeneratedMessage { - private SubA() { } - private static readonly SubA defaultInstance = new SubA().MakeReadOnly(); - public static SubA DefaultInstance { - get { return defaultInstance; } - } - - public override SubA DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override SubA ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.UnittestExtrasFull.internal__static_protobuf_unittest_extra_TestMissingFieldsA_SubA__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.UnittestExtrasFull.internal__static_protobuf_unittest_extra_TestMissingFieldsA_SubA__FieldAccessorTable; } - } - - public const int CountFieldNumber = 5; - private bool hasCount; - private int count_; - public bool HasCount { - get { return hasCount; } - } - public int Count { - get { return count_; } - } - - public const int ValuesFieldNumber = 6; - private pbc::PopsicleList values_ = new pbc::PopsicleList(); - public scg::IList ValuesList { - get { return pbc::Lists.AsReadOnly(values_); } - } - public int ValuesCount { - get { return values_.Count; } - } - public string GetValues(int index) { - return values_[index]; - } - - public static SubA ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static SubA ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static SubA ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static SubA ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static SubA ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static SubA ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static SubA ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static SubA ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static SubA ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static SubA ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private SubA MakeReadOnly() { - values_.MakeReadOnly(); - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(SubA prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(SubA cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private SubA result; - - private SubA PrepareBuilder() { - if (resultIsReadOnly) { - SubA original = result; - result = new SubA(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override SubA MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestMissingFieldsA.Types.SubA.Descriptor; } - } - - public override SubA DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestMissingFieldsA.Types.SubA.DefaultInstance; } - } - - public override SubA BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - - public bool HasCount { - get { return result.hasCount; } - } - public int Count { - get { return result.Count; } - set { SetCount(value); } - } - public Builder SetCount(int value) { - PrepareBuilder(); - result.hasCount = true; - result.count_ = value; - return this; - } - public Builder ClearCount() { - PrepareBuilder(); - result.hasCount = false; - result.count_ = 0; - return this; - } - - public pbc::IPopsicleList ValuesList { - get { return PrepareBuilder().values_; } - } - public int ValuesCount { - get { return result.ValuesCount; } - } - public string GetValues(int index) { - return result.GetValues(index); - } - public Builder SetValues(int index, string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.values_[index] = value; - return this; - } - public Builder AddValues(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.values_.Add(value); - return this; - } - public Builder AddRangeValues(scg::IEnumerable values) { - PrepareBuilder(); - result.values_.Add(values); - return this; - } - public Builder ClearValues() { - PrepareBuilder(); - result.values_.Clear(); - return this; - } - } - static SubA() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.UnittestExtrasFull.Descriptor, null); - } - } - - } - #endregion - - public const int NameFieldNumber = 1; - private bool hasName; - private string name_ = ""; - public bool HasName { - get { return hasName; } - } - public string Name { - get { return name_; } - } - - public const int IdFieldNumber = 2; - private bool hasId; - private int id_; - public bool HasId { - get { return hasId; } - } - public int Id { - get { return id_; } - } - - public const int EmailFieldNumber = 3; - private bool hasEmail; - private string email_ = ""; - public bool HasEmail { - get { return hasEmail; } - } - public string Email { - get { return email_; } - } - - public const int TestAFieldNumber = 11; - private bool hasTestA; - private global::Google.ProtocolBuffers.TestProtos.TestMissingFieldsA.Types.SubA testA_; - public bool HasTestA { - get { return hasTestA; } - } - public global::Google.ProtocolBuffers.TestProtos.TestMissingFieldsA.Types.SubA TestA { - get { return testA_ ?? global::Google.ProtocolBuffers.TestProtos.TestMissingFieldsA.Types.SubA.DefaultInstance; } - } - - public static TestMissingFieldsA ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestMissingFieldsA ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestMissingFieldsA ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestMissingFieldsA ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestMissingFieldsA ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestMissingFieldsA ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestMissingFieldsA ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestMissingFieldsA ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestMissingFieldsA ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestMissingFieldsA ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestMissingFieldsA MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestMissingFieldsA prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestMissingFieldsA cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestMissingFieldsA result; - - private TestMissingFieldsA PrepareBuilder() { - if (resultIsReadOnly) { - TestMissingFieldsA original = result; - result = new TestMissingFieldsA(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestMissingFieldsA MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestMissingFieldsA.Descriptor; } - } - - public override TestMissingFieldsA DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestMissingFieldsA.DefaultInstance; } - } - - public override TestMissingFieldsA BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - - public bool HasName { - get { return result.hasName; } - } - public string Name { - get { return result.Name; } - set { SetName(value); } - } - public Builder SetName(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasName = true; - result.name_ = value; - return this; - } - public Builder ClearName() { - PrepareBuilder(); - result.hasName = false; - result.name_ = ""; - return this; - } - - public bool HasId { - get { return result.hasId; } - } - public int Id { - get { return result.Id; } - set { SetId(value); } - } - public Builder SetId(int value) { - PrepareBuilder(); - result.hasId = true; - result.id_ = value; - return this; - } - public Builder ClearId() { - PrepareBuilder(); - result.hasId = false; - result.id_ = 0; - return this; - } - - public bool HasEmail { - get { return result.hasEmail; } - } - public string Email { - get { return result.Email; } - set { SetEmail(value); } - } - public Builder SetEmail(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasEmail = true; - result.email_ = value; - return this; - } - public Builder ClearEmail() { - PrepareBuilder(); - result.hasEmail = false; - result.email_ = ""; - return this; - } - - public bool HasTestA { - get { return result.hasTestA; } - } - public global::Google.ProtocolBuffers.TestProtos.TestMissingFieldsA.Types.SubA TestA { - get { return result.TestA; } - set { SetTestA(value); } - } - public Builder SetTestA(global::Google.ProtocolBuffers.TestProtos.TestMissingFieldsA.Types.SubA value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasTestA = true; - result.testA_ = value; - return this; - } - public Builder SetTestA(global::Google.ProtocolBuffers.TestProtos.TestMissingFieldsA.Types.SubA.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasTestA = true; - result.testA_ = builderForValue.Build(); - return this; - } - public Builder MergeTestA(global::Google.ProtocolBuffers.TestProtos.TestMissingFieldsA.Types.SubA value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasTestA && - result.testA_ != global::Google.ProtocolBuffers.TestProtos.TestMissingFieldsA.Types.SubA.DefaultInstance) { - result.testA_ = global::Google.ProtocolBuffers.TestProtos.TestMissingFieldsA.Types.SubA.CreateBuilder(result.testA_).MergeFrom(value).BuildPartial(); - } else { - result.testA_ = value; - } - result.hasTestA = true; - return this; - } - public Builder ClearTestA() { - PrepareBuilder(); - result.hasTestA = false; - result.testA_ = null; - return this; - } - } - static TestMissingFieldsA() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.UnittestExtrasFull.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestMissingFieldsB : pb::GeneratedMessage { - private TestMissingFieldsB() { } - private static readonly TestMissingFieldsB defaultInstance = new TestMissingFieldsB().MakeReadOnly(); - public static TestMissingFieldsB DefaultInstance { - get { return defaultInstance; } - } - - public override TestMissingFieldsB DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestMissingFieldsB ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.UnittestExtrasFull.internal__static_protobuf_unittest_extra_TestMissingFieldsB__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.UnittestExtrasFull.internal__static_protobuf_unittest_extra_TestMissingFieldsB__FieldAccessorTable; } - } - - #region Nested types - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class Types { - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class SubB : pb::GeneratedMessage { - private SubB() { } - private static readonly SubB defaultInstance = new SubB().MakeReadOnly(); - public static SubB DefaultInstance { - get { return defaultInstance; } - } - - public override SubB DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override SubB ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.UnittestExtrasFull.internal__static_protobuf_unittest_extra_TestMissingFieldsB_SubB__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.UnittestExtrasFull.internal__static_protobuf_unittest_extra_TestMissingFieldsB_SubB__FieldAccessorTable; } - } - - public const int ValuesFieldNumber = 7; - private pbc::PopsicleList values_ = new pbc::PopsicleList(); - public scg::IList ValuesList { - get { return pbc::Lists.AsReadOnly(values_); } - } - public int ValuesCount { - get { return values_.Count; } - } - public string GetValues(int index) { - return values_[index]; - } - - public static SubB ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static SubB ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static SubB ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static SubB ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static SubB ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static SubB ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static SubB ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static SubB ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static SubB ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static SubB ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private SubB MakeReadOnly() { - values_.MakeReadOnly(); - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(SubB prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(SubB cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private SubB result; - - private SubB PrepareBuilder() { - if (resultIsReadOnly) { - SubB original = result; - result = new SubB(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override SubB MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestMissingFieldsB.Types.SubB.Descriptor; } - } - - public override SubB DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestMissingFieldsB.Types.SubB.DefaultInstance; } - } - - public override SubB BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - - public pbc::IPopsicleList ValuesList { - get { return PrepareBuilder().values_; } - } - public int ValuesCount { - get { return result.ValuesCount; } - } - public string GetValues(int index) { - return result.GetValues(index); - } - public Builder SetValues(int index, string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.values_[index] = value; - return this; - } - public Builder AddValues(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.values_.Add(value); - return this; - } - public Builder AddRangeValues(scg::IEnumerable values) { - PrepareBuilder(); - result.values_.Add(values); - return this; - } - public Builder ClearValues() { - PrepareBuilder(); - result.values_.Clear(); - return this; - } - } - static SubB() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.UnittestExtrasFull.Descriptor, null); - } - } - - } - #endregion - - public const int NameFieldNumber = 1; - private bool hasName; - private string name_ = ""; - public bool HasName { - get { return hasName; } - } - public string Name { - get { return name_; } - } - - public const int IdFieldNumber = 2; - private bool hasId; - private int id_; - public bool HasId { - get { return hasId; } - } - public int Id { - get { return id_; } - } - - public const int WebsiteFieldNumber = 4; - private bool hasWebsite; - private string website_ = ""; - public bool HasWebsite { - get { return hasWebsite; } - } - public string Website { - get { return website_; } - } - - public const int TestBFieldNumber = 12; - private bool hasTestB; - private global::Google.ProtocolBuffers.TestProtos.TestMissingFieldsB.Types.SubB testB_; - public bool HasTestB { - get { return hasTestB; } - } - public global::Google.ProtocolBuffers.TestProtos.TestMissingFieldsB.Types.SubB TestB { - get { return testB_ ?? global::Google.ProtocolBuffers.TestProtos.TestMissingFieldsB.Types.SubB.DefaultInstance; } - } - - public static TestMissingFieldsB ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestMissingFieldsB ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestMissingFieldsB ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestMissingFieldsB ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestMissingFieldsB ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestMissingFieldsB ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestMissingFieldsB ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestMissingFieldsB ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestMissingFieldsB ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestMissingFieldsB ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestMissingFieldsB MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestMissingFieldsB prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestMissingFieldsB cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestMissingFieldsB result; - - private TestMissingFieldsB PrepareBuilder() { - if (resultIsReadOnly) { - TestMissingFieldsB original = result; - result = new TestMissingFieldsB(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestMissingFieldsB MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestMissingFieldsB.Descriptor; } - } - - public override TestMissingFieldsB DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestMissingFieldsB.DefaultInstance; } - } - - public override TestMissingFieldsB BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - - public bool HasName { - get { return result.hasName; } - } - public string Name { - get { return result.Name; } - set { SetName(value); } - } - public Builder SetName(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasName = true; - result.name_ = value; - return this; - } - public Builder ClearName() { - PrepareBuilder(); - result.hasName = false; - result.name_ = ""; - return this; - } - - public bool HasId { - get { return result.hasId; } - } - public int Id { - get { return result.Id; } - set { SetId(value); } - } - public Builder SetId(int value) { - PrepareBuilder(); - result.hasId = true; - result.id_ = value; - return this; - } - public Builder ClearId() { - PrepareBuilder(); - result.hasId = false; - result.id_ = 0; - return this; - } - - public bool HasWebsite { - get { return result.hasWebsite; } - } - public string Website { - get { return result.Website; } - set { SetWebsite(value); } - } - public Builder SetWebsite(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasWebsite = true; - result.website_ = value; - return this; - } - public Builder ClearWebsite() { - PrepareBuilder(); - result.hasWebsite = false; - result.website_ = ""; - return this; - } - - public bool HasTestB { - get { return result.hasTestB; } - } - public global::Google.ProtocolBuffers.TestProtos.TestMissingFieldsB.Types.SubB TestB { - get { return result.TestB; } - set { SetTestB(value); } - } - public Builder SetTestB(global::Google.ProtocolBuffers.TestProtos.TestMissingFieldsB.Types.SubB value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasTestB = true; - result.testB_ = value; - return this; - } - public Builder SetTestB(global::Google.ProtocolBuffers.TestProtos.TestMissingFieldsB.Types.SubB.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasTestB = true; - result.testB_ = builderForValue.Build(); - return this; - } - public Builder MergeTestB(global::Google.ProtocolBuffers.TestProtos.TestMissingFieldsB.Types.SubB value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasTestB && - result.testB_ != global::Google.ProtocolBuffers.TestProtos.TestMissingFieldsB.Types.SubB.DefaultInstance) { - result.testB_ = global::Google.ProtocolBuffers.TestProtos.TestMissingFieldsB.Types.SubB.CreateBuilder(result.testB_).MergeFrom(value).BuildPartial(); - } else { - result.testB_ = value; - } - result.hasTestB = true; - return this; - } - public Builder ClearTestB() { - PrepareBuilder(); - result.hasTestB = false; - result.testB_ = null; - return this; - } - } - static TestMissingFieldsB() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.UnittestExtrasFull.Descriptor, null); - } - } - - #endregion - -} - -#endregion Designer generated code diff --git a/csharp/src/ProtocolBuffersLite.Test/TestProtos/UnittestExtrasLite.cs b/csharp/src/ProtocolBuffersLite.Test/TestProtos/UnittestExtrasLite.cs deleted file mode 100644 index ceb9e861..00000000 --- a/csharp/src/ProtocolBuffersLite.Test/TestProtos/UnittestExtrasLite.cs +++ /dev/null @@ -1,4206 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: unittest_extras_lite.proto -#pragma warning disable 1591, 0612, 3021 -#region Designer generated code - -using pb = global::Google.ProtocolBuffers; -using pbc = global::Google.ProtocolBuffers.Collections; -using pbd = global::Google.ProtocolBuffers.Descriptors; -using scg = global::System.Collections.Generic; -namespace Google.ProtocolBuffers.TestProtos { - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class UnittestExtrasLite { - - #region Extension registration - public static void RegisterAllExtensions(pb::ExtensionRegistry registry) { - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.EmployeeIdLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.UnpackedInt32ExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.UnpackedInt64ExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.UnpackedUint32ExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.UnpackedUint64ExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.UnpackedSint32ExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.UnpackedSint64ExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.UnpackedFixed32ExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.UnpackedFixed64ExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.UnpackedSfixed32ExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.UnpackedSfixed64ExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.UnpackedFloatExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.UnpackedDoubleExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.UnpackedBoolExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.UnpackedEnumExtensionLite); - } - #endregion - #region Extensions - public const int EmployeeIdLiteFieldNumber = 126; - public static pb::GeneratedExtensionLite EmployeeIdLite; - public const int UnpackedInt32ExtensionLiteFieldNumber = 90; - public static pb::GeneratedRepeatExtensionLite UnpackedInt32ExtensionLite; - public const int UnpackedInt64ExtensionLiteFieldNumber = 91; - public static pb::GeneratedRepeatExtensionLite UnpackedInt64ExtensionLite; - public const int UnpackedUint32ExtensionLiteFieldNumber = 92; - public static pb::GeneratedRepeatExtensionLite UnpackedUint32ExtensionLite; - public const int UnpackedUint64ExtensionLiteFieldNumber = 93; - public static pb::GeneratedRepeatExtensionLite UnpackedUint64ExtensionLite; - public const int UnpackedSint32ExtensionLiteFieldNumber = 94; - public static pb::GeneratedRepeatExtensionLite UnpackedSint32ExtensionLite; - public const int UnpackedSint64ExtensionLiteFieldNumber = 95; - public static pb::GeneratedRepeatExtensionLite UnpackedSint64ExtensionLite; - public const int UnpackedFixed32ExtensionLiteFieldNumber = 96; - public static pb::GeneratedRepeatExtensionLite UnpackedFixed32ExtensionLite; - public const int UnpackedFixed64ExtensionLiteFieldNumber = 97; - public static pb::GeneratedRepeatExtensionLite UnpackedFixed64ExtensionLite; - public const int UnpackedSfixed32ExtensionLiteFieldNumber = 98; - public static pb::GeneratedRepeatExtensionLite UnpackedSfixed32ExtensionLite; - public const int UnpackedSfixed64ExtensionLiteFieldNumber = 99; - public static pb::GeneratedRepeatExtensionLite UnpackedSfixed64ExtensionLite; - public const int UnpackedFloatExtensionLiteFieldNumber = 100; - public static pb::GeneratedRepeatExtensionLite UnpackedFloatExtensionLite; - public const int UnpackedDoubleExtensionLiteFieldNumber = 101; - public static pb::GeneratedRepeatExtensionLite UnpackedDoubleExtensionLite; - public const int UnpackedBoolExtensionLiteFieldNumber = 102; - public static pb::GeneratedRepeatExtensionLite UnpackedBoolExtensionLite; - public const int UnpackedEnumExtensionLiteFieldNumber = 103; - public static pb::GeneratedRepeatExtensionLite UnpackedEnumExtensionLite; - #endregion - - #region Static variables - #endregion - #region Extensions - internal static readonly object Descriptor; - static UnittestExtrasLite() { - Descriptor = null; - global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.EmployeeIdLite = - new pb::GeneratedExtensionLite( - "protobuf_unittest_extra.employee_id_lite", - global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.DefaultInstance, - null, - global::Google.ProtocolBuffers.TestProtos.TestInteropEmployeeIdLite.DefaultInstance, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.EmployeeIdLiteFieldNumber, - pbd::FieldType.Message); - global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.UnpackedInt32ExtensionLite = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest_extra.unpacked_int32_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestUnpackedExtensionsLite.DefaultInstance, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.UnpackedInt32ExtensionLiteFieldNumber, - pbd::FieldType.Int32, - false); - global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.UnpackedInt64ExtensionLite = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest_extra.unpacked_int64_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestUnpackedExtensionsLite.DefaultInstance, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.UnpackedInt64ExtensionLiteFieldNumber, - pbd::FieldType.Int64, - false); - global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.UnpackedUint32ExtensionLite = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest_extra.unpacked_uint32_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestUnpackedExtensionsLite.DefaultInstance, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.UnpackedUint32ExtensionLiteFieldNumber, - pbd::FieldType.UInt32, - false); - global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.UnpackedUint64ExtensionLite = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest_extra.unpacked_uint64_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestUnpackedExtensionsLite.DefaultInstance, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.UnpackedUint64ExtensionLiteFieldNumber, - pbd::FieldType.UInt64, - false); - global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.UnpackedSint32ExtensionLite = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest_extra.unpacked_sint32_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestUnpackedExtensionsLite.DefaultInstance, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.UnpackedSint32ExtensionLiteFieldNumber, - pbd::FieldType.SInt32, - false); - global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.UnpackedSint64ExtensionLite = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest_extra.unpacked_sint64_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestUnpackedExtensionsLite.DefaultInstance, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.UnpackedSint64ExtensionLiteFieldNumber, - pbd::FieldType.SInt64, - false); - global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.UnpackedFixed32ExtensionLite = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest_extra.unpacked_fixed32_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestUnpackedExtensionsLite.DefaultInstance, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.UnpackedFixed32ExtensionLiteFieldNumber, - pbd::FieldType.Fixed32, - false); - global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.UnpackedFixed64ExtensionLite = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest_extra.unpacked_fixed64_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestUnpackedExtensionsLite.DefaultInstance, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.UnpackedFixed64ExtensionLiteFieldNumber, - pbd::FieldType.Fixed64, - false); - global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.UnpackedSfixed32ExtensionLite = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest_extra.unpacked_sfixed32_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestUnpackedExtensionsLite.DefaultInstance, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.UnpackedSfixed32ExtensionLiteFieldNumber, - pbd::FieldType.SFixed32, - false); - global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.UnpackedSfixed64ExtensionLite = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest_extra.unpacked_sfixed64_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestUnpackedExtensionsLite.DefaultInstance, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.UnpackedSfixed64ExtensionLiteFieldNumber, - pbd::FieldType.SFixed64, - false); - global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.UnpackedFloatExtensionLite = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest_extra.unpacked_float_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestUnpackedExtensionsLite.DefaultInstance, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.UnpackedFloatExtensionLiteFieldNumber, - pbd::FieldType.Float, - false); - global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.UnpackedDoubleExtensionLite = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest_extra.unpacked_double_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestUnpackedExtensionsLite.DefaultInstance, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.UnpackedDoubleExtensionLiteFieldNumber, - pbd::FieldType.Double, - false); - global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.UnpackedBoolExtensionLite = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest_extra.unpacked_bool_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestUnpackedExtensionsLite.DefaultInstance, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.UnpackedBoolExtensionLiteFieldNumber, - pbd::FieldType.Bool, - false); - global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.UnpackedEnumExtensionLite = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest_extra.unpacked_enum_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestUnpackedExtensionsLite.DefaultInstance, - null, - new EnumLiteMap(), - global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.UnpackedEnumExtensionLiteFieldNumber, - pbd::FieldType.Enum, - false); - } - #endregion - - } - #region Enums - public enum ExtraEnum { - DEFAULT = 10, - EXLITE_FOO = 7, - EXLITE_BAR = 8, - EXLITE_BAZ = 9, - } - - public enum UnpackedTypesForeignEnumLite { - FOREIGN_LITE_FOO = 4, - FOREIGN_LITE_BAR = 5, - FOREIGN_LITE_BAZ = 6, - } - - #endregion - - #region Messages - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestRequiredLite : pb::GeneratedMessageLite { - private TestRequiredLite() { } - private static readonly TestRequiredLite defaultInstance = new TestRequiredLite().MakeReadOnly(); - private static readonly string[] _testRequiredLiteFieldNames = new string[] { "d", "en" }; - private static readonly uint[] _testRequiredLiteFieldTags = new uint[] { 8, 16 }; - public static TestRequiredLite DefaultInstance { - get { return defaultInstance; } - } - - public override TestRequiredLite DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestRequiredLite ThisMessage { - get { return this; } - } - - public const int DFieldNumber = 1; - private bool hasD; - private int d_; - public bool HasD { - get { return hasD; } - } - public int D { - get { return d_; } - } - - public const int EnFieldNumber = 2; - private bool hasEn; - private global::Google.ProtocolBuffers.TestProtos.ExtraEnum en_ = global::Google.ProtocolBuffers.TestProtos.ExtraEnum.DEFAULT; - public bool HasEn { - get { return hasEn; } - } - public global::Google.ProtocolBuffers.TestProtos.ExtraEnum En { - get { return en_; } - } - - public override bool IsInitialized { - get { - if (!hasD) return false; - if (!hasEn) return false; - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testRequiredLiteFieldNames; - if (hasD) { - output.WriteInt32(1, field_names[0], D); - } - if (hasEn) { - output.WriteEnum(2, field_names[1], (int) En, En); - } - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasD) { - size += pb::CodedOutputStream.ComputeInt32Size(1, D); - } - if (hasEn) { - size += pb::CodedOutputStream.ComputeEnumSize(2, (int) En); - } - memoizedSerializedSize = size; - return size; - } - #region Lite runtime methods - public override int GetHashCode() { - int hash = GetType().GetHashCode(); - if (hasD) { - hash ^= d_.GetHashCode(); - } - if (hasEn) { - hash ^= en_.GetHashCode(); - } - return hash; - } - - public override bool Equals(object obj) { - TestRequiredLite other = obj as TestRequiredLite; - if (other == null) return false; - if (hasD != other.hasD || (hasD && !d_.Equals(other.d_))) return false; - if (hasEn != other.hasEn || (hasEn && !en_.Equals(other.en_))) return false; - return true; - } - - public override void PrintTo(global::System.IO.TextWriter writer) { - PrintField("d", hasD, d_, writer); - PrintField("en", hasEn, en_, writer); - } - #endregion - - public static TestRequiredLite ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestRequiredLite ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestRequiredLite ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestRequiredLite ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestRequiredLite ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestRequiredLite ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestRequiredLite ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestRequiredLite ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestRequiredLite ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestRequiredLite ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestRequiredLite MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestRequiredLite prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilderLite { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestRequiredLite cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestRequiredLite result; - - private TestRequiredLite PrepareBuilder() { - if (resultIsReadOnly) { - TestRequiredLite original = result; - result = new TestRequiredLite(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestRequiredLite MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override TestRequiredLite DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestRequiredLite.DefaultInstance; } - } - - public override TestRequiredLite BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessageLite other) { - if (other is TestRequiredLite) { - return MergeFrom((TestRequiredLite) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestRequiredLite other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestRequiredLite.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasD) { - D = other.D; - } - if (other.HasEn) { - En = other.En; - } - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testRequiredLiteFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testRequiredLiteFieldTags[field_ordinal]; - else { - ParseUnknownField(input, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - return this; - } - ParseUnknownField(input, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasD = input.ReadInt32(ref result.d_); - break; - } - case 16: { - object unknown; - if(input.ReadEnum(ref result.en_, out unknown)) { - result.hasEn = true; - } else if(unknown is int) { - } - break; - } - } - } - - return this; - } - - - public bool HasD { - get { return result.hasD; } - } - public int D { - get { return result.D; } - set { SetD(value); } - } - public Builder SetD(int value) { - PrepareBuilder(); - result.hasD = true; - result.d_ = value; - return this; - } - public Builder ClearD() { - PrepareBuilder(); - result.hasD = false; - result.d_ = 0; - return this; - } - - public bool HasEn { - get { return result.hasEn; } - } - public global::Google.ProtocolBuffers.TestProtos.ExtraEnum En { - get { return result.En; } - set { SetEn(value); } - } - public Builder SetEn(global::Google.ProtocolBuffers.TestProtos.ExtraEnum value) { - PrepareBuilder(); - result.hasEn = true; - result.en_ = value; - return this; - } - public Builder ClearEn() { - PrepareBuilder(); - result.hasEn = false; - result.en_ = global::Google.ProtocolBuffers.TestProtos.ExtraEnum.DEFAULT; - return this; - } - } - static TestRequiredLite() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestInteropPersonLite : pb::ExtendableMessageLite { - private TestInteropPersonLite() { } - private static readonly TestInteropPersonLite defaultInstance = new TestInteropPersonLite().MakeReadOnly(); - private static readonly string[] _testInteropPersonLiteFieldNames = new string[] { "addresses", "codes", "email", "id", "name", "phone" }; - private static readonly uint[] _testInteropPersonLiteFieldTags = new uint[] { 43, 82, 26, 16, 10, 34 }; - public static TestInteropPersonLite DefaultInstance { - get { return defaultInstance; } - } - - public override TestInteropPersonLite DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestInteropPersonLite ThisMessage { - get { return this; } - } - - #region Nested types - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class Types { - public enum PhoneType { - MOBILE = 0, - HOME = 1, - WORK = 2, - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class PhoneNumber : pb::GeneratedMessageLite { - private PhoneNumber() { } - private static readonly PhoneNumber defaultInstance = new PhoneNumber().MakeReadOnly(); - private static readonly string[] _phoneNumberFieldNames = new string[] { "number", "type" }; - private static readonly uint[] _phoneNumberFieldTags = new uint[] { 10, 16 }; - public static PhoneNumber DefaultInstance { - get { return defaultInstance; } - } - - public override PhoneNumber DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override PhoneNumber ThisMessage { - get { return this; } - } - - public const int NumberFieldNumber = 1; - private bool hasNumber; - private string number_ = ""; - public bool HasNumber { - get { return hasNumber; } - } - public string Number { - get { return number_; } - } - - public const int TypeFieldNumber = 2; - private bool hasType; - private global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.PhoneType type_ = global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.PhoneType.HOME; - public bool HasType { - get { return hasType; } - } - public global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.PhoneType Type { - get { return type_; } - } - - public override bool IsInitialized { - get { - if (!hasNumber) return false; - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _phoneNumberFieldNames; - if (hasNumber) { - output.WriteString(1, field_names[0], Number); - } - if (hasType) { - output.WriteEnum(2, field_names[1], (int) Type, Type); - } - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasNumber) { - size += pb::CodedOutputStream.ComputeStringSize(1, Number); - } - if (hasType) { - size += pb::CodedOutputStream.ComputeEnumSize(2, (int) Type); - } - memoizedSerializedSize = size; - return size; - } - #region Lite runtime methods - public override int GetHashCode() { - int hash = GetType().GetHashCode(); - if (hasNumber) { - hash ^= number_.GetHashCode(); - } - if (hasType) { - hash ^= type_.GetHashCode(); - } - return hash; - } - - public override bool Equals(object obj) { - PhoneNumber other = obj as PhoneNumber; - if (other == null) return false; - if (hasNumber != other.hasNumber || (hasNumber && !number_.Equals(other.number_))) return false; - if (hasType != other.hasType || (hasType && !type_.Equals(other.type_))) return false; - return true; - } - - public override void PrintTo(global::System.IO.TextWriter writer) { - PrintField("number", hasNumber, number_, writer); - PrintField("type", hasType, type_, writer); - } - #endregion - - public static PhoneNumber ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static PhoneNumber ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static PhoneNumber ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static PhoneNumber ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static PhoneNumber ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static PhoneNumber ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static PhoneNumber ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static PhoneNumber ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static PhoneNumber ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static PhoneNumber ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private PhoneNumber MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(PhoneNumber prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilderLite { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(PhoneNumber cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private PhoneNumber result; - - private PhoneNumber PrepareBuilder() { - if (resultIsReadOnly) { - PhoneNumber original = result; - result = new PhoneNumber(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override PhoneNumber MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override PhoneNumber DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.PhoneNumber.DefaultInstance; } - } - - public override PhoneNumber BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessageLite other) { - if (other is PhoneNumber) { - return MergeFrom((PhoneNumber) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(PhoneNumber other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.PhoneNumber.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasNumber) { - Number = other.Number; - } - if (other.HasType) { - Type = other.Type; - } - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_phoneNumberFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _phoneNumberFieldTags[field_ordinal]; - else { - ParseUnknownField(input, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - return this; - } - ParseUnknownField(input, extensionRegistry, tag, field_name); - break; - } - case 10: { - result.hasNumber = input.ReadString(ref result.number_); - break; - } - case 16: { - object unknown; - if(input.ReadEnum(ref result.type_, out unknown)) { - result.hasType = true; - } else if(unknown is int) { - } - break; - } - } - } - - return this; - } - - - public bool HasNumber { - get { return result.hasNumber; } - } - public string Number { - get { return result.Number; } - set { SetNumber(value); } - } - public Builder SetNumber(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasNumber = true; - result.number_ = value; - return this; - } - public Builder ClearNumber() { - PrepareBuilder(); - result.hasNumber = false; - result.number_ = ""; - return this; - } - - public bool HasType { - get { return result.hasType; } - } - public global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.PhoneType Type { - get { return result.Type; } - set { SetType(value); } - } - public Builder SetType(global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.PhoneType value) { - PrepareBuilder(); - result.hasType = true; - result.type_ = value; - return this; - } - public Builder ClearType() { - PrepareBuilder(); - result.hasType = false; - result.type_ = global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.PhoneType.HOME; - return this; - } - } - static PhoneNumber() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Addresses : pb::GeneratedMessageLite { - private Addresses() { } - private static readonly Addresses defaultInstance = new Addresses().MakeReadOnly(); - private static readonly string[] _addressesFieldNames = new string[] { "address", "address2", "city", "state", "zip" }; - private static readonly uint[] _addressesFieldTags = new uint[] { 10, 18, 26, 34, 45 }; - public static Addresses DefaultInstance { - get { return defaultInstance; } - } - - public override Addresses DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override Addresses ThisMessage { - get { return this; } - } - - public const int AddressFieldNumber = 1; - private bool hasAddress; - private string address_ = ""; - public bool HasAddress { - get { return hasAddress; } - } - public string Address { - get { return address_; } - } - - public const int Address2FieldNumber = 2; - private bool hasAddress2; - private string address2_ = ""; - public bool HasAddress2 { - get { return hasAddress2; } - } - public string Address2 { - get { return address2_; } - } - - public const int CityFieldNumber = 3; - private bool hasCity; - private string city_ = ""; - public bool HasCity { - get { return hasCity; } - } - public string City { - get { return city_; } - } - - public const int StateFieldNumber = 4; - private bool hasState; - private string state_ = ""; - public bool HasState { - get { return hasState; } - } - public string State { - get { return state_; } - } - - public const int ZipFieldNumber = 5; - private bool hasZip; - private uint zip_; - public bool HasZip { - get { return hasZip; } - } - public uint Zip { - get { return zip_; } - } - - public override bool IsInitialized { - get { - if (!hasAddress) return false; - if (!hasCity) return false; - if (!hasState) return false; - if (!hasZip) return false; - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _addressesFieldNames; - if (hasAddress) { - output.WriteString(1, field_names[0], Address); - } - if (hasAddress2) { - output.WriteString(2, field_names[1], Address2); - } - if (hasCity) { - output.WriteString(3, field_names[2], City); - } - if (hasState) { - output.WriteString(4, field_names[3], State); - } - if (hasZip) { - output.WriteFixed32(5, field_names[4], Zip); - } - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasAddress) { - size += pb::CodedOutputStream.ComputeStringSize(1, Address); - } - if (hasAddress2) { - size += pb::CodedOutputStream.ComputeStringSize(2, Address2); - } - if (hasCity) { - size += pb::CodedOutputStream.ComputeStringSize(3, City); - } - if (hasState) { - size += pb::CodedOutputStream.ComputeStringSize(4, State); - } - if (hasZip) { - size += pb::CodedOutputStream.ComputeFixed32Size(5, Zip); - } - memoizedSerializedSize = size; - return size; - } - #region Lite runtime methods - public override int GetHashCode() { - int hash = GetType().GetHashCode(); - if (hasAddress) { - hash ^= address_.GetHashCode(); - } - if (hasAddress2) { - hash ^= address2_.GetHashCode(); - } - if (hasCity) { - hash ^= city_.GetHashCode(); - } - if (hasState) { - hash ^= state_.GetHashCode(); - } - if (hasZip) { - hash ^= zip_.GetHashCode(); - } - return hash; - } - - public override bool Equals(object obj) { - Addresses other = obj as Addresses; - if (other == null) return false; - if (hasAddress != other.hasAddress || (hasAddress && !address_.Equals(other.address_))) return false; - if (hasAddress2 != other.hasAddress2 || (hasAddress2 && !address2_.Equals(other.address2_))) return false; - if (hasCity != other.hasCity || (hasCity && !city_.Equals(other.city_))) return false; - if (hasState != other.hasState || (hasState && !state_.Equals(other.state_))) return false; - if (hasZip != other.hasZip || (hasZip && !zip_.Equals(other.zip_))) return false; - return true; - } - - public override void PrintTo(global::System.IO.TextWriter writer) { - PrintField("address", hasAddress, address_, writer); - PrintField("address2", hasAddress2, address2_, writer); - PrintField("city", hasCity, city_, writer); - PrintField("state", hasState, state_, writer); - PrintField("zip", hasZip, zip_, writer); - } - #endregion - - public static Addresses ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static Addresses ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static Addresses ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static Addresses ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static Addresses ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static Addresses ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static Addresses ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static Addresses ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static Addresses ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static Addresses ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private Addresses MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(Addresses prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilderLite { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(Addresses cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private Addresses result; - - private Addresses PrepareBuilder() { - if (resultIsReadOnly) { - Addresses original = result; - result = new Addresses(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override Addresses MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override Addresses DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.Addresses.DefaultInstance; } - } - - public override Addresses BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessageLite other) { - if (other is Addresses) { - return MergeFrom((Addresses) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(Addresses other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.Addresses.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasAddress) { - Address = other.Address; - } - if (other.HasAddress2) { - Address2 = other.Address2; - } - if (other.HasCity) { - City = other.City; - } - if (other.HasState) { - State = other.State; - } - if (other.HasZip) { - Zip = other.Zip; - } - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_addressesFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _addressesFieldTags[field_ordinal]; - else { - ParseUnknownField(input, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - return this; - } - ParseUnknownField(input, extensionRegistry, tag, field_name); - break; - } - case 10: { - result.hasAddress = input.ReadString(ref result.address_); - break; - } - case 18: { - result.hasAddress2 = input.ReadString(ref result.address2_); - break; - } - case 26: { - result.hasCity = input.ReadString(ref result.city_); - break; - } - case 34: { - result.hasState = input.ReadString(ref result.state_); - break; - } - case 45: { - result.hasZip = input.ReadFixed32(ref result.zip_); - break; - } - } - } - - return this; - } - - - public bool HasAddress { - get { return result.hasAddress; } - } - public string Address { - get { return result.Address; } - set { SetAddress(value); } - } - public Builder SetAddress(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasAddress = true; - result.address_ = value; - return this; - } - public Builder ClearAddress() { - PrepareBuilder(); - result.hasAddress = false; - result.address_ = ""; - return this; - } - - public bool HasAddress2 { - get { return result.hasAddress2; } - } - public string Address2 { - get { return result.Address2; } - set { SetAddress2(value); } - } - public Builder SetAddress2(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasAddress2 = true; - result.address2_ = value; - return this; - } - public Builder ClearAddress2() { - PrepareBuilder(); - result.hasAddress2 = false; - result.address2_ = ""; - return this; - } - - public bool HasCity { - get { return result.hasCity; } - } - public string City { - get { return result.City; } - set { SetCity(value); } - } - public Builder SetCity(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasCity = true; - result.city_ = value; - return this; - } - public Builder ClearCity() { - PrepareBuilder(); - result.hasCity = false; - result.city_ = ""; - return this; - } - - public bool HasState { - get { return result.hasState; } - } - public string State { - get { return result.State; } - set { SetState(value); } - } - public Builder SetState(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasState = true; - result.state_ = value; - return this; - } - public Builder ClearState() { - PrepareBuilder(); - result.hasState = false; - result.state_ = ""; - return this; - } - - public bool HasZip { - get { return result.hasZip; } - } - public uint Zip { - get { return result.Zip; } - set { SetZip(value); } - } - public Builder SetZip(uint value) { - PrepareBuilder(); - result.hasZip = true; - result.zip_ = value; - return this; - } - public Builder ClearZip() { - PrepareBuilder(); - result.hasZip = false; - result.zip_ = 0; - return this; - } - } - static Addresses() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.Descriptor, null); - } - } - - } - #endregion - - public const int NameFieldNumber = 1; - private bool hasName; - private string name_ = ""; - public bool HasName { - get { return hasName; } - } - public string Name { - get { return name_; } - } - - public const int IdFieldNumber = 2; - private bool hasId; - private int id_; - public bool HasId { - get { return hasId; } - } - public int Id { - get { return id_; } - } - - public const int EmailFieldNumber = 3; - private bool hasEmail; - private string email_ = ""; - public bool HasEmail { - get { return hasEmail; } - } - public string Email { - get { return email_; } - } - - public const int CodesFieldNumber = 10; - private int codesMemoizedSerializedSize; - private pbc::PopsicleList codes_ = new pbc::PopsicleList(); - public scg::IList CodesList { - get { return pbc::Lists.AsReadOnly(codes_); } - } - public int CodesCount { - get { return codes_.Count; } - } - public int GetCodes(int index) { - return codes_[index]; - } - - public const int PhoneFieldNumber = 4; - private pbc::PopsicleList phone_ = new pbc::PopsicleList(); - public scg::IList PhoneList { - get { return phone_; } - } - public int PhoneCount { - get { return phone_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.PhoneNumber GetPhone(int index) { - return phone_[index]; - } - - public const int AddressesFieldNumber = 5; - private pbc::PopsicleList addresses_ = new pbc::PopsicleList(); - public scg::IList AddressesList { - get { return addresses_; } - } - public int AddressesCount { - get { return addresses_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.Addresses GetAddresses(int index) { - return addresses_[index]; - } - - public override bool IsInitialized { - get { - if (!hasName) return false; - if (!hasId) return false; - foreach (global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.PhoneNumber element in PhoneList) { - if (!element.IsInitialized) return false; - } - if (!ExtensionsAreInitialized) return false; - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testInteropPersonLiteFieldNames; - pb::ExtendableMessageLite.ExtensionWriter extensionWriter = CreateExtensionWriter(this); - if (hasName) { - output.WriteString(1, field_names[4], Name); - } - if (hasId) { - output.WriteInt32(2, field_names[3], Id); - } - if (hasEmail) { - output.WriteString(3, field_names[2], Email); - } - if (phone_.Count > 0) { - output.WriteMessageArray(4, field_names[5], phone_); - } - if (addresses_.Count > 0) { - output.WriteGroupArray(5, field_names[0], addresses_); - } - if (codes_.Count > 0) { - output.WritePackedInt32Array(10, field_names[1], codesMemoizedSerializedSize, codes_); - } - extensionWriter.WriteUntil(200, output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasName) { - size += pb::CodedOutputStream.ComputeStringSize(1, Name); - } - if (hasId) { - size += pb::CodedOutputStream.ComputeInt32Size(2, Id); - } - if (hasEmail) { - size += pb::CodedOutputStream.ComputeStringSize(3, Email); - } - { - int dataSize = 0; - foreach (int element in CodesList) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); - } - size += dataSize; - if (codes_.Count != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - codesMemoizedSerializedSize = dataSize; - } - foreach (global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.PhoneNumber element in PhoneList) { - size += pb::CodedOutputStream.ComputeMessageSize(4, element); - } - foreach (global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.Addresses element in AddressesList) { - size += pb::CodedOutputStream.ComputeGroupSize(5, element); - } - size += ExtensionsSerializedSize; - memoizedSerializedSize = size; - return size; - } - #region Lite runtime methods - public override int GetHashCode() { - int hash = GetType().GetHashCode(); - if (hasName) { - hash ^= name_.GetHashCode(); - } - if (hasId) { - hash ^= id_.GetHashCode(); - } - if (hasEmail) { - hash ^= email_.GetHashCode(); - } - foreach(int i in codes_) - hash ^= i.GetHashCode(); - foreach(global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.PhoneNumber i in phone_) - hash ^= i.GetHashCode(); - foreach(global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.Addresses i in addresses_) - hash ^= i.GetHashCode(); - hash ^= base.GetHashCode(); - return hash; - } - - public override bool Equals(object obj) { - TestInteropPersonLite other = obj as TestInteropPersonLite; - if (other == null) return false; - if (hasName != other.hasName || (hasName && !name_.Equals(other.name_))) return false; - if (hasId != other.hasId || (hasId && !id_.Equals(other.id_))) return false; - if (hasEmail != other.hasEmail || (hasEmail && !email_.Equals(other.email_))) return false; - if(codes_.Count != other.codes_.Count) return false; - for(int ix=0; ix < codes_.Count; ix++) - if(!codes_[ix].Equals(other.codes_[ix])) return false; - if(phone_.Count != other.phone_.Count) return false; - for(int ix=0; ix < phone_.Count; ix++) - if(!phone_[ix].Equals(other.phone_[ix])) return false; - if(addresses_.Count != other.addresses_.Count) return false; - for(int ix=0; ix < addresses_.Count; ix++) - if(!addresses_[ix].Equals(other.addresses_[ix])) return false; - if (!base.Equals(other)) return false; - return true; - } - - public override void PrintTo(global::System.IO.TextWriter writer) { - PrintField("name", hasName, name_, writer); - PrintField("id", hasId, id_, writer); - PrintField("email", hasEmail, email_, writer); - PrintField("phone", phone_, writer); - PrintField("Addresses", addresses_, writer); - PrintField("codes", codes_, writer); - base.PrintTo(writer); - } - #endregion - - public static TestInteropPersonLite ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestInteropPersonLite ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestInteropPersonLite ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestInteropPersonLite ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestInteropPersonLite ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestInteropPersonLite ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestInteropPersonLite ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestInteropPersonLite ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestInteropPersonLite ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestInteropPersonLite ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestInteropPersonLite MakeReadOnly() { - codes_.MakeReadOnly(); - phone_.MakeReadOnly(); - addresses_.MakeReadOnly(); - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestInteropPersonLite prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::ExtendableBuilderLite { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestInteropPersonLite cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestInteropPersonLite result; - - private TestInteropPersonLite PrepareBuilder() { - if (resultIsReadOnly) { - TestInteropPersonLite original = result; - result = new TestInteropPersonLite(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestInteropPersonLite MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override TestInteropPersonLite DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.DefaultInstance; } - } - - public override TestInteropPersonLite BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessageLite other) { - if (other is TestInteropPersonLite) { - return MergeFrom((TestInteropPersonLite) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestInteropPersonLite other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasName) { - Name = other.Name; - } - if (other.HasId) { - Id = other.Id; - } - if (other.HasEmail) { - Email = other.Email; - } - if (other.codes_.Count != 0) { - result.codes_.Add(other.codes_); - } - if (other.phone_.Count != 0) { - result.phone_.Add(other.phone_); - } - if (other.addresses_.Count != 0) { - result.addresses_.Add(other.addresses_); - } - this.MergeExtensionFields(other); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testInteropPersonLiteFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testInteropPersonLiteFieldTags[field_ordinal]; - else { - ParseUnknownField(input, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - return this; - } - ParseUnknownField(input, extensionRegistry, tag, field_name); - break; - } - case 10: { - result.hasName = input.ReadString(ref result.name_); - break; - } - case 16: { - result.hasId = input.ReadInt32(ref result.id_); - break; - } - case 26: { - result.hasEmail = input.ReadString(ref result.email_); - break; - } - case 34: { - input.ReadMessageArray(tag, field_name, result.phone_, global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.PhoneNumber.DefaultInstance, extensionRegistry); - break; - } - case 43: { - input.ReadGroupArray(tag, field_name, result.addresses_, global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.Addresses.DefaultInstance, extensionRegistry); - break; - } - case 82: - case 80: { - input.ReadInt32Array(tag, field_name, result.codes_); - break; - } - } - } - - return this; - } - - - public bool HasName { - get { return result.hasName; } - } - public string Name { - get { return result.Name; } - set { SetName(value); } - } - public Builder SetName(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasName = true; - result.name_ = value; - return this; - } - public Builder ClearName() { - PrepareBuilder(); - result.hasName = false; - result.name_ = ""; - return this; - } - - public bool HasId { - get { return result.hasId; } - } - public int Id { - get { return result.Id; } - set { SetId(value); } - } - public Builder SetId(int value) { - PrepareBuilder(); - result.hasId = true; - result.id_ = value; - return this; - } - public Builder ClearId() { - PrepareBuilder(); - result.hasId = false; - result.id_ = 0; - return this; - } - - public bool HasEmail { - get { return result.hasEmail; } - } - public string Email { - get { return result.Email; } - set { SetEmail(value); } - } - public Builder SetEmail(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasEmail = true; - result.email_ = value; - return this; - } - public Builder ClearEmail() { - PrepareBuilder(); - result.hasEmail = false; - result.email_ = ""; - return this; - } - - public pbc::IPopsicleList CodesList { - get { return PrepareBuilder().codes_; } - } - public int CodesCount { - get { return result.CodesCount; } - } - public int GetCodes(int index) { - return result.GetCodes(index); - } - public Builder SetCodes(int index, int value) { - PrepareBuilder(); - result.codes_[index] = value; - return this; - } - public Builder AddCodes(int value) { - PrepareBuilder(); - result.codes_.Add(value); - return this; - } - public Builder AddRangeCodes(scg::IEnumerable values) { - PrepareBuilder(); - result.codes_.Add(values); - return this; - } - public Builder ClearCodes() { - PrepareBuilder(); - result.codes_.Clear(); - return this; - } - - public pbc::IPopsicleList PhoneList { - get { return PrepareBuilder().phone_; } - } - public int PhoneCount { - get { return result.PhoneCount; } - } - public global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.PhoneNumber GetPhone(int index) { - return result.GetPhone(index); - } - public Builder SetPhone(int index, global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.PhoneNumber value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.phone_[index] = value; - return this; - } - public Builder SetPhone(int index, global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.PhoneNumber.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.phone_[index] = builderForValue.Build(); - return this; - } - public Builder AddPhone(global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.PhoneNumber value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.phone_.Add(value); - return this; - } - public Builder AddPhone(global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.PhoneNumber.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.phone_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangePhone(scg::IEnumerable values) { - PrepareBuilder(); - result.phone_.Add(values); - return this; - } - public Builder ClearPhone() { - PrepareBuilder(); - result.phone_.Clear(); - return this; - } - - public pbc::IPopsicleList AddressesList { - get { return PrepareBuilder().addresses_; } - } - public int AddressesCount { - get { return result.AddressesCount; } - } - public global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.Addresses GetAddresses(int index) { - return result.GetAddresses(index); - } - public Builder SetAddresses(int index, global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.Addresses value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.addresses_[index] = value; - return this; - } - public Builder SetAddresses(int index, global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.Addresses.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.addresses_[index] = builderForValue.Build(); - return this; - } - public Builder AddAddresses(global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.Addresses value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.addresses_.Add(value); - return this; - } - public Builder AddAddresses(global::Google.ProtocolBuffers.TestProtos.TestInteropPersonLite.Types.Addresses.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.addresses_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeAddresses(scg::IEnumerable values) { - PrepareBuilder(); - result.addresses_.Add(values); - return this; - } - public Builder ClearAddresses() { - PrepareBuilder(); - result.addresses_.Clear(); - return this; - } - } - static TestInteropPersonLite() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestInteropEmployeeIdLite : pb::GeneratedMessageLite { - private TestInteropEmployeeIdLite() { } - private static readonly TestInteropEmployeeIdLite defaultInstance = new TestInteropEmployeeIdLite().MakeReadOnly(); - private static readonly string[] _testInteropEmployeeIdLiteFieldNames = new string[] { "number" }; - private static readonly uint[] _testInteropEmployeeIdLiteFieldTags = new uint[] { 10 }; - public static TestInteropEmployeeIdLite DefaultInstance { - get { return defaultInstance; } - } - - public override TestInteropEmployeeIdLite DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestInteropEmployeeIdLite ThisMessage { - get { return this; } - } - - public const int NumberFieldNumber = 1; - private bool hasNumber; - private string number_ = ""; - public bool HasNumber { - get { return hasNumber; } - } - public string Number { - get { return number_; } - } - - public override bool IsInitialized { - get { - if (!hasNumber) return false; - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testInteropEmployeeIdLiteFieldNames; - if (hasNumber) { - output.WriteString(1, field_names[0], Number); - } - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasNumber) { - size += pb::CodedOutputStream.ComputeStringSize(1, Number); - } - memoizedSerializedSize = size; - return size; - } - #region Lite runtime methods - public override int GetHashCode() { - int hash = GetType().GetHashCode(); - if (hasNumber) { - hash ^= number_.GetHashCode(); - } - return hash; - } - - public override bool Equals(object obj) { - TestInteropEmployeeIdLite other = obj as TestInteropEmployeeIdLite; - if (other == null) return false; - if (hasNumber != other.hasNumber || (hasNumber && !number_.Equals(other.number_))) return false; - return true; - } - - public override void PrintTo(global::System.IO.TextWriter writer) { - PrintField("number", hasNumber, number_, writer); - } - #endregion - - public static TestInteropEmployeeIdLite ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestInteropEmployeeIdLite ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestInteropEmployeeIdLite ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestInteropEmployeeIdLite ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestInteropEmployeeIdLite ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestInteropEmployeeIdLite ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestInteropEmployeeIdLite ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestInteropEmployeeIdLite ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestInteropEmployeeIdLite ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestInteropEmployeeIdLite ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestInteropEmployeeIdLite MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestInteropEmployeeIdLite prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilderLite { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestInteropEmployeeIdLite cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestInteropEmployeeIdLite result; - - private TestInteropEmployeeIdLite PrepareBuilder() { - if (resultIsReadOnly) { - TestInteropEmployeeIdLite original = result; - result = new TestInteropEmployeeIdLite(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestInteropEmployeeIdLite MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override TestInteropEmployeeIdLite DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestInteropEmployeeIdLite.DefaultInstance; } - } - - public override TestInteropEmployeeIdLite BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessageLite other) { - if (other is TestInteropEmployeeIdLite) { - return MergeFrom((TestInteropEmployeeIdLite) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestInteropEmployeeIdLite other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestInteropEmployeeIdLite.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasNumber) { - Number = other.Number; - } - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testInteropEmployeeIdLiteFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testInteropEmployeeIdLiteFieldTags[field_ordinal]; - else { - ParseUnknownField(input, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - return this; - } - ParseUnknownField(input, extensionRegistry, tag, field_name); - break; - } - case 10: { - result.hasNumber = input.ReadString(ref result.number_); - break; - } - } - } - - return this; - } - - - public bool HasNumber { - get { return result.hasNumber; } - } - public string Number { - get { return result.Number; } - set { SetNumber(value); } - } - public Builder SetNumber(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasNumber = true; - result.number_ = value; - return this; - } - public Builder ClearNumber() { - PrepareBuilder(); - result.hasNumber = false; - result.number_ = ""; - return this; - } - } - static TestInteropEmployeeIdLite() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestUnpackedExtensionsLite : pb::ExtendableMessageLite { - private TestUnpackedExtensionsLite() { } - private static readonly TestUnpackedExtensionsLite defaultInstance = new TestUnpackedExtensionsLite().MakeReadOnly(); - private static readonly string[] _testUnpackedExtensionsLiteFieldNames = new string[] { }; - private static readonly uint[] _testUnpackedExtensionsLiteFieldTags = new uint[] { }; - public static TestUnpackedExtensionsLite DefaultInstance { - get { return defaultInstance; } - } - - public override TestUnpackedExtensionsLite DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestUnpackedExtensionsLite ThisMessage { - get { return this; } - } - - public override bool IsInitialized { - get { - if (!ExtensionsAreInitialized) return false; - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testUnpackedExtensionsLiteFieldNames; - pb::ExtendableMessageLite.ExtensionWriter extensionWriter = CreateExtensionWriter(this); - extensionWriter.WriteUntil(536870912, output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - size += ExtensionsSerializedSize; - memoizedSerializedSize = size; - return size; - } - #region Lite runtime methods - public override int GetHashCode() { - int hash = GetType().GetHashCode(); - hash ^= base.GetHashCode(); - return hash; - } - - public override bool Equals(object obj) { - TestUnpackedExtensionsLite other = obj as TestUnpackedExtensionsLite; - if (other == null) return false; - if (!base.Equals(other)) return false; - return true; - } - - public override void PrintTo(global::System.IO.TextWriter writer) { - base.PrintTo(writer); - } - #endregion - - public static TestUnpackedExtensionsLite ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestUnpackedExtensionsLite ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestUnpackedExtensionsLite ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestUnpackedExtensionsLite ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestUnpackedExtensionsLite ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestUnpackedExtensionsLite ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestUnpackedExtensionsLite ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestUnpackedExtensionsLite ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestUnpackedExtensionsLite ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestUnpackedExtensionsLite ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestUnpackedExtensionsLite MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestUnpackedExtensionsLite prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::ExtendableBuilderLite { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestUnpackedExtensionsLite cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestUnpackedExtensionsLite result; - - private TestUnpackedExtensionsLite PrepareBuilder() { - if (resultIsReadOnly) { - TestUnpackedExtensionsLite original = result; - result = new TestUnpackedExtensionsLite(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestUnpackedExtensionsLite MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override TestUnpackedExtensionsLite DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestUnpackedExtensionsLite.DefaultInstance; } - } - - public override TestUnpackedExtensionsLite BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessageLite other) { - if (other is TestUnpackedExtensionsLite) { - return MergeFrom((TestUnpackedExtensionsLite) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestUnpackedExtensionsLite other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestUnpackedExtensionsLite.DefaultInstance) return this; - PrepareBuilder(); - this.MergeExtensionFields(other); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testUnpackedExtensionsLiteFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testUnpackedExtensionsLiteFieldTags[field_ordinal]; - else { - ParseUnknownField(input, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - return this; - } - ParseUnknownField(input, extensionRegistry, tag, field_name); - break; - } - } - } - - return this; - } - - } - static TestUnpackedExtensionsLite() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestUnpackedTypesLite : pb::GeneratedMessageLite { - private TestUnpackedTypesLite() { } - private static readonly TestUnpackedTypesLite defaultInstance = new TestUnpackedTypesLite().MakeReadOnly(); - private static readonly string[] _testUnpackedTypesLiteFieldNames = new string[] { "unpacked_bool", "unpacked_double", "unpacked_enum", "unpacked_fixed32", "unpacked_fixed64", "unpacked_float", "unpacked_int32", "unpacked_int64", "unpacked_sfixed32", "unpacked_sfixed64", "unpacked_sint32", "unpacked_sint64", "unpacked_uint32", "unpacked_uint64" }; - private static readonly uint[] _testUnpackedTypesLiteFieldTags = new uint[] { 816, 809, 824, 773, 777, 805, 720, 728, 789, 793, 752, 760, 736, 744 }; - public static TestUnpackedTypesLite DefaultInstance { - get { return defaultInstance; } - } - - public override TestUnpackedTypesLite DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestUnpackedTypesLite ThisMessage { - get { return this; } - } - - public const int UnpackedInt32FieldNumber = 90; - private pbc::PopsicleList unpackedInt32_ = new pbc::PopsicleList(); - public scg::IList UnpackedInt32List { - get { return pbc::Lists.AsReadOnly(unpackedInt32_); } - } - public int UnpackedInt32Count { - get { return unpackedInt32_.Count; } - } - public int GetUnpackedInt32(int index) { - return unpackedInt32_[index]; - } - - public const int UnpackedInt64FieldNumber = 91; - private pbc::PopsicleList unpackedInt64_ = new pbc::PopsicleList(); - public scg::IList UnpackedInt64List { - get { return pbc::Lists.AsReadOnly(unpackedInt64_); } - } - public int UnpackedInt64Count { - get { return unpackedInt64_.Count; } - } - public long GetUnpackedInt64(int index) { - return unpackedInt64_[index]; - } - - public const int UnpackedUint32FieldNumber = 92; - private pbc::PopsicleList unpackedUint32_ = new pbc::PopsicleList(); - public scg::IList UnpackedUint32List { - get { return pbc::Lists.AsReadOnly(unpackedUint32_); } - } - public int UnpackedUint32Count { - get { return unpackedUint32_.Count; } - } - public uint GetUnpackedUint32(int index) { - return unpackedUint32_[index]; - } - - public const int UnpackedUint64FieldNumber = 93; - private pbc::PopsicleList unpackedUint64_ = new pbc::PopsicleList(); - public scg::IList UnpackedUint64List { - get { return pbc::Lists.AsReadOnly(unpackedUint64_); } - } - public int UnpackedUint64Count { - get { return unpackedUint64_.Count; } - } - public ulong GetUnpackedUint64(int index) { - return unpackedUint64_[index]; - } - - public const int UnpackedSint32FieldNumber = 94; - private pbc::PopsicleList unpackedSint32_ = new pbc::PopsicleList(); - public scg::IList UnpackedSint32List { - get { return pbc::Lists.AsReadOnly(unpackedSint32_); } - } - public int UnpackedSint32Count { - get { return unpackedSint32_.Count; } - } - public int GetUnpackedSint32(int index) { - return unpackedSint32_[index]; - } - - public const int UnpackedSint64FieldNumber = 95; - private pbc::PopsicleList unpackedSint64_ = new pbc::PopsicleList(); - public scg::IList UnpackedSint64List { - get { return pbc::Lists.AsReadOnly(unpackedSint64_); } - } - public int UnpackedSint64Count { - get { return unpackedSint64_.Count; } - } - public long GetUnpackedSint64(int index) { - return unpackedSint64_[index]; - } - - public const int UnpackedFixed32FieldNumber = 96; - private pbc::PopsicleList unpackedFixed32_ = new pbc::PopsicleList(); - public scg::IList UnpackedFixed32List { - get { return pbc::Lists.AsReadOnly(unpackedFixed32_); } - } - public int UnpackedFixed32Count { - get { return unpackedFixed32_.Count; } - } - public uint GetUnpackedFixed32(int index) { - return unpackedFixed32_[index]; - } - - public const int UnpackedFixed64FieldNumber = 97; - private pbc::PopsicleList unpackedFixed64_ = new pbc::PopsicleList(); - public scg::IList UnpackedFixed64List { - get { return pbc::Lists.AsReadOnly(unpackedFixed64_); } - } - public int UnpackedFixed64Count { - get { return unpackedFixed64_.Count; } - } - public ulong GetUnpackedFixed64(int index) { - return unpackedFixed64_[index]; - } - - public const int UnpackedSfixed32FieldNumber = 98; - private pbc::PopsicleList unpackedSfixed32_ = new pbc::PopsicleList(); - public scg::IList UnpackedSfixed32List { - get { return pbc::Lists.AsReadOnly(unpackedSfixed32_); } - } - public int UnpackedSfixed32Count { - get { return unpackedSfixed32_.Count; } - } - public int GetUnpackedSfixed32(int index) { - return unpackedSfixed32_[index]; - } - - public const int UnpackedSfixed64FieldNumber = 99; - private pbc::PopsicleList unpackedSfixed64_ = new pbc::PopsicleList(); - public scg::IList UnpackedSfixed64List { - get { return pbc::Lists.AsReadOnly(unpackedSfixed64_); } - } - public int UnpackedSfixed64Count { - get { return unpackedSfixed64_.Count; } - } - public long GetUnpackedSfixed64(int index) { - return unpackedSfixed64_[index]; - } - - public const int UnpackedFloatFieldNumber = 100; - private pbc::PopsicleList unpackedFloat_ = new pbc::PopsicleList(); - public scg::IList UnpackedFloatList { - get { return pbc::Lists.AsReadOnly(unpackedFloat_); } - } - public int UnpackedFloatCount { - get { return unpackedFloat_.Count; } - } - public float GetUnpackedFloat(int index) { - return unpackedFloat_[index]; - } - - public const int UnpackedDoubleFieldNumber = 101; - private pbc::PopsicleList unpackedDouble_ = new pbc::PopsicleList(); - public scg::IList UnpackedDoubleList { - get { return pbc::Lists.AsReadOnly(unpackedDouble_); } - } - public int UnpackedDoubleCount { - get { return unpackedDouble_.Count; } - } - public double GetUnpackedDouble(int index) { - return unpackedDouble_[index]; - } - - public const int UnpackedBoolFieldNumber = 102; - private pbc::PopsicleList unpackedBool_ = new pbc::PopsicleList(); - public scg::IList UnpackedBoolList { - get { return pbc::Lists.AsReadOnly(unpackedBool_); } - } - public int UnpackedBoolCount { - get { return unpackedBool_.Count; } - } - public bool GetUnpackedBool(int index) { - return unpackedBool_[index]; - } - - public const int UnpackedEnumFieldNumber = 103; - private pbc::PopsicleList unpackedEnum_ = new pbc::PopsicleList(); - public scg::IList UnpackedEnumList { - get { return pbc::Lists.AsReadOnly(unpackedEnum_); } - } - public int UnpackedEnumCount { - get { return unpackedEnum_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.UnpackedTypesForeignEnumLite GetUnpackedEnum(int index) { - return unpackedEnum_[index]; - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testUnpackedTypesLiteFieldNames; - if (unpackedInt32_.Count > 0) { - output.WriteInt32Array(90, field_names[6], unpackedInt32_); - } - if (unpackedInt64_.Count > 0) { - output.WriteInt64Array(91, field_names[7], unpackedInt64_); - } - if (unpackedUint32_.Count > 0) { - output.WriteUInt32Array(92, field_names[12], unpackedUint32_); - } - if (unpackedUint64_.Count > 0) { - output.WriteUInt64Array(93, field_names[13], unpackedUint64_); - } - if (unpackedSint32_.Count > 0) { - output.WriteSInt32Array(94, field_names[10], unpackedSint32_); - } - if (unpackedSint64_.Count > 0) { - output.WriteSInt64Array(95, field_names[11], unpackedSint64_); - } - if (unpackedFixed32_.Count > 0) { - output.WriteFixed32Array(96, field_names[3], unpackedFixed32_); - } - if (unpackedFixed64_.Count > 0) { - output.WriteFixed64Array(97, field_names[4], unpackedFixed64_); - } - if (unpackedSfixed32_.Count > 0) { - output.WriteSFixed32Array(98, field_names[8], unpackedSfixed32_); - } - if (unpackedSfixed64_.Count > 0) { - output.WriteSFixed64Array(99, field_names[9], unpackedSfixed64_); - } - if (unpackedFloat_.Count > 0) { - output.WriteFloatArray(100, field_names[5], unpackedFloat_); - } - if (unpackedDouble_.Count > 0) { - output.WriteDoubleArray(101, field_names[1], unpackedDouble_); - } - if (unpackedBool_.Count > 0) { - output.WriteBoolArray(102, field_names[0], unpackedBool_); - } - if (unpackedEnum_.Count > 0) { - output.WriteEnumArray(103, field_names[2], unpackedEnum_); - } - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - { - int dataSize = 0; - foreach (int element in UnpackedInt32List) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); - } - size += dataSize; - size += 2 * unpackedInt32_.Count; - } - { - int dataSize = 0; - foreach (long element in UnpackedInt64List) { - dataSize += pb::CodedOutputStream.ComputeInt64SizeNoTag(element); - } - size += dataSize; - size += 2 * unpackedInt64_.Count; - } - { - int dataSize = 0; - foreach (uint element in UnpackedUint32List) { - dataSize += pb::CodedOutputStream.ComputeUInt32SizeNoTag(element); - } - size += dataSize; - size += 2 * unpackedUint32_.Count; - } - { - int dataSize = 0; - foreach (ulong element in UnpackedUint64List) { - dataSize += pb::CodedOutputStream.ComputeUInt64SizeNoTag(element); - } - size += dataSize; - size += 2 * unpackedUint64_.Count; - } - { - int dataSize = 0; - foreach (int element in UnpackedSint32List) { - dataSize += pb::CodedOutputStream.ComputeSInt32SizeNoTag(element); - } - size += dataSize; - size += 2 * unpackedSint32_.Count; - } - { - int dataSize = 0; - foreach (long element in UnpackedSint64List) { - dataSize += pb::CodedOutputStream.ComputeSInt64SizeNoTag(element); - } - size += dataSize; - size += 2 * unpackedSint64_.Count; - } - { - int dataSize = 0; - dataSize = 4 * unpackedFixed32_.Count; - size += dataSize; - size += 2 * unpackedFixed32_.Count; - } - { - int dataSize = 0; - dataSize = 8 * unpackedFixed64_.Count; - size += dataSize; - size += 2 * unpackedFixed64_.Count; - } - { - int dataSize = 0; - dataSize = 4 * unpackedSfixed32_.Count; - size += dataSize; - size += 2 * unpackedSfixed32_.Count; - } - { - int dataSize = 0; - dataSize = 8 * unpackedSfixed64_.Count; - size += dataSize; - size += 2 * unpackedSfixed64_.Count; - } - { - int dataSize = 0; - dataSize = 4 * unpackedFloat_.Count; - size += dataSize; - size += 2 * unpackedFloat_.Count; - } - { - int dataSize = 0; - dataSize = 8 * unpackedDouble_.Count; - size += dataSize; - size += 2 * unpackedDouble_.Count; - } - { - int dataSize = 0; - dataSize = 1 * unpackedBool_.Count; - size += dataSize; - size += 2 * unpackedBool_.Count; - } - { - int dataSize = 0; - if (unpackedEnum_.Count > 0) { - foreach (global::Google.ProtocolBuffers.TestProtos.UnpackedTypesForeignEnumLite element in unpackedEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 2 * unpackedEnum_.Count; - } - } - memoizedSerializedSize = size; - return size; - } - #region Lite runtime methods - public override int GetHashCode() { - int hash = GetType().GetHashCode(); - foreach(int i in unpackedInt32_) - hash ^= i.GetHashCode(); - foreach(long i in unpackedInt64_) - hash ^= i.GetHashCode(); - foreach(uint i in unpackedUint32_) - hash ^= i.GetHashCode(); - foreach(ulong i in unpackedUint64_) - hash ^= i.GetHashCode(); - foreach(int i in unpackedSint32_) - hash ^= i.GetHashCode(); - foreach(long i in unpackedSint64_) - hash ^= i.GetHashCode(); - foreach(uint i in unpackedFixed32_) - hash ^= i.GetHashCode(); - foreach(ulong i in unpackedFixed64_) - hash ^= i.GetHashCode(); - foreach(int i in unpackedSfixed32_) - hash ^= i.GetHashCode(); - foreach(long i in unpackedSfixed64_) - hash ^= i.GetHashCode(); - foreach(float i in unpackedFloat_) - hash ^= i.GetHashCode(); - foreach(double i in unpackedDouble_) - hash ^= i.GetHashCode(); - foreach(bool i in unpackedBool_) - hash ^= i.GetHashCode(); - foreach(global::Google.ProtocolBuffers.TestProtos.UnpackedTypesForeignEnumLite i in unpackedEnum_) - hash ^= i.GetHashCode(); - return hash; - } - - public override bool Equals(object obj) { - TestUnpackedTypesLite other = obj as TestUnpackedTypesLite; - if (other == null) return false; - if(unpackedInt32_.Count != other.unpackedInt32_.Count) return false; - for(int ix=0; ix < unpackedInt32_.Count; ix++) - if(!unpackedInt32_[ix].Equals(other.unpackedInt32_[ix])) return false; - if(unpackedInt64_.Count != other.unpackedInt64_.Count) return false; - for(int ix=0; ix < unpackedInt64_.Count; ix++) - if(!unpackedInt64_[ix].Equals(other.unpackedInt64_[ix])) return false; - if(unpackedUint32_.Count != other.unpackedUint32_.Count) return false; - for(int ix=0; ix < unpackedUint32_.Count; ix++) - if(!unpackedUint32_[ix].Equals(other.unpackedUint32_[ix])) return false; - if(unpackedUint64_.Count != other.unpackedUint64_.Count) return false; - for(int ix=0; ix < unpackedUint64_.Count; ix++) - if(!unpackedUint64_[ix].Equals(other.unpackedUint64_[ix])) return false; - if(unpackedSint32_.Count != other.unpackedSint32_.Count) return false; - for(int ix=0; ix < unpackedSint32_.Count; ix++) - if(!unpackedSint32_[ix].Equals(other.unpackedSint32_[ix])) return false; - if(unpackedSint64_.Count != other.unpackedSint64_.Count) return false; - for(int ix=0; ix < unpackedSint64_.Count; ix++) - if(!unpackedSint64_[ix].Equals(other.unpackedSint64_[ix])) return false; - if(unpackedFixed32_.Count != other.unpackedFixed32_.Count) return false; - for(int ix=0; ix < unpackedFixed32_.Count; ix++) - if(!unpackedFixed32_[ix].Equals(other.unpackedFixed32_[ix])) return false; - if(unpackedFixed64_.Count != other.unpackedFixed64_.Count) return false; - for(int ix=0; ix < unpackedFixed64_.Count; ix++) - if(!unpackedFixed64_[ix].Equals(other.unpackedFixed64_[ix])) return false; - if(unpackedSfixed32_.Count != other.unpackedSfixed32_.Count) return false; - for(int ix=0; ix < unpackedSfixed32_.Count; ix++) - if(!unpackedSfixed32_[ix].Equals(other.unpackedSfixed32_[ix])) return false; - if(unpackedSfixed64_.Count != other.unpackedSfixed64_.Count) return false; - for(int ix=0; ix < unpackedSfixed64_.Count; ix++) - if(!unpackedSfixed64_[ix].Equals(other.unpackedSfixed64_[ix])) return false; - if(unpackedFloat_.Count != other.unpackedFloat_.Count) return false; - for(int ix=0; ix < unpackedFloat_.Count; ix++) - if(!unpackedFloat_[ix].Equals(other.unpackedFloat_[ix])) return false; - if(unpackedDouble_.Count != other.unpackedDouble_.Count) return false; - for(int ix=0; ix < unpackedDouble_.Count; ix++) - if(!unpackedDouble_[ix].Equals(other.unpackedDouble_[ix])) return false; - if(unpackedBool_.Count != other.unpackedBool_.Count) return false; - for(int ix=0; ix < unpackedBool_.Count; ix++) - if(!unpackedBool_[ix].Equals(other.unpackedBool_[ix])) return false; - if(unpackedEnum_.Count != other.unpackedEnum_.Count) return false; - for(int ix=0; ix < unpackedEnum_.Count; ix++) - if(!unpackedEnum_[ix].Equals(other.unpackedEnum_[ix])) return false; - return true; - } - - public override void PrintTo(global::System.IO.TextWriter writer) { - PrintField("unpacked_int32", unpackedInt32_, writer); - PrintField("unpacked_int64", unpackedInt64_, writer); - PrintField("unpacked_uint32", unpackedUint32_, writer); - PrintField("unpacked_uint64", unpackedUint64_, writer); - PrintField("unpacked_sint32", unpackedSint32_, writer); - PrintField("unpacked_sint64", unpackedSint64_, writer); - PrintField("unpacked_fixed32", unpackedFixed32_, writer); - PrintField("unpacked_fixed64", unpackedFixed64_, writer); - PrintField("unpacked_sfixed32", unpackedSfixed32_, writer); - PrintField("unpacked_sfixed64", unpackedSfixed64_, writer); - PrintField("unpacked_float", unpackedFloat_, writer); - PrintField("unpacked_double", unpackedDouble_, writer); - PrintField("unpacked_bool", unpackedBool_, writer); - PrintField("unpacked_enum", unpackedEnum_, writer); - } - #endregion - - public static TestUnpackedTypesLite ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestUnpackedTypesLite ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestUnpackedTypesLite ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestUnpackedTypesLite ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestUnpackedTypesLite ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestUnpackedTypesLite ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestUnpackedTypesLite ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestUnpackedTypesLite ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestUnpackedTypesLite ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestUnpackedTypesLite ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestUnpackedTypesLite MakeReadOnly() { - unpackedInt32_.MakeReadOnly(); - unpackedInt64_.MakeReadOnly(); - unpackedUint32_.MakeReadOnly(); - unpackedUint64_.MakeReadOnly(); - unpackedSint32_.MakeReadOnly(); - unpackedSint64_.MakeReadOnly(); - unpackedFixed32_.MakeReadOnly(); - unpackedFixed64_.MakeReadOnly(); - unpackedSfixed32_.MakeReadOnly(); - unpackedSfixed64_.MakeReadOnly(); - unpackedFloat_.MakeReadOnly(); - unpackedDouble_.MakeReadOnly(); - unpackedBool_.MakeReadOnly(); - unpackedEnum_.MakeReadOnly(); - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestUnpackedTypesLite prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilderLite { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestUnpackedTypesLite cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestUnpackedTypesLite result; - - private TestUnpackedTypesLite PrepareBuilder() { - if (resultIsReadOnly) { - TestUnpackedTypesLite original = result; - result = new TestUnpackedTypesLite(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestUnpackedTypesLite MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override TestUnpackedTypesLite DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestUnpackedTypesLite.DefaultInstance; } - } - - public override TestUnpackedTypesLite BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessageLite other) { - if (other is TestUnpackedTypesLite) { - return MergeFrom((TestUnpackedTypesLite) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestUnpackedTypesLite other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestUnpackedTypesLite.DefaultInstance) return this; - PrepareBuilder(); - if (other.unpackedInt32_.Count != 0) { - result.unpackedInt32_.Add(other.unpackedInt32_); - } - if (other.unpackedInt64_.Count != 0) { - result.unpackedInt64_.Add(other.unpackedInt64_); - } - if (other.unpackedUint32_.Count != 0) { - result.unpackedUint32_.Add(other.unpackedUint32_); - } - if (other.unpackedUint64_.Count != 0) { - result.unpackedUint64_.Add(other.unpackedUint64_); - } - if (other.unpackedSint32_.Count != 0) { - result.unpackedSint32_.Add(other.unpackedSint32_); - } - if (other.unpackedSint64_.Count != 0) { - result.unpackedSint64_.Add(other.unpackedSint64_); - } - if (other.unpackedFixed32_.Count != 0) { - result.unpackedFixed32_.Add(other.unpackedFixed32_); - } - if (other.unpackedFixed64_.Count != 0) { - result.unpackedFixed64_.Add(other.unpackedFixed64_); - } - if (other.unpackedSfixed32_.Count != 0) { - result.unpackedSfixed32_.Add(other.unpackedSfixed32_); - } - if (other.unpackedSfixed64_.Count != 0) { - result.unpackedSfixed64_.Add(other.unpackedSfixed64_); - } - if (other.unpackedFloat_.Count != 0) { - result.unpackedFloat_.Add(other.unpackedFloat_); - } - if (other.unpackedDouble_.Count != 0) { - result.unpackedDouble_.Add(other.unpackedDouble_); - } - if (other.unpackedBool_.Count != 0) { - result.unpackedBool_.Add(other.unpackedBool_); - } - if (other.unpackedEnum_.Count != 0) { - result.unpackedEnum_.Add(other.unpackedEnum_); - } - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testUnpackedTypesLiteFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testUnpackedTypesLiteFieldTags[field_ordinal]; - else { - ParseUnknownField(input, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - return this; - } - ParseUnknownField(input, extensionRegistry, tag, field_name); - break; - } - case 722: - case 720: { - input.ReadInt32Array(tag, field_name, result.unpackedInt32_); - break; - } - case 730: - case 728: { - input.ReadInt64Array(tag, field_name, result.unpackedInt64_); - break; - } - case 738: - case 736: { - input.ReadUInt32Array(tag, field_name, result.unpackedUint32_); - break; - } - case 746: - case 744: { - input.ReadUInt64Array(tag, field_name, result.unpackedUint64_); - break; - } - case 754: - case 752: { - input.ReadSInt32Array(tag, field_name, result.unpackedSint32_); - break; - } - case 762: - case 760: { - input.ReadSInt64Array(tag, field_name, result.unpackedSint64_); - break; - } - case 770: - case 773: { - input.ReadFixed32Array(tag, field_name, result.unpackedFixed32_); - break; - } - case 778: - case 777: { - input.ReadFixed64Array(tag, field_name, result.unpackedFixed64_); - break; - } - case 786: - case 789: { - input.ReadSFixed32Array(tag, field_name, result.unpackedSfixed32_); - break; - } - case 794: - case 793: { - input.ReadSFixed64Array(tag, field_name, result.unpackedSfixed64_); - break; - } - case 802: - case 805: { - input.ReadFloatArray(tag, field_name, result.unpackedFloat_); - break; - } - case 810: - case 809: { - input.ReadDoubleArray(tag, field_name, result.unpackedDouble_); - break; - } - case 818: - case 816: { - input.ReadBoolArray(tag, field_name, result.unpackedBool_); - break; - } - case 826: - case 824: { - scg::ICollection unknownItems; - input.ReadEnumArray(tag, field_name, result.unpackedEnum_, out unknownItems); - break; - } - } - } - - return this; - } - - - public pbc::IPopsicleList UnpackedInt32List { - get { return PrepareBuilder().unpackedInt32_; } - } - public int UnpackedInt32Count { - get { return result.UnpackedInt32Count; } - } - public int GetUnpackedInt32(int index) { - return result.GetUnpackedInt32(index); - } - public Builder SetUnpackedInt32(int index, int value) { - PrepareBuilder(); - result.unpackedInt32_[index] = value; - return this; - } - public Builder AddUnpackedInt32(int value) { - PrepareBuilder(); - result.unpackedInt32_.Add(value); - return this; - } - public Builder AddRangeUnpackedInt32(scg::IEnumerable values) { - PrepareBuilder(); - result.unpackedInt32_.Add(values); - return this; - } - public Builder ClearUnpackedInt32() { - PrepareBuilder(); - result.unpackedInt32_.Clear(); - return this; - } - - public pbc::IPopsicleList UnpackedInt64List { - get { return PrepareBuilder().unpackedInt64_; } - } - public int UnpackedInt64Count { - get { return result.UnpackedInt64Count; } - } - public long GetUnpackedInt64(int index) { - return result.GetUnpackedInt64(index); - } - public Builder SetUnpackedInt64(int index, long value) { - PrepareBuilder(); - result.unpackedInt64_[index] = value; - return this; - } - public Builder AddUnpackedInt64(long value) { - PrepareBuilder(); - result.unpackedInt64_.Add(value); - return this; - } - public Builder AddRangeUnpackedInt64(scg::IEnumerable values) { - PrepareBuilder(); - result.unpackedInt64_.Add(values); - return this; - } - public Builder ClearUnpackedInt64() { - PrepareBuilder(); - result.unpackedInt64_.Clear(); - return this; - } - - public pbc::IPopsicleList UnpackedUint32List { - get { return PrepareBuilder().unpackedUint32_; } - } - public int UnpackedUint32Count { - get { return result.UnpackedUint32Count; } - } - public uint GetUnpackedUint32(int index) { - return result.GetUnpackedUint32(index); - } - public Builder SetUnpackedUint32(int index, uint value) { - PrepareBuilder(); - result.unpackedUint32_[index] = value; - return this; - } - public Builder AddUnpackedUint32(uint value) { - PrepareBuilder(); - result.unpackedUint32_.Add(value); - return this; - } - public Builder AddRangeUnpackedUint32(scg::IEnumerable values) { - PrepareBuilder(); - result.unpackedUint32_.Add(values); - return this; - } - public Builder ClearUnpackedUint32() { - PrepareBuilder(); - result.unpackedUint32_.Clear(); - return this; - } - - public pbc::IPopsicleList UnpackedUint64List { - get { return PrepareBuilder().unpackedUint64_; } - } - public int UnpackedUint64Count { - get { return result.UnpackedUint64Count; } - } - public ulong GetUnpackedUint64(int index) { - return result.GetUnpackedUint64(index); - } - public Builder SetUnpackedUint64(int index, ulong value) { - PrepareBuilder(); - result.unpackedUint64_[index] = value; - return this; - } - public Builder AddUnpackedUint64(ulong value) { - PrepareBuilder(); - result.unpackedUint64_.Add(value); - return this; - } - public Builder AddRangeUnpackedUint64(scg::IEnumerable values) { - PrepareBuilder(); - result.unpackedUint64_.Add(values); - return this; - } - public Builder ClearUnpackedUint64() { - PrepareBuilder(); - result.unpackedUint64_.Clear(); - return this; - } - - public pbc::IPopsicleList UnpackedSint32List { - get { return PrepareBuilder().unpackedSint32_; } - } - public int UnpackedSint32Count { - get { return result.UnpackedSint32Count; } - } - public int GetUnpackedSint32(int index) { - return result.GetUnpackedSint32(index); - } - public Builder SetUnpackedSint32(int index, int value) { - PrepareBuilder(); - result.unpackedSint32_[index] = value; - return this; - } - public Builder AddUnpackedSint32(int value) { - PrepareBuilder(); - result.unpackedSint32_.Add(value); - return this; - } - public Builder AddRangeUnpackedSint32(scg::IEnumerable values) { - PrepareBuilder(); - result.unpackedSint32_.Add(values); - return this; - } - public Builder ClearUnpackedSint32() { - PrepareBuilder(); - result.unpackedSint32_.Clear(); - return this; - } - - public pbc::IPopsicleList UnpackedSint64List { - get { return PrepareBuilder().unpackedSint64_; } - } - public int UnpackedSint64Count { - get { return result.UnpackedSint64Count; } - } - public long GetUnpackedSint64(int index) { - return result.GetUnpackedSint64(index); - } - public Builder SetUnpackedSint64(int index, long value) { - PrepareBuilder(); - result.unpackedSint64_[index] = value; - return this; - } - public Builder AddUnpackedSint64(long value) { - PrepareBuilder(); - result.unpackedSint64_.Add(value); - return this; - } - public Builder AddRangeUnpackedSint64(scg::IEnumerable values) { - PrepareBuilder(); - result.unpackedSint64_.Add(values); - return this; - } - public Builder ClearUnpackedSint64() { - PrepareBuilder(); - result.unpackedSint64_.Clear(); - return this; - } - - public pbc::IPopsicleList UnpackedFixed32List { - get { return PrepareBuilder().unpackedFixed32_; } - } - public int UnpackedFixed32Count { - get { return result.UnpackedFixed32Count; } - } - public uint GetUnpackedFixed32(int index) { - return result.GetUnpackedFixed32(index); - } - public Builder SetUnpackedFixed32(int index, uint value) { - PrepareBuilder(); - result.unpackedFixed32_[index] = value; - return this; - } - public Builder AddUnpackedFixed32(uint value) { - PrepareBuilder(); - result.unpackedFixed32_.Add(value); - return this; - } - public Builder AddRangeUnpackedFixed32(scg::IEnumerable values) { - PrepareBuilder(); - result.unpackedFixed32_.Add(values); - return this; - } - public Builder ClearUnpackedFixed32() { - PrepareBuilder(); - result.unpackedFixed32_.Clear(); - return this; - } - - public pbc::IPopsicleList UnpackedFixed64List { - get { return PrepareBuilder().unpackedFixed64_; } - } - public int UnpackedFixed64Count { - get { return result.UnpackedFixed64Count; } - } - public ulong GetUnpackedFixed64(int index) { - return result.GetUnpackedFixed64(index); - } - public Builder SetUnpackedFixed64(int index, ulong value) { - PrepareBuilder(); - result.unpackedFixed64_[index] = value; - return this; - } - public Builder AddUnpackedFixed64(ulong value) { - PrepareBuilder(); - result.unpackedFixed64_.Add(value); - return this; - } - public Builder AddRangeUnpackedFixed64(scg::IEnumerable values) { - PrepareBuilder(); - result.unpackedFixed64_.Add(values); - return this; - } - public Builder ClearUnpackedFixed64() { - PrepareBuilder(); - result.unpackedFixed64_.Clear(); - return this; - } - - public pbc::IPopsicleList UnpackedSfixed32List { - get { return PrepareBuilder().unpackedSfixed32_; } - } - public int UnpackedSfixed32Count { - get { return result.UnpackedSfixed32Count; } - } - public int GetUnpackedSfixed32(int index) { - return result.GetUnpackedSfixed32(index); - } - public Builder SetUnpackedSfixed32(int index, int value) { - PrepareBuilder(); - result.unpackedSfixed32_[index] = value; - return this; - } - public Builder AddUnpackedSfixed32(int value) { - PrepareBuilder(); - result.unpackedSfixed32_.Add(value); - return this; - } - public Builder AddRangeUnpackedSfixed32(scg::IEnumerable values) { - PrepareBuilder(); - result.unpackedSfixed32_.Add(values); - return this; - } - public Builder ClearUnpackedSfixed32() { - PrepareBuilder(); - result.unpackedSfixed32_.Clear(); - return this; - } - - public pbc::IPopsicleList UnpackedSfixed64List { - get { return PrepareBuilder().unpackedSfixed64_; } - } - public int UnpackedSfixed64Count { - get { return result.UnpackedSfixed64Count; } - } - public long GetUnpackedSfixed64(int index) { - return result.GetUnpackedSfixed64(index); - } - public Builder SetUnpackedSfixed64(int index, long value) { - PrepareBuilder(); - result.unpackedSfixed64_[index] = value; - return this; - } - public Builder AddUnpackedSfixed64(long value) { - PrepareBuilder(); - result.unpackedSfixed64_.Add(value); - return this; - } - public Builder AddRangeUnpackedSfixed64(scg::IEnumerable values) { - PrepareBuilder(); - result.unpackedSfixed64_.Add(values); - return this; - } - public Builder ClearUnpackedSfixed64() { - PrepareBuilder(); - result.unpackedSfixed64_.Clear(); - return this; - } - - public pbc::IPopsicleList UnpackedFloatList { - get { return PrepareBuilder().unpackedFloat_; } - } - public int UnpackedFloatCount { - get { return result.UnpackedFloatCount; } - } - public float GetUnpackedFloat(int index) { - return result.GetUnpackedFloat(index); - } - public Builder SetUnpackedFloat(int index, float value) { - PrepareBuilder(); - result.unpackedFloat_[index] = value; - return this; - } - public Builder AddUnpackedFloat(float value) { - PrepareBuilder(); - result.unpackedFloat_.Add(value); - return this; - } - public Builder AddRangeUnpackedFloat(scg::IEnumerable values) { - PrepareBuilder(); - result.unpackedFloat_.Add(values); - return this; - } - public Builder ClearUnpackedFloat() { - PrepareBuilder(); - result.unpackedFloat_.Clear(); - return this; - } - - public pbc::IPopsicleList UnpackedDoubleList { - get { return PrepareBuilder().unpackedDouble_; } - } - public int UnpackedDoubleCount { - get { return result.UnpackedDoubleCount; } - } - public double GetUnpackedDouble(int index) { - return result.GetUnpackedDouble(index); - } - public Builder SetUnpackedDouble(int index, double value) { - PrepareBuilder(); - result.unpackedDouble_[index] = value; - return this; - } - public Builder AddUnpackedDouble(double value) { - PrepareBuilder(); - result.unpackedDouble_.Add(value); - return this; - } - public Builder AddRangeUnpackedDouble(scg::IEnumerable values) { - PrepareBuilder(); - result.unpackedDouble_.Add(values); - return this; - } - public Builder ClearUnpackedDouble() { - PrepareBuilder(); - result.unpackedDouble_.Clear(); - return this; - } - - public pbc::IPopsicleList UnpackedBoolList { - get { return PrepareBuilder().unpackedBool_; } - } - public int UnpackedBoolCount { - get { return result.UnpackedBoolCount; } - } - public bool GetUnpackedBool(int index) { - return result.GetUnpackedBool(index); - } - public Builder SetUnpackedBool(int index, bool value) { - PrepareBuilder(); - result.unpackedBool_[index] = value; - return this; - } - public Builder AddUnpackedBool(bool value) { - PrepareBuilder(); - result.unpackedBool_.Add(value); - return this; - } - public Builder AddRangeUnpackedBool(scg::IEnumerable values) { - PrepareBuilder(); - result.unpackedBool_.Add(values); - return this; - } - public Builder ClearUnpackedBool() { - PrepareBuilder(); - result.unpackedBool_.Clear(); - return this; - } - - public pbc::IPopsicleList UnpackedEnumList { - get { return PrepareBuilder().unpackedEnum_; } - } - public int UnpackedEnumCount { - get { return result.UnpackedEnumCount; } - } - public global::Google.ProtocolBuffers.TestProtos.UnpackedTypesForeignEnumLite GetUnpackedEnum(int index) { - return result.GetUnpackedEnum(index); - } - public Builder SetUnpackedEnum(int index, global::Google.ProtocolBuffers.TestProtos.UnpackedTypesForeignEnumLite value) { - PrepareBuilder(); - result.unpackedEnum_[index] = value; - return this; - } - public Builder AddUnpackedEnum(global::Google.ProtocolBuffers.TestProtos.UnpackedTypesForeignEnumLite value) { - PrepareBuilder(); - result.unpackedEnum_.Add(value); - return this; - } - public Builder AddRangeUnpackedEnum(scg::IEnumerable values) { - PrepareBuilder(); - result.unpackedEnum_.Add(values); - return this; - } - public Builder ClearUnpackedEnum() { - PrepareBuilder(); - result.unpackedEnum_.Clear(); - return this; - } - } - static TestUnpackedTypesLite() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class BucketOfBytes : pb::GeneratedMessageLite { - private BucketOfBytes() { } - private static readonly BucketOfBytes defaultInstance = new BucketOfBytes().MakeReadOnly(); - private static readonly string[] _bucketOfBytesFieldNames = new string[] { "value" }; - private static readonly uint[] _bucketOfBytesFieldTags = new uint[] { 10 }; - public static BucketOfBytes DefaultInstance { - get { return defaultInstance; } - } - - public override BucketOfBytes DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override BucketOfBytes ThisMessage { - get { return this; } - } - - public const int ValueFieldNumber = 1; - private bool hasValue; - private pb::ByteString value_ = pb::ByteString.Empty; - public bool HasValue { - get { return hasValue; } - } - public pb::ByteString Value { - get { return value_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _bucketOfBytesFieldNames; - if (hasValue) { - output.WriteBytes(1, field_names[0], Value); - } - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasValue) { - size += pb::CodedOutputStream.ComputeBytesSize(1, Value); - } - memoizedSerializedSize = size; - return size; - } - #region Lite runtime methods - public override int GetHashCode() { - int hash = GetType().GetHashCode(); - if (hasValue) { - hash ^= value_.GetHashCode(); - } - return hash; - } - - public override bool Equals(object obj) { - BucketOfBytes other = obj as BucketOfBytes; - if (other == null) return false; - if (hasValue != other.hasValue || (hasValue && !value_.Equals(other.value_))) return false; - return true; - } - - public override void PrintTo(global::System.IO.TextWriter writer) { - PrintField("value", hasValue, value_, writer); - } - #endregion - - public static BucketOfBytes ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static BucketOfBytes ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static BucketOfBytes ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static BucketOfBytes ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static BucketOfBytes ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static BucketOfBytes ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static BucketOfBytes ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static BucketOfBytes ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static BucketOfBytes ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static BucketOfBytes ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private BucketOfBytes MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(BucketOfBytes prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilderLite { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(BucketOfBytes cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private BucketOfBytes result; - - private BucketOfBytes PrepareBuilder() { - if (resultIsReadOnly) { - BucketOfBytes original = result; - result = new BucketOfBytes(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override BucketOfBytes MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override BucketOfBytes DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.BucketOfBytes.DefaultInstance; } - } - - public override BucketOfBytes BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessageLite other) { - if (other is BucketOfBytes) { - return MergeFrom((BucketOfBytes) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(BucketOfBytes other) { - if (other == global::Google.ProtocolBuffers.TestProtos.BucketOfBytes.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasValue) { - Value = other.Value; - } - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_bucketOfBytesFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _bucketOfBytesFieldTags[field_ordinal]; - else { - ParseUnknownField(input, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - return this; - } - ParseUnknownField(input, extensionRegistry, tag, field_name); - break; - } - case 10: { - result.hasValue = input.ReadBytes(ref result.value_); - break; - } - } - } - - return this; - } - - - public bool HasValue { - get { return result.hasValue; } - } - public pb::ByteString Value { - get { return result.Value; } - set { SetValue(value); } - } - public Builder SetValue(pb::ByteString value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasValue = true; - result.value_ = value; - return this; - } - public Builder ClearValue() { - PrepareBuilder(); - result.hasValue = false; - result.value_ = pb::ByteString.Empty; - return this; - } - } - static BucketOfBytes() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class BucketOfBytesEx : pb::GeneratedMessageLite { - private BucketOfBytesEx() { } - private static readonly BucketOfBytesEx defaultInstance = new BucketOfBytesEx().MakeReadOnly(); - private static readonly string[] _bucketOfBytesExFieldNames = new string[] { "value", "value2" }; - private static readonly uint[] _bucketOfBytesExFieldTags = new uint[] { 10, 2042 }; - public static BucketOfBytesEx DefaultInstance { - get { return defaultInstance; } - } - - public override BucketOfBytesEx DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override BucketOfBytesEx ThisMessage { - get { return this; } - } - - public const int ValueFieldNumber = 1; - private bool hasValue; - private pb::ByteString value_ = pb::ByteString.Empty; - public bool HasValue { - get { return hasValue; } - } - public pb::ByteString Value { - get { return value_; } - } - - public const int Value2FieldNumber = 255; - private bool hasValue2; - private pb::ByteString value2_ = pb::ByteString.Empty; - public bool HasValue2 { - get { return hasValue2; } - } - public pb::ByteString Value2 { - get { return value2_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _bucketOfBytesExFieldNames; - if (hasValue) { - output.WriteBytes(1, field_names[0], Value); - } - if (hasValue2) { - output.WriteBytes(255, field_names[1], Value2); - } - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasValue) { - size += pb::CodedOutputStream.ComputeBytesSize(1, Value); - } - if (hasValue2) { - size += pb::CodedOutputStream.ComputeBytesSize(255, Value2); - } - memoizedSerializedSize = size; - return size; - } - #region Lite runtime methods - public override int GetHashCode() { - int hash = GetType().GetHashCode(); - if (hasValue) { - hash ^= value_.GetHashCode(); - } - if (hasValue2) { - hash ^= value2_.GetHashCode(); - } - return hash; - } - - public override bool Equals(object obj) { - BucketOfBytesEx other = obj as BucketOfBytesEx; - if (other == null) return false; - if (hasValue != other.hasValue || (hasValue && !value_.Equals(other.value_))) return false; - if (hasValue2 != other.hasValue2 || (hasValue2 && !value2_.Equals(other.value2_))) return false; - return true; - } - - public override void PrintTo(global::System.IO.TextWriter writer) { - PrintField("value", hasValue, value_, writer); - PrintField("value2", hasValue2, value2_, writer); - } - #endregion - - public static BucketOfBytesEx ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static BucketOfBytesEx ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static BucketOfBytesEx ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static BucketOfBytesEx ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static BucketOfBytesEx ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static BucketOfBytesEx ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static BucketOfBytesEx ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static BucketOfBytesEx ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static BucketOfBytesEx ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static BucketOfBytesEx ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private BucketOfBytesEx MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(BucketOfBytesEx prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilderLite { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(BucketOfBytesEx cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private BucketOfBytesEx result; - - private BucketOfBytesEx PrepareBuilder() { - if (resultIsReadOnly) { - BucketOfBytesEx original = result; - result = new BucketOfBytesEx(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override BucketOfBytesEx MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override BucketOfBytesEx DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.BucketOfBytesEx.DefaultInstance; } - } - - public override BucketOfBytesEx BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessageLite other) { - if (other is BucketOfBytesEx) { - return MergeFrom((BucketOfBytesEx) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(BucketOfBytesEx other) { - if (other == global::Google.ProtocolBuffers.TestProtos.BucketOfBytesEx.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasValue) { - Value = other.Value; - } - if (other.HasValue2) { - Value2 = other.Value2; - } - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_bucketOfBytesExFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _bucketOfBytesExFieldTags[field_ordinal]; - else { - ParseUnknownField(input, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - return this; - } - ParseUnknownField(input, extensionRegistry, tag, field_name); - break; - } - case 10: { - result.hasValue = input.ReadBytes(ref result.value_); - break; - } - case 2042: { - result.hasValue2 = input.ReadBytes(ref result.value2_); - break; - } - } - } - - return this; - } - - - public bool HasValue { - get { return result.hasValue; } - } - public pb::ByteString Value { - get { return result.Value; } - set { SetValue(value); } - } - public Builder SetValue(pb::ByteString value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasValue = true; - result.value_ = value; - return this; - } - public Builder ClearValue() { - PrepareBuilder(); - result.hasValue = false; - result.value_ = pb::ByteString.Empty; - return this; - } - - public bool HasValue2 { - get { return result.hasValue2; } - } - public pb::ByteString Value2 { - get { return result.Value2; } - set { SetValue2(value); } - } - public Builder SetValue2(pb::ByteString value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasValue2 = true; - result.value2_ = value; - return this; - } - public Builder ClearValue2() { - PrepareBuilder(); - result.hasValue2 = false; - result.value2_ = pb::ByteString.Empty; - return this; - } - } - static BucketOfBytesEx() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.UnittestExtrasLite.Descriptor, null); - } - } - - #endregion - -} - -#endregion Designer generated code diff --git a/csharp/src/ProtocolBuffersLite.Test/TestProtos/UnittestImport.cs b/csharp/src/ProtocolBuffersLite.Test/TestProtos/UnittestImport.cs deleted file mode 100644 index 81f9ee53..00000000 --- a/csharp/src/ProtocolBuffersLite.Test/TestProtos/UnittestImport.cs +++ /dev/null @@ -1,347 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/protobuf/unittest_import.proto -#pragma warning disable 1591, 0612, 3021 -#region Designer generated code - -using pb = global::Google.ProtocolBuffers; -using pbc = global::Google.ProtocolBuffers.Collections; -using pbd = global::Google.ProtocolBuffers.Descriptors; -using scg = global::System.Collections.Generic; -namespace Google.ProtocolBuffers.TestProtos { - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class UnittestImport { - - #region Extension registration - public static void RegisterAllExtensions(pb::ExtensionRegistry registry) { - } - #endregion - #region Static variables - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_import_ImportMessage__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_import_ImportMessage__FieldAccessorTable; - #endregion - #region Descriptor - public static pbd::FileDescriptor Descriptor { - get { return descriptor; } - } - private static pbd::FileDescriptor descriptor; - - static UnittestImport() { - byte[] descriptorData = global::System.Convert.FromBase64String( - string.Concat( - "CiVnb29nbGUvcHJvdG9idWYvdW5pdHRlc3RfaW1wb3J0LnByb3RvEhhwcm90", - "b2J1Zl91bml0dGVzdF9pbXBvcnQaLGdvb2dsZS9wcm90b2J1Zi91bml0dGVz", - "dF9pbXBvcnRfcHVibGljLnByb3RvIhoKDUltcG9ydE1lc3NhZ2USCQoBZBgB", - "IAEoBSo8CgpJbXBvcnRFbnVtEg4KCklNUE9SVF9GT08QBxIOCgpJTVBPUlRf", - "QkFSEAgSDgoKSU1QT1JUX0JBWhAJQkMKGGNvbS5nb29nbGUucHJvdG9idWYu", - "dGVzdEgB+AEBqgIhR29vZ2xlLlByb3RvY29sQnVmZmVycy5UZXN0UHJvdG9z", - "UAA=")); - pbd::FileDescriptor.InternalDescriptorAssigner assigner = delegate(pbd::FileDescriptor root) { - descriptor = root; - internal__static_protobuf_unittest_import_ImportMessage__Descriptor = Descriptor.MessageTypes[0]; - internal__static_protobuf_unittest_import_ImportMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_import_ImportMessage__Descriptor, - new string[] { "D", }); - pb::ExtensionRegistry registry = pb::ExtensionRegistry.CreateInstance(); - RegisterAllExtensions(registry); - global::Google.ProtocolBuffers.TestProtos.UnittestImportPublic.RegisterAllExtensions(registry); - return registry; - }; - pbd::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, - new pbd::FileDescriptor[] { - global::Google.ProtocolBuffers.TestProtos.UnittestImportPublic.Descriptor, - }, assigner); - } - #endregion - - } - #region Enums - public enum ImportEnum { - IMPORT_FOO = 7, - IMPORT_BAR = 8, - IMPORT_BAZ = 9, - } - - #endregion - - #region Messages - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class ImportMessage : pb::GeneratedMessage { - private ImportMessage() { } - private static readonly ImportMessage defaultInstance = new ImportMessage().MakeReadOnly(); - private static readonly string[] _importMessageFieldNames = new string[] { "d" }; - private static readonly uint[] _importMessageFieldTags = new uint[] { 8 }; - public static ImportMessage DefaultInstance { - get { return defaultInstance; } - } - - public override ImportMessage DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override ImportMessage ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.UnittestImport.internal__static_protobuf_unittest_import_ImportMessage__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.UnittestImport.internal__static_protobuf_unittest_import_ImportMessage__FieldAccessorTable; } - } - - public const int DFieldNumber = 1; - private bool hasD; - private int d_; - public bool HasD { - get { return hasD; } - } - public int D { - get { return d_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _importMessageFieldNames; - if (hasD) { - output.WriteInt32(1, field_names[0], D); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasD) { - size += pb::CodedOutputStream.ComputeInt32Size(1, D); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static ImportMessage ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static ImportMessage ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static ImportMessage ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static ImportMessage ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static ImportMessage ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static ImportMessage ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static ImportMessage ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static ImportMessage ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static ImportMessage ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static ImportMessage ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private ImportMessage MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(ImportMessage prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(ImportMessage cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private ImportMessage result; - - private ImportMessage PrepareBuilder() { - if (resultIsReadOnly) { - ImportMessage original = result; - result = new ImportMessage(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override ImportMessage MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.ImportMessage.Descriptor; } - } - - public override ImportMessage DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.ImportMessage.DefaultInstance; } - } - - public override ImportMessage BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is ImportMessage) { - return MergeFrom((ImportMessage) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(ImportMessage other) { - if (other == global::Google.ProtocolBuffers.TestProtos.ImportMessage.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasD) { - D = other.D; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_importMessageFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _importMessageFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasD = input.ReadInt32(ref result.d_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasD { - get { return result.hasD; } - } - public int D { - get { return result.D; } - set { SetD(value); } - } - public Builder SetD(int value) { - PrepareBuilder(); - result.hasD = true; - result.d_ = value; - return this; - } - public Builder ClearD() { - PrepareBuilder(); - result.hasD = false; - result.d_ = 0; - return this; - } - } - static ImportMessage() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.UnittestImport.Descriptor, null); - } - } - - #endregion - -} - -#endregion Designer generated code diff --git a/csharp/src/ProtocolBuffersLite.Test/TestProtos/UnittestImportLite.cs b/csharp/src/ProtocolBuffersLite.Test/TestProtos/UnittestImportLite.cs deleted file mode 100644 index 1fee16e0..00000000 --- a/csharp/src/ProtocolBuffersLite.Test/TestProtos/UnittestImportLite.cs +++ /dev/null @@ -1,311 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/protobuf/unittest_import_lite.proto -#pragma warning disable 1591, 0612, 3021 -#region Designer generated code - -using pb = global::Google.ProtocolBuffers; -using pbc = global::Google.ProtocolBuffers.Collections; -using pbd = global::Google.ProtocolBuffers.Descriptors; -using scg = global::System.Collections.Generic; -namespace Google.ProtocolBuffers.TestProtos { - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class UnittestImportLite { - - #region Extension registration - public static void RegisterAllExtensions(pb::ExtensionRegistry registry) { - } - #endregion - #region Static variables - #endregion - #region Extensions - internal static readonly object Descriptor; - static UnittestImportLite() { - Descriptor = null; - } - #endregion - - } - #region Enums - public enum ImportEnumLite { - IMPORT_LITE_FOO = 7, - IMPORT_LITE_BAR = 8, - IMPORT_LITE_BAZ = 9, - } - - #endregion - - #region Messages - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class ImportMessageLite : pb::GeneratedMessageLite { - private ImportMessageLite() { } - private static readonly ImportMessageLite defaultInstance = new ImportMessageLite().MakeReadOnly(); - private static readonly string[] _importMessageLiteFieldNames = new string[] { "d" }; - private static readonly uint[] _importMessageLiteFieldTags = new uint[] { 8 }; - public static ImportMessageLite DefaultInstance { - get { return defaultInstance; } - } - - public override ImportMessageLite DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override ImportMessageLite ThisMessage { - get { return this; } - } - - public const int DFieldNumber = 1; - private bool hasD; - private int d_; - public bool HasD { - get { return hasD; } - } - public int D { - get { return d_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _importMessageLiteFieldNames; - if (hasD) { - output.WriteInt32(1, field_names[0], D); - } - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasD) { - size += pb::CodedOutputStream.ComputeInt32Size(1, D); - } - memoizedSerializedSize = size; - return size; - } - #region Lite runtime methods - public override int GetHashCode() { - int hash = GetType().GetHashCode(); - if (hasD) { - hash ^= d_.GetHashCode(); - } - return hash; - } - - public override bool Equals(object obj) { - ImportMessageLite other = obj as ImportMessageLite; - if (other == null) return false; - if (hasD != other.hasD || (hasD && !d_.Equals(other.d_))) return false; - return true; - } - - public override void PrintTo(global::System.IO.TextWriter writer) { - PrintField("d", hasD, d_, writer); - } - #endregion - - public static ImportMessageLite ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static ImportMessageLite ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static ImportMessageLite ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static ImportMessageLite ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static ImportMessageLite ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static ImportMessageLite ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static ImportMessageLite ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static ImportMessageLite ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static ImportMessageLite ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static ImportMessageLite ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private ImportMessageLite MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(ImportMessageLite prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilderLite { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(ImportMessageLite cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private ImportMessageLite result; - - private ImportMessageLite PrepareBuilder() { - if (resultIsReadOnly) { - ImportMessageLite original = result; - result = new ImportMessageLite(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override ImportMessageLite MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override ImportMessageLite DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.ImportMessageLite.DefaultInstance; } - } - - public override ImportMessageLite BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessageLite other) { - if (other is ImportMessageLite) { - return MergeFrom((ImportMessageLite) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(ImportMessageLite other) { - if (other == global::Google.ProtocolBuffers.TestProtos.ImportMessageLite.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasD) { - D = other.D; - } - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_importMessageLiteFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _importMessageLiteFieldTags[field_ordinal]; - else { - ParseUnknownField(input, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - return this; - } - ParseUnknownField(input, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasD = input.ReadInt32(ref result.d_); - break; - } - } - } - - return this; - } - - - public bool HasD { - get { return result.hasD; } - } - public int D { - get { return result.D; } - set { SetD(value); } - } - public Builder SetD(int value) { - PrepareBuilder(); - result.hasD = true; - result.d_ = value; - return this; - } - public Builder ClearD() { - PrepareBuilder(); - result.hasD = false; - result.d_ = 0; - return this; - } - } - static ImportMessageLite() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.UnittestImportLite.Descriptor, null); - } - } - - #endregion - -} - -#endregion Designer generated code diff --git a/csharp/src/ProtocolBuffersLite.Test/TestProtos/UnittestImportPublic.cs b/csharp/src/ProtocolBuffersLite.Test/TestProtos/UnittestImportPublic.cs deleted file mode 100644 index 4185cac7..00000000 --- a/csharp/src/ProtocolBuffersLite.Test/TestProtos/UnittestImportPublic.cs +++ /dev/null @@ -1,333 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/protobuf/unittest_import_public.proto -#pragma warning disable 1591, 0612, 3021 -#region Designer generated code - -using pb = global::Google.ProtocolBuffers; -using pbc = global::Google.ProtocolBuffers.Collections; -using pbd = global::Google.ProtocolBuffers.Descriptors; -using scg = global::System.Collections.Generic; -namespace Google.ProtocolBuffers.TestProtos { - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class UnittestImportPublic { - - #region Extension registration - public static void RegisterAllExtensions(pb::ExtensionRegistry registry) { - } - #endregion - #region Static variables - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_import_PublicImportMessage__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_import_PublicImportMessage__FieldAccessorTable; - #endregion - #region Descriptor - public static pbd::FileDescriptor Descriptor { - get { return descriptor; } - } - private static pbd::FileDescriptor descriptor; - - static UnittestImportPublic() { - byte[] descriptorData = global::System.Convert.FromBase64String( - string.Concat( - "Cixnb29nbGUvcHJvdG9idWYvdW5pdHRlc3RfaW1wb3J0X3B1YmxpYy5wcm90", - "bxIYcHJvdG9idWZfdW5pdHRlc3RfaW1wb3J0IiAKE1B1YmxpY0ltcG9ydE1l", - "c3NhZ2USCQoBZRgBIAEoBUI+Chhjb20uZ29vZ2xlLnByb3RvYnVmLnRlc3Sq", - "AiFHb29nbGUuUHJvdG9jb2xCdWZmZXJzLlRlc3RQcm90b3M=")); - pbd::FileDescriptor.InternalDescriptorAssigner assigner = delegate(pbd::FileDescriptor root) { - descriptor = root; - internal__static_protobuf_unittest_import_PublicImportMessage__Descriptor = Descriptor.MessageTypes[0]; - internal__static_protobuf_unittest_import_PublicImportMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_import_PublicImportMessage__Descriptor, - new string[] { "E", }); - pb::ExtensionRegistry registry = pb::ExtensionRegistry.CreateInstance(); - RegisterAllExtensions(registry); - return registry; - }; - pbd::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, - new pbd::FileDescriptor[] { - }, assigner); - } - #endregion - - } - #region Messages - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class PublicImportMessage : pb::GeneratedMessage { - private PublicImportMessage() { } - private static readonly PublicImportMessage defaultInstance = new PublicImportMessage().MakeReadOnly(); - private static readonly string[] _publicImportMessageFieldNames = new string[] { "e" }; - private static readonly uint[] _publicImportMessageFieldTags = new uint[] { 8 }; - public static PublicImportMessage DefaultInstance { - get { return defaultInstance; } - } - - public override PublicImportMessage DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override PublicImportMessage ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.UnittestImportPublic.internal__static_protobuf_unittest_import_PublicImportMessage__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.UnittestImportPublic.internal__static_protobuf_unittest_import_PublicImportMessage__FieldAccessorTable; } - } - - public const int EFieldNumber = 1; - private bool hasE; - private int e_; - public bool HasE { - get { return hasE; } - } - public int E { - get { return e_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _publicImportMessageFieldNames; - if (hasE) { - output.WriteInt32(1, field_names[0], E); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasE) { - size += pb::CodedOutputStream.ComputeInt32Size(1, E); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static PublicImportMessage ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static PublicImportMessage ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static PublicImportMessage ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static PublicImportMessage ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static PublicImportMessage ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static PublicImportMessage ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static PublicImportMessage ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static PublicImportMessage ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static PublicImportMessage ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static PublicImportMessage ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private PublicImportMessage MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(PublicImportMessage prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(PublicImportMessage cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private PublicImportMessage result; - - private PublicImportMessage PrepareBuilder() { - if (resultIsReadOnly) { - PublicImportMessage original = result; - result = new PublicImportMessage(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override PublicImportMessage MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.PublicImportMessage.Descriptor; } - } - - public override PublicImportMessage DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.PublicImportMessage.DefaultInstance; } - } - - public override PublicImportMessage BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is PublicImportMessage) { - return MergeFrom((PublicImportMessage) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(PublicImportMessage other) { - if (other == global::Google.ProtocolBuffers.TestProtos.PublicImportMessage.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasE) { - E = other.E; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_publicImportMessageFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _publicImportMessageFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasE = input.ReadInt32(ref result.e_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasE { - get { return result.hasE; } - } - public int E { - get { return result.E; } - set { SetE(value); } - } - public Builder SetE(int value) { - PrepareBuilder(); - result.hasE = true; - result.e_ = value; - return this; - } - public Builder ClearE() { - PrepareBuilder(); - result.hasE = false; - result.e_ = 0; - return this; - } - } - static PublicImportMessage() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.UnittestImportPublic.Descriptor, null); - } - } - - #endregion - -} - -#endregion Designer generated code diff --git a/csharp/src/ProtocolBuffersLite.Test/TestProtos/UnittestImportPublicLite.cs b/csharp/src/ProtocolBuffersLite.Test/TestProtos/UnittestImportPublicLite.cs deleted file mode 100644 index 6dabfcdb..00000000 --- a/csharp/src/ProtocolBuffersLite.Test/TestProtos/UnittestImportPublicLite.cs +++ /dev/null @@ -1,302 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/protobuf/unittest_import_public_lite.proto -#pragma warning disable 1591, 0612, 3021 -#region Designer generated code - -using pb = global::Google.ProtocolBuffers; -using pbc = global::Google.ProtocolBuffers.Collections; -using pbd = global::Google.ProtocolBuffers.Descriptors; -using scg = global::System.Collections.Generic; -namespace Google.ProtocolBuffers.TestProtos { - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class UnittestImportPublicLite { - - #region Extension registration - public static void RegisterAllExtensions(pb::ExtensionRegistry registry) { - } - #endregion - #region Static variables - #endregion - #region Extensions - internal static readonly object Descriptor; - static UnittestImportPublicLite() { - Descriptor = null; - } - #endregion - - } - #region Messages - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class PublicImportMessageLite : pb::GeneratedMessageLite { - private PublicImportMessageLite() { } - private static readonly PublicImportMessageLite defaultInstance = new PublicImportMessageLite().MakeReadOnly(); - private static readonly string[] _publicImportMessageLiteFieldNames = new string[] { "e" }; - private static readonly uint[] _publicImportMessageLiteFieldTags = new uint[] { 8 }; - public static PublicImportMessageLite DefaultInstance { - get { return defaultInstance; } - } - - public override PublicImportMessageLite DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override PublicImportMessageLite ThisMessage { - get { return this; } - } - - public const int EFieldNumber = 1; - private bool hasE; - private int e_; - public bool HasE { - get { return hasE; } - } - public int E { - get { return e_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _publicImportMessageLiteFieldNames; - if (hasE) { - output.WriteInt32(1, field_names[0], E); - } - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasE) { - size += pb::CodedOutputStream.ComputeInt32Size(1, E); - } - memoizedSerializedSize = size; - return size; - } - #region Lite runtime methods - public override int GetHashCode() { - int hash = GetType().GetHashCode(); - if (hasE) { - hash ^= e_.GetHashCode(); - } - return hash; - } - - public override bool Equals(object obj) { - PublicImportMessageLite other = obj as PublicImportMessageLite; - if (other == null) return false; - if (hasE != other.hasE || (hasE && !e_.Equals(other.e_))) return false; - return true; - } - - public override void PrintTo(global::System.IO.TextWriter writer) { - PrintField("e", hasE, e_, writer); - } - #endregion - - public static PublicImportMessageLite ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static PublicImportMessageLite ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static PublicImportMessageLite ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static PublicImportMessageLite ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static PublicImportMessageLite ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static PublicImportMessageLite ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static PublicImportMessageLite ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static PublicImportMessageLite ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static PublicImportMessageLite ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static PublicImportMessageLite ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private PublicImportMessageLite MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(PublicImportMessageLite prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilderLite { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(PublicImportMessageLite cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private PublicImportMessageLite result; - - private PublicImportMessageLite PrepareBuilder() { - if (resultIsReadOnly) { - PublicImportMessageLite original = result; - result = new PublicImportMessageLite(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override PublicImportMessageLite MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override PublicImportMessageLite DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.PublicImportMessageLite.DefaultInstance; } - } - - public override PublicImportMessageLite BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessageLite other) { - if (other is PublicImportMessageLite) { - return MergeFrom((PublicImportMessageLite) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(PublicImportMessageLite other) { - if (other == global::Google.ProtocolBuffers.TestProtos.PublicImportMessageLite.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasE) { - E = other.E; - } - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_publicImportMessageLiteFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _publicImportMessageLiteFieldTags[field_ordinal]; - else { - ParseUnknownField(input, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - return this; - } - ParseUnknownField(input, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasE = input.ReadInt32(ref result.e_); - break; - } - } - } - - return this; - } - - - public bool HasE { - get { return result.hasE; } - } - public int E { - get { return result.E; } - set { SetE(value); } - } - public Builder SetE(int value) { - PrepareBuilder(); - result.hasE = true; - result.e_ = value; - return this; - } - public Builder ClearE() { - PrepareBuilder(); - result.hasE = false; - result.e_ = 0; - return this; - } - } - static PublicImportMessageLite() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.UnittestImportPublicLite.Descriptor, null); - } - } - - #endregion - -} - -#endregion Designer generated code diff --git a/csharp/src/ProtocolBuffersLite.Test/TestProtos/UnittestLite.cs b/csharp/src/ProtocolBuffersLite.Test/TestProtos/UnittestLite.cs deleted file mode 100644 index bf0da956..00000000 --- a/csharp/src/ProtocolBuffersLite.Test/TestProtos/UnittestLite.cs +++ /dev/null @@ -1,12493 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/protobuf/unittest_lite.proto -#pragma warning disable 1591, 0612, 3021 -#region Designer generated code - -using pb = global::Google.ProtocolBuffers; -using pbc = global::Google.ProtocolBuffers.Collections; -using pbd = global::Google.ProtocolBuffers.Descriptors; -using scg = global::System.Collections.Generic; -namespace Google.ProtocolBuffers.TestProtos { - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class UnittestLite { - - #region Extension registration - public static void RegisterAllExtensions(pb::ExtensionRegistry registry) { - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalInt32ExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalInt64ExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalUint32ExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalUint64ExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalSint32ExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalSint64ExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalFixed32ExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalFixed64ExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalSfixed32ExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalSfixed64ExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalFloatExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalDoubleExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalBoolExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalStringExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalBytesExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalGroupExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalNestedMessageExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalForeignMessageExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalImportMessageExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalNestedEnumExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalForeignEnumExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalImportEnumExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalStringPieceExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalCordExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalPublicImportMessageExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalLazyMessageExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedInt32ExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedInt64ExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedUint32ExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedUint64ExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedSint32ExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedSint64ExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedFixed32ExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedFixed64ExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedSfixed32ExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedSfixed64ExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedFloatExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedDoubleExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedBoolExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedStringExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedBytesExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedGroupExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedNestedMessageExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedForeignMessageExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedImportMessageExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedNestedEnumExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedForeignEnumExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedImportEnumExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedStringPieceExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedCordExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedLazyMessageExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultInt32ExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultInt64ExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultUint32ExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultUint64ExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultSint32ExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultSint64ExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultFixed32ExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultFixed64ExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultSfixed32ExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultSfixed64ExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultFloatExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultDoubleExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultBoolExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultStringExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultBytesExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultNestedEnumExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultForeignEnumExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultImportEnumExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultStringPieceExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultCordExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.OneofUint32ExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.OneofNestedMessageExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.OneofStringExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.OneofBytesExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.PackedInt32ExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.PackedInt64ExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.PackedUint32ExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.PackedUint64ExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.PackedSint32ExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.PackedSint64ExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.PackedFixed32ExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.PackedFixed64ExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.PackedSfixed32ExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.PackedSfixed64ExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.PackedFloatExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.PackedDoubleExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.PackedBoolExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.UnittestLite.PackedEnumExtensionLite); - registry.Add(global::Google.ProtocolBuffers.TestProtos.TestNestedExtensionLite.NestedExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.OptionalExt); - registry.Add(global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.RepeatedExt); - } - #endregion - #region Extensions - public const int OptionalInt32ExtensionLiteFieldNumber = 1; - public static pb::GeneratedExtensionLite OptionalInt32ExtensionLite; - public const int OptionalInt64ExtensionLiteFieldNumber = 2; - public static pb::GeneratedExtensionLite OptionalInt64ExtensionLite; - public const int OptionalUint32ExtensionLiteFieldNumber = 3; - public static pb::GeneratedExtensionLite OptionalUint32ExtensionLite; - public const int OptionalUint64ExtensionLiteFieldNumber = 4; - public static pb::GeneratedExtensionLite OptionalUint64ExtensionLite; - public const int OptionalSint32ExtensionLiteFieldNumber = 5; - public static pb::GeneratedExtensionLite OptionalSint32ExtensionLite; - public const int OptionalSint64ExtensionLiteFieldNumber = 6; - public static pb::GeneratedExtensionLite OptionalSint64ExtensionLite; - public const int OptionalFixed32ExtensionLiteFieldNumber = 7; - public static pb::GeneratedExtensionLite OptionalFixed32ExtensionLite; - public const int OptionalFixed64ExtensionLiteFieldNumber = 8; - public static pb::GeneratedExtensionLite OptionalFixed64ExtensionLite; - public const int OptionalSfixed32ExtensionLiteFieldNumber = 9; - public static pb::GeneratedExtensionLite OptionalSfixed32ExtensionLite; - public const int OptionalSfixed64ExtensionLiteFieldNumber = 10; - public static pb::GeneratedExtensionLite OptionalSfixed64ExtensionLite; - public const int OptionalFloatExtensionLiteFieldNumber = 11; - public static pb::GeneratedExtensionLite OptionalFloatExtensionLite; - public const int OptionalDoubleExtensionLiteFieldNumber = 12; - public static pb::GeneratedExtensionLite OptionalDoubleExtensionLite; - public const int OptionalBoolExtensionLiteFieldNumber = 13; - public static pb::GeneratedExtensionLite OptionalBoolExtensionLite; - public const int OptionalStringExtensionLiteFieldNumber = 14; - public static pb::GeneratedExtensionLite OptionalStringExtensionLite; - public const int OptionalBytesExtensionLiteFieldNumber = 15; - public static pb::GeneratedExtensionLite OptionalBytesExtensionLite; - public const int OptionalGroupExtensionLiteFieldNumber = 16; - public static pb::GeneratedExtensionLite OptionalGroupExtensionLite; - public const int OptionalNestedMessageExtensionLiteFieldNumber = 18; - public static pb::GeneratedExtensionLite OptionalNestedMessageExtensionLite; - public const int OptionalForeignMessageExtensionLiteFieldNumber = 19; - public static pb::GeneratedExtensionLite OptionalForeignMessageExtensionLite; - public const int OptionalImportMessageExtensionLiteFieldNumber = 20; - public static pb::GeneratedExtensionLite OptionalImportMessageExtensionLite; - public const int OptionalNestedEnumExtensionLiteFieldNumber = 21; - public static pb::GeneratedExtensionLite OptionalNestedEnumExtensionLite; - public const int OptionalForeignEnumExtensionLiteFieldNumber = 22; - public static pb::GeneratedExtensionLite OptionalForeignEnumExtensionLite; - public const int OptionalImportEnumExtensionLiteFieldNumber = 23; - public static pb::GeneratedExtensionLite OptionalImportEnumExtensionLite; - public const int OptionalStringPieceExtensionLiteFieldNumber = 24; - public static pb::GeneratedExtensionLite OptionalStringPieceExtensionLite; - public const int OptionalCordExtensionLiteFieldNumber = 25; - public static pb::GeneratedExtensionLite OptionalCordExtensionLite; - public const int OptionalPublicImportMessageExtensionLiteFieldNumber = 26; - public static pb::GeneratedExtensionLite OptionalPublicImportMessageExtensionLite; - public const int OptionalLazyMessageExtensionLiteFieldNumber = 27; - public static pb::GeneratedExtensionLite OptionalLazyMessageExtensionLite; - public const int RepeatedInt32ExtensionLiteFieldNumber = 31; - public static pb::GeneratedRepeatExtensionLite RepeatedInt32ExtensionLite; - public const int RepeatedInt64ExtensionLiteFieldNumber = 32; - public static pb::GeneratedRepeatExtensionLite RepeatedInt64ExtensionLite; - public const int RepeatedUint32ExtensionLiteFieldNumber = 33; - public static pb::GeneratedRepeatExtensionLite RepeatedUint32ExtensionLite; - public const int RepeatedUint64ExtensionLiteFieldNumber = 34; - public static pb::GeneratedRepeatExtensionLite RepeatedUint64ExtensionLite; - public const int RepeatedSint32ExtensionLiteFieldNumber = 35; - public static pb::GeneratedRepeatExtensionLite RepeatedSint32ExtensionLite; - public const int RepeatedSint64ExtensionLiteFieldNumber = 36; - public static pb::GeneratedRepeatExtensionLite RepeatedSint64ExtensionLite; - public const int RepeatedFixed32ExtensionLiteFieldNumber = 37; - public static pb::GeneratedRepeatExtensionLite RepeatedFixed32ExtensionLite; - public const int RepeatedFixed64ExtensionLiteFieldNumber = 38; - public static pb::GeneratedRepeatExtensionLite RepeatedFixed64ExtensionLite; - public const int RepeatedSfixed32ExtensionLiteFieldNumber = 39; - public static pb::GeneratedRepeatExtensionLite RepeatedSfixed32ExtensionLite; - public const int RepeatedSfixed64ExtensionLiteFieldNumber = 40; - public static pb::GeneratedRepeatExtensionLite RepeatedSfixed64ExtensionLite; - public const int RepeatedFloatExtensionLiteFieldNumber = 41; - public static pb::GeneratedRepeatExtensionLite RepeatedFloatExtensionLite; - public const int RepeatedDoubleExtensionLiteFieldNumber = 42; - public static pb::GeneratedRepeatExtensionLite RepeatedDoubleExtensionLite; - public const int RepeatedBoolExtensionLiteFieldNumber = 43; - public static pb::GeneratedRepeatExtensionLite RepeatedBoolExtensionLite; - public const int RepeatedStringExtensionLiteFieldNumber = 44; - public static pb::GeneratedRepeatExtensionLite RepeatedStringExtensionLite; - public const int RepeatedBytesExtensionLiteFieldNumber = 45; - public static pb::GeneratedRepeatExtensionLite RepeatedBytesExtensionLite; - public const int RepeatedGroupExtensionLiteFieldNumber = 46; - public static pb::GeneratedRepeatExtensionLite RepeatedGroupExtensionLite; - public const int RepeatedNestedMessageExtensionLiteFieldNumber = 48; - public static pb::GeneratedRepeatExtensionLite RepeatedNestedMessageExtensionLite; - public const int RepeatedForeignMessageExtensionLiteFieldNumber = 49; - public static pb::GeneratedRepeatExtensionLite RepeatedForeignMessageExtensionLite; - public const int RepeatedImportMessageExtensionLiteFieldNumber = 50; - public static pb::GeneratedRepeatExtensionLite RepeatedImportMessageExtensionLite; - public const int RepeatedNestedEnumExtensionLiteFieldNumber = 51; - public static pb::GeneratedRepeatExtensionLite RepeatedNestedEnumExtensionLite; - public const int RepeatedForeignEnumExtensionLiteFieldNumber = 52; - public static pb::GeneratedRepeatExtensionLite RepeatedForeignEnumExtensionLite; - public const int RepeatedImportEnumExtensionLiteFieldNumber = 53; - public static pb::GeneratedRepeatExtensionLite RepeatedImportEnumExtensionLite; - public const int RepeatedStringPieceExtensionLiteFieldNumber = 54; - public static pb::GeneratedRepeatExtensionLite RepeatedStringPieceExtensionLite; - public const int RepeatedCordExtensionLiteFieldNumber = 55; - public static pb::GeneratedRepeatExtensionLite RepeatedCordExtensionLite; - public const int RepeatedLazyMessageExtensionLiteFieldNumber = 57; - public static pb::GeneratedRepeatExtensionLite RepeatedLazyMessageExtensionLite; - public const int DefaultInt32ExtensionLiteFieldNumber = 61; - public static pb::GeneratedExtensionLite DefaultInt32ExtensionLite; - public const int DefaultInt64ExtensionLiteFieldNumber = 62; - public static pb::GeneratedExtensionLite DefaultInt64ExtensionLite; - public const int DefaultUint32ExtensionLiteFieldNumber = 63; - public static pb::GeneratedExtensionLite DefaultUint32ExtensionLite; - public const int DefaultUint64ExtensionLiteFieldNumber = 64; - public static pb::GeneratedExtensionLite DefaultUint64ExtensionLite; - public const int DefaultSint32ExtensionLiteFieldNumber = 65; - public static pb::GeneratedExtensionLite DefaultSint32ExtensionLite; - public const int DefaultSint64ExtensionLiteFieldNumber = 66; - public static pb::GeneratedExtensionLite DefaultSint64ExtensionLite; - public const int DefaultFixed32ExtensionLiteFieldNumber = 67; - public static pb::GeneratedExtensionLite DefaultFixed32ExtensionLite; - public const int DefaultFixed64ExtensionLiteFieldNumber = 68; - public static pb::GeneratedExtensionLite DefaultFixed64ExtensionLite; - public const int DefaultSfixed32ExtensionLiteFieldNumber = 69; - public static pb::GeneratedExtensionLite DefaultSfixed32ExtensionLite; - public const int DefaultSfixed64ExtensionLiteFieldNumber = 70; - public static pb::GeneratedExtensionLite DefaultSfixed64ExtensionLite; - public const int DefaultFloatExtensionLiteFieldNumber = 71; - public static pb::GeneratedExtensionLite DefaultFloatExtensionLite; - public const int DefaultDoubleExtensionLiteFieldNumber = 72; - public static pb::GeneratedExtensionLite DefaultDoubleExtensionLite; - public const int DefaultBoolExtensionLiteFieldNumber = 73; - public static pb::GeneratedExtensionLite DefaultBoolExtensionLite; - public const int DefaultStringExtensionLiteFieldNumber = 74; - public static pb::GeneratedExtensionLite DefaultStringExtensionLite; - public const int DefaultBytesExtensionLiteFieldNumber = 75; - public static pb::GeneratedExtensionLite DefaultBytesExtensionLite; - public const int DefaultNestedEnumExtensionLiteFieldNumber = 81; - public static pb::GeneratedExtensionLite DefaultNestedEnumExtensionLite; - public const int DefaultForeignEnumExtensionLiteFieldNumber = 82; - public static pb::GeneratedExtensionLite DefaultForeignEnumExtensionLite; - public const int DefaultImportEnumExtensionLiteFieldNumber = 83; - public static pb::GeneratedExtensionLite DefaultImportEnumExtensionLite; - public const int DefaultStringPieceExtensionLiteFieldNumber = 84; - public static pb::GeneratedExtensionLite DefaultStringPieceExtensionLite; - public const int DefaultCordExtensionLiteFieldNumber = 85; - public static pb::GeneratedExtensionLite DefaultCordExtensionLite; - public const int OneofUint32ExtensionLiteFieldNumber = 111; - public static pb::GeneratedExtensionLite OneofUint32ExtensionLite; - public const int OneofNestedMessageExtensionLiteFieldNumber = 112; - public static pb::GeneratedExtensionLite OneofNestedMessageExtensionLite; - public const int OneofStringExtensionLiteFieldNumber = 113; - public static pb::GeneratedExtensionLite OneofStringExtensionLite; - public const int OneofBytesExtensionLiteFieldNumber = 114; - public static pb::GeneratedExtensionLite OneofBytesExtensionLite; - public const int PackedInt32ExtensionLiteFieldNumber = 90; - public static pb::GeneratedRepeatExtensionLite PackedInt32ExtensionLite; - public const int PackedInt64ExtensionLiteFieldNumber = 91; - public static pb::GeneratedRepeatExtensionLite PackedInt64ExtensionLite; - public const int PackedUint32ExtensionLiteFieldNumber = 92; - public static pb::GeneratedRepeatExtensionLite PackedUint32ExtensionLite; - public const int PackedUint64ExtensionLiteFieldNumber = 93; - public static pb::GeneratedRepeatExtensionLite PackedUint64ExtensionLite; - public const int PackedSint32ExtensionLiteFieldNumber = 94; - public static pb::GeneratedRepeatExtensionLite PackedSint32ExtensionLite; - public const int PackedSint64ExtensionLiteFieldNumber = 95; - public static pb::GeneratedRepeatExtensionLite PackedSint64ExtensionLite; - public const int PackedFixed32ExtensionLiteFieldNumber = 96; - public static pb::GeneratedRepeatExtensionLite PackedFixed32ExtensionLite; - public const int PackedFixed64ExtensionLiteFieldNumber = 97; - public static pb::GeneratedRepeatExtensionLite PackedFixed64ExtensionLite; - public const int PackedSfixed32ExtensionLiteFieldNumber = 98; - public static pb::GeneratedRepeatExtensionLite PackedSfixed32ExtensionLite; - public const int PackedSfixed64ExtensionLiteFieldNumber = 99; - public static pb::GeneratedRepeatExtensionLite PackedSfixed64ExtensionLite; - public const int PackedFloatExtensionLiteFieldNumber = 100; - public static pb::GeneratedRepeatExtensionLite PackedFloatExtensionLite; - public const int PackedDoubleExtensionLiteFieldNumber = 101; - public static pb::GeneratedRepeatExtensionLite PackedDoubleExtensionLite; - public const int PackedBoolExtensionLiteFieldNumber = 102; - public static pb::GeneratedRepeatExtensionLite PackedBoolExtensionLite; - public const int PackedEnumExtensionLiteFieldNumber = 103; - public static pb::GeneratedRepeatExtensionLite PackedEnumExtensionLite; - #endregion - - #region Static variables - #endregion - #region Extensions - internal static readonly object Descriptor; - static UnittestLite() { - Descriptor = null; - global::Google.ProtocolBuffers.TestProtos.TestNestedExtensionLite.NestedExtension = - new pb::GeneratedExtensionLite( - "protobuf_unittest.TestNestedExtensionLite.nested_extension", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - default(int), - null, - null, - global::Google.ProtocolBuffers.TestProtos.TestNestedExtensionLite.NestedExtensionFieldNumber, - pbd::FieldType.Int32); - global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.OptionalExt = - new pb::GeneratedExtensionLite( - "protobuf_unittest.TestParsingMergeLite.optional_ext", - global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.DefaultInstance, - null, - global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.DefaultInstance, - null, - global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.OptionalExtFieldNumber, - pbd::FieldType.Message); - global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.RepeatedExt = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest.TestParsingMergeLite.repeated_ext", - global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.DefaultInstance, - global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.DefaultInstance, - null, - global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.RepeatedExtFieldNumber, - pbd::FieldType.Message, - false); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalInt32ExtensionLite = - new pb::GeneratedExtensionLite( - "protobuf_unittest.optional_int32_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - default(int), - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalInt32ExtensionLiteFieldNumber, - pbd::FieldType.Int32); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalInt64ExtensionLite = - new pb::GeneratedExtensionLite( - "protobuf_unittest.optional_int64_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - default(long), - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalInt64ExtensionLiteFieldNumber, - pbd::FieldType.Int64); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalUint32ExtensionLite = - new pb::GeneratedExtensionLite( - "protobuf_unittest.optional_uint32_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - default(uint), - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalUint32ExtensionLiteFieldNumber, - pbd::FieldType.UInt32); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalUint64ExtensionLite = - new pb::GeneratedExtensionLite( - "protobuf_unittest.optional_uint64_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - default(ulong), - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalUint64ExtensionLiteFieldNumber, - pbd::FieldType.UInt64); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalSint32ExtensionLite = - new pb::GeneratedExtensionLite( - "protobuf_unittest.optional_sint32_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - default(int), - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalSint32ExtensionLiteFieldNumber, - pbd::FieldType.SInt32); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalSint64ExtensionLite = - new pb::GeneratedExtensionLite( - "protobuf_unittest.optional_sint64_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - default(long), - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalSint64ExtensionLiteFieldNumber, - pbd::FieldType.SInt64); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalFixed32ExtensionLite = - new pb::GeneratedExtensionLite( - "protobuf_unittest.optional_fixed32_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - default(uint), - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalFixed32ExtensionLiteFieldNumber, - pbd::FieldType.Fixed32); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalFixed64ExtensionLite = - new pb::GeneratedExtensionLite( - "protobuf_unittest.optional_fixed64_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - default(ulong), - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalFixed64ExtensionLiteFieldNumber, - pbd::FieldType.Fixed64); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalSfixed32ExtensionLite = - new pb::GeneratedExtensionLite( - "protobuf_unittest.optional_sfixed32_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - default(int), - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalSfixed32ExtensionLiteFieldNumber, - pbd::FieldType.SFixed32); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalSfixed64ExtensionLite = - new pb::GeneratedExtensionLite( - "protobuf_unittest.optional_sfixed64_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - default(long), - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalSfixed64ExtensionLiteFieldNumber, - pbd::FieldType.SFixed64); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalFloatExtensionLite = - new pb::GeneratedExtensionLite( - "protobuf_unittest.optional_float_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - default(float), - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalFloatExtensionLiteFieldNumber, - pbd::FieldType.Float); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalDoubleExtensionLite = - new pb::GeneratedExtensionLite( - "protobuf_unittest.optional_double_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - default(double), - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalDoubleExtensionLiteFieldNumber, - pbd::FieldType.Double); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalBoolExtensionLite = - new pb::GeneratedExtensionLite( - "protobuf_unittest.optional_bool_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - default(bool), - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalBoolExtensionLiteFieldNumber, - pbd::FieldType.Bool); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalStringExtensionLite = - new pb::GeneratedExtensionLite( - "protobuf_unittest.optional_string_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - null, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalStringExtensionLiteFieldNumber, - pbd::FieldType.String); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalBytesExtensionLite = - new pb::GeneratedExtensionLite( - "protobuf_unittest.optional_bytes_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - null, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalBytesExtensionLiteFieldNumber, - pbd::FieldType.Bytes); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalGroupExtensionLite = - new pb::GeneratedExtensionLite( - "protobuf_unittest.optionalgroup_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - null, - global::Google.ProtocolBuffers.TestProtos.OptionalGroup_extension_lite.DefaultInstance, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalGroupExtensionLiteFieldNumber, - pbd::FieldType.Group); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalNestedMessageExtensionLite = - new pb::GeneratedExtensionLite( - "protobuf_unittest.optional_nested_message_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - null, - global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage.DefaultInstance, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalNestedMessageExtensionLiteFieldNumber, - pbd::FieldType.Message); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalForeignMessageExtensionLite = - new pb::GeneratedExtensionLite( - "protobuf_unittest.optional_foreign_message_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - null, - global::Google.ProtocolBuffers.TestProtos.ForeignMessageLite.DefaultInstance, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalForeignMessageExtensionLiteFieldNumber, - pbd::FieldType.Message); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalImportMessageExtensionLite = - new pb::GeneratedExtensionLite( - "protobuf_unittest.optional_import_message_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - null, - global::Google.ProtocolBuffers.TestProtos.ImportMessageLite.DefaultInstance, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalImportMessageExtensionLiteFieldNumber, - pbd::FieldType.Message); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalNestedEnumExtensionLite = - new pb::GeneratedExtensionLite( - "protobuf_unittest.optional_nested_enum_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - default(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedEnum), - null, - new EnumLiteMap(), - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalNestedEnumExtensionLiteFieldNumber, - pbd::FieldType.Enum); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalForeignEnumExtensionLite = - new pb::GeneratedExtensionLite( - "protobuf_unittest.optional_foreign_enum_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - default(global::Google.ProtocolBuffers.TestProtos.ForeignEnumLite), - null, - new EnumLiteMap(), - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalForeignEnumExtensionLiteFieldNumber, - pbd::FieldType.Enum); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalImportEnumExtensionLite = - new pb::GeneratedExtensionLite( - "protobuf_unittest.optional_import_enum_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - default(global::Google.ProtocolBuffers.TestProtos.ImportEnumLite), - null, - new EnumLiteMap(), - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalImportEnumExtensionLiteFieldNumber, - pbd::FieldType.Enum); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalStringPieceExtensionLite = - new pb::GeneratedExtensionLite( - "protobuf_unittest.optional_string_piece_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - null, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalStringPieceExtensionLiteFieldNumber, - pbd::FieldType.String); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalCordExtensionLite = - new pb::GeneratedExtensionLite( - "protobuf_unittest.optional_cord_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - null, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalCordExtensionLiteFieldNumber, - pbd::FieldType.String); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalPublicImportMessageExtensionLite = - new pb::GeneratedExtensionLite( - "protobuf_unittest.optional_public_import_message_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - null, - global::Google.ProtocolBuffers.TestProtos.PublicImportMessageLite.DefaultInstance, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalPublicImportMessageExtensionLiteFieldNumber, - pbd::FieldType.Message); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalLazyMessageExtensionLite = - new pb::GeneratedExtensionLite( - "protobuf_unittest.optional_lazy_message_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - null, - global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage.DefaultInstance, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OptionalLazyMessageExtensionLiteFieldNumber, - pbd::FieldType.Message); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedInt32ExtensionLite = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest.repeated_int32_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedInt32ExtensionLiteFieldNumber, - pbd::FieldType.Int32, - false); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedInt64ExtensionLite = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest.repeated_int64_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedInt64ExtensionLiteFieldNumber, - pbd::FieldType.Int64, - false); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedUint32ExtensionLite = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest.repeated_uint32_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedUint32ExtensionLiteFieldNumber, - pbd::FieldType.UInt32, - false); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedUint64ExtensionLite = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest.repeated_uint64_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedUint64ExtensionLiteFieldNumber, - pbd::FieldType.UInt64, - false); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedSint32ExtensionLite = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest.repeated_sint32_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedSint32ExtensionLiteFieldNumber, - pbd::FieldType.SInt32, - false); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedSint64ExtensionLite = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest.repeated_sint64_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedSint64ExtensionLiteFieldNumber, - pbd::FieldType.SInt64, - false); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedFixed32ExtensionLite = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest.repeated_fixed32_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedFixed32ExtensionLiteFieldNumber, - pbd::FieldType.Fixed32, - false); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedFixed64ExtensionLite = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest.repeated_fixed64_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedFixed64ExtensionLiteFieldNumber, - pbd::FieldType.Fixed64, - false); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedSfixed32ExtensionLite = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest.repeated_sfixed32_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedSfixed32ExtensionLiteFieldNumber, - pbd::FieldType.SFixed32, - false); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedSfixed64ExtensionLite = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest.repeated_sfixed64_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedSfixed64ExtensionLiteFieldNumber, - pbd::FieldType.SFixed64, - false); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedFloatExtensionLite = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest.repeated_float_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedFloatExtensionLiteFieldNumber, - pbd::FieldType.Float, - false); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedDoubleExtensionLite = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest.repeated_double_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedDoubleExtensionLiteFieldNumber, - pbd::FieldType.Double, - false); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedBoolExtensionLite = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest.repeated_bool_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedBoolExtensionLiteFieldNumber, - pbd::FieldType.Bool, - false); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedStringExtensionLite = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest.repeated_string_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedStringExtensionLiteFieldNumber, - pbd::FieldType.String, - false); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedBytesExtensionLite = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest.repeated_bytes_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedBytesExtensionLiteFieldNumber, - pbd::FieldType.Bytes, - false); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedGroupExtensionLite = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest.repeatedgroup_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - global::Google.ProtocolBuffers.TestProtos.RepeatedGroup_extension_lite.DefaultInstance, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedGroupExtensionLiteFieldNumber, - pbd::FieldType.Group, - false); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedNestedMessageExtensionLite = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest.repeated_nested_message_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage.DefaultInstance, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedNestedMessageExtensionLiteFieldNumber, - pbd::FieldType.Message, - false); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedForeignMessageExtensionLite = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest.repeated_foreign_message_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - global::Google.ProtocolBuffers.TestProtos.ForeignMessageLite.DefaultInstance, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedForeignMessageExtensionLiteFieldNumber, - pbd::FieldType.Message, - false); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedImportMessageExtensionLite = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest.repeated_import_message_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - global::Google.ProtocolBuffers.TestProtos.ImportMessageLite.DefaultInstance, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedImportMessageExtensionLiteFieldNumber, - pbd::FieldType.Message, - false); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedNestedEnumExtensionLite = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest.repeated_nested_enum_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - null, - new EnumLiteMap(), - global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedNestedEnumExtensionLiteFieldNumber, - pbd::FieldType.Enum, - false); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedForeignEnumExtensionLite = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest.repeated_foreign_enum_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - null, - new EnumLiteMap(), - global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedForeignEnumExtensionLiteFieldNumber, - pbd::FieldType.Enum, - false); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedImportEnumExtensionLite = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest.repeated_import_enum_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - null, - new EnumLiteMap(), - global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedImportEnumExtensionLiteFieldNumber, - pbd::FieldType.Enum, - false); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedStringPieceExtensionLite = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest.repeated_string_piece_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedStringPieceExtensionLiteFieldNumber, - pbd::FieldType.String, - false); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedCordExtensionLite = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest.repeated_cord_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedCordExtensionLiteFieldNumber, - pbd::FieldType.String, - false); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedLazyMessageExtensionLite = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest.repeated_lazy_message_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage.DefaultInstance, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.RepeatedLazyMessageExtensionLiteFieldNumber, - pbd::FieldType.Message, - false); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultInt32ExtensionLite = - new pb::GeneratedExtensionLite( - "protobuf_unittest.default_int32_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - 41, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultInt32ExtensionLiteFieldNumber, - pbd::FieldType.Int32); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultInt64ExtensionLite = - new pb::GeneratedExtensionLite( - "protobuf_unittest.default_int64_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - 42L, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultInt64ExtensionLiteFieldNumber, - pbd::FieldType.Int64); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultUint32ExtensionLite = - new pb::GeneratedExtensionLite( - "protobuf_unittest.default_uint32_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - 43, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultUint32ExtensionLiteFieldNumber, - pbd::FieldType.UInt32); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultUint64ExtensionLite = - new pb::GeneratedExtensionLite( - "protobuf_unittest.default_uint64_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - 44UL, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultUint64ExtensionLiteFieldNumber, - pbd::FieldType.UInt64); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultSint32ExtensionLite = - new pb::GeneratedExtensionLite( - "protobuf_unittest.default_sint32_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - -45, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultSint32ExtensionLiteFieldNumber, - pbd::FieldType.SInt32); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultSint64ExtensionLite = - new pb::GeneratedExtensionLite( - "protobuf_unittest.default_sint64_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - 46L, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultSint64ExtensionLiteFieldNumber, - pbd::FieldType.SInt64); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultFixed32ExtensionLite = - new pb::GeneratedExtensionLite( - "protobuf_unittest.default_fixed32_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - 47, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultFixed32ExtensionLiteFieldNumber, - pbd::FieldType.Fixed32); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultFixed64ExtensionLite = - new pb::GeneratedExtensionLite( - "protobuf_unittest.default_fixed64_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - 48UL, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultFixed64ExtensionLiteFieldNumber, - pbd::FieldType.Fixed64); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultSfixed32ExtensionLite = - new pb::GeneratedExtensionLite( - "protobuf_unittest.default_sfixed32_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - 49, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultSfixed32ExtensionLiteFieldNumber, - pbd::FieldType.SFixed32); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultSfixed64ExtensionLite = - new pb::GeneratedExtensionLite( - "protobuf_unittest.default_sfixed64_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - -50L, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultSfixed64ExtensionLiteFieldNumber, - pbd::FieldType.SFixed64); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultFloatExtensionLite = - new pb::GeneratedExtensionLite( - "protobuf_unittest.default_float_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - 51.5F, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultFloatExtensionLiteFieldNumber, - pbd::FieldType.Float); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultDoubleExtensionLite = - new pb::GeneratedExtensionLite( - "protobuf_unittest.default_double_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - 52000D, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultDoubleExtensionLiteFieldNumber, - pbd::FieldType.Double); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultBoolExtensionLite = - new pb::GeneratedExtensionLite( - "protobuf_unittest.default_bool_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - true, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultBoolExtensionLiteFieldNumber, - pbd::FieldType.Bool); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultStringExtensionLite = - new pb::GeneratedExtensionLite( - "protobuf_unittest.default_string_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - "hello", - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultStringExtensionLiteFieldNumber, - pbd::FieldType.String); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultBytesExtensionLite = - new pb::GeneratedExtensionLite( - "protobuf_unittest.default_bytes_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - pb::ByteString.FromBase64("d29ybGQ="), - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultBytesExtensionLiteFieldNumber, - pbd::FieldType.Bytes); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultNestedEnumExtensionLite = - new pb::GeneratedExtensionLite( - "protobuf_unittest.default_nested_enum_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedEnum.BAR, - null, - new EnumLiteMap(), - global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultNestedEnumExtensionLiteFieldNumber, - pbd::FieldType.Enum); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultForeignEnumExtensionLite = - new pb::GeneratedExtensionLite( - "protobuf_unittest.default_foreign_enum_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - global::Google.ProtocolBuffers.TestProtos.ForeignEnumLite.FOREIGN_LITE_BAR, - null, - new EnumLiteMap(), - global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultForeignEnumExtensionLiteFieldNumber, - pbd::FieldType.Enum); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultImportEnumExtensionLite = - new pb::GeneratedExtensionLite( - "protobuf_unittest.default_import_enum_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - global::Google.ProtocolBuffers.TestProtos.ImportEnumLite.IMPORT_LITE_BAR, - null, - new EnumLiteMap(), - global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultImportEnumExtensionLiteFieldNumber, - pbd::FieldType.Enum); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultStringPieceExtensionLite = - new pb::GeneratedExtensionLite( - "protobuf_unittest.default_string_piece_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - "abc", - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultStringPieceExtensionLiteFieldNumber, - pbd::FieldType.String); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultCordExtensionLite = - new pb::GeneratedExtensionLite( - "protobuf_unittest.default_cord_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - "123", - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.DefaultCordExtensionLiteFieldNumber, - pbd::FieldType.String); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OneofUint32ExtensionLite = - new pb::GeneratedExtensionLite( - "protobuf_unittest.oneof_uint32_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - default(uint), - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OneofUint32ExtensionLiteFieldNumber, - pbd::FieldType.UInt32); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OneofNestedMessageExtensionLite = - new pb::GeneratedExtensionLite( - "protobuf_unittest.oneof_nested_message_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - null, - global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage.DefaultInstance, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OneofNestedMessageExtensionLiteFieldNumber, - pbd::FieldType.Message); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OneofStringExtensionLite = - new pb::GeneratedExtensionLite( - "protobuf_unittest.oneof_string_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - null, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OneofStringExtensionLiteFieldNumber, - pbd::FieldType.String); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OneofBytesExtensionLite = - new pb::GeneratedExtensionLite( - "protobuf_unittest.oneof_bytes_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance, - null, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.OneofBytesExtensionLiteFieldNumber, - pbd::FieldType.Bytes); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.PackedInt32ExtensionLite = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest.packed_int32_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestPackedExtensionsLite.DefaultInstance, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.PackedInt32ExtensionLiteFieldNumber, - pbd::FieldType.Int32, - true); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.PackedInt64ExtensionLite = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest.packed_int64_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestPackedExtensionsLite.DefaultInstance, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.PackedInt64ExtensionLiteFieldNumber, - pbd::FieldType.Int64, - true); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.PackedUint32ExtensionLite = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest.packed_uint32_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestPackedExtensionsLite.DefaultInstance, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.PackedUint32ExtensionLiteFieldNumber, - pbd::FieldType.UInt32, - true); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.PackedUint64ExtensionLite = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest.packed_uint64_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestPackedExtensionsLite.DefaultInstance, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.PackedUint64ExtensionLiteFieldNumber, - pbd::FieldType.UInt64, - true); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.PackedSint32ExtensionLite = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest.packed_sint32_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestPackedExtensionsLite.DefaultInstance, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.PackedSint32ExtensionLiteFieldNumber, - pbd::FieldType.SInt32, - true); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.PackedSint64ExtensionLite = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest.packed_sint64_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestPackedExtensionsLite.DefaultInstance, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.PackedSint64ExtensionLiteFieldNumber, - pbd::FieldType.SInt64, - true); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.PackedFixed32ExtensionLite = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest.packed_fixed32_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestPackedExtensionsLite.DefaultInstance, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.PackedFixed32ExtensionLiteFieldNumber, - pbd::FieldType.Fixed32, - true); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.PackedFixed64ExtensionLite = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest.packed_fixed64_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestPackedExtensionsLite.DefaultInstance, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.PackedFixed64ExtensionLiteFieldNumber, - pbd::FieldType.Fixed64, - true); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.PackedSfixed32ExtensionLite = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest.packed_sfixed32_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestPackedExtensionsLite.DefaultInstance, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.PackedSfixed32ExtensionLiteFieldNumber, - pbd::FieldType.SFixed32, - true); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.PackedSfixed64ExtensionLite = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest.packed_sfixed64_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestPackedExtensionsLite.DefaultInstance, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.PackedSfixed64ExtensionLiteFieldNumber, - pbd::FieldType.SFixed64, - true); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.PackedFloatExtensionLite = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest.packed_float_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestPackedExtensionsLite.DefaultInstance, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.PackedFloatExtensionLiteFieldNumber, - pbd::FieldType.Float, - true); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.PackedDoubleExtensionLite = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest.packed_double_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestPackedExtensionsLite.DefaultInstance, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.PackedDoubleExtensionLiteFieldNumber, - pbd::FieldType.Double, - true); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.PackedBoolExtensionLite = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest.packed_bool_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestPackedExtensionsLite.DefaultInstance, - null, - null, - global::Google.ProtocolBuffers.TestProtos.UnittestLite.PackedBoolExtensionLiteFieldNumber, - pbd::FieldType.Bool, - true); - global::Google.ProtocolBuffers.TestProtos.UnittestLite.PackedEnumExtensionLite = - new pb::GeneratedRepeatExtensionLite( - "protobuf_unittest.packed_enum_extension_lite", - global::Google.ProtocolBuffers.TestProtos.TestPackedExtensionsLite.DefaultInstance, - null, - new EnumLiteMap(), - global::Google.ProtocolBuffers.TestProtos.UnittestLite.PackedEnumExtensionLiteFieldNumber, - pbd::FieldType.Enum, - true); - } - #endregion - - } - #region Enums - public enum ForeignEnumLite { - FOREIGN_LITE_FOO = 4, - FOREIGN_LITE_BAR = 5, - FOREIGN_LITE_BAZ = 6, - } - - #endregion - - #region Messages - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestAllTypesLite : pb::GeneratedMessageLite { - private TestAllTypesLite() { } - private static readonly TestAllTypesLite defaultInstance = new TestAllTypesLite().MakeReadOnly(); - private static readonly string[] _testAllTypesLiteFieldNames = new string[] { "default_bool", "default_bytes", "default_cord", "default_double", "default_fixed32", "default_fixed64", "default_float", "default_foreign_enum", "default_import_enum", "default_int32", "default_int64", "default_nested_enum", "default_sfixed32", "default_sfixed64", "default_sint32", "default_sint64", "default_string", "default_string_piece", "default_uint32", "default_uint64", "oneof_bytes", "oneof_nested_message", "oneof_string", "oneof_uint32", "optional_bool", "optional_bytes", "optional_cord", "optional_double", "optional_fixed32", "optional_fixed64", "optional_float", "optional_foreign_enum", "optional_foreign_message", "optional_import_enum", "optional_import_message", "optional_int32", "optional_int64", "optional_lazy_message", "optional_nested_enum", "optional_nested_message", "optional_public_import_message", "optional_sfixed32", "optional_sfixed64", "optional_sint32", "optional_sint64", "optional_string", "optional_string_piece", "optional_uint32", "optional_uint64", "optionalgroup", "repeated_bool", "repeated_bytes", "repeated_cord", "repeated_double", "repeated_fixed32", "repeated_fixed64", "repeated_float", "repeated_foreign_enum", "repeated_foreign_message", "repeated_import_enum", "repeated_import_message", "repeated_int32", "repeated_int64", "repeated_lazy_message", "repeated_nested_enum", "repeated_nested_message", "repeated_sfixed32", "repeated_sfixed64", "repeated_sint32", "repeated_sint64", "repeated_string", "repeated_string_piece", "repeated_uint32", "repeated_uint64", "repeatedgroup" }; - private static readonly uint[] _testAllTypesLiteFieldTags = new uint[] { 584, 602, 682, 577, 541, 545, 573, 656, 664, 488, 496, 648, 557, 561, 520, 528, 594, 674, 504, 512, 914, 898, 906, 888, 104, 122, 202, 97, 61, 65, 93, 176, 154, 184, 162, 8, 16, 218, 168, 146, 210, 77, 81, 40, 48, 114, 194, 24, 32, 131, 344, 362, 442, 337, 301, 305, 333, 416, 394, 424, 402, 248, 256, 458, 408, 386, 317, 321, 280, 288, 354, 434, 264, 272, 371 }; - public static TestAllTypesLite DefaultInstance { - get { return defaultInstance; } - } - - public override TestAllTypesLite DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestAllTypesLite ThisMessage { - get { return this; } - } - - #region Nested types - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class Types { - public enum NestedEnum { - FOO = 1, - BAR = 2, - BAZ = 3, - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class NestedMessage : pb::GeneratedMessageLite { - private NestedMessage() { } - private static readonly NestedMessage defaultInstance = new NestedMessage().MakeReadOnly(); - private static readonly string[] _nestedMessageFieldNames = new string[] { "bb" }; - private static readonly uint[] _nestedMessageFieldTags = new uint[] { 8 }; - public static NestedMessage DefaultInstance { - get { return defaultInstance; } - } - - public override NestedMessage DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override NestedMessage ThisMessage { - get { return this; } - } - - public const int BbFieldNumber = 1; - private bool hasBb; - private int bb_; - public bool HasBb { - get { return hasBb; } - } - public int Bb { - get { return bb_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _nestedMessageFieldNames; - if (hasBb) { - output.WriteInt32(1, field_names[0], Bb); - } - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasBb) { - size += pb::CodedOutputStream.ComputeInt32Size(1, Bb); - } - memoizedSerializedSize = size; - return size; - } - #region Lite runtime methods - public override int GetHashCode() { - int hash = GetType().GetHashCode(); - if (hasBb) { - hash ^= bb_.GetHashCode(); - } - return hash; - } - - public override bool Equals(object obj) { - NestedMessage other = obj as NestedMessage; - if (other == null) return false; - if (hasBb != other.hasBb || (hasBb && !bb_.Equals(other.bb_))) return false; - return true; - } - - public override void PrintTo(global::System.IO.TextWriter writer) { - PrintField("bb", hasBb, bb_, writer); - } - #endregion - - public static NestedMessage ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static NestedMessage ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static NestedMessage ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static NestedMessage ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static NestedMessage ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static NestedMessage ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static NestedMessage ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static NestedMessage ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static NestedMessage ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static NestedMessage ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private NestedMessage MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(NestedMessage prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilderLite { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(NestedMessage cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private NestedMessage result; - - private NestedMessage PrepareBuilder() { - if (resultIsReadOnly) { - NestedMessage original = result; - result = new NestedMessage(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override NestedMessage MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override NestedMessage DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage.DefaultInstance; } - } - - public override NestedMessage BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessageLite other) { - if (other is NestedMessage) { - return MergeFrom((NestedMessage) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(NestedMessage other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasBb) { - Bb = other.Bb; - } - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_nestedMessageFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _nestedMessageFieldTags[field_ordinal]; - else { - ParseUnknownField(input, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - return this; - } - ParseUnknownField(input, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasBb = input.ReadInt32(ref result.bb_); - break; - } - } - } - - return this; - } - - - public bool HasBb { - get { return result.hasBb; } - } - public int Bb { - get { return result.Bb; } - set { SetBb(value); } - } - public Builder SetBb(int value) { - PrepareBuilder(); - result.hasBb = true; - result.bb_ = value; - return this; - } - public Builder ClearBb() { - PrepareBuilder(); - result.hasBb = false; - result.bb_ = 0; - return this; - } - } - static NestedMessage() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.UnittestLite.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class OptionalGroup : pb::GeneratedMessageLite { - private OptionalGroup() { } - private static readonly OptionalGroup defaultInstance = new OptionalGroup().MakeReadOnly(); - private static readonly string[] _optionalGroupFieldNames = new string[] { "a" }; - private static readonly uint[] _optionalGroupFieldTags = new uint[] { 136 }; - public static OptionalGroup DefaultInstance { - get { return defaultInstance; } - } - - public override OptionalGroup DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override OptionalGroup ThisMessage { - get { return this; } - } - - public const int AFieldNumber = 17; - private bool hasA; - private int a_; - public bool HasA { - get { return hasA; } - } - public int A { - get { return a_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _optionalGroupFieldNames; - if (hasA) { - output.WriteInt32(17, field_names[0], A); - } - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(17, A); - } - memoizedSerializedSize = size; - return size; - } - #region Lite runtime methods - public override int GetHashCode() { - int hash = GetType().GetHashCode(); - if (hasA) { - hash ^= a_.GetHashCode(); - } - return hash; - } - - public override bool Equals(object obj) { - OptionalGroup other = obj as OptionalGroup; - if (other == null) return false; - if (hasA != other.hasA || (hasA && !a_.Equals(other.a_))) return false; - return true; - } - - public override void PrintTo(global::System.IO.TextWriter writer) { - PrintField("a", hasA, a_, writer); - } - #endregion - - public static OptionalGroup ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static OptionalGroup ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static OptionalGroup ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static OptionalGroup ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static OptionalGroup ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static OptionalGroup ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static OptionalGroup ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static OptionalGroup ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static OptionalGroup ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static OptionalGroup ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private OptionalGroup MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(OptionalGroup prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilderLite { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(OptionalGroup cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private OptionalGroup result; - - private OptionalGroup PrepareBuilder() { - if (resultIsReadOnly) { - OptionalGroup original = result; - result = new OptionalGroup(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override OptionalGroup MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override OptionalGroup DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.OptionalGroup.DefaultInstance; } - } - - public override OptionalGroup BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessageLite other) { - if (other is OptionalGroup) { - return MergeFrom((OptionalGroup) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(OptionalGroup other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.OptionalGroup.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasA) { - A = other.A; - } - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_optionalGroupFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _optionalGroupFieldTags[field_ordinal]; - else { - ParseUnknownField(input, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - return this; - } - ParseUnknownField(input, extensionRegistry, tag, field_name); - break; - } - case 136: { - result.hasA = input.ReadInt32(ref result.a_); - break; - } - } - } - - return this; - } - - - public bool HasA { - get { return result.hasA; } - } - public int A { - get { return result.A; } - set { SetA(value); } - } - public Builder SetA(int value) { - PrepareBuilder(); - result.hasA = true; - result.a_ = value; - return this; - } - public Builder ClearA() { - PrepareBuilder(); - result.hasA = false; - result.a_ = 0; - return this; - } - } - static OptionalGroup() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.UnittestLite.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class RepeatedGroup : pb::GeneratedMessageLite { - private RepeatedGroup() { } - private static readonly RepeatedGroup defaultInstance = new RepeatedGroup().MakeReadOnly(); - private static readonly string[] _repeatedGroupFieldNames = new string[] { "a" }; - private static readonly uint[] _repeatedGroupFieldTags = new uint[] { 376 }; - public static RepeatedGroup DefaultInstance { - get { return defaultInstance; } - } - - public override RepeatedGroup DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override RepeatedGroup ThisMessage { - get { return this; } - } - - public const int AFieldNumber = 47; - private bool hasA; - private int a_; - public bool HasA { - get { return hasA; } - } - public int A { - get { return a_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _repeatedGroupFieldNames; - if (hasA) { - output.WriteInt32(47, field_names[0], A); - } - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(47, A); - } - memoizedSerializedSize = size; - return size; - } - #region Lite runtime methods - public override int GetHashCode() { - int hash = GetType().GetHashCode(); - if (hasA) { - hash ^= a_.GetHashCode(); - } - return hash; - } - - public override bool Equals(object obj) { - RepeatedGroup other = obj as RepeatedGroup; - if (other == null) return false; - if (hasA != other.hasA || (hasA && !a_.Equals(other.a_))) return false; - return true; - } - - public override void PrintTo(global::System.IO.TextWriter writer) { - PrintField("a", hasA, a_, writer); - } - #endregion - - public static RepeatedGroup ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static RepeatedGroup ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static RepeatedGroup ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static RepeatedGroup ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static RepeatedGroup ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static RepeatedGroup ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static RepeatedGroup ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static RepeatedGroup ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static RepeatedGroup ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static RepeatedGroup ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private RepeatedGroup MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(RepeatedGroup prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilderLite { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(RepeatedGroup cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private RepeatedGroup result; - - private RepeatedGroup PrepareBuilder() { - if (resultIsReadOnly) { - RepeatedGroup original = result; - result = new RepeatedGroup(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override RepeatedGroup MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override RepeatedGroup DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.RepeatedGroup.DefaultInstance; } - } - - public override RepeatedGroup BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessageLite other) { - if (other is RepeatedGroup) { - return MergeFrom((RepeatedGroup) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(RepeatedGroup other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.RepeatedGroup.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasA) { - A = other.A; - } - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_repeatedGroupFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _repeatedGroupFieldTags[field_ordinal]; - else { - ParseUnknownField(input, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - return this; - } - ParseUnknownField(input, extensionRegistry, tag, field_name); - break; - } - case 376: { - result.hasA = input.ReadInt32(ref result.a_); - break; - } - } - } - - return this; - } - - - public bool HasA { - get { return result.hasA; } - } - public int A { - get { return result.A; } - set { SetA(value); } - } - public Builder SetA(int value) { - PrepareBuilder(); - result.hasA = true; - result.a_ = value; - return this; - } - public Builder ClearA() { - PrepareBuilder(); - result.hasA = false; - result.a_ = 0; - return this; - } - } - static RepeatedGroup() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.UnittestLite.Descriptor, null); - } - } - - } - #endregion - - private object oneofField_; - public enum OneofFieldOneofCase { - OneofUint32 = 111, - OneofNestedMessage = 112, - OneofString = 113, - OneofBytes = 114, - None = 0, - } - private OneofFieldOneofCase oneofFieldCase_ = OneofFieldOneofCase.None; - public OneofFieldOneofCase OneofFieldCase { - get { return oneofFieldCase_; } - } - - public const int OptionalInt32FieldNumber = 1; - private bool hasOptionalInt32; - private int optionalInt32_; - public bool HasOptionalInt32 { - get { return hasOptionalInt32; } - } - public int OptionalInt32 { - get { return optionalInt32_; } - } - - public const int OptionalInt64FieldNumber = 2; - private bool hasOptionalInt64; - private long optionalInt64_; - public bool HasOptionalInt64 { - get { return hasOptionalInt64; } - } - public long OptionalInt64 { - get { return optionalInt64_; } - } - - public const int OptionalUint32FieldNumber = 3; - private bool hasOptionalUint32; - private uint optionalUint32_; - public bool HasOptionalUint32 { - get { return hasOptionalUint32; } - } - public uint OptionalUint32 { - get { return optionalUint32_; } - } - - public const int OptionalUint64FieldNumber = 4; - private bool hasOptionalUint64; - private ulong optionalUint64_; - public bool HasOptionalUint64 { - get { return hasOptionalUint64; } - } - public ulong OptionalUint64 { - get { return optionalUint64_; } - } - - public const int OptionalSint32FieldNumber = 5; - private bool hasOptionalSint32; - private int optionalSint32_; - public bool HasOptionalSint32 { - get { return hasOptionalSint32; } - } - public int OptionalSint32 { - get { return optionalSint32_; } - } - - public const int OptionalSint64FieldNumber = 6; - private bool hasOptionalSint64; - private long optionalSint64_; - public bool HasOptionalSint64 { - get { return hasOptionalSint64; } - } - public long OptionalSint64 { - get { return optionalSint64_; } - } - - public const int OptionalFixed32FieldNumber = 7; - private bool hasOptionalFixed32; - private uint optionalFixed32_; - public bool HasOptionalFixed32 { - get { return hasOptionalFixed32; } - } - public uint OptionalFixed32 { - get { return optionalFixed32_; } - } - - public const int OptionalFixed64FieldNumber = 8; - private bool hasOptionalFixed64; - private ulong optionalFixed64_; - public bool HasOptionalFixed64 { - get { return hasOptionalFixed64; } - } - public ulong OptionalFixed64 { - get { return optionalFixed64_; } - } - - public const int OptionalSfixed32FieldNumber = 9; - private bool hasOptionalSfixed32; - private int optionalSfixed32_; - public bool HasOptionalSfixed32 { - get { return hasOptionalSfixed32; } - } - public int OptionalSfixed32 { - get { return optionalSfixed32_; } - } - - public const int OptionalSfixed64FieldNumber = 10; - private bool hasOptionalSfixed64; - private long optionalSfixed64_; - public bool HasOptionalSfixed64 { - get { return hasOptionalSfixed64; } - } - public long OptionalSfixed64 { - get { return optionalSfixed64_; } - } - - public const int OptionalFloatFieldNumber = 11; - private bool hasOptionalFloat; - private float optionalFloat_; - public bool HasOptionalFloat { - get { return hasOptionalFloat; } - } - public float OptionalFloat { - get { return optionalFloat_; } - } - - public const int OptionalDoubleFieldNumber = 12; - private bool hasOptionalDouble; - private double optionalDouble_; - public bool HasOptionalDouble { - get { return hasOptionalDouble; } - } - public double OptionalDouble { - get { return optionalDouble_; } - } - - public const int OptionalBoolFieldNumber = 13; - private bool hasOptionalBool; - private bool optionalBool_; - public bool HasOptionalBool { - get { return hasOptionalBool; } - } - public bool OptionalBool { - get { return optionalBool_; } - } - - public const int OptionalStringFieldNumber = 14; - private bool hasOptionalString; - private string optionalString_ = ""; - public bool HasOptionalString { - get { return hasOptionalString; } - } - public string OptionalString { - get { return optionalString_; } - } - - public const int OptionalBytesFieldNumber = 15; - private bool hasOptionalBytes; - private pb::ByteString optionalBytes_ = pb::ByteString.Empty; - public bool HasOptionalBytes { - get { return hasOptionalBytes; } - } - public pb::ByteString OptionalBytes { - get { return optionalBytes_; } - } - - public const int OptionalGroupFieldNumber = 16; - private bool hasOptionalGroup; - private global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.OptionalGroup optionalGroup_; - public bool HasOptionalGroup { - get { return hasOptionalGroup; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.OptionalGroup OptionalGroup { - get { return optionalGroup_ ?? global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.OptionalGroup.DefaultInstance; } - } - - public const int OptionalNestedMessageFieldNumber = 18; - private bool hasOptionalNestedMessage; - private global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage optionalNestedMessage_; - public bool HasOptionalNestedMessage { - get { return hasOptionalNestedMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage OptionalNestedMessage { - get { return optionalNestedMessage_ ?? global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage.DefaultInstance; } - } - - public const int OptionalForeignMessageFieldNumber = 19; - private bool hasOptionalForeignMessage; - private global::Google.ProtocolBuffers.TestProtos.ForeignMessageLite optionalForeignMessage_; - public bool HasOptionalForeignMessage { - get { return hasOptionalForeignMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignMessageLite OptionalForeignMessage { - get { return optionalForeignMessage_ ?? global::Google.ProtocolBuffers.TestProtos.ForeignMessageLite.DefaultInstance; } - } - - public const int OptionalImportMessageFieldNumber = 20; - private bool hasOptionalImportMessage; - private global::Google.ProtocolBuffers.TestProtos.ImportMessageLite optionalImportMessage_; - public bool HasOptionalImportMessage { - get { return hasOptionalImportMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.ImportMessageLite OptionalImportMessage { - get { return optionalImportMessage_ ?? global::Google.ProtocolBuffers.TestProtos.ImportMessageLite.DefaultInstance; } - } - - public const int OptionalNestedEnumFieldNumber = 21; - private bool hasOptionalNestedEnum; - private global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedEnum optionalNestedEnum_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedEnum.FOO; - public bool HasOptionalNestedEnum { - get { return hasOptionalNestedEnum; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedEnum OptionalNestedEnum { - get { return optionalNestedEnum_; } - } - - public const int OptionalForeignEnumFieldNumber = 22; - private bool hasOptionalForeignEnum; - private global::Google.ProtocolBuffers.TestProtos.ForeignEnumLite optionalForeignEnum_ = global::Google.ProtocolBuffers.TestProtos.ForeignEnumLite.FOREIGN_LITE_FOO; - public bool HasOptionalForeignEnum { - get { return hasOptionalForeignEnum; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignEnumLite OptionalForeignEnum { - get { return optionalForeignEnum_; } - } - - public const int OptionalImportEnumFieldNumber = 23; - private bool hasOptionalImportEnum; - private global::Google.ProtocolBuffers.TestProtos.ImportEnumLite optionalImportEnum_ = global::Google.ProtocolBuffers.TestProtos.ImportEnumLite.IMPORT_LITE_FOO; - public bool HasOptionalImportEnum { - get { return hasOptionalImportEnum; } - } - public global::Google.ProtocolBuffers.TestProtos.ImportEnumLite OptionalImportEnum { - get { return optionalImportEnum_; } - } - - public const int OptionalStringPieceFieldNumber = 24; - private bool hasOptionalStringPiece; - private string optionalStringPiece_ = ""; - public bool HasOptionalStringPiece { - get { return hasOptionalStringPiece; } - } - public string OptionalStringPiece { - get { return optionalStringPiece_; } - } - - public const int OptionalCordFieldNumber = 25; - private bool hasOptionalCord; - private string optionalCord_ = ""; - public bool HasOptionalCord { - get { return hasOptionalCord; } - } - public string OptionalCord { - get { return optionalCord_; } - } - - public const int OptionalPublicImportMessageFieldNumber = 26; - private bool hasOptionalPublicImportMessage; - private global::Google.ProtocolBuffers.TestProtos.PublicImportMessageLite optionalPublicImportMessage_; - public bool HasOptionalPublicImportMessage { - get { return hasOptionalPublicImportMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.PublicImportMessageLite OptionalPublicImportMessage { - get { return optionalPublicImportMessage_ ?? global::Google.ProtocolBuffers.TestProtos.PublicImportMessageLite.DefaultInstance; } - } - - public const int OptionalLazyMessageFieldNumber = 27; - private bool hasOptionalLazyMessage; - private global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage optionalLazyMessage_; - public bool HasOptionalLazyMessage { - get { return hasOptionalLazyMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage OptionalLazyMessage { - get { return optionalLazyMessage_ ?? global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage.DefaultInstance; } - } - - public const int RepeatedInt32FieldNumber = 31; - private pbc::PopsicleList repeatedInt32_ = new pbc::PopsicleList(); - public scg::IList RepeatedInt32List { - get { return pbc::Lists.AsReadOnly(repeatedInt32_); } - } - public int RepeatedInt32Count { - get { return repeatedInt32_.Count; } - } - public int GetRepeatedInt32(int index) { - return repeatedInt32_[index]; - } - - public const int RepeatedInt64FieldNumber = 32; - private pbc::PopsicleList repeatedInt64_ = new pbc::PopsicleList(); - public scg::IList RepeatedInt64List { - get { return pbc::Lists.AsReadOnly(repeatedInt64_); } - } - public int RepeatedInt64Count { - get { return repeatedInt64_.Count; } - } - public long GetRepeatedInt64(int index) { - return repeatedInt64_[index]; - } - - public const int RepeatedUint32FieldNumber = 33; - private pbc::PopsicleList repeatedUint32_ = new pbc::PopsicleList(); - public scg::IList RepeatedUint32List { - get { return pbc::Lists.AsReadOnly(repeatedUint32_); } - } - public int RepeatedUint32Count { - get { return repeatedUint32_.Count; } - } - public uint GetRepeatedUint32(int index) { - return repeatedUint32_[index]; - } - - public const int RepeatedUint64FieldNumber = 34; - private pbc::PopsicleList repeatedUint64_ = new pbc::PopsicleList(); - public scg::IList RepeatedUint64List { - get { return pbc::Lists.AsReadOnly(repeatedUint64_); } - } - public int RepeatedUint64Count { - get { return repeatedUint64_.Count; } - } - public ulong GetRepeatedUint64(int index) { - return repeatedUint64_[index]; - } - - public const int RepeatedSint32FieldNumber = 35; - private pbc::PopsicleList repeatedSint32_ = new pbc::PopsicleList(); - public scg::IList RepeatedSint32List { - get { return pbc::Lists.AsReadOnly(repeatedSint32_); } - } - public int RepeatedSint32Count { - get { return repeatedSint32_.Count; } - } - public int GetRepeatedSint32(int index) { - return repeatedSint32_[index]; - } - - public const int RepeatedSint64FieldNumber = 36; - private pbc::PopsicleList repeatedSint64_ = new pbc::PopsicleList(); - public scg::IList RepeatedSint64List { - get { return pbc::Lists.AsReadOnly(repeatedSint64_); } - } - public int RepeatedSint64Count { - get { return repeatedSint64_.Count; } - } - public long GetRepeatedSint64(int index) { - return repeatedSint64_[index]; - } - - public const int RepeatedFixed32FieldNumber = 37; - private pbc::PopsicleList repeatedFixed32_ = new pbc::PopsicleList(); - public scg::IList RepeatedFixed32List { - get { return pbc::Lists.AsReadOnly(repeatedFixed32_); } - } - public int RepeatedFixed32Count { - get { return repeatedFixed32_.Count; } - } - public uint GetRepeatedFixed32(int index) { - return repeatedFixed32_[index]; - } - - public const int RepeatedFixed64FieldNumber = 38; - private pbc::PopsicleList repeatedFixed64_ = new pbc::PopsicleList(); - public scg::IList RepeatedFixed64List { - get { return pbc::Lists.AsReadOnly(repeatedFixed64_); } - } - public int RepeatedFixed64Count { - get { return repeatedFixed64_.Count; } - } - public ulong GetRepeatedFixed64(int index) { - return repeatedFixed64_[index]; - } - - public const int RepeatedSfixed32FieldNumber = 39; - private pbc::PopsicleList repeatedSfixed32_ = new pbc::PopsicleList(); - public scg::IList RepeatedSfixed32List { - get { return pbc::Lists.AsReadOnly(repeatedSfixed32_); } - } - public int RepeatedSfixed32Count { - get { return repeatedSfixed32_.Count; } - } - public int GetRepeatedSfixed32(int index) { - return repeatedSfixed32_[index]; - } - - public const int RepeatedSfixed64FieldNumber = 40; - private pbc::PopsicleList repeatedSfixed64_ = new pbc::PopsicleList(); - public scg::IList RepeatedSfixed64List { - get { return pbc::Lists.AsReadOnly(repeatedSfixed64_); } - } - public int RepeatedSfixed64Count { - get { return repeatedSfixed64_.Count; } - } - public long GetRepeatedSfixed64(int index) { - return repeatedSfixed64_[index]; - } - - public const int RepeatedFloatFieldNumber = 41; - private pbc::PopsicleList repeatedFloat_ = new pbc::PopsicleList(); - public scg::IList RepeatedFloatList { - get { return pbc::Lists.AsReadOnly(repeatedFloat_); } - } - public int RepeatedFloatCount { - get { return repeatedFloat_.Count; } - } - public float GetRepeatedFloat(int index) { - return repeatedFloat_[index]; - } - - public const int RepeatedDoubleFieldNumber = 42; - private pbc::PopsicleList repeatedDouble_ = new pbc::PopsicleList(); - public scg::IList RepeatedDoubleList { - get { return pbc::Lists.AsReadOnly(repeatedDouble_); } - } - public int RepeatedDoubleCount { - get { return repeatedDouble_.Count; } - } - public double GetRepeatedDouble(int index) { - return repeatedDouble_[index]; - } - - public const int RepeatedBoolFieldNumber = 43; - private pbc::PopsicleList repeatedBool_ = new pbc::PopsicleList(); - public scg::IList RepeatedBoolList { - get { return pbc::Lists.AsReadOnly(repeatedBool_); } - } - public int RepeatedBoolCount { - get { return repeatedBool_.Count; } - } - public bool GetRepeatedBool(int index) { - return repeatedBool_[index]; - } - - public const int RepeatedStringFieldNumber = 44; - private pbc::PopsicleList repeatedString_ = new pbc::PopsicleList(); - public scg::IList RepeatedStringList { - get { return pbc::Lists.AsReadOnly(repeatedString_); } - } - public int RepeatedStringCount { - get { return repeatedString_.Count; } - } - public string GetRepeatedString(int index) { - return repeatedString_[index]; - } - - public const int RepeatedBytesFieldNumber = 45; - private pbc::PopsicleList repeatedBytes_ = new pbc::PopsicleList(); - public scg::IList RepeatedBytesList { - get { return pbc::Lists.AsReadOnly(repeatedBytes_); } - } - public int RepeatedBytesCount { - get { return repeatedBytes_.Count; } - } - public pb::ByteString GetRepeatedBytes(int index) { - return repeatedBytes_[index]; - } - - public const int RepeatedGroupFieldNumber = 46; - private pbc::PopsicleList repeatedGroup_ = new pbc::PopsicleList(); - public scg::IList RepeatedGroupList { - get { return repeatedGroup_; } - } - public int RepeatedGroupCount { - get { return repeatedGroup_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.RepeatedGroup GetRepeatedGroup(int index) { - return repeatedGroup_[index]; - } - - public const int RepeatedNestedMessageFieldNumber = 48; - private pbc::PopsicleList repeatedNestedMessage_ = new pbc::PopsicleList(); - public scg::IList RepeatedNestedMessageList { - get { return repeatedNestedMessage_; } - } - public int RepeatedNestedMessageCount { - get { return repeatedNestedMessage_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage GetRepeatedNestedMessage(int index) { - return repeatedNestedMessage_[index]; - } - - public const int RepeatedForeignMessageFieldNumber = 49; - private pbc::PopsicleList repeatedForeignMessage_ = new pbc::PopsicleList(); - public scg::IList RepeatedForeignMessageList { - get { return repeatedForeignMessage_; } - } - public int RepeatedForeignMessageCount { - get { return repeatedForeignMessage_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignMessageLite GetRepeatedForeignMessage(int index) { - return repeatedForeignMessage_[index]; - } - - public const int RepeatedImportMessageFieldNumber = 50; - private pbc::PopsicleList repeatedImportMessage_ = new pbc::PopsicleList(); - public scg::IList RepeatedImportMessageList { - get { return repeatedImportMessage_; } - } - public int RepeatedImportMessageCount { - get { return repeatedImportMessage_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.ImportMessageLite GetRepeatedImportMessage(int index) { - return repeatedImportMessage_[index]; - } - - public const int RepeatedNestedEnumFieldNumber = 51; - private pbc::PopsicleList repeatedNestedEnum_ = new pbc::PopsicleList(); - public scg::IList RepeatedNestedEnumList { - get { return pbc::Lists.AsReadOnly(repeatedNestedEnum_); } - } - public int RepeatedNestedEnumCount { - get { return repeatedNestedEnum_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedEnum GetRepeatedNestedEnum(int index) { - return repeatedNestedEnum_[index]; - } - - public const int RepeatedForeignEnumFieldNumber = 52; - private pbc::PopsicleList repeatedForeignEnum_ = new pbc::PopsicleList(); - public scg::IList RepeatedForeignEnumList { - get { return pbc::Lists.AsReadOnly(repeatedForeignEnum_); } - } - public int RepeatedForeignEnumCount { - get { return repeatedForeignEnum_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignEnumLite GetRepeatedForeignEnum(int index) { - return repeatedForeignEnum_[index]; - } - - public const int RepeatedImportEnumFieldNumber = 53; - private pbc::PopsicleList repeatedImportEnum_ = new pbc::PopsicleList(); - public scg::IList RepeatedImportEnumList { - get { return pbc::Lists.AsReadOnly(repeatedImportEnum_); } - } - public int RepeatedImportEnumCount { - get { return repeatedImportEnum_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.ImportEnumLite GetRepeatedImportEnum(int index) { - return repeatedImportEnum_[index]; - } - - public const int RepeatedStringPieceFieldNumber = 54; - private pbc::PopsicleList repeatedStringPiece_ = new pbc::PopsicleList(); - public scg::IList RepeatedStringPieceList { - get { return pbc::Lists.AsReadOnly(repeatedStringPiece_); } - } - public int RepeatedStringPieceCount { - get { return repeatedStringPiece_.Count; } - } - public string GetRepeatedStringPiece(int index) { - return repeatedStringPiece_[index]; - } - - public const int RepeatedCordFieldNumber = 55; - private pbc::PopsicleList repeatedCord_ = new pbc::PopsicleList(); - public scg::IList RepeatedCordList { - get { return pbc::Lists.AsReadOnly(repeatedCord_); } - } - public int RepeatedCordCount { - get { return repeatedCord_.Count; } - } - public string GetRepeatedCord(int index) { - return repeatedCord_[index]; - } - - public const int RepeatedLazyMessageFieldNumber = 57; - private pbc::PopsicleList repeatedLazyMessage_ = new pbc::PopsicleList(); - public scg::IList RepeatedLazyMessageList { - get { return repeatedLazyMessage_; } - } - public int RepeatedLazyMessageCount { - get { return repeatedLazyMessage_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage GetRepeatedLazyMessage(int index) { - return repeatedLazyMessage_[index]; - } - - public const int DefaultInt32FieldNumber = 61; - private bool hasDefaultInt32; - private int defaultInt32_ = 41; - public bool HasDefaultInt32 { - get { return hasDefaultInt32; } - } - public int DefaultInt32 { - get { return defaultInt32_; } - } - - public const int DefaultInt64FieldNumber = 62; - private bool hasDefaultInt64; - private long defaultInt64_ = 42L; - public bool HasDefaultInt64 { - get { return hasDefaultInt64; } - } - public long DefaultInt64 { - get { return defaultInt64_; } - } - - public const int DefaultUint32FieldNumber = 63; - private bool hasDefaultUint32; - private uint defaultUint32_ = 43; - public bool HasDefaultUint32 { - get { return hasDefaultUint32; } - } - public uint DefaultUint32 { - get { return defaultUint32_; } - } - - public const int DefaultUint64FieldNumber = 64; - private bool hasDefaultUint64; - private ulong defaultUint64_ = 44UL; - public bool HasDefaultUint64 { - get { return hasDefaultUint64; } - } - public ulong DefaultUint64 { - get { return defaultUint64_; } - } - - public const int DefaultSint32FieldNumber = 65; - private bool hasDefaultSint32; - private int defaultSint32_ = -45; - public bool HasDefaultSint32 { - get { return hasDefaultSint32; } - } - public int DefaultSint32 { - get { return defaultSint32_; } - } - - public const int DefaultSint64FieldNumber = 66; - private bool hasDefaultSint64; - private long defaultSint64_ = 46L; - public bool HasDefaultSint64 { - get { return hasDefaultSint64; } - } - public long DefaultSint64 { - get { return defaultSint64_; } - } - - public const int DefaultFixed32FieldNumber = 67; - private bool hasDefaultFixed32; - private uint defaultFixed32_ = 47; - public bool HasDefaultFixed32 { - get { return hasDefaultFixed32; } - } - public uint DefaultFixed32 { - get { return defaultFixed32_; } - } - - public const int DefaultFixed64FieldNumber = 68; - private bool hasDefaultFixed64; - private ulong defaultFixed64_ = 48UL; - public bool HasDefaultFixed64 { - get { return hasDefaultFixed64; } - } - public ulong DefaultFixed64 { - get { return defaultFixed64_; } - } - - public const int DefaultSfixed32FieldNumber = 69; - private bool hasDefaultSfixed32; - private int defaultSfixed32_ = 49; - public bool HasDefaultSfixed32 { - get { return hasDefaultSfixed32; } - } - public int DefaultSfixed32 { - get { return defaultSfixed32_; } - } - - public const int DefaultSfixed64FieldNumber = 70; - private bool hasDefaultSfixed64; - private long defaultSfixed64_ = -50L; - public bool HasDefaultSfixed64 { - get { return hasDefaultSfixed64; } - } - public long DefaultSfixed64 { - get { return defaultSfixed64_; } - } - - public const int DefaultFloatFieldNumber = 71; - private bool hasDefaultFloat; - private float defaultFloat_ = 51.5F; - public bool HasDefaultFloat { - get { return hasDefaultFloat; } - } - public float DefaultFloat { - get { return defaultFloat_; } - } - - public const int DefaultDoubleFieldNumber = 72; - private bool hasDefaultDouble; - private double defaultDouble_ = 52000D; - public bool HasDefaultDouble { - get { return hasDefaultDouble; } - } - public double DefaultDouble { - get { return defaultDouble_; } - } - - public const int DefaultBoolFieldNumber = 73; - private bool hasDefaultBool; - private bool defaultBool_ = true; - public bool HasDefaultBool { - get { return hasDefaultBool; } - } - public bool DefaultBool { - get { return defaultBool_; } - } - - public const int DefaultStringFieldNumber = 74; - private bool hasDefaultString; - private string defaultString_ = "hello"; - public bool HasDefaultString { - get { return hasDefaultString; } - } - public string DefaultString { - get { return defaultString_; } - } - - public const int DefaultBytesFieldNumber = 75; - private bool hasDefaultBytes; - private pb::ByteString defaultBytes_ = pb::ByteString.FromBase64("d29ybGQ="); - public bool HasDefaultBytes { - get { return hasDefaultBytes; } - } - public pb::ByteString DefaultBytes { - get { return defaultBytes_; } - } - - public const int DefaultNestedEnumFieldNumber = 81; - private bool hasDefaultNestedEnum; - private global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedEnum defaultNestedEnum_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedEnum.BAR; - public bool HasDefaultNestedEnum { - get { return hasDefaultNestedEnum; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedEnum DefaultNestedEnum { - get { return defaultNestedEnum_; } - } - - public const int DefaultForeignEnumFieldNumber = 82; - private bool hasDefaultForeignEnum; - private global::Google.ProtocolBuffers.TestProtos.ForeignEnumLite defaultForeignEnum_ = global::Google.ProtocolBuffers.TestProtos.ForeignEnumLite.FOREIGN_LITE_BAR; - public bool HasDefaultForeignEnum { - get { return hasDefaultForeignEnum; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignEnumLite DefaultForeignEnum { - get { return defaultForeignEnum_; } - } - - public const int DefaultImportEnumFieldNumber = 83; - private bool hasDefaultImportEnum; - private global::Google.ProtocolBuffers.TestProtos.ImportEnumLite defaultImportEnum_ = global::Google.ProtocolBuffers.TestProtos.ImportEnumLite.IMPORT_LITE_BAR; - public bool HasDefaultImportEnum { - get { return hasDefaultImportEnum; } - } - public global::Google.ProtocolBuffers.TestProtos.ImportEnumLite DefaultImportEnum { - get { return defaultImportEnum_; } - } - - public const int DefaultStringPieceFieldNumber = 84; - private bool hasDefaultStringPiece; - private string defaultStringPiece_ = "abc"; - public bool HasDefaultStringPiece { - get { return hasDefaultStringPiece; } - } - public string DefaultStringPiece { - get { return defaultStringPiece_; } - } - - public const int DefaultCordFieldNumber = 85; - private bool hasDefaultCord; - private string defaultCord_ = "123"; - public bool HasDefaultCord { - get { return hasDefaultCord; } - } - public string DefaultCord { - get { return defaultCord_; } - } - - public const int OneofUint32FieldNumber = 111; - public bool HasOneofUint32 { - get { return oneofFieldCase_ == OneofFieldOneofCase.OneofUint32; } - } - public uint OneofUint32 { - get { return oneofFieldCase_ == OneofFieldOneofCase.OneofUint32 ? (uint) oneofField_ : 0; } - } - - public const int OneofNestedMessageFieldNumber = 112; - public bool HasOneofNestedMessage { - get { return oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage OneofNestedMessage { - get { return oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage ? (global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage) oneofField_ : global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage.DefaultInstance; } - } - - public const int OneofStringFieldNumber = 113; - public bool HasOneofString { - get { return oneofFieldCase_ == OneofFieldOneofCase.OneofString; } - } - public string OneofString { - get { return oneofFieldCase_ == OneofFieldOneofCase.OneofString ? (string) oneofField_ : ""; } - } - - public const int OneofBytesFieldNumber = 114; - public bool HasOneofBytes { - get { return oneofFieldCase_ == OneofFieldOneofCase.OneofBytes; } - } - public pb::ByteString OneofBytes { - get { return oneofFieldCase_ == OneofFieldOneofCase.OneofBytes ? (pb::ByteString) oneofField_ : pb::ByteString.Empty; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testAllTypesLiteFieldNames; - if (hasOptionalInt32) { - output.WriteInt32(1, field_names[35], OptionalInt32); - } - if (hasOptionalInt64) { - output.WriteInt64(2, field_names[36], OptionalInt64); - } - if (hasOptionalUint32) { - output.WriteUInt32(3, field_names[47], OptionalUint32); - } - if (hasOptionalUint64) { - output.WriteUInt64(4, field_names[48], OptionalUint64); - } - if (hasOptionalSint32) { - output.WriteSInt32(5, field_names[43], OptionalSint32); - } - if (hasOptionalSint64) { - output.WriteSInt64(6, field_names[44], OptionalSint64); - } - if (hasOptionalFixed32) { - output.WriteFixed32(7, field_names[28], OptionalFixed32); - } - if (hasOptionalFixed64) { - output.WriteFixed64(8, field_names[29], OptionalFixed64); - } - if (hasOptionalSfixed32) { - output.WriteSFixed32(9, field_names[41], OptionalSfixed32); - } - if (hasOptionalSfixed64) { - output.WriteSFixed64(10, field_names[42], OptionalSfixed64); - } - if (hasOptionalFloat) { - output.WriteFloat(11, field_names[30], OptionalFloat); - } - if (hasOptionalDouble) { - output.WriteDouble(12, field_names[27], OptionalDouble); - } - if (hasOptionalBool) { - output.WriteBool(13, field_names[24], OptionalBool); - } - if (hasOptionalString) { - output.WriteString(14, field_names[45], OptionalString); - } - if (hasOptionalBytes) { - output.WriteBytes(15, field_names[25], OptionalBytes); - } - if (hasOptionalGroup) { - output.WriteGroup(16, field_names[49], OptionalGroup); - } - if (hasOptionalNestedMessage) { - output.WriteMessage(18, field_names[39], OptionalNestedMessage); - } - if (hasOptionalForeignMessage) { - output.WriteMessage(19, field_names[32], OptionalForeignMessage); - } - if (hasOptionalImportMessage) { - output.WriteMessage(20, field_names[34], OptionalImportMessage); - } - if (hasOptionalNestedEnum) { - output.WriteEnum(21, field_names[38], (int) OptionalNestedEnum, OptionalNestedEnum); - } - if (hasOptionalForeignEnum) { - output.WriteEnum(22, field_names[31], (int) OptionalForeignEnum, OptionalForeignEnum); - } - if (hasOptionalImportEnum) { - output.WriteEnum(23, field_names[33], (int) OptionalImportEnum, OptionalImportEnum); - } - if (hasOptionalStringPiece) { - output.WriteString(24, field_names[46], OptionalStringPiece); - } - if (hasOptionalCord) { - output.WriteString(25, field_names[26], OptionalCord); - } - if (hasOptionalPublicImportMessage) { - output.WriteMessage(26, field_names[40], OptionalPublicImportMessage); - } - if (hasOptionalLazyMessage) { - output.WriteMessage(27, field_names[37], OptionalLazyMessage); - } - if (repeatedInt32_.Count > 0) { - output.WriteInt32Array(31, field_names[61], repeatedInt32_); - } - if (repeatedInt64_.Count > 0) { - output.WriteInt64Array(32, field_names[62], repeatedInt64_); - } - if (repeatedUint32_.Count > 0) { - output.WriteUInt32Array(33, field_names[72], repeatedUint32_); - } - if (repeatedUint64_.Count > 0) { - output.WriteUInt64Array(34, field_names[73], repeatedUint64_); - } - if (repeatedSint32_.Count > 0) { - output.WriteSInt32Array(35, field_names[68], repeatedSint32_); - } - if (repeatedSint64_.Count > 0) { - output.WriteSInt64Array(36, field_names[69], repeatedSint64_); - } - if (repeatedFixed32_.Count > 0) { - output.WriteFixed32Array(37, field_names[54], repeatedFixed32_); - } - if (repeatedFixed64_.Count > 0) { - output.WriteFixed64Array(38, field_names[55], repeatedFixed64_); - } - if (repeatedSfixed32_.Count > 0) { - output.WriteSFixed32Array(39, field_names[66], repeatedSfixed32_); - } - if (repeatedSfixed64_.Count > 0) { - output.WriteSFixed64Array(40, field_names[67], repeatedSfixed64_); - } - if (repeatedFloat_.Count > 0) { - output.WriteFloatArray(41, field_names[56], repeatedFloat_); - } - if (repeatedDouble_.Count > 0) { - output.WriteDoubleArray(42, field_names[53], repeatedDouble_); - } - if (repeatedBool_.Count > 0) { - output.WriteBoolArray(43, field_names[50], repeatedBool_); - } - if (repeatedString_.Count > 0) { - output.WriteStringArray(44, field_names[70], repeatedString_); - } - if (repeatedBytes_.Count > 0) { - output.WriteBytesArray(45, field_names[51], repeatedBytes_); - } - if (repeatedGroup_.Count > 0) { - output.WriteGroupArray(46, field_names[74], repeatedGroup_); - } - if (repeatedNestedMessage_.Count > 0) { - output.WriteMessageArray(48, field_names[65], repeatedNestedMessage_); - } - if (repeatedForeignMessage_.Count > 0) { - output.WriteMessageArray(49, field_names[58], repeatedForeignMessage_); - } - if (repeatedImportMessage_.Count > 0) { - output.WriteMessageArray(50, field_names[60], repeatedImportMessage_); - } - if (repeatedNestedEnum_.Count > 0) { - output.WriteEnumArray(51, field_names[64], repeatedNestedEnum_); - } - if (repeatedForeignEnum_.Count > 0) { - output.WriteEnumArray(52, field_names[57], repeatedForeignEnum_); - } - if (repeatedImportEnum_.Count > 0) { - output.WriteEnumArray(53, field_names[59], repeatedImportEnum_); - } - if (repeatedStringPiece_.Count > 0) { - output.WriteStringArray(54, field_names[71], repeatedStringPiece_); - } - if (repeatedCord_.Count > 0) { - output.WriteStringArray(55, field_names[52], repeatedCord_); - } - if (repeatedLazyMessage_.Count > 0) { - output.WriteMessageArray(57, field_names[63], repeatedLazyMessage_); - } - if (hasDefaultInt32) { - output.WriteInt32(61, field_names[9], DefaultInt32); - } - if (hasDefaultInt64) { - output.WriteInt64(62, field_names[10], DefaultInt64); - } - if (hasDefaultUint32) { - output.WriteUInt32(63, field_names[18], DefaultUint32); - } - if (hasDefaultUint64) { - output.WriteUInt64(64, field_names[19], DefaultUint64); - } - if (hasDefaultSint32) { - output.WriteSInt32(65, field_names[14], DefaultSint32); - } - if (hasDefaultSint64) { - output.WriteSInt64(66, field_names[15], DefaultSint64); - } - if (hasDefaultFixed32) { - output.WriteFixed32(67, field_names[4], DefaultFixed32); - } - if (hasDefaultFixed64) { - output.WriteFixed64(68, field_names[5], DefaultFixed64); - } - if (hasDefaultSfixed32) { - output.WriteSFixed32(69, field_names[12], DefaultSfixed32); - } - if (hasDefaultSfixed64) { - output.WriteSFixed64(70, field_names[13], DefaultSfixed64); - } - if (hasDefaultFloat) { - output.WriteFloat(71, field_names[6], DefaultFloat); - } - if (hasDefaultDouble) { - output.WriteDouble(72, field_names[3], DefaultDouble); - } - if (hasDefaultBool) { - output.WriteBool(73, field_names[0], DefaultBool); - } - if (hasDefaultString) { - output.WriteString(74, field_names[16], DefaultString); - } - if (hasDefaultBytes) { - output.WriteBytes(75, field_names[1], DefaultBytes); - } - if (hasDefaultNestedEnum) { - output.WriteEnum(81, field_names[11], (int) DefaultNestedEnum, DefaultNestedEnum); - } - if (hasDefaultForeignEnum) { - output.WriteEnum(82, field_names[7], (int) DefaultForeignEnum, DefaultForeignEnum); - } - if (hasDefaultImportEnum) { - output.WriteEnum(83, field_names[8], (int) DefaultImportEnum, DefaultImportEnum); - } - if (hasDefaultStringPiece) { - output.WriteString(84, field_names[17], DefaultStringPiece); - } - if (hasDefaultCord) { - output.WriteString(85, field_names[2], DefaultCord); - } - if (oneofFieldCase_ == OneofFieldOneofCase.OneofUint32) { - output.WriteUInt32(111, field_names[23], OneofUint32); - } - if (oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage) { - output.WriteMessage(112, field_names[21], OneofNestedMessage); - } - if (oneofFieldCase_ == OneofFieldOneofCase.OneofString) { - output.WriteString(113, field_names[22], OneofString); - } - if (oneofFieldCase_ == OneofFieldOneofCase.OneofBytes) { - output.WriteBytes(114, field_names[20], OneofBytes); - } - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasOptionalInt32) { - size += pb::CodedOutputStream.ComputeInt32Size(1, OptionalInt32); - } - if (hasOptionalInt64) { - size += pb::CodedOutputStream.ComputeInt64Size(2, OptionalInt64); - } - if (hasOptionalUint32) { - size += pb::CodedOutputStream.ComputeUInt32Size(3, OptionalUint32); - } - if (hasOptionalUint64) { - size += pb::CodedOutputStream.ComputeUInt64Size(4, OptionalUint64); - } - if (hasOptionalSint32) { - size += pb::CodedOutputStream.ComputeSInt32Size(5, OptionalSint32); - } - if (hasOptionalSint64) { - size += pb::CodedOutputStream.ComputeSInt64Size(6, OptionalSint64); - } - if (hasOptionalFixed32) { - size += pb::CodedOutputStream.ComputeFixed32Size(7, OptionalFixed32); - } - if (hasOptionalFixed64) { - size += pb::CodedOutputStream.ComputeFixed64Size(8, OptionalFixed64); - } - if (hasOptionalSfixed32) { - size += pb::CodedOutputStream.ComputeSFixed32Size(9, OptionalSfixed32); - } - if (hasOptionalSfixed64) { - size += pb::CodedOutputStream.ComputeSFixed64Size(10, OptionalSfixed64); - } - if (hasOptionalFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(11, OptionalFloat); - } - if (hasOptionalDouble) { - size += pb::CodedOutputStream.ComputeDoubleSize(12, OptionalDouble); - } - if (hasOptionalBool) { - size += pb::CodedOutputStream.ComputeBoolSize(13, OptionalBool); - } - if (hasOptionalString) { - size += pb::CodedOutputStream.ComputeStringSize(14, OptionalString); - } - if (hasOptionalBytes) { - size += pb::CodedOutputStream.ComputeBytesSize(15, OptionalBytes); - } - if (hasOptionalGroup) { - size += pb::CodedOutputStream.ComputeGroupSize(16, OptionalGroup); - } - if (hasOptionalNestedMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(18, OptionalNestedMessage); - } - if (hasOptionalForeignMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(19, OptionalForeignMessage); - } - if (hasOptionalImportMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(20, OptionalImportMessage); - } - if (hasOptionalNestedEnum) { - size += pb::CodedOutputStream.ComputeEnumSize(21, (int) OptionalNestedEnum); - } - if (hasOptionalForeignEnum) { - size += pb::CodedOutputStream.ComputeEnumSize(22, (int) OptionalForeignEnum); - } - if (hasOptionalImportEnum) { - size += pb::CodedOutputStream.ComputeEnumSize(23, (int) OptionalImportEnum); - } - if (hasOptionalStringPiece) { - size += pb::CodedOutputStream.ComputeStringSize(24, OptionalStringPiece); - } - if (hasOptionalCord) { - size += pb::CodedOutputStream.ComputeStringSize(25, OptionalCord); - } - if (hasOptionalPublicImportMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(26, OptionalPublicImportMessage); - } - if (hasOptionalLazyMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(27, OptionalLazyMessage); - } - { - int dataSize = 0; - foreach (int element in RepeatedInt32List) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedInt32_.Count; - } - { - int dataSize = 0; - foreach (long element in RepeatedInt64List) { - dataSize += pb::CodedOutputStream.ComputeInt64SizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedInt64_.Count; - } - { - int dataSize = 0; - foreach (uint element in RepeatedUint32List) { - dataSize += pb::CodedOutputStream.ComputeUInt32SizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedUint32_.Count; - } - { - int dataSize = 0; - foreach (ulong element in RepeatedUint64List) { - dataSize += pb::CodedOutputStream.ComputeUInt64SizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedUint64_.Count; - } - { - int dataSize = 0; - foreach (int element in RepeatedSint32List) { - dataSize += pb::CodedOutputStream.ComputeSInt32SizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedSint32_.Count; - } - { - int dataSize = 0; - foreach (long element in RepeatedSint64List) { - dataSize += pb::CodedOutputStream.ComputeSInt64SizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedSint64_.Count; - } - { - int dataSize = 0; - dataSize = 4 * repeatedFixed32_.Count; - size += dataSize; - size += 2 * repeatedFixed32_.Count; - } - { - int dataSize = 0; - dataSize = 8 * repeatedFixed64_.Count; - size += dataSize; - size += 2 * repeatedFixed64_.Count; - } - { - int dataSize = 0; - dataSize = 4 * repeatedSfixed32_.Count; - size += dataSize; - size += 2 * repeatedSfixed32_.Count; - } - { - int dataSize = 0; - dataSize = 8 * repeatedSfixed64_.Count; - size += dataSize; - size += 2 * repeatedSfixed64_.Count; - } - { - int dataSize = 0; - dataSize = 4 * repeatedFloat_.Count; - size += dataSize; - size += 2 * repeatedFloat_.Count; - } - { - int dataSize = 0; - dataSize = 8 * repeatedDouble_.Count; - size += dataSize; - size += 2 * repeatedDouble_.Count; - } - { - int dataSize = 0; - dataSize = 1 * repeatedBool_.Count; - size += dataSize; - size += 2 * repeatedBool_.Count; - } - { - int dataSize = 0; - foreach (string element in RepeatedStringList) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedString_.Count; - } - { - int dataSize = 0; - foreach (pb::ByteString element in RepeatedBytesList) { - dataSize += pb::CodedOutputStream.ComputeBytesSizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedBytes_.Count; - } - foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.RepeatedGroup element in RepeatedGroupList) { - size += pb::CodedOutputStream.ComputeGroupSize(46, element); - } - foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage element in RepeatedNestedMessageList) { - size += pb::CodedOutputStream.ComputeMessageSize(48, element); - } - foreach (global::Google.ProtocolBuffers.TestProtos.ForeignMessageLite element in RepeatedForeignMessageList) { - size += pb::CodedOutputStream.ComputeMessageSize(49, element); - } - foreach (global::Google.ProtocolBuffers.TestProtos.ImportMessageLite element in RepeatedImportMessageList) { - size += pb::CodedOutputStream.ComputeMessageSize(50, element); - } - { - int dataSize = 0; - if (repeatedNestedEnum_.Count > 0) { - foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedEnum element in repeatedNestedEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 2 * repeatedNestedEnum_.Count; - } - } - { - int dataSize = 0; - if (repeatedForeignEnum_.Count > 0) { - foreach (global::Google.ProtocolBuffers.TestProtos.ForeignEnumLite element in repeatedForeignEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 2 * repeatedForeignEnum_.Count; - } - } - { - int dataSize = 0; - if (repeatedImportEnum_.Count > 0) { - foreach (global::Google.ProtocolBuffers.TestProtos.ImportEnumLite element in repeatedImportEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 2 * repeatedImportEnum_.Count; - } - } - { - int dataSize = 0; - foreach (string element in RepeatedStringPieceList) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedStringPiece_.Count; - } - { - int dataSize = 0; - foreach (string element in RepeatedCordList) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedCord_.Count; - } - foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage element in RepeatedLazyMessageList) { - size += pb::CodedOutputStream.ComputeMessageSize(57, element); - } - if (hasDefaultInt32) { - size += pb::CodedOutputStream.ComputeInt32Size(61, DefaultInt32); - } - if (hasDefaultInt64) { - size += pb::CodedOutputStream.ComputeInt64Size(62, DefaultInt64); - } - if (hasDefaultUint32) { - size += pb::CodedOutputStream.ComputeUInt32Size(63, DefaultUint32); - } - if (hasDefaultUint64) { - size += pb::CodedOutputStream.ComputeUInt64Size(64, DefaultUint64); - } - if (hasDefaultSint32) { - size += pb::CodedOutputStream.ComputeSInt32Size(65, DefaultSint32); - } - if (hasDefaultSint64) { - size += pb::CodedOutputStream.ComputeSInt64Size(66, DefaultSint64); - } - if (hasDefaultFixed32) { - size += pb::CodedOutputStream.ComputeFixed32Size(67, DefaultFixed32); - } - if (hasDefaultFixed64) { - size += pb::CodedOutputStream.ComputeFixed64Size(68, DefaultFixed64); - } - if (hasDefaultSfixed32) { - size += pb::CodedOutputStream.ComputeSFixed32Size(69, DefaultSfixed32); - } - if (hasDefaultSfixed64) { - size += pb::CodedOutputStream.ComputeSFixed64Size(70, DefaultSfixed64); - } - if (hasDefaultFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(71, DefaultFloat); - } - if (hasDefaultDouble) { - size += pb::CodedOutputStream.ComputeDoubleSize(72, DefaultDouble); - } - if (hasDefaultBool) { - size += pb::CodedOutputStream.ComputeBoolSize(73, DefaultBool); - } - if (hasDefaultString) { - size += pb::CodedOutputStream.ComputeStringSize(74, DefaultString); - } - if (hasDefaultBytes) { - size += pb::CodedOutputStream.ComputeBytesSize(75, DefaultBytes); - } - if (hasDefaultNestedEnum) { - size += pb::CodedOutputStream.ComputeEnumSize(81, (int) DefaultNestedEnum); - } - if (hasDefaultForeignEnum) { - size += pb::CodedOutputStream.ComputeEnumSize(82, (int) DefaultForeignEnum); - } - if (hasDefaultImportEnum) { - size += pb::CodedOutputStream.ComputeEnumSize(83, (int) DefaultImportEnum); - } - if (hasDefaultStringPiece) { - size += pb::CodedOutputStream.ComputeStringSize(84, DefaultStringPiece); - } - if (hasDefaultCord) { - size += pb::CodedOutputStream.ComputeStringSize(85, DefaultCord); - } - if (oneofFieldCase_ == OneofFieldOneofCase.OneofUint32) { - size += pb::CodedOutputStream.ComputeUInt32Size(111, OneofUint32); - } - if (oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(112, OneofNestedMessage); - } - if (oneofFieldCase_ == OneofFieldOneofCase.OneofString) { - size += pb::CodedOutputStream.ComputeStringSize(113, OneofString); - } - if (oneofFieldCase_ == OneofFieldOneofCase.OneofBytes) { - size += pb::CodedOutputStream.ComputeBytesSize(114, OneofBytes); - } - memoizedSerializedSize = size; - return size; - } - #region Lite runtime methods - public override int GetHashCode() { - int hash = GetType().GetHashCode(); - if (hasOptionalInt32) { - hash ^= optionalInt32_.GetHashCode(); - } - if (hasOptionalInt64) { - hash ^= optionalInt64_.GetHashCode(); - } - if (hasOptionalUint32) { - hash ^= optionalUint32_.GetHashCode(); - } - if (hasOptionalUint64) { - hash ^= optionalUint64_.GetHashCode(); - } - if (hasOptionalSint32) { - hash ^= optionalSint32_.GetHashCode(); - } - if (hasOptionalSint64) { - hash ^= optionalSint64_.GetHashCode(); - } - if (hasOptionalFixed32) { - hash ^= optionalFixed32_.GetHashCode(); - } - if (hasOptionalFixed64) { - hash ^= optionalFixed64_.GetHashCode(); - } - if (hasOptionalSfixed32) { - hash ^= optionalSfixed32_.GetHashCode(); - } - if (hasOptionalSfixed64) { - hash ^= optionalSfixed64_.GetHashCode(); - } - if (hasOptionalFloat) { - hash ^= optionalFloat_.GetHashCode(); - } - if (hasOptionalDouble) { - hash ^= optionalDouble_.GetHashCode(); - } - if (hasOptionalBool) { - hash ^= optionalBool_.GetHashCode(); - } - if (hasOptionalString) { - hash ^= optionalString_.GetHashCode(); - } - if (hasOptionalBytes) { - hash ^= optionalBytes_.GetHashCode(); - } - if (hasOptionalGroup) hash ^= optionalGroup_.GetHashCode(); - if (hasOptionalNestedMessage) hash ^= optionalNestedMessage_.GetHashCode(); - if (hasOptionalForeignMessage) hash ^= optionalForeignMessage_.GetHashCode(); - if (hasOptionalImportMessage) hash ^= optionalImportMessage_.GetHashCode(); - if (hasOptionalNestedEnum) { - hash ^= optionalNestedEnum_.GetHashCode(); - } - if (hasOptionalForeignEnum) { - hash ^= optionalForeignEnum_.GetHashCode(); - } - if (hasOptionalImportEnum) { - hash ^= optionalImportEnum_.GetHashCode(); - } - if (hasOptionalStringPiece) { - hash ^= optionalStringPiece_.GetHashCode(); - } - if (hasOptionalCord) { - hash ^= optionalCord_.GetHashCode(); - } - if (hasOptionalPublicImportMessage) hash ^= optionalPublicImportMessage_.GetHashCode(); - if (hasOptionalLazyMessage) hash ^= optionalLazyMessage_.GetHashCode(); - foreach(int i in repeatedInt32_) - hash ^= i.GetHashCode(); - foreach(long i in repeatedInt64_) - hash ^= i.GetHashCode(); - foreach(uint i in repeatedUint32_) - hash ^= i.GetHashCode(); - foreach(ulong i in repeatedUint64_) - hash ^= i.GetHashCode(); - foreach(int i in repeatedSint32_) - hash ^= i.GetHashCode(); - foreach(long i in repeatedSint64_) - hash ^= i.GetHashCode(); - foreach(uint i in repeatedFixed32_) - hash ^= i.GetHashCode(); - foreach(ulong i in repeatedFixed64_) - hash ^= i.GetHashCode(); - foreach(int i in repeatedSfixed32_) - hash ^= i.GetHashCode(); - foreach(long i in repeatedSfixed64_) - hash ^= i.GetHashCode(); - foreach(float i in repeatedFloat_) - hash ^= i.GetHashCode(); - foreach(double i in repeatedDouble_) - hash ^= i.GetHashCode(); - foreach(bool i in repeatedBool_) - hash ^= i.GetHashCode(); - foreach(string i in repeatedString_) - hash ^= i.GetHashCode(); - foreach(pb::ByteString i in repeatedBytes_) - hash ^= i.GetHashCode(); - foreach(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.RepeatedGroup i in repeatedGroup_) - hash ^= i.GetHashCode(); - foreach(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage i in repeatedNestedMessage_) - hash ^= i.GetHashCode(); - foreach(global::Google.ProtocolBuffers.TestProtos.ForeignMessageLite i in repeatedForeignMessage_) - hash ^= i.GetHashCode(); - foreach(global::Google.ProtocolBuffers.TestProtos.ImportMessageLite i in repeatedImportMessage_) - hash ^= i.GetHashCode(); - foreach(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedEnum i in repeatedNestedEnum_) - hash ^= i.GetHashCode(); - foreach(global::Google.ProtocolBuffers.TestProtos.ForeignEnumLite i in repeatedForeignEnum_) - hash ^= i.GetHashCode(); - foreach(global::Google.ProtocolBuffers.TestProtos.ImportEnumLite i in repeatedImportEnum_) - hash ^= i.GetHashCode(); - foreach(string i in repeatedStringPiece_) - hash ^= i.GetHashCode(); - foreach(string i in repeatedCord_) - hash ^= i.GetHashCode(); - foreach(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage i in repeatedLazyMessage_) - hash ^= i.GetHashCode(); - if (hasDefaultInt32) { - hash ^= defaultInt32_.GetHashCode(); - } - if (hasDefaultInt64) { - hash ^= defaultInt64_.GetHashCode(); - } - if (hasDefaultUint32) { - hash ^= defaultUint32_.GetHashCode(); - } - if (hasDefaultUint64) { - hash ^= defaultUint64_.GetHashCode(); - } - if (hasDefaultSint32) { - hash ^= defaultSint32_.GetHashCode(); - } - if (hasDefaultSint64) { - hash ^= defaultSint64_.GetHashCode(); - } - if (hasDefaultFixed32) { - hash ^= defaultFixed32_.GetHashCode(); - } - if (hasDefaultFixed64) { - hash ^= defaultFixed64_.GetHashCode(); - } - if (hasDefaultSfixed32) { - hash ^= defaultSfixed32_.GetHashCode(); - } - if (hasDefaultSfixed64) { - hash ^= defaultSfixed64_.GetHashCode(); - } - if (hasDefaultFloat) { - hash ^= defaultFloat_.GetHashCode(); - } - if (hasDefaultDouble) { - hash ^= defaultDouble_.GetHashCode(); - } - if (hasDefaultBool) { - hash ^= defaultBool_.GetHashCode(); - } - if (hasDefaultString) { - hash ^= defaultString_.GetHashCode(); - } - if (hasDefaultBytes) { - hash ^= defaultBytes_.GetHashCode(); - } - if (hasDefaultNestedEnum) { - hash ^= defaultNestedEnum_.GetHashCode(); - } - if (hasDefaultForeignEnum) { - hash ^= defaultForeignEnum_.GetHashCode(); - } - if (hasDefaultImportEnum) { - hash ^= defaultImportEnum_.GetHashCode(); - } - if (hasDefaultStringPiece) { - hash ^= defaultStringPiece_.GetHashCode(); - } - if (hasDefaultCord) { - hash ^= defaultCord_.GetHashCode(); - } - if (oneofFieldCase_ != OneofFieldOneofCase.None) { - hash ^= oneofField_.GetHashCode(); - } - return hash; - } - - public override bool Equals(object obj) { - TestAllTypesLite other = obj as TestAllTypesLite; - if (other == null) return false; - if (hasOptionalInt32 != other.hasOptionalInt32 || (hasOptionalInt32 && !optionalInt32_.Equals(other.optionalInt32_))) return false; - if (hasOptionalInt64 != other.hasOptionalInt64 || (hasOptionalInt64 && !optionalInt64_.Equals(other.optionalInt64_))) return false; - if (hasOptionalUint32 != other.hasOptionalUint32 || (hasOptionalUint32 && !optionalUint32_.Equals(other.optionalUint32_))) return false; - if (hasOptionalUint64 != other.hasOptionalUint64 || (hasOptionalUint64 && !optionalUint64_.Equals(other.optionalUint64_))) return false; - if (hasOptionalSint32 != other.hasOptionalSint32 || (hasOptionalSint32 && !optionalSint32_.Equals(other.optionalSint32_))) return false; - if (hasOptionalSint64 != other.hasOptionalSint64 || (hasOptionalSint64 && !optionalSint64_.Equals(other.optionalSint64_))) return false; - if (hasOptionalFixed32 != other.hasOptionalFixed32 || (hasOptionalFixed32 && !optionalFixed32_.Equals(other.optionalFixed32_))) return false; - if (hasOptionalFixed64 != other.hasOptionalFixed64 || (hasOptionalFixed64 && !optionalFixed64_.Equals(other.optionalFixed64_))) return false; - if (hasOptionalSfixed32 != other.hasOptionalSfixed32 || (hasOptionalSfixed32 && !optionalSfixed32_.Equals(other.optionalSfixed32_))) return false; - if (hasOptionalSfixed64 != other.hasOptionalSfixed64 || (hasOptionalSfixed64 && !optionalSfixed64_.Equals(other.optionalSfixed64_))) return false; - if (hasOptionalFloat != other.hasOptionalFloat || (hasOptionalFloat && !optionalFloat_.Equals(other.optionalFloat_))) return false; - if (hasOptionalDouble != other.hasOptionalDouble || (hasOptionalDouble && !optionalDouble_.Equals(other.optionalDouble_))) return false; - if (hasOptionalBool != other.hasOptionalBool || (hasOptionalBool && !optionalBool_.Equals(other.optionalBool_))) return false; - if (hasOptionalString != other.hasOptionalString || (hasOptionalString && !optionalString_.Equals(other.optionalString_))) return false; - if (hasOptionalBytes != other.hasOptionalBytes || (hasOptionalBytes && !optionalBytes_.Equals(other.optionalBytes_))) return false; - if (hasOptionalGroup != other.hasOptionalGroup || (hasOptionalGroup && !optionalGroup_.Equals(other.optionalGroup_))) return false; - if (hasOptionalNestedMessage != other.hasOptionalNestedMessage || (hasOptionalNestedMessage && !optionalNestedMessage_.Equals(other.optionalNestedMessage_))) return false; - if (hasOptionalForeignMessage != other.hasOptionalForeignMessage || (hasOptionalForeignMessage && !optionalForeignMessage_.Equals(other.optionalForeignMessage_))) return false; - if (hasOptionalImportMessage != other.hasOptionalImportMessage || (hasOptionalImportMessage && !optionalImportMessage_.Equals(other.optionalImportMessage_))) return false; - if (hasOptionalNestedEnum != other.hasOptionalNestedEnum || (hasOptionalNestedEnum && !optionalNestedEnum_.Equals(other.optionalNestedEnum_))) return false; - if (hasOptionalForeignEnum != other.hasOptionalForeignEnum || (hasOptionalForeignEnum && !optionalForeignEnum_.Equals(other.optionalForeignEnum_))) return false; - if (hasOptionalImportEnum != other.hasOptionalImportEnum || (hasOptionalImportEnum && !optionalImportEnum_.Equals(other.optionalImportEnum_))) return false; - if (hasOptionalStringPiece != other.hasOptionalStringPiece || (hasOptionalStringPiece && !optionalStringPiece_.Equals(other.optionalStringPiece_))) return false; - if (hasOptionalCord != other.hasOptionalCord || (hasOptionalCord && !optionalCord_.Equals(other.optionalCord_))) return false; - if (hasOptionalPublicImportMessage != other.hasOptionalPublicImportMessage || (hasOptionalPublicImportMessage && !optionalPublicImportMessage_.Equals(other.optionalPublicImportMessage_))) return false; - if (hasOptionalLazyMessage != other.hasOptionalLazyMessage || (hasOptionalLazyMessage && !optionalLazyMessage_.Equals(other.optionalLazyMessage_))) return false; - if(repeatedInt32_.Count != other.repeatedInt32_.Count) return false; - for(int ix=0; ix < repeatedInt32_.Count; ix++) - if(!repeatedInt32_[ix].Equals(other.repeatedInt32_[ix])) return false; - if(repeatedInt64_.Count != other.repeatedInt64_.Count) return false; - for(int ix=0; ix < repeatedInt64_.Count; ix++) - if(!repeatedInt64_[ix].Equals(other.repeatedInt64_[ix])) return false; - if(repeatedUint32_.Count != other.repeatedUint32_.Count) return false; - for(int ix=0; ix < repeatedUint32_.Count; ix++) - if(!repeatedUint32_[ix].Equals(other.repeatedUint32_[ix])) return false; - if(repeatedUint64_.Count != other.repeatedUint64_.Count) return false; - for(int ix=0; ix < repeatedUint64_.Count; ix++) - if(!repeatedUint64_[ix].Equals(other.repeatedUint64_[ix])) return false; - if(repeatedSint32_.Count != other.repeatedSint32_.Count) return false; - for(int ix=0; ix < repeatedSint32_.Count; ix++) - if(!repeatedSint32_[ix].Equals(other.repeatedSint32_[ix])) return false; - if(repeatedSint64_.Count != other.repeatedSint64_.Count) return false; - for(int ix=0; ix < repeatedSint64_.Count; ix++) - if(!repeatedSint64_[ix].Equals(other.repeatedSint64_[ix])) return false; - if(repeatedFixed32_.Count != other.repeatedFixed32_.Count) return false; - for(int ix=0; ix < repeatedFixed32_.Count; ix++) - if(!repeatedFixed32_[ix].Equals(other.repeatedFixed32_[ix])) return false; - if(repeatedFixed64_.Count != other.repeatedFixed64_.Count) return false; - for(int ix=0; ix < repeatedFixed64_.Count; ix++) - if(!repeatedFixed64_[ix].Equals(other.repeatedFixed64_[ix])) return false; - if(repeatedSfixed32_.Count != other.repeatedSfixed32_.Count) return false; - for(int ix=0; ix < repeatedSfixed32_.Count; ix++) - if(!repeatedSfixed32_[ix].Equals(other.repeatedSfixed32_[ix])) return false; - if(repeatedSfixed64_.Count != other.repeatedSfixed64_.Count) return false; - for(int ix=0; ix < repeatedSfixed64_.Count; ix++) - if(!repeatedSfixed64_[ix].Equals(other.repeatedSfixed64_[ix])) return false; - if(repeatedFloat_.Count != other.repeatedFloat_.Count) return false; - for(int ix=0; ix < repeatedFloat_.Count; ix++) - if(!repeatedFloat_[ix].Equals(other.repeatedFloat_[ix])) return false; - if(repeatedDouble_.Count != other.repeatedDouble_.Count) return false; - for(int ix=0; ix < repeatedDouble_.Count; ix++) - if(!repeatedDouble_[ix].Equals(other.repeatedDouble_[ix])) return false; - if(repeatedBool_.Count != other.repeatedBool_.Count) return false; - for(int ix=0; ix < repeatedBool_.Count; ix++) - if(!repeatedBool_[ix].Equals(other.repeatedBool_[ix])) return false; - if(repeatedString_.Count != other.repeatedString_.Count) return false; - for(int ix=0; ix < repeatedString_.Count; ix++) - if(!repeatedString_[ix].Equals(other.repeatedString_[ix])) return false; - if(repeatedBytes_.Count != other.repeatedBytes_.Count) return false; - for(int ix=0; ix < repeatedBytes_.Count; ix++) - if(!repeatedBytes_[ix].Equals(other.repeatedBytes_[ix])) return false; - if(repeatedGroup_.Count != other.repeatedGroup_.Count) return false; - for(int ix=0; ix < repeatedGroup_.Count; ix++) - if(!repeatedGroup_[ix].Equals(other.repeatedGroup_[ix])) return false; - if(repeatedNestedMessage_.Count != other.repeatedNestedMessage_.Count) return false; - for(int ix=0; ix < repeatedNestedMessage_.Count; ix++) - if(!repeatedNestedMessage_[ix].Equals(other.repeatedNestedMessage_[ix])) return false; - if(repeatedForeignMessage_.Count != other.repeatedForeignMessage_.Count) return false; - for(int ix=0; ix < repeatedForeignMessage_.Count; ix++) - if(!repeatedForeignMessage_[ix].Equals(other.repeatedForeignMessage_[ix])) return false; - if(repeatedImportMessage_.Count != other.repeatedImportMessage_.Count) return false; - for(int ix=0; ix < repeatedImportMessage_.Count; ix++) - if(!repeatedImportMessage_[ix].Equals(other.repeatedImportMessage_[ix])) return false; - if(repeatedNestedEnum_.Count != other.repeatedNestedEnum_.Count) return false; - for(int ix=0; ix < repeatedNestedEnum_.Count; ix++) - if(!repeatedNestedEnum_[ix].Equals(other.repeatedNestedEnum_[ix])) return false; - if(repeatedForeignEnum_.Count != other.repeatedForeignEnum_.Count) return false; - for(int ix=0; ix < repeatedForeignEnum_.Count; ix++) - if(!repeatedForeignEnum_[ix].Equals(other.repeatedForeignEnum_[ix])) return false; - if(repeatedImportEnum_.Count != other.repeatedImportEnum_.Count) return false; - for(int ix=0; ix < repeatedImportEnum_.Count; ix++) - if(!repeatedImportEnum_[ix].Equals(other.repeatedImportEnum_[ix])) return false; - if(repeatedStringPiece_.Count != other.repeatedStringPiece_.Count) return false; - for(int ix=0; ix < repeatedStringPiece_.Count; ix++) - if(!repeatedStringPiece_[ix].Equals(other.repeatedStringPiece_[ix])) return false; - if(repeatedCord_.Count != other.repeatedCord_.Count) return false; - for(int ix=0; ix < repeatedCord_.Count; ix++) - if(!repeatedCord_[ix].Equals(other.repeatedCord_[ix])) return false; - if(repeatedLazyMessage_.Count != other.repeatedLazyMessage_.Count) return false; - for(int ix=0; ix < repeatedLazyMessage_.Count; ix++) - if(!repeatedLazyMessage_[ix].Equals(other.repeatedLazyMessage_[ix])) return false; - if (hasDefaultInt32 != other.hasDefaultInt32 || (hasDefaultInt32 && !defaultInt32_.Equals(other.defaultInt32_))) return false; - if (hasDefaultInt64 != other.hasDefaultInt64 || (hasDefaultInt64 && !defaultInt64_.Equals(other.defaultInt64_))) return false; - if (hasDefaultUint32 != other.hasDefaultUint32 || (hasDefaultUint32 && !defaultUint32_.Equals(other.defaultUint32_))) return false; - if (hasDefaultUint64 != other.hasDefaultUint64 || (hasDefaultUint64 && !defaultUint64_.Equals(other.defaultUint64_))) return false; - if (hasDefaultSint32 != other.hasDefaultSint32 || (hasDefaultSint32 && !defaultSint32_.Equals(other.defaultSint32_))) return false; - if (hasDefaultSint64 != other.hasDefaultSint64 || (hasDefaultSint64 && !defaultSint64_.Equals(other.defaultSint64_))) return false; - if (hasDefaultFixed32 != other.hasDefaultFixed32 || (hasDefaultFixed32 && !defaultFixed32_.Equals(other.defaultFixed32_))) return false; - if (hasDefaultFixed64 != other.hasDefaultFixed64 || (hasDefaultFixed64 && !defaultFixed64_.Equals(other.defaultFixed64_))) return false; - if (hasDefaultSfixed32 != other.hasDefaultSfixed32 || (hasDefaultSfixed32 && !defaultSfixed32_.Equals(other.defaultSfixed32_))) return false; - if (hasDefaultSfixed64 != other.hasDefaultSfixed64 || (hasDefaultSfixed64 && !defaultSfixed64_.Equals(other.defaultSfixed64_))) return false; - if (hasDefaultFloat != other.hasDefaultFloat || (hasDefaultFloat && !defaultFloat_.Equals(other.defaultFloat_))) return false; - if (hasDefaultDouble != other.hasDefaultDouble || (hasDefaultDouble && !defaultDouble_.Equals(other.defaultDouble_))) return false; - if (hasDefaultBool != other.hasDefaultBool || (hasDefaultBool && !defaultBool_.Equals(other.defaultBool_))) return false; - if (hasDefaultString != other.hasDefaultString || (hasDefaultString && !defaultString_.Equals(other.defaultString_))) return false; - if (hasDefaultBytes != other.hasDefaultBytes || (hasDefaultBytes && !defaultBytes_.Equals(other.defaultBytes_))) return false; - if (hasDefaultNestedEnum != other.hasDefaultNestedEnum || (hasDefaultNestedEnum && !defaultNestedEnum_.Equals(other.defaultNestedEnum_))) return false; - if (hasDefaultForeignEnum != other.hasDefaultForeignEnum || (hasDefaultForeignEnum && !defaultForeignEnum_.Equals(other.defaultForeignEnum_))) return false; - if (hasDefaultImportEnum != other.hasDefaultImportEnum || (hasDefaultImportEnum && !defaultImportEnum_.Equals(other.defaultImportEnum_))) return false; - if (hasDefaultStringPiece != other.hasDefaultStringPiece || (hasDefaultStringPiece && !defaultStringPiece_.Equals(other.defaultStringPiece_))) return false; - if (hasDefaultCord != other.hasDefaultCord || (hasDefaultCord && !defaultCord_.Equals(other.defaultCord_))) return false; - if (!OneofUint32.Equals(other.OneofUint32)) return false; - if (!OneofNestedMessage.Equals(other.OneofNestedMessage)) return false; - if (!OneofString.Equals(other.OneofString)) return false; - if (!OneofBytes.Equals(other.OneofBytes)) return false; - return true; - } - - public override void PrintTo(global::System.IO.TextWriter writer) { - PrintField("optional_int32", hasOptionalInt32, optionalInt32_, writer); - PrintField("optional_int64", hasOptionalInt64, optionalInt64_, writer); - PrintField("optional_uint32", hasOptionalUint32, optionalUint32_, writer); - PrintField("optional_uint64", hasOptionalUint64, optionalUint64_, writer); - PrintField("optional_sint32", hasOptionalSint32, optionalSint32_, writer); - PrintField("optional_sint64", hasOptionalSint64, optionalSint64_, writer); - PrintField("optional_fixed32", hasOptionalFixed32, optionalFixed32_, writer); - PrintField("optional_fixed64", hasOptionalFixed64, optionalFixed64_, writer); - PrintField("optional_sfixed32", hasOptionalSfixed32, optionalSfixed32_, writer); - PrintField("optional_sfixed64", hasOptionalSfixed64, optionalSfixed64_, writer); - PrintField("optional_float", hasOptionalFloat, optionalFloat_, writer); - PrintField("optional_double", hasOptionalDouble, optionalDouble_, writer); - PrintField("optional_bool", hasOptionalBool, optionalBool_, writer); - PrintField("optional_string", hasOptionalString, optionalString_, writer); - PrintField("optional_bytes", hasOptionalBytes, optionalBytes_, writer); - PrintField("OptionalGroup", hasOptionalGroup, optionalGroup_, writer); - PrintField("optional_nested_message", hasOptionalNestedMessage, optionalNestedMessage_, writer); - PrintField("optional_foreign_message", hasOptionalForeignMessage, optionalForeignMessage_, writer); - PrintField("optional_import_message", hasOptionalImportMessage, optionalImportMessage_, writer); - PrintField("optional_nested_enum", hasOptionalNestedEnum, optionalNestedEnum_, writer); - PrintField("optional_foreign_enum", hasOptionalForeignEnum, optionalForeignEnum_, writer); - PrintField("optional_import_enum", hasOptionalImportEnum, optionalImportEnum_, writer); - PrintField("optional_string_piece", hasOptionalStringPiece, optionalStringPiece_, writer); - PrintField("optional_cord", hasOptionalCord, optionalCord_, writer); - PrintField("optional_public_import_message", hasOptionalPublicImportMessage, optionalPublicImportMessage_, writer); - PrintField("optional_lazy_message", hasOptionalLazyMessage, optionalLazyMessage_, writer); - PrintField("repeated_int32", repeatedInt32_, writer); - PrintField("repeated_int64", repeatedInt64_, writer); - PrintField("repeated_uint32", repeatedUint32_, writer); - PrintField("repeated_uint64", repeatedUint64_, writer); - PrintField("repeated_sint32", repeatedSint32_, writer); - PrintField("repeated_sint64", repeatedSint64_, writer); - PrintField("repeated_fixed32", repeatedFixed32_, writer); - PrintField("repeated_fixed64", repeatedFixed64_, writer); - PrintField("repeated_sfixed32", repeatedSfixed32_, writer); - PrintField("repeated_sfixed64", repeatedSfixed64_, writer); - PrintField("repeated_float", repeatedFloat_, writer); - PrintField("repeated_double", repeatedDouble_, writer); - PrintField("repeated_bool", repeatedBool_, writer); - PrintField("repeated_string", repeatedString_, writer); - PrintField("repeated_bytes", repeatedBytes_, writer); - PrintField("RepeatedGroup", repeatedGroup_, writer); - PrintField("repeated_nested_message", repeatedNestedMessage_, writer); - PrintField("repeated_foreign_message", repeatedForeignMessage_, writer); - PrintField("repeated_import_message", repeatedImportMessage_, writer); - PrintField("repeated_nested_enum", repeatedNestedEnum_, writer); - PrintField("repeated_foreign_enum", repeatedForeignEnum_, writer); - PrintField("repeated_import_enum", repeatedImportEnum_, writer); - PrintField("repeated_string_piece", repeatedStringPiece_, writer); - PrintField("repeated_cord", repeatedCord_, writer); - PrintField("repeated_lazy_message", repeatedLazyMessage_, writer); - PrintField("default_int32", hasDefaultInt32, defaultInt32_, writer); - PrintField("default_int64", hasDefaultInt64, defaultInt64_, writer); - PrintField("default_uint32", hasDefaultUint32, defaultUint32_, writer); - PrintField("default_uint64", hasDefaultUint64, defaultUint64_, writer); - PrintField("default_sint32", hasDefaultSint32, defaultSint32_, writer); - PrintField("default_sint64", hasDefaultSint64, defaultSint64_, writer); - PrintField("default_fixed32", hasDefaultFixed32, defaultFixed32_, writer); - PrintField("default_fixed64", hasDefaultFixed64, defaultFixed64_, writer); - PrintField("default_sfixed32", hasDefaultSfixed32, defaultSfixed32_, writer); - PrintField("default_sfixed64", hasDefaultSfixed64, defaultSfixed64_, writer); - PrintField("default_float", hasDefaultFloat, defaultFloat_, writer); - PrintField("default_double", hasDefaultDouble, defaultDouble_, writer); - PrintField("default_bool", hasDefaultBool, defaultBool_, writer); - PrintField("default_string", hasDefaultString, defaultString_, writer); - PrintField("default_bytes", hasDefaultBytes, defaultBytes_, writer); - PrintField("default_nested_enum", hasDefaultNestedEnum, defaultNestedEnum_, writer); - PrintField("default_foreign_enum", hasDefaultForeignEnum, defaultForeignEnum_, writer); - PrintField("default_import_enum", hasDefaultImportEnum, defaultImportEnum_, writer); - PrintField("default_string_piece", hasDefaultStringPiece, defaultStringPiece_, writer); - PrintField("default_cord", hasDefaultCord, defaultCord_, writer); - PrintField("oneof_uint32", oneofFieldCase_ == OneofFieldOneofCase.OneofUint32, oneofField_, writer); - PrintField("oneof_nested_message", oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage, oneofField_, writer); - PrintField("oneof_string", oneofFieldCase_ == OneofFieldOneofCase.OneofString, oneofField_, writer); - PrintField("oneof_bytes", oneofFieldCase_ == OneofFieldOneofCase.OneofBytes, oneofField_, writer); - } - #endregion - - public static TestAllTypesLite ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestAllTypesLite ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestAllTypesLite ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestAllTypesLite ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestAllTypesLite ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestAllTypesLite ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestAllTypesLite ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestAllTypesLite ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestAllTypesLite ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestAllTypesLite ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestAllTypesLite MakeReadOnly() { - repeatedInt32_.MakeReadOnly(); - repeatedInt64_.MakeReadOnly(); - repeatedUint32_.MakeReadOnly(); - repeatedUint64_.MakeReadOnly(); - repeatedSint32_.MakeReadOnly(); - repeatedSint64_.MakeReadOnly(); - repeatedFixed32_.MakeReadOnly(); - repeatedFixed64_.MakeReadOnly(); - repeatedSfixed32_.MakeReadOnly(); - repeatedSfixed64_.MakeReadOnly(); - repeatedFloat_.MakeReadOnly(); - repeatedDouble_.MakeReadOnly(); - repeatedBool_.MakeReadOnly(); - repeatedString_.MakeReadOnly(); - repeatedBytes_.MakeReadOnly(); - repeatedGroup_.MakeReadOnly(); - repeatedNestedMessage_.MakeReadOnly(); - repeatedForeignMessage_.MakeReadOnly(); - repeatedImportMessage_.MakeReadOnly(); - repeatedNestedEnum_.MakeReadOnly(); - repeatedForeignEnum_.MakeReadOnly(); - repeatedImportEnum_.MakeReadOnly(); - repeatedStringPiece_.MakeReadOnly(); - repeatedCord_.MakeReadOnly(); - repeatedLazyMessage_.MakeReadOnly(); - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestAllTypesLite prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilderLite { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestAllTypesLite cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestAllTypesLite result; - - private TestAllTypesLite PrepareBuilder() { - if (resultIsReadOnly) { - TestAllTypesLite original = result; - result = new TestAllTypesLite(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestAllTypesLite MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override TestAllTypesLite DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.DefaultInstance; } - } - - public override TestAllTypesLite BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessageLite other) { - if (other is TestAllTypesLite) { - return MergeFrom((TestAllTypesLite) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestAllTypesLite other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasOptionalInt32) { - OptionalInt32 = other.OptionalInt32; - } - if (other.HasOptionalInt64) { - OptionalInt64 = other.OptionalInt64; - } - if (other.HasOptionalUint32) { - OptionalUint32 = other.OptionalUint32; - } - if (other.HasOptionalUint64) { - OptionalUint64 = other.OptionalUint64; - } - if (other.HasOptionalSint32) { - OptionalSint32 = other.OptionalSint32; - } - if (other.HasOptionalSint64) { - OptionalSint64 = other.OptionalSint64; - } - if (other.HasOptionalFixed32) { - OptionalFixed32 = other.OptionalFixed32; - } - if (other.HasOptionalFixed64) { - OptionalFixed64 = other.OptionalFixed64; - } - if (other.HasOptionalSfixed32) { - OptionalSfixed32 = other.OptionalSfixed32; - } - if (other.HasOptionalSfixed64) { - OptionalSfixed64 = other.OptionalSfixed64; - } - if (other.HasOptionalFloat) { - OptionalFloat = other.OptionalFloat; - } - if (other.HasOptionalDouble) { - OptionalDouble = other.OptionalDouble; - } - if (other.HasOptionalBool) { - OptionalBool = other.OptionalBool; - } - if (other.HasOptionalString) { - OptionalString = other.OptionalString; - } - if (other.HasOptionalBytes) { - OptionalBytes = other.OptionalBytes; - } - if (other.HasOptionalGroup) { - MergeOptionalGroup(other.OptionalGroup); - } - if (other.HasOptionalNestedMessage) { - MergeOptionalNestedMessage(other.OptionalNestedMessage); - } - if (other.HasOptionalForeignMessage) { - MergeOptionalForeignMessage(other.OptionalForeignMessage); - } - if (other.HasOptionalImportMessage) { - MergeOptionalImportMessage(other.OptionalImportMessage); - } - if (other.HasOptionalNestedEnum) { - OptionalNestedEnum = other.OptionalNestedEnum; - } - if (other.HasOptionalForeignEnum) { - OptionalForeignEnum = other.OptionalForeignEnum; - } - if (other.HasOptionalImportEnum) { - OptionalImportEnum = other.OptionalImportEnum; - } - if (other.HasOptionalStringPiece) { - OptionalStringPiece = other.OptionalStringPiece; - } - if (other.HasOptionalCord) { - OptionalCord = other.OptionalCord; - } - if (other.HasOptionalPublicImportMessage) { - MergeOptionalPublicImportMessage(other.OptionalPublicImportMessage); - } - if (other.HasOptionalLazyMessage) { - MergeOptionalLazyMessage(other.OptionalLazyMessage); - } - if (other.repeatedInt32_.Count != 0) { - result.repeatedInt32_.Add(other.repeatedInt32_); - } - if (other.repeatedInt64_.Count != 0) { - result.repeatedInt64_.Add(other.repeatedInt64_); - } - if (other.repeatedUint32_.Count != 0) { - result.repeatedUint32_.Add(other.repeatedUint32_); - } - if (other.repeatedUint64_.Count != 0) { - result.repeatedUint64_.Add(other.repeatedUint64_); - } - if (other.repeatedSint32_.Count != 0) { - result.repeatedSint32_.Add(other.repeatedSint32_); - } - if (other.repeatedSint64_.Count != 0) { - result.repeatedSint64_.Add(other.repeatedSint64_); - } - if (other.repeatedFixed32_.Count != 0) { - result.repeatedFixed32_.Add(other.repeatedFixed32_); - } - if (other.repeatedFixed64_.Count != 0) { - result.repeatedFixed64_.Add(other.repeatedFixed64_); - } - if (other.repeatedSfixed32_.Count != 0) { - result.repeatedSfixed32_.Add(other.repeatedSfixed32_); - } - if (other.repeatedSfixed64_.Count != 0) { - result.repeatedSfixed64_.Add(other.repeatedSfixed64_); - } - if (other.repeatedFloat_.Count != 0) { - result.repeatedFloat_.Add(other.repeatedFloat_); - } - if (other.repeatedDouble_.Count != 0) { - result.repeatedDouble_.Add(other.repeatedDouble_); - } - if (other.repeatedBool_.Count != 0) { - result.repeatedBool_.Add(other.repeatedBool_); - } - if (other.repeatedString_.Count != 0) { - result.repeatedString_.Add(other.repeatedString_); - } - if (other.repeatedBytes_.Count != 0) { - result.repeatedBytes_.Add(other.repeatedBytes_); - } - if (other.repeatedGroup_.Count != 0) { - result.repeatedGroup_.Add(other.repeatedGroup_); - } - if (other.repeatedNestedMessage_.Count != 0) { - result.repeatedNestedMessage_.Add(other.repeatedNestedMessage_); - } - if (other.repeatedForeignMessage_.Count != 0) { - result.repeatedForeignMessage_.Add(other.repeatedForeignMessage_); - } - if (other.repeatedImportMessage_.Count != 0) { - result.repeatedImportMessage_.Add(other.repeatedImportMessage_); - } - if (other.repeatedNestedEnum_.Count != 0) { - result.repeatedNestedEnum_.Add(other.repeatedNestedEnum_); - } - if (other.repeatedForeignEnum_.Count != 0) { - result.repeatedForeignEnum_.Add(other.repeatedForeignEnum_); - } - if (other.repeatedImportEnum_.Count != 0) { - result.repeatedImportEnum_.Add(other.repeatedImportEnum_); - } - if (other.repeatedStringPiece_.Count != 0) { - result.repeatedStringPiece_.Add(other.repeatedStringPiece_); - } - if (other.repeatedCord_.Count != 0) { - result.repeatedCord_.Add(other.repeatedCord_); - } - if (other.repeatedLazyMessage_.Count != 0) { - result.repeatedLazyMessage_.Add(other.repeatedLazyMessage_); - } - if (other.HasDefaultInt32) { - DefaultInt32 = other.DefaultInt32; - } - if (other.HasDefaultInt64) { - DefaultInt64 = other.DefaultInt64; - } - if (other.HasDefaultUint32) { - DefaultUint32 = other.DefaultUint32; - } - if (other.HasDefaultUint64) { - DefaultUint64 = other.DefaultUint64; - } - if (other.HasDefaultSint32) { - DefaultSint32 = other.DefaultSint32; - } - if (other.HasDefaultSint64) { - DefaultSint64 = other.DefaultSint64; - } - if (other.HasDefaultFixed32) { - DefaultFixed32 = other.DefaultFixed32; - } - if (other.HasDefaultFixed64) { - DefaultFixed64 = other.DefaultFixed64; - } - if (other.HasDefaultSfixed32) { - DefaultSfixed32 = other.DefaultSfixed32; - } - if (other.HasDefaultSfixed64) { - DefaultSfixed64 = other.DefaultSfixed64; - } - if (other.HasDefaultFloat) { - DefaultFloat = other.DefaultFloat; - } - if (other.HasDefaultDouble) { - DefaultDouble = other.DefaultDouble; - } - if (other.HasDefaultBool) { - DefaultBool = other.DefaultBool; - } - if (other.HasDefaultString) { - DefaultString = other.DefaultString; - } - if (other.HasDefaultBytes) { - DefaultBytes = other.DefaultBytes; - } - if (other.HasDefaultNestedEnum) { - DefaultNestedEnum = other.DefaultNestedEnum; - } - if (other.HasDefaultForeignEnum) { - DefaultForeignEnum = other.DefaultForeignEnum; - } - if (other.HasDefaultImportEnum) { - DefaultImportEnum = other.DefaultImportEnum; - } - if (other.HasDefaultStringPiece) { - DefaultStringPiece = other.DefaultStringPiece; - } - if (other.HasDefaultCord) { - DefaultCord = other.DefaultCord; - } - switch (other.OneofFieldCase) { - case OneofFieldOneofCase.OneofUint32: { - SetOneofUint32(other.OneofUint32); - break; - } - case OneofFieldOneofCase.OneofNestedMessage: { - MergeOneofNestedMessage(other.OneofNestedMessage); - break; - } - case OneofFieldOneofCase.OneofString: { - SetOneofString(other.OneofString); - break; - } - case OneofFieldOneofCase.OneofBytes: { - SetOneofBytes(other.OneofBytes); - break; - } - case OneofFieldOneofCase.None: { break; } - } - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testAllTypesLiteFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testAllTypesLiteFieldTags[field_ordinal]; - else { - ParseUnknownField(input, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - return this; - } - ParseUnknownField(input, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasOptionalInt32 = input.ReadInt32(ref result.optionalInt32_); - break; - } - case 16: { - result.hasOptionalInt64 = input.ReadInt64(ref result.optionalInt64_); - break; - } - case 24: { - result.hasOptionalUint32 = input.ReadUInt32(ref result.optionalUint32_); - break; - } - case 32: { - result.hasOptionalUint64 = input.ReadUInt64(ref result.optionalUint64_); - break; - } - case 40: { - result.hasOptionalSint32 = input.ReadSInt32(ref result.optionalSint32_); - break; - } - case 48: { - result.hasOptionalSint64 = input.ReadSInt64(ref result.optionalSint64_); - break; - } - case 61: { - result.hasOptionalFixed32 = input.ReadFixed32(ref result.optionalFixed32_); - break; - } - case 65: { - result.hasOptionalFixed64 = input.ReadFixed64(ref result.optionalFixed64_); - break; - } - case 77: { - result.hasOptionalSfixed32 = input.ReadSFixed32(ref result.optionalSfixed32_); - break; - } - case 81: { - result.hasOptionalSfixed64 = input.ReadSFixed64(ref result.optionalSfixed64_); - break; - } - case 93: { - result.hasOptionalFloat = input.ReadFloat(ref result.optionalFloat_); - break; - } - case 97: { - result.hasOptionalDouble = input.ReadDouble(ref result.optionalDouble_); - break; - } - case 104: { - result.hasOptionalBool = input.ReadBool(ref result.optionalBool_); - break; - } - case 114: { - result.hasOptionalString = input.ReadString(ref result.optionalString_); - break; - } - case 122: { - result.hasOptionalBytes = input.ReadBytes(ref result.optionalBytes_); - break; - } - case 131: { - global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.OptionalGroup.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.OptionalGroup.CreateBuilder(); - if (result.hasOptionalGroup) { - subBuilder.MergeFrom(OptionalGroup); - } - input.ReadGroup(16, subBuilder, extensionRegistry); - OptionalGroup = subBuilder.BuildPartial(); - break; - } - case 146: { - global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage.CreateBuilder(); - if (result.hasOptionalNestedMessage) { - subBuilder.MergeFrom(OptionalNestedMessage); - } - input.ReadMessage(subBuilder, extensionRegistry); - OptionalNestedMessage = subBuilder.BuildPartial(); - break; - } - case 154: { - global::Google.ProtocolBuffers.TestProtos.ForeignMessageLite.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.ForeignMessageLite.CreateBuilder(); - if (result.hasOptionalForeignMessage) { - subBuilder.MergeFrom(OptionalForeignMessage); - } - input.ReadMessage(subBuilder, extensionRegistry); - OptionalForeignMessage = subBuilder.BuildPartial(); - break; - } - case 162: { - global::Google.ProtocolBuffers.TestProtos.ImportMessageLite.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.ImportMessageLite.CreateBuilder(); - if (result.hasOptionalImportMessage) { - subBuilder.MergeFrom(OptionalImportMessage); - } - input.ReadMessage(subBuilder, extensionRegistry); - OptionalImportMessage = subBuilder.BuildPartial(); - break; - } - case 168: { - object unknown; - if(input.ReadEnum(ref result.optionalNestedEnum_, out unknown)) { - result.hasOptionalNestedEnum = true; - } else if(unknown is int) { - } - break; - } - case 176: { - object unknown; - if(input.ReadEnum(ref result.optionalForeignEnum_, out unknown)) { - result.hasOptionalForeignEnum = true; - } else if(unknown is int) { - } - break; - } - case 184: { - object unknown; - if(input.ReadEnum(ref result.optionalImportEnum_, out unknown)) { - result.hasOptionalImportEnum = true; - } else if(unknown is int) { - } - break; - } - case 194: { - result.hasOptionalStringPiece = input.ReadString(ref result.optionalStringPiece_); - break; - } - case 202: { - result.hasOptionalCord = input.ReadString(ref result.optionalCord_); - break; - } - case 210: { - global::Google.ProtocolBuffers.TestProtos.PublicImportMessageLite.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.PublicImportMessageLite.CreateBuilder(); - if (result.hasOptionalPublicImportMessage) { - subBuilder.MergeFrom(OptionalPublicImportMessage); - } - input.ReadMessage(subBuilder, extensionRegistry); - OptionalPublicImportMessage = subBuilder.BuildPartial(); - break; - } - case 218: { - global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage.CreateBuilder(); - if (result.hasOptionalLazyMessage) { - subBuilder.MergeFrom(OptionalLazyMessage); - } - input.ReadMessage(subBuilder, extensionRegistry); - OptionalLazyMessage = subBuilder.BuildPartial(); - break; - } - case 250: - case 248: { - input.ReadInt32Array(tag, field_name, result.repeatedInt32_); - break; - } - case 258: - case 256: { - input.ReadInt64Array(tag, field_name, result.repeatedInt64_); - break; - } - case 266: - case 264: { - input.ReadUInt32Array(tag, field_name, result.repeatedUint32_); - break; - } - case 274: - case 272: { - input.ReadUInt64Array(tag, field_name, result.repeatedUint64_); - break; - } - case 282: - case 280: { - input.ReadSInt32Array(tag, field_name, result.repeatedSint32_); - break; - } - case 290: - case 288: { - input.ReadSInt64Array(tag, field_name, result.repeatedSint64_); - break; - } - case 298: - case 301: { - input.ReadFixed32Array(tag, field_name, result.repeatedFixed32_); - break; - } - case 306: - case 305: { - input.ReadFixed64Array(tag, field_name, result.repeatedFixed64_); - break; - } - case 314: - case 317: { - input.ReadSFixed32Array(tag, field_name, result.repeatedSfixed32_); - break; - } - case 322: - case 321: { - input.ReadSFixed64Array(tag, field_name, result.repeatedSfixed64_); - break; - } - case 330: - case 333: { - input.ReadFloatArray(tag, field_name, result.repeatedFloat_); - break; - } - case 338: - case 337: { - input.ReadDoubleArray(tag, field_name, result.repeatedDouble_); - break; - } - case 346: - case 344: { - input.ReadBoolArray(tag, field_name, result.repeatedBool_); - break; - } - case 354: { - input.ReadStringArray(tag, field_name, result.repeatedString_); - break; - } - case 362: { - input.ReadBytesArray(tag, field_name, result.repeatedBytes_); - break; - } - case 371: { - input.ReadGroupArray(tag, field_name, result.repeatedGroup_, global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.RepeatedGroup.DefaultInstance, extensionRegistry); - break; - } - case 386: { - input.ReadMessageArray(tag, field_name, result.repeatedNestedMessage_, global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage.DefaultInstance, extensionRegistry); - break; - } - case 394: { - input.ReadMessageArray(tag, field_name, result.repeatedForeignMessage_, global::Google.ProtocolBuffers.TestProtos.ForeignMessageLite.DefaultInstance, extensionRegistry); - break; - } - case 402: { - input.ReadMessageArray(tag, field_name, result.repeatedImportMessage_, global::Google.ProtocolBuffers.TestProtos.ImportMessageLite.DefaultInstance, extensionRegistry); - break; - } - case 410: - case 408: { - scg::ICollection unknownItems; - input.ReadEnumArray(tag, field_name, result.repeatedNestedEnum_, out unknownItems); - break; - } - case 418: - case 416: { - scg::ICollection unknownItems; - input.ReadEnumArray(tag, field_name, result.repeatedForeignEnum_, out unknownItems); - break; - } - case 426: - case 424: { - scg::ICollection unknownItems; - input.ReadEnumArray(tag, field_name, result.repeatedImportEnum_, out unknownItems); - break; - } - case 434: { - input.ReadStringArray(tag, field_name, result.repeatedStringPiece_); - break; - } - case 442: { - input.ReadStringArray(tag, field_name, result.repeatedCord_); - break; - } - case 458: { - input.ReadMessageArray(tag, field_name, result.repeatedLazyMessage_, global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage.DefaultInstance, extensionRegistry); - break; - } - case 488: { - result.hasDefaultInt32 = input.ReadInt32(ref result.defaultInt32_); - break; - } - case 496: { - result.hasDefaultInt64 = input.ReadInt64(ref result.defaultInt64_); - break; - } - case 504: { - result.hasDefaultUint32 = input.ReadUInt32(ref result.defaultUint32_); - break; - } - case 512: { - result.hasDefaultUint64 = input.ReadUInt64(ref result.defaultUint64_); - break; - } - case 520: { - result.hasDefaultSint32 = input.ReadSInt32(ref result.defaultSint32_); - break; - } - case 528: { - result.hasDefaultSint64 = input.ReadSInt64(ref result.defaultSint64_); - break; - } - case 541: { - result.hasDefaultFixed32 = input.ReadFixed32(ref result.defaultFixed32_); - break; - } - case 545: { - result.hasDefaultFixed64 = input.ReadFixed64(ref result.defaultFixed64_); - break; - } - case 557: { - result.hasDefaultSfixed32 = input.ReadSFixed32(ref result.defaultSfixed32_); - break; - } - case 561: { - result.hasDefaultSfixed64 = input.ReadSFixed64(ref result.defaultSfixed64_); - break; - } - case 573: { - result.hasDefaultFloat = input.ReadFloat(ref result.defaultFloat_); - break; - } - case 577: { - result.hasDefaultDouble = input.ReadDouble(ref result.defaultDouble_); - break; - } - case 584: { - result.hasDefaultBool = input.ReadBool(ref result.defaultBool_); - break; - } - case 594: { - result.hasDefaultString = input.ReadString(ref result.defaultString_); - break; - } - case 602: { - result.hasDefaultBytes = input.ReadBytes(ref result.defaultBytes_); - break; - } - case 648: { - object unknown; - if(input.ReadEnum(ref result.defaultNestedEnum_, out unknown)) { - result.hasDefaultNestedEnum = true; - } else if(unknown is int) { - } - break; - } - case 656: { - object unknown; - if(input.ReadEnum(ref result.defaultForeignEnum_, out unknown)) { - result.hasDefaultForeignEnum = true; - } else if(unknown is int) { - } - break; - } - case 664: { - object unknown; - if(input.ReadEnum(ref result.defaultImportEnum_, out unknown)) { - result.hasDefaultImportEnum = true; - } else if(unknown is int) { - } - break; - } - case 674: { - result.hasDefaultStringPiece = input.ReadString(ref result.defaultStringPiece_); - break; - } - case 682: { - result.hasDefaultCord = input.ReadString(ref result.defaultCord_); - break; - } - case 888: { - uint value = 0; - if (input.ReadUInt32(ref value)) { - result.oneofField_ = value; - result.oneofFieldCase_ = OneofFieldOneofCase.OneofUint32; - } - break; - } - case 898: { - global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage.CreateBuilder(); - if (result.oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage) { - subBuilder.MergeFrom(OneofNestedMessage); - } - input.ReadMessage(subBuilder, extensionRegistry); - result.oneofField_ = subBuilder.BuildPartial(); - result.oneofFieldCase_ = OneofFieldOneofCase.OneofNestedMessage; - break; - } - case 906: { - string value = ""; - if (input.ReadString(ref value)) { - result.oneofField_ = value; - result.oneofFieldCase_ = OneofFieldOneofCase.OneofString; - } - break; - } - case 914: { - pb::ByteString value = pb::ByteString.Empty; - if (input.ReadBytes(ref value)) { - result.oneofField_ = value; - result.oneofFieldCase_ = OneofFieldOneofCase.OneofBytes; - } - break; - } - } - } - - return this; - } - - - public bool HasOptionalInt32 { - get { return result.hasOptionalInt32; } - } - public int OptionalInt32 { - get { return result.OptionalInt32; } - set { SetOptionalInt32(value); } - } - public Builder SetOptionalInt32(int value) { - PrepareBuilder(); - result.hasOptionalInt32 = true; - result.optionalInt32_ = value; - return this; - } - public Builder ClearOptionalInt32() { - PrepareBuilder(); - result.hasOptionalInt32 = false; - result.optionalInt32_ = 0; - return this; - } - - public bool HasOptionalInt64 { - get { return result.hasOptionalInt64; } - } - public long OptionalInt64 { - get { return result.OptionalInt64; } - set { SetOptionalInt64(value); } - } - public Builder SetOptionalInt64(long value) { - PrepareBuilder(); - result.hasOptionalInt64 = true; - result.optionalInt64_ = value; - return this; - } - public Builder ClearOptionalInt64() { - PrepareBuilder(); - result.hasOptionalInt64 = false; - result.optionalInt64_ = 0L; - return this; - } - - public bool HasOptionalUint32 { - get { return result.hasOptionalUint32; } - } - public uint OptionalUint32 { - get { return result.OptionalUint32; } - set { SetOptionalUint32(value); } - } - public Builder SetOptionalUint32(uint value) { - PrepareBuilder(); - result.hasOptionalUint32 = true; - result.optionalUint32_ = value; - return this; - } - public Builder ClearOptionalUint32() { - PrepareBuilder(); - result.hasOptionalUint32 = false; - result.optionalUint32_ = 0; - return this; - } - - public bool HasOptionalUint64 { - get { return result.hasOptionalUint64; } - } - public ulong OptionalUint64 { - get { return result.OptionalUint64; } - set { SetOptionalUint64(value); } - } - public Builder SetOptionalUint64(ulong value) { - PrepareBuilder(); - result.hasOptionalUint64 = true; - result.optionalUint64_ = value; - return this; - } - public Builder ClearOptionalUint64() { - PrepareBuilder(); - result.hasOptionalUint64 = false; - result.optionalUint64_ = 0UL; - return this; - } - - public bool HasOptionalSint32 { - get { return result.hasOptionalSint32; } - } - public int OptionalSint32 { - get { return result.OptionalSint32; } - set { SetOptionalSint32(value); } - } - public Builder SetOptionalSint32(int value) { - PrepareBuilder(); - result.hasOptionalSint32 = true; - result.optionalSint32_ = value; - return this; - } - public Builder ClearOptionalSint32() { - PrepareBuilder(); - result.hasOptionalSint32 = false; - result.optionalSint32_ = 0; - return this; - } - - public bool HasOptionalSint64 { - get { return result.hasOptionalSint64; } - } - public long OptionalSint64 { - get { return result.OptionalSint64; } - set { SetOptionalSint64(value); } - } - public Builder SetOptionalSint64(long value) { - PrepareBuilder(); - result.hasOptionalSint64 = true; - result.optionalSint64_ = value; - return this; - } - public Builder ClearOptionalSint64() { - PrepareBuilder(); - result.hasOptionalSint64 = false; - result.optionalSint64_ = 0L; - return this; - } - - public bool HasOptionalFixed32 { - get { return result.hasOptionalFixed32; } - } - public uint OptionalFixed32 { - get { return result.OptionalFixed32; } - set { SetOptionalFixed32(value); } - } - public Builder SetOptionalFixed32(uint value) { - PrepareBuilder(); - result.hasOptionalFixed32 = true; - result.optionalFixed32_ = value; - return this; - } - public Builder ClearOptionalFixed32() { - PrepareBuilder(); - result.hasOptionalFixed32 = false; - result.optionalFixed32_ = 0; - return this; - } - - public bool HasOptionalFixed64 { - get { return result.hasOptionalFixed64; } - } - public ulong OptionalFixed64 { - get { return result.OptionalFixed64; } - set { SetOptionalFixed64(value); } - } - public Builder SetOptionalFixed64(ulong value) { - PrepareBuilder(); - result.hasOptionalFixed64 = true; - result.optionalFixed64_ = value; - return this; - } - public Builder ClearOptionalFixed64() { - PrepareBuilder(); - result.hasOptionalFixed64 = false; - result.optionalFixed64_ = 0UL; - return this; - } - - public bool HasOptionalSfixed32 { - get { return result.hasOptionalSfixed32; } - } - public int OptionalSfixed32 { - get { return result.OptionalSfixed32; } - set { SetOptionalSfixed32(value); } - } - public Builder SetOptionalSfixed32(int value) { - PrepareBuilder(); - result.hasOptionalSfixed32 = true; - result.optionalSfixed32_ = value; - return this; - } - public Builder ClearOptionalSfixed32() { - PrepareBuilder(); - result.hasOptionalSfixed32 = false; - result.optionalSfixed32_ = 0; - return this; - } - - public bool HasOptionalSfixed64 { - get { return result.hasOptionalSfixed64; } - } - public long OptionalSfixed64 { - get { return result.OptionalSfixed64; } - set { SetOptionalSfixed64(value); } - } - public Builder SetOptionalSfixed64(long value) { - PrepareBuilder(); - result.hasOptionalSfixed64 = true; - result.optionalSfixed64_ = value; - return this; - } - public Builder ClearOptionalSfixed64() { - PrepareBuilder(); - result.hasOptionalSfixed64 = false; - result.optionalSfixed64_ = 0L; - return this; - } - - public bool HasOptionalFloat { - get { return result.hasOptionalFloat; } - } - public float OptionalFloat { - get { return result.OptionalFloat; } - set { SetOptionalFloat(value); } - } - public Builder SetOptionalFloat(float value) { - PrepareBuilder(); - result.hasOptionalFloat = true; - result.optionalFloat_ = value; - return this; - } - public Builder ClearOptionalFloat() { - PrepareBuilder(); - result.hasOptionalFloat = false; - result.optionalFloat_ = 0F; - return this; - } - - public bool HasOptionalDouble { - get { return result.hasOptionalDouble; } - } - public double OptionalDouble { - get { return result.OptionalDouble; } - set { SetOptionalDouble(value); } - } - public Builder SetOptionalDouble(double value) { - PrepareBuilder(); - result.hasOptionalDouble = true; - result.optionalDouble_ = value; - return this; - } - public Builder ClearOptionalDouble() { - PrepareBuilder(); - result.hasOptionalDouble = false; - result.optionalDouble_ = 0D; - return this; - } - - public bool HasOptionalBool { - get { return result.hasOptionalBool; } - } - public bool OptionalBool { - get { return result.OptionalBool; } - set { SetOptionalBool(value); } - } - public Builder SetOptionalBool(bool value) { - PrepareBuilder(); - result.hasOptionalBool = true; - result.optionalBool_ = value; - return this; - } - public Builder ClearOptionalBool() { - PrepareBuilder(); - result.hasOptionalBool = false; - result.optionalBool_ = false; - return this; - } - - public bool HasOptionalString { - get { return result.hasOptionalString; } - } - public string OptionalString { - get { return result.OptionalString; } - set { SetOptionalString(value); } - } - public Builder SetOptionalString(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOptionalString = true; - result.optionalString_ = value; - return this; - } - public Builder ClearOptionalString() { - PrepareBuilder(); - result.hasOptionalString = false; - result.optionalString_ = ""; - return this; - } - - public bool HasOptionalBytes { - get { return result.hasOptionalBytes; } - } - public pb::ByteString OptionalBytes { - get { return result.OptionalBytes; } - set { SetOptionalBytes(value); } - } - public Builder SetOptionalBytes(pb::ByteString value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOptionalBytes = true; - result.optionalBytes_ = value; - return this; - } - public Builder ClearOptionalBytes() { - PrepareBuilder(); - result.hasOptionalBytes = false; - result.optionalBytes_ = pb::ByteString.Empty; - return this; - } - - public bool HasOptionalGroup { - get { return result.hasOptionalGroup; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.OptionalGroup OptionalGroup { - get { return result.OptionalGroup; } - set { SetOptionalGroup(value); } - } - public Builder SetOptionalGroup(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.OptionalGroup value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOptionalGroup = true; - result.optionalGroup_ = value; - return this; - } - public Builder SetOptionalGroup(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.OptionalGroup.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasOptionalGroup = true; - result.optionalGroup_ = builderForValue.Build(); - return this; - } - public Builder MergeOptionalGroup(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.OptionalGroup value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasOptionalGroup && - result.optionalGroup_ != global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.OptionalGroup.DefaultInstance) { - result.optionalGroup_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.OptionalGroup.CreateBuilder(result.optionalGroup_).MergeFrom(value).BuildPartial(); - } else { - result.optionalGroup_ = value; - } - result.hasOptionalGroup = true; - return this; - } - public Builder ClearOptionalGroup() { - PrepareBuilder(); - result.hasOptionalGroup = false; - result.optionalGroup_ = null; - return this; - } - - public bool HasOptionalNestedMessage { - get { return result.hasOptionalNestedMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage OptionalNestedMessage { - get { return result.OptionalNestedMessage; } - set { SetOptionalNestedMessage(value); } - } - public Builder SetOptionalNestedMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOptionalNestedMessage = true; - result.optionalNestedMessage_ = value; - return this; - } - public Builder SetOptionalNestedMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasOptionalNestedMessage = true; - result.optionalNestedMessage_ = builderForValue.Build(); - return this; - } - public Builder MergeOptionalNestedMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasOptionalNestedMessage && - result.optionalNestedMessage_ != global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage.DefaultInstance) { - result.optionalNestedMessage_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage.CreateBuilder(result.optionalNestedMessage_).MergeFrom(value).BuildPartial(); - } else { - result.optionalNestedMessage_ = value; - } - result.hasOptionalNestedMessage = true; - return this; - } - public Builder ClearOptionalNestedMessage() { - PrepareBuilder(); - result.hasOptionalNestedMessage = false; - result.optionalNestedMessage_ = null; - return this; - } - - public bool HasOptionalForeignMessage { - get { return result.hasOptionalForeignMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignMessageLite OptionalForeignMessage { - get { return result.OptionalForeignMessage; } - set { SetOptionalForeignMessage(value); } - } - public Builder SetOptionalForeignMessage(global::Google.ProtocolBuffers.TestProtos.ForeignMessageLite value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOptionalForeignMessage = true; - result.optionalForeignMessage_ = value; - return this; - } - public Builder SetOptionalForeignMessage(global::Google.ProtocolBuffers.TestProtos.ForeignMessageLite.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasOptionalForeignMessage = true; - result.optionalForeignMessage_ = builderForValue.Build(); - return this; - } - public Builder MergeOptionalForeignMessage(global::Google.ProtocolBuffers.TestProtos.ForeignMessageLite value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasOptionalForeignMessage && - result.optionalForeignMessage_ != global::Google.ProtocolBuffers.TestProtos.ForeignMessageLite.DefaultInstance) { - result.optionalForeignMessage_ = global::Google.ProtocolBuffers.TestProtos.ForeignMessageLite.CreateBuilder(result.optionalForeignMessage_).MergeFrom(value).BuildPartial(); - } else { - result.optionalForeignMessage_ = value; - } - result.hasOptionalForeignMessage = true; - return this; - } - public Builder ClearOptionalForeignMessage() { - PrepareBuilder(); - result.hasOptionalForeignMessage = false; - result.optionalForeignMessage_ = null; - return this; - } - - public bool HasOptionalImportMessage { - get { return result.hasOptionalImportMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.ImportMessageLite OptionalImportMessage { - get { return result.OptionalImportMessage; } - set { SetOptionalImportMessage(value); } - } - public Builder SetOptionalImportMessage(global::Google.ProtocolBuffers.TestProtos.ImportMessageLite value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOptionalImportMessage = true; - result.optionalImportMessage_ = value; - return this; - } - public Builder SetOptionalImportMessage(global::Google.ProtocolBuffers.TestProtos.ImportMessageLite.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasOptionalImportMessage = true; - result.optionalImportMessage_ = builderForValue.Build(); - return this; - } - public Builder MergeOptionalImportMessage(global::Google.ProtocolBuffers.TestProtos.ImportMessageLite value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasOptionalImportMessage && - result.optionalImportMessage_ != global::Google.ProtocolBuffers.TestProtos.ImportMessageLite.DefaultInstance) { - result.optionalImportMessage_ = global::Google.ProtocolBuffers.TestProtos.ImportMessageLite.CreateBuilder(result.optionalImportMessage_).MergeFrom(value).BuildPartial(); - } else { - result.optionalImportMessage_ = value; - } - result.hasOptionalImportMessage = true; - return this; - } - public Builder ClearOptionalImportMessage() { - PrepareBuilder(); - result.hasOptionalImportMessage = false; - result.optionalImportMessage_ = null; - return this; - } - - public bool HasOptionalNestedEnum { - get { return result.hasOptionalNestedEnum; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedEnum OptionalNestedEnum { - get { return result.OptionalNestedEnum; } - set { SetOptionalNestedEnum(value); } - } - public Builder SetOptionalNestedEnum(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedEnum value) { - PrepareBuilder(); - result.hasOptionalNestedEnum = true; - result.optionalNestedEnum_ = value; - return this; - } - public Builder ClearOptionalNestedEnum() { - PrepareBuilder(); - result.hasOptionalNestedEnum = false; - result.optionalNestedEnum_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedEnum.FOO; - return this; - } - - public bool HasOptionalForeignEnum { - get { return result.hasOptionalForeignEnum; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignEnumLite OptionalForeignEnum { - get { return result.OptionalForeignEnum; } - set { SetOptionalForeignEnum(value); } - } - public Builder SetOptionalForeignEnum(global::Google.ProtocolBuffers.TestProtos.ForeignEnumLite value) { - PrepareBuilder(); - result.hasOptionalForeignEnum = true; - result.optionalForeignEnum_ = value; - return this; - } - public Builder ClearOptionalForeignEnum() { - PrepareBuilder(); - result.hasOptionalForeignEnum = false; - result.optionalForeignEnum_ = global::Google.ProtocolBuffers.TestProtos.ForeignEnumLite.FOREIGN_LITE_FOO; - return this; - } - - public bool HasOptionalImportEnum { - get { return result.hasOptionalImportEnum; } - } - public global::Google.ProtocolBuffers.TestProtos.ImportEnumLite OptionalImportEnum { - get { return result.OptionalImportEnum; } - set { SetOptionalImportEnum(value); } - } - public Builder SetOptionalImportEnum(global::Google.ProtocolBuffers.TestProtos.ImportEnumLite value) { - PrepareBuilder(); - result.hasOptionalImportEnum = true; - result.optionalImportEnum_ = value; - return this; - } - public Builder ClearOptionalImportEnum() { - PrepareBuilder(); - result.hasOptionalImportEnum = false; - result.optionalImportEnum_ = global::Google.ProtocolBuffers.TestProtos.ImportEnumLite.IMPORT_LITE_FOO; - return this; - } - - public bool HasOptionalStringPiece { - get { return result.hasOptionalStringPiece; } - } - public string OptionalStringPiece { - get { return result.OptionalStringPiece; } - set { SetOptionalStringPiece(value); } - } - public Builder SetOptionalStringPiece(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOptionalStringPiece = true; - result.optionalStringPiece_ = value; - return this; - } - public Builder ClearOptionalStringPiece() { - PrepareBuilder(); - result.hasOptionalStringPiece = false; - result.optionalStringPiece_ = ""; - return this; - } - - public bool HasOptionalCord { - get { return result.hasOptionalCord; } - } - public string OptionalCord { - get { return result.OptionalCord; } - set { SetOptionalCord(value); } - } - public Builder SetOptionalCord(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOptionalCord = true; - result.optionalCord_ = value; - return this; - } - public Builder ClearOptionalCord() { - PrepareBuilder(); - result.hasOptionalCord = false; - result.optionalCord_ = ""; - return this; - } - - public bool HasOptionalPublicImportMessage { - get { return result.hasOptionalPublicImportMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.PublicImportMessageLite OptionalPublicImportMessage { - get { return result.OptionalPublicImportMessage; } - set { SetOptionalPublicImportMessage(value); } - } - public Builder SetOptionalPublicImportMessage(global::Google.ProtocolBuffers.TestProtos.PublicImportMessageLite value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOptionalPublicImportMessage = true; - result.optionalPublicImportMessage_ = value; - return this; - } - public Builder SetOptionalPublicImportMessage(global::Google.ProtocolBuffers.TestProtos.PublicImportMessageLite.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasOptionalPublicImportMessage = true; - result.optionalPublicImportMessage_ = builderForValue.Build(); - return this; - } - public Builder MergeOptionalPublicImportMessage(global::Google.ProtocolBuffers.TestProtos.PublicImportMessageLite value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasOptionalPublicImportMessage && - result.optionalPublicImportMessage_ != global::Google.ProtocolBuffers.TestProtos.PublicImportMessageLite.DefaultInstance) { - result.optionalPublicImportMessage_ = global::Google.ProtocolBuffers.TestProtos.PublicImportMessageLite.CreateBuilder(result.optionalPublicImportMessage_).MergeFrom(value).BuildPartial(); - } else { - result.optionalPublicImportMessage_ = value; - } - result.hasOptionalPublicImportMessage = true; - return this; - } - public Builder ClearOptionalPublicImportMessage() { - PrepareBuilder(); - result.hasOptionalPublicImportMessage = false; - result.optionalPublicImportMessage_ = null; - return this; - } - - public bool HasOptionalLazyMessage { - get { return result.hasOptionalLazyMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage OptionalLazyMessage { - get { return result.OptionalLazyMessage; } - set { SetOptionalLazyMessage(value); } - } - public Builder SetOptionalLazyMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOptionalLazyMessage = true; - result.optionalLazyMessage_ = value; - return this; - } - public Builder SetOptionalLazyMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasOptionalLazyMessage = true; - result.optionalLazyMessage_ = builderForValue.Build(); - return this; - } - public Builder MergeOptionalLazyMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasOptionalLazyMessage && - result.optionalLazyMessage_ != global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage.DefaultInstance) { - result.optionalLazyMessage_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage.CreateBuilder(result.optionalLazyMessage_).MergeFrom(value).BuildPartial(); - } else { - result.optionalLazyMessage_ = value; - } - result.hasOptionalLazyMessage = true; - return this; - } - public Builder ClearOptionalLazyMessage() { - PrepareBuilder(); - result.hasOptionalLazyMessage = false; - result.optionalLazyMessage_ = null; - return this; - } - - public pbc::IPopsicleList RepeatedInt32List { - get { return PrepareBuilder().repeatedInt32_; } - } - public int RepeatedInt32Count { - get { return result.RepeatedInt32Count; } - } - public int GetRepeatedInt32(int index) { - return result.GetRepeatedInt32(index); - } - public Builder SetRepeatedInt32(int index, int value) { - PrepareBuilder(); - result.repeatedInt32_[index] = value; - return this; - } - public Builder AddRepeatedInt32(int value) { - PrepareBuilder(); - result.repeatedInt32_.Add(value); - return this; - } - public Builder AddRangeRepeatedInt32(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedInt32_.Add(values); - return this; - } - public Builder ClearRepeatedInt32() { - PrepareBuilder(); - result.repeatedInt32_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedInt64List { - get { return PrepareBuilder().repeatedInt64_; } - } - public int RepeatedInt64Count { - get { return result.RepeatedInt64Count; } - } - public long GetRepeatedInt64(int index) { - return result.GetRepeatedInt64(index); - } - public Builder SetRepeatedInt64(int index, long value) { - PrepareBuilder(); - result.repeatedInt64_[index] = value; - return this; - } - public Builder AddRepeatedInt64(long value) { - PrepareBuilder(); - result.repeatedInt64_.Add(value); - return this; - } - public Builder AddRangeRepeatedInt64(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedInt64_.Add(values); - return this; - } - public Builder ClearRepeatedInt64() { - PrepareBuilder(); - result.repeatedInt64_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedUint32List { - get { return PrepareBuilder().repeatedUint32_; } - } - public int RepeatedUint32Count { - get { return result.RepeatedUint32Count; } - } - public uint GetRepeatedUint32(int index) { - return result.GetRepeatedUint32(index); - } - public Builder SetRepeatedUint32(int index, uint value) { - PrepareBuilder(); - result.repeatedUint32_[index] = value; - return this; - } - public Builder AddRepeatedUint32(uint value) { - PrepareBuilder(); - result.repeatedUint32_.Add(value); - return this; - } - public Builder AddRangeRepeatedUint32(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedUint32_.Add(values); - return this; - } - public Builder ClearRepeatedUint32() { - PrepareBuilder(); - result.repeatedUint32_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedUint64List { - get { return PrepareBuilder().repeatedUint64_; } - } - public int RepeatedUint64Count { - get { return result.RepeatedUint64Count; } - } - public ulong GetRepeatedUint64(int index) { - return result.GetRepeatedUint64(index); - } - public Builder SetRepeatedUint64(int index, ulong value) { - PrepareBuilder(); - result.repeatedUint64_[index] = value; - return this; - } - public Builder AddRepeatedUint64(ulong value) { - PrepareBuilder(); - result.repeatedUint64_.Add(value); - return this; - } - public Builder AddRangeRepeatedUint64(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedUint64_.Add(values); - return this; - } - public Builder ClearRepeatedUint64() { - PrepareBuilder(); - result.repeatedUint64_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedSint32List { - get { return PrepareBuilder().repeatedSint32_; } - } - public int RepeatedSint32Count { - get { return result.RepeatedSint32Count; } - } - public int GetRepeatedSint32(int index) { - return result.GetRepeatedSint32(index); - } - public Builder SetRepeatedSint32(int index, int value) { - PrepareBuilder(); - result.repeatedSint32_[index] = value; - return this; - } - public Builder AddRepeatedSint32(int value) { - PrepareBuilder(); - result.repeatedSint32_.Add(value); - return this; - } - public Builder AddRangeRepeatedSint32(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedSint32_.Add(values); - return this; - } - public Builder ClearRepeatedSint32() { - PrepareBuilder(); - result.repeatedSint32_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedSint64List { - get { return PrepareBuilder().repeatedSint64_; } - } - public int RepeatedSint64Count { - get { return result.RepeatedSint64Count; } - } - public long GetRepeatedSint64(int index) { - return result.GetRepeatedSint64(index); - } - public Builder SetRepeatedSint64(int index, long value) { - PrepareBuilder(); - result.repeatedSint64_[index] = value; - return this; - } - public Builder AddRepeatedSint64(long value) { - PrepareBuilder(); - result.repeatedSint64_.Add(value); - return this; - } - public Builder AddRangeRepeatedSint64(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedSint64_.Add(values); - return this; - } - public Builder ClearRepeatedSint64() { - PrepareBuilder(); - result.repeatedSint64_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedFixed32List { - get { return PrepareBuilder().repeatedFixed32_; } - } - public int RepeatedFixed32Count { - get { return result.RepeatedFixed32Count; } - } - public uint GetRepeatedFixed32(int index) { - return result.GetRepeatedFixed32(index); - } - public Builder SetRepeatedFixed32(int index, uint value) { - PrepareBuilder(); - result.repeatedFixed32_[index] = value; - return this; - } - public Builder AddRepeatedFixed32(uint value) { - PrepareBuilder(); - result.repeatedFixed32_.Add(value); - return this; - } - public Builder AddRangeRepeatedFixed32(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedFixed32_.Add(values); - return this; - } - public Builder ClearRepeatedFixed32() { - PrepareBuilder(); - result.repeatedFixed32_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedFixed64List { - get { return PrepareBuilder().repeatedFixed64_; } - } - public int RepeatedFixed64Count { - get { return result.RepeatedFixed64Count; } - } - public ulong GetRepeatedFixed64(int index) { - return result.GetRepeatedFixed64(index); - } - public Builder SetRepeatedFixed64(int index, ulong value) { - PrepareBuilder(); - result.repeatedFixed64_[index] = value; - return this; - } - public Builder AddRepeatedFixed64(ulong value) { - PrepareBuilder(); - result.repeatedFixed64_.Add(value); - return this; - } - public Builder AddRangeRepeatedFixed64(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedFixed64_.Add(values); - return this; - } - public Builder ClearRepeatedFixed64() { - PrepareBuilder(); - result.repeatedFixed64_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedSfixed32List { - get { return PrepareBuilder().repeatedSfixed32_; } - } - public int RepeatedSfixed32Count { - get { return result.RepeatedSfixed32Count; } - } - public int GetRepeatedSfixed32(int index) { - return result.GetRepeatedSfixed32(index); - } - public Builder SetRepeatedSfixed32(int index, int value) { - PrepareBuilder(); - result.repeatedSfixed32_[index] = value; - return this; - } - public Builder AddRepeatedSfixed32(int value) { - PrepareBuilder(); - result.repeatedSfixed32_.Add(value); - return this; - } - public Builder AddRangeRepeatedSfixed32(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedSfixed32_.Add(values); - return this; - } - public Builder ClearRepeatedSfixed32() { - PrepareBuilder(); - result.repeatedSfixed32_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedSfixed64List { - get { return PrepareBuilder().repeatedSfixed64_; } - } - public int RepeatedSfixed64Count { - get { return result.RepeatedSfixed64Count; } - } - public long GetRepeatedSfixed64(int index) { - return result.GetRepeatedSfixed64(index); - } - public Builder SetRepeatedSfixed64(int index, long value) { - PrepareBuilder(); - result.repeatedSfixed64_[index] = value; - return this; - } - public Builder AddRepeatedSfixed64(long value) { - PrepareBuilder(); - result.repeatedSfixed64_.Add(value); - return this; - } - public Builder AddRangeRepeatedSfixed64(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedSfixed64_.Add(values); - return this; - } - public Builder ClearRepeatedSfixed64() { - PrepareBuilder(); - result.repeatedSfixed64_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedFloatList { - get { return PrepareBuilder().repeatedFloat_; } - } - public int RepeatedFloatCount { - get { return result.RepeatedFloatCount; } - } - public float GetRepeatedFloat(int index) { - return result.GetRepeatedFloat(index); - } - public Builder SetRepeatedFloat(int index, float value) { - PrepareBuilder(); - result.repeatedFloat_[index] = value; - return this; - } - public Builder AddRepeatedFloat(float value) { - PrepareBuilder(); - result.repeatedFloat_.Add(value); - return this; - } - public Builder AddRangeRepeatedFloat(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedFloat_.Add(values); - return this; - } - public Builder ClearRepeatedFloat() { - PrepareBuilder(); - result.repeatedFloat_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedDoubleList { - get { return PrepareBuilder().repeatedDouble_; } - } - public int RepeatedDoubleCount { - get { return result.RepeatedDoubleCount; } - } - public double GetRepeatedDouble(int index) { - return result.GetRepeatedDouble(index); - } - public Builder SetRepeatedDouble(int index, double value) { - PrepareBuilder(); - result.repeatedDouble_[index] = value; - return this; - } - public Builder AddRepeatedDouble(double value) { - PrepareBuilder(); - result.repeatedDouble_.Add(value); - return this; - } - public Builder AddRangeRepeatedDouble(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedDouble_.Add(values); - return this; - } - public Builder ClearRepeatedDouble() { - PrepareBuilder(); - result.repeatedDouble_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedBoolList { - get { return PrepareBuilder().repeatedBool_; } - } - public int RepeatedBoolCount { - get { return result.RepeatedBoolCount; } - } - public bool GetRepeatedBool(int index) { - return result.GetRepeatedBool(index); - } - public Builder SetRepeatedBool(int index, bool value) { - PrepareBuilder(); - result.repeatedBool_[index] = value; - return this; - } - public Builder AddRepeatedBool(bool value) { - PrepareBuilder(); - result.repeatedBool_.Add(value); - return this; - } - public Builder AddRangeRepeatedBool(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedBool_.Add(values); - return this; - } - public Builder ClearRepeatedBool() { - PrepareBuilder(); - result.repeatedBool_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedStringList { - get { return PrepareBuilder().repeatedString_; } - } - public int RepeatedStringCount { - get { return result.RepeatedStringCount; } - } - public string GetRepeatedString(int index) { - return result.GetRepeatedString(index); - } - public Builder SetRepeatedString(int index, string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedString_[index] = value; - return this; - } - public Builder AddRepeatedString(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedString_.Add(value); - return this; - } - public Builder AddRangeRepeatedString(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedString_.Add(values); - return this; - } - public Builder ClearRepeatedString() { - PrepareBuilder(); - result.repeatedString_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedBytesList { - get { return PrepareBuilder().repeatedBytes_; } - } - public int RepeatedBytesCount { - get { return result.RepeatedBytesCount; } - } - public pb::ByteString GetRepeatedBytes(int index) { - return result.GetRepeatedBytes(index); - } - public Builder SetRepeatedBytes(int index, pb::ByteString value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedBytes_[index] = value; - return this; - } - public Builder AddRepeatedBytes(pb::ByteString value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedBytes_.Add(value); - return this; - } - public Builder AddRangeRepeatedBytes(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedBytes_.Add(values); - return this; - } - public Builder ClearRepeatedBytes() { - PrepareBuilder(); - result.repeatedBytes_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedGroupList { - get { return PrepareBuilder().repeatedGroup_; } - } - public int RepeatedGroupCount { - get { return result.RepeatedGroupCount; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.RepeatedGroup GetRepeatedGroup(int index) { - return result.GetRepeatedGroup(index); - } - public Builder SetRepeatedGroup(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.RepeatedGroup value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedGroup_[index] = value; - return this; - } - public Builder SetRepeatedGroup(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.RepeatedGroup.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.repeatedGroup_[index] = builderForValue.Build(); - return this; - } - public Builder AddRepeatedGroup(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.RepeatedGroup value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedGroup_.Add(value); - return this; - } - public Builder AddRepeatedGroup(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.RepeatedGroup.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.repeatedGroup_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeRepeatedGroup(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedGroup_.Add(values); - return this; - } - public Builder ClearRepeatedGroup() { - PrepareBuilder(); - result.repeatedGroup_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedNestedMessageList { - get { return PrepareBuilder().repeatedNestedMessage_; } - } - public int RepeatedNestedMessageCount { - get { return result.RepeatedNestedMessageCount; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage GetRepeatedNestedMessage(int index) { - return result.GetRepeatedNestedMessage(index); - } - public Builder SetRepeatedNestedMessage(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedNestedMessage_[index] = value; - return this; - } - public Builder SetRepeatedNestedMessage(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.repeatedNestedMessage_[index] = builderForValue.Build(); - return this; - } - public Builder AddRepeatedNestedMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedNestedMessage_.Add(value); - return this; - } - public Builder AddRepeatedNestedMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.repeatedNestedMessage_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeRepeatedNestedMessage(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedNestedMessage_.Add(values); - return this; - } - public Builder ClearRepeatedNestedMessage() { - PrepareBuilder(); - result.repeatedNestedMessage_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedForeignMessageList { - get { return PrepareBuilder().repeatedForeignMessage_; } - } - public int RepeatedForeignMessageCount { - get { return result.RepeatedForeignMessageCount; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignMessageLite GetRepeatedForeignMessage(int index) { - return result.GetRepeatedForeignMessage(index); - } - public Builder SetRepeatedForeignMessage(int index, global::Google.ProtocolBuffers.TestProtos.ForeignMessageLite value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedForeignMessage_[index] = value; - return this; - } - public Builder SetRepeatedForeignMessage(int index, global::Google.ProtocolBuffers.TestProtos.ForeignMessageLite.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.repeatedForeignMessage_[index] = builderForValue.Build(); - return this; - } - public Builder AddRepeatedForeignMessage(global::Google.ProtocolBuffers.TestProtos.ForeignMessageLite value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedForeignMessage_.Add(value); - return this; - } - public Builder AddRepeatedForeignMessage(global::Google.ProtocolBuffers.TestProtos.ForeignMessageLite.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.repeatedForeignMessage_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeRepeatedForeignMessage(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedForeignMessage_.Add(values); - return this; - } - public Builder ClearRepeatedForeignMessage() { - PrepareBuilder(); - result.repeatedForeignMessage_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedImportMessageList { - get { return PrepareBuilder().repeatedImportMessage_; } - } - public int RepeatedImportMessageCount { - get { return result.RepeatedImportMessageCount; } - } - public global::Google.ProtocolBuffers.TestProtos.ImportMessageLite GetRepeatedImportMessage(int index) { - return result.GetRepeatedImportMessage(index); - } - public Builder SetRepeatedImportMessage(int index, global::Google.ProtocolBuffers.TestProtos.ImportMessageLite value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedImportMessage_[index] = value; - return this; - } - public Builder SetRepeatedImportMessage(int index, global::Google.ProtocolBuffers.TestProtos.ImportMessageLite.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.repeatedImportMessage_[index] = builderForValue.Build(); - return this; - } - public Builder AddRepeatedImportMessage(global::Google.ProtocolBuffers.TestProtos.ImportMessageLite value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedImportMessage_.Add(value); - return this; - } - public Builder AddRepeatedImportMessage(global::Google.ProtocolBuffers.TestProtos.ImportMessageLite.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.repeatedImportMessage_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeRepeatedImportMessage(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedImportMessage_.Add(values); - return this; - } - public Builder ClearRepeatedImportMessage() { - PrepareBuilder(); - result.repeatedImportMessage_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedNestedEnumList { - get { return PrepareBuilder().repeatedNestedEnum_; } - } - public int RepeatedNestedEnumCount { - get { return result.RepeatedNestedEnumCount; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedEnum GetRepeatedNestedEnum(int index) { - return result.GetRepeatedNestedEnum(index); - } - public Builder SetRepeatedNestedEnum(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedEnum value) { - PrepareBuilder(); - result.repeatedNestedEnum_[index] = value; - return this; - } - public Builder AddRepeatedNestedEnum(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedEnum value) { - PrepareBuilder(); - result.repeatedNestedEnum_.Add(value); - return this; - } - public Builder AddRangeRepeatedNestedEnum(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedNestedEnum_.Add(values); - return this; - } - public Builder ClearRepeatedNestedEnum() { - PrepareBuilder(); - result.repeatedNestedEnum_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedForeignEnumList { - get { return PrepareBuilder().repeatedForeignEnum_; } - } - public int RepeatedForeignEnumCount { - get { return result.RepeatedForeignEnumCount; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignEnumLite GetRepeatedForeignEnum(int index) { - return result.GetRepeatedForeignEnum(index); - } - public Builder SetRepeatedForeignEnum(int index, global::Google.ProtocolBuffers.TestProtos.ForeignEnumLite value) { - PrepareBuilder(); - result.repeatedForeignEnum_[index] = value; - return this; - } - public Builder AddRepeatedForeignEnum(global::Google.ProtocolBuffers.TestProtos.ForeignEnumLite value) { - PrepareBuilder(); - result.repeatedForeignEnum_.Add(value); - return this; - } - public Builder AddRangeRepeatedForeignEnum(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedForeignEnum_.Add(values); - return this; - } - public Builder ClearRepeatedForeignEnum() { - PrepareBuilder(); - result.repeatedForeignEnum_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedImportEnumList { - get { return PrepareBuilder().repeatedImportEnum_; } - } - public int RepeatedImportEnumCount { - get { return result.RepeatedImportEnumCount; } - } - public global::Google.ProtocolBuffers.TestProtos.ImportEnumLite GetRepeatedImportEnum(int index) { - return result.GetRepeatedImportEnum(index); - } - public Builder SetRepeatedImportEnum(int index, global::Google.ProtocolBuffers.TestProtos.ImportEnumLite value) { - PrepareBuilder(); - result.repeatedImportEnum_[index] = value; - return this; - } - public Builder AddRepeatedImportEnum(global::Google.ProtocolBuffers.TestProtos.ImportEnumLite value) { - PrepareBuilder(); - result.repeatedImportEnum_.Add(value); - return this; - } - public Builder AddRangeRepeatedImportEnum(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedImportEnum_.Add(values); - return this; - } - public Builder ClearRepeatedImportEnum() { - PrepareBuilder(); - result.repeatedImportEnum_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedStringPieceList { - get { return PrepareBuilder().repeatedStringPiece_; } - } - public int RepeatedStringPieceCount { - get { return result.RepeatedStringPieceCount; } - } - public string GetRepeatedStringPiece(int index) { - return result.GetRepeatedStringPiece(index); - } - public Builder SetRepeatedStringPiece(int index, string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedStringPiece_[index] = value; - return this; - } - public Builder AddRepeatedStringPiece(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedStringPiece_.Add(value); - return this; - } - public Builder AddRangeRepeatedStringPiece(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedStringPiece_.Add(values); - return this; - } - public Builder ClearRepeatedStringPiece() { - PrepareBuilder(); - result.repeatedStringPiece_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedCordList { - get { return PrepareBuilder().repeatedCord_; } - } - public int RepeatedCordCount { - get { return result.RepeatedCordCount; } - } - public string GetRepeatedCord(int index) { - return result.GetRepeatedCord(index); - } - public Builder SetRepeatedCord(int index, string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedCord_[index] = value; - return this; - } - public Builder AddRepeatedCord(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedCord_.Add(value); - return this; - } - public Builder AddRangeRepeatedCord(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedCord_.Add(values); - return this; - } - public Builder ClearRepeatedCord() { - PrepareBuilder(); - result.repeatedCord_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedLazyMessageList { - get { return PrepareBuilder().repeatedLazyMessage_; } - } - public int RepeatedLazyMessageCount { - get { return result.RepeatedLazyMessageCount; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage GetRepeatedLazyMessage(int index) { - return result.GetRepeatedLazyMessage(index); - } - public Builder SetRepeatedLazyMessage(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedLazyMessage_[index] = value; - return this; - } - public Builder SetRepeatedLazyMessage(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.repeatedLazyMessage_[index] = builderForValue.Build(); - return this; - } - public Builder AddRepeatedLazyMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedLazyMessage_.Add(value); - return this; - } - public Builder AddRepeatedLazyMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.repeatedLazyMessage_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeRepeatedLazyMessage(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedLazyMessage_.Add(values); - return this; - } - public Builder ClearRepeatedLazyMessage() { - PrepareBuilder(); - result.repeatedLazyMessage_.Clear(); - return this; - } - - public bool HasDefaultInt32 { - get { return result.hasDefaultInt32; } - } - public int DefaultInt32 { - get { return result.DefaultInt32; } - set { SetDefaultInt32(value); } - } - public Builder SetDefaultInt32(int value) { - PrepareBuilder(); - result.hasDefaultInt32 = true; - result.defaultInt32_ = value; - return this; - } - public Builder ClearDefaultInt32() { - PrepareBuilder(); - result.hasDefaultInt32 = false; - result.defaultInt32_ = 41; - return this; - } - - public bool HasDefaultInt64 { - get { return result.hasDefaultInt64; } - } - public long DefaultInt64 { - get { return result.DefaultInt64; } - set { SetDefaultInt64(value); } - } - public Builder SetDefaultInt64(long value) { - PrepareBuilder(); - result.hasDefaultInt64 = true; - result.defaultInt64_ = value; - return this; - } - public Builder ClearDefaultInt64() { - PrepareBuilder(); - result.hasDefaultInt64 = false; - result.defaultInt64_ = 42L; - return this; - } - - public bool HasDefaultUint32 { - get { return result.hasDefaultUint32; } - } - public uint DefaultUint32 { - get { return result.DefaultUint32; } - set { SetDefaultUint32(value); } - } - public Builder SetDefaultUint32(uint value) { - PrepareBuilder(); - result.hasDefaultUint32 = true; - result.defaultUint32_ = value; - return this; - } - public Builder ClearDefaultUint32() { - PrepareBuilder(); - result.hasDefaultUint32 = false; - result.defaultUint32_ = 43; - return this; - } - - public bool HasDefaultUint64 { - get { return result.hasDefaultUint64; } - } - public ulong DefaultUint64 { - get { return result.DefaultUint64; } - set { SetDefaultUint64(value); } - } - public Builder SetDefaultUint64(ulong value) { - PrepareBuilder(); - result.hasDefaultUint64 = true; - result.defaultUint64_ = value; - return this; - } - public Builder ClearDefaultUint64() { - PrepareBuilder(); - result.hasDefaultUint64 = false; - result.defaultUint64_ = 44UL; - return this; - } - - public bool HasDefaultSint32 { - get { return result.hasDefaultSint32; } - } - public int DefaultSint32 { - get { return result.DefaultSint32; } - set { SetDefaultSint32(value); } - } - public Builder SetDefaultSint32(int value) { - PrepareBuilder(); - result.hasDefaultSint32 = true; - result.defaultSint32_ = value; - return this; - } - public Builder ClearDefaultSint32() { - PrepareBuilder(); - result.hasDefaultSint32 = false; - result.defaultSint32_ = -45; - return this; - } - - public bool HasDefaultSint64 { - get { return result.hasDefaultSint64; } - } - public long DefaultSint64 { - get { return result.DefaultSint64; } - set { SetDefaultSint64(value); } - } - public Builder SetDefaultSint64(long value) { - PrepareBuilder(); - result.hasDefaultSint64 = true; - result.defaultSint64_ = value; - return this; - } - public Builder ClearDefaultSint64() { - PrepareBuilder(); - result.hasDefaultSint64 = false; - result.defaultSint64_ = 46L; - return this; - } - - public bool HasDefaultFixed32 { - get { return result.hasDefaultFixed32; } - } - public uint DefaultFixed32 { - get { return result.DefaultFixed32; } - set { SetDefaultFixed32(value); } - } - public Builder SetDefaultFixed32(uint value) { - PrepareBuilder(); - result.hasDefaultFixed32 = true; - result.defaultFixed32_ = value; - return this; - } - public Builder ClearDefaultFixed32() { - PrepareBuilder(); - result.hasDefaultFixed32 = false; - result.defaultFixed32_ = 47; - return this; - } - - public bool HasDefaultFixed64 { - get { return result.hasDefaultFixed64; } - } - public ulong DefaultFixed64 { - get { return result.DefaultFixed64; } - set { SetDefaultFixed64(value); } - } - public Builder SetDefaultFixed64(ulong value) { - PrepareBuilder(); - result.hasDefaultFixed64 = true; - result.defaultFixed64_ = value; - return this; - } - public Builder ClearDefaultFixed64() { - PrepareBuilder(); - result.hasDefaultFixed64 = false; - result.defaultFixed64_ = 48UL; - return this; - } - - public bool HasDefaultSfixed32 { - get { return result.hasDefaultSfixed32; } - } - public int DefaultSfixed32 { - get { return result.DefaultSfixed32; } - set { SetDefaultSfixed32(value); } - } - public Builder SetDefaultSfixed32(int value) { - PrepareBuilder(); - result.hasDefaultSfixed32 = true; - result.defaultSfixed32_ = value; - return this; - } - public Builder ClearDefaultSfixed32() { - PrepareBuilder(); - result.hasDefaultSfixed32 = false; - result.defaultSfixed32_ = 49; - return this; - } - - public bool HasDefaultSfixed64 { - get { return result.hasDefaultSfixed64; } - } - public long DefaultSfixed64 { - get { return result.DefaultSfixed64; } - set { SetDefaultSfixed64(value); } - } - public Builder SetDefaultSfixed64(long value) { - PrepareBuilder(); - result.hasDefaultSfixed64 = true; - result.defaultSfixed64_ = value; - return this; - } - public Builder ClearDefaultSfixed64() { - PrepareBuilder(); - result.hasDefaultSfixed64 = false; - result.defaultSfixed64_ = -50L; - return this; - } - - public bool HasDefaultFloat { - get { return result.hasDefaultFloat; } - } - public float DefaultFloat { - get { return result.DefaultFloat; } - set { SetDefaultFloat(value); } - } - public Builder SetDefaultFloat(float value) { - PrepareBuilder(); - result.hasDefaultFloat = true; - result.defaultFloat_ = value; - return this; - } - public Builder ClearDefaultFloat() { - PrepareBuilder(); - result.hasDefaultFloat = false; - result.defaultFloat_ = 51.5F; - return this; - } - - public bool HasDefaultDouble { - get { return result.hasDefaultDouble; } - } - public double DefaultDouble { - get { return result.DefaultDouble; } - set { SetDefaultDouble(value); } - } - public Builder SetDefaultDouble(double value) { - PrepareBuilder(); - result.hasDefaultDouble = true; - result.defaultDouble_ = value; - return this; - } - public Builder ClearDefaultDouble() { - PrepareBuilder(); - result.hasDefaultDouble = false; - result.defaultDouble_ = 52000D; - return this; - } - - public bool HasDefaultBool { - get { return result.hasDefaultBool; } - } - public bool DefaultBool { - get { return result.DefaultBool; } - set { SetDefaultBool(value); } - } - public Builder SetDefaultBool(bool value) { - PrepareBuilder(); - result.hasDefaultBool = true; - result.defaultBool_ = value; - return this; - } - public Builder ClearDefaultBool() { - PrepareBuilder(); - result.hasDefaultBool = false; - result.defaultBool_ = true; - return this; - } - - public bool HasDefaultString { - get { return result.hasDefaultString; } - } - public string DefaultString { - get { return result.DefaultString; } - set { SetDefaultString(value); } - } - public Builder SetDefaultString(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasDefaultString = true; - result.defaultString_ = value; - return this; - } - public Builder ClearDefaultString() { - PrepareBuilder(); - result.hasDefaultString = false; - result.defaultString_ = "hello"; - return this; - } - - public bool HasDefaultBytes { - get { return result.hasDefaultBytes; } - } - public pb::ByteString DefaultBytes { - get { return result.DefaultBytes; } - set { SetDefaultBytes(value); } - } - public Builder SetDefaultBytes(pb::ByteString value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasDefaultBytes = true; - result.defaultBytes_ = value; - return this; - } - public Builder ClearDefaultBytes() { - PrepareBuilder(); - result.hasDefaultBytes = false; - result.defaultBytes_ = pb::ByteString.FromBase64("d29ybGQ="); - return this; - } - - public bool HasDefaultNestedEnum { - get { return result.hasDefaultNestedEnum; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedEnum DefaultNestedEnum { - get { return result.DefaultNestedEnum; } - set { SetDefaultNestedEnum(value); } - } - public Builder SetDefaultNestedEnum(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedEnum value) { - PrepareBuilder(); - result.hasDefaultNestedEnum = true; - result.defaultNestedEnum_ = value; - return this; - } - public Builder ClearDefaultNestedEnum() { - PrepareBuilder(); - result.hasDefaultNestedEnum = false; - result.defaultNestedEnum_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedEnum.BAR; - return this; - } - - public bool HasDefaultForeignEnum { - get { return result.hasDefaultForeignEnum; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignEnumLite DefaultForeignEnum { - get { return result.DefaultForeignEnum; } - set { SetDefaultForeignEnum(value); } - } - public Builder SetDefaultForeignEnum(global::Google.ProtocolBuffers.TestProtos.ForeignEnumLite value) { - PrepareBuilder(); - result.hasDefaultForeignEnum = true; - result.defaultForeignEnum_ = value; - return this; - } - public Builder ClearDefaultForeignEnum() { - PrepareBuilder(); - result.hasDefaultForeignEnum = false; - result.defaultForeignEnum_ = global::Google.ProtocolBuffers.TestProtos.ForeignEnumLite.FOREIGN_LITE_BAR; - return this; - } - - public bool HasDefaultImportEnum { - get { return result.hasDefaultImportEnum; } - } - public global::Google.ProtocolBuffers.TestProtos.ImportEnumLite DefaultImportEnum { - get { return result.DefaultImportEnum; } - set { SetDefaultImportEnum(value); } - } - public Builder SetDefaultImportEnum(global::Google.ProtocolBuffers.TestProtos.ImportEnumLite value) { - PrepareBuilder(); - result.hasDefaultImportEnum = true; - result.defaultImportEnum_ = value; - return this; - } - public Builder ClearDefaultImportEnum() { - PrepareBuilder(); - result.hasDefaultImportEnum = false; - result.defaultImportEnum_ = global::Google.ProtocolBuffers.TestProtos.ImportEnumLite.IMPORT_LITE_BAR; - return this; - } - - public bool HasDefaultStringPiece { - get { return result.hasDefaultStringPiece; } - } - public string DefaultStringPiece { - get { return result.DefaultStringPiece; } - set { SetDefaultStringPiece(value); } - } - public Builder SetDefaultStringPiece(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasDefaultStringPiece = true; - result.defaultStringPiece_ = value; - return this; - } - public Builder ClearDefaultStringPiece() { - PrepareBuilder(); - result.hasDefaultStringPiece = false; - result.defaultStringPiece_ = "abc"; - return this; - } - - public bool HasDefaultCord { - get { return result.hasDefaultCord; } - } - public string DefaultCord { - get { return result.DefaultCord; } - set { SetDefaultCord(value); } - } - public Builder SetDefaultCord(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasDefaultCord = true; - result.defaultCord_ = value; - return this; - } - public Builder ClearDefaultCord() { - PrepareBuilder(); - result.hasDefaultCord = false; - result.defaultCord_ = "123"; - return this; - } - - public bool HasOneofUint32 { - get { return result.oneofFieldCase_ == OneofFieldOneofCase.OneofUint32; } - } - public uint OneofUint32 { - get { return result.oneofFieldCase_ == OneofFieldOneofCase.OneofUint32 ? (uint) result.oneofField_ : 0; } - set { SetOneofUint32(value); } - } - public Builder SetOneofUint32(uint value) { - PrepareBuilder(); - result.oneofField_ = value; - result.oneofFieldCase_ = OneofFieldOneofCase.OneofUint32; - return this; - } - public Builder ClearOneofUint32() { - PrepareBuilder(); - if (result.oneofFieldCase_ == OneofFieldOneofCase.OneofUint32) { - result.oneofFieldCase_ = OneofFieldOneofCase.None; - } - return this; - } - - public bool HasOneofNestedMessage { - get { return result.oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage OneofNestedMessage { - get { return result.oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage ? (global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage) result.oneofField_ : global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage.DefaultInstance; } - set { SetOneofNestedMessage(value); } - } - public Builder SetOneofNestedMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.oneofFieldCase_ = OneofFieldOneofCase.OneofNestedMessage; - result.oneofField_ = value; - return this; - } - public Builder SetOneofNestedMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.oneofFieldCase_ = OneofFieldOneofCase.OneofNestedMessage; - result.oneofField_ = builderForValue.Build(); - return this; - } - public Builder MergeOneofNestedMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage && - result.OneofNestedMessage != global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage.DefaultInstance) { - result.oneofField_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Types.NestedMessage.CreateBuilder(result.OneofNestedMessage).MergeFrom(value).BuildPartial(); - } else { - result.oneofField_ = value; - } - result.oneofFieldCase_ = OneofFieldOneofCase.OneofNestedMessage; - return this; - } - public Builder ClearOneofNestedMessage() { - if (result.oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage) { - PrepareBuilder(); - result.oneofFieldCase_ = OneofFieldOneofCase.None; - result.oneofField_ = null; - } - return this; - } - - public bool HasOneofString { - get { return result.oneofFieldCase_ == OneofFieldOneofCase.OneofString; } - } - public string OneofString { - get { return result.oneofFieldCase_ == OneofFieldOneofCase.OneofString ? (string) result.oneofField_ : ""; } - set { SetOneofString(value); } - } - public Builder SetOneofString(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.oneofField_ = value; - result.oneofFieldCase_ = OneofFieldOneofCase.OneofString; - return this; - } - public Builder ClearOneofString() { - PrepareBuilder(); - if (result.oneofFieldCase_ == OneofFieldOneofCase.OneofString) { - result.oneofFieldCase_ = OneofFieldOneofCase.None; - } - return this; - } - - public bool HasOneofBytes { - get { return result.oneofFieldCase_ == OneofFieldOneofCase.OneofBytes; } - } - public pb::ByteString OneofBytes { - get { return result.oneofFieldCase_ == OneofFieldOneofCase.OneofBytes ? (pb::ByteString) result.oneofField_ : pb::ByteString.Empty; } - set { SetOneofBytes(value); } - } - public Builder SetOneofBytes(pb::ByteString value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.oneofField_ = value; - result.oneofFieldCase_ = OneofFieldOneofCase.OneofBytes; - return this; - } - public Builder ClearOneofBytes() { - PrepareBuilder(); - if (result.oneofFieldCase_ == OneofFieldOneofCase.OneofBytes) { - result.oneofFieldCase_ = OneofFieldOneofCase.None; - } - return this; - } - - public OneofFieldOneofCase OneofFieldCase { - get { return result.oneofFieldCase_; } - } - public Builder ClearOneofField() { - PrepareBuilder(); - result.oneofField_ = null; - result.oneofFieldCase_ = OneofFieldOneofCase.None; - return this; - } - } - static TestAllTypesLite() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.UnittestLite.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class ForeignMessageLite : pb::GeneratedMessageLite { - private ForeignMessageLite() { } - private static readonly ForeignMessageLite defaultInstance = new ForeignMessageLite().MakeReadOnly(); - private static readonly string[] _foreignMessageLiteFieldNames = new string[] { "c" }; - private static readonly uint[] _foreignMessageLiteFieldTags = new uint[] { 8 }; - public static ForeignMessageLite DefaultInstance { - get { return defaultInstance; } - } - - public override ForeignMessageLite DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override ForeignMessageLite ThisMessage { - get { return this; } - } - - public const int CFieldNumber = 1; - private bool hasC; - private int c_; - public bool HasC { - get { return hasC; } - } - public int C { - get { return c_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _foreignMessageLiteFieldNames; - if (hasC) { - output.WriteInt32(1, field_names[0], C); - } - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasC) { - size += pb::CodedOutputStream.ComputeInt32Size(1, C); - } - memoizedSerializedSize = size; - return size; - } - #region Lite runtime methods - public override int GetHashCode() { - int hash = GetType().GetHashCode(); - if (hasC) { - hash ^= c_.GetHashCode(); - } - return hash; - } - - public override bool Equals(object obj) { - ForeignMessageLite other = obj as ForeignMessageLite; - if (other == null) return false; - if (hasC != other.hasC || (hasC && !c_.Equals(other.c_))) return false; - return true; - } - - public override void PrintTo(global::System.IO.TextWriter writer) { - PrintField("c", hasC, c_, writer); - } - #endregion - - public static ForeignMessageLite ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static ForeignMessageLite ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static ForeignMessageLite ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static ForeignMessageLite ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static ForeignMessageLite ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static ForeignMessageLite ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static ForeignMessageLite ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static ForeignMessageLite ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static ForeignMessageLite ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static ForeignMessageLite ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private ForeignMessageLite MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(ForeignMessageLite prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilderLite { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(ForeignMessageLite cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private ForeignMessageLite result; - - private ForeignMessageLite PrepareBuilder() { - if (resultIsReadOnly) { - ForeignMessageLite original = result; - result = new ForeignMessageLite(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override ForeignMessageLite MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override ForeignMessageLite DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.ForeignMessageLite.DefaultInstance; } - } - - public override ForeignMessageLite BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessageLite other) { - if (other is ForeignMessageLite) { - return MergeFrom((ForeignMessageLite) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(ForeignMessageLite other) { - if (other == global::Google.ProtocolBuffers.TestProtos.ForeignMessageLite.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasC) { - C = other.C; - } - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_foreignMessageLiteFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _foreignMessageLiteFieldTags[field_ordinal]; - else { - ParseUnknownField(input, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - return this; - } - ParseUnknownField(input, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasC = input.ReadInt32(ref result.c_); - break; - } - } - } - - return this; - } - - - public bool HasC { - get { return result.hasC; } - } - public int C { - get { return result.C; } - set { SetC(value); } - } - public Builder SetC(int value) { - PrepareBuilder(); - result.hasC = true; - result.c_ = value; - return this; - } - public Builder ClearC() { - PrepareBuilder(); - result.hasC = false; - result.c_ = 0; - return this; - } - } - static ForeignMessageLite() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.UnittestLite.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestPackedTypesLite : pb::GeneratedMessageLite { - private TestPackedTypesLite() { } - private static readonly TestPackedTypesLite defaultInstance = new TestPackedTypesLite().MakeReadOnly(); - private static readonly string[] _testPackedTypesLiteFieldNames = new string[] { "packed_bool", "packed_double", "packed_enum", "packed_fixed32", "packed_fixed64", "packed_float", "packed_int32", "packed_int64", "packed_sfixed32", "packed_sfixed64", "packed_sint32", "packed_sint64", "packed_uint32", "packed_uint64" }; - private static readonly uint[] _testPackedTypesLiteFieldTags = new uint[] { 818, 810, 826, 770, 778, 802, 722, 730, 786, 794, 754, 762, 738, 746 }; - public static TestPackedTypesLite DefaultInstance { - get { return defaultInstance; } - } - - public override TestPackedTypesLite DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestPackedTypesLite ThisMessage { - get { return this; } - } - - public const int PackedInt32FieldNumber = 90; - private int packedInt32MemoizedSerializedSize; - private pbc::PopsicleList packedInt32_ = new pbc::PopsicleList(); - public scg::IList PackedInt32List { - get { return pbc::Lists.AsReadOnly(packedInt32_); } - } - public int PackedInt32Count { - get { return packedInt32_.Count; } - } - public int GetPackedInt32(int index) { - return packedInt32_[index]; - } - - public const int PackedInt64FieldNumber = 91; - private int packedInt64MemoizedSerializedSize; - private pbc::PopsicleList packedInt64_ = new pbc::PopsicleList(); - public scg::IList PackedInt64List { - get { return pbc::Lists.AsReadOnly(packedInt64_); } - } - public int PackedInt64Count { - get { return packedInt64_.Count; } - } - public long GetPackedInt64(int index) { - return packedInt64_[index]; - } - - public const int PackedUint32FieldNumber = 92; - private int packedUint32MemoizedSerializedSize; - private pbc::PopsicleList packedUint32_ = new pbc::PopsicleList(); - public scg::IList PackedUint32List { - get { return pbc::Lists.AsReadOnly(packedUint32_); } - } - public int PackedUint32Count { - get { return packedUint32_.Count; } - } - public uint GetPackedUint32(int index) { - return packedUint32_[index]; - } - - public const int PackedUint64FieldNumber = 93; - private int packedUint64MemoizedSerializedSize; - private pbc::PopsicleList packedUint64_ = new pbc::PopsicleList(); - public scg::IList PackedUint64List { - get { return pbc::Lists.AsReadOnly(packedUint64_); } - } - public int PackedUint64Count { - get { return packedUint64_.Count; } - } - public ulong GetPackedUint64(int index) { - return packedUint64_[index]; - } - - public const int PackedSint32FieldNumber = 94; - private int packedSint32MemoizedSerializedSize; - private pbc::PopsicleList packedSint32_ = new pbc::PopsicleList(); - public scg::IList PackedSint32List { - get { return pbc::Lists.AsReadOnly(packedSint32_); } - } - public int PackedSint32Count { - get { return packedSint32_.Count; } - } - public int GetPackedSint32(int index) { - return packedSint32_[index]; - } - - public const int PackedSint64FieldNumber = 95; - private int packedSint64MemoizedSerializedSize; - private pbc::PopsicleList packedSint64_ = new pbc::PopsicleList(); - public scg::IList PackedSint64List { - get { return pbc::Lists.AsReadOnly(packedSint64_); } - } - public int PackedSint64Count { - get { return packedSint64_.Count; } - } - public long GetPackedSint64(int index) { - return packedSint64_[index]; - } - - public const int PackedFixed32FieldNumber = 96; - private int packedFixed32MemoizedSerializedSize; - private pbc::PopsicleList packedFixed32_ = new pbc::PopsicleList(); - public scg::IList PackedFixed32List { - get { return pbc::Lists.AsReadOnly(packedFixed32_); } - } - public int PackedFixed32Count { - get { return packedFixed32_.Count; } - } - public uint GetPackedFixed32(int index) { - return packedFixed32_[index]; - } - - public const int PackedFixed64FieldNumber = 97; - private int packedFixed64MemoizedSerializedSize; - private pbc::PopsicleList packedFixed64_ = new pbc::PopsicleList(); - public scg::IList PackedFixed64List { - get { return pbc::Lists.AsReadOnly(packedFixed64_); } - } - public int PackedFixed64Count { - get { return packedFixed64_.Count; } - } - public ulong GetPackedFixed64(int index) { - return packedFixed64_[index]; - } - - public const int PackedSfixed32FieldNumber = 98; - private int packedSfixed32MemoizedSerializedSize; - private pbc::PopsicleList packedSfixed32_ = new pbc::PopsicleList(); - public scg::IList PackedSfixed32List { - get { return pbc::Lists.AsReadOnly(packedSfixed32_); } - } - public int PackedSfixed32Count { - get { return packedSfixed32_.Count; } - } - public int GetPackedSfixed32(int index) { - return packedSfixed32_[index]; - } - - public const int PackedSfixed64FieldNumber = 99; - private int packedSfixed64MemoizedSerializedSize; - private pbc::PopsicleList packedSfixed64_ = new pbc::PopsicleList(); - public scg::IList PackedSfixed64List { - get { return pbc::Lists.AsReadOnly(packedSfixed64_); } - } - public int PackedSfixed64Count { - get { return packedSfixed64_.Count; } - } - public long GetPackedSfixed64(int index) { - return packedSfixed64_[index]; - } - - public const int PackedFloatFieldNumber = 100; - private int packedFloatMemoizedSerializedSize; - private pbc::PopsicleList packedFloat_ = new pbc::PopsicleList(); - public scg::IList PackedFloatList { - get { return pbc::Lists.AsReadOnly(packedFloat_); } - } - public int PackedFloatCount { - get { return packedFloat_.Count; } - } - public float GetPackedFloat(int index) { - return packedFloat_[index]; - } - - public const int PackedDoubleFieldNumber = 101; - private int packedDoubleMemoizedSerializedSize; - private pbc::PopsicleList packedDouble_ = new pbc::PopsicleList(); - public scg::IList PackedDoubleList { - get { return pbc::Lists.AsReadOnly(packedDouble_); } - } - public int PackedDoubleCount { - get { return packedDouble_.Count; } - } - public double GetPackedDouble(int index) { - return packedDouble_[index]; - } - - public const int PackedBoolFieldNumber = 102; - private int packedBoolMemoizedSerializedSize; - private pbc::PopsicleList packedBool_ = new pbc::PopsicleList(); - public scg::IList PackedBoolList { - get { return pbc::Lists.AsReadOnly(packedBool_); } - } - public int PackedBoolCount { - get { return packedBool_.Count; } - } - public bool GetPackedBool(int index) { - return packedBool_[index]; - } - - public const int PackedEnumFieldNumber = 103; - private int packedEnumMemoizedSerializedSize; - private pbc::PopsicleList packedEnum_ = new pbc::PopsicleList(); - public scg::IList PackedEnumList { - get { return pbc::Lists.AsReadOnly(packedEnum_); } - } - public int PackedEnumCount { - get { return packedEnum_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignEnumLite GetPackedEnum(int index) { - return packedEnum_[index]; - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testPackedTypesLiteFieldNames; - if (packedInt32_.Count > 0) { - output.WritePackedInt32Array(90, field_names[6], packedInt32MemoizedSerializedSize, packedInt32_); - } - if (packedInt64_.Count > 0) { - output.WritePackedInt64Array(91, field_names[7], packedInt64MemoizedSerializedSize, packedInt64_); - } - if (packedUint32_.Count > 0) { - output.WritePackedUInt32Array(92, field_names[12], packedUint32MemoizedSerializedSize, packedUint32_); - } - if (packedUint64_.Count > 0) { - output.WritePackedUInt64Array(93, field_names[13], packedUint64MemoizedSerializedSize, packedUint64_); - } - if (packedSint32_.Count > 0) { - output.WritePackedSInt32Array(94, field_names[10], packedSint32MemoizedSerializedSize, packedSint32_); - } - if (packedSint64_.Count > 0) { - output.WritePackedSInt64Array(95, field_names[11], packedSint64MemoizedSerializedSize, packedSint64_); - } - if (packedFixed32_.Count > 0) { - output.WritePackedFixed32Array(96, field_names[3], packedFixed32MemoizedSerializedSize, packedFixed32_); - } - if (packedFixed64_.Count > 0) { - output.WritePackedFixed64Array(97, field_names[4], packedFixed64MemoizedSerializedSize, packedFixed64_); - } - if (packedSfixed32_.Count > 0) { - output.WritePackedSFixed32Array(98, field_names[8], packedSfixed32MemoizedSerializedSize, packedSfixed32_); - } - if (packedSfixed64_.Count > 0) { - output.WritePackedSFixed64Array(99, field_names[9], packedSfixed64MemoizedSerializedSize, packedSfixed64_); - } - if (packedFloat_.Count > 0) { - output.WritePackedFloatArray(100, field_names[5], packedFloatMemoizedSerializedSize, packedFloat_); - } - if (packedDouble_.Count > 0) { - output.WritePackedDoubleArray(101, field_names[1], packedDoubleMemoizedSerializedSize, packedDouble_); - } - if (packedBool_.Count > 0) { - output.WritePackedBoolArray(102, field_names[0], packedBoolMemoizedSerializedSize, packedBool_); - } - if (packedEnum_.Count > 0) { - output.WritePackedEnumArray(103, field_names[2], packedEnumMemoizedSerializedSize, packedEnum_); - } - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - { - int dataSize = 0; - foreach (int element in PackedInt32List) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); - } - size += dataSize; - if (packedInt32_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedInt32MemoizedSerializedSize = dataSize; - } - { - int dataSize = 0; - foreach (long element in PackedInt64List) { - dataSize += pb::CodedOutputStream.ComputeInt64SizeNoTag(element); - } - size += dataSize; - if (packedInt64_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedInt64MemoizedSerializedSize = dataSize; - } - { - int dataSize = 0; - foreach (uint element in PackedUint32List) { - dataSize += pb::CodedOutputStream.ComputeUInt32SizeNoTag(element); - } - size += dataSize; - if (packedUint32_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedUint32MemoizedSerializedSize = dataSize; - } - { - int dataSize = 0; - foreach (ulong element in PackedUint64List) { - dataSize += pb::CodedOutputStream.ComputeUInt64SizeNoTag(element); - } - size += dataSize; - if (packedUint64_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedUint64MemoizedSerializedSize = dataSize; - } - { - int dataSize = 0; - foreach (int element in PackedSint32List) { - dataSize += pb::CodedOutputStream.ComputeSInt32SizeNoTag(element); - } - size += dataSize; - if (packedSint32_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedSint32MemoizedSerializedSize = dataSize; - } - { - int dataSize = 0; - foreach (long element in PackedSint64List) { - dataSize += pb::CodedOutputStream.ComputeSInt64SizeNoTag(element); - } - size += dataSize; - if (packedSint64_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedSint64MemoizedSerializedSize = dataSize; - } - { - int dataSize = 0; - dataSize = 4 * packedFixed32_.Count; - size += dataSize; - if (packedFixed32_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedFixed32MemoizedSerializedSize = dataSize; - } - { - int dataSize = 0; - dataSize = 8 * packedFixed64_.Count; - size += dataSize; - if (packedFixed64_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedFixed64MemoizedSerializedSize = dataSize; - } - { - int dataSize = 0; - dataSize = 4 * packedSfixed32_.Count; - size += dataSize; - if (packedSfixed32_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedSfixed32MemoizedSerializedSize = dataSize; - } - { - int dataSize = 0; - dataSize = 8 * packedSfixed64_.Count; - size += dataSize; - if (packedSfixed64_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedSfixed64MemoizedSerializedSize = dataSize; - } - { - int dataSize = 0; - dataSize = 4 * packedFloat_.Count; - size += dataSize; - if (packedFloat_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedFloatMemoizedSerializedSize = dataSize; - } - { - int dataSize = 0; - dataSize = 8 * packedDouble_.Count; - size += dataSize; - if (packedDouble_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedDoubleMemoizedSerializedSize = dataSize; - } - { - int dataSize = 0; - dataSize = 1 * packedBool_.Count; - size += dataSize; - if (packedBool_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedBoolMemoizedSerializedSize = dataSize; - } - { - int dataSize = 0; - if (packedEnum_.Count > 0) { - foreach (global::Google.ProtocolBuffers.TestProtos.ForeignEnumLite element in packedEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 2; - size += pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize); - } - packedEnumMemoizedSerializedSize = dataSize; - } - memoizedSerializedSize = size; - return size; - } - #region Lite runtime methods - public override int GetHashCode() { - int hash = GetType().GetHashCode(); - foreach(int i in packedInt32_) - hash ^= i.GetHashCode(); - foreach(long i in packedInt64_) - hash ^= i.GetHashCode(); - foreach(uint i in packedUint32_) - hash ^= i.GetHashCode(); - foreach(ulong i in packedUint64_) - hash ^= i.GetHashCode(); - foreach(int i in packedSint32_) - hash ^= i.GetHashCode(); - foreach(long i in packedSint64_) - hash ^= i.GetHashCode(); - foreach(uint i in packedFixed32_) - hash ^= i.GetHashCode(); - foreach(ulong i in packedFixed64_) - hash ^= i.GetHashCode(); - foreach(int i in packedSfixed32_) - hash ^= i.GetHashCode(); - foreach(long i in packedSfixed64_) - hash ^= i.GetHashCode(); - foreach(float i in packedFloat_) - hash ^= i.GetHashCode(); - foreach(double i in packedDouble_) - hash ^= i.GetHashCode(); - foreach(bool i in packedBool_) - hash ^= i.GetHashCode(); - foreach(global::Google.ProtocolBuffers.TestProtos.ForeignEnumLite i in packedEnum_) - hash ^= i.GetHashCode(); - return hash; - } - - public override bool Equals(object obj) { - TestPackedTypesLite other = obj as TestPackedTypesLite; - if (other == null) return false; - if(packedInt32_.Count != other.packedInt32_.Count) return false; - for(int ix=0; ix < packedInt32_.Count; ix++) - if(!packedInt32_[ix].Equals(other.packedInt32_[ix])) return false; - if(packedInt64_.Count != other.packedInt64_.Count) return false; - for(int ix=0; ix < packedInt64_.Count; ix++) - if(!packedInt64_[ix].Equals(other.packedInt64_[ix])) return false; - if(packedUint32_.Count != other.packedUint32_.Count) return false; - for(int ix=0; ix < packedUint32_.Count; ix++) - if(!packedUint32_[ix].Equals(other.packedUint32_[ix])) return false; - if(packedUint64_.Count != other.packedUint64_.Count) return false; - for(int ix=0; ix < packedUint64_.Count; ix++) - if(!packedUint64_[ix].Equals(other.packedUint64_[ix])) return false; - if(packedSint32_.Count != other.packedSint32_.Count) return false; - for(int ix=0; ix < packedSint32_.Count; ix++) - if(!packedSint32_[ix].Equals(other.packedSint32_[ix])) return false; - if(packedSint64_.Count != other.packedSint64_.Count) return false; - for(int ix=0; ix < packedSint64_.Count; ix++) - if(!packedSint64_[ix].Equals(other.packedSint64_[ix])) return false; - if(packedFixed32_.Count != other.packedFixed32_.Count) return false; - for(int ix=0; ix < packedFixed32_.Count; ix++) - if(!packedFixed32_[ix].Equals(other.packedFixed32_[ix])) return false; - if(packedFixed64_.Count != other.packedFixed64_.Count) return false; - for(int ix=0; ix < packedFixed64_.Count; ix++) - if(!packedFixed64_[ix].Equals(other.packedFixed64_[ix])) return false; - if(packedSfixed32_.Count != other.packedSfixed32_.Count) return false; - for(int ix=0; ix < packedSfixed32_.Count; ix++) - if(!packedSfixed32_[ix].Equals(other.packedSfixed32_[ix])) return false; - if(packedSfixed64_.Count != other.packedSfixed64_.Count) return false; - for(int ix=0; ix < packedSfixed64_.Count; ix++) - if(!packedSfixed64_[ix].Equals(other.packedSfixed64_[ix])) return false; - if(packedFloat_.Count != other.packedFloat_.Count) return false; - for(int ix=0; ix < packedFloat_.Count; ix++) - if(!packedFloat_[ix].Equals(other.packedFloat_[ix])) return false; - if(packedDouble_.Count != other.packedDouble_.Count) return false; - for(int ix=0; ix < packedDouble_.Count; ix++) - if(!packedDouble_[ix].Equals(other.packedDouble_[ix])) return false; - if(packedBool_.Count != other.packedBool_.Count) return false; - for(int ix=0; ix < packedBool_.Count; ix++) - if(!packedBool_[ix].Equals(other.packedBool_[ix])) return false; - if(packedEnum_.Count != other.packedEnum_.Count) return false; - for(int ix=0; ix < packedEnum_.Count; ix++) - if(!packedEnum_[ix].Equals(other.packedEnum_[ix])) return false; - return true; - } - - public override void PrintTo(global::System.IO.TextWriter writer) { - PrintField("packed_int32", packedInt32_, writer); - PrintField("packed_int64", packedInt64_, writer); - PrintField("packed_uint32", packedUint32_, writer); - PrintField("packed_uint64", packedUint64_, writer); - PrintField("packed_sint32", packedSint32_, writer); - PrintField("packed_sint64", packedSint64_, writer); - PrintField("packed_fixed32", packedFixed32_, writer); - PrintField("packed_fixed64", packedFixed64_, writer); - PrintField("packed_sfixed32", packedSfixed32_, writer); - PrintField("packed_sfixed64", packedSfixed64_, writer); - PrintField("packed_float", packedFloat_, writer); - PrintField("packed_double", packedDouble_, writer); - PrintField("packed_bool", packedBool_, writer); - PrintField("packed_enum", packedEnum_, writer); - } - #endregion - - public static TestPackedTypesLite ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestPackedTypesLite ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestPackedTypesLite ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestPackedTypesLite ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestPackedTypesLite ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestPackedTypesLite ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestPackedTypesLite ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestPackedTypesLite ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestPackedTypesLite ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestPackedTypesLite ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestPackedTypesLite MakeReadOnly() { - packedInt32_.MakeReadOnly(); - packedInt64_.MakeReadOnly(); - packedUint32_.MakeReadOnly(); - packedUint64_.MakeReadOnly(); - packedSint32_.MakeReadOnly(); - packedSint64_.MakeReadOnly(); - packedFixed32_.MakeReadOnly(); - packedFixed64_.MakeReadOnly(); - packedSfixed32_.MakeReadOnly(); - packedSfixed64_.MakeReadOnly(); - packedFloat_.MakeReadOnly(); - packedDouble_.MakeReadOnly(); - packedBool_.MakeReadOnly(); - packedEnum_.MakeReadOnly(); - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestPackedTypesLite prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilderLite { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestPackedTypesLite cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestPackedTypesLite result; - - private TestPackedTypesLite PrepareBuilder() { - if (resultIsReadOnly) { - TestPackedTypesLite original = result; - result = new TestPackedTypesLite(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestPackedTypesLite MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override TestPackedTypesLite DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestPackedTypesLite.DefaultInstance; } - } - - public override TestPackedTypesLite BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessageLite other) { - if (other is TestPackedTypesLite) { - return MergeFrom((TestPackedTypesLite) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestPackedTypesLite other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestPackedTypesLite.DefaultInstance) return this; - PrepareBuilder(); - if (other.packedInt32_.Count != 0) { - result.packedInt32_.Add(other.packedInt32_); - } - if (other.packedInt64_.Count != 0) { - result.packedInt64_.Add(other.packedInt64_); - } - if (other.packedUint32_.Count != 0) { - result.packedUint32_.Add(other.packedUint32_); - } - if (other.packedUint64_.Count != 0) { - result.packedUint64_.Add(other.packedUint64_); - } - if (other.packedSint32_.Count != 0) { - result.packedSint32_.Add(other.packedSint32_); - } - if (other.packedSint64_.Count != 0) { - result.packedSint64_.Add(other.packedSint64_); - } - if (other.packedFixed32_.Count != 0) { - result.packedFixed32_.Add(other.packedFixed32_); - } - if (other.packedFixed64_.Count != 0) { - result.packedFixed64_.Add(other.packedFixed64_); - } - if (other.packedSfixed32_.Count != 0) { - result.packedSfixed32_.Add(other.packedSfixed32_); - } - if (other.packedSfixed64_.Count != 0) { - result.packedSfixed64_.Add(other.packedSfixed64_); - } - if (other.packedFloat_.Count != 0) { - result.packedFloat_.Add(other.packedFloat_); - } - if (other.packedDouble_.Count != 0) { - result.packedDouble_.Add(other.packedDouble_); - } - if (other.packedBool_.Count != 0) { - result.packedBool_.Add(other.packedBool_); - } - if (other.packedEnum_.Count != 0) { - result.packedEnum_.Add(other.packedEnum_); - } - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testPackedTypesLiteFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testPackedTypesLiteFieldTags[field_ordinal]; - else { - ParseUnknownField(input, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - return this; - } - ParseUnknownField(input, extensionRegistry, tag, field_name); - break; - } - case 722: - case 720: { - input.ReadInt32Array(tag, field_name, result.packedInt32_); - break; - } - case 730: - case 728: { - input.ReadInt64Array(tag, field_name, result.packedInt64_); - break; - } - case 738: - case 736: { - input.ReadUInt32Array(tag, field_name, result.packedUint32_); - break; - } - case 746: - case 744: { - input.ReadUInt64Array(tag, field_name, result.packedUint64_); - break; - } - case 754: - case 752: { - input.ReadSInt32Array(tag, field_name, result.packedSint32_); - break; - } - case 762: - case 760: { - input.ReadSInt64Array(tag, field_name, result.packedSint64_); - break; - } - case 770: - case 773: { - input.ReadFixed32Array(tag, field_name, result.packedFixed32_); - break; - } - case 778: - case 777: { - input.ReadFixed64Array(tag, field_name, result.packedFixed64_); - break; - } - case 786: - case 789: { - input.ReadSFixed32Array(tag, field_name, result.packedSfixed32_); - break; - } - case 794: - case 793: { - input.ReadSFixed64Array(tag, field_name, result.packedSfixed64_); - break; - } - case 802: - case 805: { - input.ReadFloatArray(tag, field_name, result.packedFloat_); - break; - } - case 810: - case 809: { - input.ReadDoubleArray(tag, field_name, result.packedDouble_); - break; - } - case 818: - case 816: { - input.ReadBoolArray(tag, field_name, result.packedBool_); - break; - } - case 826: - case 824: { - scg::ICollection unknownItems; - input.ReadEnumArray(tag, field_name, result.packedEnum_, out unknownItems); - break; - } - } - } - - return this; - } - - - public pbc::IPopsicleList PackedInt32List { - get { return PrepareBuilder().packedInt32_; } - } - public int PackedInt32Count { - get { return result.PackedInt32Count; } - } - public int GetPackedInt32(int index) { - return result.GetPackedInt32(index); - } - public Builder SetPackedInt32(int index, int value) { - PrepareBuilder(); - result.packedInt32_[index] = value; - return this; - } - public Builder AddPackedInt32(int value) { - PrepareBuilder(); - result.packedInt32_.Add(value); - return this; - } - public Builder AddRangePackedInt32(scg::IEnumerable values) { - PrepareBuilder(); - result.packedInt32_.Add(values); - return this; - } - public Builder ClearPackedInt32() { - PrepareBuilder(); - result.packedInt32_.Clear(); - return this; - } - - public pbc::IPopsicleList PackedInt64List { - get { return PrepareBuilder().packedInt64_; } - } - public int PackedInt64Count { - get { return result.PackedInt64Count; } - } - public long GetPackedInt64(int index) { - return result.GetPackedInt64(index); - } - public Builder SetPackedInt64(int index, long value) { - PrepareBuilder(); - result.packedInt64_[index] = value; - return this; - } - public Builder AddPackedInt64(long value) { - PrepareBuilder(); - result.packedInt64_.Add(value); - return this; - } - public Builder AddRangePackedInt64(scg::IEnumerable values) { - PrepareBuilder(); - result.packedInt64_.Add(values); - return this; - } - public Builder ClearPackedInt64() { - PrepareBuilder(); - result.packedInt64_.Clear(); - return this; - } - - public pbc::IPopsicleList PackedUint32List { - get { return PrepareBuilder().packedUint32_; } - } - public int PackedUint32Count { - get { return result.PackedUint32Count; } - } - public uint GetPackedUint32(int index) { - return result.GetPackedUint32(index); - } - public Builder SetPackedUint32(int index, uint value) { - PrepareBuilder(); - result.packedUint32_[index] = value; - return this; - } - public Builder AddPackedUint32(uint value) { - PrepareBuilder(); - result.packedUint32_.Add(value); - return this; - } - public Builder AddRangePackedUint32(scg::IEnumerable values) { - PrepareBuilder(); - result.packedUint32_.Add(values); - return this; - } - public Builder ClearPackedUint32() { - PrepareBuilder(); - result.packedUint32_.Clear(); - return this; - } - - public pbc::IPopsicleList PackedUint64List { - get { return PrepareBuilder().packedUint64_; } - } - public int PackedUint64Count { - get { return result.PackedUint64Count; } - } - public ulong GetPackedUint64(int index) { - return result.GetPackedUint64(index); - } - public Builder SetPackedUint64(int index, ulong value) { - PrepareBuilder(); - result.packedUint64_[index] = value; - return this; - } - public Builder AddPackedUint64(ulong value) { - PrepareBuilder(); - result.packedUint64_.Add(value); - return this; - } - public Builder AddRangePackedUint64(scg::IEnumerable values) { - PrepareBuilder(); - result.packedUint64_.Add(values); - return this; - } - public Builder ClearPackedUint64() { - PrepareBuilder(); - result.packedUint64_.Clear(); - return this; - } - - public pbc::IPopsicleList PackedSint32List { - get { return PrepareBuilder().packedSint32_; } - } - public int PackedSint32Count { - get { return result.PackedSint32Count; } - } - public int GetPackedSint32(int index) { - return result.GetPackedSint32(index); - } - public Builder SetPackedSint32(int index, int value) { - PrepareBuilder(); - result.packedSint32_[index] = value; - return this; - } - public Builder AddPackedSint32(int value) { - PrepareBuilder(); - result.packedSint32_.Add(value); - return this; - } - public Builder AddRangePackedSint32(scg::IEnumerable values) { - PrepareBuilder(); - result.packedSint32_.Add(values); - return this; - } - public Builder ClearPackedSint32() { - PrepareBuilder(); - result.packedSint32_.Clear(); - return this; - } - - public pbc::IPopsicleList PackedSint64List { - get { return PrepareBuilder().packedSint64_; } - } - public int PackedSint64Count { - get { return result.PackedSint64Count; } - } - public long GetPackedSint64(int index) { - return result.GetPackedSint64(index); - } - public Builder SetPackedSint64(int index, long value) { - PrepareBuilder(); - result.packedSint64_[index] = value; - return this; - } - public Builder AddPackedSint64(long value) { - PrepareBuilder(); - result.packedSint64_.Add(value); - return this; - } - public Builder AddRangePackedSint64(scg::IEnumerable values) { - PrepareBuilder(); - result.packedSint64_.Add(values); - return this; - } - public Builder ClearPackedSint64() { - PrepareBuilder(); - result.packedSint64_.Clear(); - return this; - } - - public pbc::IPopsicleList PackedFixed32List { - get { return PrepareBuilder().packedFixed32_; } - } - public int PackedFixed32Count { - get { return result.PackedFixed32Count; } - } - public uint GetPackedFixed32(int index) { - return result.GetPackedFixed32(index); - } - public Builder SetPackedFixed32(int index, uint value) { - PrepareBuilder(); - result.packedFixed32_[index] = value; - return this; - } - public Builder AddPackedFixed32(uint value) { - PrepareBuilder(); - result.packedFixed32_.Add(value); - return this; - } - public Builder AddRangePackedFixed32(scg::IEnumerable values) { - PrepareBuilder(); - result.packedFixed32_.Add(values); - return this; - } - public Builder ClearPackedFixed32() { - PrepareBuilder(); - result.packedFixed32_.Clear(); - return this; - } - - public pbc::IPopsicleList PackedFixed64List { - get { return PrepareBuilder().packedFixed64_; } - } - public int PackedFixed64Count { - get { return result.PackedFixed64Count; } - } - public ulong GetPackedFixed64(int index) { - return result.GetPackedFixed64(index); - } - public Builder SetPackedFixed64(int index, ulong value) { - PrepareBuilder(); - result.packedFixed64_[index] = value; - return this; - } - public Builder AddPackedFixed64(ulong value) { - PrepareBuilder(); - result.packedFixed64_.Add(value); - return this; - } - public Builder AddRangePackedFixed64(scg::IEnumerable values) { - PrepareBuilder(); - result.packedFixed64_.Add(values); - return this; - } - public Builder ClearPackedFixed64() { - PrepareBuilder(); - result.packedFixed64_.Clear(); - return this; - } - - public pbc::IPopsicleList PackedSfixed32List { - get { return PrepareBuilder().packedSfixed32_; } - } - public int PackedSfixed32Count { - get { return result.PackedSfixed32Count; } - } - public int GetPackedSfixed32(int index) { - return result.GetPackedSfixed32(index); - } - public Builder SetPackedSfixed32(int index, int value) { - PrepareBuilder(); - result.packedSfixed32_[index] = value; - return this; - } - public Builder AddPackedSfixed32(int value) { - PrepareBuilder(); - result.packedSfixed32_.Add(value); - return this; - } - public Builder AddRangePackedSfixed32(scg::IEnumerable values) { - PrepareBuilder(); - result.packedSfixed32_.Add(values); - return this; - } - public Builder ClearPackedSfixed32() { - PrepareBuilder(); - result.packedSfixed32_.Clear(); - return this; - } - - public pbc::IPopsicleList PackedSfixed64List { - get { return PrepareBuilder().packedSfixed64_; } - } - public int PackedSfixed64Count { - get { return result.PackedSfixed64Count; } - } - public long GetPackedSfixed64(int index) { - return result.GetPackedSfixed64(index); - } - public Builder SetPackedSfixed64(int index, long value) { - PrepareBuilder(); - result.packedSfixed64_[index] = value; - return this; - } - public Builder AddPackedSfixed64(long value) { - PrepareBuilder(); - result.packedSfixed64_.Add(value); - return this; - } - public Builder AddRangePackedSfixed64(scg::IEnumerable values) { - PrepareBuilder(); - result.packedSfixed64_.Add(values); - return this; - } - public Builder ClearPackedSfixed64() { - PrepareBuilder(); - result.packedSfixed64_.Clear(); - return this; - } - - public pbc::IPopsicleList PackedFloatList { - get { return PrepareBuilder().packedFloat_; } - } - public int PackedFloatCount { - get { return result.PackedFloatCount; } - } - public float GetPackedFloat(int index) { - return result.GetPackedFloat(index); - } - public Builder SetPackedFloat(int index, float value) { - PrepareBuilder(); - result.packedFloat_[index] = value; - return this; - } - public Builder AddPackedFloat(float value) { - PrepareBuilder(); - result.packedFloat_.Add(value); - return this; - } - public Builder AddRangePackedFloat(scg::IEnumerable values) { - PrepareBuilder(); - result.packedFloat_.Add(values); - return this; - } - public Builder ClearPackedFloat() { - PrepareBuilder(); - result.packedFloat_.Clear(); - return this; - } - - public pbc::IPopsicleList PackedDoubleList { - get { return PrepareBuilder().packedDouble_; } - } - public int PackedDoubleCount { - get { return result.PackedDoubleCount; } - } - public double GetPackedDouble(int index) { - return result.GetPackedDouble(index); - } - public Builder SetPackedDouble(int index, double value) { - PrepareBuilder(); - result.packedDouble_[index] = value; - return this; - } - public Builder AddPackedDouble(double value) { - PrepareBuilder(); - result.packedDouble_.Add(value); - return this; - } - public Builder AddRangePackedDouble(scg::IEnumerable values) { - PrepareBuilder(); - result.packedDouble_.Add(values); - return this; - } - public Builder ClearPackedDouble() { - PrepareBuilder(); - result.packedDouble_.Clear(); - return this; - } - - public pbc::IPopsicleList PackedBoolList { - get { return PrepareBuilder().packedBool_; } - } - public int PackedBoolCount { - get { return result.PackedBoolCount; } - } - public bool GetPackedBool(int index) { - return result.GetPackedBool(index); - } - public Builder SetPackedBool(int index, bool value) { - PrepareBuilder(); - result.packedBool_[index] = value; - return this; - } - public Builder AddPackedBool(bool value) { - PrepareBuilder(); - result.packedBool_.Add(value); - return this; - } - public Builder AddRangePackedBool(scg::IEnumerable values) { - PrepareBuilder(); - result.packedBool_.Add(values); - return this; - } - public Builder ClearPackedBool() { - PrepareBuilder(); - result.packedBool_.Clear(); - return this; - } - - public pbc::IPopsicleList PackedEnumList { - get { return PrepareBuilder().packedEnum_; } - } - public int PackedEnumCount { - get { return result.PackedEnumCount; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignEnumLite GetPackedEnum(int index) { - return result.GetPackedEnum(index); - } - public Builder SetPackedEnum(int index, global::Google.ProtocolBuffers.TestProtos.ForeignEnumLite value) { - PrepareBuilder(); - result.packedEnum_[index] = value; - return this; - } - public Builder AddPackedEnum(global::Google.ProtocolBuffers.TestProtos.ForeignEnumLite value) { - PrepareBuilder(); - result.packedEnum_.Add(value); - return this; - } - public Builder AddRangePackedEnum(scg::IEnumerable values) { - PrepareBuilder(); - result.packedEnum_.Add(values); - return this; - } - public Builder ClearPackedEnum() { - PrepareBuilder(); - result.packedEnum_.Clear(); - return this; - } - } - static TestPackedTypesLite() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.UnittestLite.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestAllExtensionsLite : pb::ExtendableMessageLite { - private TestAllExtensionsLite() { } - private static readonly TestAllExtensionsLite defaultInstance = new TestAllExtensionsLite().MakeReadOnly(); - private static readonly string[] _testAllExtensionsLiteFieldNames = new string[] { }; - private static readonly uint[] _testAllExtensionsLiteFieldTags = new uint[] { }; - public static TestAllExtensionsLite DefaultInstance { - get { return defaultInstance; } - } - - public override TestAllExtensionsLite DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestAllExtensionsLite ThisMessage { - get { return this; } - } - - public override bool IsInitialized { - get { - if (!ExtensionsAreInitialized) return false; - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testAllExtensionsLiteFieldNames; - pb::ExtendableMessageLite.ExtensionWriter extensionWriter = CreateExtensionWriter(this); - extensionWriter.WriteUntil(536870912, output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - size += ExtensionsSerializedSize; - memoizedSerializedSize = size; - return size; - } - #region Lite runtime methods - public override int GetHashCode() { - int hash = GetType().GetHashCode(); - hash ^= base.GetHashCode(); - return hash; - } - - public override bool Equals(object obj) { - TestAllExtensionsLite other = obj as TestAllExtensionsLite; - if (other == null) return false; - if (!base.Equals(other)) return false; - return true; - } - - public override void PrintTo(global::System.IO.TextWriter writer) { - base.PrintTo(writer); - } - #endregion - - public static TestAllExtensionsLite ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestAllExtensionsLite ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestAllExtensionsLite ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestAllExtensionsLite ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestAllExtensionsLite ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestAllExtensionsLite ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestAllExtensionsLite ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestAllExtensionsLite ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestAllExtensionsLite ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestAllExtensionsLite ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestAllExtensionsLite MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestAllExtensionsLite prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::ExtendableBuilderLite { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestAllExtensionsLite cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestAllExtensionsLite result; - - private TestAllExtensionsLite PrepareBuilder() { - if (resultIsReadOnly) { - TestAllExtensionsLite original = result; - result = new TestAllExtensionsLite(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestAllExtensionsLite MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override TestAllExtensionsLite DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance; } - } - - public override TestAllExtensionsLite BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessageLite other) { - if (other is TestAllExtensionsLite) { - return MergeFrom((TestAllExtensionsLite) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestAllExtensionsLite other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestAllExtensionsLite.DefaultInstance) return this; - PrepareBuilder(); - this.MergeExtensionFields(other); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testAllExtensionsLiteFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testAllExtensionsLiteFieldTags[field_ordinal]; - else { - ParseUnknownField(input, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - return this; - } - ParseUnknownField(input, extensionRegistry, tag, field_name); - break; - } - } - } - - return this; - } - - } - static TestAllExtensionsLite() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.UnittestLite.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class OptionalGroup_extension_lite : pb::GeneratedMessageLite { - private OptionalGroup_extension_lite() { } - private static readonly OptionalGroup_extension_lite defaultInstance = new OptionalGroup_extension_lite().MakeReadOnly(); - private static readonly string[] _optionalGroupExtensionLiteFieldNames = new string[] { "a" }; - private static readonly uint[] _optionalGroupExtensionLiteFieldTags = new uint[] { 136 }; - public static OptionalGroup_extension_lite DefaultInstance { - get { return defaultInstance; } - } - - public override OptionalGroup_extension_lite DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override OptionalGroup_extension_lite ThisMessage { - get { return this; } - } - - public const int AFieldNumber = 17; - private bool hasA; - private int a_; - public bool HasA { - get { return hasA; } - } - public int A { - get { return a_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _optionalGroupExtensionLiteFieldNames; - if (hasA) { - output.WriteInt32(17, field_names[0], A); - } - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(17, A); - } - memoizedSerializedSize = size; - return size; - } - #region Lite runtime methods - public override int GetHashCode() { - int hash = GetType().GetHashCode(); - if (hasA) { - hash ^= a_.GetHashCode(); - } - return hash; - } - - public override bool Equals(object obj) { - OptionalGroup_extension_lite other = obj as OptionalGroup_extension_lite; - if (other == null) return false; - if (hasA != other.hasA || (hasA && !a_.Equals(other.a_))) return false; - return true; - } - - public override void PrintTo(global::System.IO.TextWriter writer) { - PrintField("a", hasA, a_, writer); - } - #endregion - - public static OptionalGroup_extension_lite ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static OptionalGroup_extension_lite ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static OptionalGroup_extension_lite ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static OptionalGroup_extension_lite ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static OptionalGroup_extension_lite ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static OptionalGroup_extension_lite ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static OptionalGroup_extension_lite ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static OptionalGroup_extension_lite ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static OptionalGroup_extension_lite ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static OptionalGroup_extension_lite ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private OptionalGroup_extension_lite MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(OptionalGroup_extension_lite prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilderLite { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(OptionalGroup_extension_lite cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private OptionalGroup_extension_lite result; - - private OptionalGroup_extension_lite PrepareBuilder() { - if (resultIsReadOnly) { - OptionalGroup_extension_lite original = result; - result = new OptionalGroup_extension_lite(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override OptionalGroup_extension_lite MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override OptionalGroup_extension_lite DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.OptionalGroup_extension_lite.DefaultInstance; } - } - - public override OptionalGroup_extension_lite BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessageLite other) { - if (other is OptionalGroup_extension_lite) { - return MergeFrom((OptionalGroup_extension_lite) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(OptionalGroup_extension_lite other) { - if (other == global::Google.ProtocolBuffers.TestProtos.OptionalGroup_extension_lite.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasA) { - A = other.A; - } - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_optionalGroupExtensionLiteFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _optionalGroupExtensionLiteFieldTags[field_ordinal]; - else { - ParseUnknownField(input, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - return this; - } - ParseUnknownField(input, extensionRegistry, tag, field_name); - break; - } - case 136: { - result.hasA = input.ReadInt32(ref result.a_); - break; - } - } - } - - return this; - } - - - public bool HasA { - get { return result.hasA; } - } - public int A { - get { return result.A; } - set { SetA(value); } - } - public Builder SetA(int value) { - PrepareBuilder(); - result.hasA = true; - result.a_ = value; - return this; - } - public Builder ClearA() { - PrepareBuilder(); - result.hasA = false; - result.a_ = 0; - return this; - } - } - static OptionalGroup_extension_lite() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.UnittestLite.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class RepeatedGroup_extension_lite : pb::GeneratedMessageLite { - private RepeatedGroup_extension_lite() { } - private static readonly RepeatedGroup_extension_lite defaultInstance = new RepeatedGroup_extension_lite().MakeReadOnly(); - private static readonly string[] _repeatedGroupExtensionLiteFieldNames = new string[] { "a" }; - private static readonly uint[] _repeatedGroupExtensionLiteFieldTags = new uint[] { 376 }; - public static RepeatedGroup_extension_lite DefaultInstance { - get { return defaultInstance; } - } - - public override RepeatedGroup_extension_lite DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override RepeatedGroup_extension_lite ThisMessage { - get { return this; } - } - - public const int AFieldNumber = 47; - private bool hasA; - private int a_; - public bool HasA { - get { return hasA; } - } - public int A { - get { return a_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _repeatedGroupExtensionLiteFieldNames; - if (hasA) { - output.WriteInt32(47, field_names[0], A); - } - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(47, A); - } - memoizedSerializedSize = size; - return size; - } - #region Lite runtime methods - public override int GetHashCode() { - int hash = GetType().GetHashCode(); - if (hasA) { - hash ^= a_.GetHashCode(); - } - return hash; - } - - public override bool Equals(object obj) { - RepeatedGroup_extension_lite other = obj as RepeatedGroup_extension_lite; - if (other == null) return false; - if (hasA != other.hasA || (hasA && !a_.Equals(other.a_))) return false; - return true; - } - - public override void PrintTo(global::System.IO.TextWriter writer) { - PrintField("a", hasA, a_, writer); - } - #endregion - - public static RepeatedGroup_extension_lite ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static RepeatedGroup_extension_lite ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static RepeatedGroup_extension_lite ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static RepeatedGroup_extension_lite ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static RepeatedGroup_extension_lite ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static RepeatedGroup_extension_lite ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static RepeatedGroup_extension_lite ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static RepeatedGroup_extension_lite ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static RepeatedGroup_extension_lite ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static RepeatedGroup_extension_lite ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private RepeatedGroup_extension_lite MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(RepeatedGroup_extension_lite prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilderLite { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(RepeatedGroup_extension_lite cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private RepeatedGroup_extension_lite result; - - private RepeatedGroup_extension_lite PrepareBuilder() { - if (resultIsReadOnly) { - RepeatedGroup_extension_lite original = result; - result = new RepeatedGroup_extension_lite(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override RepeatedGroup_extension_lite MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override RepeatedGroup_extension_lite DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.RepeatedGroup_extension_lite.DefaultInstance; } - } - - public override RepeatedGroup_extension_lite BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessageLite other) { - if (other is RepeatedGroup_extension_lite) { - return MergeFrom((RepeatedGroup_extension_lite) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(RepeatedGroup_extension_lite other) { - if (other == global::Google.ProtocolBuffers.TestProtos.RepeatedGroup_extension_lite.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasA) { - A = other.A; - } - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_repeatedGroupExtensionLiteFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _repeatedGroupExtensionLiteFieldTags[field_ordinal]; - else { - ParseUnknownField(input, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - return this; - } - ParseUnknownField(input, extensionRegistry, tag, field_name); - break; - } - case 376: { - result.hasA = input.ReadInt32(ref result.a_); - break; - } - } - } - - return this; - } - - - public bool HasA { - get { return result.hasA; } - } - public int A { - get { return result.A; } - set { SetA(value); } - } - public Builder SetA(int value) { - PrepareBuilder(); - result.hasA = true; - result.a_ = value; - return this; - } - public Builder ClearA() { - PrepareBuilder(); - result.hasA = false; - result.a_ = 0; - return this; - } - } - static RepeatedGroup_extension_lite() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.UnittestLite.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestPackedExtensionsLite : pb::ExtendableMessageLite { - private TestPackedExtensionsLite() { } - private static readonly TestPackedExtensionsLite defaultInstance = new TestPackedExtensionsLite().MakeReadOnly(); - private static readonly string[] _testPackedExtensionsLiteFieldNames = new string[] { }; - private static readonly uint[] _testPackedExtensionsLiteFieldTags = new uint[] { }; - public static TestPackedExtensionsLite DefaultInstance { - get { return defaultInstance; } - } - - public override TestPackedExtensionsLite DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestPackedExtensionsLite ThisMessage { - get { return this; } - } - - public override bool IsInitialized { - get { - if (!ExtensionsAreInitialized) return false; - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testPackedExtensionsLiteFieldNames; - pb::ExtendableMessageLite.ExtensionWriter extensionWriter = CreateExtensionWriter(this); - extensionWriter.WriteUntil(536870912, output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - size += ExtensionsSerializedSize; - memoizedSerializedSize = size; - return size; - } - #region Lite runtime methods - public override int GetHashCode() { - int hash = GetType().GetHashCode(); - hash ^= base.GetHashCode(); - return hash; - } - - public override bool Equals(object obj) { - TestPackedExtensionsLite other = obj as TestPackedExtensionsLite; - if (other == null) return false; - if (!base.Equals(other)) return false; - return true; - } - - public override void PrintTo(global::System.IO.TextWriter writer) { - base.PrintTo(writer); - } - #endregion - - public static TestPackedExtensionsLite ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestPackedExtensionsLite ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestPackedExtensionsLite ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestPackedExtensionsLite ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestPackedExtensionsLite ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestPackedExtensionsLite ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestPackedExtensionsLite ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestPackedExtensionsLite ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestPackedExtensionsLite ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestPackedExtensionsLite ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestPackedExtensionsLite MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestPackedExtensionsLite prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::ExtendableBuilderLite { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestPackedExtensionsLite cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestPackedExtensionsLite result; - - private TestPackedExtensionsLite PrepareBuilder() { - if (resultIsReadOnly) { - TestPackedExtensionsLite original = result; - result = new TestPackedExtensionsLite(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestPackedExtensionsLite MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override TestPackedExtensionsLite DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestPackedExtensionsLite.DefaultInstance; } - } - - public override TestPackedExtensionsLite BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessageLite other) { - if (other is TestPackedExtensionsLite) { - return MergeFrom((TestPackedExtensionsLite) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestPackedExtensionsLite other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestPackedExtensionsLite.DefaultInstance) return this; - PrepareBuilder(); - this.MergeExtensionFields(other); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testPackedExtensionsLiteFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testPackedExtensionsLiteFieldTags[field_ordinal]; - else { - ParseUnknownField(input, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - return this; - } - ParseUnknownField(input, extensionRegistry, tag, field_name); - break; - } - } - } - - return this; - } - - } - static TestPackedExtensionsLite() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.UnittestLite.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestNestedExtensionLite : pb::GeneratedMessageLite { - private TestNestedExtensionLite() { } - private static readonly TestNestedExtensionLite defaultInstance = new TestNestedExtensionLite().MakeReadOnly(); - private static readonly string[] _testNestedExtensionLiteFieldNames = new string[] { }; - private static readonly uint[] _testNestedExtensionLiteFieldTags = new uint[] { }; - public static TestNestedExtensionLite DefaultInstance { - get { return defaultInstance; } - } - - public override TestNestedExtensionLite DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestNestedExtensionLite ThisMessage { - get { return this; } - } - - public const int NestedExtensionFieldNumber = 12345; - public static pb::GeneratedExtensionLite NestedExtension; - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testNestedExtensionLiteFieldNames; - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - memoizedSerializedSize = size; - return size; - } - #region Lite runtime methods - public override int GetHashCode() { - int hash = GetType().GetHashCode(); - return hash; - } - - public override bool Equals(object obj) { - TestNestedExtensionLite other = obj as TestNestedExtensionLite; - if (other == null) return false; - return true; - } - - public override void PrintTo(global::System.IO.TextWriter writer) { - } - #endregion - - public static TestNestedExtensionLite ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestNestedExtensionLite ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestNestedExtensionLite ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestNestedExtensionLite ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestNestedExtensionLite ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestNestedExtensionLite ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestNestedExtensionLite ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestNestedExtensionLite ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestNestedExtensionLite ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestNestedExtensionLite ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestNestedExtensionLite MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestNestedExtensionLite prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilderLite { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestNestedExtensionLite cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestNestedExtensionLite result; - - private TestNestedExtensionLite PrepareBuilder() { - if (resultIsReadOnly) { - TestNestedExtensionLite original = result; - result = new TestNestedExtensionLite(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestNestedExtensionLite MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override TestNestedExtensionLite DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestNestedExtensionLite.DefaultInstance; } - } - - public override TestNestedExtensionLite BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessageLite other) { - if (other is TestNestedExtensionLite) { - return MergeFrom((TestNestedExtensionLite) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestNestedExtensionLite other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestNestedExtensionLite.DefaultInstance) return this; - PrepareBuilder(); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testNestedExtensionLiteFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testNestedExtensionLiteFieldTags[field_ordinal]; - else { - ParseUnknownField(input, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - return this; - } - ParseUnknownField(input, extensionRegistry, tag, field_name); - break; - } - } - } - - return this; - } - - } - static TestNestedExtensionLite() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.UnittestLite.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestDeprecatedLite : pb::GeneratedMessageLite { - private TestDeprecatedLite() { } - private static readonly TestDeprecatedLite defaultInstance = new TestDeprecatedLite().MakeReadOnly(); - private static readonly string[] _testDeprecatedLiteFieldNames = new string[] { "deprecated_field" }; - private static readonly uint[] _testDeprecatedLiteFieldTags = new uint[] { 8 }; - public static TestDeprecatedLite DefaultInstance { - get { return defaultInstance; } - } - - public override TestDeprecatedLite DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestDeprecatedLite ThisMessage { - get { return this; } - } - - public const int DeprecatedFieldFieldNumber = 1; - private bool hasDeprecatedField; - private int deprecatedField_; - [global::System.ObsoleteAttribute()] - public bool HasDeprecatedField { - get { return hasDeprecatedField; } - } - [global::System.ObsoleteAttribute()] - public int DeprecatedField { - get { return deprecatedField_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testDeprecatedLiteFieldNames; - if (hasDeprecatedField) { - output.WriteInt32(1, field_names[0], DeprecatedField); - } - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasDeprecatedField) { - size += pb::CodedOutputStream.ComputeInt32Size(1, DeprecatedField); - } - memoizedSerializedSize = size; - return size; - } - #region Lite runtime methods - public override int GetHashCode() { - int hash = GetType().GetHashCode(); - if (hasDeprecatedField) { - hash ^= deprecatedField_.GetHashCode(); - } - return hash; - } - - public override bool Equals(object obj) { - TestDeprecatedLite other = obj as TestDeprecatedLite; - if (other == null) return false; - if (hasDeprecatedField != other.hasDeprecatedField || (hasDeprecatedField && !deprecatedField_.Equals(other.deprecatedField_))) return false; - return true; - } - - public override void PrintTo(global::System.IO.TextWriter writer) { - PrintField("deprecated_field", hasDeprecatedField, deprecatedField_, writer); - } - #endregion - - public static TestDeprecatedLite ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestDeprecatedLite ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestDeprecatedLite ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestDeprecatedLite ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestDeprecatedLite ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestDeprecatedLite ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestDeprecatedLite ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestDeprecatedLite ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestDeprecatedLite ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestDeprecatedLite ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestDeprecatedLite MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestDeprecatedLite prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilderLite { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestDeprecatedLite cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestDeprecatedLite result; - - private TestDeprecatedLite PrepareBuilder() { - if (resultIsReadOnly) { - TestDeprecatedLite original = result; - result = new TestDeprecatedLite(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestDeprecatedLite MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override TestDeprecatedLite DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestDeprecatedLite.DefaultInstance; } - } - - public override TestDeprecatedLite BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessageLite other) { - if (other is TestDeprecatedLite) { - return MergeFrom((TestDeprecatedLite) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestDeprecatedLite other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestDeprecatedLite.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasDeprecatedField) { - DeprecatedField = other.DeprecatedField; - } - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testDeprecatedLiteFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testDeprecatedLiteFieldTags[field_ordinal]; - else { - ParseUnknownField(input, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - return this; - } - ParseUnknownField(input, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasDeprecatedField = input.ReadInt32(ref result.deprecatedField_); - break; - } - } - } - - return this; - } - - - [global::System.ObsoleteAttribute()] - public bool HasDeprecatedField { - get { return result.hasDeprecatedField; } - } - [global::System.ObsoleteAttribute()] - public int DeprecatedField { - get { return result.DeprecatedField; } - set { SetDeprecatedField(value); } - } - [global::System.ObsoleteAttribute()] - public Builder SetDeprecatedField(int value) { - PrepareBuilder(); - result.hasDeprecatedField = true; - result.deprecatedField_ = value; - return this; - } - [global::System.ObsoleteAttribute()] - public Builder ClearDeprecatedField() { - PrepareBuilder(); - result.hasDeprecatedField = false; - result.deprecatedField_ = 0; - return this; - } - } - static TestDeprecatedLite() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.UnittestLite.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestParsingMergeLite : pb::ExtendableMessageLite { - private TestParsingMergeLite() { } - private static readonly TestParsingMergeLite defaultInstance = new TestParsingMergeLite().MakeReadOnly(); - private static readonly string[] _testParsingMergeLiteFieldNames = new string[] { "optional_all_types", "optionalgroup", "repeated_all_types", "repeatedgroup", "required_all_types" }; - private static readonly uint[] _testParsingMergeLiteFieldTags = new uint[] { 18, 83, 26, 163, 10 }; - public static TestParsingMergeLite DefaultInstance { - get { return defaultInstance; } - } - - public override TestParsingMergeLite DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestParsingMergeLite ThisMessage { - get { return this; } - } - - public const int OptionalExtFieldNumber = 1000; - public static pb::GeneratedExtensionLite OptionalExt; - public const int RepeatedExtFieldNumber = 1001; - public static pb::GeneratedRepeatExtensionLite RepeatedExt; - #region Nested types - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class Types { - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class RepeatedFieldsGenerator : pb::GeneratedMessageLite { - private RepeatedFieldsGenerator() { } - private static readonly RepeatedFieldsGenerator defaultInstance = new RepeatedFieldsGenerator().MakeReadOnly(); - private static readonly string[] _repeatedFieldsGeneratorFieldNames = new string[] { "ext1", "ext2", "field1", "field2", "field3", "group1", "group2" }; - private static readonly uint[] _repeatedFieldsGeneratorFieldTags = new uint[] { 8002, 8010, 10, 18, 26, 83, 163 }; - public static RepeatedFieldsGenerator DefaultInstance { - get { return defaultInstance; } - } - - public override RepeatedFieldsGenerator DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override RepeatedFieldsGenerator ThisMessage { - get { return this; } - } - - #region Nested types - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class Types { - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Group1 : pb::GeneratedMessageLite { - private Group1() { } - private static readonly Group1 defaultInstance = new Group1().MakeReadOnly(); - private static readonly string[] _group1FieldNames = new string[] { "field1" }; - private static readonly uint[] _group1FieldTags = new uint[] { 90 }; - public static Group1 DefaultInstance { - get { return defaultInstance; } - } - - public override Group1 DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override Group1 ThisMessage { - get { return this; } - } - - public const int Field1FieldNumber = 11; - private bool hasField1; - private global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite field1_; - public bool HasField1 { - get { return hasField1; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite Field1 { - get { return field1_ ?? global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.DefaultInstance; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _group1FieldNames; - if (hasField1) { - output.WriteMessage(11, field_names[0], Field1); - } - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasField1) { - size += pb::CodedOutputStream.ComputeMessageSize(11, Field1); - } - memoizedSerializedSize = size; - return size; - } - #region Lite runtime methods - public override int GetHashCode() { - int hash = GetType().GetHashCode(); - if (hasField1) hash ^= field1_.GetHashCode(); - return hash; - } - - public override bool Equals(object obj) { - Group1 other = obj as Group1; - if (other == null) return false; - if (hasField1 != other.hasField1 || (hasField1 && !field1_.Equals(other.field1_))) return false; - return true; - } - - public override void PrintTo(global::System.IO.TextWriter writer) { - PrintField("field1", hasField1, field1_, writer); - } - #endregion - - public static Group1 ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static Group1 ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static Group1 ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static Group1 ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static Group1 ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static Group1 ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static Group1 ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static Group1 ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static Group1 ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static Group1 ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private Group1 MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(Group1 prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilderLite { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(Group1 cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private Group1 result; - - private Group1 PrepareBuilder() { - if (resultIsReadOnly) { - Group1 original = result; - result = new Group1(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override Group1 MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override Group1 DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.Types.RepeatedFieldsGenerator.Types.Group1.DefaultInstance; } - } - - public override Group1 BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessageLite other) { - if (other is Group1) { - return MergeFrom((Group1) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(Group1 other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.Types.RepeatedFieldsGenerator.Types.Group1.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasField1) { - MergeField1(other.Field1); - } - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_group1FieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _group1FieldTags[field_ordinal]; - else { - ParseUnknownField(input, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - return this; - } - ParseUnknownField(input, extensionRegistry, tag, field_name); - break; - } - case 90: { - global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.CreateBuilder(); - if (result.hasField1) { - subBuilder.MergeFrom(Field1); - } - input.ReadMessage(subBuilder, extensionRegistry); - Field1 = subBuilder.BuildPartial(); - break; - } - } - } - - return this; - } - - - public bool HasField1 { - get { return result.hasField1; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite Field1 { - get { return result.Field1; } - set { SetField1(value); } - } - public Builder SetField1(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasField1 = true; - result.field1_ = value; - return this; - } - public Builder SetField1(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasField1 = true; - result.field1_ = builderForValue.Build(); - return this; - } - public Builder MergeField1(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasField1 && - result.field1_ != global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.DefaultInstance) { - result.field1_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.CreateBuilder(result.field1_).MergeFrom(value).BuildPartial(); - } else { - result.field1_ = value; - } - result.hasField1 = true; - return this; - } - public Builder ClearField1() { - PrepareBuilder(); - result.hasField1 = false; - result.field1_ = null; - return this; - } - } - static Group1() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.UnittestLite.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Group2 : pb::GeneratedMessageLite { - private Group2() { } - private static readonly Group2 defaultInstance = new Group2().MakeReadOnly(); - private static readonly string[] _group2FieldNames = new string[] { "field1" }; - private static readonly uint[] _group2FieldTags = new uint[] { 170 }; - public static Group2 DefaultInstance { - get { return defaultInstance; } - } - - public override Group2 DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override Group2 ThisMessage { - get { return this; } - } - - public const int Field1FieldNumber = 21; - private bool hasField1; - private global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite field1_; - public bool HasField1 { - get { return hasField1; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite Field1 { - get { return field1_ ?? global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.DefaultInstance; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _group2FieldNames; - if (hasField1) { - output.WriteMessage(21, field_names[0], Field1); - } - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasField1) { - size += pb::CodedOutputStream.ComputeMessageSize(21, Field1); - } - memoizedSerializedSize = size; - return size; - } - #region Lite runtime methods - public override int GetHashCode() { - int hash = GetType().GetHashCode(); - if (hasField1) hash ^= field1_.GetHashCode(); - return hash; - } - - public override bool Equals(object obj) { - Group2 other = obj as Group2; - if (other == null) return false; - if (hasField1 != other.hasField1 || (hasField1 && !field1_.Equals(other.field1_))) return false; - return true; - } - - public override void PrintTo(global::System.IO.TextWriter writer) { - PrintField("field1", hasField1, field1_, writer); - } - #endregion - - public static Group2 ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static Group2 ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static Group2 ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static Group2 ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static Group2 ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static Group2 ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static Group2 ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static Group2 ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static Group2 ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static Group2 ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private Group2 MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(Group2 prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilderLite { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(Group2 cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private Group2 result; - - private Group2 PrepareBuilder() { - if (resultIsReadOnly) { - Group2 original = result; - result = new Group2(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override Group2 MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override Group2 DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.Types.RepeatedFieldsGenerator.Types.Group2.DefaultInstance; } - } - - public override Group2 BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessageLite other) { - if (other is Group2) { - return MergeFrom((Group2) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(Group2 other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.Types.RepeatedFieldsGenerator.Types.Group2.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasField1) { - MergeField1(other.Field1); - } - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_group2FieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _group2FieldTags[field_ordinal]; - else { - ParseUnknownField(input, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - return this; - } - ParseUnknownField(input, extensionRegistry, tag, field_name); - break; - } - case 170: { - global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.CreateBuilder(); - if (result.hasField1) { - subBuilder.MergeFrom(Field1); - } - input.ReadMessage(subBuilder, extensionRegistry); - Field1 = subBuilder.BuildPartial(); - break; - } - } - } - - return this; - } - - - public bool HasField1 { - get { return result.hasField1; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite Field1 { - get { return result.Field1; } - set { SetField1(value); } - } - public Builder SetField1(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasField1 = true; - result.field1_ = value; - return this; - } - public Builder SetField1(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasField1 = true; - result.field1_ = builderForValue.Build(); - return this; - } - public Builder MergeField1(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasField1 && - result.field1_ != global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.DefaultInstance) { - result.field1_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.CreateBuilder(result.field1_).MergeFrom(value).BuildPartial(); - } else { - result.field1_ = value; - } - result.hasField1 = true; - return this; - } - public Builder ClearField1() { - PrepareBuilder(); - result.hasField1 = false; - result.field1_ = null; - return this; - } - } - static Group2() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.UnittestLite.Descriptor, null); - } - } - - } - #endregion - - public const int Field1FieldNumber = 1; - private pbc::PopsicleList field1_ = new pbc::PopsicleList(); - public scg::IList Field1List { - get { return field1_; } - } - public int Field1Count { - get { return field1_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite GetField1(int index) { - return field1_[index]; - } - - public const int Field2FieldNumber = 2; - private pbc::PopsicleList field2_ = new pbc::PopsicleList(); - public scg::IList Field2List { - get { return field2_; } - } - public int Field2Count { - get { return field2_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite GetField2(int index) { - return field2_[index]; - } - - public const int Field3FieldNumber = 3; - private pbc::PopsicleList field3_ = new pbc::PopsicleList(); - public scg::IList Field3List { - get { return field3_; } - } - public int Field3Count { - get { return field3_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite GetField3(int index) { - return field3_[index]; - } - - public const int Group1FieldNumber = 10; - private pbc::PopsicleList group1_ = new pbc::PopsicleList(); - public scg::IList Group1List { - get { return group1_; } - } - public int Group1Count { - get { return group1_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.Types.RepeatedFieldsGenerator.Types.Group1 GetGroup1(int index) { - return group1_[index]; - } - - public const int Group2FieldNumber = 20; - private pbc::PopsicleList group2_ = new pbc::PopsicleList(); - public scg::IList Group2List { - get { return group2_; } - } - public int Group2Count { - get { return group2_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.Types.RepeatedFieldsGenerator.Types.Group2 GetGroup2(int index) { - return group2_[index]; - } - - public const int Ext1FieldNumber = 1000; - private pbc::PopsicleList ext1_ = new pbc::PopsicleList(); - public scg::IList Ext1List { - get { return ext1_; } - } - public int Ext1Count { - get { return ext1_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite GetExt1(int index) { - return ext1_[index]; - } - - public const int Ext2FieldNumber = 1001; - private pbc::PopsicleList ext2_ = new pbc::PopsicleList(); - public scg::IList Ext2List { - get { return ext2_; } - } - public int Ext2Count { - get { return ext2_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite GetExt2(int index) { - return ext2_[index]; - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _repeatedFieldsGeneratorFieldNames; - if (field1_.Count > 0) { - output.WriteMessageArray(1, field_names[2], field1_); - } - if (field2_.Count > 0) { - output.WriteMessageArray(2, field_names[3], field2_); - } - if (field3_.Count > 0) { - output.WriteMessageArray(3, field_names[4], field3_); - } - if (group1_.Count > 0) { - output.WriteGroupArray(10, field_names[5], group1_); - } - if (group2_.Count > 0) { - output.WriteGroupArray(20, field_names[6], group2_); - } - if (ext1_.Count > 0) { - output.WriteMessageArray(1000, field_names[0], ext1_); - } - if (ext2_.Count > 0) { - output.WriteMessageArray(1001, field_names[1], ext2_); - } - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite element in Field1List) { - size += pb::CodedOutputStream.ComputeMessageSize(1, element); - } - foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite element in Field2List) { - size += pb::CodedOutputStream.ComputeMessageSize(2, element); - } - foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite element in Field3List) { - size += pb::CodedOutputStream.ComputeMessageSize(3, element); - } - foreach (global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.Types.RepeatedFieldsGenerator.Types.Group1 element in Group1List) { - size += pb::CodedOutputStream.ComputeGroupSize(10, element); - } - foreach (global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.Types.RepeatedFieldsGenerator.Types.Group2 element in Group2List) { - size += pb::CodedOutputStream.ComputeGroupSize(20, element); - } - foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite element in Ext1List) { - size += pb::CodedOutputStream.ComputeMessageSize(1000, element); - } - foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite element in Ext2List) { - size += pb::CodedOutputStream.ComputeMessageSize(1001, element); - } - memoizedSerializedSize = size; - return size; - } - #region Lite runtime methods - public override int GetHashCode() { - int hash = GetType().GetHashCode(); - foreach(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite i in field1_) - hash ^= i.GetHashCode(); - foreach(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite i in field2_) - hash ^= i.GetHashCode(); - foreach(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite i in field3_) - hash ^= i.GetHashCode(); - foreach(global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.Types.RepeatedFieldsGenerator.Types.Group1 i in group1_) - hash ^= i.GetHashCode(); - foreach(global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.Types.RepeatedFieldsGenerator.Types.Group2 i in group2_) - hash ^= i.GetHashCode(); - foreach(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite i in ext1_) - hash ^= i.GetHashCode(); - foreach(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite i in ext2_) - hash ^= i.GetHashCode(); - return hash; - } - - public override bool Equals(object obj) { - RepeatedFieldsGenerator other = obj as RepeatedFieldsGenerator; - if (other == null) return false; - if(field1_.Count != other.field1_.Count) return false; - for(int ix=0; ix < field1_.Count; ix++) - if(!field1_[ix].Equals(other.field1_[ix])) return false; - if(field2_.Count != other.field2_.Count) return false; - for(int ix=0; ix < field2_.Count; ix++) - if(!field2_[ix].Equals(other.field2_[ix])) return false; - if(field3_.Count != other.field3_.Count) return false; - for(int ix=0; ix < field3_.Count; ix++) - if(!field3_[ix].Equals(other.field3_[ix])) return false; - if(group1_.Count != other.group1_.Count) return false; - for(int ix=0; ix < group1_.Count; ix++) - if(!group1_[ix].Equals(other.group1_[ix])) return false; - if(group2_.Count != other.group2_.Count) return false; - for(int ix=0; ix < group2_.Count; ix++) - if(!group2_[ix].Equals(other.group2_[ix])) return false; - if(ext1_.Count != other.ext1_.Count) return false; - for(int ix=0; ix < ext1_.Count; ix++) - if(!ext1_[ix].Equals(other.ext1_[ix])) return false; - if(ext2_.Count != other.ext2_.Count) return false; - for(int ix=0; ix < ext2_.Count; ix++) - if(!ext2_[ix].Equals(other.ext2_[ix])) return false; - return true; - } - - public override void PrintTo(global::System.IO.TextWriter writer) { - PrintField("field1", field1_, writer); - PrintField("field2", field2_, writer); - PrintField("field3", field3_, writer); - PrintField("Group1", group1_, writer); - PrintField("Group2", group2_, writer); - PrintField("ext1", ext1_, writer); - PrintField("ext2", ext2_, writer); - } - #endregion - - public static RepeatedFieldsGenerator ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static RepeatedFieldsGenerator ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static RepeatedFieldsGenerator ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static RepeatedFieldsGenerator ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static RepeatedFieldsGenerator ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static RepeatedFieldsGenerator ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static RepeatedFieldsGenerator ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static RepeatedFieldsGenerator ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static RepeatedFieldsGenerator ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static RepeatedFieldsGenerator ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private RepeatedFieldsGenerator MakeReadOnly() { - field1_.MakeReadOnly(); - field2_.MakeReadOnly(); - field3_.MakeReadOnly(); - group1_.MakeReadOnly(); - group2_.MakeReadOnly(); - ext1_.MakeReadOnly(); - ext2_.MakeReadOnly(); - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(RepeatedFieldsGenerator prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilderLite { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(RepeatedFieldsGenerator cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private RepeatedFieldsGenerator result; - - private RepeatedFieldsGenerator PrepareBuilder() { - if (resultIsReadOnly) { - RepeatedFieldsGenerator original = result; - result = new RepeatedFieldsGenerator(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override RepeatedFieldsGenerator MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override RepeatedFieldsGenerator DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.Types.RepeatedFieldsGenerator.DefaultInstance; } - } - - public override RepeatedFieldsGenerator BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessageLite other) { - if (other is RepeatedFieldsGenerator) { - return MergeFrom((RepeatedFieldsGenerator) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(RepeatedFieldsGenerator other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.Types.RepeatedFieldsGenerator.DefaultInstance) return this; - PrepareBuilder(); - if (other.field1_.Count != 0) { - result.field1_.Add(other.field1_); - } - if (other.field2_.Count != 0) { - result.field2_.Add(other.field2_); - } - if (other.field3_.Count != 0) { - result.field3_.Add(other.field3_); - } - if (other.group1_.Count != 0) { - result.group1_.Add(other.group1_); - } - if (other.group2_.Count != 0) { - result.group2_.Add(other.group2_); - } - if (other.ext1_.Count != 0) { - result.ext1_.Add(other.ext1_); - } - if (other.ext2_.Count != 0) { - result.ext2_.Add(other.ext2_); - } - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_repeatedFieldsGeneratorFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _repeatedFieldsGeneratorFieldTags[field_ordinal]; - else { - ParseUnknownField(input, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - return this; - } - ParseUnknownField(input, extensionRegistry, tag, field_name); - break; - } - case 10: { - input.ReadMessageArray(tag, field_name, result.field1_, global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.DefaultInstance, extensionRegistry); - break; - } - case 18: { - input.ReadMessageArray(tag, field_name, result.field2_, global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.DefaultInstance, extensionRegistry); - break; - } - case 26: { - input.ReadMessageArray(tag, field_name, result.field3_, global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.DefaultInstance, extensionRegistry); - break; - } - case 83: { - input.ReadGroupArray(tag, field_name, result.group1_, global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.Types.RepeatedFieldsGenerator.Types.Group1.DefaultInstance, extensionRegistry); - break; - } - case 163: { - input.ReadGroupArray(tag, field_name, result.group2_, global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.Types.RepeatedFieldsGenerator.Types.Group2.DefaultInstance, extensionRegistry); - break; - } - case 8002: { - input.ReadMessageArray(tag, field_name, result.ext1_, global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.DefaultInstance, extensionRegistry); - break; - } - case 8010: { - input.ReadMessageArray(tag, field_name, result.ext2_, global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.DefaultInstance, extensionRegistry); - break; - } - } - } - - return this; - } - - - public pbc::IPopsicleList Field1List { - get { return PrepareBuilder().field1_; } - } - public int Field1Count { - get { return result.Field1Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite GetField1(int index) { - return result.GetField1(index); - } - public Builder SetField1(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.field1_[index] = value; - return this; - } - public Builder SetField1(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.field1_[index] = builderForValue.Build(); - return this; - } - public Builder AddField1(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.field1_.Add(value); - return this; - } - public Builder AddField1(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.field1_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeField1(scg::IEnumerable values) { - PrepareBuilder(); - result.field1_.Add(values); - return this; - } - public Builder ClearField1() { - PrepareBuilder(); - result.field1_.Clear(); - return this; - } - - public pbc::IPopsicleList Field2List { - get { return PrepareBuilder().field2_; } - } - public int Field2Count { - get { return result.Field2Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite GetField2(int index) { - return result.GetField2(index); - } - public Builder SetField2(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.field2_[index] = value; - return this; - } - public Builder SetField2(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.field2_[index] = builderForValue.Build(); - return this; - } - public Builder AddField2(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.field2_.Add(value); - return this; - } - public Builder AddField2(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.field2_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeField2(scg::IEnumerable values) { - PrepareBuilder(); - result.field2_.Add(values); - return this; - } - public Builder ClearField2() { - PrepareBuilder(); - result.field2_.Clear(); - return this; - } - - public pbc::IPopsicleList Field3List { - get { return PrepareBuilder().field3_; } - } - public int Field3Count { - get { return result.Field3Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite GetField3(int index) { - return result.GetField3(index); - } - public Builder SetField3(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.field3_[index] = value; - return this; - } - public Builder SetField3(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.field3_[index] = builderForValue.Build(); - return this; - } - public Builder AddField3(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.field3_.Add(value); - return this; - } - public Builder AddField3(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.field3_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeField3(scg::IEnumerable values) { - PrepareBuilder(); - result.field3_.Add(values); - return this; - } - public Builder ClearField3() { - PrepareBuilder(); - result.field3_.Clear(); - return this; - } - - public pbc::IPopsicleList Group1List { - get { return PrepareBuilder().group1_; } - } - public int Group1Count { - get { return result.Group1Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.Types.RepeatedFieldsGenerator.Types.Group1 GetGroup1(int index) { - return result.GetGroup1(index); - } - public Builder SetGroup1(int index, global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.Types.RepeatedFieldsGenerator.Types.Group1 value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.group1_[index] = value; - return this; - } - public Builder SetGroup1(int index, global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.Types.RepeatedFieldsGenerator.Types.Group1.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.group1_[index] = builderForValue.Build(); - return this; - } - public Builder AddGroup1(global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.Types.RepeatedFieldsGenerator.Types.Group1 value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.group1_.Add(value); - return this; - } - public Builder AddGroup1(global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.Types.RepeatedFieldsGenerator.Types.Group1.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.group1_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeGroup1(scg::IEnumerable values) { - PrepareBuilder(); - result.group1_.Add(values); - return this; - } - public Builder ClearGroup1() { - PrepareBuilder(); - result.group1_.Clear(); - return this; - } - - public pbc::IPopsicleList Group2List { - get { return PrepareBuilder().group2_; } - } - public int Group2Count { - get { return result.Group2Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.Types.RepeatedFieldsGenerator.Types.Group2 GetGroup2(int index) { - return result.GetGroup2(index); - } - public Builder SetGroup2(int index, global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.Types.RepeatedFieldsGenerator.Types.Group2 value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.group2_[index] = value; - return this; - } - public Builder SetGroup2(int index, global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.Types.RepeatedFieldsGenerator.Types.Group2.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.group2_[index] = builderForValue.Build(); - return this; - } - public Builder AddGroup2(global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.Types.RepeatedFieldsGenerator.Types.Group2 value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.group2_.Add(value); - return this; - } - public Builder AddGroup2(global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.Types.RepeatedFieldsGenerator.Types.Group2.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.group2_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeGroup2(scg::IEnumerable values) { - PrepareBuilder(); - result.group2_.Add(values); - return this; - } - public Builder ClearGroup2() { - PrepareBuilder(); - result.group2_.Clear(); - return this; - } - - public pbc::IPopsicleList Ext1List { - get { return PrepareBuilder().ext1_; } - } - public int Ext1Count { - get { return result.Ext1Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite GetExt1(int index) { - return result.GetExt1(index); - } - public Builder SetExt1(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.ext1_[index] = value; - return this; - } - public Builder SetExt1(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.ext1_[index] = builderForValue.Build(); - return this; - } - public Builder AddExt1(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.ext1_.Add(value); - return this; - } - public Builder AddExt1(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.ext1_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeExt1(scg::IEnumerable values) { - PrepareBuilder(); - result.ext1_.Add(values); - return this; - } - public Builder ClearExt1() { - PrepareBuilder(); - result.ext1_.Clear(); - return this; - } - - public pbc::IPopsicleList Ext2List { - get { return PrepareBuilder().ext2_; } - } - public int Ext2Count { - get { return result.Ext2Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite GetExt2(int index) { - return result.GetExt2(index); - } - public Builder SetExt2(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.ext2_[index] = value; - return this; - } - public Builder SetExt2(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.ext2_[index] = builderForValue.Build(); - return this; - } - public Builder AddExt2(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.ext2_.Add(value); - return this; - } - public Builder AddExt2(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.ext2_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeExt2(scg::IEnumerable values) { - PrepareBuilder(); - result.ext2_.Add(values); - return this; - } - public Builder ClearExt2() { - PrepareBuilder(); - result.ext2_.Clear(); - return this; - } - } - static RepeatedFieldsGenerator() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.UnittestLite.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class OptionalGroup : pb::GeneratedMessageLite { - private OptionalGroup() { } - private static readonly OptionalGroup defaultInstance = new OptionalGroup().MakeReadOnly(); - private static readonly string[] _optionalGroupFieldNames = new string[] { "optional_group_all_types" }; - private static readonly uint[] _optionalGroupFieldTags = new uint[] { 90 }; - public static OptionalGroup DefaultInstance { - get { return defaultInstance; } - } - - public override OptionalGroup DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override OptionalGroup ThisMessage { - get { return this; } - } - - public const int OptionalGroupAllTypesFieldNumber = 11; - private bool hasOptionalGroupAllTypes; - private global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite optionalGroupAllTypes_; - public bool HasOptionalGroupAllTypes { - get { return hasOptionalGroupAllTypes; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite OptionalGroupAllTypes { - get { return optionalGroupAllTypes_ ?? global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.DefaultInstance; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _optionalGroupFieldNames; - if (hasOptionalGroupAllTypes) { - output.WriteMessage(11, field_names[0], OptionalGroupAllTypes); - } - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasOptionalGroupAllTypes) { - size += pb::CodedOutputStream.ComputeMessageSize(11, OptionalGroupAllTypes); - } - memoizedSerializedSize = size; - return size; - } - #region Lite runtime methods - public override int GetHashCode() { - int hash = GetType().GetHashCode(); - if (hasOptionalGroupAllTypes) hash ^= optionalGroupAllTypes_.GetHashCode(); - return hash; - } - - public override bool Equals(object obj) { - OptionalGroup other = obj as OptionalGroup; - if (other == null) return false; - if (hasOptionalGroupAllTypes != other.hasOptionalGroupAllTypes || (hasOptionalGroupAllTypes && !optionalGroupAllTypes_.Equals(other.optionalGroupAllTypes_))) return false; - return true; - } - - public override void PrintTo(global::System.IO.TextWriter writer) { - PrintField("optional_group_all_types", hasOptionalGroupAllTypes, optionalGroupAllTypes_, writer); - } - #endregion - - public static OptionalGroup ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static OptionalGroup ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static OptionalGroup ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static OptionalGroup ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static OptionalGroup ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static OptionalGroup ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static OptionalGroup ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static OptionalGroup ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static OptionalGroup ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static OptionalGroup ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private OptionalGroup MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(OptionalGroup prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilderLite { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(OptionalGroup cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private OptionalGroup result; - - private OptionalGroup PrepareBuilder() { - if (resultIsReadOnly) { - OptionalGroup original = result; - result = new OptionalGroup(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override OptionalGroup MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override OptionalGroup DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.Types.OptionalGroup.DefaultInstance; } - } - - public override OptionalGroup BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessageLite other) { - if (other is OptionalGroup) { - return MergeFrom((OptionalGroup) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(OptionalGroup other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.Types.OptionalGroup.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasOptionalGroupAllTypes) { - MergeOptionalGroupAllTypes(other.OptionalGroupAllTypes); - } - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_optionalGroupFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _optionalGroupFieldTags[field_ordinal]; - else { - ParseUnknownField(input, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - return this; - } - ParseUnknownField(input, extensionRegistry, tag, field_name); - break; - } - case 90: { - global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.CreateBuilder(); - if (result.hasOptionalGroupAllTypes) { - subBuilder.MergeFrom(OptionalGroupAllTypes); - } - input.ReadMessage(subBuilder, extensionRegistry); - OptionalGroupAllTypes = subBuilder.BuildPartial(); - break; - } - } - } - - return this; - } - - - public bool HasOptionalGroupAllTypes { - get { return result.hasOptionalGroupAllTypes; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite OptionalGroupAllTypes { - get { return result.OptionalGroupAllTypes; } - set { SetOptionalGroupAllTypes(value); } - } - public Builder SetOptionalGroupAllTypes(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOptionalGroupAllTypes = true; - result.optionalGroupAllTypes_ = value; - return this; - } - public Builder SetOptionalGroupAllTypes(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasOptionalGroupAllTypes = true; - result.optionalGroupAllTypes_ = builderForValue.Build(); - return this; - } - public Builder MergeOptionalGroupAllTypes(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasOptionalGroupAllTypes && - result.optionalGroupAllTypes_ != global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.DefaultInstance) { - result.optionalGroupAllTypes_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.CreateBuilder(result.optionalGroupAllTypes_).MergeFrom(value).BuildPartial(); - } else { - result.optionalGroupAllTypes_ = value; - } - result.hasOptionalGroupAllTypes = true; - return this; - } - public Builder ClearOptionalGroupAllTypes() { - PrepareBuilder(); - result.hasOptionalGroupAllTypes = false; - result.optionalGroupAllTypes_ = null; - return this; - } - } - static OptionalGroup() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.UnittestLite.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class RepeatedGroup : pb::GeneratedMessageLite { - private RepeatedGroup() { } - private static readonly RepeatedGroup defaultInstance = new RepeatedGroup().MakeReadOnly(); - private static readonly string[] _repeatedGroupFieldNames = new string[] { "repeated_group_all_types" }; - private static readonly uint[] _repeatedGroupFieldTags = new uint[] { 170 }; - public static RepeatedGroup DefaultInstance { - get { return defaultInstance; } - } - - public override RepeatedGroup DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override RepeatedGroup ThisMessage { - get { return this; } - } - - public const int RepeatedGroupAllTypesFieldNumber = 21; - private bool hasRepeatedGroupAllTypes; - private global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite repeatedGroupAllTypes_; - public bool HasRepeatedGroupAllTypes { - get { return hasRepeatedGroupAllTypes; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite RepeatedGroupAllTypes { - get { return repeatedGroupAllTypes_ ?? global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.DefaultInstance; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _repeatedGroupFieldNames; - if (hasRepeatedGroupAllTypes) { - output.WriteMessage(21, field_names[0], RepeatedGroupAllTypes); - } - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasRepeatedGroupAllTypes) { - size += pb::CodedOutputStream.ComputeMessageSize(21, RepeatedGroupAllTypes); - } - memoizedSerializedSize = size; - return size; - } - #region Lite runtime methods - public override int GetHashCode() { - int hash = GetType().GetHashCode(); - if (hasRepeatedGroupAllTypes) hash ^= repeatedGroupAllTypes_.GetHashCode(); - return hash; - } - - public override bool Equals(object obj) { - RepeatedGroup other = obj as RepeatedGroup; - if (other == null) return false; - if (hasRepeatedGroupAllTypes != other.hasRepeatedGroupAllTypes || (hasRepeatedGroupAllTypes && !repeatedGroupAllTypes_.Equals(other.repeatedGroupAllTypes_))) return false; - return true; - } - - public override void PrintTo(global::System.IO.TextWriter writer) { - PrintField("repeated_group_all_types", hasRepeatedGroupAllTypes, repeatedGroupAllTypes_, writer); - } - #endregion - - public static RepeatedGroup ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static RepeatedGroup ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static RepeatedGroup ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static RepeatedGroup ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static RepeatedGroup ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static RepeatedGroup ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static RepeatedGroup ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static RepeatedGroup ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static RepeatedGroup ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static RepeatedGroup ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private RepeatedGroup MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(RepeatedGroup prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilderLite { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(RepeatedGroup cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private RepeatedGroup result; - - private RepeatedGroup PrepareBuilder() { - if (resultIsReadOnly) { - RepeatedGroup original = result; - result = new RepeatedGroup(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override RepeatedGroup MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override RepeatedGroup DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.Types.RepeatedGroup.DefaultInstance; } - } - - public override RepeatedGroup BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessageLite other) { - if (other is RepeatedGroup) { - return MergeFrom((RepeatedGroup) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(RepeatedGroup other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.Types.RepeatedGroup.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasRepeatedGroupAllTypes) { - MergeRepeatedGroupAllTypes(other.RepeatedGroupAllTypes); - } - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_repeatedGroupFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _repeatedGroupFieldTags[field_ordinal]; - else { - ParseUnknownField(input, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - return this; - } - ParseUnknownField(input, extensionRegistry, tag, field_name); - break; - } - case 170: { - global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.CreateBuilder(); - if (result.hasRepeatedGroupAllTypes) { - subBuilder.MergeFrom(RepeatedGroupAllTypes); - } - input.ReadMessage(subBuilder, extensionRegistry); - RepeatedGroupAllTypes = subBuilder.BuildPartial(); - break; - } - } - } - - return this; - } - - - public bool HasRepeatedGroupAllTypes { - get { return result.hasRepeatedGroupAllTypes; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite RepeatedGroupAllTypes { - get { return result.RepeatedGroupAllTypes; } - set { SetRepeatedGroupAllTypes(value); } - } - public Builder SetRepeatedGroupAllTypes(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasRepeatedGroupAllTypes = true; - result.repeatedGroupAllTypes_ = value; - return this; - } - public Builder SetRepeatedGroupAllTypes(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasRepeatedGroupAllTypes = true; - result.repeatedGroupAllTypes_ = builderForValue.Build(); - return this; - } - public Builder MergeRepeatedGroupAllTypes(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasRepeatedGroupAllTypes && - result.repeatedGroupAllTypes_ != global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.DefaultInstance) { - result.repeatedGroupAllTypes_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.CreateBuilder(result.repeatedGroupAllTypes_).MergeFrom(value).BuildPartial(); - } else { - result.repeatedGroupAllTypes_ = value; - } - result.hasRepeatedGroupAllTypes = true; - return this; - } - public Builder ClearRepeatedGroupAllTypes() { - PrepareBuilder(); - result.hasRepeatedGroupAllTypes = false; - result.repeatedGroupAllTypes_ = null; - return this; - } - } - static RepeatedGroup() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.UnittestLite.Descriptor, null); - } - } - - } - #endregion - - public const int RequiredAllTypesFieldNumber = 1; - private bool hasRequiredAllTypes; - private global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite requiredAllTypes_; - public bool HasRequiredAllTypes { - get { return hasRequiredAllTypes; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite RequiredAllTypes { - get { return requiredAllTypes_ ?? global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.DefaultInstance; } - } - - public const int OptionalAllTypesFieldNumber = 2; - private bool hasOptionalAllTypes; - private global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite optionalAllTypes_; - public bool HasOptionalAllTypes { - get { return hasOptionalAllTypes; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite OptionalAllTypes { - get { return optionalAllTypes_ ?? global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.DefaultInstance; } - } - - public const int RepeatedAllTypesFieldNumber = 3; - private pbc::PopsicleList repeatedAllTypes_ = new pbc::PopsicleList(); - public scg::IList RepeatedAllTypesList { - get { return repeatedAllTypes_; } - } - public int RepeatedAllTypesCount { - get { return repeatedAllTypes_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite GetRepeatedAllTypes(int index) { - return repeatedAllTypes_[index]; - } - - public const int OptionalGroupFieldNumber = 10; - private bool hasOptionalGroup; - private global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.Types.OptionalGroup optionalGroup_; - public bool HasOptionalGroup { - get { return hasOptionalGroup; } - } - public global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.Types.OptionalGroup OptionalGroup { - get { return optionalGroup_ ?? global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.Types.OptionalGroup.DefaultInstance; } - } - - public const int RepeatedGroupFieldNumber = 20; - private pbc::PopsicleList repeatedGroup_ = new pbc::PopsicleList(); - public scg::IList RepeatedGroupList { - get { return repeatedGroup_; } - } - public int RepeatedGroupCount { - get { return repeatedGroup_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.Types.RepeatedGroup GetRepeatedGroup(int index) { - return repeatedGroup_[index]; - } - - public override bool IsInitialized { - get { - if (!hasRequiredAllTypes) return false; - if (!ExtensionsAreInitialized) return false; - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testParsingMergeLiteFieldNames; - pb::ExtendableMessageLite.ExtensionWriter extensionWriter = CreateExtensionWriter(this); - if (hasRequiredAllTypes) { - output.WriteMessage(1, field_names[4], RequiredAllTypes); - } - if (hasOptionalAllTypes) { - output.WriteMessage(2, field_names[0], OptionalAllTypes); - } - if (repeatedAllTypes_.Count > 0) { - output.WriteMessageArray(3, field_names[2], repeatedAllTypes_); - } - if (hasOptionalGroup) { - output.WriteGroup(10, field_names[1], OptionalGroup); - } - if (repeatedGroup_.Count > 0) { - output.WriteGroupArray(20, field_names[3], repeatedGroup_); - } - extensionWriter.WriteUntil(536870912, output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasRequiredAllTypes) { - size += pb::CodedOutputStream.ComputeMessageSize(1, RequiredAllTypes); - } - if (hasOptionalAllTypes) { - size += pb::CodedOutputStream.ComputeMessageSize(2, OptionalAllTypes); - } - foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite element in RepeatedAllTypesList) { - size += pb::CodedOutputStream.ComputeMessageSize(3, element); - } - if (hasOptionalGroup) { - size += pb::CodedOutputStream.ComputeGroupSize(10, OptionalGroup); - } - foreach (global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.Types.RepeatedGroup element in RepeatedGroupList) { - size += pb::CodedOutputStream.ComputeGroupSize(20, element); - } - size += ExtensionsSerializedSize; - memoizedSerializedSize = size; - return size; - } - #region Lite runtime methods - public override int GetHashCode() { - int hash = GetType().GetHashCode(); - if (hasRequiredAllTypes) hash ^= requiredAllTypes_.GetHashCode(); - if (hasOptionalAllTypes) hash ^= optionalAllTypes_.GetHashCode(); - foreach(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite i in repeatedAllTypes_) - hash ^= i.GetHashCode(); - if (hasOptionalGroup) hash ^= optionalGroup_.GetHashCode(); - foreach(global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.Types.RepeatedGroup i in repeatedGroup_) - hash ^= i.GetHashCode(); - hash ^= base.GetHashCode(); - return hash; - } - - public override bool Equals(object obj) { - TestParsingMergeLite other = obj as TestParsingMergeLite; - if (other == null) return false; - if (hasRequiredAllTypes != other.hasRequiredAllTypes || (hasRequiredAllTypes && !requiredAllTypes_.Equals(other.requiredAllTypes_))) return false; - if (hasOptionalAllTypes != other.hasOptionalAllTypes || (hasOptionalAllTypes && !optionalAllTypes_.Equals(other.optionalAllTypes_))) return false; - if(repeatedAllTypes_.Count != other.repeatedAllTypes_.Count) return false; - for(int ix=0; ix < repeatedAllTypes_.Count; ix++) - if(!repeatedAllTypes_[ix].Equals(other.repeatedAllTypes_[ix])) return false; - if (hasOptionalGroup != other.hasOptionalGroup || (hasOptionalGroup && !optionalGroup_.Equals(other.optionalGroup_))) return false; - if(repeatedGroup_.Count != other.repeatedGroup_.Count) return false; - for(int ix=0; ix < repeatedGroup_.Count; ix++) - if(!repeatedGroup_[ix].Equals(other.repeatedGroup_[ix])) return false; - if (!base.Equals(other)) return false; - return true; - } - - public override void PrintTo(global::System.IO.TextWriter writer) { - PrintField("required_all_types", hasRequiredAllTypes, requiredAllTypes_, writer); - PrintField("optional_all_types", hasOptionalAllTypes, optionalAllTypes_, writer); - PrintField("repeated_all_types", repeatedAllTypes_, writer); - PrintField("OptionalGroup", hasOptionalGroup, optionalGroup_, writer); - PrintField("RepeatedGroup", repeatedGroup_, writer); - base.PrintTo(writer); - } - #endregion - - public static TestParsingMergeLite ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestParsingMergeLite ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestParsingMergeLite ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestParsingMergeLite ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestParsingMergeLite ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestParsingMergeLite ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestParsingMergeLite ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestParsingMergeLite ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestParsingMergeLite ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestParsingMergeLite ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestParsingMergeLite MakeReadOnly() { - repeatedAllTypes_.MakeReadOnly(); - repeatedGroup_.MakeReadOnly(); - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestParsingMergeLite prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::ExtendableBuilderLite { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestParsingMergeLite cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestParsingMergeLite result; - - private TestParsingMergeLite PrepareBuilder() { - if (resultIsReadOnly) { - TestParsingMergeLite original = result; - result = new TestParsingMergeLite(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestParsingMergeLite MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override TestParsingMergeLite DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.DefaultInstance; } - } - - public override TestParsingMergeLite BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessageLite other) { - if (other is TestParsingMergeLite) { - return MergeFrom((TestParsingMergeLite) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestParsingMergeLite other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasRequiredAllTypes) { - MergeRequiredAllTypes(other.RequiredAllTypes); - } - if (other.HasOptionalAllTypes) { - MergeOptionalAllTypes(other.OptionalAllTypes); - } - if (other.repeatedAllTypes_.Count != 0) { - result.repeatedAllTypes_.Add(other.repeatedAllTypes_); - } - if (other.HasOptionalGroup) { - MergeOptionalGroup(other.OptionalGroup); - } - if (other.repeatedGroup_.Count != 0) { - result.repeatedGroup_.Add(other.repeatedGroup_); - } - this.MergeExtensionFields(other); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testParsingMergeLiteFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testParsingMergeLiteFieldTags[field_ordinal]; - else { - ParseUnknownField(input, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - return this; - } - ParseUnknownField(input, extensionRegistry, tag, field_name); - break; - } - case 10: { - global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.CreateBuilder(); - if (result.hasRequiredAllTypes) { - subBuilder.MergeFrom(RequiredAllTypes); - } - input.ReadMessage(subBuilder, extensionRegistry); - RequiredAllTypes = subBuilder.BuildPartial(); - break; - } - case 18: { - global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.CreateBuilder(); - if (result.hasOptionalAllTypes) { - subBuilder.MergeFrom(OptionalAllTypes); - } - input.ReadMessage(subBuilder, extensionRegistry); - OptionalAllTypes = subBuilder.BuildPartial(); - break; - } - case 26: { - input.ReadMessageArray(tag, field_name, result.repeatedAllTypes_, global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.DefaultInstance, extensionRegistry); - break; - } - case 83: { - global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.Types.OptionalGroup.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.Types.OptionalGroup.CreateBuilder(); - if (result.hasOptionalGroup) { - subBuilder.MergeFrom(OptionalGroup); - } - input.ReadGroup(10, subBuilder, extensionRegistry); - OptionalGroup = subBuilder.BuildPartial(); - break; - } - case 163: { - input.ReadGroupArray(tag, field_name, result.repeatedGroup_, global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.Types.RepeatedGroup.DefaultInstance, extensionRegistry); - break; - } - } - } - - return this; - } - - - public bool HasRequiredAllTypes { - get { return result.hasRequiredAllTypes; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite RequiredAllTypes { - get { return result.RequiredAllTypes; } - set { SetRequiredAllTypes(value); } - } - public Builder SetRequiredAllTypes(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasRequiredAllTypes = true; - result.requiredAllTypes_ = value; - return this; - } - public Builder SetRequiredAllTypes(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasRequiredAllTypes = true; - result.requiredAllTypes_ = builderForValue.Build(); - return this; - } - public Builder MergeRequiredAllTypes(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasRequiredAllTypes && - result.requiredAllTypes_ != global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.DefaultInstance) { - result.requiredAllTypes_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.CreateBuilder(result.requiredAllTypes_).MergeFrom(value).BuildPartial(); - } else { - result.requiredAllTypes_ = value; - } - result.hasRequiredAllTypes = true; - return this; - } - public Builder ClearRequiredAllTypes() { - PrepareBuilder(); - result.hasRequiredAllTypes = false; - result.requiredAllTypes_ = null; - return this; - } - - public bool HasOptionalAllTypes { - get { return result.hasOptionalAllTypes; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite OptionalAllTypes { - get { return result.OptionalAllTypes; } - set { SetOptionalAllTypes(value); } - } - public Builder SetOptionalAllTypes(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOptionalAllTypes = true; - result.optionalAllTypes_ = value; - return this; - } - public Builder SetOptionalAllTypes(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasOptionalAllTypes = true; - result.optionalAllTypes_ = builderForValue.Build(); - return this; - } - public Builder MergeOptionalAllTypes(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasOptionalAllTypes && - result.optionalAllTypes_ != global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.DefaultInstance) { - result.optionalAllTypes_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.CreateBuilder(result.optionalAllTypes_).MergeFrom(value).BuildPartial(); - } else { - result.optionalAllTypes_ = value; - } - result.hasOptionalAllTypes = true; - return this; - } - public Builder ClearOptionalAllTypes() { - PrepareBuilder(); - result.hasOptionalAllTypes = false; - result.optionalAllTypes_ = null; - return this; - } - - public pbc::IPopsicleList RepeatedAllTypesList { - get { return PrepareBuilder().repeatedAllTypes_; } - } - public int RepeatedAllTypesCount { - get { return result.RepeatedAllTypesCount; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite GetRepeatedAllTypes(int index) { - return result.GetRepeatedAllTypes(index); - } - public Builder SetRepeatedAllTypes(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedAllTypes_[index] = value; - return this; - } - public Builder SetRepeatedAllTypes(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.repeatedAllTypes_[index] = builderForValue.Build(); - return this; - } - public Builder AddRepeatedAllTypes(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedAllTypes_.Add(value); - return this; - } - public Builder AddRepeatedAllTypes(global::Google.ProtocolBuffers.TestProtos.TestAllTypesLite.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.repeatedAllTypes_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeRepeatedAllTypes(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedAllTypes_.Add(values); - return this; - } - public Builder ClearRepeatedAllTypes() { - PrepareBuilder(); - result.repeatedAllTypes_.Clear(); - return this; - } - - public bool HasOptionalGroup { - get { return result.hasOptionalGroup; } - } - public global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.Types.OptionalGroup OptionalGroup { - get { return result.OptionalGroup; } - set { SetOptionalGroup(value); } - } - public Builder SetOptionalGroup(global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.Types.OptionalGroup value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOptionalGroup = true; - result.optionalGroup_ = value; - return this; - } - public Builder SetOptionalGroup(global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.Types.OptionalGroup.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasOptionalGroup = true; - result.optionalGroup_ = builderForValue.Build(); - return this; - } - public Builder MergeOptionalGroup(global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.Types.OptionalGroup value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasOptionalGroup && - result.optionalGroup_ != global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.Types.OptionalGroup.DefaultInstance) { - result.optionalGroup_ = global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.Types.OptionalGroup.CreateBuilder(result.optionalGroup_).MergeFrom(value).BuildPartial(); - } else { - result.optionalGroup_ = value; - } - result.hasOptionalGroup = true; - return this; - } - public Builder ClearOptionalGroup() { - PrepareBuilder(); - result.hasOptionalGroup = false; - result.optionalGroup_ = null; - return this; - } - - public pbc::IPopsicleList RepeatedGroupList { - get { return PrepareBuilder().repeatedGroup_; } - } - public int RepeatedGroupCount { - get { return result.RepeatedGroupCount; } - } - public global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.Types.RepeatedGroup GetRepeatedGroup(int index) { - return result.GetRepeatedGroup(index); - } - public Builder SetRepeatedGroup(int index, global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.Types.RepeatedGroup value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedGroup_[index] = value; - return this; - } - public Builder SetRepeatedGroup(int index, global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.Types.RepeatedGroup.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.repeatedGroup_[index] = builderForValue.Build(); - return this; - } - public Builder AddRepeatedGroup(global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.Types.RepeatedGroup value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedGroup_.Add(value); - return this; - } - public Builder AddRepeatedGroup(global::Google.ProtocolBuffers.TestProtos.TestParsingMergeLite.Types.RepeatedGroup.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.repeatedGroup_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeRepeatedGroup(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedGroup_.Add(values); - return this; - } - public Builder ClearRepeatedGroup() { - PrepareBuilder(); - result.repeatedGroup_.Clear(); - return this; - } - } - static TestParsingMergeLite() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.UnittestLite.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestEmptyMessageLite : pb::GeneratedMessageLite { - private TestEmptyMessageLite() { } - private static readonly TestEmptyMessageLite defaultInstance = new TestEmptyMessageLite().MakeReadOnly(); - private static readonly string[] _testEmptyMessageLiteFieldNames = new string[] { }; - private static readonly uint[] _testEmptyMessageLiteFieldTags = new uint[] { }; - public static TestEmptyMessageLite DefaultInstance { - get { return defaultInstance; } - } - - public override TestEmptyMessageLite DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestEmptyMessageLite ThisMessage { - get { return this; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testEmptyMessageLiteFieldNames; - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - memoizedSerializedSize = size; - return size; - } - #region Lite runtime methods - public override int GetHashCode() { - int hash = GetType().GetHashCode(); - return hash; - } - - public override bool Equals(object obj) { - TestEmptyMessageLite other = obj as TestEmptyMessageLite; - if (other == null) return false; - return true; - } - - public override void PrintTo(global::System.IO.TextWriter writer) { - } - #endregion - - public static TestEmptyMessageLite ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestEmptyMessageLite ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestEmptyMessageLite ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestEmptyMessageLite ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestEmptyMessageLite ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestEmptyMessageLite ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestEmptyMessageLite ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestEmptyMessageLite ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestEmptyMessageLite ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestEmptyMessageLite ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestEmptyMessageLite MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestEmptyMessageLite prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilderLite { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestEmptyMessageLite cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestEmptyMessageLite result; - - private TestEmptyMessageLite PrepareBuilder() { - if (resultIsReadOnly) { - TestEmptyMessageLite original = result; - result = new TestEmptyMessageLite(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestEmptyMessageLite MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override TestEmptyMessageLite DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestEmptyMessageLite.DefaultInstance; } - } - - public override TestEmptyMessageLite BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessageLite other) { - if (other is TestEmptyMessageLite) { - return MergeFrom((TestEmptyMessageLite) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestEmptyMessageLite other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestEmptyMessageLite.DefaultInstance) return this; - PrepareBuilder(); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testEmptyMessageLiteFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testEmptyMessageLiteFieldTags[field_ordinal]; - else { - ParseUnknownField(input, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - return this; - } - ParseUnknownField(input, extensionRegistry, tag, field_name); - break; - } - } - } - - return this; - } - - } - static TestEmptyMessageLite() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.UnittestLite.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestEmptyMessageWithExtensionsLite : pb::ExtendableMessageLite { - private TestEmptyMessageWithExtensionsLite() { } - private static readonly TestEmptyMessageWithExtensionsLite defaultInstance = new TestEmptyMessageWithExtensionsLite().MakeReadOnly(); - private static readonly string[] _testEmptyMessageWithExtensionsLiteFieldNames = new string[] { }; - private static readonly uint[] _testEmptyMessageWithExtensionsLiteFieldTags = new uint[] { }; - public static TestEmptyMessageWithExtensionsLite DefaultInstance { - get { return defaultInstance; } - } - - public override TestEmptyMessageWithExtensionsLite DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestEmptyMessageWithExtensionsLite ThisMessage { - get { return this; } - } - - public override bool IsInitialized { - get { - if (!ExtensionsAreInitialized) return false; - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testEmptyMessageWithExtensionsLiteFieldNames; - pb::ExtendableMessageLite.ExtensionWriter extensionWriter = CreateExtensionWriter(this); - extensionWriter.WriteUntil(536870912, output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - size += ExtensionsSerializedSize; - memoizedSerializedSize = size; - return size; - } - #region Lite runtime methods - public override int GetHashCode() { - int hash = GetType().GetHashCode(); - hash ^= base.GetHashCode(); - return hash; - } - - public override bool Equals(object obj) { - TestEmptyMessageWithExtensionsLite other = obj as TestEmptyMessageWithExtensionsLite; - if (other == null) return false; - if (!base.Equals(other)) return false; - return true; - } - - public override void PrintTo(global::System.IO.TextWriter writer) { - base.PrintTo(writer); - } - #endregion - - public static TestEmptyMessageWithExtensionsLite ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestEmptyMessageWithExtensionsLite ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestEmptyMessageWithExtensionsLite ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestEmptyMessageWithExtensionsLite ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestEmptyMessageWithExtensionsLite ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestEmptyMessageWithExtensionsLite ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestEmptyMessageWithExtensionsLite ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestEmptyMessageWithExtensionsLite ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestEmptyMessageWithExtensionsLite ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestEmptyMessageWithExtensionsLite ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestEmptyMessageWithExtensionsLite MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestEmptyMessageWithExtensionsLite prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::ExtendableBuilderLite { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestEmptyMessageWithExtensionsLite cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestEmptyMessageWithExtensionsLite result; - - private TestEmptyMessageWithExtensionsLite PrepareBuilder() { - if (resultIsReadOnly) { - TestEmptyMessageWithExtensionsLite original = result; - result = new TestEmptyMessageWithExtensionsLite(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestEmptyMessageWithExtensionsLite MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override TestEmptyMessageWithExtensionsLite DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestEmptyMessageWithExtensionsLite.DefaultInstance; } - } - - public override TestEmptyMessageWithExtensionsLite BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessageLite other) { - if (other is TestEmptyMessageWithExtensionsLite) { - return MergeFrom((TestEmptyMessageWithExtensionsLite) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestEmptyMessageWithExtensionsLite other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestEmptyMessageWithExtensionsLite.DefaultInstance) return this; - PrepareBuilder(); - this.MergeExtensionFields(other); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testEmptyMessageWithExtensionsLiteFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testEmptyMessageWithExtensionsLiteFieldTags[field_ordinal]; - else { - ParseUnknownField(input, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - return this; - } - ParseUnknownField(input, extensionRegistry, tag, field_name); - break; - } - } - } - - return this; - } - - } - static TestEmptyMessageWithExtensionsLite() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.UnittestLite.Descriptor, null); - } - } - - #endregion - -} - -#endregion Designer generated code diff --git a/csharp/src/ProtocolBuffersLite.Test/TestProtos/UnittestLiteImportsNonlite.cs b/csharp/src/ProtocolBuffersLite.Test/TestProtos/UnittestLiteImportsNonlite.cs deleted file mode 100644 index f39ae644..00000000 --- a/csharp/src/ProtocolBuffersLite.Test/TestProtos/UnittestLiteImportsNonlite.cs +++ /dev/null @@ -1,325 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/protobuf/unittest_lite_imports_nonlite.proto -#pragma warning disable 1591, 0612, 3021 -#region Designer generated code - -using pb = global::Google.ProtocolBuffers; -using pbc = global::Google.ProtocolBuffers.Collections; -using pbd = global::Google.ProtocolBuffers.Descriptors; -using scg = global::System.Collections.Generic; -namespace Google.ProtocolBuffers.TestProtos { - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class UnittestLiteImportsNonlite { - - #region Extension registration - public static void RegisterAllExtensions(pb::ExtensionRegistry registry) { - } - #endregion - #region Static variables - #endregion - #region Extensions - internal static readonly object Descriptor; - static UnittestLiteImportsNonlite() { - Descriptor = null; - } - #endregion - - } - #region Messages - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestLiteImportsNonlite : pb::GeneratedMessageLite { - private TestLiteImportsNonlite() { } - private static readonly TestLiteImportsNonlite defaultInstance = new TestLiteImportsNonlite().MakeReadOnly(); - private static readonly string[] _testLiteImportsNonliteFieldNames = new string[] { "message" }; - private static readonly uint[] _testLiteImportsNonliteFieldTags = new uint[] { 10 }; - public static TestLiteImportsNonlite DefaultInstance { - get { return defaultInstance; } - } - - public override TestLiteImportsNonlite DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestLiteImportsNonlite ThisMessage { - get { return this; } - } - - public const int MessageFieldNumber = 1; - private bool hasMessage; - private global::Google.ProtocolBuffers.TestProtos.TestAllTypes message_; - public bool HasMessage { - get { return hasMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes Message { - get { return message_ ?? global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testLiteImportsNonliteFieldNames; - if (hasMessage) { - output.WriteMessage(1, field_names[0], Message); - } - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(1, Message); - } - memoizedSerializedSize = size; - return size; - } - #region Lite runtime methods - public override int GetHashCode() { - int hash = GetType().GetHashCode(); - if (hasMessage) hash ^= message_.GetHashCode(); - return hash; - } - - public override bool Equals(object obj) { - TestLiteImportsNonlite other = obj as TestLiteImportsNonlite; - if (other == null) return false; - if (hasMessage != other.hasMessage || (hasMessage && !message_.Equals(other.message_))) return false; - return true; - } - - public override void PrintTo(global::System.IO.TextWriter writer) { - PrintField("message", hasMessage, message_, writer); - } - #endregion - - public static TestLiteImportsNonlite ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestLiteImportsNonlite ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestLiteImportsNonlite ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestLiteImportsNonlite ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestLiteImportsNonlite ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestLiteImportsNonlite ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestLiteImportsNonlite ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestLiteImportsNonlite ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestLiteImportsNonlite ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestLiteImportsNonlite ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestLiteImportsNonlite MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestLiteImportsNonlite prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilderLite { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestLiteImportsNonlite cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestLiteImportsNonlite result; - - private TestLiteImportsNonlite PrepareBuilder() { - if (resultIsReadOnly) { - TestLiteImportsNonlite original = result; - result = new TestLiteImportsNonlite(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestLiteImportsNonlite MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override TestLiteImportsNonlite DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestLiteImportsNonlite.DefaultInstance; } - } - - public override TestLiteImportsNonlite BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessageLite other) { - if (other is TestLiteImportsNonlite) { - return MergeFrom((TestLiteImportsNonlite) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestLiteImportsNonlite other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestLiteImportsNonlite.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasMessage) { - MergeMessage(other.Message); - } - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testLiteImportsNonliteFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testLiteImportsNonliteFieldTags[field_ordinal]; - else { - ParseUnknownField(input, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - return this; - } - ParseUnknownField(input, extensionRegistry, tag, field_name); - break; - } - case 10: { - global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.CreateBuilder(); - if (result.hasMessage) { - subBuilder.MergeFrom(Message); - } - input.ReadMessage(subBuilder, extensionRegistry); - Message = subBuilder.BuildPartial(); - break; - } - } - } - - return this; - } - - - public bool HasMessage { - get { return result.hasMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes Message { - get { return result.Message; } - set { SetMessage(value); } - } - public Builder SetMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasMessage = true; - result.message_ = value; - return this; - } - public Builder SetMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasMessage = true; - result.message_ = builderForValue.Build(); - return this; - } - public Builder MergeMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasMessage && - result.message_ != global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance) { - result.message_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.CreateBuilder(result.message_).MergeFrom(value).BuildPartial(); - } else { - result.message_ = value; - } - result.hasMessage = true; - return this; - } - public Builder ClearMessage() { - PrepareBuilder(); - result.hasMessage = false; - result.message_ = null; - return this; - } - } - static TestLiteImportsNonlite() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.UnittestLiteImportsNonlite.Descriptor, null); - } - } - - #endregion - -} - -#endregion Designer generated code diff --git a/csharp/src/ProtocolBuffersLite.Test/packages.config b/csharp/src/ProtocolBuffersLite.Test/packages.config deleted file mode 100644 index c7653992..00000000 --- a/csharp/src/ProtocolBuffersLite.Test/packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file -- cgit v1.2.3 From a0f956932df52ead0223a68243b5862c7b037cf1 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Wed, 17 Jun 2015 15:34:29 +0100 Subject: Use our "local" copy of Encoding.UTF8 in CodedInputStream too. --- csharp/src/ProtocolBuffers/CodedInputStream.cs | 4 ++-- csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs | 2 +- csharp/src/ProtocolBuffers/CodedOutputStream.cs | 9 +++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/csharp/src/ProtocolBuffers/CodedInputStream.cs b/csharp/src/ProtocolBuffers/CodedInputStream.cs index 447adbb1..56283318 100644 --- a/csharp/src/ProtocolBuffers/CodedInputStream.cs +++ b/csharp/src/ProtocolBuffers/CodedInputStream.cs @@ -339,12 +339,12 @@ namespace Google.Protobuf { // Fast path: We already have the bytes in a contiguous buffer, so // just copy directly from it. - String result = Encoding.UTF8.GetString(buffer, bufferPos, size); + String result = CodedOutputStream.Utf8Encoding.GetString(buffer, bufferPos, size); bufferPos += size; return result; } // Slow path: Build a byte array first then copy it. - return Encoding.UTF8.GetString(ReadRawBytes(size), 0, size); + return CodedOutputStream.Utf8Encoding.GetString(ReadRawBytes(size), 0, size); } /// diff --git a/csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs b/csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs index e3d2b068..ef1f4c0c 100644 --- a/csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs +++ b/csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs @@ -135,7 +135,7 @@ namespace Google.Protobuf /// public static int ComputeStringSize(String value) { - int byteArraySize = UTF8.GetByteCount(value); + int byteArraySize = Utf8Encoding.GetByteCount(value); return ComputeRawVarint32Size((uint) byteArraySize) + byteArraySize; } diff --git a/csharp/src/ProtocolBuffers/CodedOutputStream.cs b/csharp/src/ProtocolBuffers/CodedOutputStream.cs index 6c135e86..1e6e7e55 100644 --- a/csharp/src/ProtocolBuffers/CodedOutputStream.cs +++ b/csharp/src/ProtocolBuffers/CodedOutputStream.cs @@ -59,7 +59,8 @@ namespace Google.Protobuf /// public sealed partial class CodedOutputStream { - private static readonly Encoding UTF8 = Encoding.UTF8; + // "Local" copy of Encoding.UTF8, for efficiency. (Yes, it makes a difference.) + internal static readonly Encoding Utf8Encoding = Encoding.UTF8; /// /// The buffer size used by CreateInstance(Stream). @@ -240,7 +241,7 @@ namespace Google.Protobuf { // Optimise the case where we have enough space to write // the string directly to the buffer, which should be common. - int length = UTF8.GetByteCount(value); + int length = Utf8Encoding.GetByteCount(value); WriteRawVarint32((uint)length); if (limit - position >= length) { @@ -253,13 +254,13 @@ namespace Google.Protobuf } else { - UTF8.GetBytes(value, 0, value.Length, buffer, position); + Utf8Encoding.GetBytes(value, 0, value.Length, buffer, position); } position += length; } else { - byte[] bytes = UTF8.GetBytes(value); + byte[] bytes = Utf8Encoding.GetBytes(value); WriteRawBytes(bytes); } } -- cgit v1.2.3 From d7dda2fed8c37a83e2d4cd7ecc4201b628588c4c Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Fri, 19 Jun 2015 08:38:21 +0100 Subject: Use an empty array instead of a null reference for an empty repeated field. --- .../ProtocolBuffers/Collections/RepeatedField.cs | 32 +++++++--------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs b/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs index 0cd5cf80..25651784 100644 --- a/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs +++ b/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs @@ -6,25 +6,21 @@ namespace Google.Protobuf.Collections { public sealed class RepeatedField : IList, IEquatable> { + private static readonly T[] EmptyArray = new T[0]; + private const int MinArraySize = 8; - private T[] array = null; + private T[] array = EmptyArray; private int count = 0; private void EnsureSize(int size) { - if (array == null) - { - array = new T[Math.Max(size, MinArraySize)]; - } - else + size = Math.Max(size, MinArraySize); + if (array.Length < size) { - if (array.Length < size) - { - int newSize = Math.Max(array.Length * 2, size); - var tmp = new T[newSize]; - Array.Copy(array, 0, tmp, 0, array.Length); - array = tmp; - } + int newSize = Math.Max(array.Length * 2, size); + var tmp = new T[newSize]; + Array.Copy(array, 0, tmp, 0, array.Length); + array = tmp; } } @@ -51,7 +47,7 @@ namespace Google.Protobuf.Collections public void Clear() { - array = null; + array = EmptyArray; count = 0; } @@ -62,10 +58,6 @@ namespace Google.Protobuf.Collections public void CopyTo(T[] array, int arrayIndex) { - if (this.array == null) - { - return; - } Array.Copy(this.array, 0, array, arrayIndex, count); } @@ -183,10 +175,6 @@ namespace Google.Protobuf.Collections { throw new ArgumentNullException("item"); } - if (array == null) - { - return -1; - } // TODO(jonskeet): Does this box for enums? EqualityComparer comparer = EqualityComparer.Default; for (int i = 0; i < count; i++) -- cgit v1.2.3 From cdeda4b87625084f5687115bb1fd7772b7c34ad6 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Fri, 19 Jun 2015 17:30:13 +0100 Subject: Minor cleanup. - Make some members internal - Remove a lot of FrameworkPortability that isn't required - Start adding documentation comments - Remove some more group-based members - Not passing in "the last tag read" into Read*Array, g --- csharp/src/AddressBook/Addressbook.cs | 4 +- .../ProtocolBuffers.Test/CodedInputStreamTest.cs | 4 +- .../ProtocolBuffers.Test/CodedOutputStreamTest.cs | 4 +- .../TestProtos/UnittestIssues.cs | 10 +- .../TestProtos/UnittestProto3.cs | 124 ++++++++++----------- csharp/src/ProtocolBuffers/ByteArray.cs | 9 +- csharp/src/ProtocolBuffers/CodedInputStream.cs | 90 +++++++-------- csharp/src/ProtocolBuffers/CodedOutputStream.cs | 5 +- .../DescriptorProtos/DescriptorProtoFile.cs | 60 +++++----- csharp/src/ProtocolBuffers/Extensions.cs | 70 ------------ csharp/src/ProtocolBuffers/FrameworkPortability.cs | 68 +---------- csharp/src/ProtocolBuffers/IMessage.cs | 43 ++++++- csharp/src/ProtocolBuffers/MessageExtensions.cs | 81 ++++++++++++++ csharp/src/ProtocolBuffers/MessageParser.cs | 37 +++++- csharp/src/ProtocolBuffers/ProtocolBuffers.csproj | 4 +- csharp/src/ProtocolBuffers/ThrowHelper.cs | 17 +-- .../compiler/csharp/csharp_repeated_enum_field.cc | 2 +- .../csharp/csharp_repeated_message_field.cc | 2 +- .../csharp/csharp_repeated_primitive_field.cc | 2 +- 19 files changed, 319 insertions(+), 317 deletions(-) delete mode 100644 csharp/src/ProtocolBuffers/Extensions.cs create mode 100644 csharp/src/ProtocolBuffers/MessageExtensions.cs diff --git a/csharp/src/AddressBook/Addressbook.cs b/csharp/src/AddressBook/Addressbook.cs index 480fb92a..322f85f7 100644 --- a/csharp/src/AddressBook/Addressbook.cs +++ b/csharp/src/AddressBook/Addressbook.cs @@ -214,7 +214,7 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { break; } case 34: { - input.ReadMessageArray(tag, phone_, global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneNumber.Parser); + input.ReadMessageArray(phone_, global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneNumber.Parser); break; } } @@ -432,7 +432,7 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { } break; case 10: { - input.ReadMessageArray(tag, person_, global::Google.ProtocolBuffers.Examples.AddressBook.Person.Parser); + input.ReadMessageArray(person_, global::Google.ProtocolBuffers.Examples.AddressBook.Person.Parser); break; } } diff --git a/csharp/src/ProtocolBuffers.Test/CodedInputStreamTest.cs b/csharp/src/ProtocolBuffers.Test/CodedInputStreamTest.cs index 0baa3a75..52757d4d 100644 --- a/csharp/src/ProtocolBuffers.Test/CodedInputStreamTest.cs +++ b/csharp/src/ProtocolBuffers.Test/CodedInputStreamTest.cs @@ -489,7 +489,7 @@ namespace Google.Protobuf Assert.IsTrue(input.ReadTag(out tag)); RepeatedField values = new RepeatedField(); - input.ReadEnumArray(tag, values); + input.ReadEnumArray(values); Assert.AreEqual(6, values.Count); Assert.AreEqual(TestNegEnum.None, values[0]); @@ -513,7 +513,7 @@ namespace Google.Protobuf Assert.IsTrue(input.ReadTag(out tag)); RepeatedField values = new RepeatedField(); - input.ReadEnumArray(tag, values); + input.ReadEnumArray(values); Assert.AreEqual(6, values.Count); Assert.AreEqual(TestNegEnum.None, values[0]); diff --git a/csharp/src/ProtocolBuffers.Test/CodedOutputStreamTest.cs b/csharp/src/ProtocolBuffers.Test/CodedOutputStreamTest.cs index bc053e19..223374e0 100644 --- a/csharp/src/ProtocolBuffers.Test/CodedOutputStreamTest.cs +++ b/csharp/src/ProtocolBuffers.Test/CodedOutputStreamTest.cs @@ -326,7 +326,7 @@ namespace Google.Protobuf Assert.IsTrue(input.ReadTag(out tag)); List values = new List(); - input.ReadInt32Array(tag, values); + input.ReadInt32Array(values); Assert.AreEqual(6, values.Count); for (int i = 0; i > -6; i--) @@ -349,7 +349,7 @@ namespace Google.Protobuf Assert.IsTrue(input.ReadTag(out tag)); List values = new List(); - input.ReadInt32Array(tag, values); + input.ReadInt32Array(values); Assert.AreEqual(6, values.Count); for (int i = 0; i > -6; i--) diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs index 1ea3728d..959b3866 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs @@ -218,12 +218,12 @@ namespace UnitTest.Issues.TestProtos { } case 18: case 16: { - input.ReadEnumArray(tag, values_); + input.ReadEnumArray(values_); break; } case 26: case 24: { - input.ReadEnumArray(tag, packedValues_); + input.ReadEnumArray(packedValues_); break; } } @@ -495,7 +495,7 @@ namespace UnitTest.Issues.TestProtos { } case 18: case 16: { - input.ReadInt32Array(tag, primitiveArray_); + input.ReadInt32Array(primitiveArray_); break; } case 26: { @@ -506,7 +506,7 @@ namespace UnitTest.Issues.TestProtos { break; } case 34: { - input.ReadMessageArray(tag, messageArray_, global::UnitTest.Issues.TestProtos.DeprecatedChild.Parser); + input.ReadMessageArray(messageArray_, global::UnitTest.Issues.TestProtos.DeprecatedChild.Parser); break; } case 40: { @@ -515,7 +515,7 @@ namespace UnitTest.Issues.TestProtos { } case 50: case 48: { - input.ReadEnumArray(tag, enumArray_); + input.ReadEnumArray(enumArray_); break; } } diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs index a2c5d5f6..bbfa8c3e 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs @@ -1547,106 +1547,106 @@ namespace Google.Protobuf.TestProtos { } case 250: case 248: { - input.ReadInt32Array(tag, repeatedInt32_); + input.ReadInt32Array(repeatedInt32_); break; } case 258: case 256: { - input.ReadInt64Array(tag, repeatedInt64_); + input.ReadInt64Array(repeatedInt64_); break; } case 266: case 264: { - input.ReadUInt32Array(tag, repeatedUint32_); + input.ReadUInt32Array(repeatedUint32_); break; } case 274: case 272: { - input.ReadUInt64Array(tag, repeatedUint64_); + input.ReadUInt64Array(repeatedUint64_); break; } case 282: case 280: { - input.ReadSInt32Array(tag, repeatedSint32_); + input.ReadSInt32Array(repeatedSint32_); break; } case 290: case 288: { - input.ReadSInt64Array(tag, repeatedSint64_); + input.ReadSInt64Array(repeatedSint64_); break; } case 298: case 301: { - input.ReadFixed32Array(tag, repeatedFixed32_); + input.ReadFixed32Array(repeatedFixed32_); break; } case 306: case 305: { - input.ReadFixed64Array(tag, repeatedFixed64_); + input.ReadFixed64Array(repeatedFixed64_); break; } case 314: case 317: { - input.ReadSFixed32Array(tag, repeatedSfixed32_); + input.ReadSFixed32Array(repeatedSfixed32_); break; } case 322: case 321: { - input.ReadSFixed64Array(tag, repeatedSfixed64_); + input.ReadSFixed64Array(repeatedSfixed64_); break; } case 330: case 333: { - input.ReadFloatArray(tag, repeatedFloat_); + input.ReadFloatArray(repeatedFloat_); break; } case 338: case 337: { - input.ReadDoubleArray(tag, repeatedDouble_); + input.ReadDoubleArray(repeatedDouble_); break; } case 346: case 344: { - input.ReadBoolArray(tag, repeatedBool_); + input.ReadBoolArray(repeatedBool_); break; } case 354: { - input.ReadStringArray(tag, repeatedString_); + input.ReadStringArray(repeatedString_); break; } case 362: { - input.ReadBytesArray(tag, repeatedBytes_); + input.ReadBytesArray(repeatedBytes_); break; } case 386: { - input.ReadMessageArray(tag, repeatedNestedMessage_, global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage.Parser); + input.ReadMessageArray(repeatedNestedMessage_, global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage.Parser); break; } case 394: { - input.ReadMessageArray(tag, repeatedForeignMessage_, global::Google.Protobuf.TestProtos.ForeignMessage.Parser); + input.ReadMessageArray(repeatedForeignMessage_, global::Google.Protobuf.TestProtos.ForeignMessage.Parser); break; } case 402: { - input.ReadMessageArray(tag, repeatedImportMessage_, global::Google.Protobuf.TestProtos.ImportMessage.Parser); + input.ReadMessageArray(repeatedImportMessage_, global::Google.Protobuf.TestProtos.ImportMessage.Parser); break; } case 410: case 408: { - input.ReadEnumArray(tag, repeatedNestedEnum_); + input.ReadEnumArray(repeatedNestedEnum_); break; } case 418: case 416: { - input.ReadEnumArray(tag, repeatedForeignEnum_); + input.ReadEnumArray(repeatedForeignEnum_); break; } case 426: case 424: { - input.ReadEnumArray(tag, repeatedImportEnum_); + input.ReadEnumArray(repeatedImportEnum_); break; } case 434: { - input.ReadMessageArray(tag, repeatedPublicImportMessage_, global::Google.Protobuf.TestProtos.PublicImportMessage.Parser); + input.ReadMessageArray(repeatedPublicImportMessage_, global::Google.Protobuf.TestProtos.PublicImportMessage.Parser); break; } case 888: { @@ -1919,7 +1919,7 @@ namespace Google.Protobuf.TestProtos { break; } case 26: { - input.ReadMessageArray(tag, repeatedChild_, global::Google.Protobuf.TestProtos.NestedTestAllTypes.Parser); + input.ReadMessageArray(repeatedChild_, global::Google.Protobuf.TestProtos.NestedTestAllTypes.Parser); break; } } @@ -2973,20 +2973,20 @@ namespace Google.Protobuf.TestProtos { } case 58: case 56: { - input.ReadInt32Array(tag, repeatedPrimitiveField_); + input.ReadInt32Array(repeatedPrimitiveField_); break; } case 66: { - input.ReadStringArray(tag, repeatedStringField_); + input.ReadStringArray(repeatedStringField_); break; } case 74: case 72: { - input.ReadEnumArray(tag, repeatedEnumField_); + input.ReadEnumArray(repeatedEnumField_); break; } case 82: { - input.ReadMessageArray(tag, repeatedMessageField_, global::Google.Protobuf.TestProtos.ForeignMessage.Parser); + input.ReadMessageArray(repeatedMessageField_, global::Google.Protobuf.TestProtos.ForeignMessage.Parser); break; } } @@ -3552,7 +3552,7 @@ namespace Google.Protobuf.TestProtos { } break; case 10: { - input.ReadStringArray(tag, data_); + input.ReadStringArray(data_); break; } } @@ -4716,72 +4716,72 @@ namespace Google.Protobuf.TestProtos { break; case 722: case 720: { - input.ReadInt32Array(tag, packedInt32_); + input.ReadInt32Array(packedInt32_); break; } case 730: case 728: { - input.ReadInt64Array(tag, packedInt64_); + input.ReadInt64Array(packedInt64_); break; } case 738: case 736: { - input.ReadUInt32Array(tag, packedUint32_); + input.ReadUInt32Array(packedUint32_); break; } case 746: case 744: { - input.ReadUInt64Array(tag, packedUint64_); + input.ReadUInt64Array(packedUint64_); break; } case 754: case 752: { - input.ReadSInt32Array(tag, packedSint32_); + input.ReadSInt32Array(packedSint32_); break; } case 762: case 760: { - input.ReadSInt64Array(tag, packedSint64_); + input.ReadSInt64Array(packedSint64_); break; } case 770: case 773: { - input.ReadFixed32Array(tag, packedFixed32_); + input.ReadFixed32Array(packedFixed32_); break; } case 778: case 777: { - input.ReadFixed64Array(tag, packedFixed64_); + input.ReadFixed64Array(packedFixed64_); break; } case 786: case 789: { - input.ReadSFixed32Array(tag, packedSfixed32_); + input.ReadSFixed32Array(packedSfixed32_); break; } case 794: case 793: { - input.ReadSFixed64Array(tag, packedSfixed64_); + input.ReadSFixed64Array(packedSfixed64_); break; } case 802: case 805: { - input.ReadFloatArray(tag, packedFloat_); + input.ReadFloatArray(packedFloat_); break; } case 810: case 809: { - input.ReadDoubleArray(tag, packedDouble_); + input.ReadDoubleArray(packedDouble_); break; } case 818: case 816: { - input.ReadBoolArray(tag, packedBool_); + input.ReadBoolArray(packedBool_); break; } case 826: case 824: { - input.ReadEnumArray(tag, packedEnum_); + input.ReadEnumArray(packedEnum_); break; } } @@ -5120,72 +5120,72 @@ namespace Google.Protobuf.TestProtos { break; case 722: case 720: { - input.ReadInt32Array(tag, unpackedInt32_); + input.ReadInt32Array(unpackedInt32_); break; } case 730: case 728: { - input.ReadInt64Array(tag, unpackedInt64_); + input.ReadInt64Array(unpackedInt64_); break; } case 738: case 736: { - input.ReadUInt32Array(tag, unpackedUint32_); + input.ReadUInt32Array(unpackedUint32_); break; } case 746: case 744: { - input.ReadUInt64Array(tag, unpackedUint64_); + input.ReadUInt64Array(unpackedUint64_); break; } case 754: case 752: { - input.ReadSInt32Array(tag, unpackedSint32_); + input.ReadSInt32Array(unpackedSint32_); break; } case 762: case 760: { - input.ReadSInt64Array(tag, unpackedSint64_); + input.ReadSInt64Array(unpackedSint64_); break; } case 770: case 773: { - input.ReadFixed32Array(tag, unpackedFixed32_); + input.ReadFixed32Array(unpackedFixed32_); break; } case 778: case 777: { - input.ReadFixed64Array(tag, unpackedFixed64_); + input.ReadFixed64Array(unpackedFixed64_); break; } case 786: case 789: { - input.ReadSFixed32Array(tag, unpackedSfixed32_); + input.ReadSFixed32Array(unpackedSfixed32_); break; } case 794: case 793: { - input.ReadSFixed64Array(tag, unpackedSfixed64_); + input.ReadSFixed64Array(unpackedSfixed64_); break; } case 802: case 805: { - input.ReadFloatArray(tag, unpackedFloat_); + input.ReadFloatArray(unpackedFloat_); break; } case 810: case 809: { - input.ReadDoubleArray(tag, unpackedDouble_); + input.ReadDoubleArray(unpackedDouble_); break; } case 818: case 816: { - input.ReadBoolArray(tag, unpackedBool_); + input.ReadBoolArray(unpackedBool_); break; } case 826: case 824: { - input.ReadEnumArray(tag, unpackedEnum_); + input.ReadEnumArray(unpackedEnum_); break; } } @@ -5378,32 +5378,32 @@ namespace Google.Protobuf.TestProtos { break; case 98: case 101: { - input.ReadFixed32Array(tag, repeatedFixed32_); + input.ReadFixed32Array(repeatedFixed32_); break; } case 106: case 104: { - input.ReadInt32Array(tag, repeatedInt32_); + input.ReadInt32Array(repeatedInt32_); break; } case 16370: case 16369: { - input.ReadFixed64Array(tag, repeatedFixed64_); + input.ReadFixed64Array(repeatedFixed64_); break; } case 16378: case 16376: { - input.ReadInt64Array(tag, repeatedInt64_); + input.ReadInt64Array(repeatedInt64_); break; } case 2097138: case 2097141: { - input.ReadFloatArray(tag, repeatedFloat_); + input.ReadFloatArray(repeatedFloat_); break; } case 2097146: case 2097144: { - input.ReadUInt64Array(tag, repeatedUint64_); + input.ReadUInt64Array(repeatedUint64_); break; } } diff --git a/csharp/src/ProtocolBuffers/ByteArray.cs b/csharp/src/ProtocolBuffers/ByteArray.cs index d367fc39..211a0e11 100644 --- a/csharp/src/ProtocolBuffers/ByteArray.cs +++ b/csharp/src/ProtocolBuffers/ByteArray.cs @@ -51,7 +51,7 @@ namespace Google.Protobuf /// /// Determines which copy routine to use based on the number of bytes to be copied. /// - public static void Copy(byte[] src, int srcOffset, byte[] dst, int dstOffset, int count) + internal static void Copy(byte[] src, int srcOffset, byte[] dst, int dstOffset, int count) { if (count > CopyThreshold) { @@ -66,7 +66,7 @@ namespace Google.Protobuf /// /// Copy the bytes provided with a for loop, faster when there are only a few bytes to copy /// - public static void ByteCopy(byte[] src, int srcOffset, byte[] dst, int dstOffset, int count) + internal static void ByteCopy(byte[] src, int srcOffset, byte[] dst, int dstOffset, int count) { int stop = srcOffset + count; for (int i = srcOffset; i < stop; i++) @@ -78,12 +78,11 @@ namespace Google.Protobuf /// /// Reverses the order of bytes in the array /// - public static void Reverse(byte[] bytes) + internal static void Reverse(byte[] bytes) { - byte temp; for (int first = 0, last = bytes.Length - 1; first < last; first++, last--) { - temp = bytes[first]; + byte temp = bytes[first]; bytes[first] = bytes[last]; bytes[last] = temp; } diff --git a/csharp/src/ProtocolBuffers/CodedInputStream.cs b/csharp/src/ProtocolBuffers/CodedInputStream.cs index 56283318..905cdb9d 100644 --- a/csharp/src/ProtocolBuffers/CodedInputStream.cs +++ b/csharp/src/ProtocolBuffers/CodedInputStream.cs @@ -37,9 +37,7 @@ using System; using System.Collections.Generic; using System.IO; -using System.Text; using Google.Protobuf.Collections; -using Google.Protobuf.Descriptors; namespace Google.Protobuf { @@ -183,7 +181,7 @@ namespace Google.Protobuf /// /// The last /// tag read was not the one specified - public void CheckLastTagWas(uint value) + internal void CheckLastTagWas(uint value) { if (lastTag != value) { @@ -251,7 +249,7 @@ namespace Google.Protobuf /// public double ReadDouble() { - return FrameworkPortability.Int64ToDouble((long) ReadRawLittleEndian64()); + return BitConverter.Int64BitsToDouble((long) ReadRawLittleEndian64()); } /// @@ -347,21 +345,6 @@ namespace Google.Protobuf return CodedOutputStream.Utf8Encoding.GetString(ReadRawBytes(size), 0, size); } - /// - /// Reads a group field value from the stream. - /// - public void ReadGroup(int fieldNumber, IMessage message) - { - if (recursionDepth >= recursionLimit) - { - throw InvalidProtocolBufferException.RecursionLimitExceeded(); - } - ++recursionDepth; - message.MergeFrom(this); - CheckLastTagWas(WireFormat.MakeTag(fieldNumber, WireFormat.WireType.EndGroup)); - --recursionDepth; - } - /// /// Reads an embedded message field value from the stream. /// @@ -516,24 +499,34 @@ namespace Google.Protobuf return false; } - public void ReadStringArray(uint fieldTag, ICollection list) + /// + /// Reads a string array. + /// + /// The stream is assumed to be positioned after a tag indicating the field + /// repeated string value. A string is read, and then if the next tag is the same, + /// the process is repeated, until the next tag is a different one. + /// + public void ReadStringArray(ICollection list) { + uint fieldTag = lastTag; do { list.Add(ReadString()); } while (ContinueArray(fieldTag)); } - public void ReadBytesArray(uint fieldTag, ICollection list) + public void ReadBytesArray(ICollection list) { + uint fieldTag = lastTag; do { list.Add(ReadBytes()); } while (ContinueArray(fieldTag)); } - public void ReadBoolArray(uint fieldTag, ICollection list) + public void ReadBoolArray(ICollection list) { + uint fieldTag = lastTag; bool isPacked; int holdLimit; if (BeginArray(fieldTag, out isPacked, out holdLimit)) @@ -545,8 +538,9 @@ namespace Google.Protobuf } } - public void ReadInt32Array(uint fieldTag, ICollection list) + public void ReadInt32Array(ICollection list) { + uint fieldTag = lastTag; bool isPacked; int holdLimit; if (BeginArray(fieldTag, out isPacked, out holdLimit)) @@ -558,8 +552,9 @@ namespace Google.Protobuf } } - public void ReadSInt32Array(uint fieldTag, ICollection list) + public void ReadSInt32Array(ICollection list) { + uint fieldTag = lastTag; bool isPacked; int holdLimit; if (BeginArray(fieldTag, out isPacked, out holdLimit)) @@ -571,8 +566,9 @@ namespace Google.Protobuf } } - public void ReadUInt32Array(uint fieldTag, ICollection list) + public void ReadUInt32Array(ICollection list) { + uint fieldTag = lastTag; bool isPacked; int holdLimit; if (BeginArray(fieldTag, out isPacked, out holdLimit)) @@ -584,8 +580,9 @@ namespace Google.Protobuf } } - public void ReadFixed32Array(uint fieldTag, ICollection list) + public void ReadFixed32Array(ICollection list) { + uint fieldTag = lastTag; bool isPacked; int holdLimit; if (BeginArray(fieldTag, out isPacked, out holdLimit)) @@ -597,8 +594,9 @@ namespace Google.Protobuf } } - public void ReadSFixed32Array(uint fieldTag, ICollection list) + public void ReadSFixed32Array(ICollection list) { + uint fieldTag = lastTag; bool isPacked; int holdLimit; if (BeginArray(fieldTag, out isPacked, out holdLimit)) @@ -610,8 +608,9 @@ namespace Google.Protobuf } } - public void ReadInt64Array(uint fieldTag, ICollection list) + public void ReadInt64Array(ICollection list) { + uint fieldTag = lastTag; bool isPacked; int holdLimit; if (BeginArray(fieldTag, out isPacked, out holdLimit)) @@ -623,8 +622,9 @@ namespace Google.Protobuf } } - public void ReadSInt64Array(uint fieldTag, ICollection list) + public void ReadSInt64Array(ICollection list) { + uint fieldTag = lastTag; bool isPacked; int holdLimit; if (BeginArray(fieldTag, out isPacked, out holdLimit)) @@ -636,8 +636,9 @@ namespace Google.Protobuf } } - public void ReadUInt64Array(uint fieldTag, ICollection list) + public void ReadUInt64Array(ICollection list) { + uint fieldTag = lastTag; bool isPacked; int holdLimit; if (BeginArray(fieldTag, out isPacked, out holdLimit)) @@ -649,8 +650,9 @@ namespace Google.Protobuf } } - public void ReadFixed64Array(uint fieldTag, ICollection list) + public void ReadFixed64Array(ICollection list) { + uint fieldTag = lastTag; bool isPacked; int holdLimit; if (BeginArray(fieldTag, out isPacked, out holdLimit)) @@ -662,8 +664,9 @@ namespace Google.Protobuf } } - public void ReadSFixed64Array(uint fieldTag, ICollection list) + public void ReadSFixed64Array(ICollection list) { + uint fieldTag = lastTag; bool isPacked; int holdLimit; if (BeginArray(fieldTag, out isPacked, out holdLimit)) @@ -675,8 +678,9 @@ namespace Google.Protobuf } } - public void ReadDoubleArray(uint fieldTag, ICollection list) + public void ReadDoubleArray(ICollection list) { + uint fieldTag = lastTag; bool isPacked; int holdLimit; if (BeginArray(fieldTag, out isPacked, out holdLimit)) @@ -688,8 +692,9 @@ namespace Google.Protobuf } } - public void ReadFloatArray(uint fieldTag, ICollection list) + public void ReadFloatArray(ICollection list) { + uint fieldTag = lastTag; bool isPacked; int holdLimit; if (BeginArray(fieldTag, out isPacked, out holdLimit)) @@ -701,9 +706,10 @@ namespace Google.Protobuf } } - public void ReadEnumArray(uint fieldTag, RepeatedField list) + public void ReadEnumArray(RepeatedField list) where T : struct, IComparable, IFormattable { + uint fieldTag = lastTag; WireFormat.WireType wformat = WireFormat.GetTagWireType(fieldTag); // 2.3 allows packed form even if the field is not declared packed. @@ -727,9 +733,10 @@ namespace Google.Protobuf } } - public void ReadMessageArray(uint fieldTag, ICollection list, MessageParser messageParser) + public void ReadMessageArray(ICollection list, MessageParser messageParser) where T : IMessage { + uint fieldTag = lastTag; do { T message = messageParser.CreateTemplate(); @@ -737,17 +744,6 @@ namespace Google.Protobuf list.Add(message); } while (ContinueArray(fieldTag)); } - - public void ReadGroupArray(uint fieldTag, ICollection list, MessageParser messageParser) - where T : IMessage - { - do - { - T message = messageParser.CreateTemplate(); - ReadGroup(WireFormat.GetTagFieldNumber(fieldTag), message); - list.Add(message); - } while (ContinueArray(fieldTag)); - } #endregion #region Underlying reading primitives diff --git a/csharp/src/ProtocolBuffers/CodedOutputStream.cs b/csharp/src/ProtocolBuffers/CodedOutputStream.cs index 1e6e7e55..e56ce789 100644 --- a/csharp/src/ProtocolBuffers/CodedOutputStream.cs +++ b/csharp/src/ProtocolBuffers/CodedOutputStream.cs @@ -35,12 +35,9 @@ #endregion using System; -using System.Collections; using System.IO; -using System.Linq; using System.Text; using Google.Protobuf.Collections; -using Google.Protobuf.Descriptors; namespace Google.Protobuf { @@ -151,7 +148,7 @@ namespace Google.Protobuf /// public void WriteDouble(double value) { - WriteRawLittleEndian64((ulong)FrameworkPortability.DoubleToInt64(value)); + WriteRawLittleEndian64((ulong)BitConverter.DoubleToInt64Bits(value)); } /// diff --git a/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs b/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs index 67938260..7b7abd8e 100644 --- a/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs +++ b/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs @@ -358,7 +358,7 @@ namespace Google.Protobuf.DescriptorProtos { } break; case 10: { - input.ReadMessageArray(tag, file_, global::Google.Protobuf.DescriptorProtos.FileDescriptorProto.Parser); + input.ReadMessageArray(file_, global::Google.Protobuf.DescriptorProtos.FileDescriptorProto.Parser); break; } } @@ -672,23 +672,23 @@ namespace Google.Protobuf.DescriptorProtos { break; } case 26: { - input.ReadStringArray(tag, dependency_); + input.ReadStringArray(dependency_); break; } case 34: { - input.ReadMessageArray(tag, messageType_, global::Google.Protobuf.DescriptorProtos.DescriptorProto.Parser); + input.ReadMessageArray(messageType_, global::Google.Protobuf.DescriptorProtos.DescriptorProto.Parser); break; } case 42: { - input.ReadMessageArray(tag, enumType_, global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto.Parser); + input.ReadMessageArray(enumType_, global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto.Parser); break; } case 50: { - input.ReadMessageArray(tag, service_, global::Google.Protobuf.DescriptorProtos.ServiceDescriptorProto.Parser); + input.ReadMessageArray(service_, global::Google.Protobuf.DescriptorProtos.ServiceDescriptorProto.Parser); break; } case 58: { - input.ReadMessageArray(tag, extension_, global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Parser); + input.ReadMessageArray(extension_, global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Parser); break; } case 66: { @@ -707,12 +707,12 @@ namespace Google.Protobuf.DescriptorProtos { } case 82: case 80: { - input.ReadInt32Array(tag, publicDependency_); + input.ReadInt32Array(publicDependency_); break; } case 90: case 88: { - input.ReadInt32Array(tag, weakDependency_); + input.ReadInt32Array(weakDependency_); break; } case 98: { @@ -979,23 +979,23 @@ namespace Google.Protobuf.DescriptorProtos { break; } case 18: { - input.ReadMessageArray(tag, field_, global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Parser); + input.ReadMessageArray(field_, global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Parser); break; } case 26: { - input.ReadMessageArray(tag, nestedType_, global::Google.Protobuf.DescriptorProtos.DescriptorProto.Parser); + input.ReadMessageArray(nestedType_, global::Google.Protobuf.DescriptorProtos.DescriptorProto.Parser); break; } case 34: { - input.ReadMessageArray(tag, enumType_, global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto.Parser); + input.ReadMessageArray(enumType_, global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto.Parser); break; } case 42: { - input.ReadMessageArray(tag, extensionRange_, global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ExtensionRange.Parser); + input.ReadMessageArray(extensionRange_, global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ExtensionRange.Parser); break; } case 50: { - input.ReadMessageArray(tag, extension_, global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Parser); + input.ReadMessageArray(extension_, global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Parser); break; } case 58: { @@ -1006,15 +1006,15 @@ namespace Google.Protobuf.DescriptorProtos { break; } case 66: { - input.ReadMessageArray(tag, oneofDecl_, global::Google.Protobuf.DescriptorProtos.OneofDescriptorProto.Parser); + input.ReadMessageArray(oneofDecl_, global::Google.Protobuf.DescriptorProtos.OneofDescriptorProto.Parser); break; } case 74: { - input.ReadMessageArray(tag, reservedRange_, global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ReservedRange.Parser); + input.ReadMessageArray(reservedRange_, global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ReservedRange.Parser); break; } case 82: { - input.ReadStringArray(tag, reservedName_); + input.ReadStringArray(reservedName_); break; } } @@ -1800,7 +1800,7 @@ namespace Google.Protobuf.DescriptorProtos { break; } case 18: { - input.ReadMessageArray(tag, value_, global::Google.Protobuf.DescriptorProtos.EnumValueDescriptorProto.Parser); + input.ReadMessageArray(value_, global::Google.Protobuf.DescriptorProtos.EnumValueDescriptorProto.Parser); break; } case 26: { @@ -2086,7 +2086,7 @@ namespace Google.Protobuf.DescriptorProtos { break; } case 18: { - input.ReadMessageArray(tag, method_, global::Google.Protobuf.DescriptorProtos.MethodDescriptorProto.Parser); + input.ReadMessageArray(method_, global::Google.Protobuf.DescriptorProtos.MethodDescriptorProto.Parser); break; } case 26: { @@ -2735,7 +2735,7 @@ namespace Google.Protobuf.DescriptorProtos { break; } case 7994: { - input.ReadMessageArray(tag, uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); + input.ReadMessageArray(uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); break; } } @@ -2933,7 +2933,7 @@ namespace Google.Protobuf.DescriptorProtos { break; } case 7994: { - input.ReadMessageArray(tag, uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); + input.ReadMessageArray(uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); break; } } @@ -3167,7 +3167,7 @@ namespace Google.Protobuf.DescriptorProtos { break; } case 7994: { - input.ReadMessageArray(tag, uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); + input.ReadMessageArray(uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); break; } } @@ -3323,7 +3323,7 @@ namespace Google.Protobuf.DescriptorProtos { break; } case 7994: { - input.ReadMessageArray(tag, uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); + input.ReadMessageArray(uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); break; } } @@ -3437,7 +3437,7 @@ namespace Google.Protobuf.DescriptorProtos { break; } case 7994: { - input.ReadMessageArray(tag, uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); + input.ReadMessageArray(uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); break; } } @@ -3551,7 +3551,7 @@ namespace Google.Protobuf.DescriptorProtos { break; } case 7994: { - input.ReadMessageArray(tag, uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); + input.ReadMessageArray(uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); break; } } @@ -3665,7 +3665,7 @@ namespace Google.Protobuf.DescriptorProtos { break; } case 7994: { - input.ReadMessageArray(tag, uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); + input.ReadMessageArray(uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); break; } } @@ -3875,7 +3875,7 @@ namespace Google.Protobuf.DescriptorProtos { } break; case 18: { - input.ReadMessageArray(tag, name_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Types.NamePart.Parser); + input.ReadMessageArray(name_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Types.NamePart.Parser); break; } case 26: { @@ -4111,7 +4111,7 @@ namespace Google.Protobuf.DescriptorProtos { } break; case 10: { - input.ReadMessageArray(tag, location_, global::Google.Protobuf.DescriptorProtos.SourceCodeInfo.Types.Location.Parser); + input.ReadMessageArray(location_, global::Google.Protobuf.DescriptorProtos.SourceCodeInfo.Types.Location.Parser); break; } } @@ -4287,12 +4287,12 @@ namespace Google.Protobuf.DescriptorProtos { break; case 10: case 8: { - input.ReadInt32Array(tag, path_); + input.ReadInt32Array(path_); break; } case 18: case 16: { - input.ReadInt32Array(tag, span_); + input.ReadInt32Array(span_); break; } case 26: { @@ -4304,7 +4304,7 @@ namespace Google.Protobuf.DescriptorProtos { break; } case 50: { - input.ReadStringArray(tag, leadingDetachedComments_); + input.ReadStringArray(leadingDetachedComments_); break; } } diff --git a/csharp/src/ProtocolBuffers/Extensions.cs b/csharp/src/ProtocolBuffers/Extensions.cs deleted file mode 100644 index 7f23057e..00000000 --- a/csharp/src/ProtocolBuffers/Extensions.cs +++ /dev/null @@ -1,70 +0,0 @@ -using System.IO; - -namespace Google.Protobuf -{ - // TODO: MessageExtensions? - public static class Extensions - { - public static void MergeFrom(this IMessage message, byte[] data) - { - CodedInputStream input = CodedInputStream.CreateInstance(data); - message.MergeFrom(input); - input.CheckLastTagWas(0); - } - - public static void MergeFrom(this IMessage message, ByteString data) - { - CodedInputStream input = data.CreateCodedInput(); - message.MergeFrom(input); - input.CheckLastTagWas(0); - } - - public static void MergeFrom(this IMessage message, Stream input) - { - CodedInputStream codedInput = CodedInputStream.CreateInstance(input); - message.MergeFrom(codedInput); - codedInput.CheckLastTagWas(0); - } - - public static void MergeDelimitedFrom(this IMessage message, Stream input) - { - int size = (int)CodedInputStream.ReadRawVarint32(input); - Stream limitedStream = new LimitedInputStream(input, size); - message.MergeFrom(limitedStream); - } - - public static byte[] ToByteArray(this IMessage message) - { - byte[] result = new byte[message.CalculateSize()]; - CodedOutputStream output = CodedOutputStream.CreateInstance(result); - message.WriteTo(output); - output.CheckNoSpaceLeft(); - return result; - } - - public static void WriteTo(this IMessage message, Stream output) - { - CodedOutputStream codedOutput = CodedOutputStream.CreateInstance(output); - message.WriteTo(codedOutput); - codedOutput.Flush(); - } - - public static void WriteTo(this IMessage message, CodedOutputStream output) - { - message.WriteTo(output); - } - - public static void WriteDelimitedTo(this IMessage message, Stream output) - { - CodedOutputStream codedOutput = CodedOutputStream.CreateInstance(output); - codedOutput.WriteRawVarint32((uint)message.CalculateSize()); - message.WriteTo(codedOutput); - codedOutput.Flush(); - } - - public static ByteString ToByteString(this IMessage message) - { - return ByteString.AttachBytes(message.ToByteArray()); - } - } -} diff --git a/csharp/src/ProtocolBuffers/FrameworkPortability.cs b/csharp/src/ProtocolBuffers/FrameworkPortability.cs index 5fa7c4e7..06246a9e 100644 --- a/csharp/src/ProtocolBuffers/FrameworkPortability.cs +++ b/csharp/src/ProtocolBuffers/FrameworkPortability.cs @@ -35,8 +35,6 @@ #endregion using System; -using System.Globalization; -using System.Reflection; using System.Text.RegularExpressions; namespace Google.Protobuf @@ -46,66 +44,10 @@ namespace Google.Protobuf /// internal static class FrameworkPortability { -#if COMPACT_FRAMEWORK - internal const string NewLine = "\n"; -#else - internal static readonly string NewLine = System.Environment.NewLine; -#endif - -#if CLIENTPROFILE - internal const RegexOptions CompiledRegexWhereAvailable = RegexOptions.Compiled; -#else - internal const RegexOptions CompiledRegexWhereAvailable = RegexOptions.None; -#endif - - internal static CultureInfo InvariantCulture - { - get { return CultureInfo.InvariantCulture; } - } - - internal static double Int64ToDouble(long value) - { -#if CLIENTPROFILE - return BitConverter.Int64BitsToDouble(value); -#else - double[] arresult = new double[1]; - Buffer.BlockCopy(new[] { value }, 0, arresult, 0, 8); - return arresult[0]; -#endif - } - - internal static long DoubleToInt64(double value) - { -#if CLIENTPROFILE - return BitConverter.DoubleToInt64Bits(value); -#else - long[] arresult = new long[1]; - Buffer.BlockCopy(new[] { value }, 0, arresult, 0, 8); - return arresult[0]; -#endif - } - - internal static bool TryParseInt32(string text, out int number) - { - return TryParseInt32(text, NumberStyles.Any, InvariantCulture, out number); - } - - internal static bool TryParseInt32(string text, NumberStyles style, IFormatProvider format, out int number) - { -#if COMPACT_FRAMEWORK - try - { - number = int.Parse(text, style, format); - return true; - } - catch - { - number = 0; - return false; - } -#else - return int.TryParse(text, style, format, out number); -#endif - } + // The value of RegexOptions.Compiled is 8. We can test for the presence at + // execution time using Enum.IsDefined, so a single build will do the right thing + // on each platform. + internal static readonly RegexOptions CompiledRegexWhereAvailable = + Enum.IsDefined(typeof(RegexOptions), 8) ? (RegexOptions)8 : RegexOptions.None; } } \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/IMessage.cs b/csharp/src/ProtocolBuffers/IMessage.cs index 55b6fc5d..9c2a2d85 100644 --- a/csharp/src/ProtocolBuffers/IMessage.cs +++ b/csharp/src/ProtocolBuffers/IMessage.cs @@ -34,30 +34,63 @@ #endregion -using System; -using System.Collections.Generic; -using System.IO; -using Google.Protobuf.Descriptors; using Google.Protobuf.FieldAccess; namespace Google.Protobuf { - // TODO(jonskeet): Do we want a "weak" version of IReflectedMessage? + // TODO(jonskeet): Do we want a "weak" (non-generic) version of IReflectedMessage? + + /// + /// Reflection support for a specific message type. message + /// + /// The message type being reflected. public interface IReflectedMessage where T : IMessage { FieldAccessorTable Fields { get; } + // TODO(jonskeet): Descriptor? Or a single property which has "all you need for reflection"? } + /// + /// Interface for a Protocol Buffers message, supporting + /// basic operations required for serialization. + /// public interface IMessage { + /// + /// Merges the data from the specified coded input stream with the current message. + /// + /// See the user guide for precise merge semantics. + /// void MergeFrom(CodedInputStream input); + + /// + /// Writes the data to the given coded output stream. + /// + /// Coded output stream to write the data to. Must not be null. void WriteTo(CodedOutputStream output); + + /// + /// Calculates the size of this message in Protocol Buffer wire format, in bytes. + /// + /// The number of bytes required to write this message + /// to a coded output stream. int CalculateSize(); } + /// + /// Generic interface for a Protocol Buffers message, + /// where the type parameter is expected to be the same type as + /// the implementation class. + /// + /// The message type. public interface IMessage : IMessage where T : IMessage { + /// + /// Merges the given message into this one. + /// + /// See the user guide for precise merge semantics. + /// The message to merge with this one. Must not be null. void MergeFrom(T message); } } \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/MessageExtensions.cs b/csharp/src/ProtocolBuffers/MessageExtensions.cs new file mode 100644 index 00000000..57cecfd4 --- /dev/null +++ b/csharp/src/ProtocolBuffers/MessageExtensions.cs @@ -0,0 +1,81 @@ +using System.IO; + +namespace Google.Protobuf +{ + /// + /// Extension methods on and . + /// + public static class MessageExtensions + { + public static void MergeFrom(this IMessage message, byte[] data) + { + ThrowHelper.ThrowIfNull(message, "message"); + ThrowHelper.ThrowIfNull(data, "data"); + CodedInputStream input = CodedInputStream.CreateInstance(data); + message.MergeFrom(input); + input.CheckLastTagWas(0); + } + + public static void MergeFrom(this IMessage message, ByteString data) + { + ThrowHelper.ThrowIfNull(message, "message"); + ThrowHelper.ThrowIfNull(data, "data"); + CodedInputStream input = data.CreateCodedInput(); + message.MergeFrom(input); + input.CheckLastTagWas(0); + } + + public static void MergeFrom(this IMessage message, Stream input) + { + ThrowHelper.ThrowIfNull(message, "message"); + ThrowHelper.ThrowIfNull(input, "input"); + CodedInputStream codedInput = CodedInputStream.CreateInstance(input); + message.MergeFrom(codedInput); + codedInput.CheckLastTagWas(0); + } + + public static void MergeDelimitedFrom(this IMessage message, Stream input) + { + ThrowHelper.ThrowIfNull(message, "message"); + ThrowHelper.ThrowIfNull(input, "input"); + int size = (int)CodedInputStream.ReadRawVarint32(input); + Stream limitedStream = new LimitedInputStream(input, size); + message.MergeFrom(limitedStream); + } + + public static byte[] ToByteArray(this IMessage message) + { + ThrowHelper.ThrowIfNull(message, "message"); + byte[] result = new byte[message.CalculateSize()]; + CodedOutputStream output = CodedOutputStream.CreateInstance(result); + message.WriteTo(output); + output.CheckNoSpaceLeft(); + return result; + } + + public static void WriteTo(this IMessage message, Stream output) + { + ThrowHelper.ThrowIfNull(message, "message"); + ThrowHelper.ThrowIfNull(output, "output"); + CodedOutputStream codedOutput = CodedOutputStream.CreateInstance(output); + message.WriteTo(codedOutput); + codedOutput.Flush(); + } + + public static void WriteDelimitedTo(this IMessage message, Stream output) + { + ThrowHelper.ThrowIfNull(message, "message"); + ThrowHelper.ThrowIfNull(output, "output"); + CodedOutputStream codedOutput = CodedOutputStream.CreateInstance(output); + codedOutput.WriteRawVarint32((uint)message.CalculateSize()); + message.WriteTo(codedOutput); + codedOutput.Flush(); + } + + public static ByteString ToByteString(this IMessage message) + { + ThrowHelper.ThrowIfNull(message, "message"); + return ByteString.AttachBytes(message.ToByteArray()); + } + } +} diff --git a/csharp/src/ProtocolBuffers/MessageParser.cs b/csharp/src/ProtocolBuffers/MessageParser.cs index 722435cc..18cda2dc 100644 --- a/csharp/src/ProtocolBuffers/MessageParser.cs +++ b/csharp/src/ProtocolBuffers/MessageParser.cs @@ -1,26 +1,58 @@ using System; using System.IO; -using Google.Protobuf; namespace Google.Protobuf { + /// + /// A parser for a specific message type. + /// + /// + ///

+ /// This delegates most behavior to the + /// implementation within the original type, but + /// provides convenient overloads to parse from a variety of sources. + ///

+ ///

+ /// Most applications will never need to create their own instances of this type; + /// instead, use the static Parser property of a generated message type to obtain a + /// parser for that type. + ///

+ ///
+ /// The type of message to be parsed. public sealed class MessageParser where T : IMessage { private readonly Func factory; + /// + /// Creates a new parser. + /// + /// + /// The factory method is effectively an optimization over using a generic constraint + /// to require a parameterless constructor: delegates are significantly faster to execute. + /// + /// Function to invoke when a new, empty message is required. public MessageParser(Func factory) { this.factory = factory; } - // Creates a template instance ready for population. + /// + /// Creates a template instance ready for population. + /// + /// An empty message. internal T CreateTemplate() { return factory(); } + /// + /// Parses a message from a byte array. + /// + /// The byte array containing the message. Must not be null. + /// The newly parsed message. public T ParseFrom(byte[] data) { + ThrowHelper.ThrowIfNull(data, "data"); T message = factory(); message.MergeFrom(data); return message; @@ -28,6 +60,7 @@ namespace Google.Protobuf public T ParseFrom(ByteString data) { + ThrowHelper.ThrowIfNull(data, "data"); T message = factory(); message.MergeFrom(data); return message; diff --git a/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj b/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj index 3a07e87f..33a32ff2 100644 --- a/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj +++ b/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj @@ -84,7 +84,8 @@ - + + @@ -92,7 +93,6 @@ - diff --git a/csharp/src/ProtocolBuffers/ThrowHelper.cs b/csharp/src/ProtocolBuffers/ThrowHelper.cs index 097b5032..c12a48a3 100644 --- a/csharp/src/ProtocolBuffers/ThrowHelper.cs +++ b/csharp/src/ProtocolBuffers/ThrowHelper.cs @@ -42,12 +42,12 @@ namespace Google.Protobuf /// /// Helper methods for throwing exceptions /// - public static class ThrowHelper + internal static class ThrowHelper { /// /// Throws an ArgumentNullException if the given value is null. /// - public static void ThrowIfNull(object value, string name) + internal static void ThrowIfNull(object value, string name) { if (value == null) { @@ -58,7 +58,7 @@ namespace Google.Protobuf /// /// Throws an ArgumentNullException if the given value is null. /// - public static void ThrowIfNull(object value) + internal static void ThrowIfNull(object value) { if (value == null) { @@ -69,7 +69,7 @@ namespace Google.Protobuf /// /// Throws an ArgumentNullException if the given value or any element within it is null. /// - public static void ThrowIfAnyNull(IEnumerable sequence) + internal static void ThrowIfAnyNull(IEnumerable sequence) { foreach (T t in sequence) { @@ -79,14 +79,5 @@ namespace Google.Protobuf } } } - - public static Exception CreateMissingMethod(Type type, string methodName) - { -#if CLIENTPROFILE - return new System.MissingMethodException(type.FullName, methodName); -#else - return new System.ArgumentException(String.Format("The method '{0}' was not found on type {1}.", methodName, type)); -#endif - } } } \ No newline at end of file diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc b/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc index c78aaef6..29c931e3 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc @@ -76,7 +76,7 @@ void RepeatedEnumFieldGenerator::GenerateMergingCode(io::Printer* printer) { void RepeatedEnumFieldGenerator::GenerateParsingCode(io::Printer* printer) { printer->Print( variables_, - "input.ReadEnumArray<$type_name$>(tag, $name$_);\n"); + "input.ReadEnumArray<$type_name$>($name$_);\n"); } void RepeatedEnumFieldGenerator::GenerateSerializationCode(io::Printer* printer) { diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc b/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc index 3553fe12..3ab0b190 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc @@ -75,7 +75,7 @@ void RepeatedMessageFieldGenerator::GenerateMergingCode(io::Printer* printer) { void RepeatedMessageFieldGenerator::GenerateParsingCode(io::Printer* printer) { printer->Print( variables_, - "input.ReadMessageArray(tag, $name$_, $type_name$.Parser);\n"); + "input.ReadMessageArray($name$_, $type_name$.Parser);\n"); } void RepeatedMessageFieldGenerator::GenerateSerializationCode(io::Printer* printer) { diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc b/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc index fe8a4364..cc787d50 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc @@ -75,7 +75,7 @@ void RepeatedPrimitiveFieldGenerator::GenerateMergingCode(io::Printer* printer) void RepeatedPrimitiveFieldGenerator::GenerateParsingCode(io::Printer* printer) { printer->Print(variables_, - "input.Read$capitalized_type_name$Array(tag, $name$_);\n"); + "input.Read$capitalized_type_name$Array($name$_);\n"); } void RepeatedPrimitiveFieldGenerator::GenerateSerializationCode( -- cgit v1.2.3 From 8e9dd12b3a2a30dacf3b782d4062c43ec68ff2f6 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Fri, 19 Jun 2015 17:33:20 +0100 Subject: Update the readme to give more context of what's going on. --- csharp/README.md | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/csharp/README.md b/csharp/README.md index d6948280..72f55521 100644 --- a/csharp/README.md +++ b/csharp/README.md @@ -1,13 +1,25 @@ - This directory contains the C# Protocol Buffers runtime library. +Warning: experimental! +====================== + +This code is still under significant churn. Unlike the original port, +it only supports proto3 (but not *all* of proto3 yet) - there are no +unknown fields or extensions, for example. protoc will (eventually) +deliberately fail if it is asked to generate C# code for proto2 +messages other than descriptor.proto, which is still required for +reflection. (It's currently exposed publicly, but won't be +eventually.) + +Also unlike the original port, the new version embraces mutability - +there are no builder types. We plan to add "freezing" operations as +well as cloning, however. + Usage ===== The easiest way to use C# protocol buffers in your project is to use the [Google.ProtocolBuffers NuGet package](http://www.nuget.org/packages/Google.ProtocolBuffers/). This package is the legacy package for C# protocol buffers, but it will work fine with C# code generated by `protoc` if you use proto2 syntax (The API of the runtime library haven't changed so far). -*WARNING: If you specify `syntax = "proto3";` in your .proto files, the generated code won't necessarily work with the legacy NuGet package. So before we officially add proto3 support, always use `syntax = "proto2";` (the default) in your protos.* - We will definitely release a new NuGet package for the runtime library in the future. The new runtime library WILL contain significant semantic, backwardly-incompatible changes in proto handling (mostly because we will be adding proto3 support and we will be using that oportunity to make some design changes). So keep in mind that you will need to regenerate your proto files and switch to a new NuGet package once the new version of runtime library becomes available. Building @@ -17,17 +29,6 @@ Open the `src/ProtocolBuffers.sln` solution in Visual Studio. Click "Build solut Supported Visual Studio versions are VS2013 (update 4) and VS2015. On Linux, you can also use Monodevelop 5.9 (older versions might work fine). -Proto2 & Proto3 -=============== - -*WARNING: Only proto2 is supported for now, proto3 is under construction.* - -C# protocol buffers are currently under development and you should expect semantic, backward-incompatible changes in the future. - -Also, as of now, only proto2 is supported. Proto3 support for C# is currently in progress -(both design & implementation) and you should not expect any of the proto3 features to work. -In fact, always use `syntax = "proto2";` in your .proto files for now, unless you are feeling like experimenting. - History of C# protobufs ======================= -- cgit v1.2.3 From 6c1fe6ea3e4e3915fc4164c43230210f9a0ac24f Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Tue, 23 Jun 2015 11:54:19 +0100 Subject: Implement Clone. Fixes issue #527. --- csharp/src/AddressBook/Addressbook.cs | 34 +- .../ProtocolBuffers.Test/GeneratedMessageTest.cs | 124 +++++- .../TestProtos/UnittestImportProto3.cs | 10 +- .../TestProtos/UnittestImportPublicProto3.cs | 10 +- .../TestProtos/UnittestIssues.cs | 46 ++- .../TestProtos/UnittestProto3.cs | 459 +++++++++++++++++---- csharp/src/ProtocolBuffers/ByteString.cs | 2 +- .../ProtocolBuffers/Collections/RepeatedField.cs | 30 ++ .../DescriptorProtos/DescriptorProtoFile.cs | 301 ++++++++++++-- csharp/src/ProtocolBuffers/IMessage.cs | 18 + .../protobuf/compiler/csharp/csharp_field_base.h | 1 + .../protobuf/compiler/csharp/csharp_message.cc | 59 ++- .../protobuf/compiler/csharp/csharp_message.h | 1 + .../compiler/csharp/csharp_message_field.cc | 10 + .../compiler/csharp/csharp_message_field.h | 2 + .../compiler/csharp/csharp_primitive_field.cc | 10 + .../compiler/csharp/csharp_primitive_field.h | 2 + .../compiler/csharp/csharp_repeated_enum_field.cc | 5 + .../compiler/csharp/csharp_repeated_enum_field.h | 1 + .../csharp/csharp_repeated_message_field.cc | 5 + .../csharp/csharp_repeated_message_field.h | 1 + .../csharp/csharp_repeated_primitive_field.cc | 5 + .../csharp/csharp_repeated_primitive_field.h | 1 + 23 files changed, 988 insertions(+), 149 deletions(-) diff --git a/csharp/src/AddressBook/Addressbook.cs b/csharp/src/AddressBook/Addressbook.cs index 322f85f7..cf09bc4c 100644 --- a/csharp/src/AddressBook/Addressbook.cs +++ b/csharp/src/AddressBook/Addressbook.cs @@ -62,7 +62,7 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { } #region Messages [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Person : pb::IMessage, global::System.IEquatable { + public sealed partial class Person : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Person()); public static pb::MessageParser Parser { get { return _parser; } } @@ -77,9 +77,18 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { } public Person() { } + public Person(Person other) { - MergeFrom(other); + name_ = other.name_; + id_ = other.id_; + email_ = other.email_; + phone_ = other.phone_.Clone(); + } + + public Person Clone() { + return new Person(this); } + public const int NameFieldNumber = 1; private string name_ = ""; public string Name { @@ -231,7 +240,7 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class PhoneNumber : pb::IMessage, global::System.IEquatable { + public sealed partial class PhoneNumber : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new PhoneNumber()); public static pb::MessageParser Parser { get { return _parser; } } @@ -246,9 +255,16 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { } public PhoneNumber() { } + public PhoneNumber(PhoneNumber other) { - MergeFrom(other); + number_ = other.number_; + type_ = other.type_; + } + + public PhoneNumber Clone() { + return new PhoneNumber(this); } + public const int NumberFieldNumber = 1; private string number_ = ""; public string Number { @@ -352,7 +368,7 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class AddressBook : pb::IMessage, global::System.IEquatable { + public sealed partial class AddressBook : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new AddressBook()); public static pb::MessageParser Parser { get { return _parser; } } @@ -367,9 +383,15 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { } public AddressBook() { } + public AddressBook(AddressBook other) { - MergeFrom(other); + person_ = other.person_.Clone(); } + + public AddressBook Clone() { + return new AddressBook(this); + } + public const int PersonFieldNumber = 1; private readonly pbc::RepeatedField person_ = new pbc::RepeatedField(); public pbc::RepeatedField Person { diff --git a/csharp/src/ProtocolBuffers.Test/GeneratedMessageTest.cs b/csharp/src/ProtocolBuffers.Test/GeneratedMessageTest.cs index c5564060..e21d904d 100644 --- a/csharp/src/ProtocolBuffers.Test/GeneratedMessageTest.cs +++ b/csharp/src/ProtocolBuffers.Test/GeneratedMessageTest.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Google.Protobuf.TestProtos; +using Google.Protobuf.TestProtos; using NUnit.Framework; namespace Google.Protobuf @@ -88,7 +83,7 @@ namespace Google.Protobuf var message = new TestAllTypes { SingleBool = true, - SingleBytes = ByteString.CopyFrom(new byte[] { 1, 2, 3, 4 }), + SingleBytes = ByteString.CopyFrom(1, 2, 3, 4), SingleDouble = 23.5, SingleFixed32 = 23, SingleFixed64 = 1234567890123, @@ -122,7 +117,7 @@ namespace Google.Protobuf var message = new TestAllTypes { RepeatedBool = { true, false }, - RepeatedBytes = { ByteString.CopyFrom(new byte[] { 1, 2, 3, 4 }), ByteString.CopyFrom(new byte[] { 5, 6 }) }, + RepeatedBytes = { ByteString.CopyFrom(1, 2, 3, 4), ByteString.CopyFrom(5, 6) }, RepeatedDouble = { -12.25, 23.5 }, RepeatedFixed32 = { uint.MaxValue, 23 }, RepeatedFixed64 = { ulong.MaxValue, 1234567890123 }, @@ -149,5 +144,118 @@ namespace Google.Protobuf TestAllTypes parsed = TestAllTypes.Parser.ParseFrom(bytes); Assert.AreEqual(message, parsed); } + + [Test] + public void CloneSingleNonMessageValues() + { + var original = new TestAllTypes + { + SingleBool = true, + SingleBytes = ByteString.CopyFrom(1, 2, 3, 4), + SingleDouble = 23.5, + SingleFixed32 = 23, + SingleFixed64 = 1234567890123, + SingleFloat = 12.25f, + SingleInt32 = 100, + SingleInt64 = 3210987654321, + SingleNestedEnum = TestAllTypes.Types.NestedEnum.FOO, + SingleSfixed32 = -123, + SingleSfixed64 = -12345678901234, + SingleSint32 = -456, + SingleSint64 = -12345678901235, + SingleString = "test", + SingleUint32 = uint.MaxValue, + SingleUint64 = ulong.MaxValue + }; + var clone = original.Clone(); + Assert.AreNotSame(original, clone); + Assert.AreEqual(original, clone); + // Just as a single example + clone.SingleInt32 = 150; + Assert.AreNotEqual(original, clone); + } + + [Test] + public void CloneRepeatedNonMessageValues() + { + var original = new TestAllTypes + { + RepeatedBool = { true, false }, + RepeatedBytes = { ByteString.CopyFrom(1, 2, 3, 4), ByteString.CopyFrom(5, 6) }, + RepeatedDouble = { -12.25, 23.5 }, + RepeatedFixed32 = { uint.MaxValue, 23 }, + RepeatedFixed64 = { ulong.MaxValue, 1234567890123 }, + RepeatedFloat = { 100f, 12.25f }, + RepeatedInt32 = { 100, 200 }, + RepeatedInt64 = { 3210987654321, long.MaxValue }, + RepeatedNestedEnum = { TestAllTypes.Types.NestedEnum.FOO, TestAllTypes.Types.NestedEnum.NEG }, + RepeatedSfixed32 = { -123, 123 }, + RepeatedSfixed64 = { -12345678901234, 12345678901234 }, + RepeatedSint32 = { -456, 100 }, + RepeatedSint64 = { -12345678901235, 123 }, + RepeatedString = { "foo", "bar" }, + RepeatedUint32 = { uint.MaxValue, uint.MinValue }, + RepeatedUint64 = { ulong.MaxValue, uint.MinValue } + }; + + var clone = original.Clone(); + Assert.AreNotSame(original, clone); + Assert.AreEqual(original, clone); + // Just as a single example + clone.RepeatedDouble.Add(25.5); + Assert.AreNotEqual(original, clone); + } + + [Test] + public void CloneSingleMessageField() + { + var original = new TestAllTypes + { + SingleNestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 20 } + }; + + var clone = original.Clone(); + Assert.AreNotSame(original, clone); + Assert.AreNotSame(original.SingleNestedMessage, clone.SingleNestedMessage); + Assert.AreEqual(original, clone); + + clone.SingleNestedMessage.Bb = 30; + Assert.AreNotEqual(original, clone); + } + + [Test] + public void CloneRepeatedMessageField() + { + var original = new TestAllTypes + { + RepeatedNestedMessage = { new TestAllTypes.Types.NestedMessage { Bb = 20 } } + }; + + var clone = original.Clone(); + Assert.AreNotSame(original, clone); + Assert.AreNotSame(original.RepeatedNestedMessage, clone.RepeatedNestedMessage); + Assert.AreNotSame(original.RepeatedNestedMessage[0], clone.RepeatedNestedMessage[0]); + Assert.AreEqual(original, clone); + + clone.RepeatedNestedMessage[0].Bb = 30; + Assert.AreNotEqual(original, clone); + } + + [Test] + public void CloneOneofField() + { + var original = new TestAllTypes + { + OneofNestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 20 } + }; + + var clone = original.Clone(); + Assert.AreNotSame(original, clone); + Assert.AreEqual(original, clone); + + // We should have cloned the message + original.OneofNestedMessage.Bb = 30; + Assert.AreNotEqual(original, clone); + } } } diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportProto3.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportProto3.cs index e048f65c..0b8a9dd3 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportProto3.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportProto3.cs @@ -60,7 +60,7 @@ namespace Google.Protobuf.TestProtos { #region Messages [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class ImportMessage : pb::IMessage, global::System.IEquatable { + public sealed partial class ImportMessage : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ImportMessage()); public static pb::MessageParser Parser { get { return _parser; } } @@ -75,9 +75,15 @@ namespace Google.Protobuf.TestProtos { } public ImportMessage() { } + public ImportMessage(ImportMessage other) { - MergeFrom(other); + d_ = other.d_; + } + + public ImportMessage Clone() { + return new ImportMessage(this); } + public const int DFieldNumber = 1; private int d_; public int D { diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportPublicProto3.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportPublicProto3.cs index 5d9f0b7a..b634ccff 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportPublicProto3.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportPublicProto3.cs @@ -45,7 +45,7 @@ namespace Google.Protobuf.TestProtos { } #region Messages [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class PublicImportMessage : pb::IMessage, global::System.IEquatable { + public sealed partial class PublicImportMessage : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new PublicImportMessage()); public static pb::MessageParser Parser { get { return _parser; } } @@ -60,9 +60,15 @@ namespace Google.Protobuf.TestProtos { } public PublicImportMessage() { } + public PublicImportMessage(PublicImportMessage other) { - MergeFrom(other); + e_ = other.e_; + } + + public PublicImportMessage Clone() { + return new PublicImportMessage(this); } + public const int EFieldNumber = 1; private int e_; public int E { diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs index 959b3866..df149323 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs @@ -90,7 +90,7 @@ namespace UnitTest.Issues.TestProtos { #region Messages [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class NegativeEnumMessage : pb::IMessage, global::System.IEquatable { + public sealed partial class NegativeEnumMessage : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NegativeEnumMessage()); public static pb::MessageParser Parser { get { return _parser; } } @@ -105,9 +105,17 @@ namespace UnitTest.Issues.TestProtos { } public NegativeEnumMessage() { } + public NegativeEnumMessage(NegativeEnumMessage other) { - MergeFrom(other); + value_ = other.value_; + values_ = other.values_.Clone(); + packedValues_ = other.packedValues_.Clone(); + } + + public NegativeEnumMessage Clone() { + return new NegativeEnumMessage(this); } + public const int ValueFieldNumber = 1; private global::UnitTest.Issues.TestProtos.NegativeEnum value_ = global::UnitTest.Issues.TestProtos.NegativeEnum.NEGATIVE_ENUM_ZERO; public global::UnitTest.Issues.TestProtos.NegativeEnum Value { @@ -233,7 +241,7 @@ namespace UnitTest.Issues.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class DeprecatedChild : pb::IMessage, global::System.IEquatable { + public sealed partial class DeprecatedChild : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new DeprecatedChild()); public static pb::MessageParser Parser { get { return _parser; } } @@ -248,9 +256,14 @@ namespace UnitTest.Issues.TestProtos { } public DeprecatedChild() { } + public DeprecatedChild(DeprecatedChild other) { - MergeFrom(other); } + + public DeprecatedChild Clone() { + return new DeprecatedChild(this); + } + public override bool Equals(object other) { return Equals(other as DeprecatedChild); } @@ -301,7 +314,7 @@ namespace UnitTest.Issues.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class DeprecatedFieldsMessage : pb::IMessage, global::System.IEquatable { + public sealed partial class DeprecatedFieldsMessage : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new DeprecatedFieldsMessage()); public static pb::MessageParser Parser { get { return _parser; } } @@ -316,9 +329,20 @@ namespace UnitTest.Issues.TestProtos { } public DeprecatedFieldsMessage() { } + public DeprecatedFieldsMessage(DeprecatedFieldsMessage other) { - MergeFrom(other); + primitiveValue_ = other.primitiveValue_; + primitiveArray_ = other.primitiveArray_.Clone(); + MessageValue = other.messageValue_ != null ? other.MessageValue.Clone() : null; + messageArray_ = other.messageArray_.Clone(); + enumValue_ = other.enumValue_; + enumArray_ = other.enumArray_.Clone(); + } + + public DeprecatedFieldsMessage Clone() { + return new DeprecatedFieldsMessage(this); } + public const int PrimitiveValueFieldNumber = 1; private int primitiveValue_; [global::System.ObsoleteAttribute()] @@ -525,7 +549,7 @@ namespace UnitTest.Issues.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class ItemField : pb::IMessage, global::System.IEquatable { + public sealed partial class ItemField : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ItemField()); public static pb::MessageParser Parser { get { return _parser; } } @@ -540,9 +564,15 @@ namespace UnitTest.Issues.TestProtos { } public ItemField() { } + public ItemField(ItemField other) { - MergeFrom(other); + item_ = other.item_; + } + + public ItemField Clone() { + return new ItemField(this); } + public const int ItemFieldNumber = 1; private int item_; public int Item { diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs index bbfa8c3e..1fab6737 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs @@ -402,7 +402,7 @@ namespace Google.Protobuf.TestProtos { #region Messages [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestAllTypes : pb::IMessage, global::System.IEquatable { + public sealed partial class TestAllTypes : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestAllTypes()); public static pb::MessageParser Parser { get { return _parser; } } @@ -417,9 +417,73 @@ namespace Google.Protobuf.TestProtos { } public TestAllTypes() { } + public TestAllTypes(TestAllTypes other) { - MergeFrom(other); + singleInt32_ = other.singleInt32_; + singleInt64_ = other.singleInt64_; + singleUint32_ = other.singleUint32_; + singleUint64_ = other.singleUint64_; + singleSint32_ = other.singleSint32_; + singleSint64_ = other.singleSint64_; + singleFixed32_ = other.singleFixed32_; + singleFixed64_ = other.singleFixed64_; + singleSfixed32_ = other.singleSfixed32_; + singleSfixed64_ = other.singleSfixed64_; + singleFloat_ = other.singleFloat_; + singleDouble_ = other.singleDouble_; + singleBool_ = other.singleBool_; + singleString_ = other.singleString_; + singleBytes_ = other.singleBytes_; + SingleNestedMessage = other.singleNestedMessage_ != null ? other.SingleNestedMessage.Clone() : null; + SingleForeignMessage = other.singleForeignMessage_ != null ? other.SingleForeignMessage.Clone() : null; + SingleImportMessage = other.singleImportMessage_ != null ? other.SingleImportMessage.Clone() : null; + singleNestedEnum_ = other.singleNestedEnum_; + singleForeignEnum_ = other.singleForeignEnum_; + singleImportEnum_ = other.singleImportEnum_; + SinglePublicImportMessage = other.singlePublicImportMessage_ != null ? other.SinglePublicImportMessage.Clone() : null; + repeatedInt32_ = other.repeatedInt32_.Clone(); + repeatedInt64_ = other.repeatedInt64_.Clone(); + repeatedUint32_ = other.repeatedUint32_.Clone(); + repeatedUint64_ = other.repeatedUint64_.Clone(); + repeatedSint32_ = other.repeatedSint32_.Clone(); + repeatedSint64_ = other.repeatedSint64_.Clone(); + repeatedFixed32_ = other.repeatedFixed32_.Clone(); + repeatedFixed64_ = other.repeatedFixed64_.Clone(); + repeatedSfixed32_ = other.repeatedSfixed32_.Clone(); + repeatedSfixed64_ = other.repeatedSfixed64_.Clone(); + repeatedFloat_ = other.repeatedFloat_.Clone(); + repeatedDouble_ = other.repeatedDouble_.Clone(); + repeatedBool_ = other.repeatedBool_.Clone(); + repeatedString_ = other.repeatedString_.Clone(); + repeatedBytes_ = other.repeatedBytes_.Clone(); + repeatedNestedMessage_ = other.repeatedNestedMessage_.Clone(); + repeatedForeignMessage_ = other.repeatedForeignMessage_.Clone(); + repeatedImportMessage_ = other.repeatedImportMessage_.Clone(); + repeatedNestedEnum_ = other.repeatedNestedEnum_.Clone(); + repeatedForeignEnum_ = other.repeatedForeignEnum_.Clone(); + repeatedImportEnum_ = other.repeatedImportEnum_.Clone(); + repeatedPublicImportMessage_ = other.repeatedPublicImportMessage_.Clone(); + switch (other.OneofFieldCase) { + case OneofFieldOneofCase.OneofUint32: + OneofUint32 = other.OneofUint32; + break; + case OneofFieldOneofCase.OneofNestedMessage: + OneofNestedMessage = other.OneofNestedMessage.Clone(); + break; + case OneofFieldOneofCase.OneofString: + OneofString = other.OneofString; + break; + case OneofFieldOneofCase.OneofBytes: + OneofBytes = other.OneofBytes; + break; + } + + } + + public TestAllTypes Clone() { + return new TestAllTypes(this); } + public const int SingleInt32FieldNumber = 1; private int singleInt32_; public int SingleInt32 { @@ -1686,7 +1750,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class NestedMessage : pb::IMessage, global::System.IEquatable { + public sealed partial class NestedMessage : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedMessage()); public static pb::MessageParser Parser { get { return _parser; } } @@ -1701,9 +1765,15 @@ namespace Google.Protobuf.TestProtos { } public NestedMessage() { } + public NestedMessage(NestedMessage other) { - MergeFrom(other); + bb_ = other.bb_; + } + + public NestedMessage Clone() { + return new NestedMessage(this); } + public const int BbFieldNumber = 1; private int bb_; public int Bb { @@ -1783,7 +1853,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class NestedTestAllTypes : pb::IMessage, global::System.IEquatable { + public sealed partial class NestedTestAllTypes : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedTestAllTypes()); public static pb::MessageParser Parser { get { return _parser; } } @@ -1798,9 +1868,17 @@ namespace Google.Protobuf.TestProtos { } public NestedTestAllTypes() { } + public NestedTestAllTypes(NestedTestAllTypes other) { - MergeFrom(other); + Child = other.child_ != null ? other.Child.Clone() : null; + Payload = other.payload_ != null ? other.Payload.Clone() : null; + repeatedChild_ = other.repeatedChild_.Clone(); } + + public NestedTestAllTypes Clone() { + return new NestedTestAllTypes(this); + } + public const int ChildFieldNumber = 1; private global::Google.Protobuf.TestProtos.NestedTestAllTypes child_; public global::Google.Protobuf.TestProtos.NestedTestAllTypes Child { @@ -1929,7 +2007,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestDeprecatedFields : pb::IMessage, global::System.IEquatable { + public sealed partial class TestDeprecatedFields : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestDeprecatedFields()); public static pb::MessageParser Parser { get { return _parser; } } @@ -1944,9 +2022,15 @@ namespace Google.Protobuf.TestProtos { } public TestDeprecatedFields() { } + public TestDeprecatedFields(TestDeprecatedFields other) { - MergeFrom(other); + deprecatedInt32_ = other.deprecatedInt32_; + } + + public TestDeprecatedFields Clone() { + return new TestDeprecatedFields(this); } + public const int DeprecatedInt32FieldNumber = 1; private int deprecatedInt32_; [global::System.ObsoleteAttribute()] @@ -2022,7 +2106,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class ForeignMessage : pb::IMessage, global::System.IEquatable { + public sealed partial class ForeignMessage : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ForeignMessage()); public static pb::MessageParser Parser { get { return _parser; } } @@ -2037,9 +2121,15 @@ namespace Google.Protobuf.TestProtos { } public ForeignMessage() { } + public ForeignMessage(ForeignMessage other) { - MergeFrom(other); + c_ = other.c_; } + + public ForeignMessage Clone() { + return new ForeignMessage(this); + } + public const int CFieldNumber = 1; private int c_; public int C { @@ -2114,7 +2204,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestReservedFields : pb::IMessage, global::System.IEquatable { + public sealed partial class TestReservedFields : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestReservedFields()); public static pb::MessageParser Parser { get { return _parser; } } @@ -2129,9 +2219,14 @@ namespace Google.Protobuf.TestProtos { } public TestReservedFields() { } + public TestReservedFields(TestReservedFields other) { - MergeFrom(other); } + + public TestReservedFields Clone() { + return new TestReservedFields(this); + } + public override bool Equals(object other) { return Equals(other as TestReservedFields); } @@ -2182,7 +2277,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestForeignNested : pb::IMessage, global::System.IEquatable { + public sealed partial class TestForeignNested : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestForeignNested()); public static pb::MessageParser Parser { get { return _parser; } } @@ -2197,9 +2292,15 @@ namespace Google.Protobuf.TestProtos { } public TestForeignNested() { } + public TestForeignNested(TestForeignNested other) { - MergeFrom(other); + ForeignNested = other.foreignNested_ != null ? other.ForeignNested.Clone() : null; + } + + public TestForeignNested Clone() { + return new TestForeignNested(this); } + public const int ForeignNestedFieldNumber = 1; private global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage foreignNested_; public global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage ForeignNested { @@ -2278,7 +2379,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestReallyLargeTagNumber : pb::IMessage, global::System.IEquatable { + public sealed partial class TestReallyLargeTagNumber : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestReallyLargeTagNumber()); public static pb::MessageParser Parser { get { return _parser; } } @@ -2293,9 +2394,16 @@ namespace Google.Protobuf.TestProtos { } public TestReallyLargeTagNumber() { } + public TestReallyLargeTagNumber(TestReallyLargeTagNumber other) { - MergeFrom(other); + a_ = other.a_; + bb_ = other.bb_; } + + public TestReallyLargeTagNumber Clone() { + return new TestReallyLargeTagNumber(this); + } + public const int AFieldNumber = 1; private int a_; public int A { @@ -2394,7 +2502,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestRecursiveMessage : pb::IMessage, global::System.IEquatable { + public sealed partial class TestRecursiveMessage : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestRecursiveMessage()); public static pb::MessageParser Parser { get { return _parser; } } @@ -2409,9 +2517,16 @@ namespace Google.Protobuf.TestProtos { } public TestRecursiveMessage() { } + public TestRecursiveMessage(TestRecursiveMessage other) { - MergeFrom(other); + A = other.a_ != null ? other.A.Clone() : null; + i_ = other.i_; + } + + public TestRecursiveMessage Clone() { + return new TestRecursiveMessage(this); } + public const int AFieldNumber = 1; private global::Google.Protobuf.TestProtos.TestRecursiveMessage a_; public global::Google.Protobuf.TestProtos.TestRecursiveMessage A { @@ -2514,7 +2629,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestMutualRecursionA : pb::IMessage, global::System.IEquatable { + public sealed partial class TestMutualRecursionA : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestMutualRecursionA()); public static pb::MessageParser Parser { get { return _parser; } } @@ -2529,9 +2644,15 @@ namespace Google.Protobuf.TestProtos { } public TestMutualRecursionA() { } + public TestMutualRecursionA(TestMutualRecursionA other) { - MergeFrom(other); + Bb = other.bb_ != null ? other.Bb.Clone() : null; } + + public TestMutualRecursionA Clone() { + return new TestMutualRecursionA(this); + } + public const int BbFieldNumber = 1; private global::Google.Protobuf.TestProtos.TestMutualRecursionB bb_; public global::Google.Protobuf.TestProtos.TestMutualRecursionB Bb { @@ -2610,7 +2731,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestMutualRecursionB : pb::IMessage, global::System.IEquatable { + public sealed partial class TestMutualRecursionB : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestMutualRecursionB()); public static pb::MessageParser Parser { get { return _parser; } } @@ -2625,9 +2746,16 @@ namespace Google.Protobuf.TestProtos { } public TestMutualRecursionB() { } + public TestMutualRecursionB(TestMutualRecursionB other) { - MergeFrom(other); + A = other.a_ != null ? other.A.Clone() : null; + optionalInt32_ = other.optionalInt32_; + } + + public TestMutualRecursionB Clone() { + return new TestMutualRecursionB(this); } + public const int AFieldNumber = 1; private global::Google.Protobuf.TestProtos.TestMutualRecursionA a_; public global::Google.Protobuf.TestProtos.TestMutualRecursionA A { @@ -2730,7 +2858,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestCamelCaseFieldNames : pb::IMessage, global::System.IEquatable { + public sealed partial class TestCamelCaseFieldNames : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestCamelCaseFieldNames()); public static pb::MessageParser Parser { get { return _parser; } } @@ -2745,9 +2873,22 @@ namespace Google.Protobuf.TestProtos { } public TestCamelCaseFieldNames() { } + public TestCamelCaseFieldNames(TestCamelCaseFieldNames other) { - MergeFrom(other); + primitiveField_ = other.primitiveField_; + stringField_ = other.stringField_; + enumField_ = other.enumField_; + MessageField = other.messageField_ != null ? other.MessageField.Clone() : null; + repeatedPrimitiveField_ = other.repeatedPrimitiveField_.Clone(); + repeatedStringField_ = other.repeatedStringField_.Clone(); + repeatedEnumField_ = other.repeatedEnumField_.Clone(); + repeatedMessageField_ = other.repeatedMessageField_.Clone(); + } + + public TestCamelCaseFieldNames Clone() { + return new TestCamelCaseFieldNames(this); } + public const int PrimitiveFieldFieldNumber = 1; private int primitiveField_; public int PrimitiveField { @@ -2996,7 +3137,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestFieldOrderings : pb::IMessage, global::System.IEquatable { + public sealed partial class TestFieldOrderings : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestFieldOrderings()); public static pb::MessageParser Parser { get { return _parser; } } @@ -3011,9 +3152,18 @@ namespace Google.Protobuf.TestProtos { } public TestFieldOrderings() { } + public TestFieldOrderings(TestFieldOrderings other) { - MergeFrom(other); + myString_ = other.myString_; + myInt_ = other.myInt_; + myFloat_ = other.myFloat_; + SingleNestedMessage = other.singleNestedMessage_ != null ? other.SingleNestedMessage.Clone() : null; } + + public TestFieldOrderings Clone() { + return new TestFieldOrderings(this); + } + public const int MyStringFieldNumber = 11; private string myString_ = ""; public string MyString { @@ -3165,7 +3315,7 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class Types { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class NestedMessage : pb::IMessage, global::System.IEquatable { + public sealed partial class NestedMessage : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedMessage()); public static pb::MessageParser Parser { get { return _parser; } } @@ -3180,9 +3330,16 @@ namespace Google.Protobuf.TestProtos { } public NestedMessage() { } + public NestedMessage(NestedMessage other) { - MergeFrom(other); + oo_ = other.oo_; + bb_ = other.bb_; + } + + public NestedMessage Clone() { + return new NestedMessage(this); } + public const int OoFieldNumber = 2; private long oo_; public long Oo { @@ -3286,7 +3443,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class SparseEnumMessage : pb::IMessage, global::System.IEquatable { + public sealed partial class SparseEnumMessage : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new SparseEnumMessage()); public static pb::MessageParser Parser { get { return _parser; } } @@ -3301,9 +3458,15 @@ namespace Google.Protobuf.TestProtos { } public SparseEnumMessage() { } + public SparseEnumMessage(SparseEnumMessage other) { - MergeFrom(other); + sparseEnum_ = other.sparseEnum_; } + + public SparseEnumMessage Clone() { + return new SparseEnumMessage(this); + } + public const int SparseEnumFieldNumber = 1; private global::Google.Protobuf.TestProtos.TestSparseEnum sparseEnum_ = global::Google.Protobuf.TestProtos.TestSparseEnum.TEST_SPARSE_ENUM_UNSPECIFIED; public global::Google.Protobuf.TestProtos.TestSparseEnum SparseEnum { @@ -3378,7 +3541,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class OneString : pb::IMessage, global::System.IEquatable { + public sealed partial class OneString : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new OneString()); public static pb::MessageParser Parser { get { return _parser; } } @@ -3393,9 +3556,15 @@ namespace Google.Protobuf.TestProtos { } public OneString() { } + public OneString(OneString other) { - MergeFrom(other); + data_ = other.data_; + } + + public OneString Clone() { + return new OneString(this); } + public const int DataFieldNumber = 1; private string data_ = ""; public string Data { @@ -3470,7 +3639,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MoreString : pb::IMessage, global::System.IEquatable { + public sealed partial class MoreString : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MoreString()); public static pb::MessageParser Parser { get { return _parser; } } @@ -3485,9 +3654,15 @@ namespace Google.Protobuf.TestProtos { } public MoreString() { } + public MoreString(MoreString other) { - MergeFrom(other); + data_ = other.data_.Clone(); + } + + public MoreString Clone() { + return new MoreString(this); } + public const int DataFieldNumber = 1; private readonly pbc::RepeatedField data_ = new pbc::RepeatedField(); public pbc::RepeatedField Data { @@ -3562,7 +3737,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class OneBytes : pb::IMessage, global::System.IEquatable { + public sealed partial class OneBytes : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new OneBytes()); public static pb::MessageParser Parser { get { return _parser; } } @@ -3577,9 +3752,15 @@ namespace Google.Protobuf.TestProtos { } public OneBytes() { } + public OneBytes(OneBytes other) { - MergeFrom(other); + data_ = other.data_; } + + public OneBytes Clone() { + return new OneBytes(this); + } + public const int DataFieldNumber = 1; private pb::ByteString data_ = pb::ByteString.Empty; public pb::ByteString Data { @@ -3654,7 +3835,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MoreBytes : pb::IMessage, global::System.IEquatable { + public sealed partial class MoreBytes : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MoreBytes()); public static pb::MessageParser Parser { get { return _parser; } } @@ -3669,9 +3850,15 @@ namespace Google.Protobuf.TestProtos { } public MoreBytes() { } + public MoreBytes(MoreBytes other) { - MergeFrom(other); + data_ = other.data_; + } + + public MoreBytes Clone() { + return new MoreBytes(this); } + public const int DataFieldNumber = 1; private pb::ByteString data_ = pb::ByteString.Empty; public pb::ByteString Data { @@ -3746,7 +3933,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Int32Message : pb::IMessage, global::System.IEquatable { + public sealed partial class Int32Message : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Int32Message()); public static pb::MessageParser Parser { get { return _parser; } } @@ -3761,9 +3948,15 @@ namespace Google.Protobuf.TestProtos { } public Int32Message() { } + public Int32Message(Int32Message other) { - MergeFrom(other); + data_ = other.data_; } + + public Int32Message Clone() { + return new Int32Message(this); + } + public const int DataFieldNumber = 1; private int data_; public int Data { @@ -3838,7 +4031,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Uint32Message : pb::IMessage, global::System.IEquatable { + public sealed partial class Uint32Message : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Uint32Message()); public static pb::MessageParser Parser { get { return _parser; } } @@ -3853,9 +4046,15 @@ namespace Google.Protobuf.TestProtos { } public Uint32Message() { } + public Uint32Message(Uint32Message other) { - MergeFrom(other); + data_ = other.data_; + } + + public Uint32Message Clone() { + return new Uint32Message(this); } + public const int DataFieldNumber = 1; private uint data_; public uint Data { @@ -3930,7 +4129,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Int64Message : pb::IMessage, global::System.IEquatable { + public sealed partial class Int64Message : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Int64Message()); public static pb::MessageParser Parser { get { return _parser; } } @@ -3945,9 +4144,15 @@ namespace Google.Protobuf.TestProtos { } public Int64Message() { } + public Int64Message(Int64Message other) { - MergeFrom(other); + data_ = other.data_; + } + + public Int64Message Clone() { + return new Int64Message(this); } + public const int DataFieldNumber = 1; private long data_; public long Data { @@ -4022,7 +4227,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Uint64Message : pb::IMessage, global::System.IEquatable { + public sealed partial class Uint64Message : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Uint64Message()); public static pb::MessageParser Parser { get { return _parser; } } @@ -4037,9 +4242,15 @@ namespace Google.Protobuf.TestProtos { } public Uint64Message() { } + public Uint64Message(Uint64Message other) { - MergeFrom(other); + data_ = other.data_; } + + public Uint64Message Clone() { + return new Uint64Message(this); + } + public const int DataFieldNumber = 1; private ulong data_; public ulong Data { @@ -4114,7 +4325,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class BoolMessage : pb::IMessage, global::System.IEquatable { + public sealed partial class BoolMessage : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new BoolMessage()); public static pb::MessageParser Parser { get { return _parser; } } @@ -4129,9 +4340,15 @@ namespace Google.Protobuf.TestProtos { } public BoolMessage() { } + public BoolMessage(BoolMessage other) { - MergeFrom(other); + data_ = other.data_; + } + + public BoolMessage Clone() { + return new BoolMessage(this); } + public const int DataFieldNumber = 1; private bool data_; public bool Data { @@ -4206,7 +4423,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestOneof : pb::IMessage, global::System.IEquatable { + public sealed partial class TestOneof : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestOneof()); public static pb::MessageParser Parser { get { return _parser; } } @@ -4221,9 +4438,26 @@ namespace Google.Protobuf.TestProtos { } public TestOneof() { } + public TestOneof(TestOneof other) { - MergeFrom(other); + switch (other.FooCase) { + case FooOneofCase.FooInt: + FooInt = other.FooInt; + break; + case FooOneofCase.FooString: + FooString = other.FooString; + break; + case FooOneofCase.FooMessage: + FooMessage = other.FooMessage.Clone(); + break; + } + + } + + public TestOneof Clone() { + return new TestOneof(this); } + public const int FooIntFieldNumber = 1; public int FooInt { get { return fooCase_ == FooOneofCase.FooInt ? (int) foo_ : 0; } @@ -4373,7 +4607,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestPackedTypes : pb::IMessage, global::System.IEquatable { + public sealed partial class TestPackedTypes : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestPackedTypes()); public static pb::MessageParser Parser { get { return _parser; } } @@ -4388,9 +4622,28 @@ namespace Google.Protobuf.TestProtos { } public TestPackedTypes() { } + public TestPackedTypes(TestPackedTypes other) { - MergeFrom(other); + packedInt32_ = other.packedInt32_.Clone(); + packedInt64_ = other.packedInt64_.Clone(); + packedUint32_ = other.packedUint32_.Clone(); + packedUint64_ = other.packedUint64_.Clone(); + packedSint32_ = other.packedSint32_.Clone(); + packedSint64_ = other.packedSint64_.Clone(); + packedFixed32_ = other.packedFixed32_.Clone(); + packedFixed64_ = other.packedFixed64_.Clone(); + packedSfixed32_ = other.packedSfixed32_.Clone(); + packedSfixed64_ = other.packedSfixed64_.Clone(); + packedFloat_ = other.packedFloat_.Clone(); + packedDouble_ = other.packedDouble_.Clone(); + packedBool_ = other.packedBool_.Clone(); + packedEnum_ = other.packedEnum_.Clone(); + } + + public TestPackedTypes Clone() { + return new TestPackedTypes(this); } + public const int PackedInt32FieldNumber = 90; private readonly pbc::RepeatedField packedInt32_ = new pbc::RepeatedField(); public pbc::RepeatedField PackedInt32 { @@ -4791,7 +5044,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestUnpackedTypes : pb::IMessage, global::System.IEquatable { + public sealed partial class TestUnpackedTypes : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestUnpackedTypes()); public static pb::MessageParser Parser { get { return _parser; } } @@ -4806,9 +5059,28 @@ namespace Google.Protobuf.TestProtos { } public TestUnpackedTypes() { } + public TestUnpackedTypes(TestUnpackedTypes other) { - MergeFrom(other); + unpackedInt32_ = other.unpackedInt32_.Clone(); + unpackedInt64_ = other.unpackedInt64_.Clone(); + unpackedUint32_ = other.unpackedUint32_.Clone(); + unpackedUint64_ = other.unpackedUint64_.Clone(); + unpackedSint32_ = other.unpackedSint32_.Clone(); + unpackedSint64_ = other.unpackedSint64_.Clone(); + unpackedFixed32_ = other.unpackedFixed32_.Clone(); + unpackedFixed64_ = other.unpackedFixed64_.Clone(); + unpackedSfixed32_ = other.unpackedSfixed32_.Clone(); + unpackedSfixed64_ = other.unpackedSfixed64_.Clone(); + unpackedFloat_ = other.unpackedFloat_.Clone(); + unpackedDouble_ = other.unpackedDouble_.Clone(); + unpackedBool_ = other.unpackedBool_.Clone(); + unpackedEnum_ = other.unpackedEnum_.Clone(); + } + + public TestUnpackedTypes Clone() { + return new TestUnpackedTypes(this); } + public const int UnpackedInt32FieldNumber = 90; private readonly pbc::RepeatedField unpackedInt32_ = new pbc::RepeatedField(); public pbc::RepeatedField UnpackedInt32 { @@ -5195,7 +5467,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestRepeatedScalarDifferentTagSizes : pb::IMessage, global::System.IEquatable { + public sealed partial class TestRepeatedScalarDifferentTagSizes : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestRepeatedScalarDifferentTagSizes()); public static pb::MessageParser Parser { get { return _parser; } } @@ -5210,9 +5482,20 @@ namespace Google.Protobuf.TestProtos { } public TestRepeatedScalarDifferentTagSizes() { } + public TestRepeatedScalarDifferentTagSizes(TestRepeatedScalarDifferentTagSizes other) { - MergeFrom(other); + repeatedFixed32_ = other.repeatedFixed32_.Clone(); + repeatedInt32_ = other.repeatedInt32_.Clone(); + repeatedFixed64_ = other.repeatedFixed64_.Clone(); + repeatedInt64_ = other.repeatedInt64_.Clone(); + repeatedFloat_ = other.repeatedFloat_.Clone(); + repeatedUint64_ = other.repeatedUint64_.Clone(); + } + + public TestRepeatedScalarDifferentTagSizes Clone() { + return new TestRepeatedScalarDifferentTagSizes(this); } + public const int RepeatedFixed32FieldNumber = 12; private readonly pbc::RepeatedField repeatedFixed32_ = new pbc::RepeatedField(); public pbc::RepeatedField RepeatedFixed32 { @@ -5413,7 +5696,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestCommentInjectionMessage : pb::IMessage, global::System.IEquatable { + public sealed partial class TestCommentInjectionMessage : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestCommentInjectionMessage()); public static pb::MessageParser Parser { get { return _parser; } } @@ -5428,9 +5711,15 @@ namespace Google.Protobuf.TestProtos { } public TestCommentInjectionMessage() { } + public TestCommentInjectionMessage(TestCommentInjectionMessage other) { - MergeFrom(other); + a_ = other.a_; + } + + public TestCommentInjectionMessage Clone() { + return new TestCommentInjectionMessage(this); } + public const int AFieldNumber = 1; private string a_ = ""; public string A { @@ -5505,7 +5794,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class FooRequest : pb::IMessage, global::System.IEquatable { + public sealed partial class FooRequest : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FooRequest()); public static pb::MessageParser Parser { get { return _parser; } } @@ -5520,9 +5809,14 @@ namespace Google.Protobuf.TestProtos { } public FooRequest() { } + public FooRequest(FooRequest other) { - MergeFrom(other); } + + public FooRequest Clone() { + return new FooRequest(this); + } + public override bool Equals(object other) { return Equals(other as FooRequest); } @@ -5573,7 +5867,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class FooResponse : pb::IMessage, global::System.IEquatable { + public sealed partial class FooResponse : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FooResponse()); public static pb::MessageParser Parser { get { return _parser; } } @@ -5588,9 +5882,14 @@ namespace Google.Protobuf.TestProtos { } public FooResponse() { } + public FooResponse(FooResponse other) { - MergeFrom(other); } + + public FooResponse Clone() { + return new FooResponse(this); + } + public override bool Equals(object other) { return Equals(other as FooResponse); } @@ -5641,7 +5940,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class FooClientMessage : pb::IMessage, global::System.IEquatable { + public sealed partial class FooClientMessage : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FooClientMessage()); public static pb::MessageParser Parser { get { return _parser; } } @@ -5656,9 +5955,14 @@ namespace Google.Protobuf.TestProtos { } public FooClientMessage() { } + public FooClientMessage(FooClientMessage other) { - MergeFrom(other); } + + public FooClientMessage Clone() { + return new FooClientMessage(this); + } + public override bool Equals(object other) { return Equals(other as FooClientMessage); } @@ -5709,7 +6013,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class FooServerMessage : pb::IMessage, global::System.IEquatable { + public sealed partial class FooServerMessage : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FooServerMessage()); public static pb::MessageParser Parser { get { return _parser; } } @@ -5724,9 +6028,14 @@ namespace Google.Protobuf.TestProtos { } public FooServerMessage() { } + public FooServerMessage(FooServerMessage other) { - MergeFrom(other); } + + public FooServerMessage Clone() { + return new FooServerMessage(this); + } + public override bool Equals(object other) { return Equals(other as FooServerMessage); } @@ -5777,7 +6086,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class BarRequest : pb::IMessage, global::System.IEquatable { + public sealed partial class BarRequest : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new BarRequest()); public static pb::MessageParser Parser { get { return _parser; } } @@ -5792,9 +6101,14 @@ namespace Google.Protobuf.TestProtos { } public BarRequest() { } + public BarRequest(BarRequest other) { - MergeFrom(other); } + + public BarRequest Clone() { + return new BarRequest(this); + } + public override bool Equals(object other) { return Equals(other as BarRequest); } @@ -5845,7 +6159,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class BarResponse : pb::IMessage, global::System.IEquatable { + public sealed partial class BarResponse : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new BarResponse()); public static pb::MessageParser Parser { get { return _parser; } } @@ -5860,9 +6174,14 @@ namespace Google.Protobuf.TestProtos { } public BarResponse() { } + public BarResponse(BarResponse other) { - MergeFrom(other); } + + public BarResponse Clone() { + return new BarResponse(this); + } + public override bool Equals(object other) { return Equals(other as BarResponse); } diff --git a/csharp/src/ProtocolBuffers/ByteString.cs b/csharp/src/ProtocolBuffers/ByteString.cs index 000914f0..e3a7ee50 100644 --- a/csharp/src/ProtocolBuffers/ByteString.cs +++ b/csharp/src/ProtocolBuffers/ByteString.cs @@ -139,7 +139,7 @@ namespace Google.Protobuf /// are copied, so further modifications to the array will not /// be reflected in the returned ByteString. /// - public static ByteString CopyFrom(byte[] bytes) + public static ByteString CopyFrom(params byte[] bytes) { return new ByteString((byte[]) bytes.Clone()); } diff --git a/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs b/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs index 25651784..5100e4db 100644 --- a/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs +++ b/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs @@ -12,6 +12,36 @@ namespace Google.Protobuf.Collections private T[] array = EmptyArray; private int count = 0; + /// + /// Creates a deep clone of this repeated field. + /// + /// + /// If the field type is + /// a message type, each element is also cloned; otherwise, it is + /// assumed that the field type is primitive (including string and + /// bytes, both of which are immutable) and so a simple copy is + /// equivalent to a deep clone. + /// + /// A deep clone of this repeated field. + public RepeatedField Clone() + { + RepeatedField clone = new RepeatedField(); + if (array != EmptyArray) + { + clone.array = (T[])array.Clone(); + IDeepCloneable[] cloneableArray = clone.array as IDeepCloneable[]; + if (cloneableArray != null) + { + for (int i = 0; i < count; i++) + { + clone.array[i] = cloneableArray[i].Clone(); + } + } + } + clone.count = count; + return clone; + } + private void EnsureSize(int size) { size = Math.Max(size, MinArraySize); diff --git a/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs b/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs index 7b7abd8e..0b966aea 100644 --- a/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs +++ b/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs @@ -278,7 +278,7 @@ namespace Google.Protobuf.DescriptorProtos { } #region Messages [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class FileDescriptorSet : pb::IMessage, global::System.IEquatable { + public sealed partial class FileDescriptorSet : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FileDescriptorSet()); public static pb::MessageParser Parser { get { return _parser; } } @@ -293,9 +293,15 @@ namespace Google.Protobuf.DescriptorProtos { } public FileDescriptorSet() { } + public FileDescriptorSet(FileDescriptorSet other) { - MergeFrom(other); + file_ = other.file_.Clone(); + } + + public FileDescriptorSet Clone() { + return new FileDescriptorSet(this); } + public const int FileFieldNumber = 1; private readonly pbc::RepeatedField file_ = new pbc::RepeatedField(); public pbc::RepeatedField File { @@ -368,7 +374,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class FileDescriptorProto : pb::IMessage, global::System.IEquatable { + public sealed partial class FileDescriptorProto : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FileDescriptorProto()); public static pb::MessageParser Parser { get { return _parser; } } @@ -383,9 +389,26 @@ namespace Google.Protobuf.DescriptorProtos { } public FileDescriptorProto() { } + public FileDescriptorProto(FileDescriptorProto other) { - MergeFrom(other); + name_ = other.name_; + package_ = other.package_; + dependency_ = other.dependency_.Clone(); + publicDependency_ = other.publicDependency_.Clone(); + weakDependency_ = other.weakDependency_.Clone(); + messageType_ = other.messageType_.Clone(); + enumType_ = other.enumType_.Clone(); + service_ = other.service_.Clone(); + extension_ = other.extension_.Clone(); + Options = other.options_ != null ? other.Options.Clone() : null; + SourceCodeInfo = other.sourceCodeInfo_ != null ? other.SourceCodeInfo.Clone() : null; + syntax_ = other.syntax_; } + + public FileDescriptorProto Clone() { + return new FileDescriptorProto(this); + } + public const int NameFieldNumber = 1; private string name_ = ""; public string Name { @@ -726,7 +749,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class DescriptorProto : pb::IMessage, global::System.IEquatable { + public sealed partial class DescriptorProto : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new DescriptorProto()); public static pb::MessageParser Parser { get { return _parser; } } @@ -741,9 +764,24 @@ namespace Google.Protobuf.DescriptorProtos { } public DescriptorProto() { } + public DescriptorProto(DescriptorProto other) { - MergeFrom(other); + name_ = other.name_; + field_ = other.field_.Clone(); + extension_ = other.extension_.Clone(); + nestedType_ = other.nestedType_.Clone(); + enumType_ = other.enumType_.Clone(); + extensionRange_ = other.extensionRange_.Clone(); + oneofDecl_ = other.oneofDecl_.Clone(); + Options = other.options_ != null ? other.Options.Clone() : null; + reservedRange_ = other.reservedRange_.Clone(); + reservedName_ = other.reservedName_.Clone(); + } + + public DescriptorProto Clone() { + return new DescriptorProto(this); } + public const int NameFieldNumber = 1; private string name_ = ""; public string Name { @@ -1025,7 +1063,7 @@ namespace Google.Protobuf.DescriptorProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class Types { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class ExtensionRange : pb::IMessage, global::System.IEquatable { + public sealed partial class ExtensionRange : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ExtensionRange()); public static pb::MessageParser Parser { get { return _parser; } } @@ -1040,9 +1078,16 @@ namespace Google.Protobuf.DescriptorProtos { } public ExtensionRange() { } + public ExtensionRange(ExtensionRange other) { - MergeFrom(other); + start_ = other.start_; + end_ = other.end_; + } + + public ExtensionRange Clone() { + return new ExtensionRange(this); } + public const int StartFieldNumber = 1; private int start_; public int Start { @@ -1141,7 +1186,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class ReservedRange : pb::IMessage, global::System.IEquatable { + public sealed partial class ReservedRange : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ReservedRange()); public static pb::MessageParser Parser { get { return _parser; } } @@ -1156,9 +1201,16 @@ namespace Google.Protobuf.DescriptorProtos { } public ReservedRange() { } + public ReservedRange(ReservedRange other) { - MergeFrom(other); + start_ = other.start_; + end_ = other.end_; } + + public ReservedRange Clone() { + return new ReservedRange(this); + } + public const int StartFieldNumber = 1; private int start_; public int Start { @@ -1262,7 +1314,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class FieldDescriptorProto : pb::IMessage, global::System.IEquatable { + public sealed partial class FieldDescriptorProto : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FieldDescriptorProto()); public static pb::MessageParser Parser { get { return _parser; } } @@ -1277,9 +1329,23 @@ namespace Google.Protobuf.DescriptorProtos { } public FieldDescriptorProto() { } + public FieldDescriptorProto(FieldDescriptorProto other) { - MergeFrom(other); + name_ = other.name_; + number_ = other.number_; + label_ = other.label_; + type_ = other.type_; + typeName_ = other.typeName_; + extendee_ = other.extendee_; + defaultValue_ = other.defaultValue_; + oneofIndex_ = other.oneofIndex_; + Options = other.options_ != null ? other.Options.Clone() : null; } + + public FieldDescriptorProto Clone() { + return new FieldDescriptorProto(this); + } + public const int NameFieldNumber = 1; private string name_ = ""; public string Name { @@ -1583,7 +1649,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class OneofDescriptorProto : pb::IMessage, global::System.IEquatable { + public sealed partial class OneofDescriptorProto : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new OneofDescriptorProto()); public static pb::MessageParser Parser { get { return _parser; } } @@ -1598,9 +1664,15 @@ namespace Google.Protobuf.DescriptorProtos { } public OneofDescriptorProto() { } + public OneofDescriptorProto(OneofDescriptorProto other) { - MergeFrom(other); + name_ = other.name_; } + + public OneofDescriptorProto Clone() { + return new OneofDescriptorProto(this); + } + public const int NameFieldNumber = 1; private string name_ = ""; public string Name { @@ -1675,7 +1747,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class EnumDescriptorProto : pb::IMessage, global::System.IEquatable { + public sealed partial class EnumDescriptorProto : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new EnumDescriptorProto()); public static pb::MessageParser Parser { get { return _parser; } } @@ -1690,9 +1762,17 @@ namespace Google.Protobuf.DescriptorProtos { } public EnumDescriptorProto() { } + public EnumDescriptorProto(EnumDescriptorProto other) { - MergeFrom(other); + name_ = other.name_; + value_ = other.value_.Clone(); + Options = other.options_ != null ? other.Options.Clone() : null; + } + + public EnumDescriptorProto Clone() { + return new EnumDescriptorProto(this); } + public const int NameFieldNumber = 1; private string name_ = ""; public string Name { @@ -1817,7 +1897,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class EnumValueDescriptorProto : pb::IMessage, global::System.IEquatable { + public sealed partial class EnumValueDescriptorProto : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new EnumValueDescriptorProto()); public static pb::MessageParser Parser { get { return _parser; } } @@ -1832,9 +1912,17 @@ namespace Google.Protobuf.DescriptorProtos { } public EnumValueDescriptorProto() { } + public EnumValueDescriptorProto(EnumValueDescriptorProto other) { - MergeFrom(other); + name_ = other.name_; + number_ = other.number_; + Options = other.options_ != null ? other.Options.Clone() : null; } + + public EnumValueDescriptorProto Clone() { + return new EnumValueDescriptorProto(this); + } + public const int NameFieldNumber = 1; private string name_ = ""; public string Name { @@ -1961,7 +2049,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class ServiceDescriptorProto : pb::IMessage, global::System.IEquatable { + public sealed partial class ServiceDescriptorProto : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ServiceDescriptorProto()); public static pb::MessageParser Parser { get { return _parser; } } @@ -1976,9 +2064,17 @@ namespace Google.Protobuf.DescriptorProtos { } public ServiceDescriptorProto() { } + public ServiceDescriptorProto(ServiceDescriptorProto other) { - MergeFrom(other); + name_ = other.name_; + method_ = other.method_.Clone(); + Options = other.options_ != null ? other.Options.Clone() : null; + } + + public ServiceDescriptorProto Clone() { + return new ServiceDescriptorProto(this); } + public const int NameFieldNumber = 1; private string name_ = ""; public string Name { @@ -2103,7 +2199,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MethodDescriptorProto : pb::IMessage, global::System.IEquatable { + public sealed partial class MethodDescriptorProto : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MethodDescriptorProto()); public static pb::MessageParser Parser { get { return _parser; } } @@ -2118,9 +2214,20 @@ namespace Google.Protobuf.DescriptorProtos { } public MethodDescriptorProto() { } + public MethodDescriptorProto(MethodDescriptorProto other) { - MergeFrom(other); + name_ = other.name_; + inputType_ = other.inputType_; + outputType_ = other.outputType_; + Options = other.options_ != null ? other.Options.Clone() : null; + clientStreaming_ = other.clientStreaming_; + serverStreaming_ = other.serverStreaming_; + } + + public MethodDescriptorProto Clone() { + return new MethodDescriptorProto(this); } + public const int NameFieldNumber = 1; private string name_ = ""; public string Name { @@ -2319,7 +2426,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class FileOptions : pb::IMessage, global::System.IEquatable { + public sealed partial class FileOptions : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FileOptions()); public static pb::MessageParser Parser { get { return _parser; } } @@ -2334,9 +2441,29 @@ namespace Google.Protobuf.DescriptorProtos { } public FileOptions() { } + public FileOptions(FileOptions other) { - MergeFrom(other); + javaPackage_ = other.javaPackage_; + javaOuterClassname_ = other.javaOuterClassname_; + javaMultipleFiles_ = other.javaMultipleFiles_; + javaGenerateEqualsAndHash_ = other.javaGenerateEqualsAndHash_; + javaStringCheckUtf8_ = other.javaStringCheckUtf8_; + optimizeFor_ = other.optimizeFor_; + goPackage_ = other.goPackage_; + ccGenericServices_ = other.ccGenericServices_; + javaGenericServices_ = other.javaGenericServices_; + pyGenericServices_ = other.pyGenericServices_; + deprecated_ = other.deprecated_; + ccEnableArenas_ = other.ccEnableArenas_; + objcClassPrefix_ = other.objcClassPrefix_; + csharpNamespace_ = other.csharpNamespace_; + uninterpretedOption_ = other.uninterpretedOption_.Clone(); + } + + public FileOptions Clone() { + return new FileOptions(this); } + public const int JavaPackageFieldNumber = 1; private string javaPackage_ = ""; public string JavaPackage { @@ -2757,7 +2884,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MessageOptions : pb::IMessage, global::System.IEquatable { + public sealed partial class MessageOptions : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MessageOptions()); public static pb::MessageParser Parser { get { return _parser; } } @@ -2772,9 +2899,19 @@ namespace Google.Protobuf.DescriptorProtos { } public MessageOptions() { } + public MessageOptions(MessageOptions other) { - MergeFrom(other); + messageSetWireFormat_ = other.messageSetWireFormat_; + noStandardDescriptorAccessor_ = other.noStandardDescriptorAccessor_; + deprecated_ = other.deprecated_; + mapEntry_ = other.mapEntry_; + uninterpretedOption_ = other.uninterpretedOption_.Clone(); + } + + public MessageOptions Clone() { + return new MessageOptions(this); } + public const int MessageSetWireFormatFieldNumber = 1; private bool messageSetWireFormat_; public bool MessageSetWireFormat { @@ -2943,7 +3080,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class FieldOptions : pb::IMessage, global::System.IEquatable { + public sealed partial class FieldOptions : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FieldOptions()); public static pb::MessageParser Parser { get { return _parser; } } @@ -2958,9 +3095,21 @@ namespace Google.Protobuf.DescriptorProtos { } public FieldOptions() { } + public FieldOptions(FieldOptions other) { - MergeFrom(other); + ctype_ = other.ctype_; + packed_ = other.packed_; + jstype_ = other.jstype_; + lazy_ = other.lazy_; + deprecated_ = other.deprecated_; + weak_ = other.weak_; + uninterpretedOption_ = other.uninterpretedOption_.Clone(); } + + public FieldOptions Clone() { + return new FieldOptions(this); + } + public const int CtypeFieldNumber = 1; private global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.CType ctype_ = global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.CType.STRING; public global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.CType Ctype { @@ -3195,7 +3344,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class EnumOptions : pb::IMessage, global::System.IEquatable { + public sealed partial class EnumOptions : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new EnumOptions()); public static pb::MessageParser Parser { get { return _parser; } } @@ -3210,9 +3359,17 @@ namespace Google.Protobuf.DescriptorProtos { } public EnumOptions() { } + public EnumOptions(EnumOptions other) { - MergeFrom(other); + allowAlias_ = other.allowAlias_; + deprecated_ = other.deprecated_; + uninterpretedOption_ = other.uninterpretedOption_.Clone(); + } + + public EnumOptions Clone() { + return new EnumOptions(this); } + public const int AllowAliasFieldNumber = 2; private bool allowAlias_; public bool AllowAlias { @@ -3333,7 +3490,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class EnumValueOptions : pb::IMessage, global::System.IEquatable { + public sealed partial class EnumValueOptions : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new EnumValueOptions()); public static pb::MessageParser Parser { get { return _parser; } } @@ -3348,9 +3505,16 @@ namespace Google.Protobuf.DescriptorProtos { } public EnumValueOptions() { } + public EnumValueOptions(EnumValueOptions other) { - MergeFrom(other); + deprecated_ = other.deprecated_; + uninterpretedOption_ = other.uninterpretedOption_.Clone(); } + + public EnumValueOptions Clone() { + return new EnumValueOptions(this); + } + public const int DeprecatedFieldNumber = 1; private bool deprecated_; public bool Deprecated { @@ -3447,7 +3611,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class ServiceOptions : pb::IMessage, global::System.IEquatable { + public sealed partial class ServiceOptions : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ServiceOptions()); public static pb::MessageParser Parser { get { return _parser; } } @@ -3462,9 +3626,16 @@ namespace Google.Protobuf.DescriptorProtos { } public ServiceOptions() { } + public ServiceOptions(ServiceOptions other) { - MergeFrom(other); + deprecated_ = other.deprecated_; + uninterpretedOption_ = other.uninterpretedOption_.Clone(); + } + + public ServiceOptions Clone() { + return new ServiceOptions(this); } + public const int DeprecatedFieldNumber = 33; private bool deprecated_; public bool Deprecated { @@ -3561,7 +3732,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MethodOptions : pb::IMessage, global::System.IEquatable { + public sealed partial class MethodOptions : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MethodOptions()); public static pb::MessageParser Parser { get { return _parser; } } @@ -3576,9 +3747,16 @@ namespace Google.Protobuf.DescriptorProtos { } public MethodOptions() { } + public MethodOptions(MethodOptions other) { - MergeFrom(other); + deprecated_ = other.deprecated_; + uninterpretedOption_ = other.uninterpretedOption_.Clone(); + } + + public MethodOptions Clone() { + return new MethodOptions(this); } + public const int DeprecatedFieldNumber = 33; private bool deprecated_; public bool Deprecated { @@ -3675,7 +3853,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class UninterpretedOption : pb::IMessage, global::System.IEquatable { + public sealed partial class UninterpretedOption : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new UninterpretedOption()); public static pb::MessageParser Parser { get { return _parser; } } @@ -3690,9 +3868,21 @@ namespace Google.Protobuf.DescriptorProtos { } public UninterpretedOption() { } + public UninterpretedOption(UninterpretedOption other) { - MergeFrom(other); + name_ = other.name_.Clone(); + identifierValue_ = other.identifierValue_; + positiveIntValue_ = other.positiveIntValue_; + negativeIntValue_ = other.negativeIntValue_; + doubleValue_ = other.doubleValue_; + stringValue_ = other.stringValue_; + aggregateValue_ = other.aggregateValue_; } + + public UninterpretedOption Clone() { + return new UninterpretedOption(this); + } + public const int NameFieldNumber = 2; private readonly pbc::RepeatedField name_ = new pbc::RepeatedField(); public pbc::RepeatedField Name { @@ -3910,7 +4100,7 @@ namespace Google.Protobuf.DescriptorProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class Types { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class NamePart : pb::IMessage, global::System.IEquatable { + public sealed partial class NamePart : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NamePart()); public static pb::MessageParser Parser { get { return _parser; } } @@ -3925,9 +4115,16 @@ namespace Google.Protobuf.DescriptorProtos { } public NamePart() { } + public NamePart(NamePart other) { - MergeFrom(other); + namePart_ = other.namePart_; + isExtension_ = other.isExtension_; } + + public NamePart Clone() { + return new NamePart(this); + } + public const int NamePart_FieldNumber = 1; private string namePart_ = ""; public string NamePart_ { @@ -4031,7 +4228,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class SourceCodeInfo : pb::IMessage, global::System.IEquatable { + public sealed partial class SourceCodeInfo : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new SourceCodeInfo()); public static pb::MessageParser Parser { get { return _parser; } } @@ -4046,9 +4243,15 @@ namespace Google.Protobuf.DescriptorProtos { } public SourceCodeInfo() { } + public SourceCodeInfo(SourceCodeInfo other) { - MergeFrom(other); + location_ = other.location_.Clone(); + } + + public SourceCodeInfo Clone() { + return new SourceCodeInfo(this); } + public const int LocationFieldNumber = 1; private readonly pbc::RepeatedField location_ = new pbc::RepeatedField(); public pbc::RepeatedField Location { @@ -4122,7 +4325,7 @@ namespace Google.Protobuf.DescriptorProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class Types { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Location : pb::IMessage, global::System.IEquatable { + public sealed partial class Location : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Location()); public static pb::MessageParser Parser { get { return _parser; } } @@ -4137,9 +4340,19 @@ namespace Google.Protobuf.DescriptorProtos { } public Location() { } + public Location(Location other) { - MergeFrom(other); + path_ = other.path_.Clone(); + span_ = other.span_.Clone(); + leadingComments_ = other.leadingComments_; + trailingComments_ = other.trailingComments_; + leadingDetachedComments_ = other.leadingDetachedComments_.Clone(); } + + public Location Clone() { + return new Location(this); + } + public const int PathFieldNumber = 1; private readonly pbc::RepeatedField path_ = new pbc::RepeatedField(); public pbc::RepeatedField Path { diff --git a/csharp/src/ProtocolBuffers/IMessage.cs b/csharp/src/ProtocolBuffers/IMessage.cs index 9c2a2d85..32dfcaff 100644 --- a/csharp/src/ProtocolBuffers/IMessage.cs +++ b/csharp/src/ProtocolBuffers/IMessage.cs @@ -93,4 +93,22 @@ namespace Google.Protobuf /// The message to merge with this one. Must not be null. void MergeFrom(T message); } + + /// + /// Generic interface for a deeply cloneable type. + /// + /// + /// In practice, all generated messages implement this interface. + /// However, due to the type constraint on T in , + /// it is simpler to keep this as a separate interface. + /// + /// The type itself, returned by the method. + public interface IDeepCloneable + { + /// + /// Creates a deep clone of this object. + /// + /// A deep clone of this object. + T Clone(); + } } \ No newline at end of file diff --git a/src/google/protobuf/compiler/csharp/csharp_field_base.h b/src/google/protobuf/compiler/csharp/csharp_field_base.h index 1b044a49..91ae3ba1 100644 --- a/src/google/protobuf/compiler/csharp/csharp_field_base.h +++ b/src/google/protobuf/compiler/csharp/csharp_field_base.h @@ -47,6 +47,7 @@ class FieldGeneratorBase : public SourceGeneratorBase { FieldGeneratorBase(const FieldDescriptor* descriptor, int fieldOrdinal); ~FieldGeneratorBase(); + virtual void GenerateCloningCode(io::Printer* printer) = 0; virtual void GenerateMembers(io::Printer* printer) = 0; virtual void GenerateMergingCode(io::Printer* printer) = 0; virtual void GenerateParsingCode(io::Printer* printer) = 0; diff --git a/src/google/protobuf/compiler/csharp/csharp_message.cc b/src/google/protobuf/compiler/csharp/csharp_message.cc index aca68fb7..32d0a82d 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message.cc @@ -179,7 +179,7 @@ void MessageGenerator::Generate(io::Printer* printer) { WriteGeneratedCodeAttributes(printer); printer->Print( vars, - "$access_level$ sealed partial class $class_name$ : pb::IMessage<$class_name$>, global::System.IEquatable<$class_name$> {\n"); + "$access_level$ sealed partial class $class_name$ : pb::IMessage<$class_name$>, global::System.IEquatable<$class_name$>, pb::IDeepCloneable<$class_name$> {\n"); printer->Indent(); // All static fields and properties @@ -213,16 +213,12 @@ void MessageGenerator::Generate(io::Printer* printer) { "}\n" "\n"); - // Constructors + // Parameterless constructor printer->Print( vars, - "public $class_name$() { }\n"); // Public parameterless ctor. + "public $class_name$() { }\n\n"); - printer->Print( - vars, - "public $class_name$($class_name$ other) {\n" - " MergeFrom(other);\n" - "}\n"); // Merge ctor. + GenerateCloningCode(printer); // Fields/properties for (int i = 0; i < descriptor_->field_count(); i++) { @@ -303,6 +299,53 @@ void MessageGenerator::Generate(io::Printer* printer) { } +void MessageGenerator::GenerateCloningCode(io::Printer* printer) { + map vars; + vars["class_name"] = class_name(); + printer->Print( + vars, + "public $class_name$($class_name$ other) {\n"); + printer->Indent(); + // Clone non-oneof fields first + for (int i = 0; i < descriptor_->field_count(); i++) { + if (!descriptor_->field(i)->containing_oneof()) { + scoped_ptr generator( + CreateFieldGeneratorInternal(descriptor_->field(i))); + generator->GenerateCloningCode(printer); + } + } + // Clone just the right field for each oneof + for (int i = 0; i < descriptor_->oneof_decl_count(); ++i) { + vars["name"] = UnderscoresToCamelCase(descriptor_->oneof_decl(i)->name(), false); + vars["property_name"] = UnderscoresToCamelCase(descriptor_->oneof_decl(i)->name(), true); + printer->Print(vars, "switch (other.$property_name$Case) {\n"); + printer->Indent(); + for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) { + const FieldDescriptor* field = descriptor_->oneof_decl(i)->field(j); + scoped_ptr generator(CreateFieldGeneratorInternal(field)); + vars["field_property_name"] = GetPropertyName(field); + printer->Print( + vars, + "case $property_name$OneofCase.$field_property_name$:\n"); + printer->Indent(); + generator->GenerateCloningCode(printer); + printer->Print("break;\n"); + printer->Outdent(); + } + printer->Outdent(); + printer->Print("}\n\n"); + } + + printer->Outdent(); + printer->Print("}\n\n"); + + printer->Print( + vars, + "public $class_name$ Clone() {\n" + " return new $class_name$(this);\n" + "}\n\n"); +} + void MessageGenerator::GenerateFrameworkMethods(io::Printer* printer) { map vars; vars["class_name"] = class_name(); diff --git a/src/google/protobuf/compiler/csharp/csharp_message.h b/src/google/protobuf/compiler/csharp/csharp_message.h index eb90ce67..c3a37a0e 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message.h +++ b/src/google/protobuf/compiler/csharp/csharp_message.h @@ -50,6 +50,7 @@ class MessageGenerator : public SourceGeneratorBase { MessageGenerator(const Descriptor* descriptor); ~MessageGenerator(); + void GenerateCloningCode(io::Printer* printer); void GenerateFrameworkMethods(io::Printer* printer); void GenerateStaticVariables(io::Printer* printer); void GenerateStaticVariableInitializers(io::Printer* printer); diff --git a/src/google/protobuf/compiler/csharp/csharp_message_field.cc b/src/google/protobuf/compiler/csharp/csharp_message_field.cc index bd67aa0f..82deef54 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message_field.cc @@ -125,6 +125,11 @@ void MessageFieldGenerator::WriteToString(io::Printer* printer) { "PrintField(\"$field_name$\", has$property_name$, $name$_, writer);\n"); } +void MessageFieldGenerator::GenerateCloningCode(io::Printer* printer) { + printer->Print(variables_, + "$property_name$ = other.$has_property_check$ ? other.$property_name$.Clone() : null;\n"); +} + MessageOneofFieldGenerator::MessageOneofFieldGenerator(const FieldDescriptor* descriptor, int fieldOrdinal) : MessageFieldGenerator(descriptor, fieldOrdinal) { @@ -166,6 +171,11 @@ void MessageOneofFieldGenerator::WriteToString(io::Printer* printer) { "PrintField(\"$descriptor_name$\", $has_property_check$, $oneof_name$_, writer);\n"); } +void MessageOneofFieldGenerator::GenerateCloningCode(io::Printer* printer) { + printer->Print(variables_, + "$property_name$ = other.$property_name$.Clone();\n"); +} + } // namespace csharp } // namespace compiler } // namespace protobuf diff --git a/src/google/protobuf/compiler/csharp/csharp_message_field.h b/src/google/protobuf/compiler/csharp/csharp_message_field.h index 02053b4f..f15e8e7e 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message_field.h +++ b/src/google/protobuf/compiler/csharp/csharp_message_field.h @@ -46,6 +46,7 @@ class MessageFieldGenerator : public FieldGeneratorBase { MessageFieldGenerator(const FieldDescriptor* descriptor, int fieldOrdinal); ~MessageFieldGenerator(); + virtual void GenerateCloningCode(io::Printer* printer); virtual void GenerateMembers(io::Printer* printer); virtual void GenerateMergingCode(io::Printer* printer); virtual void GenerateParsingCode(io::Printer* printer); @@ -65,6 +66,7 @@ class MessageOneofFieldGenerator : public MessageFieldGenerator { MessageOneofFieldGenerator(const FieldDescriptor* descriptor, int fieldOrdinal); ~MessageOneofFieldGenerator(); + virtual void GenerateCloningCode(io::Printer* printer); virtual void GenerateMembers(io::Printer* printer); virtual void WriteToString(io::Printer* printer); virtual void GenerateParsingCode(io::Printer* printer); diff --git a/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc b/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc index 5820eb37..c426c37a 100644 --- a/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc @@ -146,6 +146,11 @@ void PrimitiveFieldGenerator::WriteToString(io::Printer* printer) { "PrintField(\"$descriptor_name$\", $has_property_check$, $property_name$, writer);\n"); } +void PrimitiveFieldGenerator::GenerateCloningCode(io::Printer* printer) { + printer->Print(variables_, + "$name$_ = other.$name$_;\n"); +} + PrimitiveOneofFieldGenerator::PrimitiveOneofFieldGenerator( const FieldDescriptor* descriptor, int fieldOrdinal) : PrimitiveFieldGenerator(descriptor, fieldOrdinal) { @@ -189,6 +194,11 @@ void PrimitiveOneofFieldGenerator::GenerateParsingCode(io::Printer* printer) { "$property_name$ = input.Read$capitalized_type_name$();\n"); } +void PrimitiveOneofFieldGenerator::GenerateCloningCode(io::Printer* printer) { + printer->Print(variables_, + "$property_name$ = other.$property_name$;\n"); +} + } // namespace csharp } // namespace compiler } // namespace protobuf diff --git a/src/google/protobuf/compiler/csharp/csharp_primitive_field.h b/src/google/protobuf/compiler/csharp/csharp_primitive_field.h index d6672b6c..bac33214 100644 --- a/src/google/protobuf/compiler/csharp/csharp_primitive_field.h +++ b/src/google/protobuf/compiler/csharp/csharp_primitive_field.h @@ -46,6 +46,7 @@ class PrimitiveFieldGenerator : public FieldGeneratorBase { PrimitiveFieldGenerator(const FieldDescriptor* descriptor, int fieldOrdinal); ~PrimitiveFieldGenerator(); + virtual void GenerateCloningCode(io::Printer* printer); virtual void GenerateMembers(io::Printer* printer); virtual void GenerateMergingCode(io::Printer* printer); virtual void GenerateParsingCode(io::Printer* printer); @@ -68,6 +69,7 @@ class PrimitiveOneofFieldGenerator : public PrimitiveFieldGenerator { PrimitiveOneofFieldGenerator(const FieldDescriptor* descriptor, int fieldOrdinal); ~PrimitiveOneofFieldGenerator(); + virtual void GenerateCloningCode(io::Printer* printer); virtual void GenerateMembers(io::Printer* printer); virtual void WriteToString(io::Printer* printer); virtual void GenerateParsingCode(io::Printer* printer); diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc b/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc index 29c931e3..ce526b37 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc @@ -142,6 +142,11 @@ void RepeatedEnumFieldGenerator::WriteToString(io::Printer* printer) { "PrintField(\"$descriptor_name$\", $name$_, writer);\n"); } +void RepeatedEnumFieldGenerator::GenerateCloningCode(io::Printer* printer) { + printer->Print(variables_, + "$name$_ = other.$name$_.Clone();\n"); +} + } // namespace csharp } // namespace compiler } // namespace protobuf diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.h b/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.h index 92f265c5..c7846a61 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.h +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.h @@ -48,6 +48,7 @@ class RepeatedEnumFieldGenerator : public FieldGeneratorBase { RepeatedEnumFieldGenerator(const FieldDescriptor* descriptor, int fieldOrdinal); ~RepeatedEnumFieldGenerator(); + virtual void GenerateCloningCode(io::Printer* printer); virtual void GenerateMembers(io::Printer* printer); virtual void GenerateMergingCode(io::Printer* printer); virtual void GenerateParsingCode(io::Printer* printer); diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc b/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc index 3ab0b190..edfb98b4 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc @@ -118,6 +118,11 @@ void RepeatedMessageFieldGenerator::WriteToString(io::Printer* printer) { "PrintField(\"$field_name$\", $name$_, writer);\n"); } +void RepeatedMessageFieldGenerator::GenerateCloningCode(io::Printer* printer) { + printer->Print(variables_, + "$name$_ = other.$name$_.Clone();\n"); +} + } // namespace csharp } // namespace compiler } // namespace protobuf diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.h b/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.h index b8582800..38006731 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.h +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.h @@ -46,6 +46,7 @@ class RepeatedMessageFieldGenerator : public FieldGeneratorBase { RepeatedMessageFieldGenerator(const FieldDescriptor* descriptor, int fieldOrdinal); ~RepeatedMessageFieldGenerator(); + virtual void GenerateCloningCode(io::Printer* printer); virtual void GenerateMembers(io::Printer* printer); virtual void GenerateMergingCode(io::Printer* printer); virtual void GenerateParsingCode(io::Printer* printer); diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc b/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc index cc787d50..49a29c55 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc @@ -148,6 +148,11 @@ void RepeatedPrimitiveFieldGenerator::WriteToString(io::Printer* printer) { "PrintField(\"$descriptor_name$\", $name$_, writer);\n"); } +void RepeatedPrimitiveFieldGenerator::GenerateCloningCode(io::Printer* printer) { + printer->Print(variables_, + "$name$_ = other.$name$_.Clone();\n"); +} + } // namespace csharp } // namespace compiler } // namespace protobuf diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h b/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h index 29d437d7..7f8f17a8 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h @@ -46,6 +46,7 @@ class RepeatedPrimitiveFieldGenerator : public FieldGeneratorBase { RepeatedPrimitiveFieldGenerator(const FieldDescriptor* descriptor, int fieldOrdinal); ~RepeatedPrimitiveFieldGenerator(); + virtual void GenerateCloningCode(io::Printer* printer); virtual void GenerateMembers(io::Printer* printer); virtual void GenerateMergingCode(io::Printer* printer); virtual void GenerateParsingCode(io::Printer* printer); -- cgit v1.2.3 From 8c896b259ecda6160ad2839fab59fad71ae77a7c Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Tue, 23 Jun 2015 20:04:39 +0100 Subject: Implement requested changes for IMessage 1) New line at end of file 2) Make IMessage itself extend IEquatable and IDeepCloneable --- csharp/src/ProtocolBuffers/IMessage.cs | 9 +++++---- src/google/protobuf/compiler/csharp/csharp_message.cc | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/csharp/src/ProtocolBuffers/IMessage.cs b/csharp/src/ProtocolBuffers/IMessage.cs index 32dfcaff..5d662cfd 100644 --- a/csharp/src/ProtocolBuffers/IMessage.cs +++ b/csharp/src/ProtocolBuffers/IMessage.cs @@ -34,6 +34,7 @@ #endregion +using System; using Google.Protobuf.FieldAccess; namespace Google.Protobuf @@ -84,7 +85,7 @@ namespace Google.Protobuf /// the implementation class. /// /// The message type. - public interface IMessage : IMessage where T : IMessage + public interface IMessage : IMessage, IEquatable, IDeepCloneable where T : IMessage { /// /// Merges the given message into this one. @@ -98,8 +99,8 @@ namespace Google.Protobuf /// Generic interface for a deeply cloneable type. /// /// - /// In practice, all generated messages implement this interface. - /// However, due to the type constraint on T in , + /// All generated messages implement this interface, but so do some non-message types. + /// Additionally, due to the type constraint on T in , /// it is simpler to keep this as a separate interface. /// /// The type itself, returned by the method. @@ -111,4 +112,4 @@ namespace Google.Protobuf /// A deep clone of this object. T Clone(); } -} \ No newline at end of file +} diff --git a/src/google/protobuf/compiler/csharp/csharp_message.cc b/src/google/protobuf/compiler/csharp/csharp_message.cc index 32d0a82d..39938fa3 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message.cc @@ -179,7 +179,7 @@ void MessageGenerator::Generate(io::Printer* printer) { WriteGeneratedCodeAttributes(printer); printer->Print( vars, - "$access_level$ sealed partial class $class_name$ : pb::IMessage<$class_name$>, global::System.IEquatable<$class_name$>, pb::IDeepCloneable<$class_name$> {\n"); + "$access_level$ sealed partial class $class_name$ : pb::IMessage<$class_name$> {\n"); printer->Indent(); // All static fields and properties -- cgit v1.2.3 From 785e13e3c002ccd0a1174839f47041ef81a33640 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Tue, 23 Jun 2015 20:05:04 +0100 Subject: Generated code changes from previous commit. --- csharp/src/AddressBook/Addressbook.cs | 6 +- .../TestProtos/UnittestImportProto3.cs | 2 +- .../TestProtos/UnittestImportPublicProto3.cs | 2 +- .../TestProtos/UnittestIssues.cs | 8 +-- .../TestProtos/UnittestProto3.cs | 70 +++++++++++----------- .../DescriptorProtos/DescriptorProtoFile.cs | 44 +++++++------- 6 files changed, 66 insertions(+), 66 deletions(-) diff --git a/csharp/src/AddressBook/Addressbook.cs b/csharp/src/AddressBook/Addressbook.cs index cf09bc4c..cd1f6231 100644 --- a/csharp/src/AddressBook/Addressbook.cs +++ b/csharp/src/AddressBook/Addressbook.cs @@ -62,7 +62,7 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { } #region Messages [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Person : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class Person : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Person()); public static pb::MessageParser Parser { get { return _parser; } } @@ -240,7 +240,7 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class PhoneNumber : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class PhoneNumber : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new PhoneNumber()); public static pb::MessageParser Parser { get { return _parser; } } @@ -368,7 +368,7 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class AddressBook : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class AddressBook : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new AddressBook()); public static pb::MessageParser Parser { get { return _parser; } } diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportProto3.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportProto3.cs index 0b8a9dd3..30256972 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportProto3.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportProto3.cs @@ -60,7 +60,7 @@ namespace Google.Protobuf.TestProtos { #region Messages [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class ImportMessage : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class ImportMessage : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ImportMessage()); public static pb::MessageParser Parser { get { return _parser; } } diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportPublicProto3.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportPublicProto3.cs index b634ccff..cb7292f3 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportPublicProto3.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportPublicProto3.cs @@ -45,7 +45,7 @@ namespace Google.Protobuf.TestProtos { } #region Messages [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class PublicImportMessage : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class PublicImportMessage : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new PublicImportMessage()); public static pb::MessageParser Parser { get { return _parser; } } diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs index df149323..d32718d5 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs @@ -90,7 +90,7 @@ namespace UnitTest.Issues.TestProtos { #region Messages [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class NegativeEnumMessage : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class NegativeEnumMessage : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NegativeEnumMessage()); public static pb::MessageParser Parser { get { return _parser; } } @@ -241,7 +241,7 @@ namespace UnitTest.Issues.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class DeprecatedChild : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class DeprecatedChild : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new DeprecatedChild()); public static pb::MessageParser Parser { get { return _parser; } } @@ -314,7 +314,7 @@ namespace UnitTest.Issues.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class DeprecatedFieldsMessage : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class DeprecatedFieldsMessage : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new DeprecatedFieldsMessage()); public static pb::MessageParser Parser { get { return _parser; } } @@ -549,7 +549,7 @@ namespace UnitTest.Issues.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class ItemField : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class ItemField : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ItemField()); public static pb::MessageParser Parser { get { return _parser; } } diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs index 1fab6737..d9d33b10 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs @@ -402,7 +402,7 @@ namespace Google.Protobuf.TestProtos { #region Messages [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestAllTypes : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class TestAllTypes : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestAllTypes()); public static pb::MessageParser Parser { get { return _parser; } } @@ -1750,7 +1750,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class NestedMessage : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class NestedMessage : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedMessage()); public static pb::MessageParser Parser { get { return _parser; } } @@ -1853,7 +1853,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class NestedTestAllTypes : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class NestedTestAllTypes : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedTestAllTypes()); public static pb::MessageParser Parser { get { return _parser; } } @@ -2007,7 +2007,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestDeprecatedFields : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class TestDeprecatedFields : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestDeprecatedFields()); public static pb::MessageParser Parser { get { return _parser; } } @@ -2106,7 +2106,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class ForeignMessage : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class ForeignMessage : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ForeignMessage()); public static pb::MessageParser Parser { get { return _parser; } } @@ -2204,7 +2204,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestReservedFields : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class TestReservedFields : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestReservedFields()); public static pb::MessageParser Parser { get { return _parser; } } @@ -2277,7 +2277,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestForeignNested : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class TestForeignNested : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestForeignNested()); public static pb::MessageParser Parser { get { return _parser; } } @@ -2379,7 +2379,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestReallyLargeTagNumber : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class TestReallyLargeTagNumber : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestReallyLargeTagNumber()); public static pb::MessageParser Parser { get { return _parser; } } @@ -2502,7 +2502,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestRecursiveMessage : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class TestRecursiveMessage : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestRecursiveMessage()); public static pb::MessageParser Parser { get { return _parser; } } @@ -2629,7 +2629,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestMutualRecursionA : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class TestMutualRecursionA : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestMutualRecursionA()); public static pb::MessageParser Parser { get { return _parser; } } @@ -2731,7 +2731,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestMutualRecursionB : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class TestMutualRecursionB : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestMutualRecursionB()); public static pb::MessageParser Parser { get { return _parser; } } @@ -2858,7 +2858,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestCamelCaseFieldNames : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class TestCamelCaseFieldNames : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestCamelCaseFieldNames()); public static pb::MessageParser Parser { get { return _parser; } } @@ -3137,7 +3137,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestFieldOrderings : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class TestFieldOrderings : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestFieldOrderings()); public static pb::MessageParser Parser { get { return _parser; } } @@ -3315,7 +3315,7 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class Types { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class NestedMessage : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class NestedMessage : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedMessage()); public static pb::MessageParser Parser { get { return _parser; } } @@ -3443,7 +3443,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class SparseEnumMessage : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class SparseEnumMessage : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new SparseEnumMessage()); public static pb::MessageParser Parser { get { return _parser; } } @@ -3541,7 +3541,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class OneString : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class OneString : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new OneString()); public static pb::MessageParser Parser { get { return _parser; } } @@ -3639,7 +3639,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MoreString : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class MoreString : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MoreString()); public static pb::MessageParser Parser { get { return _parser; } } @@ -3737,7 +3737,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class OneBytes : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class OneBytes : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new OneBytes()); public static pb::MessageParser Parser { get { return _parser; } } @@ -3835,7 +3835,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MoreBytes : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class MoreBytes : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MoreBytes()); public static pb::MessageParser Parser { get { return _parser; } } @@ -3933,7 +3933,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Int32Message : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class Int32Message : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Int32Message()); public static pb::MessageParser Parser { get { return _parser; } } @@ -4031,7 +4031,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Uint32Message : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class Uint32Message : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Uint32Message()); public static pb::MessageParser Parser { get { return _parser; } } @@ -4129,7 +4129,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Int64Message : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class Int64Message : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Int64Message()); public static pb::MessageParser Parser { get { return _parser; } } @@ -4227,7 +4227,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Uint64Message : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class Uint64Message : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Uint64Message()); public static pb::MessageParser Parser { get { return _parser; } } @@ -4325,7 +4325,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class BoolMessage : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class BoolMessage : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new BoolMessage()); public static pb::MessageParser Parser { get { return _parser; } } @@ -4423,7 +4423,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestOneof : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class TestOneof : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestOneof()); public static pb::MessageParser Parser { get { return _parser; } } @@ -4607,7 +4607,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestPackedTypes : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class TestPackedTypes : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestPackedTypes()); public static pb::MessageParser Parser { get { return _parser; } } @@ -5044,7 +5044,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestUnpackedTypes : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class TestUnpackedTypes : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestUnpackedTypes()); public static pb::MessageParser Parser { get { return _parser; } } @@ -5467,7 +5467,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestRepeatedScalarDifferentTagSizes : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class TestRepeatedScalarDifferentTagSizes : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestRepeatedScalarDifferentTagSizes()); public static pb::MessageParser Parser { get { return _parser; } } @@ -5696,7 +5696,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestCommentInjectionMessage : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class TestCommentInjectionMessage : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestCommentInjectionMessage()); public static pb::MessageParser Parser { get { return _parser; } } @@ -5794,7 +5794,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class FooRequest : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class FooRequest : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FooRequest()); public static pb::MessageParser Parser { get { return _parser; } } @@ -5867,7 +5867,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class FooResponse : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class FooResponse : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FooResponse()); public static pb::MessageParser Parser { get { return _parser; } } @@ -5940,7 +5940,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class FooClientMessage : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class FooClientMessage : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FooClientMessage()); public static pb::MessageParser Parser { get { return _parser; } } @@ -6013,7 +6013,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class FooServerMessage : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class FooServerMessage : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FooServerMessage()); public static pb::MessageParser Parser { get { return _parser; } } @@ -6086,7 +6086,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class BarRequest : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class BarRequest : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new BarRequest()); public static pb::MessageParser Parser { get { return _parser; } } @@ -6159,7 +6159,7 @@ namespace Google.Protobuf.TestProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class BarResponse : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class BarResponse : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new BarResponse()); public static pb::MessageParser Parser { get { return _parser; } } diff --git a/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs b/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs index 0b966aea..23d5e964 100644 --- a/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs +++ b/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs @@ -278,7 +278,7 @@ namespace Google.Protobuf.DescriptorProtos { } #region Messages [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class FileDescriptorSet : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class FileDescriptorSet : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FileDescriptorSet()); public static pb::MessageParser Parser { get { return _parser; } } @@ -374,7 +374,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class FileDescriptorProto : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class FileDescriptorProto : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FileDescriptorProto()); public static pb::MessageParser Parser { get { return _parser; } } @@ -749,7 +749,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class DescriptorProto : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class DescriptorProto : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new DescriptorProto()); public static pb::MessageParser Parser { get { return _parser; } } @@ -1063,7 +1063,7 @@ namespace Google.Protobuf.DescriptorProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class Types { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class ExtensionRange : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class ExtensionRange : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ExtensionRange()); public static pb::MessageParser Parser { get { return _parser; } } @@ -1186,7 +1186,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class ReservedRange : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class ReservedRange : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ReservedRange()); public static pb::MessageParser Parser { get { return _parser; } } @@ -1314,7 +1314,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class FieldDescriptorProto : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class FieldDescriptorProto : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FieldDescriptorProto()); public static pb::MessageParser Parser { get { return _parser; } } @@ -1649,7 +1649,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class OneofDescriptorProto : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class OneofDescriptorProto : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new OneofDescriptorProto()); public static pb::MessageParser Parser { get { return _parser; } } @@ -1747,7 +1747,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class EnumDescriptorProto : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class EnumDescriptorProto : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new EnumDescriptorProto()); public static pb::MessageParser Parser { get { return _parser; } } @@ -1897,7 +1897,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class EnumValueDescriptorProto : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class EnumValueDescriptorProto : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new EnumValueDescriptorProto()); public static pb::MessageParser Parser { get { return _parser; } } @@ -2049,7 +2049,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class ServiceDescriptorProto : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class ServiceDescriptorProto : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ServiceDescriptorProto()); public static pb::MessageParser Parser { get { return _parser; } } @@ -2199,7 +2199,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MethodDescriptorProto : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class MethodDescriptorProto : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MethodDescriptorProto()); public static pb::MessageParser Parser { get { return _parser; } } @@ -2426,7 +2426,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class FileOptions : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class FileOptions : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FileOptions()); public static pb::MessageParser Parser { get { return _parser; } } @@ -2884,7 +2884,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MessageOptions : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class MessageOptions : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MessageOptions()); public static pb::MessageParser Parser { get { return _parser; } } @@ -3080,7 +3080,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class FieldOptions : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class FieldOptions : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FieldOptions()); public static pb::MessageParser Parser { get { return _parser; } } @@ -3344,7 +3344,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class EnumOptions : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class EnumOptions : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new EnumOptions()); public static pb::MessageParser Parser { get { return _parser; } } @@ -3490,7 +3490,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class EnumValueOptions : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class EnumValueOptions : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new EnumValueOptions()); public static pb::MessageParser Parser { get { return _parser; } } @@ -3611,7 +3611,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class ServiceOptions : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class ServiceOptions : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ServiceOptions()); public static pb::MessageParser Parser { get { return _parser; } } @@ -3732,7 +3732,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MethodOptions : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class MethodOptions : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MethodOptions()); public static pb::MessageParser Parser { get { return _parser; } } @@ -3853,7 +3853,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class UninterpretedOption : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class UninterpretedOption : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new UninterpretedOption()); public static pb::MessageParser Parser { get { return _parser; } } @@ -4100,7 +4100,7 @@ namespace Google.Protobuf.DescriptorProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class Types { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class NamePart : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class NamePart : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NamePart()); public static pb::MessageParser Parser { get { return _parser; } } @@ -4228,7 +4228,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class SourceCodeInfo : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class SourceCodeInfo : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new SourceCodeInfo()); public static pb::MessageParser Parser { get { return _parser; } } @@ -4325,7 +4325,7 @@ namespace Google.Protobuf.DescriptorProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class Types { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Location : pb::IMessage, global::System.IEquatable, pb::IDeepCloneable { + public sealed partial class Location : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Location()); public static pb::MessageParser Parser { get { return _parser; } } -- cgit v1.2.3 From bfee2dfe137b07e64ebd46baf71d932d58d01b1f Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Tue, 23 Jun 2015 16:09:27 +0100 Subject: Implement freezing for messages and repeated fields. Fixes issue #523. --- csharp/src/AddressBook/Addressbook.cs | 62 +- .../ProtocolBuffers.Test/GeneratedMessageTest.cs | 20 +- .../src/ProtocolBuffers.Test/RepeatedFieldTest.cs | 47 +- .../TestProtos/UnittestImportProto3.cs | 16 +- .../TestProtos/UnittestImportPublicProto3.cs | 16 +- .../TestProtos/UnittestIssues.cs | 78 +- .../TestProtos/UnittestProto3.cs | 789 ++++++++++++++++++--- .../ProtocolBuffers/Collections/RepeatedField.cs | 35 +- .../DescriptorProtos/DescriptorProtoFile.cs | 710 ++++++++++++++---- csharp/src/ProtocolBuffers/Freezable.cs | 60 ++ csharp/src/ProtocolBuffers/IMessage.cs | 36 +- csharp/src/ProtocolBuffers/ProtocolBuffers.csproj | 1 + .../protobuf/compiler/csharp/csharp_field_base.cc | 5 + .../protobuf/compiler/csharp/csharp_field_base.h | 1 + .../protobuf/compiler/csharp/csharp_message.cc | 36 +- .../protobuf/compiler/csharp/csharp_message.h | 1 + .../compiler/csharp/csharp_message_field.cc | 13 +- .../compiler/csharp/csharp_message_field.h | 1 + .../compiler/csharp/csharp_primitive_field.cc | 15 +- .../compiler/csharp/csharp_repeated_enum_field.cc | 5 + .../compiler/csharp/csharp_repeated_enum_field.h | 1 + .../csharp/csharp_repeated_message_field.cc | 5 + .../csharp/csharp_repeated_message_field.h | 1 + .../csharp/csharp_repeated_primitive_field.cc | 5 + .../csharp/csharp_repeated_primitive_field.h | 1 + 25 files changed, 1668 insertions(+), 292 deletions(-) create mode 100644 csharp/src/ProtocolBuffers/Freezable.cs diff --git a/csharp/src/AddressBook/Addressbook.cs b/csharp/src/AddressBook/Addressbook.cs index cd1f6231..2fb6be83 100644 --- a/csharp/src/AddressBook/Addressbook.cs +++ b/csharp/src/AddressBook/Addressbook.cs @@ -76,6 +76,9 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { get { return global::Google.ProtocolBuffers.Examples.AddressBook.Addressbook.internal__static_tutorial_Person__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public Person() { } public Person(Person other) { @@ -89,30 +92,44 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { return new Person(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + phone_.Freeze(); + } + public const int NameFieldNumber = 1; private string name_ = ""; public string Name { get { return name_; } - set { name_ = value ?? ""; } + set { + pb::Freezable.CheckMutable(this); + name_ = value ?? ""; + } } - public const int IdFieldNumber = 2; private int id_; public int Id { get { return id_; } - set { id_ = value; } + set { + pb::Freezable.CheckMutable(this); + id_ = value; + } } - public const int EmailFieldNumber = 3; private string email_ = ""; public string Email { get { return email_; } - set { email_ = value ?? ""; } + set { + pb::Freezable.CheckMutable(this); + email_ = value ?? ""; + } } - public const int PhoneFieldNumber = 4; private readonly pbc::RepeatedField phone_ = new pbc::RepeatedField(); public pbc::RepeatedField Phone { @@ -254,6 +271,9 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { get { return global::Google.ProtocolBuffers.Examples.AddressBook.Addressbook.internal__static_tutorial_Person_PhoneNumber__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public PhoneNumber() { } public PhoneNumber(PhoneNumber other) { @@ -265,22 +285,33 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { return new PhoneNumber(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + public const int NumberFieldNumber = 1; private string number_ = ""; public string Number { get { return number_; } - set { number_ = value ?? ""; } + set { + pb::Freezable.CheckMutable(this); + number_ = value ?? ""; + } } - public const int TypeFieldNumber = 2; private global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneType type_ = global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneType.HOME; public global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneType Type { get { return type_; } - set { type_ = value; } + set { + pb::Freezable.CheckMutable(this); + type_ = value; + } } - public override bool Equals(object other) { return Equals(other as PhoneNumber); } @@ -382,6 +413,9 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { get { return global::Google.ProtocolBuffers.Examples.AddressBook.Addressbook.internal__static_tutorial_AddressBook__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public AddressBook() { } public AddressBook(AddressBook other) { @@ -392,6 +426,14 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { return new AddressBook(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + person_.Freeze(); + } + public const int PersonFieldNumber = 1; private readonly pbc::RepeatedField person_ = new pbc::RepeatedField(); public pbc::RepeatedField Person { diff --git a/csharp/src/ProtocolBuffers.Test/GeneratedMessageTest.cs b/csharp/src/ProtocolBuffers.Test/GeneratedMessageTest.cs index e21d904d..26165428 100644 --- a/csharp/src/ProtocolBuffers.Test/GeneratedMessageTest.cs +++ b/csharp/src/ProtocolBuffers.Test/GeneratedMessageTest.cs @@ -1,4 +1,5 @@ -using Google.Protobuf.TestProtos; +using System; +using Google.Protobuf.TestProtos; using NUnit.Framework; namespace Google.Protobuf @@ -257,5 +258,22 @@ namespace Google.Protobuf original.OneofNestedMessage.Bb = 30; Assert.AreNotEqual(original, clone); } + + [Test] + public void Freeze() + { + var frozen = new TestAllTypes(); + frozen.Freeze(); + Assert.IsTrue(frozen.IsFrozen); + + Assert.Throws(() => frozen.ClearOneofField()); + Assert.Throws(() => frozen.SingleInt32 = 0); + Assert.Throws(() => frozen.SingleNestedMessage = null); + Assert.Throws(() => frozen.SingleNestedEnum = 0); + Assert.Throws(() => frozen.OneofString = null); + Assert.Throws(() => frozen.OneofUint32 = 0U); + Assert.Throws(() => frozen.RepeatedDouble.Add(0.0)); + Assert.Throws(() => frozen.RepeatedNestedMessage.Add(new TestAllTypes.Types.NestedMessage())); + } } } diff --git a/csharp/src/ProtocolBuffers.Test/RepeatedFieldTest.cs b/csharp/src/ProtocolBuffers.Test/RepeatedFieldTest.cs index cbe79294..c01cd8ff 100644 --- a/csharp/src/ProtocolBuffers.Test/RepeatedFieldTest.cs +++ b/csharp/src/ProtocolBuffers.Test/RepeatedFieldTest.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using Google.Protobuf.Collections; +using Google.Protobuf.TestProtos; using NUnit.Framework; namespace Google.Protobuf @@ -11,8 +12,8 @@ namespace Google.Protobuf public void NullValuesRejected() { var list = new RepeatedField(); - Assert.Throws(() => list.Add((string) null)); - Assert.Throws(() => list.Add((IEnumerable) null)); + Assert.Throws(() => list.Add((string)null)); + Assert.Throws(() => list.Add((IEnumerable)null)); Assert.Throws(() => list.Add((RepeatedField)null)); Assert.Throws(() => list.Contains(null)); Assert.Throws(() => list.IndexOf(null)); @@ -47,5 +48,47 @@ namespace Google.Protobuf Assert.AreEqual("foo", list[1]); Assert.AreEqual("bar", list[2]); } + + [Test] + public void Freeze_FreezesElements() + { + var list = new RepeatedField { new TestAllTypes() }; + Assert.IsFalse(list[0].IsFrozen); + list.Freeze(); + Assert.IsTrue(list[0].IsFrozen); + } + + [Test] + public void Freeze_PreventsMutations() + { + var list = new RepeatedField { 0 }; + list.Freeze(); + Assert.Throws(() => list.Add(1)); + Assert.Throws(() => list[0] = 1); + Assert.Throws(() => list.Clear()); + Assert.Throws(() => list.RemoveAt(0)); + Assert.Throws(() => list.Remove(0)); + Assert.Throws(() => list.Insert(0, 0)); + } + + [Test] + public void Freeze_ReportsFrozen() + { + var list = new RepeatedField { 0 }; + Assert.IsFalse(list.IsFrozen); + Assert.IsFalse(list.IsReadOnly); + list.Freeze(); + Assert.IsTrue(list.IsFrozen); + Assert.IsTrue(list.IsReadOnly); + } + + [Test] + public void Clone_ReturnsMutable() + { + var list = new RepeatedField { 0 }; + list.Freeze(); + var clone = list.Clone(); + clone[0] = 1; + } } } diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportProto3.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportProto3.cs index 30256972..a32d19c2 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportProto3.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportProto3.cs @@ -74,6 +74,9 @@ namespace Google.Protobuf.TestProtos { get { return global::Google.Protobuf.TestProtos.UnittestImportProto3.internal__static_protobuf_unittest_import_ImportMessage__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public ImportMessage() { } public ImportMessage(ImportMessage other) { @@ -84,14 +87,23 @@ namespace Google.Protobuf.TestProtos { return new ImportMessage(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + public const int DFieldNumber = 1; private int d_; public int D { get { return d_; } - set { d_ = value; } + set { + pb::Freezable.CheckMutable(this); + d_ = value; + } } - public override bool Equals(object other) { return Equals(other as ImportMessage); } diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportPublicProto3.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportPublicProto3.cs index cb7292f3..2c8b0a31 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportPublicProto3.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportPublicProto3.cs @@ -59,6 +59,9 @@ namespace Google.Protobuf.TestProtos { get { return global::Google.Protobuf.TestProtos.UnittestImportPublicProto3.internal__static_protobuf_unittest_import_PublicImportMessage__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public PublicImportMessage() { } public PublicImportMessage(PublicImportMessage other) { @@ -69,14 +72,23 @@ namespace Google.Protobuf.TestProtos { return new PublicImportMessage(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + public const int EFieldNumber = 1; private int e_; public int E { get { return e_; } - set { e_ = value; } + set { + pb::Freezable.CheckMutable(this); + e_ = value; + } } - public override bool Equals(object other) { return Equals(other as PublicImportMessage); } diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs index d32718d5..28508a3b 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs @@ -104,6 +104,9 @@ namespace UnitTest.Issues.TestProtos { get { return global::UnitTest.Issues.TestProtos.UnittestIssues.internal__static_unittest_issues_NegativeEnumMessage__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public NegativeEnumMessage() { } public NegativeEnumMessage(NegativeEnumMessage other) { @@ -116,14 +119,25 @@ namespace UnitTest.Issues.TestProtos { return new NegativeEnumMessage(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + values_.Freeze(); + packedValues_.Freeze(); + } + public const int ValueFieldNumber = 1; private global::UnitTest.Issues.TestProtos.NegativeEnum value_ = global::UnitTest.Issues.TestProtos.NegativeEnum.NEGATIVE_ENUM_ZERO; public global::UnitTest.Issues.TestProtos.NegativeEnum Value { get { return value_; } - set { value_ = value; } + set { + pb::Freezable.CheckMutable(this); + value_ = value; + } } - public const int ValuesFieldNumber = 2; private readonly pbc::RepeatedField values_ = new pbc::RepeatedField(); public pbc::RepeatedField Values { @@ -255,6 +269,9 @@ namespace UnitTest.Issues.TestProtos { get { return global::UnitTest.Issues.TestProtos.UnittestIssues.internal__static_unittest_issues_DeprecatedChild__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public DeprecatedChild() { } public DeprecatedChild(DeprecatedChild other) { @@ -264,6 +281,13 @@ namespace UnitTest.Issues.TestProtos { return new DeprecatedChild(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + public override bool Equals(object other) { return Equals(other as DeprecatedChild); } @@ -328,6 +352,9 @@ namespace UnitTest.Issues.TestProtos { get { return global::UnitTest.Issues.TestProtos.UnittestIssues.internal__static_unittest_issues_DeprecatedFieldsMessage__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public DeprecatedFieldsMessage() { } public DeprecatedFieldsMessage(DeprecatedFieldsMessage other) { @@ -343,15 +370,28 @@ namespace UnitTest.Issues.TestProtos { return new DeprecatedFieldsMessage(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + primitiveArray_.Freeze(); + if (messageValue_ != null) MessageValue.Freeze(); + messageArray_.Freeze(); + enumArray_.Freeze(); + } + public const int PrimitiveValueFieldNumber = 1; private int primitiveValue_; [global::System.ObsoleteAttribute()] public int PrimitiveValue { get { return primitiveValue_; } - set { primitiveValue_ = value; } + set { + pb::Freezable.CheckMutable(this); + primitiveValue_ = value; + } } - public const int PrimitiveArrayFieldNumber = 2; private readonly pbc::RepeatedField primitiveArray_ = new pbc::RepeatedField(); [global::System.ObsoleteAttribute()] @@ -364,7 +404,10 @@ namespace UnitTest.Issues.TestProtos { [global::System.ObsoleteAttribute()] public global::UnitTest.Issues.TestProtos.DeprecatedChild MessageValue { get { return messageValue_; } - set { messageValue_ = value; } + set { + pb::Freezable.CheckMutable(this); + messageValue_ = value; + } } public const int MessageArrayFieldNumber = 4; @@ -379,10 +422,12 @@ namespace UnitTest.Issues.TestProtos { [global::System.ObsoleteAttribute()] public global::UnitTest.Issues.TestProtos.DeprecatedEnum EnumValue { get { return enumValue_; } - set { enumValue_ = value; } + set { + pb::Freezable.CheckMutable(this); + enumValue_ = value; + } } - public const int EnumArrayFieldNumber = 6; private readonly pbc::RepeatedField enumArray_ = new pbc::RepeatedField(); [global::System.ObsoleteAttribute()] @@ -403,7 +448,8 @@ namespace UnitTest.Issues.TestProtos { } if (PrimitiveValue != other.PrimitiveValue) return false; if(!primitiveArray_.Equals(other.primitiveArray_)) return false; - if (!object.Equals(MessageValue, other.MessageValue)) return false;if(!messageArray_.Equals(other.messageArray_)) return false; + if (!object.Equals(MessageValue, other.MessageValue)) return false; + if(!messageArray_.Equals(other.messageArray_)) return false; if (EnumValue != other.EnumValue) return false; if(!enumArray_.Equals(other.enumArray_)) return false; return true; @@ -563,6 +609,9 @@ namespace UnitTest.Issues.TestProtos { get { return global::UnitTest.Issues.TestProtos.UnittestIssues.internal__static_unittest_issues_ItemField__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public ItemField() { } public ItemField(ItemField other) { @@ -573,14 +622,23 @@ namespace UnitTest.Issues.TestProtos { return new ItemField(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + public const int ItemFieldNumber = 1; private int item_; public int Item { get { return item_; } - set { item_ = value; } + set { + pb::Freezable.CheckMutable(this); + item_ = value; + } } - public override bool Equals(object other) { return Equals(other as ItemField); } diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs index d9d33b10..d758ef5c 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs @@ -416,6 +416,9 @@ namespace Google.Protobuf.TestProtos { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestAllTypes__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public TestAllTypes() { } public TestAllTypes(TestAllTypes other) { @@ -484,176 +487,258 @@ namespace Google.Protobuf.TestProtos { return new TestAllTypes(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + if (singleNestedMessage_ != null) SingleNestedMessage.Freeze(); + if (singleForeignMessage_ != null) SingleForeignMessage.Freeze(); + if (singleImportMessage_ != null) SingleImportMessage.Freeze(); + if (singlePublicImportMessage_ != null) SinglePublicImportMessage.Freeze(); + repeatedInt32_.Freeze(); + repeatedInt64_.Freeze(); + repeatedUint32_.Freeze(); + repeatedUint64_.Freeze(); + repeatedSint32_.Freeze(); + repeatedSint64_.Freeze(); + repeatedFixed32_.Freeze(); + repeatedFixed64_.Freeze(); + repeatedSfixed32_.Freeze(); + repeatedSfixed64_.Freeze(); + repeatedFloat_.Freeze(); + repeatedDouble_.Freeze(); + repeatedBool_.Freeze(); + repeatedString_.Freeze(); + repeatedBytes_.Freeze(); + repeatedNestedMessage_.Freeze(); + repeatedForeignMessage_.Freeze(); + repeatedImportMessage_.Freeze(); + repeatedNestedEnum_.Freeze(); + repeatedForeignEnum_.Freeze(); + repeatedImportEnum_.Freeze(); + repeatedPublicImportMessage_.Freeze(); + if (oneofField_ is IFreezable) ((IFreezable) oneofField_).Freeze(); + } + public const int SingleInt32FieldNumber = 1; private int singleInt32_; public int SingleInt32 { get { return singleInt32_; } - set { singleInt32_ = value; } + set { + pb::Freezable.CheckMutable(this); + singleInt32_ = value; + } } - public const int SingleInt64FieldNumber = 2; private long singleInt64_; public long SingleInt64 { get { return singleInt64_; } - set { singleInt64_ = value; } + set { + pb::Freezable.CheckMutable(this); + singleInt64_ = value; + } } - public const int SingleUint32FieldNumber = 3; private uint singleUint32_; public uint SingleUint32 { get { return singleUint32_; } - set { singleUint32_ = value; } + set { + pb::Freezable.CheckMutable(this); + singleUint32_ = value; + } } - public const int SingleUint64FieldNumber = 4; private ulong singleUint64_; public ulong SingleUint64 { get { return singleUint64_; } - set { singleUint64_ = value; } + set { + pb::Freezable.CheckMutable(this); + singleUint64_ = value; + } } - public const int SingleSint32FieldNumber = 5; private int singleSint32_; public int SingleSint32 { get { return singleSint32_; } - set { singleSint32_ = value; } + set { + pb::Freezable.CheckMutable(this); + singleSint32_ = value; + } } - public const int SingleSint64FieldNumber = 6; private long singleSint64_; public long SingleSint64 { get { return singleSint64_; } - set { singleSint64_ = value; } + set { + pb::Freezable.CheckMutable(this); + singleSint64_ = value; + } } - public const int SingleFixed32FieldNumber = 7; private uint singleFixed32_; public uint SingleFixed32 { get { return singleFixed32_; } - set { singleFixed32_ = value; } + set { + pb::Freezable.CheckMutable(this); + singleFixed32_ = value; + } } - public const int SingleFixed64FieldNumber = 8; private ulong singleFixed64_; public ulong SingleFixed64 { get { return singleFixed64_; } - set { singleFixed64_ = value; } + set { + pb::Freezable.CheckMutable(this); + singleFixed64_ = value; + } } - public const int SingleSfixed32FieldNumber = 9; private int singleSfixed32_; public int SingleSfixed32 { get { return singleSfixed32_; } - set { singleSfixed32_ = value; } + set { + pb::Freezable.CheckMutable(this); + singleSfixed32_ = value; + } } - public const int SingleSfixed64FieldNumber = 10; private long singleSfixed64_; public long SingleSfixed64 { get { return singleSfixed64_; } - set { singleSfixed64_ = value; } + set { + pb::Freezable.CheckMutable(this); + singleSfixed64_ = value; + } } - public const int SingleFloatFieldNumber = 11; private float singleFloat_; public float SingleFloat { get { return singleFloat_; } - set { singleFloat_ = value; } + set { + pb::Freezable.CheckMutable(this); + singleFloat_ = value; + } } - public const int SingleDoubleFieldNumber = 12; private double singleDouble_; public double SingleDouble { get { return singleDouble_; } - set { singleDouble_ = value; } + set { + pb::Freezable.CheckMutable(this); + singleDouble_ = value; + } } - public const int SingleBoolFieldNumber = 13; private bool singleBool_; public bool SingleBool { get { return singleBool_; } - set { singleBool_ = value; } + set { + pb::Freezable.CheckMutable(this); + singleBool_ = value; + } } - public const int SingleStringFieldNumber = 14; private string singleString_ = ""; public string SingleString { get { return singleString_; } - set { singleString_ = value ?? ""; } + set { + pb::Freezable.CheckMutable(this); + singleString_ = value ?? ""; + } } - public const int SingleBytesFieldNumber = 15; private pb::ByteString singleBytes_ = pb::ByteString.Empty; public pb::ByteString SingleBytes { get { return singleBytes_; } - set { singleBytes_ = value ?? pb::ByteString.Empty; } + set { + pb::Freezable.CheckMutable(this); + singleBytes_ = value ?? pb::ByteString.Empty; + } } - public const int SingleNestedMessageFieldNumber = 18; private global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage singleNestedMessage_; public global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage SingleNestedMessage { get { return singleNestedMessage_; } - set { singleNestedMessage_ = value; } + set { + pb::Freezable.CheckMutable(this); + singleNestedMessage_ = value; + } } public const int SingleForeignMessageFieldNumber = 19; private global::Google.Protobuf.TestProtos.ForeignMessage singleForeignMessage_; public global::Google.Protobuf.TestProtos.ForeignMessage SingleForeignMessage { get { return singleForeignMessage_; } - set { singleForeignMessage_ = value; } + set { + pb::Freezable.CheckMutable(this); + singleForeignMessage_ = value; + } } public const int SingleImportMessageFieldNumber = 20; private global::Google.Protobuf.TestProtos.ImportMessage singleImportMessage_; public global::Google.Protobuf.TestProtos.ImportMessage SingleImportMessage { get { return singleImportMessage_; } - set { singleImportMessage_ = value; } + set { + pb::Freezable.CheckMutable(this); + singleImportMessage_ = value; + } } public const int SingleNestedEnumFieldNumber = 21; private global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum singleNestedEnum_ = global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum.NESTED_ENUM_UNSPECIFIED; public global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum SingleNestedEnum { get { return singleNestedEnum_; } - set { singleNestedEnum_ = value; } + set { + pb::Freezable.CheckMutable(this); + singleNestedEnum_ = value; + } } - public const int SingleForeignEnumFieldNumber = 22; private global::Google.Protobuf.TestProtos.ForeignEnum singleForeignEnum_ = global::Google.Protobuf.TestProtos.ForeignEnum.FOREIGN_UNSPECIFIED; public global::Google.Protobuf.TestProtos.ForeignEnum SingleForeignEnum { get { return singleForeignEnum_; } - set { singleForeignEnum_ = value; } + set { + pb::Freezable.CheckMutable(this); + singleForeignEnum_ = value; + } } - public const int SingleImportEnumFieldNumber = 23; private global::Google.Protobuf.TestProtos.ImportEnum singleImportEnum_ = global::Google.Protobuf.TestProtos.ImportEnum.IMPORT_ENUM_UNSPECIFIED; public global::Google.Protobuf.TestProtos.ImportEnum SingleImportEnum { get { return singleImportEnum_; } - set { singleImportEnum_ = value; } + set { + pb::Freezable.CheckMutable(this); + singleImportEnum_ = value; + } } - public const int SinglePublicImportMessageFieldNumber = 26; private global::Google.Protobuf.TestProtos.PublicImportMessage singlePublicImportMessage_; public global::Google.Protobuf.TestProtos.PublicImportMessage SinglePublicImportMessage { get { return singlePublicImportMessage_; } - set { singlePublicImportMessage_ = value; } + set { + pb::Freezable.CheckMutable(this); + singlePublicImportMessage_ = value; + } } public const int RepeatedInt32FieldNumber = 31; @@ -792,6 +877,7 @@ namespace Google.Protobuf.TestProtos { public uint OneofUint32 { get { return oneofFieldCase_ == OneofFieldOneofCase.OneofUint32 ? (uint) oneofField_ : 0; } set { + pb::Freezable.CheckMutable(this); oneofField_ = value; oneofFieldCase_ = OneofFieldOneofCase.OneofUint32; } @@ -801,6 +887,7 @@ namespace Google.Protobuf.TestProtos { public global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage OneofNestedMessage { get { return oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage ? (global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage) oneofField_ : null; } set { + pb::Freezable.CheckMutable(this); oneofField_ = value; oneofFieldCase_ = value == null ? OneofFieldOneofCase.None : OneofFieldOneofCase.OneofNestedMessage; } @@ -810,6 +897,7 @@ namespace Google.Protobuf.TestProtos { public string OneofString { get { return oneofFieldCase_ == OneofFieldOneofCase.OneofString ? (string) oneofField_ : ""; } set { + pb::Freezable.CheckMutable(this); oneofField_ = value ?? ""; oneofFieldCase_ = OneofFieldOneofCase.OneofString; } @@ -819,6 +907,7 @@ namespace Google.Protobuf.TestProtos { public pb::ByteString OneofBytes { get { return oneofFieldCase_ == OneofFieldOneofCase.OneofBytes ? (pb::ByteString) oneofField_ : pb::ByteString.Empty; } set { + pb::Freezable.CheckMutable(this); oneofField_ = value ?? pb::ByteString.Empty; oneofFieldCase_ = OneofFieldOneofCase.OneofBytes; } @@ -838,6 +927,7 @@ namespace Google.Protobuf.TestProtos { } public void ClearOneofField() { + pb::Freezable.CheckMutable(this); oneofFieldCase_ = OneofFieldOneofCase.None; oneofField_ = null; } @@ -868,10 +958,14 @@ namespace Google.Protobuf.TestProtos { if (SingleBool != other.SingleBool) return false; if (SingleString != other.SingleString) return false; if (SingleBytes != other.SingleBytes) return false; - if (!object.Equals(SingleNestedMessage, other.SingleNestedMessage)) return false;if (!object.Equals(SingleForeignMessage, other.SingleForeignMessage)) return false;if (!object.Equals(SingleImportMessage, other.SingleImportMessage)) return false;if (SingleNestedEnum != other.SingleNestedEnum) return false; + if (!object.Equals(SingleNestedMessage, other.SingleNestedMessage)) return false; + if (!object.Equals(SingleForeignMessage, other.SingleForeignMessage)) return false; + if (!object.Equals(SingleImportMessage, other.SingleImportMessage)) return false; + if (SingleNestedEnum != other.SingleNestedEnum) return false; if (SingleForeignEnum != other.SingleForeignEnum) return false; if (SingleImportEnum != other.SingleImportEnum) return false; - if (!object.Equals(SinglePublicImportMessage, other.SinglePublicImportMessage)) return false;if(!repeatedInt32_.Equals(other.repeatedInt32_)) return false; + if (!object.Equals(SinglePublicImportMessage, other.SinglePublicImportMessage)) return false; + if(!repeatedInt32_.Equals(other.repeatedInt32_)) return false; if(!repeatedInt64_.Equals(other.repeatedInt64_)) return false; if(!repeatedUint32_.Equals(other.repeatedUint32_)) return false; if(!repeatedUint64_.Equals(other.repeatedUint64_)) return false; @@ -894,7 +988,8 @@ namespace Google.Protobuf.TestProtos { if(!repeatedImportEnum_.Equals(other.repeatedImportEnum_)) return false; if(!repeatedPublicImportMessage_.Equals(other.repeatedPublicImportMessage_)) return false; if (OneofUint32 != other.OneofUint32) return false; - if (!object.Equals(OneofNestedMessage, other.OneofNestedMessage)) return false;if (OneofString != other.OneofString) return false; + if (!object.Equals(OneofNestedMessage, other.OneofNestedMessage)) return false; + if (OneofString != other.OneofString) return false; if (OneofBytes != other.OneofBytes) return false; return true; } @@ -1764,6 +1859,9 @@ namespace Google.Protobuf.TestProtos { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestAllTypes_NestedMessage__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public NestedMessage() { } public NestedMessage(NestedMessage other) { @@ -1774,14 +1872,23 @@ namespace Google.Protobuf.TestProtos { return new NestedMessage(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + public const int BbFieldNumber = 1; private int bb_; public int Bb { get { return bb_; } - set { bb_ = value; } + set { + pb::Freezable.CheckMutable(this); + bb_ = value; + } } - public override bool Equals(object other) { return Equals(other as NestedMessage); } @@ -1867,6 +1974,9 @@ namespace Google.Protobuf.TestProtos { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_NestedTestAllTypes__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public NestedTestAllTypes() { } public NestedTestAllTypes(NestedTestAllTypes other) { @@ -1879,18 +1989,34 @@ namespace Google.Protobuf.TestProtos { return new NestedTestAllTypes(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + if (child_ != null) Child.Freeze(); + if (payload_ != null) Payload.Freeze(); + repeatedChild_.Freeze(); + } + public const int ChildFieldNumber = 1; private global::Google.Protobuf.TestProtos.NestedTestAllTypes child_; public global::Google.Protobuf.TestProtos.NestedTestAllTypes Child { get { return child_; } - set { child_ = value; } + set { + pb::Freezable.CheckMutable(this); + child_ = value; + } } public const int PayloadFieldNumber = 2; private global::Google.Protobuf.TestProtos.TestAllTypes payload_; public global::Google.Protobuf.TestProtos.TestAllTypes Payload { get { return payload_; } - set { payload_ = value; } + set { + pb::Freezable.CheckMutable(this); + payload_ = value; + } } public const int RepeatedChildFieldNumber = 3; @@ -1910,7 +2036,9 @@ namespace Google.Protobuf.TestProtos { if (ReferenceEquals(other, this)) { return true; } - if (!object.Equals(Child, other.Child)) return false;if (!object.Equals(Payload, other.Payload)) return false;if(!repeatedChild_.Equals(other.repeatedChild_)) return false; + if (!object.Equals(Child, other.Child)) return false; + if (!object.Equals(Payload, other.Payload)) return false; + if(!repeatedChild_.Equals(other.repeatedChild_)) return false; return true; } @@ -2021,6 +2149,9 @@ namespace Google.Protobuf.TestProtos { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestDeprecatedFields__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public TestDeprecatedFields() { } public TestDeprecatedFields(TestDeprecatedFields other) { @@ -2031,15 +2162,24 @@ namespace Google.Protobuf.TestProtos { return new TestDeprecatedFields(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + public const int DeprecatedInt32FieldNumber = 1; private int deprecatedInt32_; [global::System.ObsoleteAttribute()] public int DeprecatedInt32 { get { return deprecatedInt32_; } - set { deprecatedInt32_ = value; } + set { + pb::Freezable.CheckMutable(this); + deprecatedInt32_ = value; + } } - public override bool Equals(object other) { return Equals(other as TestDeprecatedFields); } @@ -2120,6 +2260,9 @@ namespace Google.Protobuf.TestProtos { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_ForeignMessage__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public ForeignMessage() { } public ForeignMessage(ForeignMessage other) { @@ -2130,14 +2273,23 @@ namespace Google.Protobuf.TestProtos { return new ForeignMessage(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + public const int CFieldNumber = 1; private int c_; public int C { get { return c_; } - set { c_ = value; } + set { + pb::Freezable.CheckMutable(this); + c_ = value; + } } - public override bool Equals(object other) { return Equals(other as ForeignMessage); } @@ -2218,6 +2370,9 @@ namespace Google.Protobuf.TestProtos { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestReservedFields__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public TestReservedFields() { } public TestReservedFields(TestReservedFields other) { @@ -2227,6 +2382,13 @@ namespace Google.Protobuf.TestProtos { return new TestReservedFields(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + public override bool Equals(object other) { return Equals(other as TestReservedFields); } @@ -2291,6 +2453,9 @@ namespace Google.Protobuf.TestProtos { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestForeignNested__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public TestForeignNested() { } public TestForeignNested(TestForeignNested other) { @@ -2301,11 +2466,22 @@ namespace Google.Protobuf.TestProtos { return new TestForeignNested(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + if (foreignNested_ != null) ForeignNested.Freeze(); + } + public const int ForeignNestedFieldNumber = 1; private global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage foreignNested_; public global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage ForeignNested { get { return foreignNested_; } - set { foreignNested_ = value; } + set { + pb::Freezable.CheckMutable(this); + foreignNested_ = value; + } } public override bool Equals(object other) { @@ -2319,7 +2495,8 @@ namespace Google.Protobuf.TestProtos { if (ReferenceEquals(other, this)) { return true; } - if (!object.Equals(ForeignNested, other.ForeignNested)) return false; return true; + if (!object.Equals(ForeignNested, other.ForeignNested)) return false; + return true; } public override int GetHashCode() { @@ -2393,6 +2570,9 @@ namespace Google.Protobuf.TestProtos { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestReallyLargeTagNumber__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public TestReallyLargeTagNumber() { } public TestReallyLargeTagNumber(TestReallyLargeTagNumber other) { @@ -2404,22 +2584,33 @@ namespace Google.Protobuf.TestProtos { return new TestReallyLargeTagNumber(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + public const int AFieldNumber = 1; private int a_; public int A { get { return a_; } - set { a_ = value; } + set { + pb::Freezable.CheckMutable(this); + a_ = value; + } } - public const int BbFieldNumber = 268435455; private int bb_; public int Bb { get { return bb_; } - set { bb_ = value; } + set { + pb::Freezable.CheckMutable(this); + bb_ = value; + } } - public override bool Equals(object other) { return Equals(other as TestReallyLargeTagNumber); } @@ -2516,6 +2707,9 @@ namespace Google.Protobuf.TestProtos { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestRecursiveMessage__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public TestRecursiveMessage() { } public TestRecursiveMessage(TestRecursiveMessage other) { @@ -2527,21 +2721,34 @@ namespace Google.Protobuf.TestProtos { return new TestRecursiveMessage(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + if (a_ != null) A.Freeze(); + } + public const int AFieldNumber = 1; private global::Google.Protobuf.TestProtos.TestRecursiveMessage a_; public global::Google.Protobuf.TestProtos.TestRecursiveMessage A { get { return a_; } - set { a_ = value; } + set { + pb::Freezable.CheckMutable(this); + a_ = value; + } } public const int IFieldNumber = 2; private int i_; public int I { get { return i_; } - set { i_ = value; } + set { + pb::Freezable.CheckMutable(this); + i_ = value; + } } - public override bool Equals(object other) { return Equals(other as TestRecursiveMessage); } @@ -2553,7 +2760,8 @@ namespace Google.Protobuf.TestProtos { if (ReferenceEquals(other, this)) { return true; } - if (!object.Equals(A, other.A)) return false;if (I != other.I) return false; + if (!object.Equals(A, other.A)) return false; + if (I != other.I) return false; return true; } @@ -2643,6 +2851,9 @@ namespace Google.Protobuf.TestProtos { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestMutualRecursionA__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public TestMutualRecursionA() { } public TestMutualRecursionA(TestMutualRecursionA other) { @@ -2653,11 +2864,22 @@ namespace Google.Protobuf.TestProtos { return new TestMutualRecursionA(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + if (bb_ != null) Bb.Freeze(); + } + public const int BbFieldNumber = 1; private global::Google.Protobuf.TestProtos.TestMutualRecursionB bb_; public global::Google.Protobuf.TestProtos.TestMutualRecursionB Bb { get { return bb_; } - set { bb_ = value; } + set { + pb::Freezable.CheckMutable(this); + bb_ = value; + } } public override bool Equals(object other) { @@ -2671,7 +2893,8 @@ namespace Google.Protobuf.TestProtos { if (ReferenceEquals(other, this)) { return true; } - if (!object.Equals(Bb, other.Bb)) return false; return true; + if (!object.Equals(Bb, other.Bb)) return false; + return true; } public override int GetHashCode() { @@ -2745,6 +2968,9 @@ namespace Google.Protobuf.TestProtos { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestMutualRecursionB__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public TestMutualRecursionB() { } public TestMutualRecursionB(TestMutualRecursionB other) { @@ -2756,21 +2982,34 @@ namespace Google.Protobuf.TestProtos { return new TestMutualRecursionB(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + if (a_ != null) A.Freeze(); + } + public const int AFieldNumber = 1; private global::Google.Protobuf.TestProtos.TestMutualRecursionA a_; public global::Google.Protobuf.TestProtos.TestMutualRecursionA A { get { return a_; } - set { a_ = value; } + set { + pb::Freezable.CheckMutable(this); + a_ = value; + } } public const int OptionalInt32FieldNumber = 2; private int optionalInt32_; public int OptionalInt32 { get { return optionalInt32_; } - set { optionalInt32_ = value; } + set { + pb::Freezable.CheckMutable(this); + optionalInt32_ = value; + } } - public override bool Equals(object other) { return Equals(other as TestMutualRecursionB); } @@ -2782,7 +3021,8 @@ namespace Google.Protobuf.TestProtos { if (ReferenceEquals(other, this)) { return true; } - if (!object.Equals(A, other.A)) return false;if (OptionalInt32 != other.OptionalInt32) return false; + if (!object.Equals(A, other.A)) return false; + if (OptionalInt32 != other.OptionalInt32) return false; return true; } @@ -2872,6 +3112,9 @@ namespace Google.Protobuf.TestProtos { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestCamelCaseFieldNames__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public TestCamelCaseFieldNames() { } public TestCamelCaseFieldNames(TestCamelCaseFieldNames other) { @@ -2889,35 +3132,56 @@ namespace Google.Protobuf.TestProtos { return new TestCamelCaseFieldNames(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + if (messageField_ != null) MessageField.Freeze(); + repeatedPrimitiveField_.Freeze(); + repeatedStringField_.Freeze(); + repeatedEnumField_.Freeze(); + repeatedMessageField_.Freeze(); + } + public const int PrimitiveFieldFieldNumber = 1; private int primitiveField_; public int PrimitiveField { get { return primitiveField_; } - set { primitiveField_ = value; } + set { + pb::Freezable.CheckMutable(this); + primitiveField_ = value; + } } - public const int StringFieldFieldNumber = 2; private string stringField_ = ""; public string StringField { get { return stringField_; } - set { stringField_ = value ?? ""; } + set { + pb::Freezable.CheckMutable(this); + stringField_ = value ?? ""; + } } - public const int EnumFieldFieldNumber = 3; private global::Google.Protobuf.TestProtos.ForeignEnum enumField_ = global::Google.Protobuf.TestProtos.ForeignEnum.FOREIGN_UNSPECIFIED; public global::Google.Protobuf.TestProtos.ForeignEnum EnumField { get { return enumField_; } - set { enumField_ = value; } + set { + pb::Freezable.CheckMutable(this); + enumField_ = value; + } } - public const int MessageFieldFieldNumber = 4; private global::Google.Protobuf.TestProtos.ForeignMessage messageField_; public global::Google.Protobuf.TestProtos.ForeignMessage MessageField { get { return messageField_; } - set { messageField_ = value; } + set { + pb::Freezable.CheckMutable(this); + messageField_ = value; + } } public const int RepeatedPrimitiveFieldFieldNumber = 7; @@ -2958,7 +3222,8 @@ namespace Google.Protobuf.TestProtos { if (PrimitiveField != other.PrimitiveField) return false; if (StringField != other.StringField) return false; if (EnumField != other.EnumField) return false; - if (!object.Equals(MessageField, other.MessageField)) return false;if(!repeatedPrimitiveField_.Equals(other.repeatedPrimitiveField_)) return false; + if (!object.Equals(MessageField, other.MessageField)) return false; + if(!repeatedPrimitiveField_.Equals(other.repeatedPrimitiveField_)) return false; if(!repeatedStringField_.Equals(other.repeatedStringField_)) return false; if(!repeatedEnumField_.Equals(other.repeatedEnumField_)) return false; if(!repeatedMessageField_.Equals(other.repeatedMessageField_)) return false; @@ -3151,6 +3416,9 @@ namespace Google.Protobuf.TestProtos { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestFieldOrderings__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public TestFieldOrderings() { } public TestFieldOrderings(TestFieldOrderings other) { @@ -3164,35 +3432,52 @@ namespace Google.Protobuf.TestProtos { return new TestFieldOrderings(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + if (singleNestedMessage_ != null) SingleNestedMessage.Freeze(); + } + public const int MyStringFieldNumber = 11; private string myString_ = ""; public string MyString { get { return myString_; } - set { myString_ = value ?? ""; } + set { + pb::Freezable.CheckMutable(this); + myString_ = value ?? ""; + } } - public const int MyIntFieldNumber = 1; private long myInt_; public long MyInt { get { return myInt_; } - set { myInt_ = value; } + set { + pb::Freezable.CheckMutable(this); + myInt_ = value; + } } - public const int MyFloatFieldNumber = 101; private float myFloat_; public float MyFloat { get { return myFloat_; } - set { myFloat_ = value; } + set { + pb::Freezable.CheckMutable(this); + myFloat_ = value; + } } - public const int SingleNestedMessageFieldNumber = 200; private global::Google.Protobuf.TestProtos.TestFieldOrderings.Types.NestedMessage singleNestedMessage_; public global::Google.Protobuf.TestProtos.TestFieldOrderings.Types.NestedMessage SingleNestedMessage { get { return singleNestedMessage_; } - set { singleNestedMessage_ = value; } + set { + pb::Freezable.CheckMutable(this); + singleNestedMessage_ = value; + } } public override bool Equals(object other) { @@ -3209,7 +3494,8 @@ namespace Google.Protobuf.TestProtos { if (MyString != other.MyString) return false; if (MyInt != other.MyInt) return false; if (MyFloat != other.MyFloat) return false; - if (!object.Equals(SingleNestedMessage, other.SingleNestedMessage)) return false; return true; + if (!object.Equals(SingleNestedMessage, other.SingleNestedMessage)) return false; + return true; } public override int GetHashCode() { @@ -3329,6 +3615,9 @@ namespace Google.Protobuf.TestProtos { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestFieldOrderings_NestedMessage__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public NestedMessage() { } public NestedMessage(NestedMessage other) { @@ -3340,22 +3629,33 @@ namespace Google.Protobuf.TestProtos { return new NestedMessage(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + public const int OoFieldNumber = 2; private long oo_; public long Oo { get { return oo_; } - set { oo_ = value; } + set { + pb::Freezable.CheckMutable(this); + oo_ = value; + } } - public const int BbFieldNumber = 1; private int bb_; public int Bb { get { return bb_; } - set { bb_ = value; } + set { + pb::Freezable.CheckMutable(this); + bb_ = value; + } } - public override bool Equals(object other) { return Equals(other as NestedMessage); } @@ -3457,6 +3757,9 @@ namespace Google.Protobuf.TestProtos { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_SparseEnumMessage__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public SparseEnumMessage() { } public SparseEnumMessage(SparseEnumMessage other) { @@ -3467,14 +3770,23 @@ namespace Google.Protobuf.TestProtos { return new SparseEnumMessage(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + public const int SparseEnumFieldNumber = 1; private global::Google.Protobuf.TestProtos.TestSparseEnum sparseEnum_ = global::Google.Protobuf.TestProtos.TestSparseEnum.TEST_SPARSE_ENUM_UNSPECIFIED; public global::Google.Protobuf.TestProtos.TestSparseEnum SparseEnum { get { return sparseEnum_; } - set { sparseEnum_ = value; } + set { + pb::Freezable.CheckMutable(this); + sparseEnum_ = value; + } } - public override bool Equals(object other) { return Equals(other as SparseEnumMessage); } @@ -3555,6 +3867,9 @@ namespace Google.Protobuf.TestProtos { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_OneString__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public OneString() { } public OneString(OneString other) { @@ -3565,14 +3880,23 @@ namespace Google.Protobuf.TestProtos { return new OneString(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + public const int DataFieldNumber = 1; private string data_ = ""; public string Data { get { return data_; } - set { data_ = value ?? ""; } + set { + pb::Freezable.CheckMutable(this); + data_ = value ?? ""; + } } - public override bool Equals(object other) { return Equals(other as OneString); } @@ -3653,6 +3977,9 @@ namespace Google.Protobuf.TestProtos { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_MoreString__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public MoreString() { } public MoreString(MoreString other) { @@ -3663,6 +3990,14 @@ namespace Google.Protobuf.TestProtos { return new MoreString(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + data_.Freeze(); + } + public const int DataFieldNumber = 1; private readonly pbc::RepeatedField data_ = new pbc::RepeatedField(); public pbc::RepeatedField Data { @@ -3751,6 +4086,9 @@ namespace Google.Protobuf.TestProtos { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_OneBytes__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public OneBytes() { } public OneBytes(OneBytes other) { @@ -3761,14 +4099,23 @@ namespace Google.Protobuf.TestProtos { return new OneBytes(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + public const int DataFieldNumber = 1; private pb::ByteString data_ = pb::ByteString.Empty; public pb::ByteString Data { get { return data_; } - set { data_ = value ?? pb::ByteString.Empty; } + set { + pb::Freezable.CheckMutable(this); + data_ = value ?? pb::ByteString.Empty; + } } - public override bool Equals(object other) { return Equals(other as OneBytes); } @@ -3849,6 +4196,9 @@ namespace Google.Protobuf.TestProtos { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_MoreBytes__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public MoreBytes() { } public MoreBytes(MoreBytes other) { @@ -3859,14 +4209,23 @@ namespace Google.Protobuf.TestProtos { return new MoreBytes(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + public const int DataFieldNumber = 1; private pb::ByteString data_ = pb::ByteString.Empty; public pb::ByteString Data { get { return data_; } - set { data_ = value ?? pb::ByteString.Empty; } + set { + pb::Freezable.CheckMutable(this); + data_ = value ?? pb::ByteString.Empty; + } } - public override bool Equals(object other) { return Equals(other as MoreBytes); } @@ -3947,6 +4306,9 @@ namespace Google.Protobuf.TestProtos { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_Int32Message__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public Int32Message() { } public Int32Message(Int32Message other) { @@ -3957,14 +4319,23 @@ namespace Google.Protobuf.TestProtos { return new Int32Message(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + public const int DataFieldNumber = 1; private int data_; public int Data { get { return data_; } - set { data_ = value; } + set { + pb::Freezable.CheckMutable(this); + data_ = value; + } } - public override bool Equals(object other) { return Equals(other as Int32Message); } @@ -4045,6 +4416,9 @@ namespace Google.Protobuf.TestProtos { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_Uint32Message__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public Uint32Message() { } public Uint32Message(Uint32Message other) { @@ -4055,14 +4429,23 @@ namespace Google.Protobuf.TestProtos { return new Uint32Message(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + public const int DataFieldNumber = 1; private uint data_; public uint Data { get { return data_; } - set { data_ = value; } + set { + pb::Freezable.CheckMutable(this); + data_ = value; + } } - public override bool Equals(object other) { return Equals(other as Uint32Message); } @@ -4143,6 +4526,9 @@ namespace Google.Protobuf.TestProtos { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_Int64Message__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public Int64Message() { } public Int64Message(Int64Message other) { @@ -4153,14 +4539,23 @@ namespace Google.Protobuf.TestProtos { return new Int64Message(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + public const int DataFieldNumber = 1; private long data_; public long Data { get { return data_; } - set { data_ = value; } + set { + pb::Freezable.CheckMutable(this); + data_ = value; + } } - public override bool Equals(object other) { return Equals(other as Int64Message); } @@ -4241,6 +4636,9 @@ namespace Google.Protobuf.TestProtos { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_Uint64Message__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public Uint64Message() { } public Uint64Message(Uint64Message other) { @@ -4251,14 +4649,23 @@ namespace Google.Protobuf.TestProtos { return new Uint64Message(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + public const int DataFieldNumber = 1; private ulong data_; public ulong Data { get { return data_; } - set { data_ = value; } + set { + pb::Freezable.CheckMutable(this); + data_ = value; + } } - public override bool Equals(object other) { return Equals(other as Uint64Message); } @@ -4339,6 +4746,9 @@ namespace Google.Protobuf.TestProtos { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_BoolMessage__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public BoolMessage() { } public BoolMessage(BoolMessage other) { @@ -4349,14 +4759,23 @@ namespace Google.Protobuf.TestProtos { return new BoolMessage(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + public const int DataFieldNumber = 1; private bool data_; public bool Data { get { return data_; } - set { data_ = value; } + set { + pb::Freezable.CheckMutable(this); + data_ = value; + } } - public override bool Equals(object other) { return Equals(other as BoolMessage); } @@ -4437,6 +4856,9 @@ namespace Google.Protobuf.TestProtos { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestOneof__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public TestOneof() { } public TestOneof(TestOneof other) { @@ -4458,10 +4880,19 @@ namespace Google.Protobuf.TestProtos { return new TestOneof(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + if (foo_ is IFreezable) ((IFreezable) foo_).Freeze(); + } + public const int FooIntFieldNumber = 1; public int FooInt { get { return fooCase_ == FooOneofCase.FooInt ? (int) foo_ : 0; } set { + pb::Freezable.CheckMutable(this); foo_ = value; fooCase_ = FooOneofCase.FooInt; } @@ -4471,6 +4902,7 @@ namespace Google.Protobuf.TestProtos { public string FooString { get { return fooCase_ == FooOneofCase.FooString ? (string) foo_ : ""; } set { + pb::Freezable.CheckMutable(this); foo_ = value ?? ""; fooCase_ = FooOneofCase.FooString; } @@ -4480,6 +4912,7 @@ namespace Google.Protobuf.TestProtos { public global::Google.Protobuf.TestProtos.TestAllTypes FooMessage { get { return fooCase_ == FooOneofCase.FooMessage ? (global::Google.Protobuf.TestProtos.TestAllTypes) foo_ : null; } set { + pb::Freezable.CheckMutable(this); foo_ = value; fooCase_ = value == null ? FooOneofCase.None : FooOneofCase.FooMessage; } @@ -4498,6 +4931,7 @@ namespace Google.Protobuf.TestProtos { } public void ClearFoo() { + pb::Freezable.CheckMutable(this); fooCase_ = FooOneofCase.None; foo_ = null; } @@ -4515,7 +4949,8 @@ namespace Google.Protobuf.TestProtos { } if (FooInt != other.FooInt) return false; if (FooString != other.FooString) return false; - if (!object.Equals(FooMessage, other.FooMessage)) return false; return true; + if (!object.Equals(FooMessage, other.FooMessage)) return false; + return true; } public override int GetHashCode() { @@ -4621,6 +5056,9 @@ namespace Google.Protobuf.TestProtos { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestPackedTypes__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public TestPackedTypes() { } public TestPackedTypes(TestPackedTypes other) { @@ -4644,6 +5082,27 @@ namespace Google.Protobuf.TestProtos { return new TestPackedTypes(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + packedInt32_.Freeze(); + packedInt64_.Freeze(); + packedUint32_.Freeze(); + packedUint64_.Freeze(); + packedSint32_.Freeze(); + packedSint64_.Freeze(); + packedFixed32_.Freeze(); + packedFixed64_.Freeze(); + packedSfixed32_.Freeze(); + packedSfixed64_.Freeze(); + packedFloat_.Freeze(); + packedDouble_.Freeze(); + packedBool_.Freeze(); + packedEnum_.Freeze(); + } + public const int PackedInt32FieldNumber = 90; private readonly pbc::RepeatedField packedInt32_ = new pbc::RepeatedField(); public pbc::RepeatedField PackedInt32 { @@ -5058,6 +5517,9 @@ namespace Google.Protobuf.TestProtos { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestUnpackedTypes__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public TestUnpackedTypes() { } public TestUnpackedTypes(TestUnpackedTypes other) { @@ -5081,6 +5543,27 @@ namespace Google.Protobuf.TestProtos { return new TestUnpackedTypes(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + unpackedInt32_.Freeze(); + unpackedInt64_.Freeze(); + unpackedUint32_.Freeze(); + unpackedUint64_.Freeze(); + unpackedSint32_.Freeze(); + unpackedSint64_.Freeze(); + unpackedFixed32_.Freeze(); + unpackedFixed64_.Freeze(); + unpackedSfixed32_.Freeze(); + unpackedSfixed64_.Freeze(); + unpackedFloat_.Freeze(); + unpackedDouble_.Freeze(); + unpackedBool_.Freeze(); + unpackedEnum_.Freeze(); + } + public const int UnpackedInt32FieldNumber = 90; private readonly pbc::RepeatedField unpackedInt32_ = new pbc::RepeatedField(); public pbc::RepeatedField UnpackedInt32 { @@ -5481,6 +5964,9 @@ namespace Google.Protobuf.TestProtos { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestRepeatedScalarDifferentTagSizes__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public TestRepeatedScalarDifferentTagSizes() { } public TestRepeatedScalarDifferentTagSizes(TestRepeatedScalarDifferentTagSizes other) { @@ -5496,6 +5982,19 @@ namespace Google.Protobuf.TestProtos { return new TestRepeatedScalarDifferentTagSizes(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + repeatedFixed32_.Freeze(); + repeatedInt32_.Freeze(); + repeatedFixed64_.Freeze(); + repeatedInt64_.Freeze(); + repeatedFloat_.Freeze(); + repeatedUint64_.Freeze(); + } + public const int RepeatedFixed32FieldNumber = 12; private readonly pbc::RepeatedField repeatedFixed32_ = new pbc::RepeatedField(); public pbc::RepeatedField RepeatedFixed32 { @@ -5710,6 +6209,9 @@ namespace Google.Protobuf.TestProtos { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestCommentInjectionMessage__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public TestCommentInjectionMessage() { } public TestCommentInjectionMessage(TestCommentInjectionMessage other) { @@ -5720,14 +6222,23 @@ namespace Google.Protobuf.TestProtos { return new TestCommentInjectionMessage(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + public const int AFieldNumber = 1; private string a_ = ""; public string A { get { return a_; } - set { a_ = value ?? ""; } + set { + pb::Freezable.CheckMutable(this); + a_ = value ?? ""; + } } - public override bool Equals(object other) { return Equals(other as TestCommentInjectionMessage); } @@ -5808,6 +6319,9 @@ namespace Google.Protobuf.TestProtos { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_FooRequest__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public FooRequest() { } public FooRequest(FooRequest other) { @@ -5817,6 +6331,13 @@ namespace Google.Protobuf.TestProtos { return new FooRequest(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + public override bool Equals(object other) { return Equals(other as FooRequest); } @@ -5881,6 +6402,9 @@ namespace Google.Protobuf.TestProtos { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_FooResponse__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public FooResponse() { } public FooResponse(FooResponse other) { @@ -5890,6 +6414,13 @@ namespace Google.Protobuf.TestProtos { return new FooResponse(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + public override bool Equals(object other) { return Equals(other as FooResponse); } @@ -5954,6 +6485,9 @@ namespace Google.Protobuf.TestProtos { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_FooClientMessage__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public FooClientMessage() { } public FooClientMessage(FooClientMessage other) { @@ -5963,6 +6497,13 @@ namespace Google.Protobuf.TestProtos { return new FooClientMessage(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + public override bool Equals(object other) { return Equals(other as FooClientMessage); } @@ -6027,6 +6568,9 @@ namespace Google.Protobuf.TestProtos { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_FooServerMessage__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public FooServerMessage() { } public FooServerMessage(FooServerMessage other) { @@ -6036,6 +6580,13 @@ namespace Google.Protobuf.TestProtos { return new FooServerMessage(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + public override bool Equals(object other) { return Equals(other as FooServerMessage); } @@ -6100,6 +6651,9 @@ namespace Google.Protobuf.TestProtos { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_BarRequest__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public BarRequest() { } public BarRequest(BarRequest other) { @@ -6109,6 +6663,13 @@ namespace Google.Protobuf.TestProtos { return new BarRequest(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + public override bool Equals(object other) { return Equals(other as BarRequest); } @@ -6173,6 +6734,9 @@ namespace Google.Protobuf.TestProtos { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_BarResponse__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public BarResponse() { } public BarResponse(BarResponse other) { @@ -6182,6 +6746,13 @@ namespace Google.Protobuf.TestProtos { return new BarResponse(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + public override bool Equals(object other) { return Equals(other as BarResponse); } diff --git a/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs b/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs index 5100e4db..ebfc522f 100644 --- a/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs +++ b/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs @@ -4,10 +4,16 @@ using System.Collections.Generic; namespace Google.Protobuf.Collections { - public sealed class RepeatedField : IList, IEquatable> + /// + /// The contents of a repeated field: essentially, a collection with some extra + /// restrictions (no null values) and capabilities (deep cloning and freezing). + /// + /// The element type of the repeated field. + public sealed class RepeatedField : IList, IDeepCloneable>, IEquatable>, IFreezable { private static readonly T[] EmptyArray = new T[0]; + private bool frozen; private const int MinArraySize = 8; private T[] array = EmptyArray; private int count = 0; @@ -26,6 +32,7 @@ namespace Google.Protobuf.Collections public RepeatedField Clone() { RepeatedField clone = new RepeatedField(); + // Clone is implicitly *not* frozen, even if this object is. if (array != EmptyArray) { clone.array = (T[])array.Clone(); @@ -42,6 +49,21 @@ namespace Google.Protobuf.Collections return clone; } + public bool IsFrozen { get { return frozen; } } + + public void Freeze() + { + frozen = true; + IFreezable[] freezableArray = array as IFreezable[]; + if (freezableArray != null) + { + for (int i = 0; i < count; i++) + { + freezableArray[i].Freeze(); + } + } + } + private void EnsureSize(int size) { size = Math.Max(size, MinArraySize); @@ -60,6 +82,7 @@ namespace Google.Protobuf.Collections { throw new ArgumentNullException("item"); } + this.CheckMutable(); EnsureSize(count + 1); array[count++] = item; } @@ -70,6 +93,7 @@ namespace Google.Protobuf.Collections /// internal void AddInt32(int item) { + this.CheckMutable(); EnsureSize(count + 1); int[] castArray = (int[]) (object) array; castArray[count++] = item; @@ -77,6 +101,7 @@ namespace Google.Protobuf.Collections public void Clear() { + this.CheckMutable(); array = EmptyArray; count = 0; } @@ -93,6 +118,7 @@ namespace Google.Protobuf.Collections public bool Remove(T item) { + this.CheckMutable(); int index = IndexOf(item); if (index == -1) { @@ -107,7 +133,7 @@ namespace Google.Protobuf.Collections public int Count { get { return count; } } // TODO(jonskeet): If we implement freezing, make this reflect it. - public bool IsReadOnly { get { return false; } } + public bool IsReadOnly { get { return IsFrozen; } } public void Add(RepeatedField values) { @@ -115,6 +141,7 @@ namespace Google.Protobuf.Collections { throw new ArgumentNullException("values"); } + this.CheckMutable(); EnsureSize(count + values.count); // We know that all the values will be valid, because it's a RepeatedField. Array.Copy(values.array, 0, array, count, values.count); @@ -127,6 +154,7 @@ namespace Google.Protobuf.Collections { throw new ArgumentNullException("values"); } + this.CheckMutable(); // TODO: Check for ICollection and get the Count? foreach (T item in values) { @@ -227,6 +255,7 @@ namespace Google.Protobuf.Collections { throw new ArgumentOutOfRangeException("index"); } + this.CheckMutable(); EnsureSize(count + 1); Array.Copy(array, index, array, index + 1, count - index); count++; @@ -238,6 +267,7 @@ namespace Google.Protobuf.Collections { throw new ArgumentOutOfRangeException("index"); } + this.CheckMutable(); Array.Copy(array, index + 1, array, index, count - index - 1); count--; array[count] = default(T); @@ -259,6 +289,7 @@ namespace Google.Protobuf.Collections { throw new ArgumentOutOfRangeException("index"); } + this.CheckMutable(); if (value == null) { throw new ArgumentNullException("value"); diff --git a/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs b/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs index 23d5e964..eedb21fe 100644 --- a/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs +++ b/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs @@ -292,6 +292,9 @@ namespace Google.Protobuf.DescriptorProtos { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FileDescriptorSet__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public FileDescriptorSet() { } public FileDescriptorSet(FileDescriptorSet other) { @@ -302,6 +305,14 @@ namespace Google.Protobuf.DescriptorProtos { return new FileDescriptorSet(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + file_.Freeze(); + } + public const int FileFieldNumber = 1; private readonly pbc::RepeatedField file_ = new pbc::RepeatedField(); public pbc::RepeatedField File { @@ -388,6 +399,9 @@ namespace Google.Protobuf.DescriptorProtos { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FileDescriptorProto__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public FileDescriptorProto() { } public FileDescriptorProto(FileDescriptorProto other) { @@ -409,22 +423,42 @@ namespace Google.Protobuf.DescriptorProtos { return new FileDescriptorProto(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + dependency_.Freeze(); + publicDependency_.Freeze(); + weakDependency_.Freeze(); + messageType_.Freeze(); + enumType_.Freeze(); + service_.Freeze(); + extension_.Freeze(); + if (options_ != null) Options.Freeze(); + if (sourceCodeInfo_ != null) SourceCodeInfo.Freeze(); + } + public const int NameFieldNumber = 1; private string name_ = ""; public string Name { get { return name_; } - set { name_ = value ?? ""; } + set { + pb::Freezable.CheckMutable(this); + name_ = value ?? ""; + } } - public const int PackageFieldNumber = 2; private string package_ = ""; public string Package { get { return package_; } - set { package_ = value ?? ""; } + set { + pb::Freezable.CheckMutable(this); + package_ = value ?? ""; + } } - public const int DependencyFieldNumber = 3; private readonly pbc::RepeatedField dependency_ = new pbc::RepeatedField(); public pbc::RepeatedField Dependency { @@ -471,24 +505,32 @@ namespace Google.Protobuf.DescriptorProtos { private global::Google.Protobuf.DescriptorProtos.FileOptions options_; public global::Google.Protobuf.DescriptorProtos.FileOptions Options { get { return options_; } - set { options_ = value; } + set { + pb::Freezable.CheckMutable(this); + options_ = value; + } } public const int SourceCodeInfoFieldNumber = 9; private global::Google.Protobuf.DescriptorProtos.SourceCodeInfo sourceCodeInfo_; public global::Google.Protobuf.DescriptorProtos.SourceCodeInfo SourceCodeInfo { get { return sourceCodeInfo_; } - set { sourceCodeInfo_ = value; } + set { + pb::Freezable.CheckMutable(this); + sourceCodeInfo_ = value; + } } public const int SyntaxFieldNumber = 12; private string syntax_ = ""; public string Syntax { get { return syntax_; } - set { syntax_ = value ?? ""; } + set { + pb::Freezable.CheckMutable(this); + syntax_ = value ?? ""; + } } - public override bool Equals(object other) { return Equals(other as FileDescriptorProto); } @@ -509,7 +551,9 @@ namespace Google.Protobuf.DescriptorProtos { if(!enumType_.Equals(other.enumType_)) return false; if(!service_.Equals(other.service_)) return false; if(!extension_.Equals(other.extension_)) return false; - if (!object.Equals(Options, other.Options)) return false;if (!object.Equals(SourceCodeInfo, other.SourceCodeInfo)) return false;if (Syntax != other.Syntax) return false; + if (!object.Equals(Options, other.Options)) return false; + if (!object.Equals(SourceCodeInfo, other.SourceCodeInfo)) return false; + if (Syntax != other.Syntax) return false; return true; } @@ -763,6 +807,9 @@ namespace Google.Protobuf.DescriptorProtos { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_DescriptorProto__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public DescriptorProto() { } public DescriptorProto(DescriptorProto other) { @@ -782,14 +829,32 @@ namespace Google.Protobuf.DescriptorProtos { return new DescriptorProto(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + field_.Freeze(); + extension_.Freeze(); + nestedType_.Freeze(); + enumType_.Freeze(); + extensionRange_.Freeze(); + oneofDecl_.Freeze(); + if (options_ != null) Options.Freeze(); + reservedRange_.Freeze(); + reservedName_.Freeze(); + } + public const int NameFieldNumber = 1; private string name_ = ""; public string Name { get { return name_; } - set { name_ = value ?? ""; } + set { + pb::Freezable.CheckMutable(this); + name_ = value ?? ""; + } } - public const int FieldFieldNumber = 2; private readonly pbc::RepeatedField field_ = new pbc::RepeatedField(); public pbc::RepeatedField Field { @@ -830,7 +895,10 @@ namespace Google.Protobuf.DescriptorProtos { private global::Google.Protobuf.DescriptorProtos.MessageOptions options_; public global::Google.Protobuf.DescriptorProtos.MessageOptions Options { get { return options_; } - set { options_ = value; } + set { + pb::Freezable.CheckMutable(this); + options_ = value; + } } public const int ReservedRangeFieldNumber = 9; @@ -863,7 +931,8 @@ namespace Google.Protobuf.DescriptorProtos { if(!enumType_.Equals(other.enumType_)) return false; if(!extensionRange_.Equals(other.extensionRange_)) return false; if(!oneofDecl_.Equals(other.oneofDecl_)) return false; - if (!object.Equals(Options, other.Options)) return false;if(!reservedRange_.Equals(other.reservedRange_)) return false; + if (!object.Equals(Options, other.Options)) return false; + if(!reservedRange_.Equals(other.reservedRange_)) return false; if(!reservedName_.Equals(other.reservedName_)) return false; return true; } @@ -1077,6 +1146,9 @@ namespace Google.Protobuf.DescriptorProtos { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_DescriptorProto_ExtensionRange__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public ExtensionRange() { } public ExtensionRange(ExtensionRange other) { @@ -1088,22 +1160,33 @@ namespace Google.Protobuf.DescriptorProtos { return new ExtensionRange(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + public const int StartFieldNumber = 1; private int start_; public int Start { get { return start_; } - set { start_ = value; } + set { + pb::Freezable.CheckMutable(this); + start_ = value; + } } - public const int EndFieldNumber = 2; private int end_; public int End { get { return end_; } - set { end_ = value; } + set { + pb::Freezable.CheckMutable(this); + end_ = value; + } } - public override bool Equals(object other) { return Equals(other as ExtensionRange); } @@ -1200,6 +1283,9 @@ namespace Google.Protobuf.DescriptorProtos { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_DescriptorProto_ReservedRange__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public ReservedRange() { } public ReservedRange(ReservedRange other) { @@ -1211,22 +1297,33 @@ namespace Google.Protobuf.DescriptorProtos { return new ReservedRange(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + public const int StartFieldNumber = 1; private int start_; public int Start { get { return start_; } - set { start_ = value; } + set { + pb::Freezable.CheckMutable(this); + start_ = value; + } } - public const int EndFieldNumber = 2; private int end_; public int End { get { return end_; } - set { end_ = value; } + set { + pb::Freezable.CheckMutable(this); + end_ = value; + } } - public override bool Equals(object other) { return Equals(other as ReservedRange); } @@ -1328,6 +1425,9 @@ namespace Google.Protobuf.DescriptorProtos { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FieldDescriptorProto__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public FieldDescriptorProto() { } public FieldDescriptorProto(FieldDescriptorProto other) { @@ -1346,75 +1446,102 @@ namespace Google.Protobuf.DescriptorProtos { return new FieldDescriptorProto(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + if (options_ != null) Options.Freeze(); + } + public const int NameFieldNumber = 1; private string name_ = ""; public string Name { get { return name_; } - set { name_ = value ?? ""; } + set { + pb::Freezable.CheckMutable(this); + name_ = value ?? ""; + } } - public const int NumberFieldNumber = 3; private int number_; public int Number { get { return number_; } - set { number_ = value; } + set { + pb::Freezable.CheckMutable(this); + number_ = value; + } } - public const int LabelFieldNumber = 4; private global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Label label_ = global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Label.LABEL_OPTIONAL; public global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Label Label { get { return label_; } - set { label_ = value; } + set { + pb::Freezable.CheckMutable(this); + label_ = value; + } } - public const int TypeFieldNumber = 5; private global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Type type_ = global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Type.TYPE_DOUBLE; public global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Type Type { get { return type_; } - set { type_ = value; } + set { + pb::Freezable.CheckMutable(this); + type_ = value; + } } - public const int TypeNameFieldNumber = 6; private string typeName_ = ""; public string TypeName { get { return typeName_; } - set { typeName_ = value ?? ""; } + set { + pb::Freezable.CheckMutable(this); + typeName_ = value ?? ""; + } } - public const int ExtendeeFieldNumber = 2; private string extendee_ = ""; public string Extendee { get { return extendee_; } - set { extendee_ = value ?? ""; } + set { + pb::Freezable.CheckMutable(this); + extendee_ = value ?? ""; + } } - public const int DefaultValueFieldNumber = 7; private string defaultValue_ = ""; public string DefaultValue { get { return defaultValue_; } - set { defaultValue_ = value ?? ""; } + set { + pb::Freezable.CheckMutable(this); + defaultValue_ = value ?? ""; + } } - public const int OneofIndexFieldNumber = 9; private int oneofIndex_; public int OneofIndex { get { return oneofIndex_; } - set { oneofIndex_ = value; } + set { + pb::Freezable.CheckMutable(this); + oneofIndex_ = value; + } } - public const int OptionsFieldNumber = 8; private global::Google.Protobuf.DescriptorProtos.FieldOptions options_; public global::Google.Protobuf.DescriptorProtos.FieldOptions Options { get { return options_; } - set { options_ = value; } + set { + pb::Freezable.CheckMutable(this); + options_ = value; + } } public override bool Equals(object other) { @@ -1436,7 +1563,8 @@ namespace Google.Protobuf.DescriptorProtos { if (Extendee != other.Extendee) return false; if (DefaultValue != other.DefaultValue) return false; if (OneofIndex != other.OneofIndex) return false; - if (!object.Equals(Options, other.Options)) return false; return true; + if (!object.Equals(Options, other.Options)) return false; + return true; } public override int GetHashCode() { @@ -1663,6 +1791,9 @@ namespace Google.Protobuf.DescriptorProtos { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_OneofDescriptorProto__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public OneofDescriptorProto() { } public OneofDescriptorProto(OneofDescriptorProto other) { @@ -1673,14 +1804,23 @@ namespace Google.Protobuf.DescriptorProtos { return new OneofDescriptorProto(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + public const int NameFieldNumber = 1; private string name_ = ""; public string Name { get { return name_; } - set { name_ = value ?? ""; } + set { + pb::Freezable.CheckMutable(this); + name_ = value ?? ""; + } } - public override bool Equals(object other) { return Equals(other as OneofDescriptorProto); } @@ -1761,6 +1901,9 @@ namespace Google.Protobuf.DescriptorProtos { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_EnumDescriptorProto__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public EnumDescriptorProto() { } public EnumDescriptorProto(EnumDescriptorProto other) { @@ -1773,14 +1916,25 @@ namespace Google.Protobuf.DescriptorProtos { return new EnumDescriptorProto(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + value_.Freeze(); + if (options_ != null) Options.Freeze(); + } + public const int NameFieldNumber = 1; private string name_ = ""; public string Name { get { return name_; } - set { name_ = value ?? ""; } + set { + pb::Freezable.CheckMutable(this); + name_ = value ?? ""; + } } - public const int ValueFieldNumber = 2; private readonly pbc::RepeatedField value_ = new pbc::RepeatedField(); public pbc::RepeatedField Value { @@ -1791,7 +1945,10 @@ namespace Google.Protobuf.DescriptorProtos { private global::Google.Protobuf.DescriptorProtos.EnumOptions options_; public global::Google.Protobuf.DescriptorProtos.EnumOptions Options { get { return options_; } - set { options_ = value; } + set { + pb::Freezable.CheckMutable(this); + options_ = value; + } } public override bool Equals(object other) { @@ -1807,7 +1964,8 @@ namespace Google.Protobuf.DescriptorProtos { } if (Name != other.Name) return false; if(!value_.Equals(other.value_)) return false; - if (!object.Equals(Options, other.Options)) return false; return true; + if (!object.Equals(Options, other.Options)) return false; + return true; } public override int GetHashCode() { @@ -1911,6 +2069,9 @@ namespace Google.Protobuf.DescriptorProtos { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_EnumValueDescriptorProto__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public EnumValueDescriptorProto() { } public EnumValueDescriptorProto(EnumValueDescriptorProto other) { @@ -1923,27 +2084,42 @@ namespace Google.Protobuf.DescriptorProtos { return new EnumValueDescriptorProto(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + if (options_ != null) Options.Freeze(); + } + public const int NameFieldNumber = 1; private string name_ = ""; public string Name { get { return name_; } - set { name_ = value ?? ""; } + set { + pb::Freezable.CheckMutable(this); + name_ = value ?? ""; + } } - public const int NumberFieldNumber = 2; private int number_; public int Number { get { return number_; } - set { number_ = value; } + set { + pb::Freezable.CheckMutable(this); + number_ = value; + } } - public const int OptionsFieldNumber = 3; private global::Google.Protobuf.DescriptorProtos.EnumValueOptions options_; public global::Google.Protobuf.DescriptorProtos.EnumValueOptions Options { get { return options_; } - set { options_ = value; } + set { + pb::Freezable.CheckMutable(this); + options_ = value; + } } public override bool Equals(object other) { @@ -1959,7 +2135,8 @@ namespace Google.Protobuf.DescriptorProtos { } if (Name != other.Name) return false; if (Number != other.Number) return false; - if (!object.Equals(Options, other.Options)) return false; return true; + if (!object.Equals(Options, other.Options)) return false; + return true; } public override int GetHashCode() { @@ -2063,6 +2240,9 @@ namespace Google.Protobuf.DescriptorProtos { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_ServiceDescriptorProto__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public ServiceDescriptorProto() { } public ServiceDescriptorProto(ServiceDescriptorProto other) { @@ -2075,14 +2255,25 @@ namespace Google.Protobuf.DescriptorProtos { return new ServiceDescriptorProto(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + method_.Freeze(); + if (options_ != null) Options.Freeze(); + } + public const int NameFieldNumber = 1; private string name_ = ""; public string Name { get { return name_; } - set { name_ = value ?? ""; } + set { + pb::Freezable.CheckMutable(this); + name_ = value ?? ""; + } } - public const int MethodFieldNumber = 2; private readonly pbc::RepeatedField method_ = new pbc::RepeatedField(); public pbc::RepeatedField Method { @@ -2093,7 +2284,10 @@ namespace Google.Protobuf.DescriptorProtos { private global::Google.Protobuf.DescriptorProtos.ServiceOptions options_; public global::Google.Protobuf.DescriptorProtos.ServiceOptions Options { get { return options_; } - set { options_ = value; } + set { + pb::Freezable.CheckMutable(this); + options_ = value; + } } public override bool Equals(object other) { @@ -2109,7 +2303,8 @@ namespace Google.Protobuf.DescriptorProtos { } if (Name != other.Name) return false; if(!method_.Equals(other.method_)) return false; - if (!object.Equals(Options, other.Options)) return false; return true; + if (!object.Equals(Options, other.Options)) return false; + return true; } public override int GetHashCode() { @@ -2213,6 +2408,9 @@ namespace Google.Protobuf.DescriptorProtos { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_MethodDescriptorProto__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public MethodDescriptorProto() { } public MethodDescriptorProto(MethodDescriptorProto other) { @@ -2228,53 +2426,74 @@ namespace Google.Protobuf.DescriptorProtos { return new MethodDescriptorProto(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + if (options_ != null) Options.Freeze(); + } + public const int NameFieldNumber = 1; private string name_ = ""; public string Name { get { return name_; } - set { name_ = value ?? ""; } + set { + pb::Freezable.CheckMutable(this); + name_ = value ?? ""; + } } - public const int InputTypeFieldNumber = 2; private string inputType_ = ""; public string InputType { get { return inputType_; } - set { inputType_ = value ?? ""; } + set { + pb::Freezable.CheckMutable(this); + inputType_ = value ?? ""; + } } - public const int OutputTypeFieldNumber = 3; private string outputType_ = ""; public string OutputType { get { return outputType_; } - set { outputType_ = value ?? ""; } + set { + pb::Freezable.CheckMutable(this); + outputType_ = value ?? ""; + } } - public const int OptionsFieldNumber = 4; private global::Google.Protobuf.DescriptorProtos.MethodOptions options_; public global::Google.Protobuf.DescriptorProtos.MethodOptions Options { get { return options_; } - set { options_ = value; } + set { + pb::Freezable.CheckMutable(this); + options_ = value; + } } public const int ClientStreamingFieldNumber = 5; private bool clientStreaming_; public bool ClientStreaming { get { return clientStreaming_; } - set { clientStreaming_ = value; } + set { + pb::Freezable.CheckMutable(this); + clientStreaming_ = value; + } } - public const int ServerStreamingFieldNumber = 6; private bool serverStreaming_; public bool ServerStreaming { get { return serverStreaming_; } - set { serverStreaming_ = value; } + set { + pb::Freezable.CheckMutable(this); + serverStreaming_ = value; + } } - public override bool Equals(object other) { return Equals(other as MethodDescriptorProto); } @@ -2289,7 +2508,8 @@ namespace Google.Protobuf.DescriptorProtos { if (Name != other.Name) return false; if (InputType != other.InputType) return false; if (OutputType != other.OutputType) return false; - if (!object.Equals(Options, other.Options)) return false;if (ClientStreaming != other.ClientStreaming) return false; + if (!object.Equals(Options, other.Options)) return false; + if (ClientStreaming != other.ClientStreaming) return false; if (ServerStreaming != other.ServerStreaming) return false; return true; } @@ -2440,6 +2660,9 @@ namespace Google.Protobuf.DescriptorProtos { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FileOptions__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public FileOptions() { } public FileOptions(FileOptions other) { @@ -2464,118 +2687,154 @@ namespace Google.Protobuf.DescriptorProtos { return new FileOptions(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + uninterpretedOption_.Freeze(); + } + public const int JavaPackageFieldNumber = 1; private string javaPackage_ = ""; public string JavaPackage { get { return javaPackage_; } - set { javaPackage_ = value ?? ""; } + set { + pb::Freezable.CheckMutable(this); + javaPackage_ = value ?? ""; + } } - public const int JavaOuterClassnameFieldNumber = 8; private string javaOuterClassname_ = ""; public string JavaOuterClassname { get { return javaOuterClassname_; } - set { javaOuterClassname_ = value ?? ""; } + set { + pb::Freezable.CheckMutable(this); + javaOuterClassname_ = value ?? ""; + } } - public const int JavaMultipleFilesFieldNumber = 10; private bool javaMultipleFiles_; public bool JavaMultipleFiles { get { return javaMultipleFiles_; } - set { javaMultipleFiles_ = value; } + set { + pb::Freezable.CheckMutable(this); + javaMultipleFiles_ = value; + } } - public const int JavaGenerateEqualsAndHashFieldNumber = 20; private bool javaGenerateEqualsAndHash_; public bool JavaGenerateEqualsAndHash { get { return javaGenerateEqualsAndHash_; } - set { javaGenerateEqualsAndHash_ = value; } + set { + pb::Freezable.CheckMutable(this); + javaGenerateEqualsAndHash_ = value; + } } - public const int JavaStringCheckUtf8FieldNumber = 27; private bool javaStringCheckUtf8_; public bool JavaStringCheckUtf8 { get { return javaStringCheckUtf8_; } - set { javaStringCheckUtf8_ = value; } + set { + pb::Freezable.CheckMutable(this); + javaStringCheckUtf8_ = value; + } } - public const int OptimizeForFieldNumber = 9; private global::Google.Protobuf.DescriptorProtos.FileOptions.Types.OptimizeMode optimizeFor_ = global::Google.Protobuf.DescriptorProtos.FileOptions.Types.OptimizeMode.SPEED; public global::Google.Protobuf.DescriptorProtos.FileOptions.Types.OptimizeMode OptimizeFor { get { return optimizeFor_; } - set { optimizeFor_ = value; } + set { + pb::Freezable.CheckMutable(this); + optimizeFor_ = value; + } } - public const int GoPackageFieldNumber = 11; private string goPackage_ = ""; public string GoPackage { get { return goPackage_; } - set { goPackage_ = value ?? ""; } + set { + pb::Freezable.CheckMutable(this); + goPackage_ = value ?? ""; + } } - public const int CcGenericServicesFieldNumber = 16; private bool ccGenericServices_; public bool CcGenericServices { get { return ccGenericServices_; } - set { ccGenericServices_ = value; } + set { + pb::Freezable.CheckMutable(this); + ccGenericServices_ = value; + } } - public const int JavaGenericServicesFieldNumber = 17; private bool javaGenericServices_; public bool JavaGenericServices { get { return javaGenericServices_; } - set { javaGenericServices_ = value; } + set { + pb::Freezable.CheckMutable(this); + javaGenericServices_ = value; + } } - public const int PyGenericServicesFieldNumber = 18; private bool pyGenericServices_; public bool PyGenericServices { get { return pyGenericServices_; } - set { pyGenericServices_ = value; } + set { + pb::Freezable.CheckMutable(this); + pyGenericServices_ = value; + } } - public const int DeprecatedFieldNumber = 23; private bool deprecated_; public bool Deprecated { get { return deprecated_; } - set { deprecated_ = value; } + set { + pb::Freezable.CheckMutable(this); + deprecated_ = value; + } } - public const int CcEnableArenasFieldNumber = 31; private bool ccEnableArenas_; public bool CcEnableArenas { get { return ccEnableArenas_; } - set { ccEnableArenas_ = value; } + set { + pb::Freezable.CheckMutable(this); + ccEnableArenas_ = value; + } } - public const int ObjcClassPrefixFieldNumber = 36; private string objcClassPrefix_ = ""; public string ObjcClassPrefix { get { return objcClassPrefix_; } - set { objcClassPrefix_ = value ?? ""; } + set { + pb::Freezable.CheckMutable(this); + objcClassPrefix_ = value ?? ""; + } } - public const int CsharpNamespaceFieldNumber = 37; private string csharpNamespace_ = ""; public string CsharpNamespace { get { return csharpNamespace_; } - set { csharpNamespace_ = value ?? ""; } + set { + pb::Freezable.CheckMutable(this); + csharpNamespace_ = value ?? ""; + } } - public const int UninterpretedOptionFieldNumber = 999; private readonly pbc::RepeatedField uninterpretedOption_ = new pbc::RepeatedField(); public pbc::RepeatedField UninterpretedOption { @@ -2898,6 +3157,9 @@ namespace Google.Protobuf.DescriptorProtos { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_MessageOptions__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public MessageOptions() { } public MessageOptions(MessageOptions other) { @@ -2912,38 +3174,54 @@ namespace Google.Protobuf.DescriptorProtos { return new MessageOptions(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + uninterpretedOption_.Freeze(); + } + public const int MessageSetWireFormatFieldNumber = 1; private bool messageSetWireFormat_; public bool MessageSetWireFormat { get { return messageSetWireFormat_; } - set { messageSetWireFormat_ = value; } + set { + pb::Freezable.CheckMutable(this); + messageSetWireFormat_ = value; + } } - public const int NoStandardDescriptorAccessorFieldNumber = 2; private bool noStandardDescriptorAccessor_; public bool NoStandardDescriptorAccessor { get { return noStandardDescriptorAccessor_; } - set { noStandardDescriptorAccessor_ = value; } + set { + pb::Freezable.CheckMutable(this); + noStandardDescriptorAccessor_ = value; + } } - public const int DeprecatedFieldNumber = 3; private bool deprecated_; public bool Deprecated { get { return deprecated_; } - set { deprecated_ = value; } + set { + pb::Freezable.CheckMutable(this); + deprecated_ = value; + } } - public const int MapEntryFieldNumber = 7; private bool mapEntry_; public bool MapEntry { get { return mapEntry_; } - set { mapEntry_ = value; } + set { + pb::Freezable.CheckMutable(this); + mapEntry_ = value; + } } - public const int UninterpretedOptionFieldNumber = 999; private readonly pbc::RepeatedField uninterpretedOption_ = new pbc::RepeatedField(); public pbc::RepeatedField UninterpretedOption { @@ -3094,6 +3372,9 @@ namespace Google.Protobuf.DescriptorProtos { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FieldOptions__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public FieldOptions() { } public FieldOptions(FieldOptions other) { @@ -3110,54 +3391,74 @@ namespace Google.Protobuf.DescriptorProtos { return new FieldOptions(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + uninterpretedOption_.Freeze(); + } + public const int CtypeFieldNumber = 1; private global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.CType ctype_ = global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.CType.STRING; public global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.CType Ctype { get { return ctype_; } - set { ctype_ = value; } + set { + pb::Freezable.CheckMutable(this); + ctype_ = value; + } } - public const int PackedFieldNumber = 2; private bool packed_; public bool Packed { get { return packed_; } - set { packed_ = value; } + set { + pb::Freezable.CheckMutable(this); + packed_ = value; + } } - public const int JstypeFieldNumber = 6; private global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.JSType jstype_ = global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.JSType.JS_NORMAL; public global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.JSType Jstype { get { return jstype_; } - set { jstype_ = value; } + set { + pb::Freezable.CheckMutable(this); + jstype_ = value; + } } - public const int LazyFieldNumber = 5; private bool lazy_; public bool Lazy { get { return lazy_; } - set { lazy_ = value; } + set { + pb::Freezable.CheckMutable(this); + lazy_ = value; + } } - public const int DeprecatedFieldNumber = 3; private bool deprecated_; public bool Deprecated { get { return deprecated_; } - set { deprecated_ = value; } + set { + pb::Freezable.CheckMutable(this); + deprecated_ = value; + } } - public const int WeakFieldNumber = 10; private bool weak_; public bool Weak { get { return weak_; } - set { weak_ = value; } + set { + pb::Freezable.CheckMutable(this); + weak_ = value; + } } - public const int UninterpretedOptionFieldNumber = 999; private readonly pbc::RepeatedField uninterpretedOption_ = new pbc::RepeatedField(); public pbc::RepeatedField UninterpretedOption { @@ -3358,6 +3659,9 @@ namespace Google.Protobuf.DescriptorProtos { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_EnumOptions__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public EnumOptions() { } public EnumOptions(EnumOptions other) { @@ -3370,22 +3674,34 @@ namespace Google.Protobuf.DescriptorProtos { return new EnumOptions(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + uninterpretedOption_.Freeze(); + } + public const int AllowAliasFieldNumber = 2; private bool allowAlias_; public bool AllowAlias { get { return allowAlias_; } - set { allowAlias_ = value; } + set { + pb::Freezable.CheckMutable(this); + allowAlias_ = value; + } } - public const int DeprecatedFieldNumber = 3; private bool deprecated_; public bool Deprecated { get { return deprecated_; } - set { deprecated_ = value; } + set { + pb::Freezable.CheckMutable(this); + deprecated_ = value; + } } - public const int UninterpretedOptionFieldNumber = 999; private readonly pbc::RepeatedField uninterpretedOption_ = new pbc::RepeatedField(); public pbc::RepeatedField UninterpretedOption { @@ -3504,6 +3820,9 @@ namespace Google.Protobuf.DescriptorProtos { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_EnumValueOptions__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public EnumValueOptions() { } public EnumValueOptions(EnumValueOptions other) { @@ -3515,14 +3834,24 @@ namespace Google.Protobuf.DescriptorProtos { return new EnumValueOptions(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + uninterpretedOption_.Freeze(); + } + public const int DeprecatedFieldNumber = 1; private bool deprecated_; public bool Deprecated { get { return deprecated_; } - set { deprecated_ = value; } + set { + pb::Freezable.CheckMutable(this); + deprecated_ = value; + } } - public const int UninterpretedOptionFieldNumber = 999; private readonly pbc::RepeatedField uninterpretedOption_ = new pbc::RepeatedField(); public pbc::RepeatedField UninterpretedOption { @@ -3625,6 +3954,9 @@ namespace Google.Protobuf.DescriptorProtos { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_ServiceOptions__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public ServiceOptions() { } public ServiceOptions(ServiceOptions other) { @@ -3636,14 +3968,24 @@ namespace Google.Protobuf.DescriptorProtos { return new ServiceOptions(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + uninterpretedOption_.Freeze(); + } + public const int DeprecatedFieldNumber = 33; private bool deprecated_; public bool Deprecated { get { return deprecated_; } - set { deprecated_ = value; } + set { + pb::Freezable.CheckMutable(this); + deprecated_ = value; + } } - public const int UninterpretedOptionFieldNumber = 999; private readonly pbc::RepeatedField uninterpretedOption_ = new pbc::RepeatedField(); public pbc::RepeatedField UninterpretedOption { @@ -3746,6 +4088,9 @@ namespace Google.Protobuf.DescriptorProtos { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_MethodOptions__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public MethodOptions() { } public MethodOptions(MethodOptions other) { @@ -3757,14 +4102,24 @@ namespace Google.Protobuf.DescriptorProtos { return new MethodOptions(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + uninterpretedOption_.Freeze(); + } + public const int DeprecatedFieldNumber = 33; private bool deprecated_; public bool Deprecated { get { return deprecated_; } - set { deprecated_ = value; } + set { + pb::Freezable.CheckMutable(this); + deprecated_ = value; + } } - public const int UninterpretedOptionFieldNumber = 999; private readonly pbc::RepeatedField uninterpretedOption_ = new pbc::RepeatedField(); public pbc::RepeatedField UninterpretedOption { @@ -3867,6 +4222,9 @@ namespace Google.Protobuf.DescriptorProtos { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_UninterpretedOption__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public UninterpretedOption() { } public UninterpretedOption(UninterpretedOption other) { @@ -3883,6 +4241,14 @@ namespace Google.Protobuf.DescriptorProtos { return new UninterpretedOption(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + name_.Freeze(); + } + public const int NameFieldNumber = 2; private readonly pbc::RepeatedField name_ = new pbc::RepeatedField(); public pbc::RepeatedField Name { @@ -3893,50 +4259,62 @@ namespace Google.Protobuf.DescriptorProtos { private string identifierValue_ = ""; public string IdentifierValue { get { return identifierValue_; } - set { identifierValue_ = value ?? ""; } + set { + pb::Freezable.CheckMutable(this); + identifierValue_ = value ?? ""; + } } - public const int PositiveIntValueFieldNumber = 4; private ulong positiveIntValue_; public ulong PositiveIntValue { get { return positiveIntValue_; } - set { positiveIntValue_ = value; } + set { + pb::Freezable.CheckMutable(this); + positiveIntValue_ = value; + } } - public const int NegativeIntValueFieldNumber = 5; private long negativeIntValue_; public long NegativeIntValue { get { return negativeIntValue_; } - set { negativeIntValue_ = value; } + set { + pb::Freezable.CheckMutable(this); + negativeIntValue_ = value; + } } - public const int DoubleValueFieldNumber = 6; private double doubleValue_; public double DoubleValue { get { return doubleValue_; } - set { doubleValue_ = value; } + set { + pb::Freezable.CheckMutable(this); + doubleValue_ = value; + } } - public const int StringValueFieldNumber = 7; private pb::ByteString stringValue_ = pb::ByteString.Empty; public pb::ByteString StringValue { get { return stringValue_; } - set { stringValue_ = value ?? pb::ByteString.Empty; } + set { + pb::Freezable.CheckMutable(this); + stringValue_ = value ?? pb::ByteString.Empty; + } } - public const int AggregateValueFieldNumber = 8; private string aggregateValue_ = ""; public string AggregateValue { get { return aggregateValue_; } - set { aggregateValue_ = value ?? ""; } + set { + pb::Freezable.CheckMutable(this); + aggregateValue_ = value ?? ""; + } } - public override bool Equals(object other) { return Equals(other as UninterpretedOption); } @@ -4114,6 +4492,9 @@ namespace Google.Protobuf.DescriptorProtos { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_UninterpretedOption_NamePart__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public NamePart() { } public NamePart(NamePart other) { @@ -4125,22 +4506,33 @@ namespace Google.Protobuf.DescriptorProtos { return new NamePart(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + public const int NamePart_FieldNumber = 1; private string namePart_ = ""; public string NamePart_ { get { return namePart_; } - set { namePart_ = value ?? ""; } + set { + pb::Freezable.CheckMutable(this); + namePart_ = value ?? ""; + } } - public const int IsExtensionFieldNumber = 2; private bool isExtension_; public bool IsExtension { get { return isExtension_; } - set { isExtension_ = value; } + set { + pb::Freezable.CheckMutable(this); + isExtension_ = value; + } } - public override bool Equals(object other) { return Equals(other as NamePart); } @@ -4242,6 +4634,9 @@ namespace Google.Protobuf.DescriptorProtos { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_SourceCodeInfo__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public SourceCodeInfo() { } public SourceCodeInfo(SourceCodeInfo other) { @@ -4252,6 +4647,14 @@ namespace Google.Protobuf.DescriptorProtos { return new SourceCodeInfo(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + location_.Freeze(); + } + public const int LocationFieldNumber = 1; private readonly pbc::RepeatedField location_ = new pbc::RepeatedField(); public pbc::RepeatedField Location { @@ -4339,6 +4742,9 @@ namespace Google.Protobuf.DescriptorProtos { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_SourceCodeInfo_Location__FieldAccessorTable; } } + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + public Location() { } public Location(Location other) { @@ -4353,6 +4759,16 @@ namespace Google.Protobuf.DescriptorProtos { return new Location(this); } + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + path_.Freeze(); + span_.Freeze(); + leadingDetachedComments_.Freeze(); + } + public const int PathFieldNumber = 1; private readonly pbc::RepeatedField path_ = new pbc::RepeatedField(); public pbc::RepeatedField Path { @@ -4369,18 +4785,22 @@ namespace Google.Protobuf.DescriptorProtos { private string leadingComments_ = ""; public string LeadingComments { get { return leadingComments_; } - set { leadingComments_ = value ?? ""; } + set { + pb::Freezable.CheckMutable(this); + leadingComments_ = value ?? ""; + } } - public const int TrailingCommentsFieldNumber = 4; private string trailingComments_ = ""; public string TrailingComments { get { return trailingComments_; } - set { trailingComments_ = value ?? ""; } + set { + pb::Freezable.CheckMutable(this); + trailingComments_ = value ?? ""; + } } - public const int LeadingDetachedCommentsFieldNumber = 6; private readonly pbc::RepeatedField leadingDetachedComments_ = new pbc::RepeatedField(); public pbc::RepeatedField LeadingDetachedComments { diff --git a/csharp/src/ProtocolBuffers/Freezable.cs b/csharp/src/ProtocolBuffers/Freezable.cs new file mode 100644 index 00000000..40b4398a --- /dev/null +++ b/csharp/src/ProtocolBuffers/Freezable.cs @@ -0,0 +1,60 @@ +#region Copyright notice and license + +// Protocol Buffers - Google's data interchange format +// Copyright 2015 Google Inc. All rights reserved. +// http://github.com/google/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; + +namespace Google.Protobuf +{ + /// + /// Extension methods for types. + /// + public static class Freezable + { + /// + /// Throws an if + /// is frozen. + /// + /// + /// This is a convenience methods that freezable types can call before all + /// mutations, to protect frozen objects. + /// + public static void CheckMutable(this IFreezable target) + { + if (target.IsFrozen) + { + throw new InvalidOperationException("Attempt to mutate frozen object"); + } + } + } +} diff --git a/csharp/src/ProtocolBuffers/IMessage.cs b/csharp/src/ProtocolBuffers/IMessage.cs index 5d662cfd..d606aee1 100644 --- a/csharp/src/ProtocolBuffers/IMessage.cs +++ b/csharp/src/ProtocolBuffers/IMessage.cs @@ -41,6 +41,7 @@ namespace Google.Protobuf { // TODO(jonskeet): Do we want a "weak" (non-generic) version of IReflectedMessage? + // TODO(jonskeet): Split these interfaces into separate files when we're happy with them. /// /// Reflection support for a specific message type. message @@ -85,7 +86,7 @@ namespace Google.Protobuf /// the implementation class. /// /// The message type. - public interface IMessage : IMessage, IEquatable, IDeepCloneable where T : IMessage + public interface IMessage : IMessage, IEquatable, IDeepCloneable, IFreezable where T : IMessage { /// /// Merges the given message into this one. @@ -102,6 +103,11 @@ namespace Google.Protobuf /// All generated messages implement this interface, but so do some non-message types. /// Additionally, due to the type constraint on T in , /// it is simpler to keep this as a separate interface. + /// + /// + /// Freezable types which implement this interface should always return a mutable clone, + /// even if the original object is frozen. + /// /// /// The type itself, returned by the method. public interface IDeepCloneable @@ -112,4 +118,32 @@ namespace Google.Protobuf /// A deep clone of this object. T Clone(); } + + /// + /// Provides a mechanism for freezing a message (or repeated field collection) + /// to make it immutable. + /// + /// + /// Implementations are under no obligation to make this thread-safe: if a freezable + /// type instance is shared between threads before being frozen, and one thread then + /// freezes it, it is possible for other threads to make changes during the freezing + /// operation and also to observe stale values for mutated fields. Objects should be + /// frozen before being made available to other threads. + /// + public interface IFreezable + { + /// + /// Freezes this object. + /// + /// + /// If the object is already frozen, this method has no effect. + /// + void Freeze(); + + /// + /// Returns whether or not this object is frozen (and therefore immutable). + /// + /// true if this object is frozen; false otherwise. + bool IsFrozen { get; } + } } diff --git a/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj b/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj index 33a32ff2..d1551148 100644 --- a/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj +++ b/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj @@ -85,6 +85,7 @@ + diff --git a/src/google/protobuf/compiler/csharp/csharp_field_base.cc b/src/google/protobuf/compiler/csharp/csharp_field_base.cc index 54f281ee..0bfbc70e 100644 --- a/src/google/protobuf/compiler/csharp/csharp_field_base.cc +++ b/src/google/protobuf/compiler/csharp/csharp_field_base.cc @@ -107,6 +107,11 @@ FieldGeneratorBase::FieldGeneratorBase(const FieldDescriptor* descriptor, FieldGeneratorBase::~FieldGeneratorBase() { } +void FieldGeneratorBase::GenerateFreezingCode(io::Printer* printer) { + // No-op: only message fields and repeated fields need + // special handling for freezing, so default to not generating any code. +} + void FieldGeneratorBase::AddDeprecatedFlag(io::Printer* printer) { if (descriptor_->options().deprecated()) { diff --git a/src/google/protobuf/compiler/csharp/csharp_field_base.h b/src/google/protobuf/compiler/csharp/csharp_field_base.h index 91ae3ba1..abf9254b 100644 --- a/src/google/protobuf/compiler/csharp/csharp_field_base.h +++ b/src/google/protobuf/compiler/csharp/csharp_field_base.h @@ -48,6 +48,7 @@ class FieldGeneratorBase : public SourceGeneratorBase { ~FieldGeneratorBase(); virtual void GenerateCloningCode(io::Printer* printer) = 0; + virtual void GenerateFreezingCode(io::Printer* printer); virtual void GenerateMembers(io::Printer* printer) = 0; virtual void GenerateMergingCode(io::Printer* printer) = 0; virtual void GenerateParsingCode(io::Printer* printer) = 0; diff --git a/src/google/protobuf/compiler/csharp/csharp_message.cc b/src/google/protobuf/compiler/csharp/csharp_message.cc index 39938fa3..9580c167 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message.cc @@ -211,7 +211,9 @@ void MessageGenerator::Generate(io::Printer* printer) { "public pb::FieldAccess.FieldAccessorTable<$class_name$> Fields {\n" " get { return $umbrella_class_name$.internal__$identifier$__FieldAccessorTable; }\n" "}\n" - "\n"); + "\n" + "private bool _frozen = false;\n" + "public bool IsFrozen { get { return _frozen; } }\n\n"); // Parameterless constructor printer->Print( @@ -219,6 +221,7 @@ void MessageGenerator::Generate(io::Printer* printer) { "public $class_name$() { }\n\n"); GenerateCloningCode(printer); + GenerateFreezingCode(printer); // Fields/properties for (int i = 0; i < descriptor_->field_count(); i++) { @@ -260,6 +263,7 @@ void MessageGenerator::Generate(io::Printer* printer) { " get { return $name$Case_; }\n" "}\n\n" "public void Clear$property_name$() {\n" + " pb::Freezable.CheckMutable(this);\n" " $name$Case_ = $property_name$OneofCase.None;\n" " $name$_ = null;\n" "}\n\n"); @@ -346,6 +350,36 @@ void MessageGenerator::GenerateCloningCode(io::Printer* printer) { "}\n\n"); } +void MessageGenerator::GenerateFreezingCode(io::Printer* printer) { + map vars; + vars["class_name"] = class_name(); + printer->Print( + "public void Freeze() {\n" + " if (IsFrozen) {\n" + " return;\n" + " }\n" + " _frozen = true;\n"); + printer->Indent(); + // Freeze non-oneof fields first (only messages and repeated fields will actually generate any code) + for (int i = 0; i < descriptor_->field_count(); i++) { + if (!descriptor_->field(i)->containing_oneof()) { + scoped_ptr generator( + CreateFieldGeneratorInternal(descriptor_->field(i))); + generator->GenerateFreezingCode(printer); + } + } + + // For each oneof, if the value is freezable, freeze it. We don't actually need to know which type it was. + for (int i = 0; i < descriptor_->oneof_decl_count(); ++i) { + vars["name"] = UnderscoresToCamelCase(descriptor_->oneof_decl(i)->name(), false); + printer->Print(vars, + "if ($name$_ is IFreezable) ((IFreezable) $name$_).Freeze();\n"); + } + + printer->Outdent(); + printer->Print("}\n\n"); +} + void MessageGenerator::GenerateFrameworkMethods(io::Printer* printer) { map vars; vars["class_name"] = class_name(); diff --git a/src/google/protobuf/compiler/csharp/csharp_message.h b/src/google/protobuf/compiler/csharp/csharp_message.h index c3a37a0e..6c7153aa 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message.h +++ b/src/google/protobuf/compiler/csharp/csharp_message.h @@ -51,6 +51,7 @@ class MessageGenerator : public SourceGeneratorBase { ~MessageGenerator(); void GenerateCloningCode(io::Printer* printer); + void GenerateFreezingCode(io::Printer* printer); void GenerateFrameworkMethods(io::Printer* printer); void GenerateStaticVariables(io::Printer* printer); void GenerateStaticVariableInitializers(io::Printer* printer); diff --git a/src/google/protobuf/compiler/csharp/csharp_message_field.cc b/src/google/protobuf/compiler/csharp/csharp_message_field.cc index 82deef54..cbf182d2 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message_field.cc @@ -66,7 +66,10 @@ void MessageFieldGenerator::GenerateMembers(io::Printer* printer) { variables_, "public $type_name$ $property_name$ {\n" " get { return $name$_; }\n" - " set { $name$_ = value; }\n" + " set {\n" + " pb::Freezable.CheckMutable(this);\n" + " $name$_ = value;\n" + " }\n" "}\n"); } @@ -116,7 +119,7 @@ void MessageFieldGenerator::WriteHash(io::Printer* printer) { void MessageFieldGenerator::WriteEquals(io::Printer* printer) { printer->Print( variables_, - "if (!object.Equals($property_name$, other.$property_name$)) return false;"); + "if (!object.Equals($property_name$, other.$property_name$)) return false;\n"); } void MessageFieldGenerator::WriteToString(io::Printer* printer) { variables_["field_name"] = GetFieldName(descriptor_); @@ -130,6 +133,11 @@ void MessageFieldGenerator::GenerateCloningCode(io::Printer* printer) { "$property_name$ = other.$has_property_check$ ? other.$property_name$.Clone() : null;\n"); } +void MessageFieldGenerator::GenerateFreezingCode(io::Printer* printer) { + printer->Print(variables_, + "if ($has_property_check$) $property_name$.Freeze();\n"); +} + MessageOneofFieldGenerator::MessageOneofFieldGenerator(const FieldDescriptor* descriptor, int fieldOrdinal) : MessageFieldGenerator(descriptor, fieldOrdinal) { @@ -147,6 +155,7 @@ void MessageOneofFieldGenerator::GenerateMembers(io::Printer* printer) { "public $type_name$ $property_name$ {\n" " get { return $has_property_check$ ? ($type_name$) $oneof_name$_ : null; }\n" " set {\n" + " pb::Freezable.CheckMutable(this);\n" " $oneof_name$_ = value;\n" " $oneof_name$Case_ = value == null ? $oneof_property_name$OneofCase.None : $oneof_property_name$OneofCase.$property_name$;\n" " }\n" diff --git a/src/google/protobuf/compiler/csharp/csharp_message_field.h b/src/google/protobuf/compiler/csharp/csharp_message_field.h index f15e8e7e..3e17f92a 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message_field.h +++ b/src/google/protobuf/compiler/csharp/csharp_message_field.h @@ -47,6 +47,7 @@ class MessageFieldGenerator : public FieldGeneratorBase { ~MessageFieldGenerator(); virtual void GenerateCloningCode(io::Printer* printer); + virtual void GenerateFreezingCode(io::Printer* printer); virtual void GenerateMembers(io::Printer* printer); virtual void GenerateMergingCode(io::Printer* printer); virtual void GenerateParsingCode(io::Printer* printer); diff --git a/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc b/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc index c426c37a..d5542f57 100644 --- a/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc @@ -72,17 +72,21 @@ void PrimitiveFieldGenerator::GenerateMembers(io::Printer* printer) { printer->Print( variables_, "public $type_name$ $property_name$ {\n" - " get { return $name$_; }\n"); + " get { return $name$_; }\n" + " set {\n" + " pb::Freezable.CheckMutable(this);\n"); if (is_value_type) { printer->Print( variables_, - " set { $name$_ = value; }\n"); + " $name$_ = value;\n"); } else { printer->Print( variables_, - " set { $name$_ = value ?? $default_value$; }\n"); + " $name$_ = value ?? $default_value$;\n"); } - printer->Print("}\n\n"); + printer->Print( + " }\n" + "}\n"); } void PrimitiveFieldGenerator::GenerateMergingCode(io::Printer* printer) { @@ -166,7 +170,8 @@ void PrimitiveOneofFieldGenerator::GenerateMembers(io::Printer* printer) { variables_, "public $type_name$ $property_name$ {\n" " get { return $has_property_check$ ? ($type_name$) $oneof_name$_ : $default_value$; }\n" - " set {\n"); + " set {\n" + " pb::Freezable.CheckMutable(this);\n"); if (is_value_type) { printer->Print( variables_, diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc b/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc index ce526b37..d223273c 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc @@ -147,6 +147,11 @@ void RepeatedEnumFieldGenerator::GenerateCloningCode(io::Printer* printer) { "$name$_ = other.$name$_.Clone();\n"); } +void RepeatedEnumFieldGenerator::GenerateFreezingCode(io::Printer* printer) { + printer->Print(variables_, + "$name$_.Freeze();\n"); +} + } // namespace csharp } // namespace compiler } // namespace protobuf diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.h b/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.h index c7846a61..ee50eef0 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.h +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.h @@ -49,6 +49,7 @@ class RepeatedEnumFieldGenerator : public FieldGeneratorBase { ~RepeatedEnumFieldGenerator(); virtual void GenerateCloningCode(io::Printer* printer); + virtual void GenerateFreezingCode(io::Printer* printer); virtual void GenerateMembers(io::Printer* printer); virtual void GenerateMergingCode(io::Printer* printer); virtual void GenerateParsingCode(io::Printer* printer); diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc b/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc index edfb98b4..400f0e4f 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc @@ -123,6 +123,11 @@ void RepeatedMessageFieldGenerator::GenerateCloningCode(io::Printer* printer) { "$name$_ = other.$name$_.Clone();\n"); } +void RepeatedMessageFieldGenerator::GenerateFreezingCode(io::Printer* printer) { + printer->Print(variables_, + "$name$_.Freeze();\n"); +} + } // namespace csharp } // namespace compiler } // namespace protobuf diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.h b/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.h index 38006731..cf601c7e 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.h +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.h @@ -47,6 +47,7 @@ class RepeatedMessageFieldGenerator : public FieldGeneratorBase { ~RepeatedMessageFieldGenerator(); virtual void GenerateCloningCode(io::Printer* printer); + virtual void GenerateFreezingCode(io::Printer* printer); virtual void GenerateMembers(io::Printer* printer); virtual void GenerateMergingCode(io::Printer* printer); virtual void GenerateParsingCode(io::Printer* printer); diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc b/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc index 49a29c55..a78a74c0 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc @@ -153,6 +153,11 @@ void RepeatedPrimitiveFieldGenerator::GenerateCloningCode(io::Printer* printer) "$name$_ = other.$name$_.Clone();\n"); } +void RepeatedPrimitiveFieldGenerator::GenerateFreezingCode(io::Printer* printer) { + printer->Print(variables_, + "$name$_.Freeze();\n"); +} + } // namespace csharp } // namespace compiler } // namespace protobuf diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h b/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h index 7f8f17a8..f1ceeb50 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h @@ -47,6 +47,7 @@ class RepeatedPrimitiveFieldGenerator : public FieldGeneratorBase { ~RepeatedPrimitiveFieldGenerator(); virtual void GenerateCloningCode(io::Printer* printer); + virtual void GenerateFreezingCode(io::Printer* printer); virtual void GenerateMembers(io::Printer* printer); virtual void GenerateMergingCode(io::Printer* printer); virtual void GenerateParsingCode(io::Printer* printer); -- cgit v1.2.3 From 322ec531615b3f1aa7b25902ecb10e8673408cac Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Wed, 24 Jun 2015 17:55:02 +0100 Subject: Revert the change to wire_format.h. It seems too much code relies on the broken behaviour. See issue #493. Instead, we reimplement MakeTag just for C#, temporarily. --- src/google/protobuf/compiler/csharp/csharp_field_base.cc | 2 +- src/google/protobuf/compiler/csharp/csharp_helpers.cc | 11 +++++++++++ src/google/protobuf/compiler/csharp/csharp_helpers.h | 2 ++ src/google/protobuf/compiler/csharp/csharp_message.cc | 3 +-- src/google/protobuf/wire_format.h | 2 +- 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/google/protobuf/compiler/csharp/csharp_field_base.cc b/src/google/protobuf/compiler/csharp/csharp_field_base.cc index 0bfbc70e..c716e1bf 100644 --- a/src/google/protobuf/compiler/csharp/csharp_field_base.cc +++ b/src/google/protobuf/compiler/csharp/csharp_field_base.cc @@ -57,7 +57,7 @@ void FieldGeneratorBase::SetCommonFieldVariables( // repeated fields varies by wire format. The wire format is encoded in the bottom 3 bits, which // never effects the tag size. int tag_size = internal::WireFormat::TagSize(descriptor_->number(), descriptor_->type()); - uint tag = internal::WireFormat::MakeTag(descriptor_); + uint tag = FixedMakeTag(descriptor_); uint8 tag_array[5]; io::CodedOutputStream::WriteTagToArray(tag, tag_array); string tag_bytes = SimpleItoa(tag_array[0]); diff --git a/src/google/protobuf/compiler/csharp/csharp_helpers.cc b/src/google/protobuf/compiler/csharp/csharp_helpers.cc index 76e2c850..39a53268 100644 --- a/src/google/protobuf/compiler/csharp/csharp_helpers.cc +++ b/src/google/protobuf/compiler/csharp/csharp_helpers.cc @@ -338,6 +338,17 @@ std::string FileDescriptorToBase64(const FileDescriptor* descriptor) { return StringToBase64(fdp_bytes); } +// TODO(jonskeet): Remove this when internal::WireFormat::MakeTag works +// properly... +// Workaround for issue #493 +uint FixedMakeTag(const FieldDescriptor* field) { + internal::WireFormatLite::WireType field_type = field->is_packed() + ? internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED + : internal::WireFormat::WireTypeForFieldType(field->type()); + + return internal::WireFormatLite::MakeTag(field->number(), field_type); +} + FieldGeneratorBase* CreateFieldGenerator(const FieldDescriptor* descriptor, int fieldOrdinal) { switch (descriptor->type()) { diff --git a/src/google/protobuf/compiler/csharp/csharp_helpers.h b/src/google/protobuf/compiler/csharp/csharp_helpers.h index bc77f43a..d2ee8fbe 100644 --- a/src/google/protobuf/compiler/csharp/csharp_helpers.h +++ b/src/google/protobuf/compiler/csharp/csharp_helpers.h @@ -97,6 +97,8 @@ std::string StringToBase64(const std::string& input); std::string FileDescriptorToBase64(const FileDescriptor* descriptor); +uint FixedMakeTag(const FieldDescriptor* descriptor); + FieldGeneratorBase* CreateFieldGenerator(const FieldDescriptor* descriptor, int fieldOrdinal); bool HasRequiredFields(const Descriptor* descriptor); diff --git a/src/google/protobuf/compiler/csharp/csharp_message.cc b/src/google/protobuf/compiler/csharp/csharp_message.cc index 9580c167..a6c8e32b 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message.cc @@ -194,8 +194,7 @@ void MessageGenerator::Generate(io::Printer* printer) { "slash", field_names().size() > 0 ? "\"" : ""); std::vector tags; for (int i = 0; i < field_names().size(); i++) { - uint32 tag = internal::WireFormat::MakeTag( - descriptor_->FindFieldByName(field_names()[i])); + uint32 tag = FixedMakeTag(descriptor_->FindFieldByName(field_names()[i])); tags.push_back(SimpleItoa(tag)); } printer->Print( diff --git a/src/google/protobuf/wire_format.h b/src/google/protobuf/wire_format.h index 84270fee..8de491a6 100644 --- a/src/google/protobuf/wire_format.h +++ b/src/google/protobuf/wire_format.h @@ -290,7 +290,7 @@ class LIBPROTOBUF_EXPORT UnknownFieldSetFieldSkipper : public FieldSkipper { inline WireFormatLite::WireType WireFormat::WireTypeForField( const FieldDescriptor* field) { - if (field->is_packed()) { + if (field->options().packed()) { return WireFormatLite::WIRETYPE_LENGTH_DELIMITED; } else { return WireTypeForFieldType(field->type()); -- cgit v1.2.3 From d487c322defd80f3dba1d1dfc1546e451c7b1c1d Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Thu, 25 Jun 2015 08:22:56 +0100 Subject: Regenerated descriptor C++ code --- src/google/protobuf/descriptor.pb.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/google/protobuf/descriptor.pb.cc b/src/google/protobuf/descriptor.pb.cc index 30b3a3a7..1f49cd6d 100644 --- a/src/google/protobuf/descriptor.pb.cc +++ b/src/google/protobuf/descriptor.pb.cc @@ -753,10 +753,9 @@ void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto() { "ion\032\206\001\n\010Location\022\020\n\004path\030\001 \003(\005B\002\020\001\022\020\n\004sp" "an\030\002 \003(\005B\002\020\001\022\030\n\020leading_comments\030\003 \001(\t\022\031" "\n\021trailing_comments\030\004 \001(\t\022!\n\031leading_det" - "ached_comments\030\006 \003(\tBe\n\023com.google.proto" + "ached_comments\030\006 \003(\tB^\n\023com.google.proto" "bufB\020DescriptorProtosH\001Z\ndescriptor\242\002\003GP" - "B\252\002\'Google.ProtocolBuffers.DescriptorPro" - "tos", 4963); + "B\252\002 Google.Protobuf.DescriptorProtos", 4956); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/descriptor.proto", &protobuf_RegisterTypes); FileDescriptorSet::default_instance_ = new FileDescriptorSet(); -- cgit v1.2.3 From 0698aa973740d2a666fed8281c84a884a4227aa4 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Thu, 25 Jun 2015 08:59:35 +0100 Subject: Get the Mono build script working again. The solution as a whole doesn't build yet - we probably want to remove ProtoDump and ProtoMunge entirely, and ProtoBench should use Jan's new benchmarks for parity with Java. The version of NUnit on my machine, packaged with Mono 3.12.1, is only NUnit 2.4.2, which is extremely old - it still requires an explicit [TestFixture] attribute on test fixtures. I've added one just for ByteStringTest for the moment so that we can see some tests passing in Travis, but as part of a separate PR we should work on making sure we're using a recent NUnit version. (It may already be doing so, but we can check that once it's working and merged.) --- csharp/buildall.sh | 15 ++++++++------- csharp/src/ProtocolBuffers.Test/ByteStringTest.cs | 1 + csharp/src/ProtocolBuffers.sln | 6 ------ 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/csharp/buildall.sh b/csharp/buildall.sh index 164707cb..e19cea0a 100755 --- a/csharp/buildall.sh +++ b/csharp/buildall.sh @@ -11,12 +11,13 @@ SRC=$(dirname $0)/src set -ex -echo Building the solution. -xbuild /p:Configuration=$CONFIG $SRC/ProtocolBuffers.sln +# echo Building the solution. +# TODO(jonskeet): Re-enable building the whole solution when we have ProtoBench et al +# working again. +# xbuild /p:Configuration=$CONFIG $SRC/ProtocolBuffers.sln -echo Running tests. -$NUNIT_CONSOLE $SRC/ProtocolBuffers.Test/bin/$CONFIG/Google.ProtocolBuffers.Test.dll - -$NUNIT_CONSOLE $SRC/ProtocolBuffersLite.Test/bin/$CONFIG/Google.ProtocolBuffersLite.Test.dll +xbuild /p:Configuration=$CONFIG $SRC/ProtocolBuffers/ProtocolBuffers.csproj +xbuild /p:Configuration=$CONFIG $SRC/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj -$NUNIT_CONSOLE $SRC/ProtocolBuffersLite.Test/bin/$CONFIG/Google.ProtocolBuffersMixedLite.Test.dll +echo Running tests. +$NUNIT_CONSOLE $SRC/ProtocolBuffers.Test/bin/$CONFIG/Google.Protobuf.Test.dll diff --git a/csharp/src/ProtocolBuffers.Test/ByteStringTest.cs b/csharp/src/ProtocolBuffers.Test/ByteStringTest.cs index 0edd149b..f7ddb23f 100644 --- a/csharp/src/ProtocolBuffers.Test/ByteStringTest.cs +++ b/csharp/src/ProtocolBuffers.Test/ByteStringTest.cs @@ -40,6 +40,7 @@ using NUnit.Framework; namespace Google.Protobuf { + [TestFixture] public class ByteStringTest { [Test] diff --git a/csharp/src/ProtocolBuffers.sln b/csharp/src/ProtocolBuffers.sln index 0889c50e..7413122f 100644 --- a/csharp/src/ProtocolBuffers.sln +++ b/csharp/src/ProtocolBuffers.sln @@ -4,8 +4,6 @@ VisualStudioVersion = 14.0.22823.1 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProtocolBuffers", "ProtocolBuffers\ProtocolBuffers.csproj", "{6908BDCE-D925-43F3-94AC-A531E6DF2591}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProtocolBuffers.Serialization", "ProtocolBuffers.Serialization\ProtocolBuffers.Serialization.csproj", "{231391AF-449C-4A39-986C-AD7F270F4750}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProtocolBuffers.Test", "ProtocolBuffers.Test\ProtocolBuffers.Test.csproj", "{DD01ED24-3750-4567-9A23-1DB676A15610}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AddressBook", "AddressBook\AddressBook.csproj", "{A31F5FB2-4FF3-432A-B35B-5CD203606311}" @@ -26,10 +24,6 @@ Global {6908BDCE-D925-43F3-94AC-A531E6DF2591}.Debug|Any CPU.Build.0 = Debug|Any CPU {6908BDCE-D925-43F3-94AC-A531E6DF2591}.Release|Any CPU.ActiveCfg = Release|Any CPU {6908BDCE-D925-43F3-94AC-A531E6DF2591}.Release|Any CPU.Build.0 = Release|Any CPU - {231391AF-449C-4A39-986C-AD7F270F4750}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {231391AF-449C-4A39-986C-AD7F270F4750}.Debug|Any CPU.Build.0 = Debug|Any CPU - {231391AF-449C-4A39-986C-AD7F270F4750}.Release|Any CPU.ActiveCfg = Release|Any CPU - {231391AF-449C-4A39-986C-AD7F270F4750}.Release|Any CPU.Build.0 = Release|Any CPU {DD01ED24-3750-4567-9A23-1DB676A15610}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {DD01ED24-3750-4567-9A23-1DB676A15610}.Debug|Any CPU.Build.0 = Debug|Any CPU {DD01ED24-3750-4567-9A23-1DB676A15610}.Release|Any CPU.ActiveCfg = Release|Any CPU -- cgit v1.2.3 From 0d684d34209f8405106e580af854c45fb7c3f16d Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Wed, 24 Jun 2015 17:21:55 +0100 Subject: First pass at map support. More tests required. Generated code in next commit. --- cmake/libprotoc.cmake | 1 + .../ProtocolBuffers.Test/GeneratedMessageTest.cs | 61 ++++ csharp/src/ProtocolBuffers/CodedOutputStream.cs | 8 + csharp/src/ProtocolBuffers/Collections/MapField.cs | 400 +++++++++++++++++++++ csharp/src/ProtocolBuffers/FieldCodec.cs | 178 +++++++++ csharp/src/ProtocolBuffers/ProtocolBuffers.csproj | 2 + src/Makefile.am | 2 + .../protobuf/compiler/csharp/csharp_enum_field.cc | 6 + .../protobuf/compiler/csharp/csharp_enum_field.h | 1 + .../protobuf/compiler/csharp/csharp_field_base.cc | 16 +- .../protobuf/compiler/csharp/csharp_field_base.h | 2 + .../protobuf/compiler/csharp/csharp_helpers.cc | 7 +- .../protobuf/compiler/csharp/csharp_map_field.cc | 141 ++++++++ .../protobuf/compiler/csharp/csharp_map_field.h | 71 ++++ .../protobuf/compiler/csharp/csharp_message.cc | 6 +- .../compiler/csharp/csharp_message_field.cc | 6 + .../compiler/csharp/csharp_message_field.h | 1 + .../compiler/csharp/csharp_primitive_field.cc | 8 +- .../compiler/csharp/csharp_primitive_field.h | 1 + src/google/protobuf/unittest_proto3.proto | 5 + 20 files changed, 913 insertions(+), 10 deletions(-) create mode 100644 csharp/src/ProtocolBuffers/Collections/MapField.cs create mode 100644 csharp/src/ProtocolBuffers/FieldCodec.cs create mode 100644 src/google/protobuf/compiler/csharp/csharp_map_field.cc create mode 100644 src/google/protobuf/compiler/csharp/csharp_map_field.h diff --git a/cmake/libprotoc.cmake b/cmake/libprotoc.cmake index e9e88af5..8bf0a1f3 100644 --- a/cmake/libprotoc.cmake +++ b/cmake/libprotoc.cmake @@ -19,6 +19,7 @@ set(libprotoc_files ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_field_base.cc ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_generator.cc ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_helpers.cc + ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_map_field.cc ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_message.cc ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_message_field.cc ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc diff --git a/csharp/src/ProtocolBuffers.Test/GeneratedMessageTest.cs b/csharp/src/ProtocolBuffers.Test/GeneratedMessageTest.cs index 26165428..81e35940 100644 --- a/csharp/src/ProtocolBuffers.Test/GeneratedMessageTest.cs +++ b/csharp/src/ProtocolBuffers.Test/GeneratedMessageTest.cs @@ -1,4 +1,6 @@ using System; +using System.Configuration; +using System.IO; using Google.Protobuf.TestProtos; using NUnit.Framework; @@ -146,6 +148,65 @@ namespace Google.Protobuf Assert.AreEqual(message, parsed); } + [Test] + public void RoundTrip_Maps() + { + var message = new TestAllTypes + { + MapBoolToEnum = { + { false, TestAllTypes.Types.NestedEnum.BAR}, + { true, TestAllTypes.Types.NestedEnum.BAZ} + }, + MapInt32ToBytes = { + { 5, ByteString.CopyFrom(6, 7, 8) }, + { 25, ByteString.CopyFrom(1, 2, 3, 4, 5) }, + { 10, ByteString.Empty } + }, + MapStringToNestedMessage = { + { "", new TestAllTypes.Types.NestedMessage { Bb = 10 } }, + { "null value", null }, + } + }; + + byte[] bytes = message.ToByteArray(); + TestAllTypes parsed = TestAllTypes.Parser.ParseFrom(bytes); + Assert.AreEqual(message, parsed); + } + + [Test] + public void MapWithEmptyEntry() + { + var message = new TestAllTypes + { + MapInt32ToBytes = { { 0, ByteString.Empty } } + }; + + byte[] bytes = message.ToByteArray(); + Assert.AreEqual(3, bytes.Length); // Tag for field entry (2 bytes), length of entry (0; 1 byte) + + var parsed = TestAllTypes.Parser.ParseFrom(bytes); + Assert.AreEqual(1, parsed.MapInt32ToBytes.Count); + Assert.AreEqual(ByteString.Empty, parsed.MapInt32ToBytes[0]); + } + + [Test] + public void MapWithOnlyValue() + { + // Hand-craft the stream to contain a single entry with just a value. + var memoryStream = new MemoryStream(); + var output = CodedOutputStream.CreateInstance(memoryStream); + output.WriteTag(TestAllTypes.MapStringToNestedMessageFieldNumber, WireFormat.WireType.LengthDelimited); + var nestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 20 }; + // Size of the entry (tag, size written by WriteMessage, data written by WriteMessage) + output.WriteRawVarint32((uint)(nestedMessage.CalculateSize() + 3)); + output.WriteTag(2, WireFormat.WireType.LengthDelimited); + output.WriteMessage(nestedMessage); + output.Flush(); + + var parsed = TestAllTypes.Parser.ParseFrom(memoryStream.ToArray()); + Assert.AreEqual(nestedMessage, parsed.MapStringToNestedMessage[""]); + } + [Test] public void CloneSingleNonMessageValues() { diff --git a/csharp/src/ProtocolBuffers/CodedOutputStream.cs b/csharp/src/ProtocolBuffers/CodedOutputStream.cs index e56ce789..def874c0 100644 --- a/csharp/src/ProtocolBuffers/CodedOutputStream.cs +++ b/csharp/src/ProtocolBuffers/CodedOutputStream.cs @@ -475,6 +475,14 @@ namespace Google.Protobuf WriteRawVarint32(WireFormat.MakeTag(fieldNumber, type)); } + /// + /// Writes an already-encoded tag. + /// + public void WriteTag(uint tag) + { + WriteRawVarint32(tag); + } + /// /// Writes the given single-byte tag directly to the stream. /// diff --git a/csharp/src/ProtocolBuffers/Collections/MapField.cs b/csharp/src/ProtocolBuffers/Collections/MapField.cs new file mode 100644 index 00000000..2f5a741d --- /dev/null +++ b/csharp/src/ProtocolBuffers/Collections/MapField.cs @@ -0,0 +1,400 @@ +#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 System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; + +namespace Google.Protobuf.Collections +{ + /// + /// Representation of a map field in a Protocol Buffer message. + /// + /// + /// This implementation preserves insertion order for simplicity of testing + /// code using maps fields. Overwriting an existing entry does not change the + /// position of that entry within the map. Equality is not order-sensitive. + /// For string keys, the equality comparison is provided by . + /// + /// Key type in the map. Must be a type supported by Protocol Buffer map keys. + /// Value type in the map. Must be a type supported by Protocol Buffers. + public sealed class MapField : IDeepCloneable>, IFreezable, IDictionary, IEquatable> + { + // TODO: Don't create the map/list until we have an entry. (Assume many maps will be empty.) + private bool frozen; + private readonly Dictionary>> map = + new Dictionary>>(); + private readonly LinkedList> list = new LinkedList>(); + + public MapField Clone() + { + var clone = new MapField(); + // Keys are never cloneable. Values might be. + if (typeof(IDeepCloneable).IsAssignableFrom(typeof(TValue))) + { + foreach (var pair in list) + { + clone.Add(pair.Key, pair.Value == null ? pair.Value : ((IDeepCloneable) pair.Value).Clone()); + } + } + else + { + // Nothing is cloneable, so we don't need to worry. + clone.Add(this); + } + return clone; + } + + public void Add(TKey key, TValue value) + { + ThrowHelper.ThrowIfNull(key, "key"); + this.CheckMutable(); + if (ContainsKey(key)) + { + throw new ArgumentException("Key already exists in map", "key"); + } + this[key] = value; + } + + public bool ContainsKey(TKey key) + { + return map.ContainsKey(key); + } + + public bool Remove(TKey key) + { + this.CheckMutable(); + LinkedListNode> node; + if (map.TryGetValue(key, out node)) + { + map.Remove(key); + node.List.Remove(node); + return true; + } + else + { + return false; + } + } + + public bool TryGetValue(TKey key, out TValue value) + { + LinkedListNode> node; + if (map.TryGetValue(key, out node)) + { + value = node.Value.Value; + return true; + } + else + { + value = default(TValue); + return false; + } + } + + public TValue this[TKey key] + { + get + { + TValue value; + if (TryGetValue(key, out value)) + { + return value; + } + throw new KeyNotFoundException(); + } + set + { + this.CheckMutable(); + LinkedListNode> node; + var pair = new KeyValuePair(key, value); + if (map.TryGetValue(key, out node)) + { + node.Value = pair; + } + else + { + node = list.AddLast(pair); + map[key] = node; + } + } + } + + // TODO: Make these views? + public ICollection Keys { get { return list.Select(t => t.Key).ToList(); } } + public ICollection Values { get { return list.Select(t => t.Value).ToList(); } } + + public void Add(IDictionary entries) + { + foreach (var pair in entries) + { + Add(pair); + } + } + + public IEnumerator> GetEnumerator() + { + return list.GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public void Add(KeyValuePair item) + { + this.CheckMutable(); + Add(item.Key, item.Value); + } + + public void Clear() + { + this.CheckMutable(); + list.Clear(); + map.Clear(); + } + + public bool Contains(KeyValuePair item) + { + TValue value; + return TryGetValue(item.Key, out value) + && EqualityComparer.Default.Equals(item.Value, value); + } + + public void CopyTo(KeyValuePair[] array, int arrayIndex) + { + list.CopyTo(array, arrayIndex); + } + + public bool Remove(KeyValuePair item) + { + this.CheckMutable(); + return Remove(item.Key); + } + + public int Count { get { return list.Count; } } + public bool IsReadOnly { get { return frozen; } } + + public void Freeze() + { + if (IsFrozen) + { + return; + } + frozen = true; + // Only values can be frozen, as all the key types are simple. + // Everything can be done in-place, as we're just freezing objects. + if (typeof(IFreezable).IsAssignableFrom(typeof(TValue))) + { + for (var node = list.First; node != null; node = node.Next) + { + var pair = node.Value; + IFreezable freezableValue = pair.Value as IFreezable; + if (freezableValue != null) + { + freezableValue.Freeze(); + } + } + } + } + + public bool IsFrozen { get { return frozen; } } + + public override bool Equals(object other) + { + return Equals(other as MapField); + } + + public override int GetHashCode() + { + var valueComparer = EqualityComparer.Default; + int hash = 0; + foreach (var pair in list) + { + hash ^= pair.Key.GetHashCode() * 31 + valueComparer.GetHashCode(pair.Value); + } + return hash; + } + + public bool Equals(MapField other) + { + if (other == null) + { + return false; + } + if (other == this) + { + return true; + } + if (other.Count != this.Count) + { + return false; + } + var valueComparer = EqualityComparer.Default; + foreach (var pair in this) + { + TValue value; + if (!other.TryGetValue(pair.Key, out value)) + { + return false; + } + if (!valueComparer.Equals(value, pair.Value)) + { + return false; + } + } + return true; + } + + public void AddEntriesFrom(CodedInputStream input, Codec codec) + { + // TODO: Peek at the next tag and see if it's the same. If it is, we can reuse the entry object... + var adapter = new Codec.MessageAdapter(codec); + adapter.Reset(); + input.ReadMessage(adapter); + this[adapter.Key] = adapter.Value; + } + + public void WriteTo(CodedOutputStream 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); + } + } + + public int CalculateSize(Codec codec) + { + var message = new Codec.MessageAdapter(codec); + int size = 0; + foreach (var entry in list) + { + message.Key = entry.Key; + message.Value = entry.Value; + size += CodedOutputStream.ComputeRawVarint32Size(codec.MapTag); + size += CodedOutputStream.ComputeMessageSize(message); + } + return size; + } + + /// + /// A codec for a specific map field. This contains all the information required to encoded and + /// decode the nested messages. + /// + public sealed class Codec + { + private readonly FieldCodec keyCodec; + private readonly FieldCodec valueCodec; + private readonly uint mapTag; + + public Codec(FieldCodec keyCodec, FieldCodec valueCodec, uint mapTag) + { + this.keyCodec = keyCodec; + this.valueCodec = valueCodec; + this.mapTag = mapTag; + } + + /// + /// The tag used in the enclosing message to indicate map entries. + /// + internal uint MapTag { get { return mapTag; } } + + /// + /// A mutable message class, used for parsing and serializing. This + /// delegates the work to a codec, but implements the interface + /// for interop with and . + /// This is nested inside Codec as it's tightly coupled to the associated codec, + /// and it's simpler if it has direct access to all its fields. + /// + internal class MessageAdapter : IMessage + { + private readonly Codec codec; + internal TKey Key { get; set; } + internal TValue Value { get; set; } + internal int Size { get; set; } + + internal MessageAdapter(Codec codec) + { + this.codec = codec; + } + + internal void Reset() + { + Key = codec.keyCodec.DefaultValue; + Value = codec.valueCodec.DefaultValue; + } + + public void MergeFrom(CodedInputStream input) + { + uint tag; + while (input.ReadTag(out tag)) + { + if (tag == 0) + { + throw InvalidProtocolBufferException.InvalidTag(); + } + if (tag == codec.keyCodec.Tag) + { + Key = codec.keyCodec.Read(input); + } + else if (tag == codec.valueCodec.Tag) + { + Value = codec.valueCodec.Read(input); + } + else if (WireFormat.IsEndGroupTag(tag)) + { + // TODO(jonskeet): Do we need this? (Given that we don't support groups...) + return; + } + } + } + + public void WriteTo(CodedOutputStream output) + { + codec.keyCodec.Write(output, Key); + codec.valueCodec.Write(output, Value); + } + + public int CalculateSize() + { + return codec.keyCodec.CalculateSize(Key) + codec.valueCodec.CalculateSize(Value); + } + } + } + } +} diff --git a/csharp/src/ProtocolBuffers/FieldCodec.cs b/csharp/src/ProtocolBuffers/FieldCodec.cs new file mode 100644 index 00000000..931b54d3 --- /dev/null +++ b/csharp/src/ProtocolBuffers/FieldCodec.cs @@ -0,0 +1,178 @@ +using System; +using System.Collections.Generic; + +namespace Google.Protobuf +{ + /// + /// Factory methods for . + /// + public static class FieldCodec + { + public static FieldCodec ForString(uint tag) + { + return new FieldCodec(input => input.ReadString(), (output, value) => output.WriteString(value), CodedOutputStream.ComputeStringSize, tag); + } + + public static FieldCodec ForBytes(uint tag) + { + return new FieldCodec(input => input.ReadBytes(), (output, value) => output.WriteBytes(value), CodedOutputStream.ComputeBytesSize, tag); + } + + public static FieldCodec ForBool(uint tag) + { + return new FieldCodec(input => input.ReadBool(), (output, value) => output.WriteBool(value), CodedOutputStream.ComputeBoolSize, tag); + } + + public static FieldCodec ForInt32(uint tag) + { + return new FieldCodec(input => input.ReadInt32(), (output, value) => output.WriteInt32(value), CodedOutputStream.ComputeInt32Size, tag); + } + + public static FieldCodec ForSInt32(uint tag) + { + return new FieldCodec(input => input.ReadSInt32(), (output, value) => output.WriteSInt32(value), CodedOutputStream.ComputeSInt32Size, tag); + } + + public static FieldCodec ForFixedInt32(uint tag) + { + return new FieldCodec(input => input.ReadFixed32(), (output, value) => output.WriteFixed32(value), CodedOutputStream.ComputeFixed32Size, tag); + } + + public static FieldCodec ForUInt32(uint tag) + { + return new FieldCodec(input => input.ReadUInt32(), (output, value) => output.WriteUInt32(value), CodedOutputStream.ComputeUInt32Size, tag); + } + + public static FieldCodec ForInt64(uint tag) + { + return new FieldCodec(input => input.ReadInt64(), (output, value) => output.WriteInt64(value), CodedOutputStream.ComputeInt64Size, tag); + } + + public static FieldCodec ForSInt64(uint tag) + { + return new FieldCodec(input => input.ReadSInt64(), (output, value) => output.WriteSInt64(value), CodedOutputStream.ComputeSInt64Size, tag); + } + + public static FieldCodec ForFixedInt64(uint tag) + { + return new FieldCodec(input => input.ReadFixed64(), (output, value) => output.WriteFixed64(value), CodedOutputStream.ComputeFixed64Size, tag); + } + + public static FieldCodec ForUInt64(uint tag) + { + return new FieldCodec(input => input.ReadUInt64(), (output, value) => output.WriteUInt64(value), CodedOutputStream.ComputeUInt64Size, tag); + } + + public static FieldCodec ForFloat(uint tag) + { + return new FieldCodec(input => input.ReadFloat(), (output, value) => output.WriteFloat(value), CodedOutputStream.ComputeFloatSize, tag); + } + + public static FieldCodec ForDouble(uint tag) + { + return new FieldCodec(input => input.ReadFloat(), (output, value) => output.WriteDouble(value), CodedOutputStream.ComputeDoubleSize, tag); + } + + // Enums are tricky. We can probably use expression trees to build these delegates automatically, + // but it's easy to generate the code fdor it. + public static FieldCodec ForEnum(uint tag, Func toInt32, Func fromInt32) + { + return new FieldCodec(input => fromInt32( + input.ReadEnum()), + (output, value) => output.WriteEnum(toInt32(value)), + value => CodedOutputStream.ComputeEnumSize(toInt32(value)), tag); + } + + public static FieldCodec ForMessage(uint tag, MessageParser parser) where T : IMessage + { + return new FieldCodec(input => { T message = parser.CreateTemplate(); input.ReadMessage(message); return message; }, + (output, value) => output.WriteMessage(value), message => CodedOutputStream.ComputeMessageSize(message), tag); + } + } + + /// + /// An encode/decode pair for a single field. This effectively encapsulates + /// all the information needed to read or write the field value from/to a coded + /// stream. + /// + /// + /// This never writes default values to the stream, and is not currently designed + /// to play well with packed arrays. + /// + public sealed class FieldCodec + { + private static readonly Func IsDefault; + private static readonly T Default; + + static FieldCodec() + { + if (typeof(T) == typeof(string)) + { + Default = (T)(object)""; + IsDefault = CreateDefaultValueCheck(x => x.Length == 0); + } + else if (typeof(T) == typeof(ByteString)) + { + Default = (T)(object)ByteString.Empty; + IsDefault = CreateDefaultValueCheck(x => x.Length == 0); + } + else if (!typeof(T).IsValueType) + { + // Default default + IsDefault = CreateDefaultValueCheck(x => x == null); + } + else + { + // Default default + IsDefault = CreateDefaultValueCheck(x => EqualityComparer.Default.Equals(x, default(T))); + } + } + + private static Func CreateDefaultValueCheck(Func check) + { + return (Func)(object)check; + } + + private readonly Func reader; + private readonly Action writer; + private readonly Func sizeComputer; + private readonly uint tag; + private readonly int tagSize; + + internal FieldCodec( + Func reader, + Action writer, + Func sizeComputer, + uint tag) + { + this.reader = reader; + this.writer = writer; + this.sizeComputer = sizeComputer; + this.tag = tag; + tagSize = CodedOutputStream.ComputeRawVarint32Size(tag); + } + + public uint Tag { get { return tag; } } + + public T DefaultValue { get { return Default; } } + + public void Write(CodedOutputStream output, T value) + { + if (!IsDefault(value)) + { + output.WriteTag(tag); + writer(output, value); + } + } + + public T Read(CodedInputStream input) + { + return reader(input); + } + + public int CalculateSize(T value) + { + return IsDefault(value) ? 0 : sizeComputer(value) + CodedOutputStream.ComputeRawVarint32Size(tag); + } + } +} diff --git a/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj b/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj index d1551148..5edeff70 100644 --- a/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj +++ b/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj @@ -60,6 +60,7 @@ + @@ -84,6 +85,7 @@ + diff --git a/src/Makefile.am b/src/Makefile.am index 866af48a..cea3089e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -425,6 +425,8 @@ libprotoc_la_SOURCES = \ google/protobuf/compiler/csharp/csharp_generator.cc \ google/protobuf/compiler/csharp/csharp_helpers.cc \ google/protobuf/compiler/csharp/csharp_helpers.h \ + google/protobuf/compiler/csharp/csharp_map_field.cc \ + google/protobuf/compiler/csharp/csharp_map_field.h \ google/protobuf/compiler/csharp/csharp_message.cc \ google/protobuf/compiler/csharp/csharp_message.h \ google/protobuf/compiler/csharp/csharp_message_field.cc \ diff --git a/src/google/protobuf/compiler/csharp/csharp_enum_field.cc b/src/google/protobuf/compiler/csharp/csharp_enum_field.cc index af34f50c..d38fb1ed 100644 --- a/src/google/protobuf/compiler/csharp/csharp_enum_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_enum_field.cc @@ -74,6 +74,12 @@ void EnumFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) { "}\n"); } +void EnumFieldGenerator::GenerateCodecCode(io::Printer* printer) { + printer->Print( + variables_, + "pb::FieldCodec.ForEnum($tag$, x => (int) x, x => ($type_name$) x)"); +} + EnumOneofFieldGenerator::EnumOneofFieldGenerator(const FieldDescriptor* descriptor, int fieldOrdinal) : PrimitiveOneofFieldGenerator(descriptor, fieldOrdinal) { diff --git a/src/google/protobuf/compiler/csharp/csharp_enum_field.h b/src/google/protobuf/compiler/csharp/csharp_enum_field.h index e627b7cc..08364157 100644 --- a/src/google/protobuf/compiler/csharp/csharp_enum_field.h +++ b/src/google/protobuf/compiler/csharp/csharp_enum_field.h @@ -46,6 +46,7 @@ class EnumFieldGenerator : public PrimitiveFieldGenerator { EnumFieldGenerator(const FieldDescriptor* descriptor, int fieldOrdinal); ~EnumFieldGenerator(); + virtual void GenerateCodecCode(io::Printer* printer); virtual void GenerateParsingCode(io::Printer* printer); virtual void GenerateSerializationCode(io::Printer* printer); virtual void GenerateSerializedSizeCode(io::Printer* printer); diff --git a/src/google/protobuf/compiler/csharp/csharp_field_base.cc b/src/google/protobuf/compiler/csharp/csharp_field_base.cc index c716e1bf..bfb39a64 100644 --- a/src/google/protobuf/compiler/csharp/csharp_field_base.cc +++ b/src/google/protobuf/compiler/csharp/csharp_field_base.cc @@ -65,6 +65,7 @@ void FieldGeneratorBase::SetCommonFieldVariables( tag_bytes += ", " + SimpleItoa(tag_array[i]); } + (*variables)["tag"] = SimpleItoa(tag); (*variables)["tag_size"] = SimpleItoa(tag_size); (*variables)["tag_bytes"] = tag_bytes; @@ -112,6 +113,11 @@ void FieldGeneratorBase::GenerateFreezingCode(io::Printer* printer) { // special handling for freezing, so default to not generating any code. } +void FieldGeneratorBase::GenerateCodecCode(io::Printer* printer) { + // No-op: expect this to be overridden by appropriate types. + // Could fail if we get called here though... +} + void FieldGeneratorBase::AddDeprecatedFlag(io::Printer* printer) { if (descriptor_->options().deprecated()) { @@ -151,12 +157,16 @@ std::string FieldGeneratorBase::name() { } std::string FieldGeneratorBase::type_name() { - switch (descriptor_->type()) { + return type_name(descriptor_); +} + +std::string FieldGeneratorBase::type_name(const FieldDescriptor* descriptor) { + switch (descriptor->type()) { case FieldDescriptor::TYPE_ENUM: - return GetClassName(descriptor_->enum_type()); + return GetClassName(descriptor->enum_type()); case FieldDescriptor::TYPE_MESSAGE: case FieldDescriptor::TYPE_GROUP: - return GetClassName(descriptor_->message_type()); + return GetClassName(descriptor->message_type()); case FieldDescriptor::TYPE_DOUBLE: return "double"; case FieldDescriptor::TYPE_FLOAT: diff --git a/src/google/protobuf/compiler/csharp/csharp_field_base.h b/src/google/protobuf/compiler/csharp/csharp_field_base.h index abf9254b..349d835b 100644 --- a/src/google/protobuf/compiler/csharp/csharp_field_base.h +++ b/src/google/protobuf/compiler/csharp/csharp_field_base.h @@ -49,6 +49,7 @@ class FieldGeneratorBase : public SourceGeneratorBase { virtual void GenerateCloningCode(io::Printer* printer) = 0; virtual void GenerateFreezingCode(io::Printer* printer); + virtual void GenerateCodecCode(io::Printer* printer); virtual void GenerateMembers(io::Printer* printer) = 0; virtual void GenerateMergingCode(io::Printer* printer) = 0; virtual void GenerateParsingCode(io::Printer* printer) = 0; @@ -76,6 +77,7 @@ class FieldGeneratorBase : public SourceGeneratorBase { std::string property_name(); std::string name(); std::string type_name(); + std::string type_name(const FieldDescriptor* descriptor); bool has_default_value(); bool is_nullable_type(); std::string default_value(); diff --git a/src/google/protobuf/compiler/csharp/csharp_helpers.cc b/src/google/protobuf/compiler/csharp/csharp_helpers.cc index 39a53268..927fea97 100644 --- a/src/google/protobuf/compiler/csharp/csharp_helpers.cc +++ b/src/google/protobuf/compiler/csharp/csharp_helpers.cc @@ -46,6 +46,7 @@ #include #include +#include #include #include #include @@ -355,7 +356,11 @@ FieldGeneratorBase* CreateFieldGenerator(const FieldDescriptor* descriptor, case FieldDescriptor::TYPE_GROUP: case FieldDescriptor::TYPE_MESSAGE: if (descriptor->is_repeated()) { - return new RepeatedMessageFieldGenerator(descriptor, fieldOrdinal); + if (descriptor->is_map()) { + return new MapFieldGenerator(descriptor, fieldOrdinal); + } else { + return new RepeatedMessageFieldGenerator(descriptor, fieldOrdinal); + } } else { if (descriptor->containing_oneof()) { return new MessageOneofFieldGenerator(descriptor, fieldOrdinal); diff --git a/src/google/protobuf/compiler/csharp/csharp_map_field.cc b/src/google/protobuf/compiler/csharp/csharp_map_field.cc new file mode 100644 index 00000000..b8f1592c --- /dev/null +++ b/src/google/protobuf/compiler/csharp/csharp_map_field.cc @@ -0,0 +1,141 @@ +// 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. + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +namespace google { +namespace protobuf { +namespace compiler { +namespace csharp { + +MapFieldGenerator::MapFieldGenerator(const FieldDescriptor* descriptor, + int fieldOrdinal) + : FieldGeneratorBase(descriptor, fieldOrdinal) { +} + +MapFieldGenerator::~MapFieldGenerator() { +} + +void MapFieldGenerator::GenerateMembers(io::Printer* printer) { + const FieldDescriptor* key_descriptor = + descriptor_->message_type()->FindFieldByName("key"); + const FieldDescriptor* value_descriptor = + descriptor_->message_type()->FindFieldByName("value"); + variables_["key_type_name"] = type_name(key_descriptor); + variables_["value_type_name"] = type_name(value_descriptor); + scoped_ptr key_generator(CreateFieldGenerator(key_descriptor, 1)); + scoped_ptr value_generator(CreateFieldGenerator(value_descriptor, 2)); + + printer->Print( + variables_, + "private static readonly pbc::MapField<$key_type_name$, $value_type_name$>.Codec _map_$name$_codec\n" + " = new pbc::MapField<$key_type_name$, $value_type_name$>.Codec("); + key_generator->GenerateCodecCode(printer); + printer->Print(", "); + value_generator->GenerateCodecCode(printer); + printer->Print( + variables_, + ", $tag$);\n" + "private readonly pbc::MapField<$key_type_name$, $value_type_name$> $name$_ = new pbc::MapField<$key_type_name$, $value_type_name$>();\n"); + AddDeprecatedFlag(printer); + printer->Print( + variables_, + "public pbc::MapField<$key_type_name$, $value_type_name$> $property_name$ {\n" + " get { return $name$_; }\n" + "}\n"); +} + +void MapFieldGenerator::GenerateMergingCode(io::Printer* printer) { + printer->Print( + variables_, + "$name$_.Add(other.$name$_);\n"); +} + +void MapFieldGenerator::GenerateParsingCode(io::Printer* printer) { + printer->Print( + variables_, + "$name$_.AddEntriesFrom(input, _map_$name$_codec);\n"); +} + +void MapFieldGenerator::GenerateSerializationCode(io::Printer* printer) { + printer->Print( + variables_, + "$name$_.WriteTo(output, _map_$name$_codec);\n"); +} + +void MapFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) { + printer->Print( + variables_, + "size += $name$_.CalculateSize(_map_$name$_codec);\n"); +} + +void MapFieldGenerator::WriteHash(io::Printer* printer) { + printer->Print( + variables_, + "hash ^= $property_name$.GetHashCode();\n"); +} +void MapFieldGenerator::WriteEquals(io::Printer* printer) { + printer->Print( + variables_, + "if (!$property_name$.Equals(other.$property_name$)) return false;\n"); +} +void MapFieldGenerator::WriteToString(io::Printer* printer) { + /* + variables_["field_name"] = GetFieldName(descriptor_); + printer->Print( + variables_, + "PrintField(\"$field_name$\", has$property_name$, $name$_, writer);\n");*/ +} + +void MapFieldGenerator::GenerateCloningCode(io::Printer* printer) { + printer->Print(variables_, + "$name$_ = other.$name$_.Clone();\n"); +} + +void MapFieldGenerator::GenerateFreezingCode(io::Printer* printer) { + printer->Print(variables_, + "$name$_.Freeze();\n"); +} + +} // namespace csharp +} // namespace compiler +} // namespace protobuf +} // namespace google diff --git a/src/google/protobuf/compiler/csharp/csharp_map_field.h b/src/google/protobuf/compiler/csharp/csharp_map_field.h new file mode 100644 index 00000000..f33fe1c3 --- /dev/null +++ b/src/google/protobuf/compiler/csharp/csharp_map_field.h @@ -0,0 +1,71 @@ +// 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. + +#ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_MAP_FIELD_H__ +#define GOOGLE_PROTOBUF_COMPILER_CSHARP_MAP_FIELD_H__ + +#include + +#include +#include + +namespace google { +namespace protobuf { +namespace compiler { +namespace csharp { + +class MapFieldGenerator : public FieldGeneratorBase { + public: + MapFieldGenerator(const FieldDescriptor* descriptor, int fieldOrdinal); + ~MapFieldGenerator(); + + virtual void GenerateCloningCode(io::Printer* printer); + virtual void GenerateFreezingCode(io::Printer* printer); + virtual void GenerateMembers(io::Printer* printer); + virtual void GenerateMergingCode(io::Printer* printer); + virtual void GenerateParsingCode(io::Printer* printer); + virtual void GenerateSerializationCode(io::Printer* printer); + virtual void GenerateSerializedSizeCode(io::Printer* printer); + + virtual void WriteHash(io::Printer* printer); + virtual void WriteEquals(io::Printer* printer); + virtual void WriteToString(io::Printer* printer); + + private: + GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapFieldGenerator); +}; + +} // namespace csharp +} // namespace compiler +} // namespace protobuf +} // namespace google + +#endif // GOOGLE_PROTOBUF_COMPILER_CSHARP_MAP_FIELD_H__ + diff --git a/src/google/protobuf/compiler/csharp/csharp_message.cc b/src/google/protobuf/compiler/csharp/csharp_message.cc index a6c8e32b..3cb91951 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message.cc @@ -268,8 +268,6 @@ void MessageGenerator::Generate(io::Printer* printer) { "}\n\n"); } - // TODO(jonskeet): Map properties - // Standard methods GenerateFrameworkMethods(printer); GenerateMessageSerializationMethods(printer); @@ -299,7 +297,6 @@ void MessageGenerator::Generate(io::Printer* printer) { printer->Outdent(); printer->Print("}\n"); printer->Print("\n"); - } void MessageGenerator::GenerateCloningCode(io::Printer* printer) { @@ -451,7 +448,7 @@ void MessageGenerator::GenerateMessageSerializationMethods(io::Printer* printer) } printer->Print("return size;\n"); printer->Outdent(); - printer->Print("}\n"); + printer->Print("}\n\n"); } void MessageGenerator::GenerateMergingMethods(io::Printer* printer) { @@ -469,7 +466,6 @@ void MessageGenerator::GenerateMergingMethods(io::Printer* printer) { "if (other == null) {\n" " return;\n" "}\n"); - // TODO(jonskeet): Maps? // Merge non-oneof fields for (int i = 0; i < descriptor_->field_count(); i++) { if (!descriptor_->field(i)->containing_oneof()) { diff --git a/src/google/protobuf/compiler/csharp/csharp_message_field.cc b/src/google/protobuf/compiler/csharp/csharp_message_field.cc index cbf182d2..d8c82271 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message_field.cc @@ -138,6 +138,12 @@ void MessageFieldGenerator::GenerateFreezingCode(io::Printer* printer) { "if ($has_property_check$) $property_name$.Freeze();\n"); } +void MessageFieldGenerator::GenerateCodecCode(io::Printer* printer) { + printer->Print( + variables_, + "pb::FieldCodec.ForMessage($tag$, $type_name$.Parser)"); +} + MessageOneofFieldGenerator::MessageOneofFieldGenerator(const FieldDescriptor* descriptor, int fieldOrdinal) : MessageFieldGenerator(descriptor, fieldOrdinal) { diff --git a/src/google/protobuf/compiler/csharp/csharp_message_field.h b/src/google/protobuf/compiler/csharp/csharp_message_field.h index 3e17f92a..dc6e4dc5 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message_field.h +++ b/src/google/protobuf/compiler/csharp/csharp_message_field.h @@ -46,6 +46,7 @@ class MessageFieldGenerator : public FieldGeneratorBase { MessageFieldGenerator(const FieldDescriptor* descriptor, int fieldOrdinal); ~MessageFieldGenerator(); + virtual void GenerateCodecCode(io::Printer* printer); virtual void GenerateCloningCode(io::Printer* printer); virtual void GenerateFreezingCode(io::Printer* printer); virtual void GenerateMembers(io::Printer* printer); diff --git a/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc b/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc index d5542f57..c40cba13 100644 --- a/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc @@ -129,7 +129,7 @@ void PrimitiveFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) { "size += $tag_size$ + $fixed_size$;\n", "fixed_size", SimpleItoa(fixedSize), "tag_size", variables_["tag_size"]); - } + } printer->Outdent(); printer->Print("}\n"); } @@ -155,6 +155,12 @@ void PrimitiveFieldGenerator::GenerateCloningCode(io::Printer* printer) { "$name$_ = other.$name$_;\n"); } +void PrimitiveFieldGenerator::GenerateCodecCode(io::Printer* printer) { + printer->Print( + variables_, + "pb::FieldCodec.For$capitalized_type_name$($tag$)"); +} + PrimitiveOneofFieldGenerator::PrimitiveOneofFieldGenerator( const FieldDescriptor* descriptor, int fieldOrdinal) : PrimitiveFieldGenerator(descriptor, fieldOrdinal) { diff --git a/src/google/protobuf/compiler/csharp/csharp_primitive_field.h b/src/google/protobuf/compiler/csharp/csharp_primitive_field.h index bac33214..8b87ebc4 100644 --- a/src/google/protobuf/compiler/csharp/csharp_primitive_field.h +++ b/src/google/protobuf/compiler/csharp/csharp_primitive_field.h @@ -46,6 +46,7 @@ class PrimitiveFieldGenerator : public FieldGeneratorBase { PrimitiveFieldGenerator(const FieldDescriptor* descriptor, int fieldOrdinal); ~PrimitiveFieldGenerator(); + virtual void GenerateCodecCode(io::Printer* printer); virtual void GenerateCloningCode(io::Printer* printer); virtual void GenerateMembers(io::Printer* printer); virtual void GenerateMergingCode(io::Printer* printer); diff --git a/src/google/protobuf/unittest_proto3.proto b/src/google/protobuf/unittest_proto3.proto index f59d2178..41fa56dc 100644 --- a/src/google/protobuf/unittest_proto3.proto +++ b/src/google/protobuf/unittest_proto3.proto @@ -140,6 +140,11 @@ message TestAllTypes { string oneof_string = 113; bytes oneof_bytes = 114; } + + // Sample maps + map map_string_to_nested_message = 200; + map map_int32_to_bytes = 201; + map map_bool_to_enum = 202; } // This proto includes a recusively nested message. -- cgit v1.2.3 From e36e601a394e96759a9ccf0eda97c0451c49c2cc Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Wed, 24 Jun 2015 17:22:15 +0100 Subject: Generated map code. --- .../TestProtos/UnittestProto3.cs | 679 ++++++++++++++++++--- 1 file changed, 592 insertions(+), 87 deletions(-) diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs index d758ef5c..e0d0d3d0 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs @@ -17,6 +17,12 @@ namespace Google.Protobuf.TestProtos { internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestAllTypes__FieldAccessorTable; internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestAllTypes_NestedMessage__Descriptor; internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestAllTypes_NestedMessage__FieldAccessorTable; + internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestAllTypes_MapStringToNestedMessageEntry__Descriptor; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestAllTypes_MapStringToNestedMessageEntry__FieldAccessorTable; + internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestAllTypes_MapInt32ToBytesEntry__Descriptor; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestAllTypes_MapInt32ToBytesEntry__FieldAccessorTable; + internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestAllTypes_MapBoolToEnumEntry__Descriptor; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestAllTypes_MapBoolToEnumEntry__FieldAccessorTable; internal static pbd::MessageDescriptor internal__static_protobuf_unittest_NestedTestAllTypes__Descriptor; internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_NestedTestAllTypes__FieldAccessorTable; internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestDeprecatedFields__Descriptor; @@ -95,7 +101,7 @@ namespace Google.Protobuf.TestProtos { string.Concat( "CiVnb29nbGUvcHJvdG9idWYvdW5pdHRlc3RfcHJvdG8zLnByb3RvEhFwcm90", "b2J1Zl91bml0dGVzdBosZ29vZ2xlL3Byb3RvYnVmL3VuaXR0ZXN0X2ltcG9y", - "dF9wcm90bzMucHJvdG8i8A8KDFRlc3RBbGxUeXBlcxIUCgxzaW5nbGVfaW50", + "dF9wcm90bzMucHJvdG8ighQKDFRlc3RBbGxUeXBlcxIUCgxzaW5nbGVfaW50", "MzIYASABKAUSFAoMc2luZ2xlX2ludDY0GAIgASgDEhUKDXNpbmdsZV91aW50", "MzIYAyABKA0SFQoNc2luZ2xlX3VpbnQ2NBgEIAEoBBIVCg1zaW5nbGVfc2lu", "dDMyGAUgASgREhUKDXNpbmdsZV9zaW50NjQYBiABKBISFgoOc2luZ2xlX2Zp", @@ -137,99 +143,123 @@ namespace Google.Protobuf.TestProtos { "bXBvcnRNZXNzYWdlEhYKDG9uZW9mX3VpbnQzMhhvIAEoDUgAEk0KFG9uZW9m", "X25lc3RlZF9tZXNzYWdlGHAgASgLMi0ucHJvdG9idWZfdW5pdHRlc3QuVGVz", "dEFsbFR5cGVzLk5lc3RlZE1lc3NhZ2VIABIWCgxvbmVvZl9zdHJpbmcYcSAB", - "KAlIABIVCgtvbmVvZl9ieXRlcxhyIAEoDEgAGhsKDU5lc3RlZE1lc3NhZ2US", - "CgoCYmIYASABKAUiVgoKTmVzdGVkRW51bRIbChdORVNURURfRU5VTV9VTlNQ", - "RUNJRklFRBAAEgcKA0ZPTxABEgcKA0JBUhACEgcKA0JBWhADEhAKA05FRxD/", - "//////////8BQg0KC29uZW9mX2ZpZWxkIrsBChJOZXN0ZWRUZXN0QWxsVHlw", - "ZXMSNAoFY2hpbGQYASABKAsyJS5wcm90b2J1Zl91bml0dGVzdC5OZXN0ZWRU", - "ZXN0QWxsVHlwZXMSMAoHcGF5bG9hZBgCIAEoCzIfLnByb3RvYnVmX3VuaXR0", - "ZXN0LlRlc3RBbGxUeXBlcxI9Cg5yZXBlYXRlZF9jaGlsZBgDIAMoCzIlLnBy", - "b3RvYnVmX3VuaXR0ZXN0Lk5lc3RlZFRlc3RBbGxUeXBlcyI0ChRUZXN0RGVw", - "cmVjYXRlZEZpZWxkcxIcChBkZXByZWNhdGVkX2ludDMyGAEgASgFQgIYASIb", - "Cg5Gb3JlaWduTWVzc2FnZRIJCgFjGAEgASgFIjAKElRlc3RSZXNlcnZlZEZp", - "ZWxkc0oECAIQA0oECA8QEEoECAkQDFIDYmFyUgNiYXoiWgoRVGVzdEZvcmVp", - "Z25OZXN0ZWQSRQoOZm9yZWlnbl9uZXN0ZWQYASABKAsyLS5wcm90b2J1Zl91", - "bml0dGVzdC5UZXN0QWxsVHlwZXMuTmVzdGVkTWVzc2FnZSI0ChhUZXN0UmVh", - "bGx5TGFyZ2VUYWdOdW1iZXISCQoBYRgBIAEoBRINCgJiYhj///9/IAEoBSJV", - "ChRUZXN0UmVjdXJzaXZlTWVzc2FnZRIyCgFhGAEgASgLMicucHJvdG9idWZf", - "dW5pdHRlc3QuVGVzdFJlY3Vyc2l2ZU1lc3NhZ2USCQoBaRgCIAEoBSJLChRU", - "ZXN0TXV0dWFsUmVjdXJzaW9uQRIzCgJiYhgBIAEoCzInLnByb3RvYnVmX3Vu", - "aXR0ZXN0LlRlc3RNdXR1YWxSZWN1cnNpb25CImIKFFRlc3RNdXR1YWxSZWN1", - "cnNpb25CEjIKAWEYASABKAsyJy5wcm90b2J1Zl91bml0dGVzdC5UZXN0TXV0", - "dWFsUmVjdXJzaW9uQRIWCg5vcHRpb25hbF9pbnQzMhgCIAEoBSLrAgoXVGVz", - "dENhbWVsQ2FzZUZpZWxkTmFtZXMSFgoOUHJpbWl0aXZlRmllbGQYASABKAUS", - "EwoLU3RyaW5nRmllbGQYAiABKAkSMQoJRW51bUZpZWxkGAMgASgOMh4ucHJv", - "dG9idWZfdW5pdHRlc3QuRm9yZWlnbkVudW0SNwoMTWVzc2FnZUZpZWxkGAQg", - "ASgLMiEucHJvdG9idWZfdW5pdHRlc3QuRm9yZWlnbk1lc3NhZ2USHgoWUmVw", - "ZWF0ZWRQcmltaXRpdmVGaWVsZBgHIAMoBRIbChNSZXBlYXRlZFN0cmluZ0Zp", - "ZWxkGAggAygJEjkKEVJlcGVhdGVkRW51bUZpZWxkGAkgAygOMh4ucHJvdG9i", - "dWZfdW5pdHRlc3QuRm9yZWlnbkVudW0SPwoUUmVwZWF0ZWRNZXNzYWdlRmll", - "bGQYCiADKAsyIS5wcm90b2J1Zl91bml0dGVzdC5Gb3JlaWduTWVzc2FnZSLH", - "AQoSVGVzdEZpZWxkT3JkZXJpbmdzEhEKCW15X3N0cmluZxgLIAEoCRIOCgZt", - "eV9pbnQYASABKAMSEAoIbXlfZmxvYXQYZSABKAISUwoVc2luZ2xlX25lc3Rl", - "ZF9tZXNzYWdlGMgBIAEoCzIzLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RGaWVs", - "ZE9yZGVyaW5ncy5OZXN0ZWRNZXNzYWdlGicKDU5lc3RlZE1lc3NhZ2USCgoC", - "b28YAiABKAMSCgoCYmIYASABKAUiSwoRU3BhcnNlRW51bU1lc3NhZ2USNgoL", - "c3BhcnNlX2VudW0YASABKA4yIS5wcm90b2J1Zl91bml0dGVzdC5UZXN0U3Bh", - "cnNlRW51bSIZCglPbmVTdHJpbmcSDAoEZGF0YRgBIAEoCSIaCgpNb3JlU3Ry", - "aW5nEgwKBGRhdGEYASADKAkiGAoIT25lQnl0ZXMSDAoEZGF0YRgBIAEoDCIZ", - "CglNb3JlQnl0ZXMSDAoEZGF0YRgBIAEoDCIcCgxJbnQzMk1lc3NhZ2USDAoE", - "ZGF0YRgBIAEoBSIdCg1VaW50MzJNZXNzYWdlEgwKBGRhdGEYASABKA0iHAoM", - "SW50NjRNZXNzYWdlEgwKBGRhdGEYASABKAMiHQoNVWludDY0TWVzc2FnZRIM", - "CgRkYXRhGAEgASgEIhsKC0Jvb2xNZXNzYWdlEgwKBGRhdGEYASABKAgicwoJ", - "VGVzdE9uZW9mEhEKB2Zvb19pbnQYASABKAVIABIUCgpmb29fc3RyaW5nGAIg", - "ASgJSAASNgoLZm9vX21lc3NhZ2UYAyABKAsyHy5wcm90b2J1Zl91bml0dGVz", - "dC5UZXN0QWxsVHlwZXNIAEIFCgNmb28iqgMKD1Rlc3RQYWNrZWRUeXBlcxIY", - "CgxwYWNrZWRfaW50MzIYWiADKAVCAhABEhgKDHBhY2tlZF9pbnQ2NBhbIAMo", - "A0ICEAESGQoNcGFja2VkX3VpbnQzMhhcIAMoDUICEAESGQoNcGFja2VkX3Vp", - "bnQ2NBhdIAMoBEICEAESGQoNcGFja2VkX3NpbnQzMhheIAMoEUICEAESGQoN", - "cGFja2VkX3NpbnQ2NBhfIAMoEkICEAESGgoOcGFja2VkX2ZpeGVkMzIYYCAD", - "KAdCAhABEhoKDnBhY2tlZF9maXhlZDY0GGEgAygGQgIQARIbCg9wYWNrZWRf", - "c2ZpeGVkMzIYYiADKA9CAhABEhsKD3BhY2tlZF9zZml4ZWQ2NBhjIAMoEEIC", - "EAESGAoMcGFja2VkX2Zsb2F0GGQgAygCQgIQARIZCg1wYWNrZWRfZG91Ymxl", - "GGUgAygBQgIQARIXCgtwYWNrZWRfYm9vbBhmIAMoCEICEAESNwoLcGFja2Vk", - "X2VudW0YZyADKA4yHi5wcm90b2J1Zl91bml0dGVzdC5Gb3JlaWduRW51bUIC", - "EAEiyAMKEVRlc3RVbnBhY2tlZFR5cGVzEhoKDnVucGFja2VkX2ludDMyGFog", - "AygFQgIQABIaCg51bnBhY2tlZF9pbnQ2NBhbIAMoA0ICEAASGwoPdW5wYWNr", - "ZWRfdWludDMyGFwgAygNQgIQABIbCg91bnBhY2tlZF91aW50NjQYXSADKARC", - "AhAAEhsKD3VucGFja2VkX3NpbnQzMhheIAMoEUICEAASGwoPdW5wYWNrZWRf", - "c2ludDY0GF8gAygSQgIQABIcChB1bnBhY2tlZF9maXhlZDMyGGAgAygHQgIQ", - "ABIcChB1bnBhY2tlZF9maXhlZDY0GGEgAygGQgIQABIdChF1bnBhY2tlZF9z", - "Zml4ZWQzMhhiIAMoD0ICEAASHQoRdW5wYWNrZWRfc2ZpeGVkNjQYYyADKBBC", - "AhAAEhoKDnVucGFja2VkX2Zsb2F0GGQgAygCQgIQABIbCg91bnBhY2tlZF9k", - "b3VibGUYZSADKAFCAhAAEhkKDXVucGFja2VkX2Jvb2wYZiADKAhCAhAAEjkK", - "DXVucGFja2VkX2VudW0YZyADKA4yHi5wcm90b2J1Zl91bml0dGVzdC5Gb3Jl", - "aWduRW51bUICEAAiwAEKI1Rlc3RSZXBlYXRlZFNjYWxhckRpZmZlcmVudFRh", - "Z1NpemVzEhgKEHJlcGVhdGVkX2ZpeGVkMzIYDCADKAcSFgoOcmVwZWF0ZWRf", - "aW50MzIYDSADKAUSGQoQcmVwZWF0ZWRfZml4ZWQ2NBj+DyADKAYSFwoOcmVw", - "ZWF0ZWRfaW50NjQY/w8gAygDEhgKDnJlcGVhdGVkX2Zsb2F0GP7/DyADKAIS", - "GQoPcmVwZWF0ZWRfdWludDY0GP//DyADKAQiKAobVGVzdENvbW1lbnRJbmpl", - "Y3Rpb25NZXNzYWdlEgkKAWEYASABKAkiDAoKRm9vUmVxdWVzdCINCgtGb29S", - "ZXNwb25zZSISChBGb29DbGllbnRNZXNzYWdlIhIKEEZvb1NlcnZlck1lc3Nh", - "Z2UiDAoKQmFyUmVxdWVzdCINCgtCYXJSZXNwb25zZSpZCgtGb3JlaWduRW51", - "bRIXChNGT1JFSUdOX1VOU1BFQ0lGSUVEEAASDwoLRk9SRUlHTl9GT08QBBIP", - "CgtGT1JFSUdOX0JBUhAFEg8KC0ZPUkVJR05fQkFaEAYqdQoUVGVzdEVudW1X", - "aXRoRHVwVmFsdWUSKAokVEVTVF9FTlVNX1dJVEhfRFVQX1ZBTFVFX1VOU1BF", - "Q0lGSUVEEAASCAoERk9PMRABEggKBEJBUjEQAhIHCgNCQVoQAxIICgRGT08y", - "EAESCAoEQkFSMhACGgIQASqdAQoOVGVzdFNwYXJzZUVudW0SIAocVEVTVF9T", - "UEFSU0VfRU5VTV9VTlNQRUNJRklFRBAAEgwKCFNQQVJTRV9BEHsSDgoIU1BB", - "UlNFX0IQpucDEg8KCFNQQVJTRV9DELKxgAYSFQoIU1BBUlNFX0QQ8f//////", - "////ARIVCghTUEFSU0VfRRC03vz///////8BEgwKCFNQQVJTRV9HEAIymQEK", - "C1Rlc3RTZXJ2aWNlEkQKA0ZvbxIdLnByb3RvYnVmX3VuaXR0ZXN0LkZvb1Jl", - "cXVlc3QaHi5wcm90b2J1Zl91bml0dGVzdC5Gb29SZXNwb25zZRJECgNCYXIS", - "HS5wcm90b2J1Zl91bml0dGVzdC5CYXJSZXF1ZXN0Gh4ucHJvdG9idWZfdW5p", - "dHRlc3QuQmFyUmVzcG9uc2VCOkINVW5pdHRlc3RQcm90b0gBgAEBiAEBkAEB", - "+AEBqgIaR29vZ2xlLlByb3RvYnVmLlRlc3RQcm90b3NiBnByb3RvMw==")); + "KAlIABIVCgtvbmVvZl9ieXRlcxhyIAEoDEgAEmQKHG1hcF9zdHJpbmdfdG9f", + "bmVzdGVkX21lc3NhZ2UYyAEgAygLMj0ucHJvdG9idWZfdW5pdHRlc3QuVGVz", + "dEFsbFR5cGVzLk1hcFN0cmluZ1RvTmVzdGVkTWVzc2FnZUVudHJ5ElEKEm1h", + "cF9pbnQzMl90b19ieXRlcxjJASADKAsyNC5wcm90b2J1Zl91bml0dGVzdC5U", + "ZXN0QWxsVHlwZXMuTWFwSW50MzJUb0J5dGVzRW50cnkSTQoQbWFwX2Jvb2xf", + "dG9fZW51bRjKASADKAsyMi5wcm90b2J1Zl91bml0dGVzdC5UZXN0QWxsVHlw", + "ZXMuTWFwQm9vbFRvRW51bUVudHJ5GhsKDU5lc3RlZE1lc3NhZ2USCgoCYmIY", + "ASABKAUabgodTWFwU3RyaW5nVG9OZXN0ZWRNZXNzYWdlRW50cnkSCwoDa2V5", + "GAEgASgJEjwKBXZhbHVlGAIgASgLMi0ucHJvdG9idWZfdW5pdHRlc3QuVGVz", + "dEFsbFR5cGVzLk5lc3RlZE1lc3NhZ2U6AjgBGjYKFE1hcEludDMyVG9CeXRl", + "c0VudHJ5EgsKA2tleRgBIAEoBRINCgV2YWx1ZRgCIAEoDDoCOAEaYAoSTWFw", + "Qm9vbFRvRW51bUVudHJ5EgsKA2tleRgBIAEoCBI5CgV2YWx1ZRgCIAEoDjIq", + "LnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RBbGxUeXBlcy5OZXN0ZWRFbnVtOgI4", + "ASJWCgpOZXN0ZWRFbnVtEhsKF05FU1RFRF9FTlVNX1VOU1BFQ0lGSUVEEAAS", + "BwoDRk9PEAESBwoDQkFSEAISBwoDQkFaEAMSEAoDTkVHEP///////////wFC", + "DQoLb25lb2ZfZmllbGQiuwEKEk5lc3RlZFRlc3RBbGxUeXBlcxI0CgVjaGls", + "ZBgBIAEoCzIlLnByb3RvYnVmX3VuaXR0ZXN0Lk5lc3RlZFRlc3RBbGxUeXBl", + "cxIwCgdwYXlsb2FkGAIgASgLMh8ucHJvdG9idWZfdW5pdHRlc3QuVGVzdEFs", + "bFR5cGVzEj0KDnJlcGVhdGVkX2NoaWxkGAMgAygLMiUucHJvdG9idWZfdW5p", + "dHRlc3QuTmVzdGVkVGVzdEFsbFR5cGVzIjQKFFRlc3REZXByZWNhdGVkRmll", + "bGRzEhwKEGRlcHJlY2F0ZWRfaW50MzIYASABKAVCAhgBIhsKDkZvcmVpZ25N", + "ZXNzYWdlEgkKAWMYASABKAUiMAoSVGVzdFJlc2VydmVkRmllbGRzSgQIAhAD", + "SgQIDxAQSgQICRAMUgNiYXJSA2JheiJaChFUZXN0Rm9yZWlnbk5lc3RlZBJF", + "Cg5mb3JlaWduX25lc3RlZBgBIAEoCzItLnByb3RvYnVmX3VuaXR0ZXN0LlRl", + "c3RBbGxUeXBlcy5OZXN0ZWRNZXNzYWdlIjQKGFRlc3RSZWFsbHlMYXJnZVRh", + "Z051bWJlchIJCgFhGAEgASgFEg0KAmJiGP///38gASgFIlUKFFRlc3RSZWN1", + "cnNpdmVNZXNzYWdlEjIKAWEYASABKAsyJy5wcm90b2J1Zl91bml0dGVzdC5U", + "ZXN0UmVjdXJzaXZlTWVzc2FnZRIJCgFpGAIgASgFIksKFFRlc3RNdXR1YWxS", + "ZWN1cnNpb25BEjMKAmJiGAEgASgLMicucHJvdG9idWZfdW5pdHRlc3QuVGVz", + "dE11dHVhbFJlY3Vyc2lvbkIiYgoUVGVzdE11dHVhbFJlY3Vyc2lvbkISMgoB", + "YRgBIAEoCzInLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RNdXR1YWxSZWN1cnNp", + "b25BEhYKDm9wdGlvbmFsX2ludDMyGAIgASgFIusCChdUZXN0Q2FtZWxDYXNl", + "RmllbGROYW1lcxIWCg5QcmltaXRpdmVGaWVsZBgBIAEoBRITCgtTdHJpbmdG", + "aWVsZBgCIAEoCRIxCglFbnVtRmllbGQYAyABKA4yHi5wcm90b2J1Zl91bml0", + "dGVzdC5Gb3JlaWduRW51bRI3CgxNZXNzYWdlRmllbGQYBCABKAsyIS5wcm90", + "b2J1Zl91bml0dGVzdC5Gb3JlaWduTWVzc2FnZRIeChZSZXBlYXRlZFByaW1p", + "dGl2ZUZpZWxkGAcgAygFEhsKE1JlcGVhdGVkU3RyaW5nRmllbGQYCCADKAkS", + "OQoRUmVwZWF0ZWRFbnVtRmllbGQYCSADKA4yHi5wcm90b2J1Zl91bml0dGVz", + "dC5Gb3JlaWduRW51bRI/ChRSZXBlYXRlZE1lc3NhZ2VGaWVsZBgKIAMoCzIh", + "LnByb3RvYnVmX3VuaXR0ZXN0LkZvcmVpZ25NZXNzYWdlIscBChJUZXN0Rmll", + "bGRPcmRlcmluZ3MSEQoJbXlfc3RyaW5nGAsgASgJEg4KBm15X2ludBgBIAEo", + "AxIQCghteV9mbG9hdBhlIAEoAhJTChVzaW5nbGVfbmVzdGVkX21lc3NhZ2UY", + "yAEgASgLMjMucHJvdG9idWZfdW5pdHRlc3QuVGVzdEZpZWxkT3JkZXJpbmdz", + "Lk5lc3RlZE1lc3NhZ2UaJwoNTmVzdGVkTWVzc2FnZRIKCgJvbxgCIAEoAxIK", + "CgJiYhgBIAEoBSJLChFTcGFyc2VFbnVtTWVzc2FnZRI2CgtzcGFyc2VfZW51", + "bRgBIAEoDjIhLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RTcGFyc2VFbnVtIhkK", + "CU9uZVN0cmluZxIMCgRkYXRhGAEgASgJIhoKCk1vcmVTdHJpbmcSDAoEZGF0", + "YRgBIAMoCSIYCghPbmVCeXRlcxIMCgRkYXRhGAEgASgMIhkKCU1vcmVCeXRl", + "cxIMCgRkYXRhGAEgASgMIhwKDEludDMyTWVzc2FnZRIMCgRkYXRhGAEgASgF", + "Ih0KDVVpbnQzMk1lc3NhZ2USDAoEZGF0YRgBIAEoDSIcCgxJbnQ2NE1lc3Nh", + "Z2USDAoEZGF0YRgBIAEoAyIdCg1VaW50NjRNZXNzYWdlEgwKBGRhdGEYASAB", + "KAQiGwoLQm9vbE1lc3NhZ2USDAoEZGF0YRgBIAEoCCJzCglUZXN0T25lb2YS", + "EQoHZm9vX2ludBgBIAEoBUgAEhQKCmZvb19zdHJpbmcYAiABKAlIABI2Cgtm", + "b29fbWVzc2FnZRgDIAEoCzIfLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RBbGxU", + "eXBlc0gAQgUKA2ZvbyKqAwoPVGVzdFBhY2tlZFR5cGVzEhgKDHBhY2tlZF9p", + "bnQzMhhaIAMoBUICEAESGAoMcGFja2VkX2ludDY0GFsgAygDQgIQARIZCg1w", + "YWNrZWRfdWludDMyGFwgAygNQgIQARIZCg1wYWNrZWRfdWludDY0GF0gAygE", + "QgIQARIZCg1wYWNrZWRfc2ludDMyGF4gAygRQgIQARIZCg1wYWNrZWRfc2lu", + "dDY0GF8gAygSQgIQARIaCg5wYWNrZWRfZml4ZWQzMhhgIAMoB0ICEAESGgoO", + "cGFja2VkX2ZpeGVkNjQYYSADKAZCAhABEhsKD3BhY2tlZF9zZml4ZWQzMhhi", + "IAMoD0ICEAESGwoPcGFja2VkX3NmaXhlZDY0GGMgAygQQgIQARIYCgxwYWNr", + "ZWRfZmxvYXQYZCADKAJCAhABEhkKDXBhY2tlZF9kb3VibGUYZSADKAFCAhAB", + "EhcKC3BhY2tlZF9ib29sGGYgAygIQgIQARI3CgtwYWNrZWRfZW51bRhnIAMo", + "DjIeLnByb3RvYnVmX3VuaXR0ZXN0LkZvcmVpZ25FbnVtQgIQASLIAwoRVGVz", + "dFVucGFja2VkVHlwZXMSGgoOdW5wYWNrZWRfaW50MzIYWiADKAVCAhAAEhoK", + "DnVucGFja2VkX2ludDY0GFsgAygDQgIQABIbCg91bnBhY2tlZF91aW50MzIY", + "XCADKA1CAhAAEhsKD3VucGFja2VkX3VpbnQ2NBhdIAMoBEICEAASGwoPdW5w", + "YWNrZWRfc2ludDMyGF4gAygRQgIQABIbCg91bnBhY2tlZF9zaW50NjQYXyAD", + "KBJCAhAAEhwKEHVucGFja2VkX2ZpeGVkMzIYYCADKAdCAhAAEhwKEHVucGFj", + "a2VkX2ZpeGVkNjQYYSADKAZCAhAAEh0KEXVucGFja2VkX3NmaXhlZDMyGGIg", + "AygPQgIQABIdChF1bnBhY2tlZF9zZml4ZWQ2NBhjIAMoEEICEAASGgoOdW5w", + "YWNrZWRfZmxvYXQYZCADKAJCAhAAEhsKD3VucGFja2VkX2RvdWJsZRhlIAMo", + "AUICEAASGQoNdW5wYWNrZWRfYm9vbBhmIAMoCEICEAASOQoNdW5wYWNrZWRf", + "ZW51bRhnIAMoDjIeLnByb3RvYnVmX3VuaXR0ZXN0LkZvcmVpZ25FbnVtQgIQ", + "ACLAAQojVGVzdFJlcGVhdGVkU2NhbGFyRGlmZmVyZW50VGFnU2l6ZXMSGAoQ", + "cmVwZWF0ZWRfZml4ZWQzMhgMIAMoBxIWCg5yZXBlYXRlZF9pbnQzMhgNIAMo", + "BRIZChByZXBlYXRlZF9maXhlZDY0GP4PIAMoBhIXCg5yZXBlYXRlZF9pbnQ2", + "NBj/DyADKAMSGAoOcmVwZWF0ZWRfZmxvYXQY/v8PIAMoAhIZCg9yZXBlYXRl", + "ZF91aW50NjQY//8PIAMoBCIoChtUZXN0Q29tbWVudEluamVjdGlvbk1lc3Nh", + "Z2USCQoBYRgBIAEoCSIMCgpGb29SZXF1ZXN0Ig0KC0Zvb1Jlc3BvbnNlIhIK", + "EEZvb0NsaWVudE1lc3NhZ2UiEgoQRm9vU2VydmVyTWVzc2FnZSIMCgpCYXJS", + "ZXF1ZXN0Ig0KC0JhclJlc3BvbnNlKlkKC0ZvcmVpZ25FbnVtEhcKE0ZPUkVJ", + "R05fVU5TUEVDSUZJRUQQABIPCgtGT1JFSUdOX0ZPTxAEEg8KC0ZPUkVJR05f", + "QkFSEAUSDwoLRk9SRUlHTl9CQVoQBip1ChRUZXN0RW51bVdpdGhEdXBWYWx1", + "ZRIoCiRURVNUX0VOVU1fV0lUSF9EVVBfVkFMVUVfVU5TUEVDSUZJRUQQABII", + "CgRGT08xEAESCAoEQkFSMRACEgcKA0JBWhADEggKBEZPTzIQARIICgRCQVIy", + "EAIaAhABKp0BCg5UZXN0U3BhcnNlRW51bRIgChxURVNUX1NQQVJTRV9FTlVN", + "X1VOU1BFQ0lGSUVEEAASDAoIU1BBUlNFX0EQexIOCghTUEFSU0VfQhCm5wMS", + "DwoIU1BBUlNFX0MQsrGABhIVCghTUEFSU0VfRBDx//////////8BEhUKCFNQ", + "QVJTRV9FELTe/P///////wESDAoIU1BBUlNFX0cQAjKZAQoLVGVzdFNlcnZp", + "Y2USRAoDRm9vEh0ucHJvdG9idWZfdW5pdHRlc3QuRm9vUmVxdWVzdBoeLnBy", + "b3RvYnVmX3VuaXR0ZXN0LkZvb1Jlc3BvbnNlEkQKA0JhchIdLnByb3RvYnVm", + "X3VuaXR0ZXN0LkJhclJlcXVlc3QaHi5wcm90b2J1Zl91bml0dGVzdC5CYXJS", + "ZXNwb25zZUI6Qg1Vbml0dGVzdFByb3RvSAGAAQGIAQGQAQH4AQGqAhpHb29n", + "bGUuUHJvdG9idWYuVGVzdFByb3Rvc2IGcHJvdG8z")); pbd::FileDescriptor.InternalDescriptorAssigner assigner = delegate(pbd::FileDescriptor root) { descriptor = root; internal__static_protobuf_unittest_TestAllTypes__Descriptor = Descriptor.MessageTypes[0]; internal__static_protobuf_unittest_TestAllTypes__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestAllTypes__Descriptor, - new string[] { "SingleInt32", "SingleInt64", "SingleUint32", "SingleUint64", "SingleSint32", "SingleSint64", "SingleFixed32", "SingleFixed64", "SingleSfixed32", "SingleSfixed64", "SingleFloat", "SingleDouble", "SingleBool", "SingleString", "SingleBytes", "SingleNestedMessage", "SingleForeignMessage", "SingleImportMessage", "SingleNestedEnum", "SingleForeignEnum", "SingleImportEnum", "SinglePublicImportMessage", "RepeatedInt32", "RepeatedInt64", "RepeatedUint32", "RepeatedUint64", "RepeatedSint32", "RepeatedSint64", "RepeatedFixed32", "RepeatedFixed64", "RepeatedSfixed32", "RepeatedSfixed64", "RepeatedFloat", "RepeatedDouble", "RepeatedBool", "RepeatedString", "RepeatedBytes", "RepeatedNestedMessage", "RepeatedForeignMessage", "RepeatedImportMessage", "RepeatedNestedEnum", "RepeatedForeignEnum", "RepeatedImportEnum", "RepeatedPublicImportMessage", "OneofUint32", "OneofNestedMessage", "OneofString", "OneofBytes", "OneofField", }); + new string[] { "SingleInt32", "SingleInt64", "SingleUint32", "SingleUint64", "SingleSint32", "SingleSint64", "SingleFixed32", "SingleFixed64", "SingleSfixed32", "SingleSfixed64", "SingleFloat", "SingleDouble", "SingleBool", "SingleString", "SingleBytes", "SingleNestedMessage", "SingleForeignMessage", "SingleImportMessage", "SingleNestedEnum", "SingleForeignEnum", "SingleImportEnum", "SinglePublicImportMessage", "RepeatedInt32", "RepeatedInt64", "RepeatedUint32", "RepeatedUint64", "RepeatedSint32", "RepeatedSint64", "RepeatedFixed32", "RepeatedFixed64", "RepeatedSfixed32", "RepeatedSfixed64", "RepeatedFloat", "RepeatedDouble", "RepeatedBool", "RepeatedString", "RepeatedBytes", "RepeatedNestedMessage", "RepeatedForeignMessage", "RepeatedImportMessage", "RepeatedNestedEnum", "RepeatedForeignEnum", "RepeatedImportEnum", "RepeatedPublicImportMessage", "OneofUint32", "OneofNestedMessage", "OneofString", "OneofBytes", "MapStringToNestedMessage", "MapInt32ToBytes", "MapBoolToEnum", "OneofField", }); internal__static_protobuf_unittest_TestAllTypes_NestedMessage__Descriptor = internal__static_protobuf_unittest_TestAllTypes__Descriptor.NestedTypes[0]; internal__static_protobuf_unittest_TestAllTypes_NestedMessage__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestAllTypes_NestedMessage__Descriptor, new string[] { "Bb", }); + internal__static_protobuf_unittest_TestAllTypes_MapStringToNestedMessageEntry__Descriptor = internal__static_protobuf_unittest_TestAllTypes__Descriptor.NestedTypes[1]; + internal__static_protobuf_unittest_TestAllTypes_MapStringToNestedMessageEntry__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestAllTypes_MapStringToNestedMessageEntry__Descriptor, + new string[] { "Key", "Value", }); + internal__static_protobuf_unittest_TestAllTypes_MapInt32ToBytesEntry__Descriptor = internal__static_protobuf_unittest_TestAllTypes__Descriptor.NestedTypes[2]; + internal__static_protobuf_unittest_TestAllTypes_MapInt32ToBytesEntry__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestAllTypes_MapInt32ToBytesEntry__Descriptor, + new string[] { "Key", "Value", }); + internal__static_protobuf_unittest_TestAllTypes_MapBoolToEnumEntry__Descriptor = internal__static_protobuf_unittest_TestAllTypes__Descriptor.NestedTypes[3]; + internal__static_protobuf_unittest_TestAllTypes_MapBoolToEnumEntry__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestAllTypes_MapBoolToEnumEntry__Descriptor, + new string[] { "Key", "Value", }); internal__static_protobuf_unittest_NestedTestAllTypes__Descriptor = Descriptor.MessageTypes[1]; internal__static_protobuf_unittest_NestedTestAllTypes__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_NestedTestAllTypes__Descriptor, @@ -406,8 +436,8 @@ namespace Google.Protobuf.TestProtos { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestAllTypes()); public static pb::MessageParser Parser { get { return _parser; } } - private static readonly string[] _fieldNames = new string[] { "oneof_bytes", "oneof_nested_message", "oneof_string", "oneof_uint32", "repeated_bool", "repeated_bytes", "repeated_double", "repeated_fixed32", "repeated_fixed64", "repeated_float", "repeated_foreign_enum", "repeated_foreign_message", "repeated_import_enum", "repeated_import_message", "repeated_int32", "repeated_int64", "repeated_nested_enum", "repeated_nested_message", "repeated_public_import_message", "repeated_sfixed32", "repeated_sfixed64", "repeated_sint32", "repeated_sint64", "repeated_string", "repeated_uint32", "repeated_uint64", "single_bool", "single_bytes", "single_double", "single_fixed32", "single_fixed64", "single_float", "single_foreign_enum", "single_foreign_message", "single_import_enum", "single_import_message", "single_int32", "single_int64", "single_nested_enum", "single_nested_message", "single_public_import_message", "single_sfixed32", "single_sfixed64", "single_sint32", "single_sint64", "single_string", "single_uint32", "single_uint64" }; - private static readonly uint[] _fieldTags = new uint[] { 914, 898, 906, 888, 346, 362, 338, 298, 306, 330, 418, 394, 426, 402, 250, 258, 410, 386, 434, 314, 322, 282, 290, 354, 266, 274, 104, 122, 97, 61, 65, 93, 176, 154, 184, 162, 8, 16, 168, 146, 210, 77, 81, 40, 48, 114, 24, 32 }; + private static readonly string[] _fieldNames = new string[] { "map_bool_to_enum", "map_int32_to_bytes", "map_string_to_nested_message", "oneof_bytes", "oneof_nested_message", "oneof_string", "oneof_uint32", "repeated_bool", "repeated_bytes", "repeated_double", "repeated_fixed32", "repeated_fixed64", "repeated_float", "repeated_foreign_enum", "repeated_foreign_message", "repeated_import_enum", "repeated_import_message", "repeated_int32", "repeated_int64", "repeated_nested_enum", "repeated_nested_message", "repeated_public_import_message", "repeated_sfixed32", "repeated_sfixed64", "repeated_sint32", "repeated_sint64", "repeated_string", "repeated_uint32", "repeated_uint64", "single_bool", "single_bytes", "single_double", "single_fixed32", "single_fixed64", "single_float", "single_foreign_enum", "single_foreign_message", "single_import_enum", "single_import_message", "single_int32", "single_int64", "single_nested_enum", "single_nested_message", "single_public_import_message", "single_sfixed32", "single_sfixed64", "single_sint32", "single_sint64", "single_string", "single_uint32", "single_uint64" }; + private static readonly uint[] _fieldTags = new uint[] { 1618, 1610, 1602, 914, 898, 906, 888, 346, 362, 338, 298, 306, 330, 418, 394, 426, 402, 250, 258, 410, 386, 434, 314, 322, 282, 290, 354, 266, 274, 104, 122, 97, 61, 65, 93, 176, 154, 184, 162, 8, 16, 168, 146, 210, 77, 81, 40, 48, 114, 24, 32 }; public static pbd::MessageDescriptor Descriptor { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestAllTypes__Descriptor; } } @@ -466,6 +496,9 @@ namespace Google.Protobuf.TestProtos { repeatedForeignEnum_ = other.repeatedForeignEnum_.Clone(); repeatedImportEnum_ = other.repeatedImportEnum_.Clone(); repeatedPublicImportMessage_ = other.repeatedPublicImportMessage_.Clone(); + mapStringToNestedMessage_ = other.mapStringToNestedMessage_.Clone(); + mapInt32ToBytes_ = other.mapInt32ToBytes_.Clone(); + mapBoolToEnum_ = other.mapBoolToEnum_.Clone(); switch (other.OneofFieldCase) { case OneofFieldOneofCase.OneofUint32: OneofUint32 = other.OneofUint32; @@ -518,6 +551,9 @@ namespace Google.Protobuf.TestProtos { repeatedForeignEnum_.Freeze(); repeatedImportEnum_.Freeze(); repeatedPublicImportMessage_.Freeze(); + mapStringToNestedMessage_.Freeze(); + mapInt32ToBytes_.Freeze(); + mapBoolToEnum_.Freeze(); if (oneofField_ is IFreezable) ((IFreezable) oneofField_).Freeze(); } @@ -913,6 +949,30 @@ namespace Google.Protobuf.TestProtos { } } + public const int MapStringToNestedMessageFieldNumber = 200; + private static readonly pbc::MapField.Codec _map_mapStringToNestedMessage_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForString(10), pb::FieldCodec.ForMessage(18, global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage.Parser), 1602); + private readonly pbc::MapField mapStringToNestedMessage_ = new pbc::MapField(); + public pbc::MapField MapStringToNestedMessage { + get { return mapStringToNestedMessage_; } + } + + public const int MapInt32ToBytesFieldNumber = 201; + private static readonly pbc::MapField.Codec _map_mapInt32ToBytes_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForBytes(18), 1610); + private readonly pbc::MapField mapInt32ToBytes_ = new pbc::MapField(); + public pbc::MapField MapInt32ToBytes { + get { return mapInt32ToBytes_; } + } + + public const int MapBoolToEnumFieldNumber = 202; + private static readonly pbc::MapField.Codec _map_mapBoolToEnum_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForBool(8), pb::FieldCodec.ForEnum(16, x => (int) x, x => (global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum) x), 1618); + private readonly pbc::MapField mapBoolToEnum_ = new pbc::MapField(); + public pbc::MapField MapBoolToEnum { + get { return mapBoolToEnum_; } + } + private object oneofField_; public enum OneofFieldOneofCase { None = 0, @@ -991,6 +1051,9 @@ namespace Google.Protobuf.TestProtos { if (!object.Equals(OneofNestedMessage, other.OneofNestedMessage)) return false; if (OneofString != other.OneofString) return false; if (OneofBytes != other.OneofBytes) return false; + if (!MapStringToNestedMessage.Equals(other.MapStringToNestedMessage)) return false; + if (!MapInt32ToBytes.Equals(other.MapInt32ToBytes)) return false; + if (!MapBoolToEnum.Equals(other.MapBoolToEnum)) return false; return true; } @@ -1044,6 +1107,9 @@ namespace Google.Protobuf.TestProtos { if (oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage) hash ^= OneofNestedMessage.GetHashCode(); if (oneofFieldCase_ == OneofFieldOneofCase.OneofString) hash ^= OneofString.GetHashCode(); if (oneofFieldCase_ == OneofFieldOneofCase.OneofBytes) hash ^= OneofBytes.GetHashCode(); + hash ^= MapStringToNestedMessage.GetHashCode(); + hash ^= MapInt32ToBytes.GetHashCode(); + hash ^= MapBoolToEnum.GetHashCode(); return hash; } @@ -1234,6 +1300,9 @@ namespace Google.Protobuf.TestProtos { output.WriteRawTag(146, 7); output.WriteBytes(OneofBytes); } + mapStringToNestedMessage_.WriteTo(output, _map_mapStringToNestedMessage_codec); + mapInt32ToBytes_.WriteTo(output, _map_mapInt32ToBytes_codec); + mapBoolToEnum_.WriteTo(output, _map_mapBoolToEnum_codec); } public int CalculateSize() { @@ -1470,6 +1539,9 @@ namespace Google.Protobuf.TestProtos { if (oneofFieldCase_ == OneofFieldOneofCase.OneofBytes) { size += 2 + pb::CodedOutputStream.ComputeBytesSize(OneofBytes); } + size += mapStringToNestedMessage_.CalculateSize(_map_mapStringToNestedMessage_codec); + size += mapInt32ToBytes_.CalculateSize(_map_mapInt32ToBytes_codec); + size += mapBoolToEnum_.CalculateSize(_map_mapBoolToEnum_codec); return size; } public void MergeFrom(TestAllTypes other) { @@ -1576,6 +1648,9 @@ namespace Google.Protobuf.TestProtos { repeatedForeignEnum_.Add(other.repeatedForeignEnum_); repeatedImportEnum_.Add(other.repeatedImportEnum_); repeatedPublicImportMessage_.Add(other.repeatedPublicImportMessage_); + mapStringToNestedMessage_.Add(other.mapStringToNestedMessage_); + mapInt32ToBytes_.Add(other.mapInt32ToBytes_); + mapBoolToEnum_.Add(other.mapBoolToEnum_); switch (other.OneofFieldCase) { case OneofFieldOneofCase.OneofUint32: OneofUint32 = other.OneofUint32; @@ -1829,6 +1904,18 @@ namespace Google.Protobuf.TestProtos { OneofBytes = input.ReadBytes(); break; } + case 1602: { + mapStringToNestedMessage_.AddEntriesFrom(input, _map_mapStringToNestedMessage_codec); + break; + } + case 1610: { + mapInt32ToBytes_.AddEntriesFrom(input, _map_mapInt32ToBytes_codec); + break; + } + case 1618: { + mapBoolToEnum_.AddEntriesFrom(input, _map_mapBoolToEnum_codec); + break; + } } } } @@ -1954,6 +2041,424 @@ namespace Google.Protobuf.TestProtos { } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class MapStringToNestedMessageEntry : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MapStringToNestedMessageEntry()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "key", "value" }; + private static readonly uint[] _fieldTags = new uint[] { 10, 18 }; + public static pbd::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestAllTypes_MapStringToNestedMessageEntry__Descriptor; } + } + + public pb::FieldAccess.FieldAccessorTable Fields { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestAllTypes_MapStringToNestedMessageEntry__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public MapStringToNestedMessageEntry() { } + + public MapStringToNestedMessageEntry(MapStringToNestedMessageEntry other) { + key_ = other.key_; + Value = other.value_ != null ? other.Value.Clone() : null; + } + + public MapStringToNestedMessageEntry Clone() { + return new MapStringToNestedMessageEntry(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + if (value_ != null) Value.Freeze(); + } + + public const int KeyFieldNumber = 1; + private string key_ = ""; + public string Key { + get { return key_; } + set { + pb::Freezable.CheckMutable(this); + key_ = value ?? ""; + } + } + + public const int ValueFieldNumber = 2; + private global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage value_; + public global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage Value { + get { return value_; } + set { + pb::Freezable.CheckMutable(this); + value_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as MapStringToNestedMessageEntry); + } + + public bool Equals(MapStringToNestedMessageEntry other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Key != other.Key) return false; + if (!object.Equals(Value, other.Value)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 0; + if (Key.Length != 0) hash ^= Key.GetHashCode(); + if (value_ != null) hash ^= Value.GetHashCode(); + return hash; + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Key.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Key); + } + if (value_ != null) { + output.WriteRawTag(18); + output.WriteMessage(Value); + } + } + + public int CalculateSize() { + int size = 0; + if (Key.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Key); + } + if (value_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Value); + } + return size; + } + public void MergeFrom(MapStringToNestedMessageEntry other) { + if (other == null) { + return; + } + if (other.Key.Length != 0) { + Key = other.Key; + } + if (other.value_ != null) { + if (value_ == null) { + value_ = new global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage(); + } + Value.MergeFrom(other.Value); + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + Key = input.ReadString(); + break; + } + case 18: { + if (value_ == null) { + value_ = new global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage(); + } + input.ReadMessage(value_); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class MapInt32ToBytesEntry : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MapInt32ToBytesEntry()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "key", "value" }; + private static readonly uint[] _fieldTags = new uint[] { 8, 18 }; + public static pbd::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestAllTypes_MapInt32ToBytesEntry__Descriptor; } + } + + public pb::FieldAccess.FieldAccessorTable Fields { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestAllTypes_MapInt32ToBytesEntry__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public MapInt32ToBytesEntry() { } + + public MapInt32ToBytesEntry(MapInt32ToBytesEntry other) { + key_ = other.key_; + value_ = other.value_; + } + + public MapInt32ToBytesEntry Clone() { + return new MapInt32ToBytesEntry(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public const int KeyFieldNumber = 1; + private int key_; + public int Key { + get { return key_; } + set { + pb::Freezable.CheckMutable(this); + key_ = value; + } + } + + public const int ValueFieldNumber = 2; + private pb::ByteString value_ = pb::ByteString.Empty; + public pb::ByteString Value { + get { return value_; } + set { + pb::Freezable.CheckMutable(this); + value_ = value ?? pb::ByteString.Empty; + } + } + + public override bool Equals(object other) { + return Equals(other as MapInt32ToBytesEntry); + } + + public bool Equals(MapInt32ToBytesEntry other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Key != other.Key) return false; + if (Value != other.Value) return false; + return true; + } + + public override int GetHashCode() { + int hash = 0; + if (Key != 0) hash ^= Key.GetHashCode(); + if (Value.Length != 0) hash ^= Value.GetHashCode(); + return hash; + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Key != 0) { + output.WriteRawTag(8); + output.WriteInt32(Key); + } + if (Value.Length != 0) { + output.WriteRawTag(18); + output.WriteBytes(Value); + } + } + + public int CalculateSize() { + int size = 0; + if (Key != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Key); + } + if (Value.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeBytesSize(Value); + } + return size; + } + public void MergeFrom(MapInt32ToBytesEntry other) { + if (other == null) { + return; + } + if (other.Key != 0) { + Key = other.Key; + } + if (other.Value.Length != 0) { + Value = other.Value; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 8: { + Key = input.ReadInt32(); + break; + } + case 18: { + Value = input.ReadBytes(); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class MapBoolToEnumEntry : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MapBoolToEnumEntry()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "key", "value" }; + private static readonly uint[] _fieldTags = new uint[] { 8, 16 }; + public static pbd::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestAllTypes_MapBoolToEnumEntry__Descriptor; } + } + + public pb::FieldAccess.FieldAccessorTable Fields { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestAllTypes_MapBoolToEnumEntry__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public MapBoolToEnumEntry() { } + + public MapBoolToEnumEntry(MapBoolToEnumEntry other) { + key_ = other.key_; + value_ = other.value_; + } + + public MapBoolToEnumEntry Clone() { + return new MapBoolToEnumEntry(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public const int KeyFieldNumber = 1; + private bool key_; + public bool Key { + get { return key_; } + set { + pb::Freezable.CheckMutable(this); + key_ = value; + } + } + + public const int ValueFieldNumber = 2; + private global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum value_ = global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum.NESTED_ENUM_UNSPECIFIED; + public global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum Value { + get { return value_; } + set { + pb::Freezable.CheckMutable(this); + value_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as MapBoolToEnumEntry); + } + + public bool Equals(MapBoolToEnumEntry other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Key != other.Key) return false; + if (Value != other.Value) return false; + return true; + } + + public override int GetHashCode() { + int hash = 0; + if (Key != false) hash ^= Key.GetHashCode(); + if (Value != global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum.NESTED_ENUM_UNSPECIFIED) hash ^= Value.GetHashCode(); + return hash; + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Key != false) { + output.WriteRawTag(8); + output.WriteBool(Key); + } + if (Value != global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum.NESTED_ENUM_UNSPECIFIED) { + output.WriteRawTag(16); + output.WriteEnum((int) Value); + } + } + + public int CalculateSize() { + int size = 0; + if (Key != false) { + size += 1 + 1; + } + if (Value != global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum.NESTED_ENUM_UNSPECIFIED) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Value); + } + return size; + } + public void MergeFrom(MapBoolToEnumEntry other) { + if (other == null) { + return; + } + if (other.Key != false) { + Key = other.Key; + } + if (other.Value != global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum.NESTED_ENUM_UNSPECIFIED) { + Value = other.Value; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 8: { + Key = input.ReadBool(); + break; + } + case 16: { + value_ = (global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum) input.ReadEnum(); + break; + } + } + } + } + + } + } #endregion -- cgit v1.2.3 From df44ae4413109a7c3ce9f27fb7ae02f0414c29d9 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Thu, 25 Jun 2015 12:08:18 +0100 Subject: More map tests, and various production code improvements. Generated code in next commit. --- .../Collections/MapFieldTest.cs | 354 +++++++++++++++++++++ .../Collections/RepeatedFieldTest.cs | 93 ++++++ csharp/src/ProtocolBuffers.Test/EqualityTester.cs | 63 ++++ .../ProtocolBuffers.Test/GeneratedMessageTest.cs | 9 + .../ProtocolBuffers.Test.csproj | 8 +- .../src/ProtocolBuffers.Test/RepeatedFieldTest.cs | 94 ------ csharp/src/ProtocolBuffers/CodedInputStream.cs | 28 +- csharp/src/ProtocolBuffers/Collections/MapField.cs | 64 +++- .../protobuf/compiler/csharp/csharp_message.cc | 3 +- 9 files changed, 584 insertions(+), 132 deletions(-) create mode 100644 csharp/src/ProtocolBuffers.Test/Collections/MapFieldTest.cs create mode 100644 csharp/src/ProtocolBuffers.Test/Collections/RepeatedFieldTest.cs create mode 100644 csharp/src/ProtocolBuffers.Test/EqualityTester.cs delete mode 100644 csharp/src/ProtocolBuffers.Test/RepeatedFieldTest.cs diff --git a/csharp/src/ProtocolBuffers.Test/Collections/MapFieldTest.cs b/csharp/src/ProtocolBuffers.Test/Collections/MapFieldTest.cs new file mode 100644 index 00000000..498e4718 --- /dev/null +++ b/csharp/src/ProtocolBuffers.Test/Collections/MapFieldTest.cs @@ -0,0 +1,354 @@ +#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 System; +using System.Collections.Generic; +using Google.Protobuf.TestProtos; +using NUnit.Framework; + +namespace Google.Protobuf.Collections +{ + /// + /// Tests for MapField which aren't reliant on the encoded format - + /// tests for serialization/deserialization are part of GeneratedMessageTest. + /// + public class MapFieldTest + { + // Protobuf-specific tests + [Test] + public void Freeze_FreezesMessages() + { + var message = new ForeignMessage { C = 20 }; + var map = new MapField { { "x", message } }; + map.Freeze(); + Assert.IsTrue(message.IsFrozen); + } + + [Test] + public void Freeze_PreventsMutation() + { + var map = new MapField(); + map.Freeze(); + Assert.IsTrue(map.IsFrozen); + Assert.IsTrue(map.IsReadOnly); + ICollection> collection = map; + Assert.Throws(() => map["x"] = "y"); + Assert.Throws(() => map.Add("x", "y")); + Assert.Throws(() => map.Remove("x")); + Assert.Throws(() => map.Clear()); + Assert.Throws(() => collection.Add(NewKeyValuePair("x", "y"))); + Assert.Throws(() => collection.Remove(NewKeyValuePair("x", "y"))); + } + + [Test] + public void Clone_ReturnsNonFrozen() + { + var map = new MapField(); + map.Freeze(); + var clone = map.Clone(); + clone.Add("x", "y"); + } + + [Test] + public void Clone_ClonesMessages() + { + var message = new ForeignMessage { C = 20 }; + var map = new MapField { { "x", message } }; + var clone = map.Clone(); + map["x"].C = 30; + Assert.AreEqual(20, clone["x"].C); + } + + [Test] + public void Add_ForbidsNullKeys() + { + var map = new MapField(); + Assert.Throws(() => map.Add(null, new ForeignMessage())); + } + + [Test] + public void Add_AcceptsNullMessageValues() + { + var map = new MapField(); + map.Add("missing", null); + Assert.IsNull(map["missing"]); + } + + [Test] + public void Add_ForbidsNullStringValues() + { + var map = new MapField(); + Assert.Throws(() => map.Add("missing", null)); + } + + [Test] + public void Add_ForbidsNullByteStringValues() + { + var map = new MapField(); + Assert.Throws(() => map.Add("missing", null)); + } + + [Test] + public void Indexer_ForbidsNullKeys() + { + var map = new MapField(); + Assert.Throws(() => map[null] = new ForeignMessage()); + } + + [Test] + public void Indexer_AcceptsNullMessageValues() + { + var map = new MapField(); + map["missing"] = null; + Assert.IsNull(map["missing"]); + } + + [Test] + public void Indexer_ForbidsNullStringValues() + { + var map = new MapField(); + Assert.Throws(() => map["missing"] = null); + } + + [Test] + public void Indexer_ForbidsNullByteStringValues() + { + var map = new MapField(); + Assert.Throws(() => map["missing"] = null); + } + + [Test] + public void AddPreservesInsertionOrder() + { + var map = new MapField(); + map.Add("a", "v1"); + map.Add("b", "v2"); + map.Add("c", "v3"); + map.Remove("b"); + map.Add("d", "v4"); + CollectionAssert.AreEqual(new[] { "a", "c", "d" }, map.Keys); + CollectionAssert.AreEqual(new[] { "v1", "v3", "v4" }, map.Values); + } + + [Test] + public void EqualityIsOrderInsensitive() + { + var map1 = new MapField(); + map1.Add("a", "v1"); + map1.Add("b", "v2"); + + var map2 = new MapField(); + map2.Add("b", "v2"); + map2.Add("a", "v1"); + + EqualityTester.AssertEquality(map1, map2); + } + + [Test] + public void EqualityIsKeySensitive() + { + var map1 = new MapField(); + map1.Add("a1", "v1"); + map1.Add("b1", "v2"); + + var map2 = new MapField(); + map2.Add("a2", "v1"); + map2.Add("b2", "v2"); + + EqualityTester.AssertInequality(map1, map2); + } + + [Test] + public void EqualityIsValueSensitive() + { + // Note: Without some care, it's a little easier than one might + // hope to see hash collisions, but only in some environments... + var map1 = new MapField(); + map1.Add("a", "a1"); + map1.Add("b", "a2"); + + var map2 = new MapField(); + map2.Add("a", "b1"); + map2.Add("b", "b2"); + + EqualityTester.AssertInequality(map1, map2); + } + + [Test] + public void EqualityHandlesNullValues() + { + var map1 = new MapField(); + map1.Add("a", new ForeignMessage { C = 10 }); + map1.Add("b", null); + + var map2 = new MapField(); + map2.Add("a", new ForeignMessage { C = 10 }); + map2.Add("b", null); + + EqualityTester.AssertEquality(map1, map2); + // Check the null value isn't ignored entirely... + Assert.IsTrue(map1.Remove("b")); + EqualityTester.AssertInequality(map1, map2); + map1.Add("b", new ForeignMessage()); + EqualityTester.AssertInequality(map1, map2); + map1["b"] = null; + EqualityTester.AssertEquality(map1, map2); + } + + [Test] + public void Add_Dictionary() + { + var map1 = new MapField + { + { "x", "y" }, + { "a", "b" } + }; + var map2 = new MapField + { + { "before", "" }, + map1, + { "after", "" } + }; + var expected = new MapField + { + { "before", "" }, + { "x", "y" }, + { "a", "b" }, + { "after", "" } + }; + Assert.AreEqual(expected, map2); + CollectionAssert.AreEqual(new[] { "before", "x", "a", "after" }, map2.Keys); + } + + // General IDictionary behavior tests + [Test] + public void Add_KeyAlreadyExists() + { + var map = new MapField(); + map.Add("foo", "bar"); + Assert.Throws(() => map.Add("foo", "baz")); + } + + [Test] + public void Add_Pair() + { + var map = new MapField(); + ICollection> collection = map; + collection.Add(NewKeyValuePair("x", "y")); + Assert.AreEqual("y", map["x"]); + Assert.Throws(() => collection.Add(NewKeyValuePair("x", "z"))); + } + + [Test] + public void Contains_Pair() + { + var map = new MapField { { "x", "y" } }; + ICollection> collection = map; + Assert.IsTrue(collection.Contains(NewKeyValuePair("x", "y"))); + Assert.IsFalse(collection.Contains(NewKeyValuePair("x", "z"))); + Assert.IsFalse(collection.Contains(NewKeyValuePair("z", "y"))); + } + + [Test] + public void Remove_Key() + { + var map = new MapField(); + map.Add("foo", "bar"); + Assert.AreEqual(1, map.Count); + Assert.IsFalse(map.Remove("missing")); + Assert.AreEqual(1, map.Count); + Assert.IsTrue(map.Remove("foo")); + Assert.AreEqual(0, map.Count); + } + + [Test] + public void Remove_Pair() + { + var map = new MapField(); + map.Add("foo", "bar"); + ICollection> collection = map; + Assert.AreEqual(1, map.Count); + Assert.IsFalse(collection.Remove(NewKeyValuePair("wrong key", "bar"))); + Assert.AreEqual(1, map.Count); + Assert.IsFalse(collection.Remove(NewKeyValuePair("foo", "wrong value"))); + Assert.AreEqual(1, map.Count); + Assert.IsTrue(collection.Remove(NewKeyValuePair("foo", "bar"))); + Assert.AreEqual(0, map.Count); + Assert.Throws(() => collection.Remove(new KeyValuePair(null, ""))); + } + + [Test] + public void CopyTo_Pair() + { + var map = new MapField(); + map.Add("foo", "bar"); + ICollection> collection = map; + KeyValuePair[] array = new KeyValuePair[3]; + collection.CopyTo(array, 1); + Assert.AreEqual(NewKeyValuePair("foo", "bar"), array[1]); + } + + [Test] + public void Clear() + { + var map = new MapField { { "x", "y" } }; + Assert.AreEqual(1, map.Count); + map.Clear(); + Assert.AreEqual(0, map.Count); + map.Add("x", "y"); + Assert.AreEqual(1, map.Count); + } + + [Test] + public void Indexer_Get() + { + var map = new MapField { { "x", "y" } }; + Assert.AreEqual("y", map["x"]); + Assert.Throws(() => { var ignored = map["z"]; }); + } + + [Test] + public void Indexer_Set() + { + var map = new MapField(); + map["x"] = "y"; + Assert.AreEqual("y", map["x"]); + map["x"] = "z"; // This won't throw, unlike Add. + Assert.AreEqual("z", map["x"]); + } + + private static KeyValuePair NewKeyValuePair(TKey key, TValue value) + { + return new KeyValuePair(key, value); + } + } +} diff --git a/csharp/src/ProtocolBuffers.Test/Collections/RepeatedFieldTest.cs b/csharp/src/ProtocolBuffers.Test/Collections/RepeatedFieldTest.cs new file mode 100644 index 00000000..29945c36 --- /dev/null +++ b/csharp/src/ProtocolBuffers.Test/Collections/RepeatedFieldTest.cs @@ -0,0 +1,93 @@ +using System; +using System.Collections.Generic; +using Google.Protobuf.TestProtos; +using NUnit.Framework; + +namespace Google.Protobuf.Collections +{ + public class RepeatedFieldTest + { + [Test] + public void NullValuesRejected() + { + var list = new RepeatedField(); + Assert.Throws(() => list.Add((string)null)); + Assert.Throws(() => list.Add((IEnumerable)null)); + Assert.Throws(() => list.Add((RepeatedField)null)); + Assert.Throws(() => list.Contains(null)); + Assert.Throws(() => list.IndexOf(null)); + } + + [Test] + public void Add_SingleItem() + { + var list = new RepeatedField(); + list.Add("foo"); + Assert.AreEqual(1, list.Count); + Assert.AreEqual("foo", list[0]); + } + + [Test] + public void Add_Sequence() + { + var list = new RepeatedField(); + list.Add(new[] { "foo", "bar" }); + Assert.AreEqual(2, list.Count); + Assert.AreEqual("foo", list[0]); + Assert.AreEqual("bar", list[1]); + } + + [Test] + public void Add_RepeatedField() + { + var list = new RepeatedField { "original" }; + list.Add(new RepeatedField { "foo", "bar" }); + Assert.AreEqual(3, list.Count); + Assert.AreEqual("original", list[0]); + Assert.AreEqual("foo", list[1]); + Assert.AreEqual("bar", list[2]); + } + + [Test] + public void Freeze_FreezesElements() + { + var list = new RepeatedField { new TestAllTypes() }; + Assert.IsFalse(list[0].IsFrozen); + list.Freeze(); + Assert.IsTrue(list[0].IsFrozen); + } + + [Test] + public void Freeze_PreventsMutations() + { + var list = new RepeatedField { 0 }; + list.Freeze(); + Assert.Throws(() => list.Add(1)); + Assert.Throws(() => list[0] = 1); + Assert.Throws(() => list.Clear()); + Assert.Throws(() => list.RemoveAt(0)); + Assert.Throws(() => list.Remove(0)); + Assert.Throws(() => list.Insert(0, 0)); + } + + [Test] + public void Freeze_ReportsFrozen() + { + var list = new RepeatedField { 0 }; + Assert.IsFalse(list.IsFrozen); + Assert.IsFalse(list.IsReadOnly); + list.Freeze(); + Assert.IsTrue(list.IsFrozen); + Assert.IsTrue(list.IsReadOnly); + } + + [Test] + public void Clone_ReturnsMutable() + { + var list = new RepeatedField { 0 }; + list.Freeze(); + var clone = list.Clone(); + clone[0] = 1; + } + } +} diff --git a/csharp/src/ProtocolBuffers.Test/EqualityTester.cs b/csharp/src/ProtocolBuffers.Test/EqualityTester.cs new file mode 100644 index 00000000..816f2be1 --- /dev/null +++ b/csharp/src/ProtocolBuffers.Test/EqualityTester.cs @@ -0,0 +1,63 @@ +#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 System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using NUnit.Framework; + +namespace Google.Protobuf +{ + /// + /// Helper methods when testing equality. NUnit's Assert.AreEqual and + /// Assert.AreNotEqual methods try to be clever with collections, which can + /// be annoying... + /// + internal static class EqualityTester + { + public static void AssertEquality(T first, T second) where T : IEquatable + { + Assert.IsTrue(first.Equals(second)); + Assert.AreEqual(first.GetHashCode(), second.GetHashCode()); + } + + public static void AssertInequality(T first, T second) where T : IEquatable + { + Assert.IsFalse(first.Equals(second)); + // While this isn't a requirement, the chances of this test failing due to + // coincidence rather than a bug are very small. + Assert.AreNotEqual(first.GetHashCode(), second.GetHashCode()); + } + } +} diff --git a/csharp/src/ProtocolBuffers.Test/GeneratedMessageTest.cs b/csharp/src/ProtocolBuffers.Test/GeneratedMessageTest.cs index 81e35940..efeb7a97 100644 --- a/csharp/src/ProtocolBuffers.Test/GeneratedMessageTest.cs +++ b/csharp/src/ProtocolBuffers.Test/GeneratedMessageTest.cs @@ -11,6 +11,15 @@ namespace Google.Protobuf /// public class GeneratedMessageTest { + [Test] + public void EmptyMessageFieldDistinctFromMissingMessageField() + { + // This demonstrates what we're really interested in... + var message1 = new TestAllTypes { SingleForeignMessage = new ForeignMessage() }; + var message2 = new TestAllTypes(); // SingleForeignMessage is null + EqualityTester.AssertInequality(message1, message2); + } + [Test] public void DefaultValues() { diff --git a/csharp/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj b/csharp/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj index 31095a5b..d11e2596 100644 --- a/csharp/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj +++ b/csharp/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj @@ -74,8 +74,10 @@ + - + + @@ -99,9 +101,7 @@ - - - + - \ No newline at end of file diff --git a/csharp/src/ProtoBench/Unittest.cs b/csharp/src/ProtoBench/Unittest.cs deleted file mode 100644 index d39c9345..00000000 --- a/csharp/src/ProtoBench/Unittest.cs +++ /dev/null @@ -1,33516 +0,0 @@ -// Manual changes: -// - Search and replace of RepeatedFieldsGenerator.Group to RepeatedFieldsGenerator.Types.Group -// -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/protobuf/unittest.proto -#pragma warning disable 1591, 0612, 3021 -#region Designer generated code - -using pb = global::Google.ProtocolBuffers; -using pbc = global::Google.ProtocolBuffers.Collections; -using pbd = global::Google.ProtocolBuffers.Descriptors; -using scg = global::System.Collections.Generic; -namespace Google.ProtocolBuffers.TestProtos { - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class Unittest { - - #region Extension registration - public static void RegisterAllExtensions(pb::ExtensionRegistry registry) { - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalInt32Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalInt64Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalUint32Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalUint64Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalSint32Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalSint64Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalFixed32Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalFixed64Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalSfixed32Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalSfixed64Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalFloatExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalDoubleExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalBoolExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalStringExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalBytesExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalGroupExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalNestedMessageExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalForeignMessageExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalImportMessageExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalNestedEnumExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalForeignEnumExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalImportEnumExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalStringPieceExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalCordExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalPublicImportMessageExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalLazyMessageExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedInt32Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedInt64Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedUint32Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedUint64Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedSint32Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedSint64Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedFixed32Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedFixed64Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedSfixed32Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedSfixed64Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedFloatExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedDoubleExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedBoolExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedStringExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedBytesExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedGroupExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedNestedMessageExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedForeignMessageExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedImportMessageExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedNestedEnumExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedForeignEnumExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedImportEnumExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedStringPieceExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedCordExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedLazyMessageExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultInt32Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultInt64Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultUint32Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultUint64Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultSint32Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultSint64Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultFixed32Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultFixed64Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultSfixed32Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultSfixed64Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultFloatExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultDoubleExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultBoolExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultStringExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultBytesExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultNestedEnumExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultForeignEnumExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultImportEnumExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultStringPieceExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultCordExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OneofUint32Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OneofNestedMessageExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OneofStringExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.OneofBytesExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.MyExtensionString); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.MyExtensionInt); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.PackedInt32Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.PackedInt64Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.PackedUint32Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.PackedUint64Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.PackedSint32Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.PackedSint64Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.PackedFixed32Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.PackedFixed64Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.PackedSfixed32Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.PackedSfixed64Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.PackedFloatExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.PackedDoubleExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.PackedBoolExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.PackedEnumExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedInt32Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedInt64Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedUint32Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedUint64Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedSint32Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedSint64Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedFixed32Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedFixed64Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedSfixed32Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedSfixed64Extension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedFloatExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedDoubleExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedBoolExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedEnumExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.TestNestedExtension.Test); - registry.Add(global::Google.ProtocolBuffers.TestProtos.TestNestedExtension.NestedStringExtension); - registry.Add(global::Google.ProtocolBuffers.TestProtos.TestRequired.Single); - registry.Add(global::Google.ProtocolBuffers.TestProtos.TestRequired.Multi); - registry.Add(global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.OptionalExt); - registry.Add(global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.RepeatedExt); - } - #endregion - #region Extensions - public const int OptionalInt32ExtensionFieldNumber = 1; - public static pb::GeneratedExtensionBase OptionalInt32Extension; - public const int OptionalInt64ExtensionFieldNumber = 2; - public static pb::GeneratedExtensionBase OptionalInt64Extension; - public const int OptionalUint32ExtensionFieldNumber = 3; - [global::System.CLSCompliant(false)] - public static pb::GeneratedExtensionBase OptionalUint32Extension; - public const int OptionalUint64ExtensionFieldNumber = 4; - [global::System.CLSCompliant(false)] - public static pb::GeneratedExtensionBase OptionalUint64Extension; - public const int OptionalSint32ExtensionFieldNumber = 5; - public static pb::GeneratedExtensionBase OptionalSint32Extension; - public const int OptionalSint64ExtensionFieldNumber = 6; - public static pb::GeneratedExtensionBase OptionalSint64Extension; - public const int OptionalFixed32ExtensionFieldNumber = 7; - [global::System.CLSCompliant(false)] - public static pb::GeneratedExtensionBase OptionalFixed32Extension; - public const int OptionalFixed64ExtensionFieldNumber = 8; - [global::System.CLSCompliant(false)] - public static pb::GeneratedExtensionBase OptionalFixed64Extension; - public const int OptionalSfixed32ExtensionFieldNumber = 9; - public static pb::GeneratedExtensionBase OptionalSfixed32Extension; - public const int OptionalSfixed64ExtensionFieldNumber = 10; - public static pb::GeneratedExtensionBase OptionalSfixed64Extension; - public const int OptionalFloatExtensionFieldNumber = 11; - public static pb::GeneratedExtensionBase OptionalFloatExtension; - public const int OptionalDoubleExtensionFieldNumber = 12; - public static pb::GeneratedExtensionBase OptionalDoubleExtension; - public const int OptionalBoolExtensionFieldNumber = 13; - public static pb::GeneratedExtensionBase OptionalBoolExtension; - public const int OptionalStringExtensionFieldNumber = 14; - public static pb::GeneratedExtensionBase OptionalStringExtension; - public const int OptionalBytesExtensionFieldNumber = 15; - public static pb::GeneratedExtensionBase OptionalBytesExtension; - public const int OptionalGroupExtensionFieldNumber = 16; - public static pb::GeneratedExtensionBase OptionalGroupExtension; - public const int OptionalNestedMessageExtensionFieldNumber = 18; - public static pb::GeneratedExtensionBase OptionalNestedMessageExtension; - public const int OptionalForeignMessageExtensionFieldNumber = 19; - public static pb::GeneratedExtensionBase OptionalForeignMessageExtension; - public const int OptionalImportMessageExtensionFieldNumber = 20; - public static pb::GeneratedExtensionBase OptionalImportMessageExtension; - public const int OptionalNestedEnumExtensionFieldNumber = 21; - public static pb::GeneratedExtensionBase OptionalNestedEnumExtension; - public const int OptionalForeignEnumExtensionFieldNumber = 22; - public static pb::GeneratedExtensionBase OptionalForeignEnumExtension; - public const int OptionalImportEnumExtensionFieldNumber = 23; - public static pb::GeneratedExtensionBase OptionalImportEnumExtension; - public const int OptionalStringPieceExtensionFieldNumber = 24; - public static pb::GeneratedExtensionBase OptionalStringPieceExtension; - public const int OptionalCordExtensionFieldNumber = 25; - public static pb::GeneratedExtensionBase OptionalCordExtension; - public const int OptionalPublicImportMessageExtensionFieldNumber = 26; - public static pb::GeneratedExtensionBase OptionalPublicImportMessageExtension; - public const int OptionalLazyMessageExtensionFieldNumber = 27; - public static pb::GeneratedExtensionBase OptionalLazyMessageExtension; - public const int RepeatedInt32ExtensionFieldNumber = 31; - public static pb::GeneratedExtensionBase> RepeatedInt32Extension; - public const int RepeatedInt64ExtensionFieldNumber = 32; - public static pb::GeneratedExtensionBase> RepeatedInt64Extension; - public const int RepeatedUint32ExtensionFieldNumber = 33; - [global::System.CLSCompliant(false)] - public static pb::GeneratedExtensionBase> RepeatedUint32Extension; - public const int RepeatedUint64ExtensionFieldNumber = 34; - [global::System.CLSCompliant(false)] - public static pb::GeneratedExtensionBase> RepeatedUint64Extension; - public const int RepeatedSint32ExtensionFieldNumber = 35; - public static pb::GeneratedExtensionBase> RepeatedSint32Extension; - public const int RepeatedSint64ExtensionFieldNumber = 36; - public static pb::GeneratedExtensionBase> RepeatedSint64Extension; - public const int RepeatedFixed32ExtensionFieldNumber = 37; - [global::System.CLSCompliant(false)] - public static pb::GeneratedExtensionBase> RepeatedFixed32Extension; - public const int RepeatedFixed64ExtensionFieldNumber = 38; - [global::System.CLSCompliant(false)] - public static pb::GeneratedExtensionBase> RepeatedFixed64Extension; - public const int RepeatedSfixed32ExtensionFieldNumber = 39; - public static pb::GeneratedExtensionBase> RepeatedSfixed32Extension; - public const int RepeatedSfixed64ExtensionFieldNumber = 40; - public static pb::GeneratedExtensionBase> RepeatedSfixed64Extension; - public const int RepeatedFloatExtensionFieldNumber = 41; - public static pb::GeneratedExtensionBase> RepeatedFloatExtension; - public const int RepeatedDoubleExtensionFieldNumber = 42; - public static pb::GeneratedExtensionBase> RepeatedDoubleExtension; - public const int RepeatedBoolExtensionFieldNumber = 43; - public static pb::GeneratedExtensionBase> RepeatedBoolExtension; - public const int RepeatedStringExtensionFieldNumber = 44; - public static pb::GeneratedExtensionBase> RepeatedStringExtension; - public const int RepeatedBytesExtensionFieldNumber = 45; - public static pb::GeneratedExtensionBase> RepeatedBytesExtension; - public const int RepeatedGroupExtensionFieldNumber = 46; - public static pb::GeneratedExtensionBase> RepeatedGroupExtension; - public const int RepeatedNestedMessageExtensionFieldNumber = 48; - public static pb::GeneratedExtensionBase> RepeatedNestedMessageExtension; - public const int RepeatedForeignMessageExtensionFieldNumber = 49; - public static pb::GeneratedExtensionBase> RepeatedForeignMessageExtension; - public const int RepeatedImportMessageExtensionFieldNumber = 50; - public static pb::GeneratedExtensionBase> RepeatedImportMessageExtension; - public const int RepeatedNestedEnumExtensionFieldNumber = 51; - public static pb::GeneratedExtensionBase> RepeatedNestedEnumExtension; - public const int RepeatedForeignEnumExtensionFieldNumber = 52; - public static pb::GeneratedExtensionBase> RepeatedForeignEnumExtension; - public const int RepeatedImportEnumExtensionFieldNumber = 53; - public static pb::GeneratedExtensionBase> RepeatedImportEnumExtension; - public const int RepeatedStringPieceExtensionFieldNumber = 54; - public static pb::GeneratedExtensionBase> RepeatedStringPieceExtension; - public const int RepeatedCordExtensionFieldNumber = 55; - public static pb::GeneratedExtensionBase> RepeatedCordExtension; - public const int RepeatedLazyMessageExtensionFieldNumber = 57; - public static pb::GeneratedExtensionBase> RepeatedLazyMessageExtension; - public const int DefaultInt32ExtensionFieldNumber = 61; - public static pb::GeneratedExtensionBase DefaultInt32Extension; - public const int DefaultInt64ExtensionFieldNumber = 62; - public static pb::GeneratedExtensionBase DefaultInt64Extension; - public const int DefaultUint32ExtensionFieldNumber = 63; - [global::System.CLSCompliant(false)] - public static pb::GeneratedExtensionBase DefaultUint32Extension; - public const int DefaultUint64ExtensionFieldNumber = 64; - [global::System.CLSCompliant(false)] - public static pb::GeneratedExtensionBase DefaultUint64Extension; - public const int DefaultSint32ExtensionFieldNumber = 65; - public static pb::GeneratedExtensionBase DefaultSint32Extension; - public const int DefaultSint64ExtensionFieldNumber = 66; - public static pb::GeneratedExtensionBase DefaultSint64Extension; - public const int DefaultFixed32ExtensionFieldNumber = 67; - [global::System.CLSCompliant(false)] - public static pb::GeneratedExtensionBase DefaultFixed32Extension; - public const int DefaultFixed64ExtensionFieldNumber = 68; - [global::System.CLSCompliant(false)] - public static pb::GeneratedExtensionBase DefaultFixed64Extension; - public const int DefaultSfixed32ExtensionFieldNumber = 69; - public static pb::GeneratedExtensionBase DefaultSfixed32Extension; - public const int DefaultSfixed64ExtensionFieldNumber = 70; - public static pb::GeneratedExtensionBase DefaultSfixed64Extension; - public const int DefaultFloatExtensionFieldNumber = 71; - public static pb::GeneratedExtensionBase DefaultFloatExtension; - public const int DefaultDoubleExtensionFieldNumber = 72; - public static pb::GeneratedExtensionBase DefaultDoubleExtension; - public const int DefaultBoolExtensionFieldNumber = 73; - public static pb::GeneratedExtensionBase DefaultBoolExtension; - public const int DefaultStringExtensionFieldNumber = 74; - public static pb::GeneratedExtensionBase DefaultStringExtension; - public const int DefaultBytesExtensionFieldNumber = 75; - public static pb::GeneratedExtensionBase DefaultBytesExtension; - public const int DefaultNestedEnumExtensionFieldNumber = 81; - public static pb::GeneratedExtensionBase DefaultNestedEnumExtension; - public const int DefaultForeignEnumExtensionFieldNumber = 82; - public static pb::GeneratedExtensionBase DefaultForeignEnumExtension; - public const int DefaultImportEnumExtensionFieldNumber = 83; - public static pb::GeneratedExtensionBase DefaultImportEnumExtension; - public const int DefaultStringPieceExtensionFieldNumber = 84; - public static pb::GeneratedExtensionBase DefaultStringPieceExtension; - public const int DefaultCordExtensionFieldNumber = 85; - public static pb::GeneratedExtensionBase DefaultCordExtension; - public const int OneofUint32ExtensionFieldNumber = 111; - [global::System.CLSCompliant(false)] - public static pb::GeneratedExtensionBase OneofUint32Extension; - public const int OneofNestedMessageExtensionFieldNumber = 112; - public static pb::GeneratedExtensionBase OneofNestedMessageExtension; - public const int OneofStringExtensionFieldNumber = 113; - public static pb::GeneratedExtensionBase OneofStringExtension; - public const int OneofBytesExtensionFieldNumber = 114; - public static pb::GeneratedExtensionBase OneofBytesExtension; - public const int MyExtensionStringFieldNumber = 50; - public static pb::GeneratedExtensionBase MyExtensionString; - public const int MyExtensionIntFieldNumber = 5; - public static pb::GeneratedExtensionBase MyExtensionInt; - public const int PackedInt32ExtensionFieldNumber = 90; - public static pb::GeneratedExtensionBase> PackedInt32Extension; - public const int PackedInt64ExtensionFieldNumber = 91; - public static pb::GeneratedExtensionBase> PackedInt64Extension; - public const int PackedUint32ExtensionFieldNumber = 92; - [global::System.CLSCompliant(false)] - public static pb::GeneratedExtensionBase> PackedUint32Extension; - public const int PackedUint64ExtensionFieldNumber = 93; - [global::System.CLSCompliant(false)] - public static pb::GeneratedExtensionBase> PackedUint64Extension; - public const int PackedSint32ExtensionFieldNumber = 94; - public static pb::GeneratedExtensionBase> PackedSint32Extension; - public const int PackedSint64ExtensionFieldNumber = 95; - public static pb::GeneratedExtensionBase> PackedSint64Extension; - public const int PackedFixed32ExtensionFieldNumber = 96; - [global::System.CLSCompliant(false)] - public static pb::GeneratedExtensionBase> PackedFixed32Extension; - public const int PackedFixed64ExtensionFieldNumber = 97; - [global::System.CLSCompliant(false)] - public static pb::GeneratedExtensionBase> PackedFixed64Extension; - public const int PackedSfixed32ExtensionFieldNumber = 98; - public static pb::GeneratedExtensionBase> PackedSfixed32Extension; - public const int PackedSfixed64ExtensionFieldNumber = 99; - public static pb::GeneratedExtensionBase> PackedSfixed64Extension; - public const int PackedFloatExtensionFieldNumber = 100; - public static pb::GeneratedExtensionBase> PackedFloatExtension; - public const int PackedDoubleExtensionFieldNumber = 101; - public static pb::GeneratedExtensionBase> PackedDoubleExtension; - public const int PackedBoolExtensionFieldNumber = 102; - public static pb::GeneratedExtensionBase> PackedBoolExtension; - public const int PackedEnumExtensionFieldNumber = 103; - public static pb::GeneratedExtensionBase> PackedEnumExtension; - public const int UnpackedInt32ExtensionFieldNumber = 90; - public static pb::GeneratedExtensionBase> UnpackedInt32Extension; - public const int UnpackedInt64ExtensionFieldNumber = 91; - public static pb::GeneratedExtensionBase> UnpackedInt64Extension; - public const int UnpackedUint32ExtensionFieldNumber = 92; - [global::System.CLSCompliant(false)] - public static pb::GeneratedExtensionBase> UnpackedUint32Extension; - public const int UnpackedUint64ExtensionFieldNumber = 93; - [global::System.CLSCompliant(false)] - public static pb::GeneratedExtensionBase> UnpackedUint64Extension; - public const int UnpackedSint32ExtensionFieldNumber = 94; - public static pb::GeneratedExtensionBase> UnpackedSint32Extension; - public const int UnpackedSint64ExtensionFieldNumber = 95; - public static pb::GeneratedExtensionBase> UnpackedSint64Extension; - public const int UnpackedFixed32ExtensionFieldNumber = 96; - [global::System.CLSCompliant(false)] - public static pb::GeneratedExtensionBase> UnpackedFixed32Extension; - public const int UnpackedFixed64ExtensionFieldNumber = 97; - [global::System.CLSCompliant(false)] - public static pb::GeneratedExtensionBase> UnpackedFixed64Extension; - public const int UnpackedSfixed32ExtensionFieldNumber = 98; - public static pb::GeneratedExtensionBase> UnpackedSfixed32Extension; - public const int UnpackedSfixed64ExtensionFieldNumber = 99; - public static pb::GeneratedExtensionBase> UnpackedSfixed64Extension; - public const int UnpackedFloatExtensionFieldNumber = 100; - public static pb::GeneratedExtensionBase> UnpackedFloatExtension; - public const int UnpackedDoubleExtensionFieldNumber = 101; - public static pb::GeneratedExtensionBase> UnpackedDoubleExtension; - public const int UnpackedBoolExtensionFieldNumber = 102; - public static pb::GeneratedExtensionBase> UnpackedBoolExtension; - public const int UnpackedEnumExtensionFieldNumber = 103; - public static pb::GeneratedExtensionBase> UnpackedEnumExtension; - #endregion - - #region Static variables - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestAllTypes__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestAllTypes__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestAllTypes_NestedMessage__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestAllTypes_NestedMessage__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestAllTypes_OptionalGroup__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestAllTypes_OptionalGroup__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestAllTypes_RepeatedGroup__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestAllTypes_RepeatedGroup__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_NestedTestAllTypes__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_NestedTestAllTypes__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestDeprecatedFields__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestDeprecatedFields__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_ForeignMessage__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_ForeignMessage__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestAllExtensions__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestAllExtensions__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_OptionalGroup_extension__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_OptionalGroup_extension__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_RepeatedGroup_extension__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_RepeatedGroup_extension__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestNestedExtension__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestNestedExtension__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestRequired__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestRequired__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestRequiredForeign__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestRequiredForeign__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestForeignNested__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestForeignNested__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestEmptyMessage__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestEmptyMessage__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestEmptyMessageWithExtensions__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestEmptyMessageWithExtensions__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestMultipleExtensionRanges__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMultipleExtensionRanges__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestReallyLargeTagNumber__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestReallyLargeTagNumber__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestRecursiveMessage__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestRecursiveMessage__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestMutualRecursionA__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMutualRecursionA__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestMutualRecursionB__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMutualRecursionB__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestDupFieldNumber__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestDupFieldNumber__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestDupFieldNumber_Foo__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestDupFieldNumber_Foo__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestDupFieldNumber_Bar__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestDupFieldNumber_Bar__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestEagerMessage__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestEagerMessage__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestLazyMessage__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestLazyMessage__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestNestedMessageHasBits__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestNestedMessageHasBits__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestNestedMessageHasBits_NestedMessage__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestNestedMessageHasBits_NestedMessage__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestCamelCaseFieldNames__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestCamelCaseFieldNames__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestFieldOrderings__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestFieldOrderings__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestFieldOrderings_NestedMessage__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestFieldOrderings_NestedMessage__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestExtremeDefaultValues__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestExtremeDefaultValues__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_SparseEnumMessage__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_SparseEnumMessage__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_OneString__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_OneString__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_MoreString__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_MoreString__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_OneBytes__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_OneBytes__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_MoreBytes__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_MoreBytes__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_Int32Message__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_Int32Message__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_Uint32Message__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_Uint32Message__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_Int64Message__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_Int64Message__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_Uint64Message__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_Uint64Message__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_BoolMessage__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_BoolMessage__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestOneof__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestOneof__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestOneof_FooGroup__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestOneof_FooGroup__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestOneofBackwardsCompatible__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestOneofBackwardsCompatible__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestOneofBackwardsCompatible_FooGroup__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestOneofBackwardsCompatible_FooGroup__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestOneof2__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestOneof2__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestOneof2_FooGroup__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestOneof2_FooGroup__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestOneof2_NestedMessage__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestOneof2_NestedMessage__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestRequiredOneof__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestRequiredOneof__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestRequiredOneof_NestedMessage__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestRequiredOneof_NestedMessage__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestPackedTypes__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestPackedTypes__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestUnpackedTypes__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestUnpackedTypes__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestPackedExtensions__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestPackedExtensions__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestUnpackedExtensions__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestUnpackedExtensions__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestDynamicExtensions__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestDynamicExtensions__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestDynamicExtensions_DynamicMessageType__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestDynamicExtensions_DynamicMessageType__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestRepeatedScalarDifferentTagSizes__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestRepeatedScalarDifferentTagSizes__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestParsingMerge__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestParsingMerge__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestParsingMerge_RepeatedFieldsGenerator__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestParsingMerge_RepeatedFieldsGenerator__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestParsingMerge_RepeatedFieldsGenerator_Group1__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestParsingMerge_RepeatedFieldsGenerator_Group1__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestParsingMerge_RepeatedFieldsGenerator_Group2__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestParsingMerge_RepeatedFieldsGenerator_Group2__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestParsingMerge_OptionalGroup__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestParsingMerge_OptionalGroup__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestParsingMerge_RepeatedGroup__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestParsingMerge_RepeatedGroup__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestCommentInjectionMessage__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestCommentInjectionMessage__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_FooRequest__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_FooRequest__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_FooResponse__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_FooResponse__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_FooClientMessage__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_FooClientMessage__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_FooServerMessage__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_FooServerMessage__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_BarRequest__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_BarRequest__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_BarResponse__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_BarResponse__FieldAccessorTable; - #endregion - #region Descriptor - public static pbd::FileDescriptor Descriptor { - get { return descriptor; } - } - private static pbd::FileDescriptor descriptor; - - static Unittest() { - byte[] descriptorData = global::System.Convert.FromBase64String( - string.Concat( - "Ch5nb29nbGUvcHJvdG9idWYvdW5pdHRlc3QucHJvdG8SEXByb3RvYnVmX3Vu", - "aXR0ZXN0GiVnb29nbGUvcHJvdG9idWYvdW5pdHRlc3RfaW1wb3J0LnByb3Rv", - "Iu0YCgxUZXN0QWxsVHlwZXMSFgoOb3B0aW9uYWxfaW50MzIYASABKAUSFgoO", - "b3B0aW9uYWxfaW50NjQYAiABKAMSFwoPb3B0aW9uYWxfdWludDMyGAMgASgN", - "EhcKD29wdGlvbmFsX3VpbnQ2NBgEIAEoBBIXCg9vcHRpb25hbF9zaW50MzIY", - "BSABKBESFwoPb3B0aW9uYWxfc2ludDY0GAYgASgSEhgKEG9wdGlvbmFsX2Zp", - "eGVkMzIYByABKAcSGAoQb3B0aW9uYWxfZml4ZWQ2NBgIIAEoBhIZChFvcHRp", - "b25hbF9zZml4ZWQzMhgJIAEoDxIZChFvcHRpb25hbF9zZml4ZWQ2NBgKIAEo", - "EBIWCg5vcHRpb25hbF9mbG9hdBgLIAEoAhIXCg9vcHRpb25hbF9kb3VibGUY", - "DCABKAESFQoNb3B0aW9uYWxfYm9vbBgNIAEoCBIXCg9vcHRpb25hbF9zdHJp", - "bmcYDiABKAkSFgoOb3B0aW9uYWxfYnl0ZXMYDyABKAwSRAoNb3B0aW9uYWxn", - "cm91cBgQIAEoCjItLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RBbGxUeXBlcy5P", - "cHRpb25hbEdyb3VwEk4KF29wdGlvbmFsX25lc3RlZF9tZXNzYWdlGBIgASgL", - "Mi0ucHJvdG9idWZfdW5pdHRlc3QuVGVzdEFsbFR5cGVzLk5lc3RlZE1lc3Nh", - "Z2USQwoYb3B0aW9uYWxfZm9yZWlnbl9tZXNzYWdlGBMgASgLMiEucHJvdG9i", - "dWZfdW5pdHRlc3QuRm9yZWlnbk1lc3NhZ2USSAoXb3B0aW9uYWxfaW1wb3J0", - "X21lc3NhZ2UYFCABKAsyJy5wcm90b2J1Zl91bml0dGVzdF9pbXBvcnQuSW1w", - "b3J0TWVzc2FnZRJIChRvcHRpb25hbF9uZXN0ZWRfZW51bRgVIAEoDjIqLnBy", - "b3RvYnVmX3VuaXR0ZXN0LlRlc3RBbGxUeXBlcy5OZXN0ZWRFbnVtEj0KFW9w", - "dGlvbmFsX2ZvcmVpZ25fZW51bRgWIAEoDjIeLnByb3RvYnVmX3VuaXR0ZXN0", - "LkZvcmVpZ25FbnVtEkIKFG9wdGlvbmFsX2ltcG9ydF9lbnVtGBcgASgOMiQu", - "cHJvdG9idWZfdW5pdHRlc3RfaW1wb3J0LkltcG9ydEVudW0SIQoVb3B0aW9u", - "YWxfc3RyaW5nX3BpZWNlGBggASgJQgIIAhIZCg1vcHRpb25hbF9jb3JkGBkg", - "ASgJQgIIARJVCh5vcHRpb25hbF9wdWJsaWNfaW1wb3J0X21lc3NhZ2UYGiAB", - "KAsyLS5wcm90b2J1Zl91bml0dGVzdF9pbXBvcnQuUHVibGljSW1wb3J0TWVz", - "c2FnZRJQChVvcHRpb25hbF9sYXp5X21lc3NhZ2UYGyABKAsyLS5wcm90b2J1", - "Zl91bml0dGVzdC5UZXN0QWxsVHlwZXMuTmVzdGVkTWVzc2FnZUICKAESFgoO", - "cmVwZWF0ZWRfaW50MzIYHyADKAUSFgoOcmVwZWF0ZWRfaW50NjQYICADKAMS", - "FwoPcmVwZWF0ZWRfdWludDMyGCEgAygNEhcKD3JlcGVhdGVkX3VpbnQ2NBgi", - "IAMoBBIXCg9yZXBlYXRlZF9zaW50MzIYIyADKBESFwoPcmVwZWF0ZWRfc2lu", - "dDY0GCQgAygSEhgKEHJlcGVhdGVkX2ZpeGVkMzIYJSADKAcSGAoQcmVwZWF0", - "ZWRfZml4ZWQ2NBgmIAMoBhIZChFyZXBlYXRlZF9zZml4ZWQzMhgnIAMoDxIZ", - "ChFyZXBlYXRlZF9zZml4ZWQ2NBgoIAMoEBIWCg5yZXBlYXRlZF9mbG9hdBgp", - "IAMoAhIXCg9yZXBlYXRlZF9kb3VibGUYKiADKAESFQoNcmVwZWF0ZWRfYm9v", - "bBgrIAMoCBIXCg9yZXBlYXRlZF9zdHJpbmcYLCADKAkSFgoOcmVwZWF0ZWRf", - "Ynl0ZXMYLSADKAwSRAoNcmVwZWF0ZWRncm91cBguIAMoCjItLnByb3RvYnVm", - "X3VuaXR0ZXN0LlRlc3RBbGxUeXBlcy5SZXBlYXRlZEdyb3VwEk4KF3JlcGVh", - "dGVkX25lc3RlZF9tZXNzYWdlGDAgAygLMi0ucHJvdG9idWZfdW5pdHRlc3Qu", - "VGVzdEFsbFR5cGVzLk5lc3RlZE1lc3NhZ2USQwoYcmVwZWF0ZWRfZm9yZWln", - "bl9tZXNzYWdlGDEgAygLMiEucHJvdG9idWZfdW5pdHRlc3QuRm9yZWlnbk1l", - "c3NhZ2USSAoXcmVwZWF0ZWRfaW1wb3J0X21lc3NhZ2UYMiADKAsyJy5wcm90", - "b2J1Zl91bml0dGVzdF9pbXBvcnQuSW1wb3J0TWVzc2FnZRJIChRyZXBlYXRl", - "ZF9uZXN0ZWRfZW51bRgzIAMoDjIqLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RB", - "bGxUeXBlcy5OZXN0ZWRFbnVtEj0KFXJlcGVhdGVkX2ZvcmVpZ25fZW51bRg0", - "IAMoDjIeLnByb3RvYnVmX3VuaXR0ZXN0LkZvcmVpZ25FbnVtEkIKFHJlcGVh", - "dGVkX2ltcG9ydF9lbnVtGDUgAygOMiQucHJvdG9idWZfdW5pdHRlc3RfaW1w", - "b3J0LkltcG9ydEVudW0SIQoVcmVwZWF0ZWRfc3RyaW5nX3BpZWNlGDYgAygJ", - "QgIIAhIZCg1yZXBlYXRlZF9jb3JkGDcgAygJQgIIARJQChVyZXBlYXRlZF9s", - "YXp5X21lc3NhZ2UYOSADKAsyLS5wcm90b2J1Zl91bml0dGVzdC5UZXN0QWxs", - "VHlwZXMuTmVzdGVkTWVzc2FnZUICKAESGQoNZGVmYXVsdF9pbnQzMhg9IAEo", - "BToCNDESGQoNZGVmYXVsdF9pbnQ2NBg+IAEoAzoCNDISGgoOZGVmYXVsdF91", - "aW50MzIYPyABKA06AjQzEhoKDmRlZmF1bHRfdWludDY0GEAgASgEOgI0NBIb", - "Cg5kZWZhdWx0X3NpbnQzMhhBIAEoEToDLTQ1EhoKDmRlZmF1bHRfc2ludDY0", - "GEIgASgSOgI0NhIbCg9kZWZhdWx0X2ZpeGVkMzIYQyABKAc6AjQ3EhsKD2Rl", - "ZmF1bHRfZml4ZWQ2NBhEIAEoBjoCNDgSHAoQZGVmYXVsdF9zZml4ZWQzMhhF", - "IAEoDzoCNDkSHQoQZGVmYXVsdF9zZml4ZWQ2NBhGIAEoEDoDLTUwEhsKDWRl", - "ZmF1bHRfZmxvYXQYRyABKAI6BDUxLjUSHQoOZGVmYXVsdF9kb3VibGUYSCAB", - "KAE6BTUyMDAwEhoKDGRlZmF1bHRfYm9vbBhJIAEoCDoEdHJ1ZRIdCg5kZWZh", - "dWx0X3N0cmluZxhKIAEoCToFaGVsbG8SHAoNZGVmYXVsdF9ieXRlcxhLIAEo", - "DDoFd29ybGQSTAoTZGVmYXVsdF9uZXN0ZWRfZW51bRhRIAEoDjIqLnByb3Rv", - "YnVmX3VuaXR0ZXN0LlRlc3RBbGxUeXBlcy5OZXN0ZWRFbnVtOgNCQVISSQoU", - "ZGVmYXVsdF9mb3JlaWduX2VudW0YUiABKA4yHi5wcm90b2J1Zl91bml0dGVz", - "dC5Gb3JlaWduRW51bToLRk9SRUlHTl9CQVISTQoTZGVmYXVsdF9pbXBvcnRf", - "ZW51bRhTIAEoDjIkLnByb3RvYnVmX3VuaXR0ZXN0X2ltcG9ydC5JbXBvcnRF", - "bnVtOgpJTVBPUlRfQkFSEiUKFGRlZmF1bHRfc3RyaW5nX3BpZWNlGFQgASgJ", - "OgNhYmNCAggCEh0KDGRlZmF1bHRfY29yZBhVIAEoCToDMTIzQgIIARIWCgxv", - "bmVvZl91aW50MzIYbyABKA1IABJNChRvbmVvZl9uZXN0ZWRfbWVzc2FnZRhw", - "IAEoCzItLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RBbGxUeXBlcy5OZXN0ZWRN", - "ZXNzYWdlSAASFgoMb25lb2Zfc3RyaW5nGHEgASgJSAASFQoLb25lb2ZfYnl0", - "ZXMYciABKAxIABobCg1OZXN0ZWRNZXNzYWdlEgoKAmJiGAEgASgFGhoKDU9w", - "dGlvbmFsR3JvdXASCQoBYRgRIAEoBRoaCg1SZXBlYXRlZEdyb3VwEgkKAWEY", - "LyABKAUiOQoKTmVzdGVkRW51bRIHCgNGT08QARIHCgNCQVIQAhIHCgNCQVoQ", - "AxIQCgNORUcQ////////////AUINCgtvbmVvZl9maWVsZCJ8ChJOZXN0ZWRU", - "ZXN0QWxsVHlwZXMSNAoFY2hpbGQYASABKAsyJS5wcm90b2J1Zl91bml0dGVz", - "dC5OZXN0ZWRUZXN0QWxsVHlwZXMSMAoHcGF5bG9hZBgCIAEoCzIfLnByb3Rv", - "YnVmX3VuaXR0ZXN0LlRlc3RBbGxUeXBlcyI0ChRUZXN0RGVwcmVjYXRlZEZp", - "ZWxkcxIcChBkZXByZWNhdGVkX2ludDMyGAEgASgFQgIYASIbCg5Gb3JlaWdu", - "TWVzc2FnZRIJCgFjGAEgASgFIh0KEVRlc3RBbGxFeHRlbnNpb25zKggIARCA", - "gICAAiIkChdPcHRpb25hbEdyb3VwX2V4dGVuc2lvbhIJCgFhGBEgASgFIiQK", - "F1JlcGVhdGVkR3JvdXBfZXh0ZW5zaW9uEgkKAWEYLyABKAUimAEKE1Rlc3RO", - "ZXN0ZWRFeHRlbnNpb24yOQoEdGVzdBIkLnByb3RvYnVmX3VuaXR0ZXN0LlRl", - "c3RBbGxFeHRlbnNpb25zGOoHIAEoCToEdGVzdDJGChduZXN0ZWRfc3RyaW5n", - "X2V4dGVuc2lvbhIkLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RBbGxFeHRlbnNp", - "b25zGOsHIAEoCSLVBQoMVGVzdFJlcXVpcmVkEgkKAWEYASACKAUSDgoGZHVt", - "bXkyGAIgASgFEgkKAWIYAyACKAUSDgoGZHVtbXk0GAQgASgFEg4KBmR1bW15", - "NRgFIAEoBRIOCgZkdW1teTYYBiABKAUSDgoGZHVtbXk3GAcgASgFEg4KBmR1", - "bW15OBgIIAEoBRIOCgZkdW1teTkYCSABKAUSDwoHZHVtbXkxMBgKIAEoBRIP", - "CgdkdW1teTExGAsgASgFEg8KB2R1bW15MTIYDCABKAUSDwoHZHVtbXkxMxgN", - "IAEoBRIPCgdkdW1teTE0GA4gASgFEg8KB2R1bW15MTUYDyABKAUSDwoHZHVt", - "bXkxNhgQIAEoBRIPCgdkdW1teTE3GBEgASgFEg8KB2R1bW15MTgYEiABKAUS", - "DwoHZHVtbXkxORgTIAEoBRIPCgdkdW1teTIwGBQgASgFEg8KB2R1bW15MjEY", - "FSABKAUSDwoHZHVtbXkyMhgWIAEoBRIPCgdkdW1teTIzGBcgASgFEg8KB2R1", - "bW15MjQYGCABKAUSDwoHZHVtbXkyNRgZIAEoBRIPCgdkdW1teTI2GBogASgF", - "Eg8KB2R1bW15MjcYGyABKAUSDwoHZHVtbXkyOBgcIAEoBRIPCgdkdW1teTI5", - "GB0gASgFEg8KB2R1bW15MzAYHiABKAUSDwoHZHVtbXkzMRgfIAEoBRIPCgdk", - "dW1teTMyGCAgASgFEgkKAWMYISACKAUyVgoGc2luZ2xlEiQucHJvdG9idWZf", - "dW5pdHRlc3QuVGVzdEFsbEV4dGVuc2lvbnMY6AcgASgLMh8ucHJvdG9idWZf", - "dW5pdHRlc3QuVGVzdFJlcXVpcmVkMlUKBW11bHRpEiQucHJvdG9idWZfdW5p", - "dHRlc3QuVGVzdEFsbEV4dGVuc2lvbnMY6QcgAygLMh8ucHJvdG9idWZfdW5p", - "dHRlc3QuVGVzdFJlcXVpcmVkIpoBChNUZXN0UmVxdWlyZWRGb3JlaWduEjkK", - "EG9wdGlvbmFsX21lc3NhZ2UYASABKAsyHy5wcm90b2J1Zl91bml0dGVzdC5U", - "ZXN0UmVxdWlyZWQSOQoQcmVwZWF0ZWRfbWVzc2FnZRgCIAMoCzIfLnByb3Rv", - "YnVmX3VuaXR0ZXN0LlRlc3RSZXF1aXJlZBINCgVkdW1teRgDIAEoBSJaChFU", - "ZXN0Rm9yZWlnbk5lc3RlZBJFCg5mb3JlaWduX25lc3RlZBgBIAEoCzItLnBy", - "b3RvYnVmX3VuaXR0ZXN0LlRlc3RBbGxUeXBlcy5OZXN0ZWRNZXNzYWdlIhIK", - "EFRlc3RFbXB0eU1lc3NhZ2UiKgoeVGVzdEVtcHR5TWVzc2FnZVdpdGhFeHRl", - "bnNpb25zKggIARCAgICAAiI3ChtUZXN0TXVsdGlwbGVFeHRlbnNpb25SYW5n", - "ZXMqBAgqECsqBgivIBCUISoKCICABBCAgICAAiI0ChhUZXN0UmVhbGx5TGFy", - "Z2VUYWdOdW1iZXISCQoBYRgBIAEoBRINCgJiYhj///9/IAEoBSJVChRUZXN0", - "UmVjdXJzaXZlTWVzc2FnZRIyCgFhGAEgASgLMicucHJvdG9idWZfdW5pdHRl", - "c3QuVGVzdFJlY3Vyc2l2ZU1lc3NhZ2USCQoBaRgCIAEoBSJLChRUZXN0TXV0", - "dWFsUmVjdXJzaW9uQRIzCgJiYhgBIAEoCzInLnByb3RvYnVmX3VuaXR0ZXN0", - "LlRlc3RNdXR1YWxSZWN1cnNpb25CImIKFFRlc3RNdXR1YWxSZWN1cnNpb25C", - "EjIKAWEYASABKAsyJy5wcm90b2J1Zl91bml0dGVzdC5UZXN0TXV0dWFsUmVj", - "dXJzaW9uQRIWCg5vcHRpb25hbF9pbnQzMhgCIAEoBSKzAQoSVGVzdER1cEZp", - "ZWxkTnVtYmVyEgkKAWEYASABKAUSNgoDZm9vGAIgASgKMikucHJvdG9idWZf", - "dW5pdHRlc3QuVGVzdER1cEZpZWxkTnVtYmVyLkZvbxI2CgNiYXIYAyABKAoy", - "KS5wcm90b2J1Zl91bml0dGVzdC5UZXN0RHVwRmllbGROdW1iZXIuQmFyGhAK", - "A0ZvbxIJCgFhGAEgASgFGhAKA0JhchIJCgFhGAEgASgFIkwKEFRlc3RFYWdl", - "ck1lc3NhZ2USOAoLc3ViX21lc3NhZ2UYASABKAsyHy5wcm90b2J1Zl91bml0", - "dGVzdC5UZXN0QWxsVHlwZXNCAigAIksKD1Rlc3RMYXp5TWVzc2FnZRI4Cgtz", - "dWJfbWVzc2FnZRgBIAEoCzIfLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RBbGxU", - "eXBlc0ICKAEigAIKGFRlc3ROZXN0ZWRNZXNzYWdlSGFzQml0cxJaChdvcHRp", - "b25hbF9uZXN0ZWRfbWVzc2FnZRgBIAEoCzI5LnByb3RvYnVmX3VuaXR0ZXN0", - "LlRlc3ROZXN0ZWRNZXNzYWdlSGFzQml0cy5OZXN0ZWRNZXNzYWdlGocBCg1O", - "ZXN0ZWRNZXNzYWdlEiQKHG5lc3RlZG1lc3NhZ2VfcmVwZWF0ZWRfaW50MzIY", - "ASADKAUSUAolbmVzdGVkbWVzc2FnZV9yZXBlYXRlZF9mb3JlaWdubWVzc2Fn", - "ZRgCIAMoCzIhLnByb3RvYnVmX3VuaXR0ZXN0LkZvcmVpZ25NZXNzYWdlIuUD", - "ChdUZXN0Q2FtZWxDYXNlRmllbGROYW1lcxIWCg5QcmltaXRpdmVGaWVsZBgB", - "IAEoBRITCgtTdHJpbmdGaWVsZBgCIAEoCRIxCglFbnVtRmllbGQYAyABKA4y", - "Hi5wcm90b2J1Zl91bml0dGVzdC5Gb3JlaWduRW51bRI3CgxNZXNzYWdlRmll", - "bGQYBCABKAsyIS5wcm90b2J1Zl91bml0dGVzdC5Gb3JlaWduTWVzc2FnZRIc", - "ChBTdHJpbmdQaWVjZUZpZWxkGAUgASgJQgIIAhIVCglDb3JkRmllbGQYBiAB", - "KAlCAggBEh4KFlJlcGVhdGVkUHJpbWl0aXZlRmllbGQYByADKAUSGwoTUmVw", - "ZWF0ZWRTdHJpbmdGaWVsZBgIIAMoCRI5ChFSZXBlYXRlZEVudW1GaWVsZBgJ", - "IAMoDjIeLnByb3RvYnVmX3VuaXR0ZXN0LkZvcmVpZ25FbnVtEj8KFFJlcGVh", - "dGVkTWVzc2FnZUZpZWxkGAogAygLMiEucHJvdG9idWZfdW5pdHRlc3QuRm9y", - "ZWlnbk1lc3NhZ2USJAoYUmVwZWF0ZWRTdHJpbmdQaWVjZUZpZWxkGAsgAygJ", - "QgIIAhIdChFSZXBlYXRlZENvcmRGaWVsZBgMIAMoCUICCAEi1QEKElRlc3RG", - "aWVsZE9yZGVyaW5ncxIRCglteV9zdHJpbmcYCyABKAkSDgoGbXlfaW50GAEg", - "ASgDEhAKCG15X2Zsb2F0GGUgASgCElUKF29wdGlvbmFsX25lc3RlZF9tZXNz", - "YWdlGMgBIAEoCzIzLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RGaWVsZE9yZGVy", - "aW5ncy5OZXN0ZWRNZXNzYWdlGicKDU5lc3RlZE1lc3NhZ2USCgoCb28YAiAB", - "KAMSCgoCYmIYASABKAUqBAgCEAsqBAgMEGUitgcKGFRlc3RFeHRyZW1lRGVm", - "YXVsdFZhbHVlcxI/Cg1lc2NhcGVkX2J5dGVzGAEgASgMOihcMDAwXDAwMVww", - "MDdcMDEwXDAxNFxuXHJcdFwwMTNcXFwnXCJcMzc2EiAKDGxhcmdlX3VpbnQz", - "MhgCIAEoDToKNDI5NDk2NzI5NRIqCgxsYXJnZV91aW50NjQYAyABKAQ6FDE4", - "NDQ2NzQ0MDczNzA5NTUxNjE1EiAKC3NtYWxsX2ludDMyGAQgASgFOgstMjE0", - "NzQ4MzY0NxIpCgtzbWFsbF9pbnQ2NBgFIAEoAzoULTkyMjMzNzIwMzY4NTQ3", - "NzU4MDcSJwoScmVhbGx5X3NtYWxsX2ludDMyGBUgASgFOgstMjE0NzQ4MzY0", - "OBIwChJyZWFsbHlfc21hbGxfaW50NjQYFiABKAM6FC05MjIzMzcyMDM2ODU0", - "Nzc1ODA4EhgKC3V0Zjhfc3RyaW5nGAYgASgJOgPhiLQSFQoKemVyb19mbG9h", - "dBgHIAEoAjoBMBIUCglvbmVfZmxvYXQYCCABKAI6ATESGAoLc21hbGxfZmxv", - "YXQYCSABKAI6AzEuNRIeChJuZWdhdGl2ZV9vbmVfZmxvYXQYCiABKAI6Ai0x", - "EhwKDm5lZ2F0aXZlX2Zsb2F0GAsgASgCOgQtMS41EhoKC2xhcmdlX2Zsb2F0", - "GAwgASgCOgUyZSswOBIkChRzbWFsbF9uZWdhdGl2ZV9mbG9hdBgNIAEoAjoG", - "LThlLTI4EhcKCmluZl9kb3VibGUYDiABKAE6A2luZhIcCg5uZWdfaW5mX2Rv", - "dWJsZRgPIAEoAToELWluZhIXCgpuYW5fZG91YmxlGBAgASgBOgNuYW4SFgoJ", - "aW5mX2Zsb2F0GBEgASgCOgNpbmYSGwoNbmVnX2luZl9mbG9hdBgSIAEoAjoE", - "LWluZhIWCgluYW5fZmxvYXQYEyABKAI6A25hbhIrCgxjcHBfdHJpZ3JhcGgY", - "FCABKAk6FT8gPyA/PyA/PyA/Pz8gPz8vID8/LRIgChBzdHJpbmdfd2l0aF96", - "ZXJvGBcgASgJOgZoZWwAbG8SIgoPYnl0ZXNfd2l0aF96ZXJvGBggASgMOgl3", - "b3JcMDAwbGQSKAoWc3RyaW5nX3BpZWNlX3dpdGhfemVybxgZIAEoCToEYWIA", - "Y0ICCAISIAoOY29yZF93aXRoX3plcm8YGiABKAk6BDEyADNCAggBEiYKEnJl", - "cGxhY2VtZW50X3N0cmluZxgbIAEoCToKJHt1bmtub3dufSJLChFTcGFyc2VF", - "bnVtTWVzc2FnZRI2CgtzcGFyc2VfZW51bRgBIAEoDjIhLnByb3RvYnVmX3Vu", - "aXR0ZXN0LlRlc3RTcGFyc2VFbnVtIhkKCU9uZVN0cmluZxIMCgRkYXRhGAEg", - "ASgJIhoKCk1vcmVTdHJpbmcSDAoEZGF0YRgBIAMoCSIYCghPbmVCeXRlcxIM", - "CgRkYXRhGAEgASgMIhkKCU1vcmVCeXRlcxIMCgRkYXRhGAEgAygMIhwKDElu", - "dDMyTWVzc2FnZRIMCgRkYXRhGAEgASgFIh0KDVVpbnQzMk1lc3NhZ2USDAoE", - "ZGF0YRgBIAEoDSIcCgxJbnQ2NE1lc3NhZ2USDAoEZGF0YRgBIAEoAyIdCg1V", - "aW50NjRNZXNzYWdlEgwKBGRhdGEYASABKAQiGwoLQm9vbE1lc3NhZ2USDAoE", - "ZGF0YRgBIAEoCCLQAQoJVGVzdE9uZW9mEhEKB2Zvb19pbnQYASABKAVIABIU", - "Cgpmb29fc3RyaW5nGAIgASgJSAASNgoLZm9vX21lc3NhZ2UYAyABKAsyHy5w", - "cm90b2J1Zl91bml0dGVzdC5UZXN0QWxsVHlwZXNIABI5Cghmb29ncm91cBgE", - "IAEoCjIlLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RPbmVvZi5Gb29Hcm91cEgA", - "GiAKCEZvb0dyb3VwEgkKAWEYBSABKAUSCQoBYhgGIAEoCUIFCgNmb28i5wEK", - "HFRlc3RPbmVvZkJhY2t3YXJkc0NvbXBhdGlibGUSDwoHZm9vX2ludBgBIAEo", - "BRISCgpmb29fc3RyaW5nGAIgASgJEjQKC2Zvb19tZXNzYWdlGAMgASgLMh8u", - "cHJvdG9idWZfdW5pdHRlc3QuVGVzdEFsbFR5cGVzEkoKCGZvb2dyb3VwGAQg", - "ASgKMjgucHJvdG9idWZfdW5pdHRlc3QuVGVzdE9uZW9mQmFja3dhcmRzQ29t", - "cGF0aWJsZS5Gb29Hcm91cBogCghGb29Hcm91cBIJCgFhGAUgASgFEgkKAWIY", - "BiABKAkingYKClRlc3RPbmVvZjISEQoHZm9vX2ludBgBIAEoBUgAEhQKCmZv", - "b19zdHJpbmcYAiABKAlIABIWCghmb29fY29yZBgDIAEoCUICCAFIABIeChBm", - "b29fc3RyaW5nX3BpZWNlGAQgASgJQgIIAkgAEhMKCWZvb19ieXRlcxgFIAEo", - "DEgAEjwKCGZvb19lbnVtGAYgASgOMigucHJvdG9idWZfdW5pdHRlc3QuVGVz", - "dE9uZW9mMi5OZXN0ZWRFbnVtSAASQgoLZm9vX21lc3NhZ2UYByABKAsyKy5w", - "cm90b2J1Zl91bml0dGVzdC5UZXN0T25lb2YyLk5lc3RlZE1lc3NhZ2VIABI6", - "Cghmb29ncm91cBgIIAEoCjImLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RPbmVv", - "ZjIuRm9vR3JvdXBIABJLChBmb29fbGF6eV9tZXNzYWdlGAsgASgLMisucHJv", - "dG9idWZfdW5pdHRlc3QuVGVzdE9uZW9mMi5OZXN0ZWRNZXNzYWdlQgIoAUgA", - "EhQKB2Jhcl9pbnQYDCABKAU6ATVIARIcCgpiYXJfc3RyaW5nGA0gASgJOgZT", - "VFJJTkdIARIcCghiYXJfY29yZBgOIAEoCToEQ09SREICCAFIARImChBiYXJf", - "c3RyaW5nX3BpZWNlGA8gASgJOgZTUElFQ0VCAggCSAESGgoJYmFyX2J5dGVz", - "GBAgASgMOgVCWVRFU0gBEkEKCGJhcl9lbnVtGBEgASgOMigucHJvdG9idWZf", - "dW5pdHRlc3QuVGVzdE9uZW9mMi5OZXN0ZWRFbnVtOgNCQVJIARIPCgdiYXpf", - "aW50GBIgASgFEhcKCmJhel9zdHJpbmcYEyABKAk6A0JBWhogCghGb29Hcm91", - "cBIJCgFhGAkgASgFEgkKAWIYCiABKAkaMwoNTmVzdGVkTWVzc2FnZRIPCgdx", - "dXhfaW50GAEgASgDEhEKCWNvcmdlX2ludBgCIAMoBSInCgpOZXN0ZWRFbnVt", - "EgcKA0ZPTxABEgcKA0JBUhACEgcKA0JBWhADQgUKA2Zvb0IFCgNiYXIiuAEK", - "EVRlc3RSZXF1aXJlZE9uZW9mEhEKB2Zvb19pbnQYASABKAVIABIUCgpmb29f", - "c3RyaW5nGAIgASgJSAASSQoLZm9vX21lc3NhZ2UYAyABKAsyMi5wcm90b2J1", - "Zl91bml0dGVzdC5UZXN0UmVxdWlyZWRPbmVvZi5OZXN0ZWRNZXNzYWdlSAAa", - "KAoNTmVzdGVkTWVzc2FnZRIXCg9yZXF1aXJlZF9kb3VibGUYASACKAFCBQoD", - "Zm9vIqoDCg9UZXN0UGFja2VkVHlwZXMSGAoMcGFja2VkX2ludDMyGFogAygF", - "QgIQARIYCgxwYWNrZWRfaW50NjQYWyADKANCAhABEhkKDXBhY2tlZF91aW50", - "MzIYXCADKA1CAhABEhkKDXBhY2tlZF91aW50NjQYXSADKARCAhABEhkKDXBh", - "Y2tlZF9zaW50MzIYXiADKBFCAhABEhkKDXBhY2tlZF9zaW50NjQYXyADKBJC", - "AhABEhoKDnBhY2tlZF9maXhlZDMyGGAgAygHQgIQARIaCg5wYWNrZWRfZml4", - "ZWQ2NBhhIAMoBkICEAESGwoPcGFja2VkX3NmaXhlZDMyGGIgAygPQgIQARIb", - "Cg9wYWNrZWRfc2ZpeGVkNjQYYyADKBBCAhABEhgKDHBhY2tlZF9mbG9hdBhk", - "IAMoAkICEAESGQoNcGFja2VkX2RvdWJsZRhlIAMoAUICEAESFwoLcGFja2Vk", - "X2Jvb2wYZiADKAhCAhABEjcKC3BhY2tlZF9lbnVtGGcgAygOMh4ucHJvdG9i", - "dWZfdW5pdHRlc3QuRm9yZWlnbkVudW1CAhABIsgDChFUZXN0VW5wYWNrZWRU", - "eXBlcxIaCg51bnBhY2tlZF9pbnQzMhhaIAMoBUICEAASGgoOdW5wYWNrZWRf", - "aW50NjQYWyADKANCAhAAEhsKD3VucGFja2VkX3VpbnQzMhhcIAMoDUICEAAS", - "GwoPdW5wYWNrZWRfdWludDY0GF0gAygEQgIQABIbCg91bnBhY2tlZF9zaW50", - "MzIYXiADKBFCAhAAEhsKD3VucGFja2VkX3NpbnQ2NBhfIAMoEkICEAASHAoQ", - "dW5wYWNrZWRfZml4ZWQzMhhgIAMoB0ICEAASHAoQdW5wYWNrZWRfZml4ZWQ2", - "NBhhIAMoBkICEAASHQoRdW5wYWNrZWRfc2ZpeGVkMzIYYiADKA9CAhAAEh0K", - "EXVucGFja2VkX3NmaXhlZDY0GGMgAygQQgIQABIaCg51bnBhY2tlZF9mbG9h", - "dBhkIAMoAkICEAASGwoPdW5wYWNrZWRfZG91YmxlGGUgAygBQgIQABIZCg11", - "bnBhY2tlZF9ib29sGGYgAygIQgIQABI5Cg11bnBhY2tlZF9lbnVtGGcgAygO", - "Mh4ucHJvdG9idWZfdW5pdHRlc3QuRm9yZWlnbkVudW1CAhAAIiAKFFRlc3RQ", - "YWNrZWRFeHRlbnNpb25zKggIARCAgICAAiIiChZUZXN0VW5wYWNrZWRFeHRl", - "bnNpb25zKggIARCAgICAAiKZBAoVVGVzdER5bmFtaWNFeHRlbnNpb25zEhkK", - "EHNjYWxhcl9leHRlbnNpb24Y0A8gASgHEjcKDmVudW1fZXh0ZW5zaW9uGNEP", - "IAEoDjIeLnByb3RvYnVmX3VuaXR0ZXN0LkZvcmVpZ25FbnVtElkKFmR5bmFt", - "aWNfZW51bV9leHRlbnNpb24Y0g8gASgOMjgucHJvdG9idWZfdW5pdHRlc3Qu", - "VGVzdER5bmFtaWNFeHRlbnNpb25zLkR5bmFtaWNFbnVtVHlwZRI9ChFtZXNz", - "YWdlX2V4dGVuc2lvbhjTDyABKAsyIS5wcm90b2J1Zl91bml0dGVzdC5Gb3Jl", - "aWduTWVzc2FnZRJfChlkeW5hbWljX21lc3NhZ2VfZXh0ZW5zaW9uGNQPIAEo", - "CzI7LnByb3RvYnVmX3VuaXR0ZXN0LlRlc3REeW5hbWljRXh0ZW5zaW9ucy5E", - "eW5hbWljTWVzc2FnZVR5cGUSGwoScmVwZWF0ZWRfZXh0ZW5zaW9uGNUPIAMo", - "CRIdChBwYWNrZWRfZXh0ZW5zaW9uGNYPIAMoEUICEAEaLAoSRHluYW1pY01l", - "c3NhZ2VUeXBlEhYKDWR5bmFtaWNfZmllbGQYtBAgASgFIkcKD0R5bmFtaWNF", - "bnVtVHlwZRIQCgtEWU5BTUlDX0ZPTxCYERIQCgtEWU5BTUlDX0JBUhCZERIQ", - "CgtEWU5BTUlDX0JBWhCaESLAAQojVGVzdFJlcGVhdGVkU2NhbGFyRGlmZmVy", - "ZW50VGFnU2l6ZXMSGAoQcmVwZWF0ZWRfZml4ZWQzMhgMIAMoBxIWCg5yZXBl", - "YXRlZF9pbnQzMhgNIAMoBRIZChByZXBlYXRlZF9maXhlZDY0GP4PIAMoBhIX", - "Cg5yZXBlYXRlZF9pbnQ2NBj/DyADKAMSGAoOcmVwZWF0ZWRfZmxvYXQY/v8P", - "IAMoAhIZCg9yZXBlYXRlZF91aW50NjQY//8PIAMoBCL3CQoQVGVzdFBhcnNp", - "bmdNZXJnZRI7ChJyZXF1aXJlZF9hbGxfdHlwZXMYASACKAsyHy5wcm90b2J1", - "Zl91bml0dGVzdC5UZXN0QWxsVHlwZXMSOwoSb3B0aW9uYWxfYWxsX3R5cGVz", - "GAIgASgLMh8ucHJvdG9idWZfdW5pdHRlc3QuVGVzdEFsbFR5cGVzEjsKEnJl", - "cGVhdGVkX2FsbF90eXBlcxgDIAMoCzIfLnByb3RvYnVmX3VuaXR0ZXN0LlRl", - "c3RBbGxUeXBlcxJICg1vcHRpb25hbGdyb3VwGAogASgKMjEucHJvdG9idWZf", - "dW5pdHRlc3QuVGVzdFBhcnNpbmdNZXJnZS5PcHRpb25hbEdyb3VwEkgKDXJl", - "cGVhdGVkZ3JvdXAYFCADKAoyMS5wcm90b2J1Zl91bml0dGVzdC5UZXN0UGFy", - "c2luZ01lcmdlLlJlcGVhdGVkR3JvdXAaqgQKF1JlcGVhdGVkRmllbGRzR2Vu", - "ZXJhdG9yEi8KBmZpZWxkMRgBIAMoCzIfLnByb3RvYnVmX3VuaXR0ZXN0LlRl", - "c3RBbGxUeXBlcxIvCgZmaWVsZDIYAiADKAsyHy5wcm90b2J1Zl91bml0dGVz", - "dC5UZXN0QWxsVHlwZXMSLwoGZmllbGQzGAMgAygLMh8ucHJvdG9idWZfdW5p", - "dHRlc3QuVGVzdEFsbFR5cGVzElIKBmdyb3VwMRgKIAMoCjJCLnByb3RvYnVm", - "X3VuaXR0ZXN0LlRlc3RQYXJzaW5nTWVyZ2UuUmVwZWF0ZWRGaWVsZHNHZW5l", - "cmF0b3IuR3JvdXAxElIKBmdyb3VwMhgUIAMoCjJCLnByb3RvYnVmX3VuaXR0", - "ZXN0LlRlc3RQYXJzaW5nTWVyZ2UuUmVwZWF0ZWRGaWVsZHNHZW5lcmF0b3Iu", - "R3JvdXAyEi4KBGV4dDEY6AcgAygLMh8ucHJvdG9idWZfdW5pdHRlc3QuVGVz", - "dEFsbFR5cGVzEi4KBGV4dDIY6QcgAygLMh8ucHJvdG9idWZfdW5pdHRlc3Qu", - "VGVzdEFsbFR5cGVzGjkKBkdyb3VwMRIvCgZmaWVsZDEYCyABKAsyHy5wcm90", - "b2J1Zl91bml0dGVzdC5UZXN0QWxsVHlwZXMaOQoGR3JvdXAyEi8KBmZpZWxk", - "MRgVIAEoCzIfLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RBbGxUeXBlcxpSCg1P", - "cHRpb25hbEdyb3VwEkEKGG9wdGlvbmFsX2dyb3VwX2FsbF90eXBlcxgLIAEo", - "CzIfLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RBbGxUeXBlcxpSCg1SZXBlYXRl", - "ZEdyb3VwEkEKGHJlcGVhdGVkX2dyb3VwX2FsbF90eXBlcxgVIAEoCzIfLnBy", - "b3RvYnVmX3VuaXR0ZXN0LlRlc3RBbGxUeXBlcyoJCOgHEICAgIACMlsKDG9w", - "dGlvbmFsX2V4dBIjLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RQYXJzaW5nTWVy", - "Z2UY6AcgASgLMh8ucHJvdG9idWZfdW5pdHRlc3QuVGVzdEFsbFR5cGVzMlsK", - "DHJlcGVhdGVkX2V4dBIjLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RQYXJzaW5n", - "TWVyZ2UY6QcgAygLMh8ucHJvdG9idWZfdW5pdHRlc3QuVGVzdEFsbFR5cGVz", - "IkQKG1Rlc3RDb21tZW50SW5qZWN0aW9uTWVzc2FnZRIlCgFhGAEgASgJOhoq", - "LyA8LSBOZWl0aGVyIHNob3VsZCB0aGlzLiIMCgpGb29SZXF1ZXN0Ig0KC0Zv", - "b1Jlc3BvbnNlIhIKEEZvb0NsaWVudE1lc3NhZ2UiEgoQRm9vU2VydmVyTWVz", - "c2FnZSIMCgpCYXJSZXF1ZXN0Ig0KC0JhclJlc3BvbnNlKkAKC0ZvcmVpZ25F", - "bnVtEg8KC0ZPUkVJR05fRk9PEAQSDwoLRk9SRUlHTl9CQVIQBRIPCgtGT1JF", - "SUdOX0JBWhAGKksKFFRlc3RFbnVtV2l0aER1cFZhbHVlEggKBEZPTzEQARII", - "CgRCQVIxEAISBwoDQkFaEAMSCAoERk9PMhABEggKBEJBUjIQAhoCEAEqiQEK", - "DlRlc3RTcGFyc2VFbnVtEgwKCFNQQVJTRV9BEHsSDgoIU1BBUlNFX0IQpucD", - "Eg8KCFNQQVJTRV9DELKxgAYSFQoIU1BBUlNFX0QQ8f//////////ARIVCghT", - "UEFSU0VfRRC03vz///////8BEgwKCFNQQVJTRV9GEAASDAoIU1BBUlNFX0cQ", - "AjKZAQoLVGVzdFNlcnZpY2USRAoDRm9vEh0ucHJvdG9idWZfdW5pdHRlc3Qu", - "Rm9vUmVxdWVzdBoeLnByb3RvYnVmX3VuaXR0ZXN0LkZvb1Jlc3BvbnNlEkQK", - "A0JhchIdLnByb3RvYnVmX3VuaXR0ZXN0LkJhclJlcXVlc3QaHi5wcm90b2J1", - "Zl91bml0dGVzdC5CYXJSZXNwb25zZTpGChhvcHRpb25hbF9pbnQzMl9leHRl", - "bnNpb24SJC5wcm90b2J1Zl91bml0dGVzdC5UZXN0QWxsRXh0ZW5zaW9ucxgB", - "IAEoBTpGChhvcHRpb25hbF9pbnQ2NF9leHRlbnNpb24SJC5wcm90b2J1Zl91", - "bml0dGVzdC5UZXN0QWxsRXh0ZW5zaW9ucxgCIAEoAzpHChlvcHRpb25hbF91", - "aW50MzJfZXh0ZW5zaW9uEiQucHJvdG9idWZfdW5pdHRlc3QuVGVzdEFsbEV4", - "dGVuc2lvbnMYAyABKA06RwoZb3B0aW9uYWxfdWludDY0X2V4dGVuc2lvbhIk", - "LnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RBbGxFeHRlbnNpb25zGAQgASgEOkcK", - "GW9wdGlvbmFsX3NpbnQzMl9leHRlbnNpb24SJC5wcm90b2J1Zl91bml0dGVz", - "dC5UZXN0QWxsRXh0ZW5zaW9ucxgFIAEoETpHChlvcHRpb25hbF9zaW50NjRf", - "ZXh0ZW5zaW9uEiQucHJvdG9idWZfdW5pdHRlc3QuVGVzdEFsbEV4dGVuc2lv", - "bnMYBiABKBI6SAoab3B0aW9uYWxfZml4ZWQzMl9leHRlbnNpb24SJC5wcm90", - "b2J1Zl91bml0dGVzdC5UZXN0QWxsRXh0ZW5zaW9ucxgHIAEoBzpIChpvcHRp", - "b25hbF9maXhlZDY0X2V4dGVuc2lvbhIkLnByb3RvYnVmX3VuaXR0ZXN0LlRl", - "c3RBbGxFeHRlbnNpb25zGAggASgGOkkKG29wdGlvbmFsX3NmaXhlZDMyX2V4", - "dGVuc2lvbhIkLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RBbGxFeHRlbnNpb25z", - "GAkgASgPOkkKG29wdGlvbmFsX3NmaXhlZDY0X2V4dGVuc2lvbhIkLnByb3Rv", - "YnVmX3VuaXR0ZXN0LlRlc3RBbGxFeHRlbnNpb25zGAogASgQOkYKGG9wdGlv", - "bmFsX2Zsb2F0X2V4dGVuc2lvbhIkLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RB", - "bGxFeHRlbnNpb25zGAsgASgCOkcKGW9wdGlvbmFsX2RvdWJsZV9leHRlbnNp", - "b24SJC5wcm90b2J1Zl91bml0dGVzdC5UZXN0QWxsRXh0ZW5zaW9ucxgMIAEo", - "ATpFChdvcHRpb25hbF9ib29sX2V4dGVuc2lvbhIkLnByb3RvYnVmX3VuaXR0", - "ZXN0LlRlc3RBbGxFeHRlbnNpb25zGA0gASgIOkcKGW9wdGlvbmFsX3N0cmlu", - "Z19leHRlbnNpb24SJC5wcm90b2J1Zl91bml0dGVzdC5UZXN0QWxsRXh0ZW5z", - "aW9ucxgOIAEoCTpGChhvcHRpb25hbF9ieXRlc19leHRlbnNpb24SJC5wcm90", - "b2J1Zl91bml0dGVzdC5UZXN0QWxsRXh0ZW5zaW9ucxgPIAEoDDpxChdvcHRp", - "b25hbGdyb3VwX2V4dGVuc2lvbhIkLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RB", - "bGxFeHRlbnNpb25zGBAgASgKMioucHJvdG9idWZfdW5pdHRlc3QuT3B0aW9u", - "YWxHcm91cF9leHRlbnNpb246fgohb3B0aW9uYWxfbmVzdGVkX21lc3NhZ2Vf", - "ZXh0ZW5zaW9uEiQucHJvdG9idWZfdW5pdHRlc3QuVGVzdEFsbEV4dGVuc2lv", - "bnMYEiABKAsyLS5wcm90b2J1Zl91bml0dGVzdC5UZXN0QWxsVHlwZXMuTmVz", - "dGVkTWVzc2FnZTpzCiJvcHRpb25hbF9mb3JlaWduX21lc3NhZ2VfZXh0ZW5z", - "aW9uEiQucHJvdG9idWZfdW5pdHRlc3QuVGVzdEFsbEV4dGVuc2lvbnMYEyAB", - "KAsyIS5wcm90b2J1Zl91bml0dGVzdC5Gb3JlaWduTWVzc2FnZTp4CiFvcHRp", - "b25hbF9pbXBvcnRfbWVzc2FnZV9leHRlbnNpb24SJC5wcm90b2J1Zl91bml0", - "dGVzdC5UZXN0QWxsRXh0ZW5zaW9ucxgUIAEoCzInLnByb3RvYnVmX3VuaXR0", - "ZXN0X2ltcG9ydC5JbXBvcnRNZXNzYWdlOngKHm9wdGlvbmFsX25lc3RlZF9l", - "bnVtX2V4dGVuc2lvbhIkLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RBbGxFeHRl", - "bnNpb25zGBUgASgOMioucHJvdG9idWZfdW5pdHRlc3QuVGVzdEFsbFR5cGVz", - "Lk5lc3RlZEVudW06bQofb3B0aW9uYWxfZm9yZWlnbl9lbnVtX2V4dGVuc2lv", - "bhIkLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RBbGxFeHRlbnNpb25zGBYgASgO", - "Mh4ucHJvdG9idWZfdW5pdHRlc3QuRm9yZWlnbkVudW06cgoeb3B0aW9uYWxf", - "aW1wb3J0X2VudW1fZXh0ZW5zaW9uEiQucHJvdG9idWZfdW5pdHRlc3QuVGVz", - "dEFsbEV4dGVuc2lvbnMYFyABKA4yJC5wcm90b2J1Zl91bml0dGVzdF9pbXBv", - "cnQuSW1wb3J0RW51bTpRCh9vcHRpb25hbF9zdHJpbmdfcGllY2VfZXh0ZW5z", - "aW9uEiQucHJvdG9idWZfdW5pdHRlc3QuVGVzdEFsbEV4dGVuc2lvbnMYGCAB", - "KAlCAggCOkkKF29wdGlvbmFsX2NvcmRfZXh0ZW5zaW9uEiQucHJvdG9idWZf", - "dW5pdHRlc3QuVGVzdEFsbEV4dGVuc2lvbnMYGSABKAlCAggBOoUBCihvcHRp", - "b25hbF9wdWJsaWNfaW1wb3J0X21lc3NhZ2VfZXh0ZW5zaW9uEiQucHJvdG9i", - "dWZfdW5pdHRlc3QuVGVzdEFsbEV4dGVuc2lvbnMYGiABKAsyLS5wcm90b2J1", - "Zl91bml0dGVzdF9pbXBvcnQuUHVibGljSW1wb3J0TWVzc2FnZTqAAQofb3B0", - "aW9uYWxfbGF6eV9tZXNzYWdlX2V4dGVuc2lvbhIkLnByb3RvYnVmX3VuaXR0", - "ZXN0LlRlc3RBbGxFeHRlbnNpb25zGBsgASgLMi0ucHJvdG9idWZfdW5pdHRl", - "c3QuVGVzdEFsbFR5cGVzLk5lc3RlZE1lc3NhZ2VCAigBOkYKGHJlcGVhdGVk", - "X2ludDMyX2V4dGVuc2lvbhIkLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RBbGxF", - "eHRlbnNpb25zGB8gAygFOkYKGHJlcGVhdGVkX2ludDY0X2V4dGVuc2lvbhIk", - "LnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RBbGxFeHRlbnNpb25zGCAgAygDOkcK", - "GXJlcGVhdGVkX3VpbnQzMl9leHRlbnNpb24SJC5wcm90b2J1Zl91bml0dGVz", - "dC5UZXN0QWxsRXh0ZW5zaW9ucxghIAMoDTpHChlyZXBlYXRlZF91aW50NjRf", - "ZXh0ZW5zaW9uEiQucHJvdG9idWZfdW5pdHRlc3QuVGVzdEFsbEV4dGVuc2lv", - "bnMYIiADKAQ6RwoZcmVwZWF0ZWRfc2ludDMyX2V4dGVuc2lvbhIkLnByb3Rv", - "YnVmX3VuaXR0ZXN0LlRlc3RBbGxFeHRlbnNpb25zGCMgAygROkcKGXJlcGVh", - "dGVkX3NpbnQ2NF9leHRlbnNpb24SJC5wcm90b2J1Zl91bml0dGVzdC5UZXN0", - "QWxsRXh0ZW5zaW9ucxgkIAMoEjpIChpyZXBlYXRlZF9maXhlZDMyX2V4dGVu", - "c2lvbhIkLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RBbGxFeHRlbnNpb25zGCUg", - "AygHOkgKGnJlcGVhdGVkX2ZpeGVkNjRfZXh0ZW5zaW9uEiQucHJvdG9idWZf", - "dW5pdHRlc3QuVGVzdEFsbEV4dGVuc2lvbnMYJiADKAY6SQobcmVwZWF0ZWRf", - "c2ZpeGVkMzJfZXh0ZW5zaW9uEiQucHJvdG9idWZfdW5pdHRlc3QuVGVzdEFs", - "bEV4dGVuc2lvbnMYJyADKA86SQobcmVwZWF0ZWRfc2ZpeGVkNjRfZXh0ZW5z", - "aW9uEiQucHJvdG9idWZfdW5pdHRlc3QuVGVzdEFsbEV4dGVuc2lvbnMYKCAD", - "KBA6RgoYcmVwZWF0ZWRfZmxvYXRfZXh0ZW5zaW9uEiQucHJvdG9idWZfdW5p", - "dHRlc3QuVGVzdEFsbEV4dGVuc2lvbnMYKSADKAI6RwoZcmVwZWF0ZWRfZG91", - "YmxlX2V4dGVuc2lvbhIkLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RBbGxFeHRl", - "bnNpb25zGCogAygBOkUKF3JlcGVhdGVkX2Jvb2xfZXh0ZW5zaW9uEiQucHJv", - "dG9idWZfdW5pdHRlc3QuVGVzdEFsbEV4dGVuc2lvbnMYKyADKAg6RwoZcmVw", - "ZWF0ZWRfc3RyaW5nX2V4dGVuc2lvbhIkLnByb3RvYnVmX3VuaXR0ZXN0LlRl", - "c3RBbGxFeHRlbnNpb25zGCwgAygJOkYKGHJlcGVhdGVkX2J5dGVzX2V4dGVu", - "c2lvbhIkLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RBbGxFeHRlbnNpb25zGC0g", - "AygMOnEKF3JlcGVhdGVkZ3JvdXBfZXh0ZW5zaW9uEiQucHJvdG9idWZfdW5p", - "dHRlc3QuVGVzdEFsbEV4dGVuc2lvbnMYLiADKAoyKi5wcm90b2J1Zl91bml0", - "dGVzdC5SZXBlYXRlZEdyb3VwX2V4dGVuc2lvbjp+CiFyZXBlYXRlZF9uZXN0", - "ZWRfbWVzc2FnZV9leHRlbnNpb24SJC5wcm90b2J1Zl91bml0dGVzdC5UZXN0", - "QWxsRXh0ZW5zaW9ucxgwIAMoCzItLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RB", - "bGxUeXBlcy5OZXN0ZWRNZXNzYWdlOnMKInJlcGVhdGVkX2ZvcmVpZ25fbWVz", - "c2FnZV9leHRlbnNpb24SJC5wcm90b2J1Zl91bml0dGVzdC5UZXN0QWxsRXh0", - "ZW5zaW9ucxgxIAMoCzIhLnByb3RvYnVmX3VuaXR0ZXN0LkZvcmVpZ25NZXNz", - "YWdlOngKIXJlcGVhdGVkX2ltcG9ydF9tZXNzYWdlX2V4dGVuc2lvbhIkLnBy", - "b3RvYnVmX3VuaXR0ZXN0LlRlc3RBbGxFeHRlbnNpb25zGDIgAygLMicucHJv", - "dG9idWZfdW5pdHRlc3RfaW1wb3J0LkltcG9ydE1lc3NhZ2U6eAoecmVwZWF0", - "ZWRfbmVzdGVkX2VudW1fZXh0ZW5zaW9uEiQucHJvdG9idWZfdW5pdHRlc3Qu", - "VGVzdEFsbEV4dGVuc2lvbnMYMyADKA4yKi5wcm90b2J1Zl91bml0dGVzdC5U", - "ZXN0QWxsVHlwZXMuTmVzdGVkRW51bTptCh9yZXBlYXRlZF9mb3JlaWduX2Vu", - "dW1fZXh0ZW5zaW9uEiQucHJvdG9idWZfdW5pdHRlc3QuVGVzdEFsbEV4dGVu", - "c2lvbnMYNCADKA4yHi5wcm90b2J1Zl91bml0dGVzdC5Gb3JlaWduRW51bTpy", - "Ch5yZXBlYXRlZF9pbXBvcnRfZW51bV9leHRlbnNpb24SJC5wcm90b2J1Zl91", - "bml0dGVzdC5UZXN0QWxsRXh0ZW5zaW9ucxg1IAMoDjIkLnByb3RvYnVmX3Vu", - "aXR0ZXN0X2ltcG9ydC5JbXBvcnRFbnVtOlEKH3JlcGVhdGVkX3N0cmluZ19w", - "aWVjZV9leHRlbnNpb24SJC5wcm90b2J1Zl91bml0dGVzdC5UZXN0QWxsRXh0", - "ZW5zaW9ucxg2IAMoCUICCAI6SQoXcmVwZWF0ZWRfY29yZF9leHRlbnNpb24S", - "JC5wcm90b2J1Zl91bml0dGVzdC5UZXN0QWxsRXh0ZW5zaW9ucxg3IAMoCUIC", - "CAE6gAEKH3JlcGVhdGVkX2xhenlfbWVzc2FnZV9leHRlbnNpb24SJC5wcm90", - "b2J1Zl91bml0dGVzdC5UZXN0QWxsRXh0ZW5zaW9ucxg5IAMoCzItLnByb3Rv", - "YnVmX3VuaXR0ZXN0LlRlc3RBbGxUeXBlcy5OZXN0ZWRNZXNzYWdlQgIoATpJ", - "ChdkZWZhdWx0X2ludDMyX2V4dGVuc2lvbhIkLnByb3RvYnVmX3VuaXR0ZXN0", - "LlRlc3RBbGxFeHRlbnNpb25zGD0gASgFOgI0MTpJChdkZWZhdWx0X2ludDY0", - "X2V4dGVuc2lvbhIkLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RBbGxFeHRlbnNp", - "b25zGD4gASgDOgI0MjpKChhkZWZhdWx0X3VpbnQzMl9leHRlbnNpb24SJC5w", - "cm90b2J1Zl91bml0dGVzdC5UZXN0QWxsRXh0ZW5zaW9ucxg/IAEoDToCNDM6", - "SgoYZGVmYXVsdF91aW50NjRfZXh0ZW5zaW9uEiQucHJvdG9idWZfdW5pdHRl", - "c3QuVGVzdEFsbEV4dGVuc2lvbnMYQCABKAQ6AjQ0OksKGGRlZmF1bHRfc2lu", - "dDMyX2V4dGVuc2lvbhIkLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RBbGxFeHRl", - "bnNpb25zGEEgASgROgMtNDU6SgoYZGVmYXVsdF9zaW50NjRfZXh0ZW5zaW9u", - "EiQucHJvdG9idWZfdW5pdHRlc3QuVGVzdEFsbEV4dGVuc2lvbnMYQiABKBI6", - "AjQ2OksKGWRlZmF1bHRfZml4ZWQzMl9leHRlbnNpb24SJC5wcm90b2J1Zl91", - "bml0dGVzdC5UZXN0QWxsRXh0ZW5zaW9ucxhDIAEoBzoCNDc6SwoZZGVmYXVs", - "dF9maXhlZDY0X2V4dGVuc2lvbhIkLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RB", - "bGxFeHRlbnNpb25zGEQgASgGOgI0ODpMChpkZWZhdWx0X3NmaXhlZDMyX2V4", - "dGVuc2lvbhIkLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RBbGxFeHRlbnNpb25z", - "GEUgASgPOgI0OTpNChpkZWZhdWx0X3NmaXhlZDY0X2V4dGVuc2lvbhIkLnBy", - "b3RvYnVmX3VuaXR0ZXN0LlRlc3RBbGxFeHRlbnNpb25zGEYgASgQOgMtNTA6", - "SwoXZGVmYXVsdF9mbG9hdF9leHRlbnNpb24SJC5wcm90b2J1Zl91bml0dGVz", - "dC5UZXN0QWxsRXh0ZW5zaW9ucxhHIAEoAjoENTEuNTpNChhkZWZhdWx0X2Rv", - "dWJsZV9leHRlbnNpb24SJC5wcm90b2J1Zl91bml0dGVzdC5UZXN0QWxsRXh0", - "ZW5zaW9ucxhIIAEoAToFNTIwMDA6SgoWZGVmYXVsdF9ib29sX2V4dGVuc2lv", - "bhIkLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RBbGxFeHRlbnNpb25zGEkgASgI", - "OgR0cnVlOk0KGGRlZmF1bHRfc3RyaW5nX2V4dGVuc2lvbhIkLnByb3RvYnVm", - "X3VuaXR0ZXN0LlRlc3RBbGxFeHRlbnNpb25zGEogASgJOgVoZWxsbzpMChdk", - "ZWZhdWx0X2J5dGVzX2V4dGVuc2lvbhIkLnByb3RvYnVmX3VuaXR0ZXN0LlRl", - "c3RBbGxFeHRlbnNpb25zGEsgASgMOgV3b3JsZDp8Ch1kZWZhdWx0X25lc3Rl", - "ZF9lbnVtX2V4dGVuc2lvbhIkLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RBbGxF", - "eHRlbnNpb25zGFEgASgOMioucHJvdG9idWZfdW5pdHRlc3QuVGVzdEFsbFR5", - "cGVzLk5lc3RlZEVudW06A0JBUjp5Ch5kZWZhdWx0X2ZvcmVpZ25fZW51bV9l", - "eHRlbnNpb24SJC5wcm90b2J1Zl91bml0dGVzdC5UZXN0QWxsRXh0ZW5zaW9u", - "cxhSIAEoDjIeLnByb3RvYnVmX3VuaXR0ZXN0LkZvcmVpZ25FbnVtOgtGT1JF", - "SUdOX0JBUjp9Ch1kZWZhdWx0X2ltcG9ydF9lbnVtX2V4dGVuc2lvbhIkLnBy", - "b3RvYnVmX3VuaXR0ZXN0LlRlc3RBbGxFeHRlbnNpb25zGFMgASgOMiQucHJv", - "dG9idWZfdW5pdHRlc3RfaW1wb3J0LkltcG9ydEVudW06CklNUE9SVF9CQVI6", - "VQoeZGVmYXVsdF9zdHJpbmdfcGllY2VfZXh0ZW5zaW9uEiQucHJvdG9idWZf", - "dW5pdHRlc3QuVGVzdEFsbEV4dGVuc2lvbnMYVCABKAk6A2FiY0ICCAI6TQoW", - "ZGVmYXVsdF9jb3JkX2V4dGVuc2lvbhIkLnByb3RvYnVmX3VuaXR0ZXN0LlRl", - "c3RBbGxFeHRlbnNpb25zGFUgASgJOgMxMjNCAggBOkQKFm9uZW9mX3VpbnQz", - "Ml9leHRlbnNpb24SJC5wcm90b2J1Zl91bml0dGVzdC5UZXN0QWxsRXh0ZW5z", - "aW9ucxhvIAEoDTp7Ch5vbmVvZl9uZXN0ZWRfbWVzc2FnZV9leHRlbnNpb24S", - "JC5wcm90b2J1Zl91bml0dGVzdC5UZXN0QWxsRXh0ZW5zaW9ucxhwIAEoCzIt", - "LnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RBbGxUeXBlcy5OZXN0ZWRNZXNzYWdl", - "OkQKFm9uZW9mX3N0cmluZ19leHRlbnNpb24SJC5wcm90b2J1Zl91bml0dGVz", - "dC5UZXN0QWxsRXh0ZW5zaW9ucxhxIAEoCTpDChVvbmVvZl9ieXRlc19leHRl", - "bnNpb24SJC5wcm90b2J1Zl91bml0dGVzdC5UZXN0QWxsRXh0ZW5zaW9ucxhy", - "IAEoDDpCChNteV9leHRlbnNpb25fc3RyaW5nEiUucHJvdG9idWZfdW5pdHRl", - "c3QuVGVzdEZpZWxkT3JkZXJpbmdzGDIgASgJOj8KEG15X2V4dGVuc2lvbl9p", - "bnQSJS5wcm90b2J1Zl91bml0dGVzdC5UZXN0RmllbGRPcmRlcmluZ3MYBSAB", - "KAU6SwoWcGFja2VkX2ludDMyX2V4dGVuc2lvbhInLnByb3RvYnVmX3VuaXR0", - "ZXN0LlRlc3RQYWNrZWRFeHRlbnNpb25zGFogAygFQgIQATpLChZwYWNrZWRf", - "aW50NjRfZXh0ZW5zaW9uEicucHJvdG9idWZfdW5pdHRlc3QuVGVzdFBhY2tl", - "ZEV4dGVuc2lvbnMYWyADKANCAhABOkwKF3BhY2tlZF91aW50MzJfZXh0ZW5z", - "aW9uEicucHJvdG9idWZfdW5pdHRlc3QuVGVzdFBhY2tlZEV4dGVuc2lvbnMY", - "XCADKA1CAhABOkwKF3BhY2tlZF91aW50NjRfZXh0ZW5zaW9uEicucHJvdG9i", - "dWZfdW5pdHRlc3QuVGVzdFBhY2tlZEV4dGVuc2lvbnMYXSADKARCAhABOkwK", - "F3BhY2tlZF9zaW50MzJfZXh0ZW5zaW9uEicucHJvdG9idWZfdW5pdHRlc3Qu", - "VGVzdFBhY2tlZEV4dGVuc2lvbnMYXiADKBFCAhABOkwKF3BhY2tlZF9zaW50", - "NjRfZXh0ZW5zaW9uEicucHJvdG9idWZfdW5pdHRlc3QuVGVzdFBhY2tlZEV4", - "dGVuc2lvbnMYXyADKBJCAhABOk0KGHBhY2tlZF9maXhlZDMyX2V4dGVuc2lv", - "bhInLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RQYWNrZWRFeHRlbnNpb25zGGAg", - "AygHQgIQATpNChhwYWNrZWRfZml4ZWQ2NF9leHRlbnNpb24SJy5wcm90b2J1", - "Zl91bml0dGVzdC5UZXN0UGFja2VkRXh0ZW5zaW9ucxhhIAMoBkICEAE6TgoZ", - "cGFja2VkX3NmaXhlZDMyX2V4dGVuc2lvbhInLnByb3RvYnVmX3VuaXR0ZXN0", - "LlRlc3RQYWNrZWRFeHRlbnNpb25zGGIgAygPQgIQATpOChlwYWNrZWRfc2Zp", - "eGVkNjRfZXh0ZW5zaW9uEicucHJvdG9idWZfdW5pdHRlc3QuVGVzdFBhY2tl", - "ZEV4dGVuc2lvbnMYYyADKBBCAhABOksKFnBhY2tlZF9mbG9hdF9leHRlbnNp", - "b24SJy5wcm90b2J1Zl91bml0dGVzdC5UZXN0UGFja2VkRXh0ZW5zaW9ucxhk", - "IAMoAkICEAE6TAoXcGFja2VkX2RvdWJsZV9leHRlbnNpb24SJy5wcm90b2J1", - "Zl91bml0dGVzdC5UZXN0UGFja2VkRXh0ZW5zaW9ucxhlIAMoAUICEAE6SgoV", - "cGFja2VkX2Jvb2xfZXh0ZW5zaW9uEicucHJvdG9idWZfdW5pdHRlc3QuVGVz", - "dFBhY2tlZEV4dGVuc2lvbnMYZiADKAhCAhABOmoKFXBhY2tlZF9lbnVtX2V4", - "dGVuc2lvbhInLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RQYWNrZWRFeHRlbnNp", - "b25zGGcgAygOMh4ucHJvdG9idWZfdW5pdHRlc3QuRm9yZWlnbkVudW1CAhAB", - "Ok8KGHVucGFja2VkX2ludDMyX2V4dGVuc2lvbhIpLnByb3RvYnVmX3VuaXR0", - "ZXN0LlRlc3RVbnBhY2tlZEV4dGVuc2lvbnMYWiADKAVCAhAAOk8KGHVucGFj", - "a2VkX2ludDY0X2V4dGVuc2lvbhIpLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RV", - "bnBhY2tlZEV4dGVuc2lvbnMYWyADKANCAhAAOlAKGXVucGFja2VkX3VpbnQz", - "Ml9leHRlbnNpb24SKS5wcm90b2J1Zl91bml0dGVzdC5UZXN0VW5wYWNrZWRF", - "eHRlbnNpb25zGFwgAygNQgIQADpQChl1bnBhY2tlZF91aW50NjRfZXh0ZW5z", - "aW9uEikucHJvdG9idWZfdW5pdHRlc3QuVGVzdFVucGFja2VkRXh0ZW5zaW9u", - "cxhdIAMoBEICEAA6UAoZdW5wYWNrZWRfc2ludDMyX2V4dGVuc2lvbhIpLnBy", - "b3RvYnVmX3VuaXR0ZXN0LlRlc3RVbnBhY2tlZEV4dGVuc2lvbnMYXiADKBFC", - "AhAAOlAKGXVucGFja2VkX3NpbnQ2NF9leHRlbnNpb24SKS5wcm90b2J1Zl91", - "bml0dGVzdC5UZXN0VW5wYWNrZWRFeHRlbnNpb25zGF8gAygSQgIQADpRChp1", - "bnBhY2tlZF9maXhlZDMyX2V4dGVuc2lvbhIpLnByb3RvYnVmX3VuaXR0ZXN0", - "LlRlc3RVbnBhY2tlZEV4dGVuc2lvbnMYYCADKAdCAhAAOlEKGnVucGFja2Vk", - "X2ZpeGVkNjRfZXh0ZW5zaW9uEikucHJvdG9idWZfdW5pdHRlc3QuVGVzdFVu", - "cGFja2VkRXh0ZW5zaW9ucxhhIAMoBkICEAA6UgobdW5wYWNrZWRfc2ZpeGVk", - "MzJfZXh0ZW5zaW9uEikucHJvdG9idWZfdW5pdHRlc3QuVGVzdFVucGFja2Vk", - "RXh0ZW5zaW9ucxhiIAMoD0ICEAA6UgobdW5wYWNrZWRfc2ZpeGVkNjRfZXh0", - "ZW5zaW9uEikucHJvdG9idWZfdW5pdHRlc3QuVGVzdFVucGFja2VkRXh0ZW5z", - "aW9ucxhjIAMoEEICEAA6TwoYdW5wYWNrZWRfZmxvYXRfZXh0ZW5zaW9uEiku", - "cHJvdG9idWZfdW5pdHRlc3QuVGVzdFVucGFja2VkRXh0ZW5zaW9ucxhkIAMo", - "AkICEAA6UAoZdW5wYWNrZWRfZG91YmxlX2V4dGVuc2lvbhIpLnByb3RvYnVm", - "X3VuaXR0ZXN0LlRlc3RVbnBhY2tlZEV4dGVuc2lvbnMYZSADKAFCAhAAOk4K", - "F3VucGFja2VkX2Jvb2xfZXh0ZW5zaW9uEikucHJvdG9idWZfdW5pdHRlc3Qu", - "VGVzdFVucGFja2VkRXh0ZW5zaW9ucxhmIAMoCEICEAA6bgoXdW5wYWNrZWRf", - "ZW51bV9leHRlbnNpb24SKS5wcm90b2J1Zl91bml0dGVzdC5UZXN0VW5wYWNr", - "ZWRFeHRlbnNpb25zGGcgAygOMh4ucHJvdG9idWZfdW5pdHRlc3QuRm9yZWln", - "bkVudW1CAhAAQkFCDVVuaXR0ZXN0UHJvdG9IAYABAYgBAZABAfgBAaoCIUdv", - "b2dsZS5Qcm90b2NvbEJ1ZmZlcnMuVGVzdFByb3Rvcw==")); - pbd::FileDescriptor.InternalDescriptorAssigner assigner = delegate(pbd::FileDescriptor root) { - descriptor = root; - internal__static_protobuf_unittest_TestAllTypes__Descriptor = Descriptor.MessageTypes[0]; - internal__static_protobuf_unittest_TestAllTypes__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestAllTypes__Descriptor, - new string[] { "OptionalInt32", "OptionalInt64", "OptionalUint32", "OptionalUint64", "OptionalSint32", "OptionalSint64", "OptionalFixed32", "OptionalFixed64", "OptionalSfixed32", "OptionalSfixed64", "OptionalFloat", "OptionalDouble", "OptionalBool", "OptionalString", "OptionalBytes", "OptionalGroup", "OptionalNestedMessage", "OptionalForeignMessage", "OptionalImportMessage", "OptionalNestedEnum", "OptionalForeignEnum", "OptionalImportEnum", "OptionalStringPiece", "OptionalCord", "OptionalPublicImportMessage", "OptionalLazyMessage", "RepeatedInt32", "RepeatedInt64", "RepeatedUint32", "RepeatedUint64", "RepeatedSint32", "RepeatedSint64", "RepeatedFixed32", "RepeatedFixed64", "RepeatedSfixed32", "RepeatedSfixed64", "RepeatedFloat", "RepeatedDouble", "RepeatedBool", "RepeatedString", "RepeatedBytes", "RepeatedGroup", "RepeatedNestedMessage", "RepeatedForeignMessage", "RepeatedImportMessage", "RepeatedNestedEnum", "RepeatedForeignEnum", "RepeatedImportEnum", "RepeatedStringPiece", "RepeatedCord", "RepeatedLazyMessage", "DefaultInt32", "DefaultInt64", "DefaultUint32", "DefaultUint64", "DefaultSint32", "DefaultSint64", "DefaultFixed32", "DefaultFixed64", "DefaultSfixed32", "DefaultSfixed64", "DefaultFloat", "DefaultDouble", "DefaultBool", "DefaultString", "DefaultBytes", "DefaultNestedEnum", "DefaultForeignEnum", "DefaultImportEnum", "DefaultStringPiece", "DefaultCord", "OneofUint32", "OneofNestedMessage", "OneofString", "OneofBytes", }); - internal__static_protobuf_unittest_TestAllTypes_NestedMessage__Descriptor = internal__static_protobuf_unittest_TestAllTypes__Descriptor.NestedTypes[0]; - internal__static_protobuf_unittest_TestAllTypes_NestedMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestAllTypes_NestedMessage__Descriptor, - new string[] { "Bb", }); - internal__static_protobuf_unittest_TestAllTypes_OptionalGroup__Descriptor = internal__static_protobuf_unittest_TestAllTypes__Descriptor.NestedTypes[1]; - internal__static_protobuf_unittest_TestAllTypes_OptionalGroup__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestAllTypes_OptionalGroup__Descriptor, - new string[] { "A", }); - internal__static_protobuf_unittest_TestAllTypes_RepeatedGroup__Descriptor = internal__static_protobuf_unittest_TestAllTypes__Descriptor.NestedTypes[2]; - internal__static_protobuf_unittest_TestAllTypes_RepeatedGroup__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestAllTypes_RepeatedGroup__Descriptor, - new string[] { "A", }); - internal__static_protobuf_unittest_NestedTestAllTypes__Descriptor = Descriptor.MessageTypes[1]; - internal__static_protobuf_unittest_NestedTestAllTypes__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_NestedTestAllTypes__Descriptor, - new string[] { "Child", "Payload", }); - internal__static_protobuf_unittest_TestDeprecatedFields__Descriptor = Descriptor.MessageTypes[2]; - internal__static_protobuf_unittest_TestDeprecatedFields__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestDeprecatedFields__Descriptor, - new string[] { "DeprecatedInt32", }); - internal__static_protobuf_unittest_ForeignMessage__Descriptor = Descriptor.MessageTypes[3]; - internal__static_protobuf_unittest_ForeignMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_ForeignMessage__Descriptor, - new string[] { "C", }); - internal__static_protobuf_unittest_TestAllExtensions__Descriptor = Descriptor.MessageTypes[4]; - internal__static_protobuf_unittest_TestAllExtensions__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestAllExtensions__Descriptor, - new string[] { }); - internal__static_protobuf_unittest_OptionalGroup_extension__Descriptor = Descriptor.MessageTypes[5]; - internal__static_protobuf_unittest_OptionalGroup_extension__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_OptionalGroup_extension__Descriptor, - new string[] { "A", }); - internal__static_protobuf_unittest_RepeatedGroup_extension__Descriptor = Descriptor.MessageTypes[6]; - internal__static_protobuf_unittest_RepeatedGroup_extension__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_RepeatedGroup_extension__Descriptor, - new string[] { "A", }); - internal__static_protobuf_unittest_TestNestedExtension__Descriptor = Descriptor.MessageTypes[7]; - internal__static_protobuf_unittest_TestNestedExtension__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestNestedExtension__Descriptor, - new string[] { }); - global::Google.ProtocolBuffers.TestProtos.TestNestedExtension.Test = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.TestNestedExtension.Descriptor.Extensions[0]); - global::Google.ProtocolBuffers.TestProtos.TestNestedExtension.NestedStringExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.TestNestedExtension.Descriptor.Extensions[1]); - internal__static_protobuf_unittest_TestRequired__Descriptor = Descriptor.MessageTypes[8]; - internal__static_protobuf_unittest_TestRequired__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestRequired__Descriptor, - new string[] { "A", "Dummy2", "B", "Dummy4", "Dummy5", "Dummy6", "Dummy7", "Dummy8", "Dummy9", "Dummy10", "Dummy11", "Dummy12", "Dummy13", "Dummy14", "Dummy15", "Dummy16", "Dummy17", "Dummy18", "Dummy19", "Dummy20", "Dummy21", "Dummy22", "Dummy23", "Dummy24", "Dummy25", "Dummy26", "Dummy27", "Dummy28", "Dummy29", "Dummy30", "Dummy31", "Dummy32", "C", }); - global::Google.ProtocolBuffers.TestProtos.TestRequired.Single = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.TestRequired.Descriptor.Extensions[0]); - global::Google.ProtocolBuffers.TestProtos.TestRequired.Multi = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.TestRequired.Descriptor.Extensions[1]); - internal__static_protobuf_unittest_TestRequiredForeign__Descriptor = Descriptor.MessageTypes[9]; - internal__static_protobuf_unittest_TestRequiredForeign__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestRequiredForeign__Descriptor, - new string[] { "OptionalMessage", "RepeatedMessage", "Dummy", }); - internal__static_protobuf_unittest_TestForeignNested__Descriptor = Descriptor.MessageTypes[10]; - internal__static_protobuf_unittest_TestForeignNested__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestForeignNested__Descriptor, - new string[] { "ForeignNested", }); - internal__static_protobuf_unittest_TestEmptyMessage__Descriptor = Descriptor.MessageTypes[11]; - internal__static_protobuf_unittest_TestEmptyMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestEmptyMessage__Descriptor, - new string[] { }); - internal__static_protobuf_unittest_TestEmptyMessageWithExtensions__Descriptor = Descriptor.MessageTypes[12]; - internal__static_protobuf_unittest_TestEmptyMessageWithExtensions__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestEmptyMessageWithExtensions__Descriptor, - new string[] { }); - internal__static_protobuf_unittest_TestMultipleExtensionRanges__Descriptor = Descriptor.MessageTypes[13]; - internal__static_protobuf_unittest_TestMultipleExtensionRanges__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestMultipleExtensionRanges__Descriptor, - new string[] { }); - internal__static_protobuf_unittest_TestReallyLargeTagNumber__Descriptor = Descriptor.MessageTypes[14]; - internal__static_protobuf_unittest_TestReallyLargeTagNumber__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestReallyLargeTagNumber__Descriptor, - new string[] { "A", "Bb", }); - internal__static_protobuf_unittest_TestRecursiveMessage__Descriptor = Descriptor.MessageTypes[15]; - internal__static_protobuf_unittest_TestRecursiveMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestRecursiveMessage__Descriptor, - new string[] { "A", "I", }); - internal__static_protobuf_unittest_TestMutualRecursionA__Descriptor = Descriptor.MessageTypes[16]; - internal__static_protobuf_unittest_TestMutualRecursionA__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestMutualRecursionA__Descriptor, - new string[] { "Bb", }); - internal__static_protobuf_unittest_TestMutualRecursionB__Descriptor = Descriptor.MessageTypes[17]; - internal__static_protobuf_unittest_TestMutualRecursionB__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestMutualRecursionB__Descriptor, - new string[] { "A", "OptionalInt32", }); - internal__static_protobuf_unittest_TestDupFieldNumber__Descriptor = Descriptor.MessageTypes[18]; - internal__static_protobuf_unittest_TestDupFieldNumber__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestDupFieldNumber__Descriptor, - new string[] { "A", "Foo", "Bar", }); - internal__static_protobuf_unittest_TestDupFieldNumber_Foo__Descriptor = internal__static_protobuf_unittest_TestDupFieldNumber__Descriptor.NestedTypes[0]; - internal__static_protobuf_unittest_TestDupFieldNumber_Foo__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestDupFieldNumber_Foo__Descriptor, - new string[] { "A", }); - internal__static_protobuf_unittest_TestDupFieldNumber_Bar__Descriptor = internal__static_protobuf_unittest_TestDupFieldNumber__Descriptor.NestedTypes[1]; - internal__static_protobuf_unittest_TestDupFieldNumber_Bar__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestDupFieldNumber_Bar__Descriptor, - new string[] { "A", }); - internal__static_protobuf_unittest_TestEagerMessage__Descriptor = Descriptor.MessageTypes[19]; - internal__static_protobuf_unittest_TestEagerMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestEagerMessage__Descriptor, - new string[] { "SubMessage", }); - internal__static_protobuf_unittest_TestLazyMessage__Descriptor = Descriptor.MessageTypes[20]; - internal__static_protobuf_unittest_TestLazyMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestLazyMessage__Descriptor, - new string[] { "SubMessage", }); - internal__static_protobuf_unittest_TestNestedMessageHasBits__Descriptor = Descriptor.MessageTypes[21]; - internal__static_protobuf_unittest_TestNestedMessageHasBits__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestNestedMessageHasBits__Descriptor, - new string[] { "OptionalNestedMessage", }); - internal__static_protobuf_unittest_TestNestedMessageHasBits_NestedMessage__Descriptor = internal__static_protobuf_unittest_TestNestedMessageHasBits__Descriptor.NestedTypes[0]; - internal__static_protobuf_unittest_TestNestedMessageHasBits_NestedMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestNestedMessageHasBits_NestedMessage__Descriptor, - new string[] { "NestedmessageRepeatedInt32", "NestedmessageRepeatedForeignmessage", }); - internal__static_protobuf_unittest_TestCamelCaseFieldNames__Descriptor = Descriptor.MessageTypes[22]; - internal__static_protobuf_unittest_TestCamelCaseFieldNames__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestCamelCaseFieldNames__Descriptor, - new string[] { "PrimitiveField", "StringField", "EnumField", "MessageField", "StringPieceField", "CordField", "RepeatedPrimitiveField", "RepeatedStringField", "RepeatedEnumField", "RepeatedMessageField", "RepeatedStringPieceField", "RepeatedCordField", }); - internal__static_protobuf_unittest_TestFieldOrderings__Descriptor = Descriptor.MessageTypes[23]; - internal__static_protobuf_unittest_TestFieldOrderings__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestFieldOrderings__Descriptor, - new string[] { "MyString", "MyInt", "MyFloat", "OptionalNestedMessage", }); - internal__static_protobuf_unittest_TestFieldOrderings_NestedMessage__Descriptor = internal__static_protobuf_unittest_TestFieldOrderings__Descriptor.NestedTypes[0]; - internal__static_protobuf_unittest_TestFieldOrderings_NestedMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestFieldOrderings_NestedMessage__Descriptor, - new string[] { "Oo", "Bb", }); - internal__static_protobuf_unittest_TestExtremeDefaultValues__Descriptor = Descriptor.MessageTypes[24]; - internal__static_protobuf_unittest_TestExtremeDefaultValues__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestExtremeDefaultValues__Descriptor, - new string[] { "EscapedBytes", "LargeUint32", "LargeUint64", "SmallInt32", "SmallInt64", "ReallySmallInt32", "ReallySmallInt64", "Utf8String", "ZeroFloat", "OneFloat", "SmallFloat", "NegativeOneFloat", "NegativeFloat", "LargeFloat", "SmallNegativeFloat", "InfDouble", "NegInfDouble", "NanDouble", "InfFloat", "NegInfFloat", "NanFloat", "CppTrigraph", "StringWithZero", "BytesWithZero", "StringPieceWithZero", "CordWithZero", "ReplacementString", }); - internal__static_protobuf_unittest_SparseEnumMessage__Descriptor = Descriptor.MessageTypes[25]; - internal__static_protobuf_unittest_SparseEnumMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_SparseEnumMessage__Descriptor, - new string[] { "SparseEnum", }); - internal__static_protobuf_unittest_OneString__Descriptor = Descriptor.MessageTypes[26]; - internal__static_protobuf_unittest_OneString__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_OneString__Descriptor, - new string[] { "Data", }); - internal__static_protobuf_unittest_MoreString__Descriptor = Descriptor.MessageTypes[27]; - internal__static_protobuf_unittest_MoreString__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_MoreString__Descriptor, - new string[] { "Data", }); - internal__static_protobuf_unittest_OneBytes__Descriptor = Descriptor.MessageTypes[28]; - internal__static_protobuf_unittest_OneBytes__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_OneBytes__Descriptor, - new string[] { "Data", }); - internal__static_protobuf_unittest_MoreBytes__Descriptor = Descriptor.MessageTypes[29]; - internal__static_protobuf_unittest_MoreBytes__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_MoreBytes__Descriptor, - new string[] { "Data", }); - internal__static_protobuf_unittest_Int32Message__Descriptor = Descriptor.MessageTypes[30]; - internal__static_protobuf_unittest_Int32Message__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_Int32Message__Descriptor, - new string[] { "Data", }); - internal__static_protobuf_unittest_Uint32Message__Descriptor = Descriptor.MessageTypes[31]; - internal__static_protobuf_unittest_Uint32Message__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_Uint32Message__Descriptor, - new string[] { "Data", }); - internal__static_protobuf_unittest_Int64Message__Descriptor = Descriptor.MessageTypes[32]; - internal__static_protobuf_unittest_Int64Message__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_Int64Message__Descriptor, - new string[] { "Data", }); - internal__static_protobuf_unittest_Uint64Message__Descriptor = Descriptor.MessageTypes[33]; - internal__static_protobuf_unittest_Uint64Message__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_Uint64Message__Descriptor, - new string[] { "Data", }); - internal__static_protobuf_unittest_BoolMessage__Descriptor = Descriptor.MessageTypes[34]; - internal__static_protobuf_unittest_BoolMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_BoolMessage__Descriptor, - new string[] { "Data", }); - internal__static_protobuf_unittest_TestOneof__Descriptor = Descriptor.MessageTypes[35]; - internal__static_protobuf_unittest_TestOneof__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestOneof__Descriptor, - new string[] { "FooInt", "FooString", "FooMessage", "FooGroup", }); - internal__static_protobuf_unittest_TestOneof_FooGroup__Descriptor = internal__static_protobuf_unittest_TestOneof__Descriptor.NestedTypes[0]; - internal__static_protobuf_unittest_TestOneof_FooGroup__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestOneof_FooGroup__Descriptor, - new string[] { "A", "B", }); - internal__static_protobuf_unittest_TestOneofBackwardsCompatible__Descriptor = Descriptor.MessageTypes[36]; - internal__static_protobuf_unittest_TestOneofBackwardsCompatible__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestOneofBackwardsCompatible__Descriptor, - new string[] { "FooInt", "FooString", "FooMessage", "FooGroup", }); - internal__static_protobuf_unittest_TestOneofBackwardsCompatible_FooGroup__Descriptor = internal__static_protobuf_unittest_TestOneofBackwardsCompatible__Descriptor.NestedTypes[0]; - internal__static_protobuf_unittest_TestOneofBackwardsCompatible_FooGroup__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestOneofBackwardsCompatible_FooGroup__Descriptor, - new string[] { "A", "B", }); - internal__static_protobuf_unittest_TestOneof2__Descriptor = Descriptor.MessageTypes[37]; - internal__static_protobuf_unittest_TestOneof2__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestOneof2__Descriptor, - new string[] { "FooInt", "FooString", "FooCord", "FooStringPiece", "FooBytes", "FooEnum", "FooMessage", "FooGroup", "FooLazyMessage", "BarInt", "BarString", "BarCord", "BarStringPiece", "BarBytes", "BarEnum", "BazInt", "BazString", }); - internal__static_protobuf_unittest_TestOneof2_FooGroup__Descriptor = internal__static_protobuf_unittest_TestOneof2__Descriptor.NestedTypes[0]; - internal__static_protobuf_unittest_TestOneof2_FooGroup__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestOneof2_FooGroup__Descriptor, - new string[] { "A", "B", }); - internal__static_protobuf_unittest_TestOneof2_NestedMessage__Descriptor = internal__static_protobuf_unittest_TestOneof2__Descriptor.NestedTypes[1]; - internal__static_protobuf_unittest_TestOneof2_NestedMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestOneof2_NestedMessage__Descriptor, - new string[] { "QuxInt", "CorgeInt", }); - internal__static_protobuf_unittest_TestRequiredOneof__Descriptor = Descriptor.MessageTypes[38]; - internal__static_protobuf_unittest_TestRequiredOneof__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestRequiredOneof__Descriptor, - new string[] { "FooInt", "FooString", "FooMessage", }); - internal__static_protobuf_unittest_TestRequiredOneof_NestedMessage__Descriptor = internal__static_protobuf_unittest_TestRequiredOneof__Descriptor.NestedTypes[0]; - internal__static_protobuf_unittest_TestRequiredOneof_NestedMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestRequiredOneof_NestedMessage__Descriptor, - new string[] { "RequiredDouble", }); - internal__static_protobuf_unittest_TestPackedTypes__Descriptor = Descriptor.MessageTypes[39]; - internal__static_protobuf_unittest_TestPackedTypes__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestPackedTypes__Descriptor, - new string[] { "PackedInt32", "PackedInt64", "PackedUint32", "PackedUint64", "PackedSint32", "PackedSint64", "PackedFixed32", "PackedFixed64", "PackedSfixed32", "PackedSfixed64", "PackedFloat", "PackedDouble", "PackedBool", "PackedEnum", }); - internal__static_protobuf_unittest_TestUnpackedTypes__Descriptor = Descriptor.MessageTypes[40]; - internal__static_protobuf_unittest_TestUnpackedTypes__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestUnpackedTypes__Descriptor, - new string[] { "UnpackedInt32", "UnpackedInt64", "UnpackedUint32", "UnpackedUint64", "UnpackedSint32", "UnpackedSint64", "UnpackedFixed32", "UnpackedFixed64", "UnpackedSfixed32", "UnpackedSfixed64", "UnpackedFloat", "UnpackedDouble", "UnpackedBool", "UnpackedEnum", }); - internal__static_protobuf_unittest_TestPackedExtensions__Descriptor = Descriptor.MessageTypes[41]; - internal__static_protobuf_unittest_TestPackedExtensions__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestPackedExtensions__Descriptor, - new string[] { }); - internal__static_protobuf_unittest_TestUnpackedExtensions__Descriptor = Descriptor.MessageTypes[42]; - internal__static_protobuf_unittest_TestUnpackedExtensions__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestUnpackedExtensions__Descriptor, - new string[] { }); - internal__static_protobuf_unittest_TestDynamicExtensions__Descriptor = Descriptor.MessageTypes[43]; - internal__static_protobuf_unittest_TestDynamicExtensions__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestDynamicExtensions__Descriptor, - new string[] { "ScalarExtension", "EnumExtension", "DynamicEnumExtension", "MessageExtension", "DynamicMessageExtension", "RepeatedExtension", "PackedExtension", }); - internal__static_protobuf_unittest_TestDynamicExtensions_DynamicMessageType__Descriptor = internal__static_protobuf_unittest_TestDynamicExtensions__Descriptor.NestedTypes[0]; - internal__static_protobuf_unittest_TestDynamicExtensions_DynamicMessageType__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestDynamicExtensions_DynamicMessageType__Descriptor, - new string[] { "DynamicField", }); - internal__static_protobuf_unittest_TestRepeatedScalarDifferentTagSizes__Descriptor = Descriptor.MessageTypes[44]; - internal__static_protobuf_unittest_TestRepeatedScalarDifferentTagSizes__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestRepeatedScalarDifferentTagSizes__Descriptor, - new string[] { "RepeatedFixed32", "RepeatedInt32", "RepeatedFixed64", "RepeatedInt64", "RepeatedFloat", "RepeatedUint64", }); - internal__static_protobuf_unittest_TestParsingMerge__Descriptor = Descriptor.MessageTypes[45]; - internal__static_protobuf_unittest_TestParsingMerge__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestParsingMerge__Descriptor, - new string[] { "RequiredAllTypes", "OptionalAllTypes", "RepeatedAllTypes", "OptionalGroup", "RepeatedGroup", }); - internal__static_protobuf_unittest_TestParsingMerge_RepeatedFieldsGenerator__Descriptor = internal__static_protobuf_unittest_TestParsingMerge__Descriptor.NestedTypes[0]; - internal__static_protobuf_unittest_TestParsingMerge_RepeatedFieldsGenerator__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestParsingMerge_RepeatedFieldsGenerator__Descriptor, - new string[] { "Field1", "Field2", "Field3", "Group1", "Group2", "Ext1", "Ext2", }); - internal__static_protobuf_unittest_TestParsingMerge_RepeatedFieldsGenerator_Group1__Descriptor = internal__static_protobuf_unittest_TestParsingMerge_RepeatedFieldsGenerator__Descriptor.NestedTypes[0]; - internal__static_protobuf_unittest_TestParsingMerge_RepeatedFieldsGenerator_Group1__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestParsingMerge_RepeatedFieldsGenerator_Group1__Descriptor, - new string[] { "Field1", }); - internal__static_protobuf_unittest_TestParsingMerge_RepeatedFieldsGenerator_Group2__Descriptor = internal__static_protobuf_unittest_TestParsingMerge_RepeatedFieldsGenerator__Descriptor.NestedTypes[1]; - internal__static_protobuf_unittest_TestParsingMerge_RepeatedFieldsGenerator_Group2__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestParsingMerge_RepeatedFieldsGenerator_Group2__Descriptor, - new string[] { "Field1", }); - internal__static_protobuf_unittest_TestParsingMerge_OptionalGroup__Descriptor = internal__static_protobuf_unittest_TestParsingMerge__Descriptor.NestedTypes[1]; - internal__static_protobuf_unittest_TestParsingMerge_OptionalGroup__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestParsingMerge_OptionalGroup__Descriptor, - new string[] { "OptionalGroupAllTypes", }); - internal__static_protobuf_unittest_TestParsingMerge_RepeatedGroup__Descriptor = internal__static_protobuf_unittest_TestParsingMerge__Descriptor.NestedTypes[2]; - internal__static_protobuf_unittest_TestParsingMerge_RepeatedGroup__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestParsingMerge_RepeatedGroup__Descriptor, - new string[] { "RepeatedGroupAllTypes", }); - global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.OptionalExt = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Descriptor.Extensions[0]); - global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.RepeatedExt = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Descriptor.Extensions[1]); - internal__static_protobuf_unittest_TestCommentInjectionMessage__Descriptor = Descriptor.MessageTypes[46]; - internal__static_protobuf_unittest_TestCommentInjectionMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestCommentInjectionMessage__Descriptor, - new string[] { "A", }); - internal__static_protobuf_unittest_FooRequest__Descriptor = Descriptor.MessageTypes[47]; - internal__static_protobuf_unittest_FooRequest__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_FooRequest__Descriptor, - new string[] { }); - internal__static_protobuf_unittest_FooResponse__Descriptor = Descriptor.MessageTypes[48]; - internal__static_protobuf_unittest_FooResponse__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_FooResponse__Descriptor, - new string[] { }); - internal__static_protobuf_unittest_FooClientMessage__Descriptor = Descriptor.MessageTypes[49]; - internal__static_protobuf_unittest_FooClientMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_FooClientMessage__Descriptor, - new string[] { }); - internal__static_protobuf_unittest_FooServerMessage__Descriptor = Descriptor.MessageTypes[50]; - internal__static_protobuf_unittest_FooServerMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_FooServerMessage__Descriptor, - new string[] { }); - internal__static_protobuf_unittest_BarRequest__Descriptor = Descriptor.MessageTypes[51]; - internal__static_protobuf_unittest_BarRequest__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_BarRequest__Descriptor, - new string[] { }); - internal__static_protobuf_unittest_BarResponse__Descriptor = Descriptor.MessageTypes[52]; - internal__static_protobuf_unittest_BarResponse__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_BarResponse__Descriptor, - new string[] { }); - global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalInt32Extension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[0]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalInt64Extension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[1]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalUint32Extension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[2]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalUint64Extension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[3]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalSint32Extension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[4]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalSint64Extension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[5]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalFixed32Extension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[6]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalFixed64Extension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[7]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalSfixed32Extension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[8]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalSfixed64Extension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[9]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalFloatExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[10]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalDoubleExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[11]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalBoolExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[12]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalStringExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[13]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalBytesExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[14]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalGroupExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[15]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalNestedMessageExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[16]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalForeignMessageExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[17]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalImportMessageExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[18]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalNestedEnumExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[19]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalForeignEnumExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[20]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalImportEnumExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[21]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalStringPieceExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[22]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalCordExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[23]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalPublicImportMessageExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[24]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OptionalLazyMessageExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[25]); - global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedInt32Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[26]); - global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedInt64Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[27]); - global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedUint32Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[28]); - global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedUint64Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[29]); - global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedSint32Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[30]); - global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedSint64Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[31]); - global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedFixed32Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[32]); - global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedFixed64Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[33]); - global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedSfixed32Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[34]); - global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedSfixed64Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[35]); - global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedFloatExtension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[36]); - global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedDoubleExtension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[37]); - global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedBoolExtension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[38]); - global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedStringExtension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[39]); - global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedBytesExtension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[40]); - global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedGroupExtension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[41]); - global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedNestedMessageExtension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[42]); - global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedForeignMessageExtension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[43]); - global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedImportMessageExtension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[44]); - global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedNestedEnumExtension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[45]); - global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedForeignEnumExtension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[46]); - global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedImportEnumExtension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[47]); - global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedStringPieceExtension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[48]); - global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedCordExtension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[49]); - global::Google.ProtocolBuffers.TestProtos.Unittest.RepeatedLazyMessageExtension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[50]); - global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultInt32Extension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[51]); - global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultInt64Extension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[52]); - global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultUint32Extension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[53]); - global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultUint64Extension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[54]); - global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultSint32Extension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[55]); - global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultSint64Extension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[56]); - global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultFixed32Extension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[57]); - global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultFixed64Extension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[58]); - global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultSfixed32Extension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[59]); - global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultSfixed64Extension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[60]); - global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultFloatExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[61]); - global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultDoubleExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[62]); - global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultBoolExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[63]); - global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultStringExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[64]); - global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultBytesExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[65]); - global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultNestedEnumExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[66]); - global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultForeignEnumExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[67]); - global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultImportEnumExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[68]); - global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultStringPieceExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[69]); - global::Google.ProtocolBuffers.TestProtos.Unittest.DefaultCordExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[70]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OneofUint32Extension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[71]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OneofNestedMessageExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[72]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OneofStringExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[73]); - global::Google.ProtocolBuffers.TestProtos.Unittest.OneofBytesExtension = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[74]); - global::Google.ProtocolBuffers.TestProtos.Unittest.MyExtensionString = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[75]); - global::Google.ProtocolBuffers.TestProtos.Unittest.MyExtensionInt = pb::GeneratedSingleExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[76]); - global::Google.ProtocolBuffers.TestProtos.Unittest.PackedInt32Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[77]); - global::Google.ProtocolBuffers.TestProtos.Unittest.PackedInt64Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[78]); - global::Google.ProtocolBuffers.TestProtos.Unittest.PackedUint32Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[79]); - global::Google.ProtocolBuffers.TestProtos.Unittest.PackedUint64Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[80]); - global::Google.ProtocolBuffers.TestProtos.Unittest.PackedSint32Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[81]); - global::Google.ProtocolBuffers.TestProtos.Unittest.PackedSint64Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[82]); - global::Google.ProtocolBuffers.TestProtos.Unittest.PackedFixed32Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[83]); - global::Google.ProtocolBuffers.TestProtos.Unittest.PackedFixed64Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[84]); - global::Google.ProtocolBuffers.TestProtos.Unittest.PackedSfixed32Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[85]); - global::Google.ProtocolBuffers.TestProtos.Unittest.PackedSfixed64Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[86]); - global::Google.ProtocolBuffers.TestProtos.Unittest.PackedFloatExtension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[87]); - global::Google.ProtocolBuffers.TestProtos.Unittest.PackedDoubleExtension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[88]); - global::Google.ProtocolBuffers.TestProtos.Unittest.PackedBoolExtension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[89]); - global::Google.ProtocolBuffers.TestProtos.Unittest.PackedEnumExtension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[90]); - global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedInt32Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[91]); - global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedInt64Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[92]); - global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedUint32Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[93]); - global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedUint64Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[94]); - global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedSint32Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[95]); - global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedSint64Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[96]); - global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedFixed32Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[97]); - global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedFixed64Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[98]); - global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedSfixed32Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[99]); - global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedSfixed64Extension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[100]); - global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedFloatExtension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[101]); - global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedDoubleExtension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[102]); - global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedBoolExtension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[103]); - global::Google.ProtocolBuffers.TestProtos.Unittest.UnpackedEnumExtension = pb::GeneratedRepeatExtension.CreateInstance(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor.Extensions[104]); - pb::ExtensionRegistry registry = pb::ExtensionRegistry.CreateInstance(); - RegisterAllExtensions(registry); - global::Google.ProtocolBuffers.TestProtos.UnittestImport.RegisterAllExtensions(registry); - return registry; - }; - pbd::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, - new pbd::FileDescriptor[] { - global::Google.ProtocolBuffers.TestProtos.UnittestImport.Descriptor, - }, assigner); - } - #endregion - - } - #region Enums - public enum ForeignEnum { - FOREIGN_FOO = 4, - FOREIGN_BAR = 5, - FOREIGN_BAZ = 6, - } - - public enum TestEnumWithDupValue { - FOO1 = 1, - BAR1 = 2, - BAZ = 3, - FOO2 = 1, - BAR2 = 2, - } - - public enum TestSparseEnum { - SPARSE_A = 123, - SPARSE_B = 62374, - SPARSE_C = 12589234, - SPARSE_D = -15, - SPARSE_E = -53452, - SPARSE_F = 0, - SPARSE_G = 2, - } - - #endregion - - #region Messages - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestAllTypes : pb::GeneratedMessage { - private TestAllTypes() { } - private static readonly TestAllTypes defaultInstance = new TestAllTypes().MakeReadOnly(); - private static readonly string[] _testAllTypesFieldNames = new string[] { "default_bool", "default_bytes", "default_cord", "default_double", "default_fixed32", "default_fixed64", "default_float", "default_foreign_enum", "default_import_enum", "default_int32", "default_int64", "default_nested_enum", "default_sfixed32", "default_sfixed64", "default_sint32", "default_sint64", "default_string", "default_string_piece", "default_uint32", "default_uint64", "oneof_bytes", "oneof_nested_message", "oneof_string", "oneof_uint32", "optional_bool", "optional_bytes", "optional_cord", "optional_double", "optional_fixed32", "optional_fixed64", "optional_float", "optional_foreign_enum", "optional_foreign_message", "optional_import_enum", "optional_import_message", "optional_int32", "optional_int64", "optional_lazy_message", "optional_nested_enum", "optional_nested_message", "optional_public_import_message", "optional_sfixed32", "optional_sfixed64", "optional_sint32", "optional_sint64", "optional_string", "optional_string_piece", "optional_uint32", "optional_uint64", "optionalgroup", "repeated_bool", "repeated_bytes", "repeated_cord", "repeated_double", "repeated_fixed32", "repeated_fixed64", "repeated_float", "repeated_foreign_enum", "repeated_foreign_message", "repeated_import_enum", "repeated_import_message", "repeated_int32", "repeated_int64", "repeated_lazy_message", "repeated_nested_enum", "repeated_nested_message", "repeated_sfixed32", "repeated_sfixed64", "repeated_sint32", "repeated_sint64", "repeated_string", "repeated_string_piece", "repeated_uint32", "repeated_uint64", "repeatedgroup" }; - private static readonly uint[] _testAllTypesFieldTags = new uint[] { 584, 602, 682, 577, 541, 545, 573, 656, 664, 488, 496, 648, 557, 561, 520, 528, 594, 674, 504, 512, 914, 898, 906, 888, 104, 122, 202, 97, 61, 65, 93, 176, 154, 184, 162, 8, 16, 218, 168, 146, 210, 77, 81, 40, 48, 114, 194, 24, 32, 131, 344, 362, 442, 337, 301, 305, 333, 416, 394, 424, 402, 248, 256, 458, 408, 386, 317, 321, 280, 288, 354, 434, 264, 272, 371 }; - public static TestAllTypes DefaultInstance { - get { return defaultInstance; } - } - - public override TestAllTypes DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestAllTypes ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestAllTypes__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestAllTypes__FieldAccessorTable; } - } - - #region Nested types - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class Types { - public enum NestedEnum { - FOO = 1, - BAR = 2, - BAZ = 3, - NEG = -1, - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class NestedMessage : pb::GeneratedMessage { - private NestedMessage() { } - private static readonly NestedMessage defaultInstance = new NestedMessage().MakeReadOnly(); - private static readonly string[] _nestedMessageFieldNames = new string[] { "bb" }; - private static readonly uint[] _nestedMessageFieldTags = new uint[] { 8 }; - public static NestedMessage DefaultInstance { - get { return defaultInstance; } - } - - public override NestedMessage DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override NestedMessage ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestAllTypes_NestedMessage__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestAllTypes_NestedMessage__FieldAccessorTable; } - } - - public const int BbFieldNumber = 1; - private bool hasBb; - private int bb_; - public bool HasBb { - get { return hasBb; } - } - public int Bb { - get { return bb_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _nestedMessageFieldNames; - if (hasBb) { - output.WriteInt32(1, field_names[0], Bb); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasBb) { - size += pb::CodedOutputStream.ComputeInt32Size(1, Bb); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static NestedMessage ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static NestedMessage ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static NestedMessage ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static NestedMessage ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static NestedMessage ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static NestedMessage ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static NestedMessage ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static NestedMessage ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static NestedMessage ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static NestedMessage ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private NestedMessage MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(NestedMessage prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(NestedMessage cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private NestedMessage result; - - private NestedMessage PrepareBuilder() { - if (resultIsReadOnly) { - NestedMessage original = result; - result = new NestedMessage(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override NestedMessage MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.Descriptor; } - } - - public override NestedMessage DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.DefaultInstance; } - } - - public override NestedMessage BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is NestedMessage) { - return MergeFrom((NestedMessage) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(NestedMessage other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasBb) { - Bb = other.Bb; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_nestedMessageFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _nestedMessageFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasBb = input.ReadInt32(ref result.bb_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasBb { - get { return result.hasBb; } - } - public int Bb { - get { return result.Bb; } - set { SetBb(value); } - } - public Builder SetBb(int value) { - PrepareBuilder(); - result.hasBb = true; - result.bb_ = value; - return this; - } - public Builder ClearBb() { - PrepareBuilder(); - result.hasBb = false; - result.bb_ = 0; - return this; - } - } - static NestedMessage() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class OptionalGroup : pb::GeneratedMessage { - private OptionalGroup() { } - private static readonly OptionalGroup defaultInstance = new OptionalGroup().MakeReadOnly(); - private static readonly string[] _optionalGroupFieldNames = new string[] { "a" }; - private static readonly uint[] _optionalGroupFieldTags = new uint[] { 136 }; - public static OptionalGroup DefaultInstance { - get { return defaultInstance; } - } - - public override OptionalGroup DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override OptionalGroup ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestAllTypes_OptionalGroup__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestAllTypes_OptionalGroup__FieldAccessorTable; } - } - - public const int AFieldNumber = 17; - private bool hasA; - private int a_; - public bool HasA { - get { return hasA; } - } - public int A { - get { return a_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _optionalGroupFieldNames; - if (hasA) { - output.WriteInt32(17, field_names[0], A); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(17, A); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static OptionalGroup ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static OptionalGroup ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static OptionalGroup ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static OptionalGroup ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static OptionalGroup ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static OptionalGroup ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static OptionalGroup ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static OptionalGroup ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static OptionalGroup ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static OptionalGroup ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private OptionalGroup MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(OptionalGroup prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(OptionalGroup cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private OptionalGroup result; - - private OptionalGroup PrepareBuilder() { - if (resultIsReadOnly) { - OptionalGroup original = result; - result = new OptionalGroup(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override OptionalGroup MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.OptionalGroup.Descriptor; } - } - - public override OptionalGroup DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.OptionalGroup.DefaultInstance; } - } - - public override OptionalGroup BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is OptionalGroup) { - return MergeFrom((OptionalGroup) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(OptionalGroup other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.OptionalGroup.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasA) { - A = other.A; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_optionalGroupFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _optionalGroupFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 136: { - result.hasA = input.ReadInt32(ref result.a_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasA { - get { return result.hasA; } - } - public int A { - get { return result.A; } - set { SetA(value); } - } - public Builder SetA(int value) { - PrepareBuilder(); - result.hasA = true; - result.a_ = value; - return this; - } - public Builder ClearA() { - PrepareBuilder(); - result.hasA = false; - result.a_ = 0; - return this; - } - } - static OptionalGroup() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class RepeatedGroup : pb::GeneratedMessage { - private RepeatedGroup() { } - private static readonly RepeatedGroup defaultInstance = new RepeatedGroup().MakeReadOnly(); - private static readonly string[] _repeatedGroupFieldNames = new string[] { "a" }; - private static readonly uint[] _repeatedGroupFieldTags = new uint[] { 376 }; - public static RepeatedGroup DefaultInstance { - get { return defaultInstance; } - } - - public override RepeatedGroup DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override RepeatedGroup ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestAllTypes_RepeatedGroup__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestAllTypes_RepeatedGroup__FieldAccessorTable; } - } - - public const int AFieldNumber = 47; - private bool hasA; - private int a_; - public bool HasA { - get { return hasA; } - } - public int A { - get { return a_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _repeatedGroupFieldNames; - if (hasA) { - output.WriteInt32(47, field_names[0], A); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(47, A); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static RepeatedGroup ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static RepeatedGroup ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static RepeatedGroup ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static RepeatedGroup ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static RepeatedGroup ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static RepeatedGroup ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static RepeatedGroup ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static RepeatedGroup ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static RepeatedGroup ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static RepeatedGroup ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private RepeatedGroup MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(RepeatedGroup prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(RepeatedGroup cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private RepeatedGroup result; - - private RepeatedGroup PrepareBuilder() { - if (resultIsReadOnly) { - RepeatedGroup original = result; - result = new RepeatedGroup(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override RepeatedGroup MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup.Descriptor; } - } - - public override RepeatedGroup DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup.DefaultInstance; } - } - - public override RepeatedGroup BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is RepeatedGroup) { - return MergeFrom((RepeatedGroup) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(RepeatedGroup other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasA) { - A = other.A; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_repeatedGroupFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _repeatedGroupFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 376: { - result.hasA = input.ReadInt32(ref result.a_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasA { - get { return result.hasA; } - } - public int A { - get { return result.A; } - set { SetA(value); } - } - public Builder SetA(int value) { - PrepareBuilder(); - result.hasA = true; - result.a_ = value; - return this; - } - public Builder ClearA() { - PrepareBuilder(); - result.hasA = false; - result.a_ = 0; - return this; - } - } - static RepeatedGroup() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - } - #endregion - - public const int OptionalInt32FieldNumber = 1; - private bool hasOptionalInt32; - private int optionalInt32_; - public bool HasOptionalInt32 { - get { return hasOptionalInt32; } - } - public int OptionalInt32 { - get { return optionalInt32_; } - } - - public const int OptionalInt64FieldNumber = 2; - private bool hasOptionalInt64; - private long optionalInt64_; - public bool HasOptionalInt64 { - get { return hasOptionalInt64; } - } - public long OptionalInt64 { - get { return optionalInt64_; } - } - - public const int OptionalUint32FieldNumber = 3; - private bool hasOptionalUint32; - private uint optionalUint32_; - public bool HasOptionalUint32 { - get { return hasOptionalUint32; } - } - [global::System.CLSCompliant(false)] - public uint OptionalUint32 { - get { return optionalUint32_; } - } - - public const int OptionalUint64FieldNumber = 4; - private bool hasOptionalUint64; - private ulong optionalUint64_; - public bool HasOptionalUint64 { - get { return hasOptionalUint64; } - } - [global::System.CLSCompliant(false)] - public ulong OptionalUint64 { - get { return optionalUint64_; } - } - - public const int OptionalSint32FieldNumber = 5; - private bool hasOptionalSint32; - private int optionalSint32_; - public bool HasOptionalSint32 { - get { return hasOptionalSint32; } - } - public int OptionalSint32 { - get { return optionalSint32_; } - } - - public const int OptionalSint64FieldNumber = 6; - private bool hasOptionalSint64; - private long optionalSint64_; - public bool HasOptionalSint64 { - get { return hasOptionalSint64; } - } - public long OptionalSint64 { - get { return optionalSint64_; } - } - - public const int OptionalFixed32FieldNumber = 7; - private bool hasOptionalFixed32; - private uint optionalFixed32_; - public bool HasOptionalFixed32 { - get { return hasOptionalFixed32; } - } - [global::System.CLSCompliant(false)] - public uint OptionalFixed32 { - get { return optionalFixed32_; } - } - - public const int OptionalFixed64FieldNumber = 8; - private bool hasOptionalFixed64; - private ulong optionalFixed64_; - public bool HasOptionalFixed64 { - get { return hasOptionalFixed64; } - } - [global::System.CLSCompliant(false)] - public ulong OptionalFixed64 { - get { return optionalFixed64_; } - } - - public const int OptionalSfixed32FieldNumber = 9; - private bool hasOptionalSfixed32; - private int optionalSfixed32_; - public bool HasOptionalSfixed32 { - get { return hasOptionalSfixed32; } - } - public int OptionalSfixed32 { - get { return optionalSfixed32_; } - } - - public const int OptionalSfixed64FieldNumber = 10; - private bool hasOptionalSfixed64; - private long optionalSfixed64_; - public bool HasOptionalSfixed64 { - get { return hasOptionalSfixed64; } - } - public long OptionalSfixed64 { - get { return optionalSfixed64_; } - } - - public const int OptionalFloatFieldNumber = 11; - private bool hasOptionalFloat; - private float optionalFloat_; - public bool HasOptionalFloat { - get { return hasOptionalFloat; } - } - public float OptionalFloat { - get { return optionalFloat_; } - } - - public const int OptionalDoubleFieldNumber = 12; - private bool hasOptionalDouble; - private double optionalDouble_; - public bool HasOptionalDouble { - get { return hasOptionalDouble; } - } - public double OptionalDouble { - get { return optionalDouble_; } - } - - public const int OptionalBoolFieldNumber = 13; - private bool hasOptionalBool; - private bool optionalBool_; - public bool HasOptionalBool { - get { return hasOptionalBool; } - } - public bool OptionalBool { - get { return optionalBool_; } - } - - public const int OptionalStringFieldNumber = 14; - private bool hasOptionalString; - private string optionalString_ = ""; - public bool HasOptionalString { - get { return hasOptionalString; } - } - public string OptionalString { - get { return optionalString_; } - } - - public const int OptionalBytesFieldNumber = 15; - private bool hasOptionalBytes; - private pb::ByteString optionalBytes_ = pb::ByteString.Empty; - public bool HasOptionalBytes { - get { return hasOptionalBytes; } - } - public pb::ByteString OptionalBytes { - get { return optionalBytes_; } - } - - public const int OptionalGroupFieldNumber = 16; - private bool hasOptionalGroup; - private global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.OptionalGroup optionalGroup_; - public bool HasOptionalGroup { - get { return hasOptionalGroup; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.OptionalGroup OptionalGroup { - get { return optionalGroup_ ?? global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.OptionalGroup.DefaultInstance; } - } - - public const int OptionalNestedMessageFieldNumber = 18; - private bool hasOptionalNestedMessage; - private global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage optionalNestedMessage_; - public bool HasOptionalNestedMessage { - get { return hasOptionalNestedMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage OptionalNestedMessage { - get { return optionalNestedMessage_ ?? global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.DefaultInstance; } - } - - public const int OptionalForeignMessageFieldNumber = 19; - private bool hasOptionalForeignMessage; - private global::Google.ProtocolBuffers.TestProtos.ForeignMessage optionalForeignMessage_; - public bool HasOptionalForeignMessage { - get { return hasOptionalForeignMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignMessage OptionalForeignMessage { - get { return optionalForeignMessage_ ?? global::Google.ProtocolBuffers.TestProtos.ForeignMessage.DefaultInstance; } - } - - public const int OptionalImportMessageFieldNumber = 20; - private bool hasOptionalImportMessage; - private global::Google.ProtocolBuffers.TestProtos.ImportMessage optionalImportMessage_; - public bool HasOptionalImportMessage { - get { return hasOptionalImportMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.ImportMessage OptionalImportMessage { - get { return optionalImportMessage_ ?? global::Google.ProtocolBuffers.TestProtos.ImportMessage.DefaultInstance; } - } - - public const int OptionalNestedEnumFieldNumber = 21; - private bool hasOptionalNestedEnum; - private global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedEnum optionalNestedEnum_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedEnum.FOO; - public bool HasOptionalNestedEnum { - get { return hasOptionalNestedEnum; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedEnum OptionalNestedEnum { - get { return optionalNestedEnum_; } - } - - public const int OptionalForeignEnumFieldNumber = 22; - private bool hasOptionalForeignEnum; - private global::Google.ProtocolBuffers.TestProtos.ForeignEnum optionalForeignEnum_ = global::Google.ProtocolBuffers.TestProtos.ForeignEnum.FOREIGN_FOO; - public bool HasOptionalForeignEnum { - get { return hasOptionalForeignEnum; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignEnum OptionalForeignEnum { - get { return optionalForeignEnum_; } - } - - public const int OptionalImportEnumFieldNumber = 23; - private bool hasOptionalImportEnum; - private global::Google.ProtocolBuffers.TestProtos.ImportEnum optionalImportEnum_ = global::Google.ProtocolBuffers.TestProtos.ImportEnum.IMPORT_FOO; - public bool HasOptionalImportEnum { - get { return hasOptionalImportEnum; } - } - public global::Google.ProtocolBuffers.TestProtos.ImportEnum OptionalImportEnum { - get { return optionalImportEnum_; } - } - - public const int OptionalStringPieceFieldNumber = 24; - private bool hasOptionalStringPiece; - private string optionalStringPiece_ = ""; - public bool HasOptionalStringPiece { - get { return hasOptionalStringPiece; } - } - public string OptionalStringPiece { - get { return optionalStringPiece_; } - } - - public const int OptionalCordFieldNumber = 25; - private bool hasOptionalCord; - private string optionalCord_ = ""; - public bool HasOptionalCord { - get { return hasOptionalCord; } - } - public string OptionalCord { - get { return optionalCord_; } - } - - public const int OptionalPublicImportMessageFieldNumber = 26; - private bool hasOptionalPublicImportMessage; - private global::Google.ProtocolBuffers.TestProtos.PublicImportMessage optionalPublicImportMessage_; - public bool HasOptionalPublicImportMessage { - get { return hasOptionalPublicImportMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.PublicImportMessage OptionalPublicImportMessage { - get { return optionalPublicImportMessage_ ?? global::Google.ProtocolBuffers.TestProtos.PublicImportMessage.DefaultInstance; } - } - - public const int OptionalLazyMessageFieldNumber = 27; - private bool hasOptionalLazyMessage; - private global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage optionalLazyMessage_; - public bool HasOptionalLazyMessage { - get { return hasOptionalLazyMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage OptionalLazyMessage { - get { return optionalLazyMessage_ ?? global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.DefaultInstance; } - } - - public const int RepeatedInt32FieldNumber = 31; - private pbc::PopsicleList repeatedInt32_ = new pbc::PopsicleList(); - public scg::IList RepeatedInt32List { - get { return pbc::Lists.AsReadOnly(repeatedInt32_); } - } - public int RepeatedInt32Count { - get { return repeatedInt32_.Count; } - } - public int GetRepeatedInt32(int index) { - return repeatedInt32_[index]; - } - - public const int RepeatedInt64FieldNumber = 32; - private pbc::PopsicleList repeatedInt64_ = new pbc::PopsicleList(); - public scg::IList RepeatedInt64List { - get { return pbc::Lists.AsReadOnly(repeatedInt64_); } - } - public int RepeatedInt64Count { - get { return repeatedInt64_.Count; } - } - public long GetRepeatedInt64(int index) { - return repeatedInt64_[index]; - } - - public const int RepeatedUint32FieldNumber = 33; - private pbc::PopsicleList repeatedUint32_ = new pbc::PopsicleList(); - [global::System.CLSCompliant(false)] - public scg::IList RepeatedUint32List { - get { return pbc::Lists.AsReadOnly(repeatedUint32_); } - } - public int RepeatedUint32Count { - get { return repeatedUint32_.Count; } - } - [global::System.CLSCompliant(false)] - public uint GetRepeatedUint32(int index) { - return repeatedUint32_[index]; - } - - public const int RepeatedUint64FieldNumber = 34; - private pbc::PopsicleList repeatedUint64_ = new pbc::PopsicleList(); - [global::System.CLSCompliant(false)] - public scg::IList RepeatedUint64List { - get { return pbc::Lists.AsReadOnly(repeatedUint64_); } - } - public int RepeatedUint64Count { - get { return repeatedUint64_.Count; } - } - [global::System.CLSCompliant(false)] - public ulong GetRepeatedUint64(int index) { - return repeatedUint64_[index]; - } - - public const int RepeatedSint32FieldNumber = 35; - private pbc::PopsicleList repeatedSint32_ = new pbc::PopsicleList(); - public scg::IList RepeatedSint32List { - get { return pbc::Lists.AsReadOnly(repeatedSint32_); } - } - public int RepeatedSint32Count { - get { return repeatedSint32_.Count; } - } - public int GetRepeatedSint32(int index) { - return repeatedSint32_[index]; - } - - public const int RepeatedSint64FieldNumber = 36; - private pbc::PopsicleList repeatedSint64_ = new pbc::PopsicleList(); - public scg::IList RepeatedSint64List { - get { return pbc::Lists.AsReadOnly(repeatedSint64_); } - } - public int RepeatedSint64Count { - get { return repeatedSint64_.Count; } - } - public long GetRepeatedSint64(int index) { - return repeatedSint64_[index]; - } - - public const int RepeatedFixed32FieldNumber = 37; - private pbc::PopsicleList repeatedFixed32_ = new pbc::PopsicleList(); - [global::System.CLSCompliant(false)] - public scg::IList RepeatedFixed32List { - get { return pbc::Lists.AsReadOnly(repeatedFixed32_); } - } - public int RepeatedFixed32Count { - get { return repeatedFixed32_.Count; } - } - [global::System.CLSCompliant(false)] - public uint GetRepeatedFixed32(int index) { - return repeatedFixed32_[index]; - } - - public const int RepeatedFixed64FieldNumber = 38; - private pbc::PopsicleList repeatedFixed64_ = new pbc::PopsicleList(); - [global::System.CLSCompliant(false)] - public scg::IList RepeatedFixed64List { - get { return pbc::Lists.AsReadOnly(repeatedFixed64_); } - } - public int RepeatedFixed64Count { - get { return repeatedFixed64_.Count; } - } - [global::System.CLSCompliant(false)] - public ulong GetRepeatedFixed64(int index) { - return repeatedFixed64_[index]; - } - - public const int RepeatedSfixed32FieldNumber = 39; - private pbc::PopsicleList repeatedSfixed32_ = new pbc::PopsicleList(); - public scg::IList RepeatedSfixed32List { - get { return pbc::Lists.AsReadOnly(repeatedSfixed32_); } - } - public int RepeatedSfixed32Count { - get { return repeatedSfixed32_.Count; } - } - public int GetRepeatedSfixed32(int index) { - return repeatedSfixed32_[index]; - } - - public const int RepeatedSfixed64FieldNumber = 40; - private pbc::PopsicleList repeatedSfixed64_ = new pbc::PopsicleList(); - public scg::IList RepeatedSfixed64List { - get { return pbc::Lists.AsReadOnly(repeatedSfixed64_); } - } - public int RepeatedSfixed64Count { - get { return repeatedSfixed64_.Count; } - } - public long GetRepeatedSfixed64(int index) { - return repeatedSfixed64_[index]; - } - - public const int RepeatedFloatFieldNumber = 41; - private pbc::PopsicleList repeatedFloat_ = new pbc::PopsicleList(); - public scg::IList RepeatedFloatList { - get { return pbc::Lists.AsReadOnly(repeatedFloat_); } - } - public int RepeatedFloatCount { - get { return repeatedFloat_.Count; } - } - public float GetRepeatedFloat(int index) { - return repeatedFloat_[index]; - } - - public const int RepeatedDoubleFieldNumber = 42; - private pbc::PopsicleList repeatedDouble_ = new pbc::PopsicleList(); - public scg::IList RepeatedDoubleList { - get { return pbc::Lists.AsReadOnly(repeatedDouble_); } - } - public int RepeatedDoubleCount { - get { return repeatedDouble_.Count; } - } - public double GetRepeatedDouble(int index) { - return repeatedDouble_[index]; - } - - public const int RepeatedBoolFieldNumber = 43; - private pbc::PopsicleList repeatedBool_ = new pbc::PopsicleList(); - public scg::IList RepeatedBoolList { - get { return pbc::Lists.AsReadOnly(repeatedBool_); } - } - public int RepeatedBoolCount { - get { return repeatedBool_.Count; } - } - public bool GetRepeatedBool(int index) { - return repeatedBool_[index]; - } - - public const int RepeatedStringFieldNumber = 44; - private pbc::PopsicleList repeatedString_ = new pbc::PopsicleList(); - public scg::IList RepeatedStringList { - get { return pbc::Lists.AsReadOnly(repeatedString_); } - } - public int RepeatedStringCount { - get { return repeatedString_.Count; } - } - public string GetRepeatedString(int index) { - return repeatedString_[index]; - } - - public const int RepeatedBytesFieldNumber = 45; - private pbc::PopsicleList repeatedBytes_ = new pbc::PopsicleList(); - public scg::IList RepeatedBytesList { - get { return pbc::Lists.AsReadOnly(repeatedBytes_); } - } - public int RepeatedBytesCount { - get { return repeatedBytes_.Count; } - } - public pb::ByteString GetRepeatedBytes(int index) { - return repeatedBytes_[index]; - } - - public const int RepeatedGroupFieldNumber = 46; - private pbc::PopsicleList repeatedGroup_ = new pbc::PopsicleList(); - public scg::IList RepeatedGroupList { - get { return repeatedGroup_; } - } - public int RepeatedGroupCount { - get { return repeatedGroup_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup GetRepeatedGroup(int index) { - return repeatedGroup_[index]; - } - - public const int RepeatedNestedMessageFieldNumber = 48; - private pbc::PopsicleList repeatedNestedMessage_ = new pbc::PopsicleList(); - public scg::IList RepeatedNestedMessageList { - get { return repeatedNestedMessage_; } - } - public int RepeatedNestedMessageCount { - get { return repeatedNestedMessage_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage GetRepeatedNestedMessage(int index) { - return repeatedNestedMessage_[index]; - } - - public const int RepeatedForeignMessageFieldNumber = 49; - private pbc::PopsicleList repeatedForeignMessage_ = new pbc::PopsicleList(); - public scg::IList RepeatedForeignMessageList { - get { return repeatedForeignMessage_; } - } - public int RepeatedForeignMessageCount { - get { return repeatedForeignMessage_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignMessage GetRepeatedForeignMessage(int index) { - return repeatedForeignMessage_[index]; - } - - public const int RepeatedImportMessageFieldNumber = 50; - private pbc::PopsicleList repeatedImportMessage_ = new pbc::PopsicleList(); - public scg::IList RepeatedImportMessageList { - get { return repeatedImportMessage_; } - } - public int RepeatedImportMessageCount { - get { return repeatedImportMessage_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.ImportMessage GetRepeatedImportMessage(int index) { - return repeatedImportMessage_[index]; - } - - public const int RepeatedNestedEnumFieldNumber = 51; - private pbc::PopsicleList repeatedNestedEnum_ = new pbc::PopsicleList(); - public scg::IList RepeatedNestedEnumList { - get { return pbc::Lists.AsReadOnly(repeatedNestedEnum_); } - } - public int RepeatedNestedEnumCount { - get { return repeatedNestedEnum_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedEnum GetRepeatedNestedEnum(int index) { - return repeatedNestedEnum_[index]; - } - - public const int RepeatedForeignEnumFieldNumber = 52; - private pbc::PopsicleList repeatedForeignEnum_ = new pbc::PopsicleList(); - public scg::IList RepeatedForeignEnumList { - get { return pbc::Lists.AsReadOnly(repeatedForeignEnum_); } - } - public int RepeatedForeignEnumCount { - get { return repeatedForeignEnum_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignEnum GetRepeatedForeignEnum(int index) { - return repeatedForeignEnum_[index]; - } - - public const int RepeatedImportEnumFieldNumber = 53; - private pbc::PopsicleList repeatedImportEnum_ = new pbc::PopsicleList(); - public scg::IList RepeatedImportEnumList { - get { return pbc::Lists.AsReadOnly(repeatedImportEnum_); } - } - public int RepeatedImportEnumCount { - get { return repeatedImportEnum_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.ImportEnum GetRepeatedImportEnum(int index) { - return repeatedImportEnum_[index]; - } - - public const int RepeatedStringPieceFieldNumber = 54; - private pbc::PopsicleList repeatedStringPiece_ = new pbc::PopsicleList(); - public scg::IList RepeatedStringPieceList { - get { return pbc::Lists.AsReadOnly(repeatedStringPiece_); } - } - public int RepeatedStringPieceCount { - get { return repeatedStringPiece_.Count; } - } - public string GetRepeatedStringPiece(int index) { - return repeatedStringPiece_[index]; - } - - public const int RepeatedCordFieldNumber = 55; - private pbc::PopsicleList repeatedCord_ = new pbc::PopsicleList(); - public scg::IList RepeatedCordList { - get { return pbc::Lists.AsReadOnly(repeatedCord_); } - } - public int RepeatedCordCount { - get { return repeatedCord_.Count; } - } - public string GetRepeatedCord(int index) { - return repeatedCord_[index]; - } - - public const int RepeatedLazyMessageFieldNumber = 57; - private pbc::PopsicleList repeatedLazyMessage_ = new pbc::PopsicleList(); - public scg::IList RepeatedLazyMessageList { - get { return repeatedLazyMessage_; } - } - public int RepeatedLazyMessageCount { - get { return repeatedLazyMessage_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage GetRepeatedLazyMessage(int index) { - return repeatedLazyMessage_[index]; - } - - public const int DefaultInt32FieldNumber = 61; - private bool hasDefaultInt32; - private int defaultInt32_ = 41; - public bool HasDefaultInt32 { - get { return hasDefaultInt32; } - } - public int DefaultInt32 { - get { return defaultInt32_; } - } - - public const int DefaultInt64FieldNumber = 62; - private bool hasDefaultInt64; - private long defaultInt64_ = 42L; - public bool HasDefaultInt64 { - get { return hasDefaultInt64; } - } - public long DefaultInt64 { - get { return defaultInt64_; } - } - - public const int DefaultUint32FieldNumber = 63; - private bool hasDefaultUint32; - private uint defaultUint32_ = 43; - public bool HasDefaultUint32 { - get { return hasDefaultUint32; } - } - [global::System.CLSCompliant(false)] - public uint DefaultUint32 { - get { return defaultUint32_; } - } - - public const int DefaultUint64FieldNumber = 64; - private bool hasDefaultUint64; - private ulong defaultUint64_ = 44UL; - public bool HasDefaultUint64 { - get { return hasDefaultUint64; } - } - [global::System.CLSCompliant(false)] - public ulong DefaultUint64 { - get { return defaultUint64_; } - } - - public const int DefaultSint32FieldNumber = 65; - private bool hasDefaultSint32; - private int defaultSint32_ = -45; - public bool HasDefaultSint32 { - get { return hasDefaultSint32; } - } - public int DefaultSint32 { - get { return defaultSint32_; } - } - - public const int DefaultSint64FieldNumber = 66; - private bool hasDefaultSint64; - private long defaultSint64_ = 46L; - public bool HasDefaultSint64 { - get { return hasDefaultSint64; } - } - public long DefaultSint64 { - get { return defaultSint64_; } - } - - public const int DefaultFixed32FieldNumber = 67; - private bool hasDefaultFixed32; - private uint defaultFixed32_ = 47; - public bool HasDefaultFixed32 { - get { return hasDefaultFixed32; } - } - [global::System.CLSCompliant(false)] - public uint DefaultFixed32 { - get { return defaultFixed32_; } - } - - public const int DefaultFixed64FieldNumber = 68; - private bool hasDefaultFixed64; - private ulong defaultFixed64_ = 48UL; - public bool HasDefaultFixed64 { - get { return hasDefaultFixed64; } - } - [global::System.CLSCompliant(false)] - public ulong DefaultFixed64 { - get { return defaultFixed64_; } - } - - public const int DefaultSfixed32FieldNumber = 69; - private bool hasDefaultSfixed32; - private int defaultSfixed32_ = 49; - public bool HasDefaultSfixed32 { - get { return hasDefaultSfixed32; } - } - public int DefaultSfixed32 { - get { return defaultSfixed32_; } - } - - public const int DefaultSfixed64FieldNumber = 70; - private bool hasDefaultSfixed64; - private long defaultSfixed64_ = -50L; - public bool HasDefaultSfixed64 { - get { return hasDefaultSfixed64; } - } - public long DefaultSfixed64 { - get { return defaultSfixed64_; } - } - - public const int DefaultFloatFieldNumber = 71; - private bool hasDefaultFloat; - private float defaultFloat_ = 51.5F; - public bool HasDefaultFloat { - get { return hasDefaultFloat; } - } - public float DefaultFloat { - get { return defaultFloat_; } - } - - public const int DefaultDoubleFieldNumber = 72; - private bool hasDefaultDouble; - private double defaultDouble_ = 52000D; - public bool HasDefaultDouble { - get { return hasDefaultDouble; } - } - public double DefaultDouble { - get { return defaultDouble_; } - } - - public const int DefaultBoolFieldNumber = 73; - private bool hasDefaultBool; - private bool defaultBool_ = true; - public bool HasDefaultBool { - get { return hasDefaultBool; } - } - public bool DefaultBool { - get { return defaultBool_; } - } - - public const int DefaultStringFieldNumber = 74; - private bool hasDefaultString; - private string defaultString_ = "hello"; - public bool HasDefaultString { - get { return hasDefaultString; } - } - public string DefaultString { - get { return defaultString_; } - } - - public const int DefaultBytesFieldNumber = 75; - private bool hasDefaultBytes; - private pb::ByteString defaultBytes_ = (pb::ByteString) global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Descriptor.Fields[65].DefaultValue; - public bool HasDefaultBytes { - get { return hasDefaultBytes; } - } - public pb::ByteString DefaultBytes { - get { return defaultBytes_; } - } - - public const int DefaultNestedEnumFieldNumber = 81; - private bool hasDefaultNestedEnum; - private global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedEnum defaultNestedEnum_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedEnum.BAR; - public bool HasDefaultNestedEnum { - get { return hasDefaultNestedEnum; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedEnum DefaultNestedEnum { - get { return defaultNestedEnum_; } - } - - public const int DefaultForeignEnumFieldNumber = 82; - private bool hasDefaultForeignEnum; - private global::Google.ProtocolBuffers.TestProtos.ForeignEnum defaultForeignEnum_ = global::Google.ProtocolBuffers.TestProtos.ForeignEnum.FOREIGN_BAR; - public bool HasDefaultForeignEnum { - get { return hasDefaultForeignEnum; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignEnum DefaultForeignEnum { - get { return defaultForeignEnum_; } - } - - public const int DefaultImportEnumFieldNumber = 83; - private bool hasDefaultImportEnum; - private global::Google.ProtocolBuffers.TestProtos.ImportEnum defaultImportEnum_ = global::Google.ProtocolBuffers.TestProtos.ImportEnum.IMPORT_BAR; - public bool HasDefaultImportEnum { - get { return hasDefaultImportEnum; } - } - public global::Google.ProtocolBuffers.TestProtos.ImportEnum DefaultImportEnum { - get { return defaultImportEnum_; } - } - - public const int DefaultStringPieceFieldNumber = 84; - private bool hasDefaultStringPiece; - private string defaultStringPiece_ = "abc"; - public bool HasDefaultStringPiece { - get { return hasDefaultStringPiece; } - } - public string DefaultStringPiece { - get { return defaultStringPiece_; } - } - - public const int DefaultCordFieldNumber = 85; - private bool hasDefaultCord; - private string defaultCord_ = "123"; - public bool HasDefaultCord { - get { return hasDefaultCord; } - } - public string DefaultCord { - get { return defaultCord_; } - } - - public const int OneofUint32FieldNumber = 111; - private bool hasOneofUint32; - private uint oneofUint32_; - public bool HasOneofUint32 { - get { return hasOneofUint32; } - } - [global::System.CLSCompliant(false)] - public uint OneofUint32 { - get { return oneofUint32_; } - } - - public const int OneofNestedMessageFieldNumber = 112; - private bool hasOneofNestedMessage; - private global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage oneofNestedMessage_; - public bool HasOneofNestedMessage { - get { return hasOneofNestedMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage OneofNestedMessage { - get { return oneofNestedMessage_ ?? global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.DefaultInstance; } - } - - public const int OneofStringFieldNumber = 113; - private bool hasOneofString; - private string oneofString_ = ""; - public bool HasOneofString { - get { return hasOneofString; } - } - public string OneofString { - get { return oneofString_; } - } - - public const int OneofBytesFieldNumber = 114; - private bool hasOneofBytes; - private pb::ByteString oneofBytes_ = pb::ByteString.Empty; - public bool HasOneofBytes { - get { return hasOneofBytes; } - } - public pb::ByteString OneofBytes { - get { return oneofBytes_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testAllTypesFieldNames; - if (hasOptionalInt32) { - output.WriteInt32(1, field_names[35], OptionalInt32); - } - if (hasOptionalInt64) { - output.WriteInt64(2, field_names[36], OptionalInt64); - } - if (hasOptionalUint32) { - output.WriteUInt32(3, field_names[47], OptionalUint32); - } - if (hasOptionalUint64) { - output.WriteUInt64(4, field_names[48], OptionalUint64); - } - if (hasOptionalSint32) { - output.WriteSInt32(5, field_names[43], OptionalSint32); - } - if (hasOptionalSint64) { - output.WriteSInt64(6, field_names[44], OptionalSint64); - } - if (hasOptionalFixed32) { - output.WriteFixed32(7, field_names[28], OptionalFixed32); - } - if (hasOptionalFixed64) { - output.WriteFixed64(8, field_names[29], OptionalFixed64); - } - if (hasOptionalSfixed32) { - output.WriteSFixed32(9, field_names[41], OptionalSfixed32); - } - if (hasOptionalSfixed64) { - output.WriteSFixed64(10, field_names[42], OptionalSfixed64); - } - if (hasOptionalFloat) { - output.WriteFloat(11, field_names[30], OptionalFloat); - } - if (hasOptionalDouble) { - output.WriteDouble(12, field_names[27], OptionalDouble); - } - if (hasOptionalBool) { - output.WriteBool(13, field_names[24], OptionalBool); - } - if (hasOptionalString) { - output.WriteString(14, field_names[45], OptionalString); - } - if (hasOptionalBytes) { - output.WriteBytes(15, field_names[25], OptionalBytes); - } - if (hasOptionalGroup) { - output.WriteGroup(16, field_names[49], OptionalGroup); - } - if (hasOptionalNestedMessage) { - output.WriteMessage(18, field_names[39], OptionalNestedMessage); - } - if (hasOptionalForeignMessage) { - output.WriteMessage(19, field_names[32], OptionalForeignMessage); - } - if (hasOptionalImportMessage) { - output.WriteMessage(20, field_names[34], OptionalImportMessage); - } - if (hasOptionalNestedEnum) { - output.WriteEnum(21, field_names[38], (int) OptionalNestedEnum, OptionalNestedEnum); - } - if (hasOptionalForeignEnum) { - output.WriteEnum(22, field_names[31], (int) OptionalForeignEnum, OptionalForeignEnum); - } - if (hasOptionalImportEnum) { - output.WriteEnum(23, field_names[33], (int) OptionalImportEnum, OptionalImportEnum); - } - if (hasOptionalStringPiece) { - output.WriteString(24, field_names[46], OptionalStringPiece); - } - if (hasOptionalCord) { - output.WriteString(25, field_names[26], OptionalCord); - } - if (hasOptionalPublicImportMessage) { - output.WriteMessage(26, field_names[40], OptionalPublicImportMessage); - } - if (hasOptionalLazyMessage) { - output.WriteMessage(27, field_names[37], OptionalLazyMessage); - } - if (repeatedInt32_.Count > 0) { - output.WriteInt32Array(31, field_names[61], repeatedInt32_); - } - if (repeatedInt64_.Count > 0) { - output.WriteInt64Array(32, field_names[62], repeatedInt64_); - } - if (repeatedUint32_.Count > 0) { - output.WriteUInt32Array(33, field_names[72], repeatedUint32_); - } - if (repeatedUint64_.Count > 0) { - output.WriteUInt64Array(34, field_names[73], repeatedUint64_); - } - if (repeatedSint32_.Count > 0) { - output.WriteSInt32Array(35, field_names[68], repeatedSint32_); - } - if (repeatedSint64_.Count > 0) { - output.WriteSInt64Array(36, field_names[69], repeatedSint64_); - } - if (repeatedFixed32_.Count > 0) { - output.WriteFixed32Array(37, field_names[54], repeatedFixed32_); - } - if (repeatedFixed64_.Count > 0) { - output.WriteFixed64Array(38, field_names[55], repeatedFixed64_); - } - if (repeatedSfixed32_.Count > 0) { - output.WriteSFixed32Array(39, field_names[66], repeatedSfixed32_); - } - if (repeatedSfixed64_.Count > 0) { - output.WriteSFixed64Array(40, field_names[67], repeatedSfixed64_); - } - if (repeatedFloat_.Count > 0) { - output.WriteFloatArray(41, field_names[56], repeatedFloat_); - } - if (repeatedDouble_.Count > 0) { - output.WriteDoubleArray(42, field_names[53], repeatedDouble_); - } - if (repeatedBool_.Count > 0) { - output.WriteBoolArray(43, field_names[50], repeatedBool_); - } - if (repeatedString_.Count > 0) { - output.WriteStringArray(44, field_names[70], repeatedString_); - } - if (repeatedBytes_.Count > 0) { - output.WriteBytesArray(45, field_names[51], repeatedBytes_); - } - if (repeatedGroup_.Count > 0) { - output.WriteGroupArray(46, field_names[74], repeatedGroup_); - } - if (repeatedNestedMessage_.Count > 0) { - output.WriteMessageArray(48, field_names[65], repeatedNestedMessage_); - } - if (repeatedForeignMessage_.Count > 0) { - output.WriteMessageArray(49, field_names[58], repeatedForeignMessage_); - } - if (repeatedImportMessage_.Count > 0) { - output.WriteMessageArray(50, field_names[60], repeatedImportMessage_); - } - if (repeatedNestedEnum_.Count > 0) { - output.WriteEnumArray(51, field_names[64], repeatedNestedEnum_); - } - if (repeatedForeignEnum_.Count > 0) { - output.WriteEnumArray(52, field_names[57], repeatedForeignEnum_); - } - if (repeatedImportEnum_.Count > 0) { - output.WriteEnumArray(53, field_names[59], repeatedImportEnum_); - } - if (repeatedStringPiece_.Count > 0) { - output.WriteStringArray(54, field_names[71], repeatedStringPiece_); - } - if (repeatedCord_.Count > 0) { - output.WriteStringArray(55, field_names[52], repeatedCord_); - } - if (repeatedLazyMessage_.Count > 0) { - output.WriteMessageArray(57, field_names[63], repeatedLazyMessage_); - } - if (hasDefaultInt32) { - output.WriteInt32(61, field_names[9], DefaultInt32); - } - if (hasDefaultInt64) { - output.WriteInt64(62, field_names[10], DefaultInt64); - } - if (hasDefaultUint32) { - output.WriteUInt32(63, field_names[18], DefaultUint32); - } - if (hasDefaultUint64) { - output.WriteUInt64(64, field_names[19], DefaultUint64); - } - if (hasDefaultSint32) { - output.WriteSInt32(65, field_names[14], DefaultSint32); - } - if (hasDefaultSint64) { - output.WriteSInt64(66, field_names[15], DefaultSint64); - } - if (hasDefaultFixed32) { - output.WriteFixed32(67, field_names[4], DefaultFixed32); - } - if (hasDefaultFixed64) { - output.WriteFixed64(68, field_names[5], DefaultFixed64); - } - if (hasDefaultSfixed32) { - output.WriteSFixed32(69, field_names[12], DefaultSfixed32); - } - if (hasDefaultSfixed64) { - output.WriteSFixed64(70, field_names[13], DefaultSfixed64); - } - if (hasDefaultFloat) { - output.WriteFloat(71, field_names[6], DefaultFloat); - } - if (hasDefaultDouble) { - output.WriteDouble(72, field_names[3], DefaultDouble); - } - if (hasDefaultBool) { - output.WriteBool(73, field_names[0], DefaultBool); - } - if (hasDefaultString) { - output.WriteString(74, field_names[16], DefaultString); - } - if (hasDefaultBytes) { - output.WriteBytes(75, field_names[1], DefaultBytes); - } - if (hasDefaultNestedEnum) { - output.WriteEnum(81, field_names[11], (int) DefaultNestedEnum, DefaultNestedEnum); - } - if (hasDefaultForeignEnum) { - output.WriteEnum(82, field_names[7], (int) DefaultForeignEnum, DefaultForeignEnum); - } - if (hasDefaultImportEnum) { - output.WriteEnum(83, field_names[8], (int) DefaultImportEnum, DefaultImportEnum); - } - if (hasDefaultStringPiece) { - output.WriteString(84, field_names[17], DefaultStringPiece); - } - if (hasDefaultCord) { - output.WriteString(85, field_names[2], DefaultCord); - } - if (hasOneofUint32) { - output.WriteUInt32(111, field_names[23], OneofUint32); - } - if (hasOneofNestedMessage) { - output.WriteMessage(112, field_names[21], OneofNestedMessage); - } - if (hasOneofString) { - output.WriteString(113, field_names[22], OneofString); - } - if (hasOneofBytes) { - output.WriteBytes(114, field_names[20], OneofBytes); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasOptionalInt32) { - size += pb::CodedOutputStream.ComputeInt32Size(1, OptionalInt32); - } - if (hasOptionalInt64) { - size += pb::CodedOutputStream.ComputeInt64Size(2, OptionalInt64); - } - if (hasOptionalUint32) { - size += pb::CodedOutputStream.ComputeUInt32Size(3, OptionalUint32); - } - if (hasOptionalUint64) { - size += pb::CodedOutputStream.ComputeUInt64Size(4, OptionalUint64); - } - if (hasOptionalSint32) { - size += pb::CodedOutputStream.ComputeSInt32Size(5, OptionalSint32); - } - if (hasOptionalSint64) { - size += pb::CodedOutputStream.ComputeSInt64Size(6, OptionalSint64); - } - if (hasOptionalFixed32) { - size += pb::CodedOutputStream.ComputeFixed32Size(7, OptionalFixed32); - } - if (hasOptionalFixed64) { - size += pb::CodedOutputStream.ComputeFixed64Size(8, OptionalFixed64); - } - if (hasOptionalSfixed32) { - size += pb::CodedOutputStream.ComputeSFixed32Size(9, OptionalSfixed32); - } - if (hasOptionalSfixed64) { - size += pb::CodedOutputStream.ComputeSFixed64Size(10, OptionalSfixed64); - } - if (hasOptionalFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(11, OptionalFloat); - } - if (hasOptionalDouble) { - size += pb::CodedOutputStream.ComputeDoubleSize(12, OptionalDouble); - } - if (hasOptionalBool) { - size += pb::CodedOutputStream.ComputeBoolSize(13, OptionalBool); - } - if (hasOptionalString) { - size += pb::CodedOutputStream.ComputeStringSize(14, OptionalString); - } - if (hasOptionalBytes) { - size += pb::CodedOutputStream.ComputeBytesSize(15, OptionalBytes); - } - if (hasOptionalGroup) { - size += pb::CodedOutputStream.ComputeGroupSize(16, OptionalGroup); - } - if (hasOptionalNestedMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(18, OptionalNestedMessage); - } - if (hasOptionalForeignMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(19, OptionalForeignMessage); - } - if (hasOptionalImportMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(20, OptionalImportMessage); - } - if (hasOptionalNestedEnum) { - size += pb::CodedOutputStream.ComputeEnumSize(21, (int) OptionalNestedEnum); - } - if (hasOptionalForeignEnum) { - size += pb::CodedOutputStream.ComputeEnumSize(22, (int) OptionalForeignEnum); - } - if (hasOptionalImportEnum) { - size += pb::CodedOutputStream.ComputeEnumSize(23, (int) OptionalImportEnum); - } - if (hasOptionalStringPiece) { - size += pb::CodedOutputStream.ComputeStringSize(24, OptionalStringPiece); - } - if (hasOptionalCord) { - size += pb::CodedOutputStream.ComputeStringSize(25, OptionalCord); - } - if (hasOptionalPublicImportMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(26, OptionalPublicImportMessage); - } - if (hasOptionalLazyMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(27, OptionalLazyMessage); - } - { - int dataSize = 0; - foreach (int element in RepeatedInt32List) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedInt32_.Count; - } - { - int dataSize = 0; - foreach (long element in RepeatedInt64List) { - dataSize += pb::CodedOutputStream.ComputeInt64SizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedInt64_.Count; - } - { - int dataSize = 0; - foreach (uint element in RepeatedUint32List) { - dataSize += pb::CodedOutputStream.ComputeUInt32SizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedUint32_.Count; - } - { - int dataSize = 0; - foreach (ulong element in RepeatedUint64List) { - dataSize += pb::CodedOutputStream.ComputeUInt64SizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedUint64_.Count; - } - { - int dataSize = 0; - foreach (int element in RepeatedSint32List) { - dataSize += pb::CodedOutputStream.ComputeSInt32SizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedSint32_.Count; - } - { - int dataSize = 0; - foreach (long element in RepeatedSint64List) { - dataSize += pb::CodedOutputStream.ComputeSInt64SizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedSint64_.Count; - } - { - int dataSize = 0; - dataSize = 4 * repeatedFixed32_.Count; - size += dataSize; - size += 2 * repeatedFixed32_.Count; - } - { - int dataSize = 0; - dataSize = 8 * repeatedFixed64_.Count; - size += dataSize; - size += 2 * repeatedFixed64_.Count; - } - { - int dataSize = 0; - dataSize = 4 * repeatedSfixed32_.Count; - size += dataSize; - size += 2 * repeatedSfixed32_.Count; - } - { - int dataSize = 0; - dataSize = 8 * repeatedSfixed64_.Count; - size += dataSize; - size += 2 * repeatedSfixed64_.Count; - } - { - int dataSize = 0; - dataSize = 4 * repeatedFloat_.Count; - size += dataSize; - size += 2 * repeatedFloat_.Count; - } - { - int dataSize = 0; - dataSize = 8 * repeatedDouble_.Count; - size += dataSize; - size += 2 * repeatedDouble_.Count; - } - { - int dataSize = 0; - dataSize = 1 * repeatedBool_.Count; - size += dataSize; - size += 2 * repeatedBool_.Count; - } - { - int dataSize = 0; - foreach (string element in RepeatedStringList) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedString_.Count; - } - { - int dataSize = 0; - foreach (pb::ByteString element in RepeatedBytesList) { - dataSize += pb::CodedOutputStream.ComputeBytesSizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedBytes_.Count; - } - foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup element in RepeatedGroupList) { - size += pb::CodedOutputStream.ComputeGroupSize(46, element); - } - foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage element in RepeatedNestedMessageList) { - size += pb::CodedOutputStream.ComputeMessageSize(48, element); - } - foreach (global::Google.ProtocolBuffers.TestProtos.ForeignMessage element in RepeatedForeignMessageList) { - size += pb::CodedOutputStream.ComputeMessageSize(49, element); - } - foreach (global::Google.ProtocolBuffers.TestProtos.ImportMessage element in RepeatedImportMessageList) { - size += pb::CodedOutputStream.ComputeMessageSize(50, element); - } - { - int dataSize = 0; - if (repeatedNestedEnum_.Count > 0) { - foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedEnum element in repeatedNestedEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 2 * repeatedNestedEnum_.Count; - } - } - { - int dataSize = 0; - if (repeatedForeignEnum_.Count > 0) { - foreach (global::Google.ProtocolBuffers.TestProtos.ForeignEnum element in repeatedForeignEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 2 * repeatedForeignEnum_.Count; - } - } - { - int dataSize = 0; - if (repeatedImportEnum_.Count > 0) { - foreach (global::Google.ProtocolBuffers.TestProtos.ImportEnum element in repeatedImportEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 2 * repeatedImportEnum_.Count; - } - } - { - int dataSize = 0; - foreach (string element in RepeatedStringPieceList) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedStringPiece_.Count; - } - { - int dataSize = 0; - foreach (string element in RepeatedCordList) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedCord_.Count; - } - foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage element in RepeatedLazyMessageList) { - size += pb::CodedOutputStream.ComputeMessageSize(57, element); - } - if (hasDefaultInt32) { - size += pb::CodedOutputStream.ComputeInt32Size(61, DefaultInt32); - } - if (hasDefaultInt64) { - size += pb::CodedOutputStream.ComputeInt64Size(62, DefaultInt64); - } - if (hasDefaultUint32) { - size += pb::CodedOutputStream.ComputeUInt32Size(63, DefaultUint32); - } - if (hasDefaultUint64) { - size += pb::CodedOutputStream.ComputeUInt64Size(64, DefaultUint64); - } - if (hasDefaultSint32) { - size += pb::CodedOutputStream.ComputeSInt32Size(65, DefaultSint32); - } - if (hasDefaultSint64) { - size += pb::CodedOutputStream.ComputeSInt64Size(66, DefaultSint64); - } - if (hasDefaultFixed32) { - size += pb::CodedOutputStream.ComputeFixed32Size(67, DefaultFixed32); - } - if (hasDefaultFixed64) { - size += pb::CodedOutputStream.ComputeFixed64Size(68, DefaultFixed64); - } - if (hasDefaultSfixed32) { - size += pb::CodedOutputStream.ComputeSFixed32Size(69, DefaultSfixed32); - } - if (hasDefaultSfixed64) { - size += pb::CodedOutputStream.ComputeSFixed64Size(70, DefaultSfixed64); - } - if (hasDefaultFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(71, DefaultFloat); - } - if (hasDefaultDouble) { - size += pb::CodedOutputStream.ComputeDoubleSize(72, DefaultDouble); - } - if (hasDefaultBool) { - size += pb::CodedOutputStream.ComputeBoolSize(73, DefaultBool); - } - if (hasDefaultString) { - size += pb::CodedOutputStream.ComputeStringSize(74, DefaultString); - } - if (hasDefaultBytes) { - size += pb::CodedOutputStream.ComputeBytesSize(75, DefaultBytes); - } - if (hasDefaultNestedEnum) { - size += pb::CodedOutputStream.ComputeEnumSize(81, (int) DefaultNestedEnum); - } - if (hasDefaultForeignEnum) { - size += pb::CodedOutputStream.ComputeEnumSize(82, (int) DefaultForeignEnum); - } - if (hasDefaultImportEnum) { - size += pb::CodedOutputStream.ComputeEnumSize(83, (int) DefaultImportEnum); - } - if (hasDefaultStringPiece) { - size += pb::CodedOutputStream.ComputeStringSize(84, DefaultStringPiece); - } - if (hasDefaultCord) { - size += pb::CodedOutputStream.ComputeStringSize(85, DefaultCord); - } - if (hasOneofUint32) { - size += pb::CodedOutputStream.ComputeUInt32Size(111, OneofUint32); - } - if (hasOneofNestedMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(112, OneofNestedMessage); - } - if (hasOneofString) { - size += pb::CodedOutputStream.ComputeStringSize(113, OneofString); - } - if (hasOneofBytes) { - size += pb::CodedOutputStream.ComputeBytesSize(114, OneofBytes); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestAllTypes ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestAllTypes ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestAllTypes ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestAllTypes ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestAllTypes ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestAllTypes ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestAllTypes ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestAllTypes ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestAllTypes ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestAllTypes ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestAllTypes MakeReadOnly() { - repeatedInt32_.MakeReadOnly(); - repeatedInt64_.MakeReadOnly(); - repeatedUint32_.MakeReadOnly(); - repeatedUint64_.MakeReadOnly(); - repeatedSint32_.MakeReadOnly(); - repeatedSint64_.MakeReadOnly(); - repeatedFixed32_.MakeReadOnly(); - repeatedFixed64_.MakeReadOnly(); - repeatedSfixed32_.MakeReadOnly(); - repeatedSfixed64_.MakeReadOnly(); - repeatedFloat_.MakeReadOnly(); - repeatedDouble_.MakeReadOnly(); - repeatedBool_.MakeReadOnly(); - repeatedString_.MakeReadOnly(); - repeatedBytes_.MakeReadOnly(); - repeatedGroup_.MakeReadOnly(); - repeatedNestedMessage_.MakeReadOnly(); - repeatedForeignMessage_.MakeReadOnly(); - repeatedImportMessage_.MakeReadOnly(); - repeatedNestedEnum_.MakeReadOnly(); - repeatedForeignEnum_.MakeReadOnly(); - repeatedImportEnum_.MakeReadOnly(); - repeatedStringPiece_.MakeReadOnly(); - repeatedCord_.MakeReadOnly(); - repeatedLazyMessage_.MakeReadOnly(); - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestAllTypes prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestAllTypes cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestAllTypes result; - - private TestAllTypes PrepareBuilder() { - if (resultIsReadOnly) { - TestAllTypes original = result; - result = new TestAllTypes(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestAllTypes MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Descriptor; } - } - - public override TestAllTypes DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance; } - } - - public override TestAllTypes BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestAllTypes) { - return MergeFrom((TestAllTypes) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestAllTypes other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasOptionalInt32) { - OptionalInt32 = other.OptionalInt32; - } - if (other.HasOptionalInt64) { - OptionalInt64 = other.OptionalInt64; - } - if (other.HasOptionalUint32) { - OptionalUint32 = other.OptionalUint32; - } - if (other.HasOptionalUint64) { - OptionalUint64 = other.OptionalUint64; - } - if (other.HasOptionalSint32) { - OptionalSint32 = other.OptionalSint32; - } - if (other.HasOptionalSint64) { - OptionalSint64 = other.OptionalSint64; - } - if (other.HasOptionalFixed32) { - OptionalFixed32 = other.OptionalFixed32; - } - if (other.HasOptionalFixed64) { - OptionalFixed64 = other.OptionalFixed64; - } - if (other.HasOptionalSfixed32) { - OptionalSfixed32 = other.OptionalSfixed32; - } - if (other.HasOptionalSfixed64) { - OptionalSfixed64 = other.OptionalSfixed64; - } - if (other.HasOptionalFloat) { - OptionalFloat = other.OptionalFloat; - } - if (other.HasOptionalDouble) { - OptionalDouble = other.OptionalDouble; - } - if (other.HasOptionalBool) { - OptionalBool = other.OptionalBool; - } - if (other.HasOptionalString) { - OptionalString = other.OptionalString; - } - if (other.HasOptionalBytes) { - OptionalBytes = other.OptionalBytes; - } - if (other.HasOptionalGroup) { - MergeOptionalGroup(other.OptionalGroup); - } - if (other.HasOptionalNestedMessage) { - MergeOptionalNestedMessage(other.OptionalNestedMessage); - } - if (other.HasOptionalForeignMessage) { - MergeOptionalForeignMessage(other.OptionalForeignMessage); - } - if (other.HasOptionalImportMessage) { - MergeOptionalImportMessage(other.OptionalImportMessage); - } - if (other.HasOptionalNestedEnum) { - OptionalNestedEnum = other.OptionalNestedEnum; - } - if (other.HasOptionalForeignEnum) { - OptionalForeignEnum = other.OptionalForeignEnum; - } - if (other.HasOptionalImportEnum) { - OptionalImportEnum = other.OptionalImportEnum; - } - if (other.HasOptionalStringPiece) { - OptionalStringPiece = other.OptionalStringPiece; - } - if (other.HasOptionalCord) { - OptionalCord = other.OptionalCord; - } - if (other.HasOptionalPublicImportMessage) { - MergeOptionalPublicImportMessage(other.OptionalPublicImportMessage); - } - if (other.HasOptionalLazyMessage) { - MergeOptionalLazyMessage(other.OptionalLazyMessage); - } - if (other.repeatedInt32_.Count != 0) { - result.repeatedInt32_.Add(other.repeatedInt32_); - } - if (other.repeatedInt64_.Count != 0) { - result.repeatedInt64_.Add(other.repeatedInt64_); - } - if (other.repeatedUint32_.Count != 0) { - result.repeatedUint32_.Add(other.repeatedUint32_); - } - if (other.repeatedUint64_.Count != 0) { - result.repeatedUint64_.Add(other.repeatedUint64_); - } - if (other.repeatedSint32_.Count != 0) { - result.repeatedSint32_.Add(other.repeatedSint32_); - } - if (other.repeatedSint64_.Count != 0) { - result.repeatedSint64_.Add(other.repeatedSint64_); - } - if (other.repeatedFixed32_.Count != 0) { - result.repeatedFixed32_.Add(other.repeatedFixed32_); - } - if (other.repeatedFixed64_.Count != 0) { - result.repeatedFixed64_.Add(other.repeatedFixed64_); - } - if (other.repeatedSfixed32_.Count != 0) { - result.repeatedSfixed32_.Add(other.repeatedSfixed32_); - } - if (other.repeatedSfixed64_.Count != 0) { - result.repeatedSfixed64_.Add(other.repeatedSfixed64_); - } - if (other.repeatedFloat_.Count != 0) { - result.repeatedFloat_.Add(other.repeatedFloat_); - } - if (other.repeatedDouble_.Count != 0) { - result.repeatedDouble_.Add(other.repeatedDouble_); - } - if (other.repeatedBool_.Count != 0) { - result.repeatedBool_.Add(other.repeatedBool_); - } - if (other.repeatedString_.Count != 0) { - result.repeatedString_.Add(other.repeatedString_); - } - if (other.repeatedBytes_.Count != 0) { - result.repeatedBytes_.Add(other.repeatedBytes_); - } - if (other.repeatedGroup_.Count != 0) { - result.repeatedGroup_.Add(other.repeatedGroup_); - } - if (other.repeatedNestedMessage_.Count != 0) { - result.repeatedNestedMessage_.Add(other.repeatedNestedMessage_); - } - if (other.repeatedForeignMessage_.Count != 0) { - result.repeatedForeignMessage_.Add(other.repeatedForeignMessage_); - } - if (other.repeatedImportMessage_.Count != 0) { - result.repeatedImportMessage_.Add(other.repeatedImportMessage_); - } - if (other.repeatedNestedEnum_.Count != 0) { - result.repeatedNestedEnum_.Add(other.repeatedNestedEnum_); - } - if (other.repeatedForeignEnum_.Count != 0) { - result.repeatedForeignEnum_.Add(other.repeatedForeignEnum_); - } - if (other.repeatedImportEnum_.Count != 0) { - result.repeatedImportEnum_.Add(other.repeatedImportEnum_); - } - if (other.repeatedStringPiece_.Count != 0) { - result.repeatedStringPiece_.Add(other.repeatedStringPiece_); - } - if (other.repeatedCord_.Count != 0) { - result.repeatedCord_.Add(other.repeatedCord_); - } - if (other.repeatedLazyMessage_.Count != 0) { - result.repeatedLazyMessage_.Add(other.repeatedLazyMessage_); - } - if (other.HasDefaultInt32) { - DefaultInt32 = other.DefaultInt32; - } - if (other.HasDefaultInt64) { - DefaultInt64 = other.DefaultInt64; - } - if (other.HasDefaultUint32) { - DefaultUint32 = other.DefaultUint32; - } - if (other.HasDefaultUint64) { - DefaultUint64 = other.DefaultUint64; - } - if (other.HasDefaultSint32) { - DefaultSint32 = other.DefaultSint32; - } - if (other.HasDefaultSint64) { - DefaultSint64 = other.DefaultSint64; - } - if (other.HasDefaultFixed32) { - DefaultFixed32 = other.DefaultFixed32; - } - if (other.HasDefaultFixed64) { - DefaultFixed64 = other.DefaultFixed64; - } - if (other.HasDefaultSfixed32) { - DefaultSfixed32 = other.DefaultSfixed32; - } - if (other.HasDefaultSfixed64) { - DefaultSfixed64 = other.DefaultSfixed64; - } - if (other.HasDefaultFloat) { - DefaultFloat = other.DefaultFloat; - } - if (other.HasDefaultDouble) { - DefaultDouble = other.DefaultDouble; - } - if (other.HasDefaultBool) { - DefaultBool = other.DefaultBool; - } - if (other.HasDefaultString) { - DefaultString = other.DefaultString; - } - if (other.HasDefaultBytes) { - DefaultBytes = other.DefaultBytes; - } - if (other.HasDefaultNestedEnum) { - DefaultNestedEnum = other.DefaultNestedEnum; - } - if (other.HasDefaultForeignEnum) { - DefaultForeignEnum = other.DefaultForeignEnum; - } - if (other.HasDefaultImportEnum) { - DefaultImportEnum = other.DefaultImportEnum; - } - if (other.HasDefaultStringPiece) { - DefaultStringPiece = other.DefaultStringPiece; - } - if (other.HasDefaultCord) { - DefaultCord = other.DefaultCord; - } - if (other.HasOneofUint32) { - OneofUint32 = other.OneofUint32; - } - if (other.HasOneofNestedMessage) { - MergeOneofNestedMessage(other.OneofNestedMessage); - } - if (other.HasOneofString) { - OneofString = other.OneofString; - } - if (other.HasOneofBytes) { - OneofBytes = other.OneofBytes; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testAllTypesFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testAllTypesFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasOptionalInt32 = input.ReadInt32(ref result.optionalInt32_); - break; - } - case 16: { - result.hasOptionalInt64 = input.ReadInt64(ref result.optionalInt64_); - break; - } - case 24: { - result.hasOptionalUint32 = input.ReadUInt32(ref result.optionalUint32_); - break; - } - case 32: { - result.hasOptionalUint64 = input.ReadUInt64(ref result.optionalUint64_); - break; - } - case 40: { - result.hasOptionalSint32 = input.ReadSInt32(ref result.optionalSint32_); - break; - } - case 48: { - result.hasOptionalSint64 = input.ReadSInt64(ref result.optionalSint64_); - break; - } - case 61: { - result.hasOptionalFixed32 = input.ReadFixed32(ref result.optionalFixed32_); - break; - } - case 65: { - result.hasOptionalFixed64 = input.ReadFixed64(ref result.optionalFixed64_); - break; - } - case 77: { - result.hasOptionalSfixed32 = input.ReadSFixed32(ref result.optionalSfixed32_); - break; - } - case 81: { - result.hasOptionalSfixed64 = input.ReadSFixed64(ref result.optionalSfixed64_); - break; - } - case 93: { - result.hasOptionalFloat = input.ReadFloat(ref result.optionalFloat_); - break; - } - case 97: { - result.hasOptionalDouble = input.ReadDouble(ref result.optionalDouble_); - break; - } - case 104: { - result.hasOptionalBool = input.ReadBool(ref result.optionalBool_); - break; - } - case 114: { - result.hasOptionalString = input.ReadString(ref result.optionalString_); - break; - } - case 122: { - result.hasOptionalBytes = input.ReadBytes(ref result.optionalBytes_); - break; - } - case 131: { - global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.OptionalGroup.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.OptionalGroup.CreateBuilder(); - if (result.hasOptionalGroup) { - subBuilder.MergeFrom(OptionalGroup); - } - input.ReadGroup(16, subBuilder, extensionRegistry); - OptionalGroup = subBuilder.BuildPartial(); - break; - } - case 146: { - global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.CreateBuilder(); - if (result.hasOptionalNestedMessage) { - subBuilder.MergeFrom(OptionalNestedMessage); - } - input.ReadMessage(subBuilder, extensionRegistry); - OptionalNestedMessage = subBuilder.BuildPartial(); - break; - } - case 154: { - global::Google.ProtocolBuffers.TestProtos.ForeignMessage.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.ForeignMessage.CreateBuilder(); - if (result.hasOptionalForeignMessage) { - subBuilder.MergeFrom(OptionalForeignMessage); - } - input.ReadMessage(subBuilder, extensionRegistry); - OptionalForeignMessage = subBuilder.BuildPartial(); - break; - } - case 162: { - global::Google.ProtocolBuffers.TestProtos.ImportMessage.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.ImportMessage.CreateBuilder(); - if (result.hasOptionalImportMessage) { - subBuilder.MergeFrom(OptionalImportMessage); - } - input.ReadMessage(subBuilder, extensionRegistry); - OptionalImportMessage = subBuilder.BuildPartial(); - break; - } - case 168: { - object unknown; - if(input.ReadEnum(ref result.optionalNestedEnum_, out unknown)) { - result.hasOptionalNestedEnum = true; - } else if(unknown is int) { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - unknownFields.MergeVarintField(21, (ulong)(int)unknown); - } - break; - } - case 176: { - object unknown; - if(input.ReadEnum(ref result.optionalForeignEnum_, out unknown)) { - result.hasOptionalForeignEnum = true; - } else if(unknown is int) { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - unknownFields.MergeVarintField(22, (ulong)(int)unknown); - } - break; - } - case 184: { - object unknown; - if(input.ReadEnum(ref result.optionalImportEnum_, out unknown)) { - result.hasOptionalImportEnum = true; - } else if(unknown is int) { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - unknownFields.MergeVarintField(23, (ulong)(int)unknown); - } - break; - } - case 194: { - result.hasOptionalStringPiece = input.ReadString(ref result.optionalStringPiece_); - break; - } - case 202: { - result.hasOptionalCord = input.ReadString(ref result.optionalCord_); - break; - } - case 210: { - global::Google.ProtocolBuffers.TestProtos.PublicImportMessage.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.PublicImportMessage.CreateBuilder(); - if (result.hasOptionalPublicImportMessage) { - subBuilder.MergeFrom(OptionalPublicImportMessage); - } - input.ReadMessage(subBuilder, extensionRegistry); - OptionalPublicImportMessage = subBuilder.BuildPartial(); - break; - } - case 218: { - global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.CreateBuilder(); - if (result.hasOptionalLazyMessage) { - subBuilder.MergeFrom(OptionalLazyMessage); - } - input.ReadMessage(subBuilder, extensionRegistry); - OptionalLazyMessage = subBuilder.BuildPartial(); - break; - } - case 250: - case 248: { - input.ReadInt32Array(tag, field_name, result.repeatedInt32_); - break; - } - case 258: - case 256: { - input.ReadInt64Array(tag, field_name, result.repeatedInt64_); - break; - } - case 266: - case 264: { - input.ReadUInt32Array(tag, field_name, result.repeatedUint32_); - break; - } - case 274: - case 272: { - input.ReadUInt64Array(tag, field_name, result.repeatedUint64_); - break; - } - case 282: - case 280: { - input.ReadSInt32Array(tag, field_name, result.repeatedSint32_); - break; - } - case 290: - case 288: { - input.ReadSInt64Array(tag, field_name, result.repeatedSint64_); - break; - } - case 298: - case 301: { - input.ReadFixed32Array(tag, field_name, result.repeatedFixed32_); - break; - } - case 306: - case 305: { - input.ReadFixed64Array(tag, field_name, result.repeatedFixed64_); - break; - } - case 314: - case 317: { - input.ReadSFixed32Array(tag, field_name, result.repeatedSfixed32_); - break; - } - case 322: - case 321: { - input.ReadSFixed64Array(tag, field_name, result.repeatedSfixed64_); - break; - } - case 330: - case 333: { - input.ReadFloatArray(tag, field_name, result.repeatedFloat_); - break; - } - case 338: - case 337: { - input.ReadDoubleArray(tag, field_name, result.repeatedDouble_); - break; - } - case 346: - case 344: { - input.ReadBoolArray(tag, field_name, result.repeatedBool_); - break; - } - case 354: { - input.ReadStringArray(tag, field_name, result.repeatedString_); - break; - } - case 362: { - input.ReadBytesArray(tag, field_name, result.repeatedBytes_); - break; - } - case 371: { - input.ReadGroupArray(tag, field_name, result.repeatedGroup_, global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup.DefaultInstance, extensionRegistry); - break; - } - case 386: { - input.ReadMessageArray(tag, field_name, result.repeatedNestedMessage_, global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.DefaultInstance, extensionRegistry); - break; - } - case 394: { - input.ReadMessageArray(tag, field_name, result.repeatedForeignMessage_, global::Google.ProtocolBuffers.TestProtos.ForeignMessage.DefaultInstance, extensionRegistry); - break; - } - case 402: { - input.ReadMessageArray(tag, field_name, result.repeatedImportMessage_, global::Google.ProtocolBuffers.TestProtos.ImportMessage.DefaultInstance, extensionRegistry); - break; - } - case 410: - case 408: { - scg::ICollection unknownItems; - input.ReadEnumArray(tag, field_name, result.repeatedNestedEnum_, out unknownItems); - if (unknownItems != null) { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - foreach (object rawValue in unknownItems) - if (rawValue is int) - unknownFields.MergeVarintField(51, (ulong)(int)rawValue); - } - break; - } - case 418: - case 416: { - scg::ICollection unknownItems; - input.ReadEnumArray(tag, field_name, result.repeatedForeignEnum_, out unknownItems); - if (unknownItems != null) { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - foreach (object rawValue in unknownItems) - if (rawValue is int) - unknownFields.MergeVarintField(52, (ulong)(int)rawValue); - } - break; - } - case 426: - case 424: { - scg::ICollection unknownItems; - input.ReadEnumArray(tag, field_name, result.repeatedImportEnum_, out unknownItems); - if (unknownItems != null) { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - foreach (object rawValue in unknownItems) - if (rawValue is int) - unknownFields.MergeVarintField(53, (ulong)(int)rawValue); - } - break; - } - case 434: { - input.ReadStringArray(tag, field_name, result.repeatedStringPiece_); - break; - } - case 442: { - input.ReadStringArray(tag, field_name, result.repeatedCord_); - break; - } - case 458: { - input.ReadMessageArray(tag, field_name, result.repeatedLazyMessage_, global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.DefaultInstance, extensionRegistry); - break; - } - case 488: { - result.hasDefaultInt32 = input.ReadInt32(ref result.defaultInt32_); - break; - } - case 496: { - result.hasDefaultInt64 = input.ReadInt64(ref result.defaultInt64_); - break; - } - case 504: { - result.hasDefaultUint32 = input.ReadUInt32(ref result.defaultUint32_); - break; - } - case 512: { - result.hasDefaultUint64 = input.ReadUInt64(ref result.defaultUint64_); - break; - } - case 520: { - result.hasDefaultSint32 = input.ReadSInt32(ref result.defaultSint32_); - break; - } - case 528: { - result.hasDefaultSint64 = input.ReadSInt64(ref result.defaultSint64_); - break; - } - case 541: { - result.hasDefaultFixed32 = input.ReadFixed32(ref result.defaultFixed32_); - break; - } - case 545: { - result.hasDefaultFixed64 = input.ReadFixed64(ref result.defaultFixed64_); - break; - } - case 557: { - result.hasDefaultSfixed32 = input.ReadSFixed32(ref result.defaultSfixed32_); - break; - } - case 561: { - result.hasDefaultSfixed64 = input.ReadSFixed64(ref result.defaultSfixed64_); - break; - } - case 573: { - result.hasDefaultFloat = input.ReadFloat(ref result.defaultFloat_); - break; - } - case 577: { - result.hasDefaultDouble = input.ReadDouble(ref result.defaultDouble_); - break; - } - case 584: { - result.hasDefaultBool = input.ReadBool(ref result.defaultBool_); - break; - } - case 594: { - result.hasDefaultString = input.ReadString(ref result.defaultString_); - break; - } - case 602: { - result.hasDefaultBytes = input.ReadBytes(ref result.defaultBytes_); - break; - } - case 648: { - object unknown; - if(input.ReadEnum(ref result.defaultNestedEnum_, out unknown)) { - result.hasDefaultNestedEnum = true; - } else if(unknown is int) { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - unknownFields.MergeVarintField(81, (ulong)(int)unknown); - } - break; - } - case 656: { - object unknown; - if(input.ReadEnum(ref result.defaultForeignEnum_, out unknown)) { - result.hasDefaultForeignEnum = true; - } else if(unknown is int) { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - unknownFields.MergeVarintField(82, (ulong)(int)unknown); - } - break; - } - case 664: { - object unknown; - if(input.ReadEnum(ref result.defaultImportEnum_, out unknown)) { - result.hasDefaultImportEnum = true; - } else if(unknown is int) { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - unknownFields.MergeVarintField(83, (ulong)(int)unknown); - } - break; - } - case 674: { - result.hasDefaultStringPiece = input.ReadString(ref result.defaultStringPiece_); - break; - } - case 682: { - result.hasDefaultCord = input.ReadString(ref result.defaultCord_); - break; - } - case 888: { - result.hasOneofUint32 = input.ReadUInt32(ref result.oneofUint32_); - break; - } - case 898: { - global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.CreateBuilder(); - if (result.hasOneofNestedMessage) { - subBuilder.MergeFrom(OneofNestedMessage); - } - input.ReadMessage(subBuilder, extensionRegistry); - OneofNestedMessage = subBuilder.BuildPartial(); - break; - } - case 906: { - result.hasOneofString = input.ReadString(ref result.oneofString_); - break; - } - case 914: { - result.hasOneofBytes = input.ReadBytes(ref result.oneofBytes_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasOptionalInt32 { - get { return result.hasOptionalInt32; } - } - public int OptionalInt32 { - get { return result.OptionalInt32; } - set { SetOptionalInt32(value); } - } - public Builder SetOptionalInt32(int value) { - PrepareBuilder(); - result.hasOptionalInt32 = true; - result.optionalInt32_ = value; - return this; - } - public Builder ClearOptionalInt32() { - PrepareBuilder(); - result.hasOptionalInt32 = false; - result.optionalInt32_ = 0; - return this; - } - - public bool HasOptionalInt64 { - get { return result.hasOptionalInt64; } - } - public long OptionalInt64 { - get { return result.OptionalInt64; } - set { SetOptionalInt64(value); } - } - public Builder SetOptionalInt64(long value) { - PrepareBuilder(); - result.hasOptionalInt64 = true; - result.optionalInt64_ = value; - return this; - } - public Builder ClearOptionalInt64() { - PrepareBuilder(); - result.hasOptionalInt64 = false; - result.optionalInt64_ = 0L; - return this; - } - - public bool HasOptionalUint32 { - get { return result.hasOptionalUint32; } - } - [global::System.CLSCompliant(false)] - public uint OptionalUint32 { - get { return result.OptionalUint32; } - set { SetOptionalUint32(value); } - } - [global::System.CLSCompliant(false)] - public Builder SetOptionalUint32(uint value) { - PrepareBuilder(); - result.hasOptionalUint32 = true; - result.optionalUint32_ = value; - return this; - } - public Builder ClearOptionalUint32() { - PrepareBuilder(); - result.hasOptionalUint32 = false; - result.optionalUint32_ = 0; - return this; - } - - public bool HasOptionalUint64 { - get { return result.hasOptionalUint64; } - } - [global::System.CLSCompliant(false)] - public ulong OptionalUint64 { - get { return result.OptionalUint64; } - set { SetOptionalUint64(value); } - } - [global::System.CLSCompliant(false)] - public Builder SetOptionalUint64(ulong value) { - PrepareBuilder(); - result.hasOptionalUint64 = true; - result.optionalUint64_ = value; - return this; - } - public Builder ClearOptionalUint64() { - PrepareBuilder(); - result.hasOptionalUint64 = false; - result.optionalUint64_ = 0UL; - return this; - } - - public bool HasOptionalSint32 { - get { return result.hasOptionalSint32; } - } - public int OptionalSint32 { - get { return result.OptionalSint32; } - set { SetOptionalSint32(value); } - } - public Builder SetOptionalSint32(int value) { - PrepareBuilder(); - result.hasOptionalSint32 = true; - result.optionalSint32_ = value; - return this; - } - public Builder ClearOptionalSint32() { - PrepareBuilder(); - result.hasOptionalSint32 = false; - result.optionalSint32_ = 0; - return this; - } - - public bool HasOptionalSint64 { - get { return result.hasOptionalSint64; } - } - public long OptionalSint64 { - get { return result.OptionalSint64; } - set { SetOptionalSint64(value); } - } - public Builder SetOptionalSint64(long value) { - PrepareBuilder(); - result.hasOptionalSint64 = true; - result.optionalSint64_ = value; - return this; - } - public Builder ClearOptionalSint64() { - PrepareBuilder(); - result.hasOptionalSint64 = false; - result.optionalSint64_ = 0L; - return this; - } - - public bool HasOptionalFixed32 { - get { return result.hasOptionalFixed32; } - } - [global::System.CLSCompliant(false)] - public uint OptionalFixed32 { - get { return result.OptionalFixed32; } - set { SetOptionalFixed32(value); } - } - [global::System.CLSCompliant(false)] - public Builder SetOptionalFixed32(uint value) { - PrepareBuilder(); - result.hasOptionalFixed32 = true; - result.optionalFixed32_ = value; - return this; - } - public Builder ClearOptionalFixed32() { - PrepareBuilder(); - result.hasOptionalFixed32 = false; - result.optionalFixed32_ = 0; - return this; - } - - public bool HasOptionalFixed64 { - get { return result.hasOptionalFixed64; } - } - [global::System.CLSCompliant(false)] - public ulong OptionalFixed64 { - get { return result.OptionalFixed64; } - set { SetOptionalFixed64(value); } - } - [global::System.CLSCompliant(false)] - public Builder SetOptionalFixed64(ulong value) { - PrepareBuilder(); - result.hasOptionalFixed64 = true; - result.optionalFixed64_ = value; - return this; - } - public Builder ClearOptionalFixed64() { - PrepareBuilder(); - result.hasOptionalFixed64 = false; - result.optionalFixed64_ = 0UL; - return this; - } - - public bool HasOptionalSfixed32 { - get { return result.hasOptionalSfixed32; } - } - public int OptionalSfixed32 { - get { return result.OptionalSfixed32; } - set { SetOptionalSfixed32(value); } - } - public Builder SetOptionalSfixed32(int value) { - PrepareBuilder(); - result.hasOptionalSfixed32 = true; - result.optionalSfixed32_ = value; - return this; - } - public Builder ClearOptionalSfixed32() { - PrepareBuilder(); - result.hasOptionalSfixed32 = false; - result.optionalSfixed32_ = 0; - return this; - } - - public bool HasOptionalSfixed64 { - get { return result.hasOptionalSfixed64; } - } - public long OptionalSfixed64 { - get { return result.OptionalSfixed64; } - set { SetOptionalSfixed64(value); } - } - public Builder SetOptionalSfixed64(long value) { - PrepareBuilder(); - result.hasOptionalSfixed64 = true; - result.optionalSfixed64_ = value; - return this; - } - public Builder ClearOptionalSfixed64() { - PrepareBuilder(); - result.hasOptionalSfixed64 = false; - result.optionalSfixed64_ = 0L; - return this; - } - - public bool HasOptionalFloat { - get { return result.hasOptionalFloat; } - } - public float OptionalFloat { - get { return result.OptionalFloat; } - set { SetOptionalFloat(value); } - } - public Builder SetOptionalFloat(float value) { - PrepareBuilder(); - result.hasOptionalFloat = true; - result.optionalFloat_ = value; - return this; - } - public Builder ClearOptionalFloat() { - PrepareBuilder(); - result.hasOptionalFloat = false; - result.optionalFloat_ = 0F; - return this; - } - - public bool HasOptionalDouble { - get { return result.hasOptionalDouble; } - } - public double OptionalDouble { - get { return result.OptionalDouble; } - set { SetOptionalDouble(value); } - } - public Builder SetOptionalDouble(double value) { - PrepareBuilder(); - result.hasOptionalDouble = true; - result.optionalDouble_ = value; - return this; - } - public Builder ClearOptionalDouble() { - PrepareBuilder(); - result.hasOptionalDouble = false; - result.optionalDouble_ = 0D; - return this; - } - - public bool HasOptionalBool { - get { return result.hasOptionalBool; } - } - public bool OptionalBool { - get { return result.OptionalBool; } - set { SetOptionalBool(value); } - } - public Builder SetOptionalBool(bool value) { - PrepareBuilder(); - result.hasOptionalBool = true; - result.optionalBool_ = value; - return this; - } - public Builder ClearOptionalBool() { - PrepareBuilder(); - result.hasOptionalBool = false; - result.optionalBool_ = false; - return this; - } - - public bool HasOptionalString { - get { return result.hasOptionalString; } - } - public string OptionalString { - get { return result.OptionalString; } - set { SetOptionalString(value); } - } - public Builder SetOptionalString(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOptionalString = true; - result.optionalString_ = value; - return this; - } - public Builder ClearOptionalString() { - PrepareBuilder(); - result.hasOptionalString = false; - result.optionalString_ = ""; - return this; - } - - public bool HasOptionalBytes { - get { return result.hasOptionalBytes; } - } - public pb::ByteString OptionalBytes { - get { return result.OptionalBytes; } - set { SetOptionalBytes(value); } - } - public Builder SetOptionalBytes(pb::ByteString value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOptionalBytes = true; - result.optionalBytes_ = value; - return this; - } - public Builder ClearOptionalBytes() { - PrepareBuilder(); - result.hasOptionalBytes = false; - result.optionalBytes_ = pb::ByteString.Empty; - return this; - } - - public bool HasOptionalGroup { - get { return result.hasOptionalGroup; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.OptionalGroup OptionalGroup { - get { return result.OptionalGroup; } - set { SetOptionalGroup(value); } - } - public Builder SetOptionalGroup(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.OptionalGroup value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOptionalGroup = true; - result.optionalGroup_ = value; - return this; - } - public Builder SetOptionalGroup(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.OptionalGroup.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasOptionalGroup = true; - result.optionalGroup_ = builderForValue.Build(); - return this; - } - public Builder MergeOptionalGroup(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.OptionalGroup value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasOptionalGroup && - result.optionalGroup_ != global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.OptionalGroup.DefaultInstance) { - result.optionalGroup_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.OptionalGroup.CreateBuilder(result.optionalGroup_).MergeFrom(value).BuildPartial(); - } else { - result.optionalGroup_ = value; - } - result.hasOptionalGroup = true; - return this; - } - public Builder ClearOptionalGroup() { - PrepareBuilder(); - result.hasOptionalGroup = false; - result.optionalGroup_ = null; - return this; - } - - public bool HasOptionalNestedMessage { - get { return result.hasOptionalNestedMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage OptionalNestedMessage { - get { return result.OptionalNestedMessage; } - set { SetOptionalNestedMessage(value); } - } - public Builder SetOptionalNestedMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOptionalNestedMessage = true; - result.optionalNestedMessage_ = value; - return this; - } - public Builder SetOptionalNestedMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasOptionalNestedMessage = true; - result.optionalNestedMessage_ = builderForValue.Build(); - return this; - } - public Builder MergeOptionalNestedMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasOptionalNestedMessage && - result.optionalNestedMessage_ != global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.DefaultInstance) { - result.optionalNestedMessage_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.CreateBuilder(result.optionalNestedMessage_).MergeFrom(value).BuildPartial(); - } else { - result.optionalNestedMessage_ = value; - } - result.hasOptionalNestedMessage = true; - return this; - } - public Builder ClearOptionalNestedMessage() { - PrepareBuilder(); - result.hasOptionalNestedMessage = false; - result.optionalNestedMessage_ = null; - return this; - } - - public bool HasOptionalForeignMessage { - get { return result.hasOptionalForeignMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignMessage OptionalForeignMessage { - get { return result.OptionalForeignMessage; } - set { SetOptionalForeignMessage(value); } - } - public Builder SetOptionalForeignMessage(global::Google.ProtocolBuffers.TestProtos.ForeignMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOptionalForeignMessage = true; - result.optionalForeignMessage_ = value; - return this; - } - public Builder SetOptionalForeignMessage(global::Google.ProtocolBuffers.TestProtos.ForeignMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasOptionalForeignMessage = true; - result.optionalForeignMessage_ = builderForValue.Build(); - return this; - } - public Builder MergeOptionalForeignMessage(global::Google.ProtocolBuffers.TestProtos.ForeignMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasOptionalForeignMessage && - result.optionalForeignMessage_ != global::Google.ProtocolBuffers.TestProtos.ForeignMessage.DefaultInstance) { - result.optionalForeignMessage_ = global::Google.ProtocolBuffers.TestProtos.ForeignMessage.CreateBuilder(result.optionalForeignMessage_).MergeFrom(value).BuildPartial(); - } else { - result.optionalForeignMessage_ = value; - } - result.hasOptionalForeignMessage = true; - return this; - } - public Builder ClearOptionalForeignMessage() { - PrepareBuilder(); - result.hasOptionalForeignMessage = false; - result.optionalForeignMessage_ = null; - return this; - } - - public bool HasOptionalImportMessage { - get { return result.hasOptionalImportMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.ImportMessage OptionalImportMessage { - get { return result.OptionalImportMessage; } - set { SetOptionalImportMessage(value); } - } - public Builder SetOptionalImportMessage(global::Google.ProtocolBuffers.TestProtos.ImportMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOptionalImportMessage = true; - result.optionalImportMessage_ = value; - return this; - } - public Builder SetOptionalImportMessage(global::Google.ProtocolBuffers.TestProtos.ImportMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasOptionalImportMessage = true; - result.optionalImportMessage_ = builderForValue.Build(); - return this; - } - public Builder MergeOptionalImportMessage(global::Google.ProtocolBuffers.TestProtos.ImportMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasOptionalImportMessage && - result.optionalImportMessage_ != global::Google.ProtocolBuffers.TestProtos.ImportMessage.DefaultInstance) { - result.optionalImportMessage_ = global::Google.ProtocolBuffers.TestProtos.ImportMessage.CreateBuilder(result.optionalImportMessage_).MergeFrom(value).BuildPartial(); - } else { - result.optionalImportMessage_ = value; - } - result.hasOptionalImportMessage = true; - return this; - } - public Builder ClearOptionalImportMessage() { - PrepareBuilder(); - result.hasOptionalImportMessage = false; - result.optionalImportMessage_ = null; - return this; - } - - public bool HasOptionalNestedEnum { - get { return result.hasOptionalNestedEnum; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedEnum OptionalNestedEnum { - get { return result.OptionalNestedEnum; } - set { SetOptionalNestedEnum(value); } - } - public Builder SetOptionalNestedEnum(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedEnum value) { - PrepareBuilder(); - result.hasOptionalNestedEnum = true; - result.optionalNestedEnum_ = value; - return this; - } - public Builder ClearOptionalNestedEnum() { - PrepareBuilder(); - result.hasOptionalNestedEnum = false; - result.optionalNestedEnum_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedEnum.FOO; - return this; - } - - public bool HasOptionalForeignEnum { - get { return result.hasOptionalForeignEnum; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignEnum OptionalForeignEnum { - get { return result.OptionalForeignEnum; } - set { SetOptionalForeignEnum(value); } - } - public Builder SetOptionalForeignEnum(global::Google.ProtocolBuffers.TestProtos.ForeignEnum value) { - PrepareBuilder(); - result.hasOptionalForeignEnum = true; - result.optionalForeignEnum_ = value; - return this; - } - public Builder ClearOptionalForeignEnum() { - PrepareBuilder(); - result.hasOptionalForeignEnum = false; - result.optionalForeignEnum_ = global::Google.ProtocolBuffers.TestProtos.ForeignEnum.FOREIGN_FOO; - return this; - } - - public bool HasOptionalImportEnum { - get { return result.hasOptionalImportEnum; } - } - public global::Google.ProtocolBuffers.TestProtos.ImportEnum OptionalImportEnum { - get { return result.OptionalImportEnum; } - set { SetOptionalImportEnum(value); } - } - public Builder SetOptionalImportEnum(global::Google.ProtocolBuffers.TestProtos.ImportEnum value) { - PrepareBuilder(); - result.hasOptionalImportEnum = true; - result.optionalImportEnum_ = value; - return this; - } - public Builder ClearOptionalImportEnum() { - PrepareBuilder(); - result.hasOptionalImportEnum = false; - result.optionalImportEnum_ = global::Google.ProtocolBuffers.TestProtos.ImportEnum.IMPORT_FOO; - return this; - } - - public bool HasOptionalStringPiece { - get { return result.hasOptionalStringPiece; } - } - public string OptionalStringPiece { - get { return result.OptionalStringPiece; } - set { SetOptionalStringPiece(value); } - } - public Builder SetOptionalStringPiece(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOptionalStringPiece = true; - result.optionalStringPiece_ = value; - return this; - } - public Builder ClearOptionalStringPiece() { - PrepareBuilder(); - result.hasOptionalStringPiece = false; - result.optionalStringPiece_ = ""; - return this; - } - - public bool HasOptionalCord { - get { return result.hasOptionalCord; } - } - public string OptionalCord { - get { return result.OptionalCord; } - set { SetOptionalCord(value); } - } - public Builder SetOptionalCord(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOptionalCord = true; - result.optionalCord_ = value; - return this; - } - public Builder ClearOptionalCord() { - PrepareBuilder(); - result.hasOptionalCord = false; - result.optionalCord_ = ""; - return this; - } - - public bool HasOptionalPublicImportMessage { - get { return result.hasOptionalPublicImportMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.PublicImportMessage OptionalPublicImportMessage { - get { return result.OptionalPublicImportMessage; } - set { SetOptionalPublicImportMessage(value); } - } - public Builder SetOptionalPublicImportMessage(global::Google.ProtocolBuffers.TestProtos.PublicImportMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOptionalPublicImportMessage = true; - result.optionalPublicImportMessage_ = value; - return this; - } - public Builder SetOptionalPublicImportMessage(global::Google.ProtocolBuffers.TestProtos.PublicImportMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasOptionalPublicImportMessage = true; - result.optionalPublicImportMessage_ = builderForValue.Build(); - return this; - } - public Builder MergeOptionalPublicImportMessage(global::Google.ProtocolBuffers.TestProtos.PublicImportMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasOptionalPublicImportMessage && - result.optionalPublicImportMessage_ != global::Google.ProtocolBuffers.TestProtos.PublicImportMessage.DefaultInstance) { - result.optionalPublicImportMessage_ = global::Google.ProtocolBuffers.TestProtos.PublicImportMessage.CreateBuilder(result.optionalPublicImportMessage_).MergeFrom(value).BuildPartial(); - } else { - result.optionalPublicImportMessage_ = value; - } - result.hasOptionalPublicImportMessage = true; - return this; - } - public Builder ClearOptionalPublicImportMessage() { - PrepareBuilder(); - result.hasOptionalPublicImportMessage = false; - result.optionalPublicImportMessage_ = null; - return this; - } - - public bool HasOptionalLazyMessage { - get { return result.hasOptionalLazyMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage OptionalLazyMessage { - get { return result.OptionalLazyMessage; } - set { SetOptionalLazyMessage(value); } - } - public Builder SetOptionalLazyMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOptionalLazyMessage = true; - result.optionalLazyMessage_ = value; - return this; - } - public Builder SetOptionalLazyMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasOptionalLazyMessage = true; - result.optionalLazyMessage_ = builderForValue.Build(); - return this; - } - public Builder MergeOptionalLazyMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasOptionalLazyMessage && - result.optionalLazyMessage_ != global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.DefaultInstance) { - result.optionalLazyMessage_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.CreateBuilder(result.optionalLazyMessage_).MergeFrom(value).BuildPartial(); - } else { - result.optionalLazyMessage_ = value; - } - result.hasOptionalLazyMessage = true; - return this; - } - public Builder ClearOptionalLazyMessage() { - PrepareBuilder(); - result.hasOptionalLazyMessage = false; - result.optionalLazyMessage_ = null; - return this; - } - - public pbc::IPopsicleList RepeatedInt32List { - get { return PrepareBuilder().repeatedInt32_; } - } - public int RepeatedInt32Count { - get { return result.RepeatedInt32Count; } - } - public int GetRepeatedInt32(int index) { - return result.GetRepeatedInt32(index); - } - public Builder SetRepeatedInt32(int index, int value) { - PrepareBuilder(); - result.repeatedInt32_[index] = value; - return this; - } - public Builder AddRepeatedInt32(int value) { - PrepareBuilder(); - result.repeatedInt32_.Add(value); - return this; - } - public Builder AddRangeRepeatedInt32(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedInt32_.Add(values); - return this; - } - public Builder ClearRepeatedInt32() { - PrepareBuilder(); - result.repeatedInt32_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedInt64List { - get { return PrepareBuilder().repeatedInt64_; } - } - public int RepeatedInt64Count { - get { return result.RepeatedInt64Count; } - } - public long GetRepeatedInt64(int index) { - return result.GetRepeatedInt64(index); - } - public Builder SetRepeatedInt64(int index, long value) { - PrepareBuilder(); - result.repeatedInt64_[index] = value; - return this; - } - public Builder AddRepeatedInt64(long value) { - PrepareBuilder(); - result.repeatedInt64_.Add(value); - return this; - } - public Builder AddRangeRepeatedInt64(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedInt64_.Add(values); - return this; - } - public Builder ClearRepeatedInt64() { - PrepareBuilder(); - result.repeatedInt64_.Clear(); - return this; - } - - [global::System.CLSCompliant(false)] - public pbc::IPopsicleList RepeatedUint32List { - get { return PrepareBuilder().repeatedUint32_; } - } - public int RepeatedUint32Count { - get { return result.RepeatedUint32Count; } - } - [global::System.CLSCompliant(false)] - public uint GetRepeatedUint32(int index) { - return result.GetRepeatedUint32(index); - } - [global::System.CLSCompliant(false)] - public Builder SetRepeatedUint32(int index, uint value) { - PrepareBuilder(); - result.repeatedUint32_[index] = value; - return this; - } - [global::System.CLSCompliant(false)] - public Builder AddRepeatedUint32(uint value) { - PrepareBuilder(); - result.repeatedUint32_.Add(value); - return this; - } - [global::System.CLSCompliant(false)] - public Builder AddRangeRepeatedUint32(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedUint32_.Add(values); - return this; - } - public Builder ClearRepeatedUint32() { - PrepareBuilder(); - result.repeatedUint32_.Clear(); - return this; - } - - [global::System.CLSCompliant(false)] - public pbc::IPopsicleList RepeatedUint64List { - get { return PrepareBuilder().repeatedUint64_; } - } - public int RepeatedUint64Count { - get { return result.RepeatedUint64Count; } - } - [global::System.CLSCompliant(false)] - public ulong GetRepeatedUint64(int index) { - return result.GetRepeatedUint64(index); - } - [global::System.CLSCompliant(false)] - public Builder SetRepeatedUint64(int index, ulong value) { - PrepareBuilder(); - result.repeatedUint64_[index] = value; - return this; - } - [global::System.CLSCompliant(false)] - public Builder AddRepeatedUint64(ulong value) { - PrepareBuilder(); - result.repeatedUint64_.Add(value); - return this; - } - [global::System.CLSCompliant(false)] - public Builder AddRangeRepeatedUint64(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedUint64_.Add(values); - return this; - } - public Builder ClearRepeatedUint64() { - PrepareBuilder(); - result.repeatedUint64_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedSint32List { - get { return PrepareBuilder().repeatedSint32_; } - } - public int RepeatedSint32Count { - get { return result.RepeatedSint32Count; } - } - public int GetRepeatedSint32(int index) { - return result.GetRepeatedSint32(index); - } - public Builder SetRepeatedSint32(int index, int value) { - PrepareBuilder(); - result.repeatedSint32_[index] = value; - return this; - } - public Builder AddRepeatedSint32(int value) { - PrepareBuilder(); - result.repeatedSint32_.Add(value); - return this; - } - public Builder AddRangeRepeatedSint32(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedSint32_.Add(values); - return this; - } - public Builder ClearRepeatedSint32() { - PrepareBuilder(); - result.repeatedSint32_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedSint64List { - get { return PrepareBuilder().repeatedSint64_; } - } - public int RepeatedSint64Count { - get { return result.RepeatedSint64Count; } - } - public long GetRepeatedSint64(int index) { - return result.GetRepeatedSint64(index); - } - public Builder SetRepeatedSint64(int index, long value) { - PrepareBuilder(); - result.repeatedSint64_[index] = value; - return this; - } - public Builder AddRepeatedSint64(long value) { - PrepareBuilder(); - result.repeatedSint64_.Add(value); - return this; - } - public Builder AddRangeRepeatedSint64(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedSint64_.Add(values); - return this; - } - public Builder ClearRepeatedSint64() { - PrepareBuilder(); - result.repeatedSint64_.Clear(); - return this; - } - - [global::System.CLSCompliant(false)] - public pbc::IPopsicleList RepeatedFixed32List { - get { return PrepareBuilder().repeatedFixed32_; } - } - public int RepeatedFixed32Count { - get { return result.RepeatedFixed32Count; } - } - [global::System.CLSCompliant(false)] - public uint GetRepeatedFixed32(int index) { - return result.GetRepeatedFixed32(index); - } - [global::System.CLSCompliant(false)] - public Builder SetRepeatedFixed32(int index, uint value) { - PrepareBuilder(); - result.repeatedFixed32_[index] = value; - return this; - } - [global::System.CLSCompliant(false)] - public Builder AddRepeatedFixed32(uint value) { - PrepareBuilder(); - result.repeatedFixed32_.Add(value); - return this; - } - [global::System.CLSCompliant(false)] - public Builder AddRangeRepeatedFixed32(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedFixed32_.Add(values); - return this; - } - public Builder ClearRepeatedFixed32() { - PrepareBuilder(); - result.repeatedFixed32_.Clear(); - return this; - } - - [global::System.CLSCompliant(false)] - public pbc::IPopsicleList RepeatedFixed64List { - get { return PrepareBuilder().repeatedFixed64_; } - } - public int RepeatedFixed64Count { - get { return result.RepeatedFixed64Count; } - } - [global::System.CLSCompliant(false)] - public ulong GetRepeatedFixed64(int index) { - return result.GetRepeatedFixed64(index); - } - [global::System.CLSCompliant(false)] - public Builder SetRepeatedFixed64(int index, ulong value) { - PrepareBuilder(); - result.repeatedFixed64_[index] = value; - return this; - } - [global::System.CLSCompliant(false)] - public Builder AddRepeatedFixed64(ulong value) { - PrepareBuilder(); - result.repeatedFixed64_.Add(value); - return this; - } - [global::System.CLSCompliant(false)] - public Builder AddRangeRepeatedFixed64(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedFixed64_.Add(values); - return this; - } - public Builder ClearRepeatedFixed64() { - PrepareBuilder(); - result.repeatedFixed64_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedSfixed32List { - get { return PrepareBuilder().repeatedSfixed32_; } - } - public int RepeatedSfixed32Count { - get { return result.RepeatedSfixed32Count; } - } - public int GetRepeatedSfixed32(int index) { - return result.GetRepeatedSfixed32(index); - } - public Builder SetRepeatedSfixed32(int index, int value) { - PrepareBuilder(); - result.repeatedSfixed32_[index] = value; - return this; - } - public Builder AddRepeatedSfixed32(int value) { - PrepareBuilder(); - result.repeatedSfixed32_.Add(value); - return this; - } - public Builder AddRangeRepeatedSfixed32(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedSfixed32_.Add(values); - return this; - } - public Builder ClearRepeatedSfixed32() { - PrepareBuilder(); - result.repeatedSfixed32_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedSfixed64List { - get { return PrepareBuilder().repeatedSfixed64_; } - } - public int RepeatedSfixed64Count { - get { return result.RepeatedSfixed64Count; } - } - public long GetRepeatedSfixed64(int index) { - return result.GetRepeatedSfixed64(index); - } - public Builder SetRepeatedSfixed64(int index, long value) { - PrepareBuilder(); - result.repeatedSfixed64_[index] = value; - return this; - } - public Builder AddRepeatedSfixed64(long value) { - PrepareBuilder(); - result.repeatedSfixed64_.Add(value); - return this; - } - public Builder AddRangeRepeatedSfixed64(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedSfixed64_.Add(values); - return this; - } - public Builder ClearRepeatedSfixed64() { - PrepareBuilder(); - result.repeatedSfixed64_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedFloatList { - get { return PrepareBuilder().repeatedFloat_; } - } - public int RepeatedFloatCount { - get { return result.RepeatedFloatCount; } - } - public float GetRepeatedFloat(int index) { - return result.GetRepeatedFloat(index); - } - public Builder SetRepeatedFloat(int index, float value) { - PrepareBuilder(); - result.repeatedFloat_[index] = value; - return this; - } - public Builder AddRepeatedFloat(float value) { - PrepareBuilder(); - result.repeatedFloat_.Add(value); - return this; - } - public Builder AddRangeRepeatedFloat(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedFloat_.Add(values); - return this; - } - public Builder ClearRepeatedFloat() { - PrepareBuilder(); - result.repeatedFloat_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedDoubleList { - get { return PrepareBuilder().repeatedDouble_; } - } - public int RepeatedDoubleCount { - get { return result.RepeatedDoubleCount; } - } - public double GetRepeatedDouble(int index) { - return result.GetRepeatedDouble(index); - } - public Builder SetRepeatedDouble(int index, double value) { - PrepareBuilder(); - result.repeatedDouble_[index] = value; - return this; - } - public Builder AddRepeatedDouble(double value) { - PrepareBuilder(); - result.repeatedDouble_.Add(value); - return this; - } - public Builder AddRangeRepeatedDouble(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedDouble_.Add(values); - return this; - } - public Builder ClearRepeatedDouble() { - PrepareBuilder(); - result.repeatedDouble_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedBoolList { - get { return PrepareBuilder().repeatedBool_; } - } - public int RepeatedBoolCount { - get { return result.RepeatedBoolCount; } - } - public bool GetRepeatedBool(int index) { - return result.GetRepeatedBool(index); - } - public Builder SetRepeatedBool(int index, bool value) { - PrepareBuilder(); - result.repeatedBool_[index] = value; - return this; - } - public Builder AddRepeatedBool(bool value) { - PrepareBuilder(); - result.repeatedBool_.Add(value); - return this; - } - public Builder AddRangeRepeatedBool(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedBool_.Add(values); - return this; - } - public Builder ClearRepeatedBool() { - PrepareBuilder(); - result.repeatedBool_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedStringList { - get { return PrepareBuilder().repeatedString_; } - } - public int RepeatedStringCount { - get { return result.RepeatedStringCount; } - } - public string GetRepeatedString(int index) { - return result.GetRepeatedString(index); - } - public Builder SetRepeatedString(int index, string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedString_[index] = value; - return this; - } - public Builder AddRepeatedString(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedString_.Add(value); - return this; - } - public Builder AddRangeRepeatedString(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedString_.Add(values); - return this; - } - public Builder ClearRepeatedString() { - PrepareBuilder(); - result.repeatedString_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedBytesList { - get { return PrepareBuilder().repeatedBytes_; } - } - public int RepeatedBytesCount { - get { return result.RepeatedBytesCount; } - } - public pb::ByteString GetRepeatedBytes(int index) { - return result.GetRepeatedBytes(index); - } - public Builder SetRepeatedBytes(int index, pb::ByteString value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedBytes_[index] = value; - return this; - } - public Builder AddRepeatedBytes(pb::ByteString value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedBytes_.Add(value); - return this; - } - public Builder AddRangeRepeatedBytes(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedBytes_.Add(values); - return this; - } - public Builder ClearRepeatedBytes() { - PrepareBuilder(); - result.repeatedBytes_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedGroupList { - get { return PrepareBuilder().repeatedGroup_; } - } - public int RepeatedGroupCount { - get { return result.RepeatedGroupCount; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup GetRepeatedGroup(int index) { - return result.GetRepeatedGroup(index); - } - public Builder SetRepeatedGroup(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedGroup_[index] = value; - return this; - } - public Builder SetRepeatedGroup(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.repeatedGroup_[index] = builderForValue.Build(); - return this; - } - public Builder AddRepeatedGroup(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedGroup_.Add(value); - return this; - } - public Builder AddRepeatedGroup(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.RepeatedGroup.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.repeatedGroup_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeRepeatedGroup(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedGroup_.Add(values); - return this; - } - public Builder ClearRepeatedGroup() { - PrepareBuilder(); - result.repeatedGroup_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedNestedMessageList { - get { return PrepareBuilder().repeatedNestedMessage_; } - } - public int RepeatedNestedMessageCount { - get { return result.RepeatedNestedMessageCount; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage GetRepeatedNestedMessage(int index) { - return result.GetRepeatedNestedMessage(index); - } - public Builder SetRepeatedNestedMessage(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedNestedMessage_[index] = value; - return this; - } - public Builder SetRepeatedNestedMessage(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.repeatedNestedMessage_[index] = builderForValue.Build(); - return this; - } - public Builder AddRepeatedNestedMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedNestedMessage_.Add(value); - return this; - } - public Builder AddRepeatedNestedMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.repeatedNestedMessage_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeRepeatedNestedMessage(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedNestedMessage_.Add(values); - return this; - } - public Builder ClearRepeatedNestedMessage() { - PrepareBuilder(); - result.repeatedNestedMessage_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedForeignMessageList { - get { return PrepareBuilder().repeatedForeignMessage_; } - } - public int RepeatedForeignMessageCount { - get { return result.RepeatedForeignMessageCount; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignMessage GetRepeatedForeignMessage(int index) { - return result.GetRepeatedForeignMessage(index); - } - public Builder SetRepeatedForeignMessage(int index, global::Google.ProtocolBuffers.TestProtos.ForeignMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedForeignMessage_[index] = value; - return this; - } - public Builder SetRepeatedForeignMessage(int index, global::Google.ProtocolBuffers.TestProtos.ForeignMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.repeatedForeignMessage_[index] = builderForValue.Build(); - return this; - } - public Builder AddRepeatedForeignMessage(global::Google.ProtocolBuffers.TestProtos.ForeignMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedForeignMessage_.Add(value); - return this; - } - public Builder AddRepeatedForeignMessage(global::Google.ProtocolBuffers.TestProtos.ForeignMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.repeatedForeignMessage_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeRepeatedForeignMessage(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedForeignMessage_.Add(values); - return this; - } - public Builder ClearRepeatedForeignMessage() { - PrepareBuilder(); - result.repeatedForeignMessage_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedImportMessageList { - get { return PrepareBuilder().repeatedImportMessage_; } - } - public int RepeatedImportMessageCount { - get { return result.RepeatedImportMessageCount; } - } - public global::Google.ProtocolBuffers.TestProtos.ImportMessage GetRepeatedImportMessage(int index) { - return result.GetRepeatedImportMessage(index); - } - public Builder SetRepeatedImportMessage(int index, global::Google.ProtocolBuffers.TestProtos.ImportMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedImportMessage_[index] = value; - return this; - } - public Builder SetRepeatedImportMessage(int index, global::Google.ProtocolBuffers.TestProtos.ImportMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.repeatedImportMessage_[index] = builderForValue.Build(); - return this; - } - public Builder AddRepeatedImportMessage(global::Google.ProtocolBuffers.TestProtos.ImportMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedImportMessage_.Add(value); - return this; - } - public Builder AddRepeatedImportMessage(global::Google.ProtocolBuffers.TestProtos.ImportMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.repeatedImportMessage_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeRepeatedImportMessage(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedImportMessage_.Add(values); - return this; - } - public Builder ClearRepeatedImportMessage() { - PrepareBuilder(); - result.repeatedImportMessage_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedNestedEnumList { - get { return PrepareBuilder().repeatedNestedEnum_; } - } - public int RepeatedNestedEnumCount { - get { return result.RepeatedNestedEnumCount; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedEnum GetRepeatedNestedEnum(int index) { - return result.GetRepeatedNestedEnum(index); - } - public Builder SetRepeatedNestedEnum(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedEnum value) { - PrepareBuilder(); - result.repeatedNestedEnum_[index] = value; - return this; - } - public Builder AddRepeatedNestedEnum(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedEnum value) { - PrepareBuilder(); - result.repeatedNestedEnum_.Add(value); - return this; - } - public Builder AddRangeRepeatedNestedEnum(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedNestedEnum_.Add(values); - return this; - } - public Builder ClearRepeatedNestedEnum() { - PrepareBuilder(); - result.repeatedNestedEnum_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedForeignEnumList { - get { return PrepareBuilder().repeatedForeignEnum_; } - } - public int RepeatedForeignEnumCount { - get { return result.RepeatedForeignEnumCount; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignEnum GetRepeatedForeignEnum(int index) { - return result.GetRepeatedForeignEnum(index); - } - public Builder SetRepeatedForeignEnum(int index, global::Google.ProtocolBuffers.TestProtos.ForeignEnum value) { - PrepareBuilder(); - result.repeatedForeignEnum_[index] = value; - return this; - } - public Builder AddRepeatedForeignEnum(global::Google.ProtocolBuffers.TestProtos.ForeignEnum value) { - PrepareBuilder(); - result.repeatedForeignEnum_.Add(value); - return this; - } - public Builder AddRangeRepeatedForeignEnum(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedForeignEnum_.Add(values); - return this; - } - public Builder ClearRepeatedForeignEnum() { - PrepareBuilder(); - result.repeatedForeignEnum_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedImportEnumList { - get { return PrepareBuilder().repeatedImportEnum_; } - } - public int RepeatedImportEnumCount { - get { return result.RepeatedImportEnumCount; } - } - public global::Google.ProtocolBuffers.TestProtos.ImportEnum GetRepeatedImportEnum(int index) { - return result.GetRepeatedImportEnum(index); - } - public Builder SetRepeatedImportEnum(int index, global::Google.ProtocolBuffers.TestProtos.ImportEnum value) { - PrepareBuilder(); - result.repeatedImportEnum_[index] = value; - return this; - } - public Builder AddRepeatedImportEnum(global::Google.ProtocolBuffers.TestProtos.ImportEnum value) { - PrepareBuilder(); - result.repeatedImportEnum_.Add(value); - return this; - } - public Builder AddRangeRepeatedImportEnum(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedImportEnum_.Add(values); - return this; - } - public Builder ClearRepeatedImportEnum() { - PrepareBuilder(); - result.repeatedImportEnum_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedStringPieceList { - get { return PrepareBuilder().repeatedStringPiece_; } - } - public int RepeatedStringPieceCount { - get { return result.RepeatedStringPieceCount; } - } - public string GetRepeatedStringPiece(int index) { - return result.GetRepeatedStringPiece(index); - } - public Builder SetRepeatedStringPiece(int index, string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedStringPiece_[index] = value; - return this; - } - public Builder AddRepeatedStringPiece(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedStringPiece_.Add(value); - return this; - } - public Builder AddRangeRepeatedStringPiece(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedStringPiece_.Add(values); - return this; - } - public Builder ClearRepeatedStringPiece() { - PrepareBuilder(); - result.repeatedStringPiece_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedCordList { - get { return PrepareBuilder().repeatedCord_; } - } - public int RepeatedCordCount { - get { return result.RepeatedCordCount; } - } - public string GetRepeatedCord(int index) { - return result.GetRepeatedCord(index); - } - public Builder SetRepeatedCord(int index, string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedCord_[index] = value; - return this; - } - public Builder AddRepeatedCord(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedCord_.Add(value); - return this; - } - public Builder AddRangeRepeatedCord(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedCord_.Add(values); - return this; - } - public Builder ClearRepeatedCord() { - PrepareBuilder(); - result.repeatedCord_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedLazyMessageList { - get { return PrepareBuilder().repeatedLazyMessage_; } - } - public int RepeatedLazyMessageCount { - get { return result.RepeatedLazyMessageCount; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage GetRepeatedLazyMessage(int index) { - return result.GetRepeatedLazyMessage(index); - } - public Builder SetRepeatedLazyMessage(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedLazyMessage_[index] = value; - return this; - } - public Builder SetRepeatedLazyMessage(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.repeatedLazyMessage_[index] = builderForValue.Build(); - return this; - } - public Builder AddRepeatedLazyMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedLazyMessage_.Add(value); - return this; - } - public Builder AddRepeatedLazyMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.repeatedLazyMessage_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeRepeatedLazyMessage(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedLazyMessage_.Add(values); - return this; - } - public Builder ClearRepeatedLazyMessage() { - PrepareBuilder(); - result.repeatedLazyMessage_.Clear(); - return this; - } - - public bool HasDefaultInt32 { - get { return result.hasDefaultInt32; } - } - public int DefaultInt32 { - get { return result.DefaultInt32; } - set { SetDefaultInt32(value); } - } - public Builder SetDefaultInt32(int value) { - PrepareBuilder(); - result.hasDefaultInt32 = true; - result.defaultInt32_ = value; - return this; - } - public Builder ClearDefaultInt32() { - PrepareBuilder(); - result.hasDefaultInt32 = false; - result.defaultInt32_ = 41; - return this; - } - - public bool HasDefaultInt64 { - get { return result.hasDefaultInt64; } - } - public long DefaultInt64 { - get { return result.DefaultInt64; } - set { SetDefaultInt64(value); } - } - public Builder SetDefaultInt64(long value) { - PrepareBuilder(); - result.hasDefaultInt64 = true; - result.defaultInt64_ = value; - return this; - } - public Builder ClearDefaultInt64() { - PrepareBuilder(); - result.hasDefaultInt64 = false; - result.defaultInt64_ = 42L; - return this; - } - - public bool HasDefaultUint32 { - get { return result.hasDefaultUint32; } - } - [global::System.CLSCompliant(false)] - public uint DefaultUint32 { - get { return result.DefaultUint32; } - set { SetDefaultUint32(value); } - } - [global::System.CLSCompliant(false)] - public Builder SetDefaultUint32(uint value) { - PrepareBuilder(); - result.hasDefaultUint32 = true; - result.defaultUint32_ = value; - return this; - } - public Builder ClearDefaultUint32() { - PrepareBuilder(); - result.hasDefaultUint32 = false; - result.defaultUint32_ = 43; - return this; - } - - public bool HasDefaultUint64 { - get { return result.hasDefaultUint64; } - } - [global::System.CLSCompliant(false)] - public ulong DefaultUint64 { - get { return result.DefaultUint64; } - set { SetDefaultUint64(value); } - } - [global::System.CLSCompliant(false)] - public Builder SetDefaultUint64(ulong value) { - PrepareBuilder(); - result.hasDefaultUint64 = true; - result.defaultUint64_ = value; - return this; - } - public Builder ClearDefaultUint64() { - PrepareBuilder(); - result.hasDefaultUint64 = false; - result.defaultUint64_ = 44UL; - return this; - } - - public bool HasDefaultSint32 { - get { return result.hasDefaultSint32; } - } - public int DefaultSint32 { - get { return result.DefaultSint32; } - set { SetDefaultSint32(value); } - } - public Builder SetDefaultSint32(int value) { - PrepareBuilder(); - result.hasDefaultSint32 = true; - result.defaultSint32_ = value; - return this; - } - public Builder ClearDefaultSint32() { - PrepareBuilder(); - result.hasDefaultSint32 = false; - result.defaultSint32_ = -45; - return this; - } - - public bool HasDefaultSint64 { - get { return result.hasDefaultSint64; } - } - public long DefaultSint64 { - get { return result.DefaultSint64; } - set { SetDefaultSint64(value); } - } - public Builder SetDefaultSint64(long value) { - PrepareBuilder(); - result.hasDefaultSint64 = true; - result.defaultSint64_ = value; - return this; - } - public Builder ClearDefaultSint64() { - PrepareBuilder(); - result.hasDefaultSint64 = false; - result.defaultSint64_ = 46L; - return this; - } - - public bool HasDefaultFixed32 { - get { return result.hasDefaultFixed32; } - } - [global::System.CLSCompliant(false)] - public uint DefaultFixed32 { - get { return result.DefaultFixed32; } - set { SetDefaultFixed32(value); } - } - [global::System.CLSCompliant(false)] - public Builder SetDefaultFixed32(uint value) { - PrepareBuilder(); - result.hasDefaultFixed32 = true; - result.defaultFixed32_ = value; - return this; - } - public Builder ClearDefaultFixed32() { - PrepareBuilder(); - result.hasDefaultFixed32 = false; - result.defaultFixed32_ = 47; - return this; - } - - public bool HasDefaultFixed64 { - get { return result.hasDefaultFixed64; } - } - [global::System.CLSCompliant(false)] - public ulong DefaultFixed64 { - get { return result.DefaultFixed64; } - set { SetDefaultFixed64(value); } - } - [global::System.CLSCompliant(false)] - public Builder SetDefaultFixed64(ulong value) { - PrepareBuilder(); - result.hasDefaultFixed64 = true; - result.defaultFixed64_ = value; - return this; - } - public Builder ClearDefaultFixed64() { - PrepareBuilder(); - result.hasDefaultFixed64 = false; - result.defaultFixed64_ = 48UL; - return this; - } - - public bool HasDefaultSfixed32 { - get { return result.hasDefaultSfixed32; } - } - public int DefaultSfixed32 { - get { return result.DefaultSfixed32; } - set { SetDefaultSfixed32(value); } - } - public Builder SetDefaultSfixed32(int value) { - PrepareBuilder(); - result.hasDefaultSfixed32 = true; - result.defaultSfixed32_ = value; - return this; - } - public Builder ClearDefaultSfixed32() { - PrepareBuilder(); - result.hasDefaultSfixed32 = false; - result.defaultSfixed32_ = 49; - return this; - } - - public bool HasDefaultSfixed64 { - get { return result.hasDefaultSfixed64; } - } - public long DefaultSfixed64 { - get { return result.DefaultSfixed64; } - set { SetDefaultSfixed64(value); } - } - public Builder SetDefaultSfixed64(long value) { - PrepareBuilder(); - result.hasDefaultSfixed64 = true; - result.defaultSfixed64_ = value; - return this; - } - public Builder ClearDefaultSfixed64() { - PrepareBuilder(); - result.hasDefaultSfixed64 = false; - result.defaultSfixed64_ = -50L; - return this; - } - - public bool HasDefaultFloat { - get { return result.hasDefaultFloat; } - } - public float DefaultFloat { - get { return result.DefaultFloat; } - set { SetDefaultFloat(value); } - } - public Builder SetDefaultFloat(float value) { - PrepareBuilder(); - result.hasDefaultFloat = true; - result.defaultFloat_ = value; - return this; - } - public Builder ClearDefaultFloat() { - PrepareBuilder(); - result.hasDefaultFloat = false; - result.defaultFloat_ = 51.5F; - return this; - } - - public bool HasDefaultDouble { - get { return result.hasDefaultDouble; } - } - public double DefaultDouble { - get { return result.DefaultDouble; } - set { SetDefaultDouble(value); } - } - public Builder SetDefaultDouble(double value) { - PrepareBuilder(); - result.hasDefaultDouble = true; - result.defaultDouble_ = value; - return this; - } - public Builder ClearDefaultDouble() { - PrepareBuilder(); - result.hasDefaultDouble = false; - result.defaultDouble_ = 52000D; - return this; - } - - public bool HasDefaultBool { - get { return result.hasDefaultBool; } - } - public bool DefaultBool { - get { return result.DefaultBool; } - set { SetDefaultBool(value); } - } - public Builder SetDefaultBool(bool value) { - PrepareBuilder(); - result.hasDefaultBool = true; - result.defaultBool_ = value; - return this; - } - public Builder ClearDefaultBool() { - PrepareBuilder(); - result.hasDefaultBool = false; - result.defaultBool_ = true; - return this; - } - - public bool HasDefaultString { - get { return result.hasDefaultString; } - } - public string DefaultString { - get { return result.DefaultString; } - set { SetDefaultString(value); } - } - public Builder SetDefaultString(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasDefaultString = true; - result.defaultString_ = value; - return this; - } - public Builder ClearDefaultString() { - PrepareBuilder(); - result.hasDefaultString = false; - result.defaultString_ = "hello"; - return this; - } - - public bool HasDefaultBytes { - get { return result.hasDefaultBytes; } - } - public pb::ByteString DefaultBytes { - get { return result.DefaultBytes; } - set { SetDefaultBytes(value); } - } - public Builder SetDefaultBytes(pb::ByteString value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasDefaultBytes = true; - result.defaultBytes_ = value; - return this; - } - public Builder ClearDefaultBytes() { - PrepareBuilder(); - result.hasDefaultBytes = false; - result.defaultBytes_ = (pb::ByteString) global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Descriptor.Fields[65].DefaultValue; - return this; - } - - public bool HasDefaultNestedEnum { - get { return result.hasDefaultNestedEnum; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedEnum DefaultNestedEnum { - get { return result.DefaultNestedEnum; } - set { SetDefaultNestedEnum(value); } - } - public Builder SetDefaultNestedEnum(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedEnum value) { - PrepareBuilder(); - result.hasDefaultNestedEnum = true; - result.defaultNestedEnum_ = value; - return this; - } - public Builder ClearDefaultNestedEnum() { - PrepareBuilder(); - result.hasDefaultNestedEnum = false; - result.defaultNestedEnum_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedEnum.BAR; - return this; - } - - public bool HasDefaultForeignEnum { - get { return result.hasDefaultForeignEnum; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignEnum DefaultForeignEnum { - get { return result.DefaultForeignEnum; } - set { SetDefaultForeignEnum(value); } - } - public Builder SetDefaultForeignEnum(global::Google.ProtocolBuffers.TestProtos.ForeignEnum value) { - PrepareBuilder(); - result.hasDefaultForeignEnum = true; - result.defaultForeignEnum_ = value; - return this; - } - public Builder ClearDefaultForeignEnum() { - PrepareBuilder(); - result.hasDefaultForeignEnum = false; - result.defaultForeignEnum_ = global::Google.ProtocolBuffers.TestProtos.ForeignEnum.FOREIGN_BAR; - return this; - } - - public bool HasDefaultImportEnum { - get { return result.hasDefaultImportEnum; } - } - public global::Google.ProtocolBuffers.TestProtos.ImportEnum DefaultImportEnum { - get { return result.DefaultImportEnum; } - set { SetDefaultImportEnum(value); } - } - public Builder SetDefaultImportEnum(global::Google.ProtocolBuffers.TestProtos.ImportEnum value) { - PrepareBuilder(); - result.hasDefaultImportEnum = true; - result.defaultImportEnum_ = value; - return this; - } - public Builder ClearDefaultImportEnum() { - PrepareBuilder(); - result.hasDefaultImportEnum = false; - result.defaultImportEnum_ = global::Google.ProtocolBuffers.TestProtos.ImportEnum.IMPORT_BAR; - return this; - } - - public bool HasDefaultStringPiece { - get { return result.hasDefaultStringPiece; } - } - public string DefaultStringPiece { - get { return result.DefaultStringPiece; } - set { SetDefaultStringPiece(value); } - } - public Builder SetDefaultStringPiece(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasDefaultStringPiece = true; - result.defaultStringPiece_ = value; - return this; - } - public Builder ClearDefaultStringPiece() { - PrepareBuilder(); - result.hasDefaultStringPiece = false; - result.defaultStringPiece_ = "abc"; - return this; - } - - public bool HasDefaultCord { - get { return result.hasDefaultCord; } - } - public string DefaultCord { - get { return result.DefaultCord; } - set { SetDefaultCord(value); } - } - public Builder SetDefaultCord(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasDefaultCord = true; - result.defaultCord_ = value; - return this; - } - public Builder ClearDefaultCord() { - PrepareBuilder(); - result.hasDefaultCord = false; - result.defaultCord_ = "123"; - return this; - } - - public bool HasOneofUint32 { - get { return result.hasOneofUint32; } - } - [global::System.CLSCompliant(false)] - public uint OneofUint32 { - get { return result.OneofUint32; } - set { SetOneofUint32(value); } - } - [global::System.CLSCompliant(false)] - public Builder SetOneofUint32(uint value) { - PrepareBuilder(); - result.hasOneofUint32 = true; - result.oneofUint32_ = value; - return this; - } - public Builder ClearOneofUint32() { - PrepareBuilder(); - result.hasOneofUint32 = false; - result.oneofUint32_ = 0; - return this; - } - - public bool HasOneofNestedMessage { - get { return result.hasOneofNestedMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage OneofNestedMessage { - get { return result.OneofNestedMessage; } - set { SetOneofNestedMessage(value); } - } - public Builder SetOneofNestedMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOneofNestedMessage = true; - result.oneofNestedMessage_ = value; - return this; - } - public Builder SetOneofNestedMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasOneofNestedMessage = true; - result.oneofNestedMessage_ = builderForValue.Build(); - return this; - } - public Builder MergeOneofNestedMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasOneofNestedMessage && - result.oneofNestedMessage_ != global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.DefaultInstance) { - result.oneofNestedMessage_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.CreateBuilder(result.oneofNestedMessage_).MergeFrom(value).BuildPartial(); - } else { - result.oneofNestedMessage_ = value; - } - result.hasOneofNestedMessage = true; - return this; - } - public Builder ClearOneofNestedMessage() { - PrepareBuilder(); - result.hasOneofNestedMessage = false; - result.oneofNestedMessage_ = null; - return this; - } - - public bool HasOneofString { - get { return result.hasOneofString; } - } - public string OneofString { - get { return result.OneofString; } - set { SetOneofString(value); } - } - public Builder SetOneofString(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOneofString = true; - result.oneofString_ = value; - return this; - } - public Builder ClearOneofString() { - PrepareBuilder(); - result.hasOneofString = false; - result.oneofString_ = ""; - return this; - } - - public bool HasOneofBytes { - get { return result.hasOneofBytes; } - } - public pb::ByteString OneofBytes { - get { return result.OneofBytes; } - set { SetOneofBytes(value); } - } - public Builder SetOneofBytes(pb::ByteString value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOneofBytes = true; - result.oneofBytes_ = value; - return this; - } - public Builder ClearOneofBytes() { - PrepareBuilder(); - result.hasOneofBytes = false; - result.oneofBytes_ = pb::ByteString.Empty; - return this; - } - } - static TestAllTypes() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class NestedTestAllTypes : pb::GeneratedMessage { - private NestedTestAllTypes() { } - private static readonly NestedTestAllTypes defaultInstance = new NestedTestAllTypes().MakeReadOnly(); - private static readonly string[] _nestedTestAllTypesFieldNames = new string[] { "child", "payload" }; - private static readonly uint[] _nestedTestAllTypesFieldTags = new uint[] { 10, 18 }; - public static NestedTestAllTypes DefaultInstance { - get { return defaultInstance; } - } - - public override NestedTestAllTypes DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override NestedTestAllTypes ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_NestedTestAllTypes__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_NestedTestAllTypes__FieldAccessorTable; } - } - - public const int ChildFieldNumber = 1; - private bool hasChild; - private global::Google.ProtocolBuffers.TestProtos.NestedTestAllTypes child_; - public bool HasChild { - get { return hasChild; } - } - public global::Google.ProtocolBuffers.TestProtos.NestedTestAllTypes Child { - get { return child_ ?? global::Google.ProtocolBuffers.TestProtos.NestedTestAllTypes.DefaultInstance; } - } - - public const int PayloadFieldNumber = 2; - private bool hasPayload; - private global::Google.ProtocolBuffers.TestProtos.TestAllTypes payload_; - public bool HasPayload { - get { return hasPayload; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes Payload { - get { return payload_ ?? global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _nestedTestAllTypesFieldNames; - if (hasChild) { - output.WriteMessage(1, field_names[0], Child); - } - if (hasPayload) { - output.WriteMessage(2, field_names[1], Payload); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasChild) { - size += pb::CodedOutputStream.ComputeMessageSize(1, Child); - } - if (hasPayload) { - size += pb::CodedOutputStream.ComputeMessageSize(2, Payload); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static NestedTestAllTypes ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static NestedTestAllTypes ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static NestedTestAllTypes ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static NestedTestAllTypes ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static NestedTestAllTypes ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static NestedTestAllTypes ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static NestedTestAllTypes ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static NestedTestAllTypes ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static NestedTestAllTypes ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static NestedTestAllTypes ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private NestedTestAllTypes MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(NestedTestAllTypes prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(NestedTestAllTypes cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private NestedTestAllTypes result; - - private NestedTestAllTypes PrepareBuilder() { - if (resultIsReadOnly) { - NestedTestAllTypes original = result; - result = new NestedTestAllTypes(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override NestedTestAllTypes MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.NestedTestAllTypes.Descriptor; } - } - - public override NestedTestAllTypes DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.NestedTestAllTypes.DefaultInstance; } - } - - public override NestedTestAllTypes BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is NestedTestAllTypes) { - return MergeFrom((NestedTestAllTypes) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(NestedTestAllTypes other) { - if (other == global::Google.ProtocolBuffers.TestProtos.NestedTestAllTypes.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasChild) { - MergeChild(other.Child); - } - if (other.HasPayload) { - MergePayload(other.Payload); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_nestedTestAllTypesFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _nestedTestAllTypesFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 10: { - global::Google.ProtocolBuffers.TestProtos.NestedTestAllTypes.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.NestedTestAllTypes.CreateBuilder(); - if (result.hasChild) { - subBuilder.MergeFrom(Child); - } - input.ReadMessage(subBuilder, extensionRegistry); - Child = subBuilder.BuildPartial(); - break; - } - case 18: { - global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.CreateBuilder(); - if (result.hasPayload) { - subBuilder.MergeFrom(Payload); - } - input.ReadMessage(subBuilder, extensionRegistry); - Payload = subBuilder.BuildPartial(); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasChild { - get { return result.hasChild; } - } - public global::Google.ProtocolBuffers.TestProtos.NestedTestAllTypes Child { - get { return result.Child; } - set { SetChild(value); } - } - public Builder SetChild(global::Google.ProtocolBuffers.TestProtos.NestedTestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasChild = true; - result.child_ = value; - return this; - } - public Builder SetChild(global::Google.ProtocolBuffers.TestProtos.NestedTestAllTypes.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasChild = true; - result.child_ = builderForValue.Build(); - return this; - } - public Builder MergeChild(global::Google.ProtocolBuffers.TestProtos.NestedTestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasChild && - result.child_ != global::Google.ProtocolBuffers.TestProtos.NestedTestAllTypes.DefaultInstance) { - result.child_ = global::Google.ProtocolBuffers.TestProtos.NestedTestAllTypes.CreateBuilder(result.child_).MergeFrom(value).BuildPartial(); - } else { - result.child_ = value; - } - result.hasChild = true; - return this; - } - public Builder ClearChild() { - PrepareBuilder(); - result.hasChild = false; - result.child_ = null; - return this; - } - - public bool HasPayload { - get { return result.hasPayload; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes Payload { - get { return result.Payload; } - set { SetPayload(value); } - } - public Builder SetPayload(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasPayload = true; - result.payload_ = value; - return this; - } - public Builder SetPayload(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasPayload = true; - result.payload_ = builderForValue.Build(); - return this; - } - public Builder MergePayload(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasPayload && - result.payload_ != global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance) { - result.payload_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.CreateBuilder(result.payload_).MergeFrom(value).BuildPartial(); - } else { - result.payload_ = value; - } - result.hasPayload = true; - return this; - } - public Builder ClearPayload() { - PrepareBuilder(); - result.hasPayload = false; - result.payload_ = null; - return this; - } - } - static NestedTestAllTypes() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestDeprecatedFields : pb::GeneratedMessage { - private TestDeprecatedFields() { } - private static readonly TestDeprecatedFields defaultInstance = new TestDeprecatedFields().MakeReadOnly(); - private static readonly string[] _testDeprecatedFieldsFieldNames = new string[] { "deprecated_int32" }; - private static readonly uint[] _testDeprecatedFieldsFieldTags = new uint[] { 8 }; - public static TestDeprecatedFields DefaultInstance { - get { return defaultInstance; } - } - - public override TestDeprecatedFields DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestDeprecatedFields ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestDeprecatedFields__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestDeprecatedFields__FieldAccessorTable; } - } - - public const int DeprecatedInt32FieldNumber = 1; - private bool hasDeprecatedInt32; - private int deprecatedInt32_; - [global::System.ObsoleteAttribute()] - public bool HasDeprecatedInt32 { - get { return hasDeprecatedInt32; } - } - [global::System.ObsoleteAttribute()] - public int DeprecatedInt32 { - get { return deprecatedInt32_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testDeprecatedFieldsFieldNames; - if (hasDeprecatedInt32) { - output.WriteInt32(1, field_names[0], DeprecatedInt32); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasDeprecatedInt32) { - size += pb::CodedOutputStream.ComputeInt32Size(1, DeprecatedInt32); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestDeprecatedFields ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestDeprecatedFields ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestDeprecatedFields ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestDeprecatedFields ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestDeprecatedFields ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestDeprecatedFields ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestDeprecatedFields ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestDeprecatedFields ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestDeprecatedFields ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestDeprecatedFields ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestDeprecatedFields MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestDeprecatedFields prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestDeprecatedFields cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestDeprecatedFields result; - - private TestDeprecatedFields PrepareBuilder() { - if (resultIsReadOnly) { - TestDeprecatedFields original = result; - result = new TestDeprecatedFields(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestDeprecatedFields MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestDeprecatedFields.Descriptor; } - } - - public override TestDeprecatedFields DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestDeprecatedFields.DefaultInstance; } - } - - public override TestDeprecatedFields BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestDeprecatedFields) { - return MergeFrom((TestDeprecatedFields) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestDeprecatedFields other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestDeprecatedFields.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasDeprecatedInt32) { - DeprecatedInt32 = other.DeprecatedInt32; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testDeprecatedFieldsFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testDeprecatedFieldsFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasDeprecatedInt32 = input.ReadInt32(ref result.deprecatedInt32_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - [global::System.ObsoleteAttribute()] - public bool HasDeprecatedInt32 { - get { return result.hasDeprecatedInt32; } - } - [global::System.ObsoleteAttribute()] - public int DeprecatedInt32 { - get { return result.DeprecatedInt32; } - set { SetDeprecatedInt32(value); } - } - [global::System.ObsoleteAttribute()] - public Builder SetDeprecatedInt32(int value) { - PrepareBuilder(); - result.hasDeprecatedInt32 = true; - result.deprecatedInt32_ = value; - return this; - } - [global::System.ObsoleteAttribute()] - public Builder ClearDeprecatedInt32() { - PrepareBuilder(); - result.hasDeprecatedInt32 = false; - result.deprecatedInt32_ = 0; - return this; - } - } - static TestDeprecatedFields() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class ForeignMessage : pb::GeneratedMessage { - private ForeignMessage() { } - private static readonly ForeignMessage defaultInstance = new ForeignMessage().MakeReadOnly(); - private static readonly string[] _foreignMessageFieldNames = new string[] { "c" }; - private static readonly uint[] _foreignMessageFieldTags = new uint[] { 8 }; - public static ForeignMessage DefaultInstance { - get { return defaultInstance; } - } - - public override ForeignMessage DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override ForeignMessage ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_ForeignMessage__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_ForeignMessage__FieldAccessorTable; } - } - - public const int CFieldNumber = 1; - private bool hasC; - private int c_; - public bool HasC { - get { return hasC; } - } - public int C { - get { return c_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _foreignMessageFieldNames; - if (hasC) { - output.WriteInt32(1, field_names[0], C); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasC) { - size += pb::CodedOutputStream.ComputeInt32Size(1, C); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static ForeignMessage ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static ForeignMessage ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static ForeignMessage ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static ForeignMessage ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static ForeignMessage ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static ForeignMessage ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static ForeignMessage ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static ForeignMessage ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static ForeignMessage ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static ForeignMessage ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private ForeignMessage MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(ForeignMessage prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(ForeignMessage cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private ForeignMessage result; - - private ForeignMessage PrepareBuilder() { - if (resultIsReadOnly) { - ForeignMessage original = result; - result = new ForeignMessage(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override ForeignMessage MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.ForeignMessage.Descriptor; } - } - - public override ForeignMessage DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.ForeignMessage.DefaultInstance; } - } - - public override ForeignMessage BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is ForeignMessage) { - return MergeFrom((ForeignMessage) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(ForeignMessage other) { - if (other == global::Google.ProtocolBuffers.TestProtos.ForeignMessage.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasC) { - C = other.C; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_foreignMessageFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _foreignMessageFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasC = input.ReadInt32(ref result.c_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasC { - get { return result.hasC; } - } - public int C { - get { return result.C; } - set { SetC(value); } - } - public Builder SetC(int value) { - PrepareBuilder(); - result.hasC = true; - result.c_ = value; - return this; - } - public Builder ClearC() { - PrepareBuilder(); - result.hasC = false; - result.c_ = 0; - return this; - } - } - static ForeignMessage() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestAllExtensions : pb::ExtendableMessage { - private TestAllExtensions() { } - private static readonly TestAllExtensions defaultInstance = new TestAllExtensions().MakeReadOnly(); - private static readonly string[] _testAllExtensionsFieldNames = new string[] { }; - private static readonly uint[] _testAllExtensionsFieldTags = new uint[] { }; - public static TestAllExtensions DefaultInstance { - get { return defaultInstance; } - } - - public override TestAllExtensions DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestAllExtensions ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestAllExtensions__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestAllExtensions__FieldAccessorTable; } - } - - public override bool IsInitialized { - get { - if (!ExtensionsAreInitialized) return false; - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testAllExtensionsFieldNames; - pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); - extensionWriter.WriteUntil(536870912, output); - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - size += ExtensionsSerializedSize; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestAllExtensions ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestAllExtensions ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestAllExtensions ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestAllExtensions ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestAllExtensions ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestAllExtensions ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestAllExtensions ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestAllExtensions ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestAllExtensions ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestAllExtensions ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestAllExtensions MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestAllExtensions prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::ExtendableBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestAllExtensions cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestAllExtensions result; - - private TestAllExtensions PrepareBuilder() { - if (resultIsReadOnly) { - TestAllExtensions original = result; - result = new TestAllExtensions(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestAllExtensions MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestAllExtensions.Descriptor; } - } - - public override TestAllExtensions DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestAllExtensions.DefaultInstance; } - } - - public override TestAllExtensions BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestAllExtensions) { - return MergeFrom((TestAllExtensions) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestAllExtensions other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestAllExtensions.DefaultInstance) return this; - PrepareBuilder(); - this.MergeExtensionFields(other); - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testAllExtensionsFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testAllExtensionsFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - } - static TestAllExtensions() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class OptionalGroup_extension : pb::GeneratedMessage { - private OptionalGroup_extension() { } - private static readonly OptionalGroup_extension defaultInstance = new OptionalGroup_extension().MakeReadOnly(); - private static readonly string[] _optionalGroupExtensionFieldNames = new string[] { "a" }; - private static readonly uint[] _optionalGroupExtensionFieldTags = new uint[] { 136 }; - public static OptionalGroup_extension DefaultInstance { - get { return defaultInstance; } - } - - public override OptionalGroup_extension DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override OptionalGroup_extension ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_OptionalGroup_extension__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_OptionalGroup_extension__FieldAccessorTable; } - } - - public const int AFieldNumber = 17; - private bool hasA; - private int a_; - public bool HasA { - get { return hasA; } - } - public int A { - get { return a_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _optionalGroupExtensionFieldNames; - if (hasA) { - output.WriteInt32(17, field_names[0], A); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(17, A); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static OptionalGroup_extension ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static OptionalGroup_extension ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static OptionalGroup_extension ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static OptionalGroup_extension ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static OptionalGroup_extension ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static OptionalGroup_extension ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static OptionalGroup_extension ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static OptionalGroup_extension ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static OptionalGroup_extension ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static OptionalGroup_extension ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private OptionalGroup_extension MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(OptionalGroup_extension prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(OptionalGroup_extension cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private OptionalGroup_extension result; - - private OptionalGroup_extension PrepareBuilder() { - if (resultIsReadOnly) { - OptionalGroup_extension original = result; - result = new OptionalGroup_extension(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override OptionalGroup_extension MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.OptionalGroup_extension.Descriptor; } - } - - public override OptionalGroup_extension DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.OptionalGroup_extension.DefaultInstance; } - } - - public override OptionalGroup_extension BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is OptionalGroup_extension) { - return MergeFrom((OptionalGroup_extension) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(OptionalGroup_extension other) { - if (other == global::Google.ProtocolBuffers.TestProtos.OptionalGroup_extension.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasA) { - A = other.A; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_optionalGroupExtensionFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _optionalGroupExtensionFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 136: { - result.hasA = input.ReadInt32(ref result.a_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasA { - get { return result.hasA; } - } - public int A { - get { return result.A; } - set { SetA(value); } - } - public Builder SetA(int value) { - PrepareBuilder(); - result.hasA = true; - result.a_ = value; - return this; - } - public Builder ClearA() { - PrepareBuilder(); - result.hasA = false; - result.a_ = 0; - return this; - } - } - static OptionalGroup_extension() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class RepeatedGroup_extension : pb::GeneratedMessage { - private RepeatedGroup_extension() { } - private static readonly RepeatedGroup_extension defaultInstance = new RepeatedGroup_extension().MakeReadOnly(); - private static readonly string[] _repeatedGroupExtensionFieldNames = new string[] { "a" }; - private static readonly uint[] _repeatedGroupExtensionFieldTags = new uint[] { 376 }; - public static RepeatedGroup_extension DefaultInstance { - get { return defaultInstance; } - } - - public override RepeatedGroup_extension DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override RepeatedGroup_extension ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_RepeatedGroup_extension__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_RepeatedGroup_extension__FieldAccessorTable; } - } - - public const int AFieldNumber = 47; - private bool hasA; - private int a_; - public bool HasA { - get { return hasA; } - } - public int A { - get { return a_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _repeatedGroupExtensionFieldNames; - if (hasA) { - output.WriteInt32(47, field_names[0], A); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(47, A); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static RepeatedGroup_extension ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static RepeatedGroup_extension ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static RepeatedGroup_extension ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static RepeatedGroup_extension ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static RepeatedGroup_extension ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static RepeatedGroup_extension ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static RepeatedGroup_extension ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static RepeatedGroup_extension ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static RepeatedGroup_extension ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static RepeatedGroup_extension ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private RepeatedGroup_extension MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(RepeatedGroup_extension prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(RepeatedGroup_extension cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private RepeatedGroup_extension result; - - private RepeatedGroup_extension PrepareBuilder() { - if (resultIsReadOnly) { - RepeatedGroup_extension original = result; - result = new RepeatedGroup_extension(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override RepeatedGroup_extension MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.RepeatedGroup_extension.Descriptor; } - } - - public override RepeatedGroup_extension DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.RepeatedGroup_extension.DefaultInstance; } - } - - public override RepeatedGroup_extension BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is RepeatedGroup_extension) { - return MergeFrom((RepeatedGroup_extension) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(RepeatedGroup_extension other) { - if (other == global::Google.ProtocolBuffers.TestProtos.RepeatedGroup_extension.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasA) { - A = other.A; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_repeatedGroupExtensionFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _repeatedGroupExtensionFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 376: { - result.hasA = input.ReadInt32(ref result.a_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasA { - get { return result.hasA; } - } - public int A { - get { return result.A; } - set { SetA(value); } - } - public Builder SetA(int value) { - PrepareBuilder(); - result.hasA = true; - result.a_ = value; - return this; - } - public Builder ClearA() { - PrepareBuilder(); - result.hasA = false; - result.a_ = 0; - return this; - } - } - static RepeatedGroup_extension() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestNestedExtension : pb::GeneratedMessage { - private TestNestedExtension() { } - private static readonly TestNestedExtension defaultInstance = new TestNestedExtension().MakeReadOnly(); - private static readonly string[] _testNestedExtensionFieldNames = new string[] { }; - private static readonly uint[] _testNestedExtensionFieldTags = new uint[] { }; - public static TestNestedExtension DefaultInstance { - get { return defaultInstance; } - } - - public override TestNestedExtension DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestNestedExtension ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestNestedExtension__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestNestedExtension__FieldAccessorTable; } - } - - public const int TestFieldNumber = 1002; - public static pb::GeneratedExtensionBase Test; - public const int NestedStringExtensionFieldNumber = 1003; - public static pb::GeneratedExtensionBase NestedStringExtension; - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testNestedExtensionFieldNames; - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestNestedExtension ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestNestedExtension ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestNestedExtension ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestNestedExtension ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestNestedExtension ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestNestedExtension ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestNestedExtension ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestNestedExtension ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestNestedExtension ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestNestedExtension ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestNestedExtension MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestNestedExtension prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestNestedExtension cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestNestedExtension result; - - private TestNestedExtension PrepareBuilder() { - if (resultIsReadOnly) { - TestNestedExtension original = result; - result = new TestNestedExtension(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestNestedExtension MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestNestedExtension.Descriptor; } - } - - public override TestNestedExtension DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestNestedExtension.DefaultInstance; } - } - - public override TestNestedExtension BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestNestedExtension) { - return MergeFrom((TestNestedExtension) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestNestedExtension other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestNestedExtension.DefaultInstance) return this; - PrepareBuilder(); - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testNestedExtensionFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testNestedExtensionFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - } - static TestNestedExtension() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestRequired : pb::GeneratedMessage { - private TestRequired() { } - private static readonly TestRequired defaultInstance = new TestRequired().MakeReadOnly(); - private static readonly string[] _testRequiredFieldNames = new string[] { "a", "b", "c", "dummy10", "dummy11", "dummy12", "dummy13", "dummy14", "dummy15", "dummy16", "dummy17", "dummy18", "dummy19", "dummy2", "dummy20", "dummy21", "dummy22", "dummy23", "dummy24", "dummy25", "dummy26", "dummy27", "dummy28", "dummy29", "dummy30", "dummy31", "dummy32", "dummy4", "dummy5", "dummy6", "dummy7", "dummy8", "dummy9" }; - private static readonly uint[] _testRequiredFieldTags = new uint[] { 8, 24, 264, 80, 88, 96, 104, 112, 120, 128, 136, 144, 152, 16, 160, 168, 176, 184, 192, 200, 208, 216, 224, 232, 240, 248, 256, 32, 40, 48, 56, 64, 72 }; - public static TestRequired DefaultInstance { - get { return defaultInstance; } - } - - public override TestRequired DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestRequired ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestRequired__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestRequired__FieldAccessorTable; } - } - - public const int SingleFieldNumber = 1000; - public static pb::GeneratedExtensionBase Single; - public const int MultiFieldNumber = 1001; - public static pb::GeneratedExtensionBase> Multi; - public const int AFieldNumber = 1; - private bool hasA; - private int a_; - public bool HasA { - get { return hasA; } - } - public int A { - get { return a_; } - } - - public const int Dummy2FieldNumber = 2; - private bool hasDummy2; - private int dummy2_; - public bool HasDummy2 { - get { return hasDummy2; } - } - public int Dummy2 { - get { return dummy2_; } - } - - public const int BFieldNumber = 3; - private bool hasB; - private int b_; - public bool HasB { - get { return hasB; } - } - public int B { - get { return b_; } - } - - public const int Dummy4FieldNumber = 4; - private bool hasDummy4; - private int dummy4_; - public bool HasDummy4 { - get { return hasDummy4; } - } - public int Dummy4 { - get { return dummy4_; } - } - - public const int Dummy5FieldNumber = 5; - private bool hasDummy5; - private int dummy5_; - public bool HasDummy5 { - get { return hasDummy5; } - } - public int Dummy5 { - get { return dummy5_; } - } - - public const int Dummy6FieldNumber = 6; - private bool hasDummy6; - private int dummy6_; - public bool HasDummy6 { - get { return hasDummy6; } - } - public int Dummy6 { - get { return dummy6_; } - } - - public const int Dummy7FieldNumber = 7; - private bool hasDummy7; - private int dummy7_; - public bool HasDummy7 { - get { return hasDummy7; } - } - public int Dummy7 { - get { return dummy7_; } - } - - public const int Dummy8FieldNumber = 8; - private bool hasDummy8; - private int dummy8_; - public bool HasDummy8 { - get { return hasDummy8; } - } - public int Dummy8 { - get { return dummy8_; } - } - - public const int Dummy9FieldNumber = 9; - private bool hasDummy9; - private int dummy9_; - public bool HasDummy9 { - get { return hasDummy9; } - } - public int Dummy9 { - get { return dummy9_; } - } - - public const int Dummy10FieldNumber = 10; - private bool hasDummy10; - private int dummy10_; - public bool HasDummy10 { - get { return hasDummy10; } - } - public int Dummy10 { - get { return dummy10_; } - } - - public const int Dummy11FieldNumber = 11; - private bool hasDummy11; - private int dummy11_; - public bool HasDummy11 { - get { return hasDummy11; } - } - public int Dummy11 { - get { return dummy11_; } - } - - public const int Dummy12FieldNumber = 12; - private bool hasDummy12; - private int dummy12_; - public bool HasDummy12 { - get { return hasDummy12; } - } - public int Dummy12 { - get { return dummy12_; } - } - - public const int Dummy13FieldNumber = 13; - private bool hasDummy13; - private int dummy13_; - public bool HasDummy13 { - get { return hasDummy13; } - } - public int Dummy13 { - get { return dummy13_; } - } - - public const int Dummy14FieldNumber = 14; - private bool hasDummy14; - private int dummy14_; - public bool HasDummy14 { - get { return hasDummy14; } - } - public int Dummy14 { - get { return dummy14_; } - } - - public const int Dummy15FieldNumber = 15; - private bool hasDummy15; - private int dummy15_; - public bool HasDummy15 { - get { return hasDummy15; } - } - public int Dummy15 { - get { return dummy15_; } - } - - public const int Dummy16FieldNumber = 16; - private bool hasDummy16; - private int dummy16_; - public bool HasDummy16 { - get { return hasDummy16; } - } - public int Dummy16 { - get { return dummy16_; } - } - - public const int Dummy17FieldNumber = 17; - private bool hasDummy17; - private int dummy17_; - public bool HasDummy17 { - get { return hasDummy17; } - } - public int Dummy17 { - get { return dummy17_; } - } - - public const int Dummy18FieldNumber = 18; - private bool hasDummy18; - private int dummy18_; - public bool HasDummy18 { - get { return hasDummy18; } - } - public int Dummy18 { - get { return dummy18_; } - } - - public const int Dummy19FieldNumber = 19; - private bool hasDummy19; - private int dummy19_; - public bool HasDummy19 { - get { return hasDummy19; } - } - public int Dummy19 { - get { return dummy19_; } - } - - public const int Dummy20FieldNumber = 20; - private bool hasDummy20; - private int dummy20_; - public bool HasDummy20 { - get { return hasDummy20; } - } - public int Dummy20 { - get { return dummy20_; } - } - - public const int Dummy21FieldNumber = 21; - private bool hasDummy21; - private int dummy21_; - public bool HasDummy21 { - get { return hasDummy21; } - } - public int Dummy21 { - get { return dummy21_; } - } - - public const int Dummy22FieldNumber = 22; - private bool hasDummy22; - private int dummy22_; - public bool HasDummy22 { - get { return hasDummy22; } - } - public int Dummy22 { - get { return dummy22_; } - } - - public const int Dummy23FieldNumber = 23; - private bool hasDummy23; - private int dummy23_; - public bool HasDummy23 { - get { return hasDummy23; } - } - public int Dummy23 { - get { return dummy23_; } - } - - public const int Dummy24FieldNumber = 24; - private bool hasDummy24; - private int dummy24_; - public bool HasDummy24 { - get { return hasDummy24; } - } - public int Dummy24 { - get { return dummy24_; } - } - - public const int Dummy25FieldNumber = 25; - private bool hasDummy25; - private int dummy25_; - public bool HasDummy25 { - get { return hasDummy25; } - } - public int Dummy25 { - get { return dummy25_; } - } - - public const int Dummy26FieldNumber = 26; - private bool hasDummy26; - private int dummy26_; - public bool HasDummy26 { - get { return hasDummy26; } - } - public int Dummy26 { - get { return dummy26_; } - } - - public const int Dummy27FieldNumber = 27; - private bool hasDummy27; - private int dummy27_; - public bool HasDummy27 { - get { return hasDummy27; } - } - public int Dummy27 { - get { return dummy27_; } - } - - public const int Dummy28FieldNumber = 28; - private bool hasDummy28; - private int dummy28_; - public bool HasDummy28 { - get { return hasDummy28; } - } - public int Dummy28 { - get { return dummy28_; } - } - - public const int Dummy29FieldNumber = 29; - private bool hasDummy29; - private int dummy29_; - public bool HasDummy29 { - get { return hasDummy29; } - } - public int Dummy29 { - get { return dummy29_; } - } - - public const int Dummy30FieldNumber = 30; - private bool hasDummy30; - private int dummy30_; - public bool HasDummy30 { - get { return hasDummy30; } - } - public int Dummy30 { - get { return dummy30_; } - } - - public const int Dummy31FieldNumber = 31; - private bool hasDummy31; - private int dummy31_; - public bool HasDummy31 { - get { return hasDummy31; } - } - public int Dummy31 { - get { return dummy31_; } - } - - public const int Dummy32FieldNumber = 32; - private bool hasDummy32; - private int dummy32_; - public bool HasDummy32 { - get { return hasDummy32; } - } - public int Dummy32 { - get { return dummy32_; } - } - - public const int CFieldNumber = 33; - private bool hasC; - private int c_; - public bool HasC { - get { return hasC; } - } - public int C { - get { return c_; } - } - - public override bool IsInitialized { - get { - if (!hasA) return false; - if (!hasB) return false; - if (!hasC) return false; - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testRequiredFieldNames; - if (hasA) { - output.WriteInt32(1, field_names[0], A); - } - if (hasDummy2) { - output.WriteInt32(2, field_names[13], Dummy2); - } - if (hasB) { - output.WriteInt32(3, field_names[1], B); - } - if (hasDummy4) { - output.WriteInt32(4, field_names[27], Dummy4); - } - if (hasDummy5) { - output.WriteInt32(5, field_names[28], Dummy5); - } - if (hasDummy6) { - output.WriteInt32(6, field_names[29], Dummy6); - } - if (hasDummy7) { - output.WriteInt32(7, field_names[30], Dummy7); - } - if (hasDummy8) { - output.WriteInt32(8, field_names[31], Dummy8); - } - if (hasDummy9) { - output.WriteInt32(9, field_names[32], Dummy9); - } - if (hasDummy10) { - output.WriteInt32(10, field_names[3], Dummy10); - } - if (hasDummy11) { - output.WriteInt32(11, field_names[4], Dummy11); - } - if (hasDummy12) { - output.WriteInt32(12, field_names[5], Dummy12); - } - if (hasDummy13) { - output.WriteInt32(13, field_names[6], Dummy13); - } - if (hasDummy14) { - output.WriteInt32(14, field_names[7], Dummy14); - } - if (hasDummy15) { - output.WriteInt32(15, field_names[8], Dummy15); - } - if (hasDummy16) { - output.WriteInt32(16, field_names[9], Dummy16); - } - if (hasDummy17) { - output.WriteInt32(17, field_names[10], Dummy17); - } - if (hasDummy18) { - output.WriteInt32(18, field_names[11], Dummy18); - } - if (hasDummy19) { - output.WriteInt32(19, field_names[12], Dummy19); - } - if (hasDummy20) { - output.WriteInt32(20, field_names[14], Dummy20); - } - if (hasDummy21) { - output.WriteInt32(21, field_names[15], Dummy21); - } - if (hasDummy22) { - output.WriteInt32(22, field_names[16], Dummy22); - } - if (hasDummy23) { - output.WriteInt32(23, field_names[17], Dummy23); - } - if (hasDummy24) { - output.WriteInt32(24, field_names[18], Dummy24); - } - if (hasDummy25) { - output.WriteInt32(25, field_names[19], Dummy25); - } - if (hasDummy26) { - output.WriteInt32(26, field_names[20], Dummy26); - } - if (hasDummy27) { - output.WriteInt32(27, field_names[21], Dummy27); - } - if (hasDummy28) { - output.WriteInt32(28, field_names[22], Dummy28); - } - if (hasDummy29) { - output.WriteInt32(29, field_names[23], Dummy29); - } - if (hasDummy30) { - output.WriteInt32(30, field_names[24], Dummy30); - } - if (hasDummy31) { - output.WriteInt32(31, field_names[25], Dummy31); - } - if (hasDummy32) { - output.WriteInt32(32, field_names[26], Dummy32); - } - if (hasC) { - output.WriteInt32(33, field_names[2], C); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(1, A); - } - if (hasDummy2) { - size += pb::CodedOutputStream.ComputeInt32Size(2, Dummy2); - } - if (hasB) { - size += pb::CodedOutputStream.ComputeInt32Size(3, B); - } - if (hasDummy4) { - size += pb::CodedOutputStream.ComputeInt32Size(4, Dummy4); - } - if (hasDummy5) { - size += pb::CodedOutputStream.ComputeInt32Size(5, Dummy5); - } - if (hasDummy6) { - size += pb::CodedOutputStream.ComputeInt32Size(6, Dummy6); - } - if (hasDummy7) { - size += pb::CodedOutputStream.ComputeInt32Size(7, Dummy7); - } - if (hasDummy8) { - size += pb::CodedOutputStream.ComputeInt32Size(8, Dummy8); - } - if (hasDummy9) { - size += pb::CodedOutputStream.ComputeInt32Size(9, Dummy9); - } - if (hasDummy10) { - size += pb::CodedOutputStream.ComputeInt32Size(10, Dummy10); - } - if (hasDummy11) { - size += pb::CodedOutputStream.ComputeInt32Size(11, Dummy11); - } - if (hasDummy12) { - size += pb::CodedOutputStream.ComputeInt32Size(12, Dummy12); - } - if (hasDummy13) { - size += pb::CodedOutputStream.ComputeInt32Size(13, Dummy13); - } - if (hasDummy14) { - size += pb::CodedOutputStream.ComputeInt32Size(14, Dummy14); - } - if (hasDummy15) { - size += pb::CodedOutputStream.ComputeInt32Size(15, Dummy15); - } - if (hasDummy16) { - size += pb::CodedOutputStream.ComputeInt32Size(16, Dummy16); - } - if (hasDummy17) { - size += pb::CodedOutputStream.ComputeInt32Size(17, Dummy17); - } - if (hasDummy18) { - size += pb::CodedOutputStream.ComputeInt32Size(18, Dummy18); - } - if (hasDummy19) { - size += pb::CodedOutputStream.ComputeInt32Size(19, Dummy19); - } - if (hasDummy20) { - size += pb::CodedOutputStream.ComputeInt32Size(20, Dummy20); - } - if (hasDummy21) { - size += pb::CodedOutputStream.ComputeInt32Size(21, Dummy21); - } - if (hasDummy22) { - size += pb::CodedOutputStream.ComputeInt32Size(22, Dummy22); - } - if (hasDummy23) { - size += pb::CodedOutputStream.ComputeInt32Size(23, Dummy23); - } - if (hasDummy24) { - size += pb::CodedOutputStream.ComputeInt32Size(24, Dummy24); - } - if (hasDummy25) { - size += pb::CodedOutputStream.ComputeInt32Size(25, Dummy25); - } - if (hasDummy26) { - size += pb::CodedOutputStream.ComputeInt32Size(26, Dummy26); - } - if (hasDummy27) { - size += pb::CodedOutputStream.ComputeInt32Size(27, Dummy27); - } - if (hasDummy28) { - size += pb::CodedOutputStream.ComputeInt32Size(28, Dummy28); - } - if (hasDummy29) { - size += pb::CodedOutputStream.ComputeInt32Size(29, Dummy29); - } - if (hasDummy30) { - size += pb::CodedOutputStream.ComputeInt32Size(30, Dummy30); - } - if (hasDummy31) { - size += pb::CodedOutputStream.ComputeInt32Size(31, Dummy31); - } - if (hasDummy32) { - size += pb::CodedOutputStream.ComputeInt32Size(32, Dummy32); - } - if (hasC) { - size += pb::CodedOutputStream.ComputeInt32Size(33, C); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestRequired ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestRequired ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestRequired ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestRequired ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestRequired ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestRequired ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestRequired ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestRequired ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestRequired ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestRequired ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestRequired MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestRequired prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestRequired cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestRequired result; - - private TestRequired PrepareBuilder() { - if (resultIsReadOnly) { - TestRequired original = result; - result = new TestRequired(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestRequired MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestRequired.Descriptor; } - } - - public override TestRequired DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestRequired.DefaultInstance; } - } - - public override TestRequired BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestRequired) { - return MergeFrom((TestRequired) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestRequired other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestRequired.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasA) { - A = other.A; - } - if (other.HasDummy2) { - Dummy2 = other.Dummy2; - } - if (other.HasB) { - B = other.B; - } - if (other.HasDummy4) { - Dummy4 = other.Dummy4; - } - if (other.HasDummy5) { - Dummy5 = other.Dummy5; - } - if (other.HasDummy6) { - Dummy6 = other.Dummy6; - } - if (other.HasDummy7) { - Dummy7 = other.Dummy7; - } - if (other.HasDummy8) { - Dummy8 = other.Dummy8; - } - if (other.HasDummy9) { - Dummy9 = other.Dummy9; - } - if (other.HasDummy10) { - Dummy10 = other.Dummy10; - } - if (other.HasDummy11) { - Dummy11 = other.Dummy11; - } - if (other.HasDummy12) { - Dummy12 = other.Dummy12; - } - if (other.HasDummy13) { - Dummy13 = other.Dummy13; - } - if (other.HasDummy14) { - Dummy14 = other.Dummy14; - } - if (other.HasDummy15) { - Dummy15 = other.Dummy15; - } - if (other.HasDummy16) { - Dummy16 = other.Dummy16; - } - if (other.HasDummy17) { - Dummy17 = other.Dummy17; - } - if (other.HasDummy18) { - Dummy18 = other.Dummy18; - } - if (other.HasDummy19) { - Dummy19 = other.Dummy19; - } - if (other.HasDummy20) { - Dummy20 = other.Dummy20; - } - if (other.HasDummy21) { - Dummy21 = other.Dummy21; - } - if (other.HasDummy22) { - Dummy22 = other.Dummy22; - } - if (other.HasDummy23) { - Dummy23 = other.Dummy23; - } - if (other.HasDummy24) { - Dummy24 = other.Dummy24; - } - if (other.HasDummy25) { - Dummy25 = other.Dummy25; - } - if (other.HasDummy26) { - Dummy26 = other.Dummy26; - } - if (other.HasDummy27) { - Dummy27 = other.Dummy27; - } - if (other.HasDummy28) { - Dummy28 = other.Dummy28; - } - if (other.HasDummy29) { - Dummy29 = other.Dummy29; - } - if (other.HasDummy30) { - Dummy30 = other.Dummy30; - } - if (other.HasDummy31) { - Dummy31 = other.Dummy31; - } - if (other.HasDummy32) { - Dummy32 = other.Dummy32; - } - if (other.HasC) { - C = other.C; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testRequiredFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testRequiredFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasA = input.ReadInt32(ref result.a_); - break; - } - case 16: { - result.hasDummy2 = input.ReadInt32(ref result.dummy2_); - break; - } - case 24: { - result.hasB = input.ReadInt32(ref result.b_); - break; - } - case 32: { - result.hasDummy4 = input.ReadInt32(ref result.dummy4_); - break; - } - case 40: { - result.hasDummy5 = input.ReadInt32(ref result.dummy5_); - break; - } - case 48: { - result.hasDummy6 = input.ReadInt32(ref result.dummy6_); - break; - } - case 56: { - result.hasDummy7 = input.ReadInt32(ref result.dummy7_); - break; - } - case 64: { - result.hasDummy8 = input.ReadInt32(ref result.dummy8_); - break; - } - case 72: { - result.hasDummy9 = input.ReadInt32(ref result.dummy9_); - break; - } - case 80: { - result.hasDummy10 = input.ReadInt32(ref result.dummy10_); - break; - } - case 88: { - result.hasDummy11 = input.ReadInt32(ref result.dummy11_); - break; - } - case 96: { - result.hasDummy12 = input.ReadInt32(ref result.dummy12_); - break; - } - case 104: { - result.hasDummy13 = input.ReadInt32(ref result.dummy13_); - break; - } - case 112: { - result.hasDummy14 = input.ReadInt32(ref result.dummy14_); - break; - } - case 120: { - result.hasDummy15 = input.ReadInt32(ref result.dummy15_); - break; - } - case 128: { - result.hasDummy16 = input.ReadInt32(ref result.dummy16_); - break; - } - case 136: { - result.hasDummy17 = input.ReadInt32(ref result.dummy17_); - break; - } - case 144: { - result.hasDummy18 = input.ReadInt32(ref result.dummy18_); - break; - } - case 152: { - result.hasDummy19 = input.ReadInt32(ref result.dummy19_); - break; - } - case 160: { - result.hasDummy20 = input.ReadInt32(ref result.dummy20_); - break; - } - case 168: { - result.hasDummy21 = input.ReadInt32(ref result.dummy21_); - break; - } - case 176: { - result.hasDummy22 = input.ReadInt32(ref result.dummy22_); - break; - } - case 184: { - result.hasDummy23 = input.ReadInt32(ref result.dummy23_); - break; - } - case 192: { - result.hasDummy24 = input.ReadInt32(ref result.dummy24_); - break; - } - case 200: { - result.hasDummy25 = input.ReadInt32(ref result.dummy25_); - break; - } - case 208: { - result.hasDummy26 = input.ReadInt32(ref result.dummy26_); - break; - } - case 216: { - result.hasDummy27 = input.ReadInt32(ref result.dummy27_); - break; - } - case 224: { - result.hasDummy28 = input.ReadInt32(ref result.dummy28_); - break; - } - case 232: { - result.hasDummy29 = input.ReadInt32(ref result.dummy29_); - break; - } - case 240: { - result.hasDummy30 = input.ReadInt32(ref result.dummy30_); - break; - } - case 248: { - result.hasDummy31 = input.ReadInt32(ref result.dummy31_); - break; - } - case 256: { - result.hasDummy32 = input.ReadInt32(ref result.dummy32_); - break; - } - case 264: { - result.hasC = input.ReadInt32(ref result.c_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasA { - get { return result.hasA; } - } - public int A { - get { return result.A; } - set { SetA(value); } - } - public Builder SetA(int value) { - PrepareBuilder(); - result.hasA = true; - result.a_ = value; - return this; - } - public Builder ClearA() { - PrepareBuilder(); - result.hasA = false; - result.a_ = 0; - return this; - } - - public bool HasDummy2 { - get { return result.hasDummy2; } - } - public int Dummy2 { - get { return result.Dummy2; } - set { SetDummy2(value); } - } - public Builder SetDummy2(int value) { - PrepareBuilder(); - result.hasDummy2 = true; - result.dummy2_ = value; - return this; - } - public Builder ClearDummy2() { - PrepareBuilder(); - result.hasDummy2 = false; - result.dummy2_ = 0; - return this; - } - - public bool HasB { - get { return result.hasB; } - } - public int B { - get { return result.B; } - set { SetB(value); } - } - public Builder SetB(int value) { - PrepareBuilder(); - result.hasB = true; - result.b_ = value; - return this; - } - public Builder ClearB() { - PrepareBuilder(); - result.hasB = false; - result.b_ = 0; - return this; - } - - public bool HasDummy4 { - get { return result.hasDummy4; } - } - public int Dummy4 { - get { return result.Dummy4; } - set { SetDummy4(value); } - } - public Builder SetDummy4(int value) { - PrepareBuilder(); - result.hasDummy4 = true; - result.dummy4_ = value; - return this; - } - public Builder ClearDummy4() { - PrepareBuilder(); - result.hasDummy4 = false; - result.dummy4_ = 0; - return this; - } - - public bool HasDummy5 { - get { return result.hasDummy5; } - } - public int Dummy5 { - get { return result.Dummy5; } - set { SetDummy5(value); } - } - public Builder SetDummy5(int value) { - PrepareBuilder(); - result.hasDummy5 = true; - result.dummy5_ = value; - return this; - } - public Builder ClearDummy5() { - PrepareBuilder(); - result.hasDummy5 = false; - result.dummy5_ = 0; - return this; - } - - public bool HasDummy6 { - get { return result.hasDummy6; } - } - public int Dummy6 { - get { return result.Dummy6; } - set { SetDummy6(value); } - } - public Builder SetDummy6(int value) { - PrepareBuilder(); - result.hasDummy6 = true; - result.dummy6_ = value; - return this; - } - public Builder ClearDummy6() { - PrepareBuilder(); - result.hasDummy6 = false; - result.dummy6_ = 0; - return this; - } - - public bool HasDummy7 { - get { return result.hasDummy7; } - } - public int Dummy7 { - get { return result.Dummy7; } - set { SetDummy7(value); } - } - public Builder SetDummy7(int value) { - PrepareBuilder(); - result.hasDummy7 = true; - result.dummy7_ = value; - return this; - } - public Builder ClearDummy7() { - PrepareBuilder(); - result.hasDummy7 = false; - result.dummy7_ = 0; - return this; - } - - public bool HasDummy8 { - get { return result.hasDummy8; } - } - public int Dummy8 { - get { return result.Dummy8; } - set { SetDummy8(value); } - } - public Builder SetDummy8(int value) { - PrepareBuilder(); - result.hasDummy8 = true; - result.dummy8_ = value; - return this; - } - public Builder ClearDummy8() { - PrepareBuilder(); - result.hasDummy8 = false; - result.dummy8_ = 0; - return this; - } - - public bool HasDummy9 { - get { return result.hasDummy9; } - } - public int Dummy9 { - get { return result.Dummy9; } - set { SetDummy9(value); } - } - public Builder SetDummy9(int value) { - PrepareBuilder(); - result.hasDummy9 = true; - result.dummy9_ = value; - return this; - } - public Builder ClearDummy9() { - PrepareBuilder(); - result.hasDummy9 = false; - result.dummy9_ = 0; - return this; - } - - public bool HasDummy10 { - get { return result.hasDummy10; } - } - public int Dummy10 { - get { return result.Dummy10; } - set { SetDummy10(value); } - } - public Builder SetDummy10(int value) { - PrepareBuilder(); - result.hasDummy10 = true; - result.dummy10_ = value; - return this; - } - public Builder ClearDummy10() { - PrepareBuilder(); - result.hasDummy10 = false; - result.dummy10_ = 0; - return this; - } - - public bool HasDummy11 { - get { return result.hasDummy11; } - } - public int Dummy11 { - get { return result.Dummy11; } - set { SetDummy11(value); } - } - public Builder SetDummy11(int value) { - PrepareBuilder(); - result.hasDummy11 = true; - result.dummy11_ = value; - return this; - } - public Builder ClearDummy11() { - PrepareBuilder(); - result.hasDummy11 = false; - result.dummy11_ = 0; - return this; - } - - public bool HasDummy12 { - get { return result.hasDummy12; } - } - public int Dummy12 { - get { return result.Dummy12; } - set { SetDummy12(value); } - } - public Builder SetDummy12(int value) { - PrepareBuilder(); - result.hasDummy12 = true; - result.dummy12_ = value; - return this; - } - public Builder ClearDummy12() { - PrepareBuilder(); - result.hasDummy12 = false; - result.dummy12_ = 0; - return this; - } - - public bool HasDummy13 { - get { return result.hasDummy13; } - } - public int Dummy13 { - get { return result.Dummy13; } - set { SetDummy13(value); } - } - public Builder SetDummy13(int value) { - PrepareBuilder(); - result.hasDummy13 = true; - result.dummy13_ = value; - return this; - } - public Builder ClearDummy13() { - PrepareBuilder(); - result.hasDummy13 = false; - result.dummy13_ = 0; - return this; - } - - public bool HasDummy14 { - get { return result.hasDummy14; } - } - public int Dummy14 { - get { return result.Dummy14; } - set { SetDummy14(value); } - } - public Builder SetDummy14(int value) { - PrepareBuilder(); - result.hasDummy14 = true; - result.dummy14_ = value; - return this; - } - public Builder ClearDummy14() { - PrepareBuilder(); - result.hasDummy14 = false; - result.dummy14_ = 0; - return this; - } - - public bool HasDummy15 { - get { return result.hasDummy15; } - } - public int Dummy15 { - get { return result.Dummy15; } - set { SetDummy15(value); } - } - public Builder SetDummy15(int value) { - PrepareBuilder(); - result.hasDummy15 = true; - result.dummy15_ = value; - return this; - } - public Builder ClearDummy15() { - PrepareBuilder(); - result.hasDummy15 = false; - result.dummy15_ = 0; - return this; - } - - public bool HasDummy16 { - get { return result.hasDummy16; } - } - public int Dummy16 { - get { return result.Dummy16; } - set { SetDummy16(value); } - } - public Builder SetDummy16(int value) { - PrepareBuilder(); - result.hasDummy16 = true; - result.dummy16_ = value; - return this; - } - public Builder ClearDummy16() { - PrepareBuilder(); - result.hasDummy16 = false; - result.dummy16_ = 0; - return this; - } - - public bool HasDummy17 { - get { return result.hasDummy17; } - } - public int Dummy17 { - get { return result.Dummy17; } - set { SetDummy17(value); } - } - public Builder SetDummy17(int value) { - PrepareBuilder(); - result.hasDummy17 = true; - result.dummy17_ = value; - return this; - } - public Builder ClearDummy17() { - PrepareBuilder(); - result.hasDummy17 = false; - result.dummy17_ = 0; - return this; - } - - public bool HasDummy18 { - get { return result.hasDummy18; } - } - public int Dummy18 { - get { return result.Dummy18; } - set { SetDummy18(value); } - } - public Builder SetDummy18(int value) { - PrepareBuilder(); - result.hasDummy18 = true; - result.dummy18_ = value; - return this; - } - public Builder ClearDummy18() { - PrepareBuilder(); - result.hasDummy18 = false; - result.dummy18_ = 0; - return this; - } - - public bool HasDummy19 { - get { return result.hasDummy19; } - } - public int Dummy19 { - get { return result.Dummy19; } - set { SetDummy19(value); } - } - public Builder SetDummy19(int value) { - PrepareBuilder(); - result.hasDummy19 = true; - result.dummy19_ = value; - return this; - } - public Builder ClearDummy19() { - PrepareBuilder(); - result.hasDummy19 = false; - result.dummy19_ = 0; - return this; - } - - public bool HasDummy20 { - get { return result.hasDummy20; } - } - public int Dummy20 { - get { return result.Dummy20; } - set { SetDummy20(value); } - } - public Builder SetDummy20(int value) { - PrepareBuilder(); - result.hasDummy20 = true; - result.dummy20_ = value; - return this; - } - public Builder ClearDummy20() { - PrepareBuilder(); - result.hasDummy20 = false; - result.dummy20_ = 0; - return this; - } - - public bool HasDummy21 { - get { return result.hasDummy21; } - } - public int Dummy21 { - get { return result.Dummy21; } - set { SetDummy21(value); } - } - public Builder SetDummy21(int value) { - PrepareBuilder(); - result.hasDummy21 = true; - result.dummy21_ = value; - return this; - } - public Builder ClearDummy21() { - PrepareBuilder(); - result.hasDummy21 = false; - result.dummy21_ = 0; - return this; - } - - public bool HasDummy22 { - get { return result.hasDummy22; } - } - public int Dummy22 { - get { return result.Dummy22; } - set { SetDummy22(value); } - } - public Builder SetDummy22(int value) { - PrepareBuilder(); - result.hasDummy22 = true; - result.dummy22_ = value; - return this; - } - public Builder ClearDummy22() { - PrepareBuilder(); - result.hasDummy22 = false; - result.dummy22_ = 0; - return this; - } - - public bool HasDummy23 { - get { return result.hasDummy23; } - } - public int Dummy23 { - get { return result.Dummy23; } - set { SetDummy23(value); } - } - public Builder SetDummy23(int value) { - PrepareBuilder(); - result.hasDummy23 = true; - result.dummy23_ = value; - return this; - } - public Builder ClearDummy23() { - PrepareBuilder(); - result.hasDummy23 = false; - result.dummy23_ = 0; - return this; - } - - public bool HasDummy24 { - get { return result.hasDummy24; } - } - public int Dummy24 { - get { return result.Dummy24; } - set { SetDummy24(value); } - } - public Builder SetDummy24(int value) { - PrepareBuilder(); - result.hasDummy24 = true; - result.dummy24_ = value; - return this; - } - public Builder ClearDummy24() { - PrepareBuilder(); - result.hasDummy24 = false; - result.dummy24_ = 0; - return this; - } - - public bool HasDummy25 { - get { return result.hasDummy25; } - } - public int Dummy25 { - get { return result.Dummy25; } - set { SetDummy25(value); } - } - public Builder SetDummy25(int value) { - PrepareBuilder(); - result.hasDummy25 = true; - result.dummy25_ = value; - return this; - } - public Builder ClearDummy25() { - PrepareBuilder(); - result.hasDummy25 = false; - result.dummy25_ = 0; - return this; - } - - public bool HasDummy26 { - get { return result.hasDummy26; } - } - public int Dummy26 { - get { return result.Dummy26; } - set { SetDummy26(value); } - } - public Builder SetDummy26(int value) { - PrepareBuilder(); - result.hasDummy26 = true; - result.dummy26_ = value; - return this; - } - public Builder ClearDummy26() { - PrepareBuilder(); - result.hasDummy26 = false; - result.dummy26_ = 0; - return this; - } - - public bool HasDummy27 { - get { return result.hasDummy27; } - } - public int Dummy27 { - get { return result.Dummy27; } - set { SetDummy27(value); } - } - public Builder SetDummy27(int value) { - PrepareBuilder(); - result.hasDummy27 = true; - result.dummy27_ = value; - return this; - } - public Builder ClearDummy27() { - PrepareBuilder(); - result.hasDummy27 = false; - result.dummy27_ = 0; - return this; - } - - public bool HasDummy28 { - get { return result.hasDummy28; } - } - public int Dummy28 { - get { return result.Dummy28; } - set { SetDummy28(value); } - } - public Builder SetDummy28(int value) { - PrepareBuilder(); - result.hasDummy28 = true; - result.dummy28_ = value; - return this; - } - public Builder ClearDummy28() { - PrepareBuilder(); - result.hasDummy28 = false; - result.dummy28_ = 0; - return this; - } - - public bool HasDummy29 { - get { return result.hasDummy29; } - } - public int Dummy29 { - get { return result.Dummy29; } - set { SetDummy29(value); } - } - public Builder SetDummy29(int value) { - PrepareBuilder(); - result.hasDummy29 = true; - result.dummy29_ = value; - return this; - } - public Builder ClearDummy29() { - PrepareBuilder(); - result.hasDummy29 = false; - result.dummy29_ = 0; - return this; - } - - public bool HasDummy30 { - get { return result.hasDummy30; } - } - public int Dummy30 { - get { return result.Dummy30; } - set { SetDummy30(value); } - } - public Builder SetDummy30(int value) { - PrepareBuilder(); - result.hasDummy30 = true; - result.dummy30_ = value; - return this; - } - public Builder ClearDummy30() { - PrepareBuilder(); - result.hasDummy30 = false; - result.dummy30_ = 0; - return this; - } - - public bool HasDummy31 { - get { return result.hasDummy31; } - } - public int Dummy31 { - get { return result.Dummy31; } - set { SetDummy31(value); } - } - public Builder SetDummy31(int value) { - PrepareBuilder(); - result.hasDummy31 = true; - result.dummy31_ = value; - return this; - } - public Builder ClearDummy31() { - PrepareBuilder(); - result.hasDummy31 = false; - result.dummy31_ = 0; - return this; - } - - public bool HasDummy32 { - get { return result.hasDummy32; } - } - public int Dummy32 { - get { return result.Dummy32; } - set { SetDummy32(value); } - } - public Builder SetDummy32(int value) { - PrepareBuilder(); - result.hasDummy32 = true; - result.dummy32_ = value; - return this; - } - public Builder ClearDummy32() { - PrepareBuilder(); - result.hasDummy32 = false; - result.dummy32_ = 0; - return this; - } - - public bool HasC { - get { return result.hasC; } - } - public int C { - get { return result.C; } - set { SetC(value); } - } - public Builder SetC(int value) { - PrepareBuilder(); - result.hasC = true; - result.c_ = value; - return this; - } - public Builder ClearC() { - PrepareBuilder(); - result.hasC = false; - result.c_ = 0; - return this; - } - } - static TestRequired() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestRequiredForeign : pb::GeneratedMessage { - private TestRequiredForeign() { } - private static readonly TestRequiredForeign defaultInstance = new TestRequiredForeign().MakeReadOnly(); - private static readonly string[] _testRequiredForeignFieldNames = new string[] { "dummy", "optional_message", "repeated_message" }; - private static readonly uint[] _testRequiredForeignFieldTags = new uint[] { 24, 10, 18 }; - public static TestRequiredForeign DefaultInstance { - get { return defaultInstance; } - } - - public override TestRequiredForeign DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestRequiredForeign ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestRequiredForeign__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestRequiredForeign__FieldAccessorTable; } - } - - public const int OptionalMessageFieldNumber = 1; - private bool hasOptionalMessage; - private global::Google.ProtocolBuffers.TestProtos.TestRequired optionalMessage_; - public bool HasOptionalMessage { - get { return hasOptionalMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestRequired OptionalMessage { - get { return optionalMessage_ ?? global::Google.ProtocolBuffers.TestProtos.TestRequired.DefaultInstance; } - } - - public const int RepeatedMessageFieldNumber = 2; - private pbc::PopsicleList repeatedMessage_ = new pbc::PopsicleList(); - public scg::IList RepeatedMessageList { - get { return repeatedMessage_; } - } - public int RepeatedMessageCount { - get { return repeatedMessage_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestRequired GetRepeatedMessage(int index) { - return repeatedMessage_[index]; - } - - public const int DummyFieldNumber = 3; - private bool hasDummy; - private int dummy_; - public bool HasDummy { - get { return hasDummy; } - } - public int Dummy { - get { return dummy_; } - } - - public override bool IsInitialized { - get { - if (HasOptionalMessage) { - if (!OptionalMessage.IsInitialized) return false; - } - foreach (global::Google.ProtocolBuffers.TestProtos.TestRequired element in RepeatedMessageList) { - if (!element.IsInitialized) return false; - } - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testRequiredForeignFieldNames; - if (hasOptionalMessage) { - output.WriteMessage(1, field_names[1], OptionalMessage); - } - if (repeatedMessage_.Count > 0) { - output.WriteMessageArray(2, field_names[2], repeatedMessage_); - } - if (hasDummy) { - output.WriteInt32(3, field_names[0], Dummy); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasOptionalMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(1, OptionalMessage); - } - foreach (global::Google.ProtocolBuffers.TestProtos.TestRequired element in RepeatedMessageList) { - size += pb::CodedOutputStream.ComputeMessageSize(2, element); - } - if (hasDummy) { - size += pb::CodedOutputStream.ComputeInt32Size(3, Dummy); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestRequiredForeign ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestRequiredForeign ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestRequiredForeign ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestRequiredForeign ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestRequiredForeign ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestRequiredForeign ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestRequiredForeign ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestRequiredForeign ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestRequiredForeign ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestRequiredForeign ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestRequiredForeign MakeReadOnly() { - repeatedMessage_.MakeReadOnly(); - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestRequiredForeign prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestRequiredForeign cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestRequiredForeign result; - - private TestRequiredForeign PrepareBuilder() { - if (resultIsReadOnly) { - TestRequiredForeign original = result; - result = new TestRequiredForeign(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestRequiredForeign MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestRequiredForeign.Descriptor; } - } - - public override TestRequiredForeign DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestRequiredForeign.DefaultInstance; } - } - - public override TestRequiredForeign BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestRequiredForeign) { - return MergeFrom((TestRequiredForeign) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestRequiredForeign other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestRequiredForeign.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasOptionalMessage) { - MergeOptionalMessage(other.OptionalMessage); - } - if (other.repeatedMessage_.Count != 0) { - result.repeatedMessage_.Add(other.repeatedMessage_); - } - if (other.HasDummy) { - Dummy = other.Dummy; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testRequiredForeignFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testRequiredForeignFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 10: { - global::Google.ProtocolBuffers.TestProtos.TestRequired.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestRequired.CreateBuilder(); - if (result.hasOptionalMessage) { - subBuilder.MergeFrom(OptionalMessage); - } - input.ReadMessage(subBuilder, extensionRegistry); - OptionalMessage = subBuilder.BuildPartial(); - break; - } - case 18: { - input.ReadMessageArray(tag, field_name, result.repeatedMessage_, global::Google.ProtocolBuffers.TestProtos.TestRequired.DefaultInstance, extensionRegistry); - break; - } - case 24: { - result.hasDummy = input.ReadInt32(ref result.dummy_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasOptionalMessage { - get { return result.hasOptionalMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestRequired OptionalMessage { - get { return result.OptionalMessage; } - set { SetOptionalMessage(value); } - } - public Builder SetOptionalMessage(global::Google.ProtocolBuffers.TestProtos.TestRequired value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOptionalMessage = true; - result.optionalMessage_ = value; - return this; - } - public Builder SetOptionalMessage(global::Google.ProtocolBuffers.TestProtos.TestRequired.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasOptionalMessage = true; - result.optionalMessage_ = builderForValue.Build(); - return this; - } - public Builder MergeOptionalMessage(global::Google.ProtocolBuffers.TestProtos.TestRequired value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasOptionalMessage && - result.optionalMessage_ != global::Google.ProtocolBuffers.TestProtos.TestRequired.DefaultInstance) { - result.optionalMessage_ = global::Google.ProtocolBuffers.TestProtos.TestRequired.CreateBuilder(result.optionalMessage_).MergeFrom(value).BuildPartial(); - } else { - result.optionalMessage_ = value; - } - result.hasOptionalMessage = true; - return this; - } - public Builder ClearOptionalMessage() { - PrepareBuilder(); - result.hasOptionalMessage = false; - result.optionalMessage_ = null; - return this; - } - - public pbc::IPopsicleList RepeatedMessageList { - get { return PrepareBuilder().repeatedMessage_; } - } - public int RepeatedMessageCount { - get { return result.RepeatedMessageCount; } - } - public global::Google.ProtocolBuffers.TestProtos.TestRequired GetRepeatedMessage(int index) { - return result.GetRepeatedMessage(index); - } - public Builder SetRepeatedMessage(int index, global::Google.ProtocolBuffers.TestProtos.TestRequired value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedMessage_[index] = value; - return this; - } - public Builder SetRepeatedMessage(int index, global::Google.ProtocolBuffers.TestProtos.TestRequired.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.repeatedMessage_[index] = builderForValue.Build(); - return this; - } - public Builder AddRepeatedMessage(global::Google.ProtocolBuffers.TestProtos.TestRequired value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedMessage_.Add(value); - return this; - } - public Builder AddRepeatedMessage(global::Google.ProtocolBuffers.TestProtos.TestRequired.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.repeatedMessage_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeRepeatedMessage(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedMessage_.Add(values); - return this; - } - public Builder ClearRepeatedMessage() { - PrepareBuilder(); - result.repeatedMessage_.Clear(); - return this; - } - - public bool HasDummy { - get { return result.hasDummy; } - } - public int Dummy { - get { return result.Dummy; } - set { SetDummy(value); } - } - public Builder SetDummy(int value) { - PrepareBuilder(); - result.hasDummy = true; - result.dummy_ = value; - return this; - } - public Builder ClearDummy() { - PrepareBuilder(); - result.hasDummy = false; - result.dummy_ = 0; - return this; - } - } - static TestRequiredForeign() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestForeignNested : pb::GeneratedMessage { - private TestForeignNested() { } - private static readonly TestForeignNested defaultInstance = new TestForeignNested().MakeReadOnly(); - private static readonly string[] _testForeignNestedFieldNames = new string[] { "foreign_nested" }; - private static readonly uint[] _testForeignNestedFieldTags = new uint[] { 10 }; - public static TestForeignNested DefaultInstance { - get { return defaultInstance; } - } - - public override TestForeignNested DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestForeignNested ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestForeignNested__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestForeignNested__FieldAccessorTable; } - } - - public const int ForeignNestedFieldNumber = 1; - private bool hasForeignNested; - private global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage foreignNested_; - public bool HasForeignNested { - get { return hasForeignNested; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage ForeignNested { - get { return foreignNested_ ?? global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.DefaultInstance; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testForeignNestedFieldNames; - if (hasForeignNested) { - output.WriteMessage(1, field_names[0], ForeignNested); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasForeignNested) { - size += pb::CodedOutputStream.ComputeMessageSize(1, ForeignNested); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestForeignNested ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestForeignNested ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestForeignNested ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestForeignNested ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestForeignNested ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestForeignNested ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestForeignNested ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestForeignNested ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestForeignNested ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestForeignNested ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestForeignNested MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestForeignNested prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestForeignNested cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestForeignNested result; - - private TestForeignNested PrepareBuilder() { - if (resultIsReadOnly) { - TestForeignNested original = result; - result = new TestForeignNested(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestForeignNested MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestForeignNested.Descriptor; } - } - - public override TestForeignNested DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestForeignNested.DefaultInstance; } - } - - public override TestForeignNested BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestForeignNested) { - return MergeFrom((TestForeignNested) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestForeignNested other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestForeignNested.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasForeignNested) { - MergeForeignNested(other.ForeignNested); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testForeignNestedFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testForeignNestedFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 10: { - global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.CreateBuilder(); - if (result.hasForeignNested) { - subBuilder.MergeFrom(ForeignNested); - } - input.ReadMessage(subBuilder, extensionRegistry); - ForeignNested = subBuilder.BuildPartial(); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasForeignNested { - get { return result.hasForeignNested; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage ForeignNested { - get { return result.ForeignNested; } - set { SetForeignNested(value); } - } - public Builder SetForeignNested(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasForeignNested = true; - result.foreignNested_ = value; - return this; - } - public Builder SetForeignNested(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasForeignNested = true; - result.foreignNested_ = builderForValue.Build(); - return this; - } - public Builder MergeForeignNested(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasForeignNested && - result.foreignNested_ != global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.DefaultInstance) { - result.foreignNested_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Types.NestedMessage.CreateBuilder(result.foreignNested_).MergeFrom(value).BuildPartial(); - } else { - result.foreignNested_ = value; - } - result.hasForeignNested = true; - return this; - } - public Builder ClearForeignNested() { - PrepareBuilder(); - result.hasForeignNested = false; - result.foreignNested_ = null; - return this; - } - } - static TestForeignNested() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestEmptyMessage : pb::GeneratedMessage { - private TestEmptyMessage() { } - private static readonly TestEmptyMessage defaultInstance = new TestEmptyMessage().MakeReadOnly(); - private static readonly string[] _testEmptyMessageFieldNames = new string[] { }; - private static readonly uint[] _testEmptyMessageFieldTags = new uint[] { }; - public static TestEmptyMessage DefaultInstance { - get { return defaultInstance; } - } - - public override TestEmptyMessage DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestEmptyMessage ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestEmptyMessage__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestEmptyMessage__FieldAccessorTable; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testEmptyMessageFieldNames; - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestEmptyMessage ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestEmptyMessage ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestEmptyMessage ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestEmptyMessage ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestEmptyMessage ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestEmptyMessage ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestEmptyMessage ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestEmptyMessage ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestEmptyMessage ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestEmptyMessage ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestEmptyMessage MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestEmptyMessage prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestEmptyMessage cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestEmptyMessage result; - - private TestEmptyMessage PrepareBuilder() { - if (resultIsReadOnly) { - TestEmptyMessage original = result; - result = new TestEmptyMessage(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestEmptyMessage MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestEmptyMessage.Descriptor; } - } - - public override TestEmptyMessage DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestEmptyMessage.DefaultInstance; } - } - - public override TestEmptyMessage BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestEmptyMessage) { - return MergeFrom((TestEmptyMessage) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestEmptyMessage other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestEmptyMessage.DefaultInstance) return this; - PrepareBuilder(); - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testEmptyMessageFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testEmptyMessageFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - } - static TestEmptyMessage() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestEmptyMessageWithExtensions : pb::ExtendableMessage { - private TestEmptyMessageWithExtensions() { } - private static readonly TestEmptyMessageWithExtensions defaultInstance = new TestEmptyMessageWithExtensions().MakeReadOnly(); - private static readonly string[] _testEmptyMessageWithExtensionsFieldNames = new string[] { }; - private static readonly uint[] _testEmptyMessageWithExtensionsFieldTags = new uint[] { }; - public static TestEmptyMessageWithExtensions DefaultInstance { - get { return defaultInstance; } - } - - public override TestEmptyMessageWithExtensions DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestEmptyMessageWithExtensions ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestEmptyMessageWithExtensions__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestEmptyMessageWithExtensions__FieldAccessorTable; } - } - - public override bool IsInitialized { - get { - if (!ExtensionsAreInitialized) return false; - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testEmptyMessageWithExtensionsFieldNames; - pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); - extensionWriter.WriteUntil(536870912, output); - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - size += ExtensionsSerializedSize; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestEmptyMessageWithExtensions ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestEmptyMessageWithExtensions ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestEmptyMessageWithExtensions ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestEmptyMessageWithExtensions ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestEmptyMessageWithExtensions ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestEmptyMessageWithExtensions ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestEmptyMessageWithExtensions ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestEmptyMessageWithExtensions ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestEmptyMessageWithExtensions ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestEmptyMessageWithExtensions ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestEmptyMessageWithExtensions MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestEmptyMessageWithExtensions prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::ExtendableBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestEmptyMessageWithExtensions cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestEmptyMessageWithExtensions result; - - private TestEmptyMessageWithExtensions PrepareBuilder() { - if (resultIsReadOnly) { - TestEmptyMessageWithExtensions original = result; - result = new TestEmptyMessageWithExtensions(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestEmptyMessageWithExtensions MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestEmptyMessageWithExtensions.Descriptor; } - } - - public override TestEmptyMessageWithExtensions DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestEmptyMessageWithExtensions.DefaultInstance; } - } - - public override TestEmptyMessageWithExtensions BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestEmptyMessageWithExtensions) { - return MergeFrom((TestEmptyMessageWithExtensions) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestEmptyMessageWithExtensions other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestEmptyMessageWithExtensions.DefaultInstance) return this; - PrepareBuilder(); - this.MergeExtensionFields(other); - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testEmptyMessageWithExtensionsFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testEmptyMessageWithExtensionsFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - } - static TestEmptyMessageWithExtensions() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestMultipleExtensionRanges : pb::ExtendableMessage { - private TestMultipleExtensionRanges() { } - private static readonly TestMultipleExtensionRanges defaultInstance = new TestMultipleExtensionRanges().MakeReadOnly(); - private static readonly string[] _testMultipleExtensionRangesFieldNames = new string[] { }; - private static readonly uint[] _testMultipleExtensionRangesFieldTags = new uint[] { }; - public static TestMultipleExtensionRanges DefaultInstance { - get { return defaultInstance; } - } - - public override TestMultipleExtensionRanges DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestMultipleExtensionRanges ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestMultipleExtensionRanges__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestMultipleExtensionRanges__FieldAccessorTable; } - } - - public override bool IsInitialized { - get { - if (!ExtensionsAreInitialized) return false; - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testMultipleExtensionRangesFieldNames; - pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); - extensionWriter.WriteUntil(43, output); - extensionWriter.WriteUntil(4244, output); - extensionWriter.WriteUntil(536870912, output); - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - size += ExtensionsSerializedSize; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestMultipleExtensionRanges ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestMultipleExtensionRanges ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestMultipleExtensionRanges ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestMultipleExtensionRanges ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestMultipleExtensionRanges ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestMultipleExtensionRanges ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestMultipleExtensionRanges ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestMultipleExtensionRanges ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestMultipleExtensionRanges ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestMultipleExtensionRanges ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestMultipleExtensionRanges MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestMultipleExtensionRanges prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::ExtendableBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestMultipleExtensionRanges cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestMultipleExtensionRanges result; - - private TestMultipleExtensionRanges PrepareBuilder() { - if (resultIsReadOnly) { - TestMultipleExtensionRanges original = result; - result = new TestMultipleExtensionRanges(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestMultipleExtensionRanges MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestMultipleExtensionRanges.Descriptor; } - } - - public override TestMultipleExtensionRanges DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestMultipleExtensionRanges.DefaultInstance; } - } - - public override TestMultipleExtensionRanges BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestMultipleExtensionRanges) { - return MergeFrom((TestMultipleExtensionRanges) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestMultipleExtensionRanges other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestMultipleExtensionRanges.DefaultInstance) return this; - PrepareBuilder(); - this.MergeExtensionFields(other); - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testMultipleExtensionRangesFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testMultipleExtensionRangesFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - } - static TestMultipleExtensionRanges() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestReallyLargeTagNumber : pb::GeneratedMessage { - private TestReallyLargeTagNumber() { } - private static readonly TestReallyLargeTagNumber defaultInstance = new TestReallyLargeTagNumber().MakeReadOnly(); - private static readonly string[] _testReallyLargeTagNumberFieldNames = new string[] { "a", "bb" }; - private static readonly uint[] _testReallyLargeTagNumberFieldTags = new uint[] { 8, 2147483640 }; - public static TestReallyLargeTagNumber DefaultInstance { - get { return defaultInstance; } - } - - public override TestReallyLargeTagNumber DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestReallyLargeTagNumber ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestReallyLargeTagNumber__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestReallyLargeTagNumber__FieldAccessorTable; } - } - - public const int AFieldNumber = 1; - private bool hasA; - private int a_; - public bool HasA { - get { return hasA; } - } - public int A { - get { return a_; } - } - - public const int BbFieldNumber = 268435455; - private bool hasBb; - private int bb_; - public bool HasBb { - get { return hasBb; } - } - public int Bb { - get { return bb_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testReallyLargeTagNumberFieldNames; - if (hasA) { - output.WriteInt32(1, field_names[0], A); - } - if (hasBb) { - output.WriteInt32(268435455, field_names[1], Bb); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(1, A); - } - if (hasBb) { - size += pb::CodedOutputStream.ComputeInt32Size(268435455, Bb); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestReallyLargeTagNumber ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestReallyLargeTagNumber ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestReallyLargeTagNumber ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestReallyLargeTagNumber ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestReallyLargeTagNumber ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestReallyLargeTagNumber ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestReallyLargeTagNumber ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestReallyLargeTagNumber ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestReallyLargeTagNumber ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestReallyLargeTagNumber ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestReallyLargeTagNumber MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestReallyLargeTagNumber prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestReallyLargeTagNumber cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestReallyLargeTagNumber result; - - private TestReallyLargeTagNumber PrepareBuilder() { - if (resultIsReadOnly) { - TestReallyLargeTagNumber original = result; - result = new TestReallyLargeTagNumber(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestReallyLargeTagNumber MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestReallyLargeTagNumber.Descriptor; } - } - - public override TestReallyLargeTagNumber DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestReallyLargeTagNumber.DefaultInstance; } - } - - public override TestReallyLargeTagNumber BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestReallyLargeTagNumber) { - return MergeFrom((TestReallyLargeTagNumber) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestReallyLargeTagNumber other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestReallyLargeTagNumber.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasA) { - A = other.A; - } - if (other.HasBb) { - Bb = other.Bb; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testReallyLargeTagNumberFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testReallyLargeTagNumberFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasA = input.ReadInt32(ref result.a_); - break; - } - case 2147483640: { - result.hasBb = input.ReadInt32(ref result.bb_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasA { - get { return result.hasA; } - } - public int A { - get { return result.A; } - set { SetA(value); } - } - public Builder SetA(int value) { - PrepareBuilder(); - result.hasA = true; - result.a_ = value; - return this; - } - public Builder ClearA() { - PrepareBuilder(); - result.hasA = false; - result.a_ = 0; - return this; - } - - public bool HasBb { - get { return result.hasBb; } - } - public int Bb { - get { return result.Bb; } - set { SetBb(value); } - } - public Builder SetBb(int value) { - PrepareBuilder(); - result.hasBb = true; - result.bb_ = value; - return this; - } - public Builder ClearBb() { - PrepareBuilder(); - result.hasBb = false; - result.bb_ = 0; - return this; - } - } - static TestReallyLargeTagNumber() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestRecursiveMessage : pb::GeneratedMessage { - private TestRecursiveMessage() { } - private static readonly TestRecursiveMessage defaultInstance = new TestRecursiveMessage().MakeReadOnly(); - private static readonly string[] _testRecursiveMessageFieldNames = new string[] { "a", "i" }; - private static readonly uint[] _testRecursiveMessageFieldTags = new uint[] { 10, 16 }; - public static TestRecursiveMessage DefaultInstance { - get { return defaultInstance; } - } - - public override TestRecursiveMessage DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestRecursiveMessage ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestRecursiveMessage__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestRecursiveMessage__FieldAccessorTable; } - } - - public const int AFieldNumber = 1; - private bool hasA; - private global::Google.ProtocolBuffers.TestProtos.TestRecursiveMessage a_; - public bool HasA { - get { return hasA; } - } - public global::Google.ProtocolBuffers.TestProtos.TestRecursiveMessage A { - get { return a_ ?? global::Google.ProtocolBuffers.TestProtos.TestRecursiveMessage.DefaultInstance; } - } - - public const int IFieldNumber = 2; - private bool hasI; - private int i_; - public bool HasI { - get { return hasI; } - } - public int I { - get { return i_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testRecursiveMessageFieldNames; - if (hasA) { - output.WriteMessage(1, field_names[0], A); - } - if (hasI) { - output.WriteInt32(2, field_names[1], I); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeMessageSize(1, A); - } - if (hasI) { - size += pb::CodedOutputStream.ComputeInt32Size(2, I); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestRecursiveMessage ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestRecursiveMessage ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestRecursiveMessage ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestRecursiveMessage ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestRecursiveMessage ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestRecursiveMessage ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestRecursiveMessage ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestRecursiveMessage ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestRecursiveMessage ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestRecursiveMessage ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestRecursiveMessage MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestRecursiveMessage prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestRecursiveMessage cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestRecursiveMessage result; - - private TestRecursiveMessage PrepareBuilder() { - if (resultIsReadOnly) { - TestRecursiveMessage original = result; - result = new TestRecursiveMessage(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestRecursiveMessage MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestRecursiveMessage.Descriptor; } - } - - public override TestRecursiveMessage DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestRecursiveMessage.DefaultInstance; } - } - - public override TestRecursiveMessage BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestRecursiveMessage) { - return MergeFrom((TestRecursiveMessage) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestRecursiveMessage other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestRecursiveMessage.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasA) { - MergeA(other.A); - } - if (other.HasI) { - I = other.I; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testRecursiveMessageFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testRecursiveMessageFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 10: { - global::Google.ProtocolBuffers.TestProtos.TestRecursiveMessage.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestRecursiveMessage.CreateBuilder(); - if (result.hasA) { - subBuilder.MergeFrom(A); - } - input.ReadMessage(subBuilder, extensionRegistry); - A = subBuilder.BuildPartial(); - break; - } - case 16: { - result.hasI = input.ReadInt32(ref result.i_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasA { - get { return result.hasA; } - } - public global::Google.ProtocolBuffers.TestProtos.TestRecursiveMessage A { - get { return result.A; } - set { SetA(value); } - } - public Builder SetA(global::Google.ProtocolBuffers.TestProtos.TestRecursiveMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasA = true; - result.a_ = value; - return this; - } - public Builder SetA(global::Google.ProtocolBuffers.TestProtos.TestRecursiveMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasA = true; - result.a_ = builderForValue.Build(); - return this; - } - public Builder MergeA(global::Google.ProtocolBuffers.TestProtos.TestRecursiveMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasA && - result.a_ != global::Google.ProtocolBuffers.TestProtos.TestRecursiveMessage.DefaultInstance) { - result.a_ = global::Google.ProtocolBuffers.TestProtos.TestRecursiveMessage.CreateBuilder(result.a_).MergeFrom(value).BuildPartial(); - } else { - result.a_ = value; - } - result.hasA = true; - return this; - } - public Builder ClearA() { - PrepareBuilder(); - result.hasA = false; - result.a_ = null; - return this; - } - - public bool HasI { - get { return result.hasI; } - } - public int I { - get { return result.I; } - set { SetI(value); } - } - public Builder SetI(int value) { - PrepareBuilder(); - result.hasI = true; - result.i_ = value; - return this; - } - public Builder ClearI() { - PrepareBuilder(); - result.hasI = false; - result.i_ = 0; - return this; - } - } - static TestRecursiveMessage() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestMutualRecursionA : pb::GeneratedMessage { - private TestMutualRecursionA() { } - private static readonly TestMutualRecursionA defaultInstance = new TestMutualRecursionA().MakeReadOnly(); - private static readonly string[] _testMutualRecursionAFieldNames = new string[] { "bb" }; - private static readonly uint[] _testMutualRecursionAFieldTags = new uint[] { 10 }; - public static TestMutualRecursionA DefaultInstance { - get { return defaultInstance; } - } - - public override TestMutualRecursionA DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestMutualRecursionA ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestMutualRecursionA__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestMutualRecursionA__FieldAccessorTable; } - } - - public const int BbFieldNumber = 1; - private bool hasBb; - private global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionB bb_; - public bool HasBb { - get { return hasBb; } - } - public global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionB Bb { - get { return bb_ ?? global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionB.DefaultInstance; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testMutualRecursionAFieldNames; - if (hasBb) { - output.WriteMessage(1, field_names[0], Bb); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasBb) { - size += pb::CodedOutputStream.ComputeMessageSize(1, Bb); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestMutualRecursionA ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestMutualRecursionA ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestMutualRecursionA ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestMutualRecursionA ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestMutualRecursionA ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestMutualRecursionA ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestMutualRecursionA ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestMutualRecursionA ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestMutualRecursionA ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestMutualRecursionA ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestMutualRecursionA MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestMutualRecursionA prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestMutualRecursionA cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestMutualRecursionA result; - - private TestMutualRecursionA PrepareBuilder() { - if (resultIsReadOnly) { - TestMutualRecursionA original = result; - result = new TestMutualRecursionA(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestMutualRecursionA MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionA.Descriptor; } - } - - public override TestMutualRecursionA DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionA.DefaultInstance; } - } - - public override TestMutualRecursionA BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestMutualRecursionA) { - return MergeFrom((TestMutualRecursionA) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestMutualRecursionA other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionA.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasBb) { - MergeBb(other.Bb); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testMutualRecursionAFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testMutualRecursionAFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 10: { - global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionB.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionB.CreateBuilder(); - if (result.hasBb) { - subBuilder.MergeFrom(Bb); - } - input.ReadMessage(subBuilder, extensionRegistry); - Bb = subBuilder.BuildPartial(); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasBb { - get { return result.hasBb; } - } - public global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionB Bb { - get { return result.Bb; } - set { SetBb(value); } - } - public Builder SetBb(global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionB value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasBb = true; - result.bb_ = value; - return this; - } - public Builder SetBb(global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionB.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasBb = true; - result.bb_ = builderForValue.Build(); - return this; - } - public Builder MergeBb(global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionB value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasBb && - result.bb_ != global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionB.DefaultInstance) { - result.bb_ = global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionB.CreateBuilder(result.bb_).MergeFrom(value).BuildPartial(); - } else { - result.bb_ = value; - } - result.hasBb = true; - return this; - } - public Builder ClearBb() { - PrepareBuilder(); - result.hasBb = false; - result.bb_ = null; - return this; - } - } - static TestMutualRecursionA() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestMutualRecursionB : pb::GeneratedMessage { - private TestMutualRecursionB() { } - private static readonly TestMutualRecursionB defaultInstance = new TestMutualRecursionB().MakeReadOnly(); - private static readonly string[] _testMutualRecursionBFieldNames = new string[] { "a", "optional_int32" }; - private static readonly uint[] _testMutualRecursionBFieldTags = new uint[] { 10, 16 }; - public static TestMutualRecursionB DefaultInstance { - get { return defaultInstance; } - } - - public override TestMutualRecursionB DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestMutualRecursionB ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestMutualRecursionB__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestMutualRecursionB__FieldAccessorTable; } - } - - public const int AFieldNumber = 1; - private bool hasA; - private global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionA a_; - public bool HasA { - get { return hasA; } - } - public global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionA A { - get { return a_ ?? global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionA.DefaultInstance; } - } - - public const int OptionalInt32FieldNumber = 2; - private bool hasOptionalInt32; - private int optionalInt32_; - public bool HasOptionalInt32 { - get { return hasOptionalInt32; } - } - public int OptionalInt32 { - get { return optionalInt32_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testMutualRecursionBFieldNames; - if (hasA) { - output.WriteMessage(1, field_names[0], A); - } - if (hasOptionalInt32) { - output.WriteInt32(2, field_names[1], OptionalInt32); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeMessageSize(1, A); - } - if (hasOptionalInt32) { - size += pb::CodedOutputStream.ComputeInt32Size(2, OptionalInt32); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestMutualRecursionB ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestMutualRecursionB ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestMutualRecursionB ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestMutualRecursionB ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestMutualRecursionB ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestMutualRecursionB ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestMutualRecursionB ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestMutualRecursionB ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestMutualRecursionB ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestMutualRecursionB ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestMutualRecursionB MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestMutualRecursionB prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestMutualRecursionB cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestMutualRecursionB result; - - private TestMutualRecursionB PrepareBuilder() { - if (resultIsReadOnly) { - TestMutualRecursionB original = result; - result = new TestMutualRecursionB(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestMutualRecursionB MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionB.Descriptor; } - } - - public override TestMutualRecursionB DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionB.DefaultInstance; } - } - - public override TestMutualRecursionB BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestMutualRecursionB) { - return MergeFrom((TestMutualRecursionB) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestMutualRecursionB other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionB.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasA) { - MergeA(other.A); - } - if (other.HasOptionalInt32) { - OptionalInt32 = other.OptionalInt32; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testMutualRecursionBFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testMutualRecursionBFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 10: { - global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionA.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionA.CreateBuilder(); - if (result.hasA) { - subBuilder.MergeFrom(A); - } - input.ReadMessage(subBuilder, extensionRegistry); - A = subBuilder.BuildPartial(); - break; - } - case 16: { - result.hasOptionalInt32 = input.ReadInt32(ref result.optionalInt32_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasA { - get { return result.hasA; } - } - public global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionA A { - get { return result.A; } - set { SetA(value); } - } - public Builder SetA(global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionA value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasA = true; - result.a_ = value; - return this; - } - public Builder SetA(global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionA.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasA = true; - result.a_ = builderForValue.Build(); - return this; - } - public Builder MergeA(global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionA value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasA && - result.a_ != global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionA.DefaultInstance) { - result.a_ = global::Google.ProtocolBuffers.TestProtos.TestMutualRecursionA.CreateBuilder(result.a_).MergeFrom(value).BuildPartial(); - } else { - result.a_ = value; - } - result.hasA = true; - return this; - } - public Builder ClearA() { - PrepareBuilder(); - result.hasA = false; - result.a_ = null; - return this; - } - - public bool HasOptionalInt32 { - get { return result.hasOptionalInt32; } - } - public int OptionalInt32 { - get { return result.OptionalInt32; } - set { SetOptionalInt32(value); } - } - public Builder SetOptionalInt32(int value) { - PrepareBuilder(); - result.hasOptionalInt32 = true; - result.optionalInt32_ = value; - return this; - } - public Builder ClearOptionalInt32() { - PrepareBuilder(); - result.hasOptionalInt32 = false; - result.optionalInt32_ = 0; - return this; - } - } - static TestMutualRecursionB() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestDupFieldNumber : pb::GeneratedMessage { - private TestDupFieldNumber() { } - private static readonly TestDupFieldNumber defaultInstance = new TestDupFieldNumber().MakeReadOnly(); - private static readonly string[] _testDupFieldNumberFieldNames = new string[] { "a", "bar", "foo" }; - private static readonly uint[] _testDupFieldNumberFieldTags = new uint[] { 8, 27, 19 }; - public static TestDupFieldNumber DefaultInstance { - get { return defaultInstance; } - } - - public override TestDupFieldNumber DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestDupFieldNumber ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestDupFieldNumber__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestDupFieldNumber__FieldAccessorTable; } - } - - #region Nested types - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class Types { - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Foo : pb::GeneratedMessage { - private Foo() { } - private static readonly Foo defaultInstance = new Foo().MakeReadOnly(); - private static readonly string[] _fooFieldNames = new string[] { "a" }; - private static readonly uint[] _fooFieldTags = new uint[] { 8 }; - public static Foo DefaultInstance { - get { return defaultInstance; } - } - - public override Foo DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override Foo ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestDupFieldNumber_Foo__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestDupFieldNumber_Foo__FieldAccessorTable; } - } - - public const int AFieldNumber = 1; - private bool hasA; - private int a_; - public bool HasA { - get { return hasA; } - } - public int A { - get { return a_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _fooFieldNames; - if (hasA) { - output.WriteInt32(1, field_names[0], A); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(1, A); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static Foo ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static Foo ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static Foo ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static Foo ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static Foo ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static Foo ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static Foo ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static Foo ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static Foo ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static Foo ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private Foo MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(Foo prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(Foo cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private Foo result; - - private Foo PrepareBuilder() { - if (resultIsReadOnly) { - Foo original = result; - result = new Foo(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override Foo MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Foo.Descriptor; } - } - - public override Foo DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Foo.DefaultInstance; } - } - - public override Foo BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is Foo) { - return MergeFrom((Foo) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(Foo other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Foo.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasA) { - A = other.A; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_fooFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _fooFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasA = input.ReadInt32(ref result.a_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasA { - get { return result.hasA; } - } - public int A { - get { return result.A; } - set { SetA(value); } - } - public Builder SetA(int value) { - PrepareBuilder(); - result.hasA = true; - result.a_ = value; - return this; - } - public Builder ClearA() { - PrepareBuilder(); - result.hasA = false; - result.a_ = 0; - return this; - } - } - static Foo() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Bar : pb::GeneratedMessage { - private Bar() { } - private static readonly Bar defaultInstance = new Bar().MakeReadOnly(); - private static readonly string[] _barFieldNames = new string[] { "a" }; - private static readonly uint[] _barFieldTags = new uint[] { 8 }; - public static Bar DefaultInstance { - get { return defaultInstance; } - } - - public override Bar DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override Bar ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestDupFieldNumber_Bar__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestDupFieldNumber_Bar__FieldAccessorTable; } - } - - public const int AFieldNumber = 1; - private bool hasA; - private int a_; - public bool HasA { - get { return hasA; } - } - public int A { - get { return a_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _barFieldNames; - if (hasA) { - output.WriteInt32(1, field_names[0], A); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(1, A); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static Bar ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static Bar ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static Bar ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static Bar ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static Bar ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static Bar ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static Bar ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static Bar ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static Bar ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static Bar ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private Bar MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(Bar prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(Bar cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private Bar result; - - private Bar PrepareBuilder() { - if (resultIsReadOnly) { - Bar original = result; - result = new Bar(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override Bar MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Bar.Descriptor; } - } - - public override Bar DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Bar.DefaultInstance; } - } - - public override Bar BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is Bar) { - return MergeFrom((Bar) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(Bar other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Bar.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasA) { - A = other.A; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_barFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _barFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasA = input.ReadInt32(ref result.a_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasA { - get { return result.hasA; } - } - public int A { - get { return result.A; } - set { SetA(value); } - } - public Builder SetA(int value) { - PrepareBuilder(); - result.hasA = true; - result.a_ = value; - return this; - } - public Builder ClearA() { - PrepareBuilder(); - result.hasA = false; - result.a_ = 0; - return this; - } - } - static Bar() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - } - #endregion - - public const int AFieldNumber = 1; - private bool hasA; - private int a_; - public bool HasA { - get { return hasA; } - } - public int A { - get { return a_; } - } - - public const int FooFieldNumber = 2; - private bool hasFoo; - private global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Foo foo_; - public bool HasFoo { - get { return hasFoo; } - } - public global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Foo Foo { - get { return foo_ ?? global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Foo.DefaultInstance; } - } - - public const int BarFieldNumber = 3; - private bool hasBar; - private global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Bar bar_; - public bool HasBar { - get { return hasBar; } - } - public global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Bar Bar { - get { return bar_ ?? global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Bar.DefaultInstance; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testDupFieldNumberFieldNames; - if (hasA) { - output.WriteInt32(1, field_names[0], A); - } - if (hasFoo) { - output.WriteGroup(2, field_names[2], Foo); - } - if (hasBar) { - output.WriteGroup(3, field_names[1], Bar); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(1, A); - } - if (hasFoo) { - size += pb::CodedOutputStream.ComputeGroupSize(2, Foo); - } - if (hasBar) { - size += pb::CodedOutputStream.ComputeGroupSize(3, Bar); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestDupFieldNumber ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestDupFieldNumber ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestDupFieldNumber ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestDupFieldNumber ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestDupFieldNumber ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestDupFieldNumber ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestDupFieldNumber ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestDupFieldNumber ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestDupFieldNumber ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestDupFieldNumber ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestDupFieldNumber MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestDupFieldNumber prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestDupFieldNumber cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestDupFieldNumber result; - - private TestDupFieldNumber PrepareBuilder() { - if (resultIsReadOnly) { - TestDupFieldNumber original = result; - result = new TestDupFieldNumber(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestDupFieldNumber MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Descriptor; } - } - - public override TestDupFieldNumber DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.DefaultInstance; } - } - - public override TestDupFieldNumber BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestDupFieldNumber) { - return MergeFrom((TestDupFieldNumber) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestDupFieldNumber other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasA) { - A = other.A; - } - if (other.HasFoo) { - MergeFoo(other.Foo); - } - if (other.HasBar) { - MergeBar(other.Bar); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testDupFieldNumberFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testDupFieldNumberFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasA = input.ReadInt32(ref result.a_); - break; - } - case 19: { - global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Foo.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Foo.CreateBuilder(); - if (result.hasFoo) { - subBuilder.MergeFrom(Foo); - } - input.ReadGroup(2, subBuilder, extensionRegistry); - Foo = subBuilder.BuildPartial(); - break; - } - case 27: { - global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Bar.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Bar.CreateBuilder(); - if (result.hasBar) { - subBuilder.MergeFrom(Bar); - } - input.ReadGroup(3, subBuilder, extensionRegistry); - Bar = subBuilder.BuildPartial(); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasA { - get { return result.hasA; } - } - public int A { - get { return result.A; } - set { SetA(value); } - } - public Builder SetA(int value) { - PrepareBuilder(); - result.hasA = true; - result.a_ = value; - return this; - } - public Builder ClearA() { - PrepareBuilder(); - result.hasA = false; - result.a_ = 0; - return this; - } - - public bool HasFoo { - get { return result.hasFoo; } - } - public global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Foo Foo { - get { return result.Foo; } - set { SetFoo(value); } - } - public Builder SetFoo(global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Foo value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasFoo = true; - result.foo_ = value; - return this; - } - public Builder SetFoo(global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Foo.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasFoo = true; - result.foo_ = builderForValue.Build(); - return this; - } - public Builder MergeFoo(global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Foo value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasFoo && - result.foo_ != global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Foo.DefaultInstance) { - result.foo_ = global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Foo.CreateBuilder(result.foo_).MergeFrom(value).BuildPartial(); - } else { - result.foo_ = value; - } - result.hasFoo = true; - return this; - } - public Builder ClearFoo() { - PrepareBuilder(); - result.hasFoo = false; - result.foo_ = null; - return this; - } - - public bool HasBar { - get { return result.hasBar; } - } - public global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Bar Bar { - get { return result.Bar; } - set { SetBar(value); } - } - public Builder SetBar(global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Bar value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasBar = true; - result.bar_ = value; - return this; - } - public Builder SetBar(global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Bar.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasBar = true; - result.bar_ = builderForValue.Build(); - return this; - } - public Builder MergeBar(global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Bar value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasBar && - result.bar_ != global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Bar.DefaultInstance) { - result.bar_ = global::Google.ProtocolBuffers.TestProtos.TestDupFieldNumber.Types.Bar.CreateBuilder(result.bar_).MergeFrom(value).BuildPartial(); - } else { - result.bar_ = value; - } - result.hasBar = true; - return this; - } - public Builder ClearBar() { - PrepareBuilder(); - result.hasBar = false; - result.bar_ = null; - return this; - } - } - static TestDupFieldNumber() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestEagerMessage : pb::GeneratedMessage { - private TestEagerMessage() { } - private static readonly TestEagerMessage defaultInstance = new TestEagerMessage().MakeReadOnly(); - private static readonly string[] _testEagerMessageFieldNames = new string[] { "sub_message" }; - private static readonly uint[] _testEagerMessageFieldTags = new uint[] { 10 }; - public static TestEagerMessage DefaultInstance { - get { return defaultInstance; } - } - - public override TestEagerMessage DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestEagerMessage ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestEagerMessage__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestEagerMessage__FieldAccessorTable; } - } - - public const int SubMessageFieldNumber = 1; - private bool hasSubMessage; - private global::Google.ProtocolBuffers.TestProtos.TestAllTypes subMessage_; - public bool HasSubMessage { - get { return hasSubMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes SubMessage { - get { return subMessage_ ?? global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testEagerMessageFieldNames; - if (hasSubMessage) { - output.WriteMessage(1, field_names[0], SubMessage); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasSubMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(1, SubMessage); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestEagerMessage ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestEagerMessage ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestEagerMessage ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestEagerMessage ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestEagerMessage ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestEagerMessage ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestEagerMessage ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestEagerMessage ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestEagerMessage ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestEagerMessage ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestEagerMessage MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestEagerMessage prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestEagerMessage cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestEagerMessage result; - - private TestEagerMessage PrepareBuilder() { - if (resultIsReadOnly) { - TestEagerMessage original = result; - result = new TestEagerMessage(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestEagerMessage MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestEagerMessage.Descriptor; } - } - - public override TestEagerMessage DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestEagerMessage.DefaultInstance; } - } - - public override TestEagerMessage BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestEagerMessage) { - return MergeFrom((TestEagerMessage) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestEagerMessage other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestEagerMessage.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasSubMessage) { - MergeSubMessage(other.SubMessage); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testEagerMessageFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testEagerMessageFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 10: { - global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.CreateBuilder(); - if (result.hasSubMessage) { - subBuilder.MergeFrom(SubMessage); - } - input.ReadMessage(subBuilder, extensionRegistry); - SubMessage = subBuilder.BuildPartial(); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasSubMessage { - get { return result.hasSubMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes SubMessage { - get { return result.SubMessage; } - set { SetSubMessage(value); } - } - public Builder SetSubMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasSubMessage = true; - result.subMessage_ = value; - return this; - } - public Builder SetSubMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasSubMessage = true; - result.subMessage_ = builderForValue.Build(); - return this; - } - public Builder MergeSubMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasSubMessage && - result.subMessage_ != global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance) { - result.subMessage_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.CreateBuilder(result.subMessage_).MergeFrom(value).BuildPartial(); - } else { - result.subMessage_ = value; - } - result.hasSubMessage = true; - return this; - } - public Builder ClearSubMessage() { - PrepareBuilder(); - result.hasSubMessage = false; - result.subMessage_ = null; - return this; - } - } - static TestEagerMessage() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestLazyMessage : pb::GeneratedMessage { - private TestLazyMessage() { } - private static readonly TestLazyMessage defaultInstance = new TestLazyMessage().MakeReadOnly(); - private static readonly string[] _testLazyMessageFieldNames = new string[] { "sub_message" }; - private static readonly uint[] _testLazyMessageFieldTags = new uint[] { 10 }; - public static TestLazyMessage DefaultInstance { - get { return defaultInstance; } - } - - public override TestLazyMessage DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestLazyMessage ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestLazyMessage__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestLazyMessage__FieldAccessorTable; } - } - - public const int SubMessageFieldNumber = 1; - private bool hasSubMessage; - private global::Google.ProtocolBuffers.TestProtos.TestAllTypes subMessage_; - public bool HasSubMessage { - get { return hasSubMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes SubMessage { - get { return subMessage_ ?? global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testLazyMessageFieldNames; - if (hasSubMessage) { - output.WriteMessage(1, field_names[0], SubMessage); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasSubMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(1, SubMessage); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestLazyMessage ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestLazyMessage ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestLazyMessage ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestLazyMessage ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestLazyMessage ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestLazyMessage ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestLazyMessage ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestLazyMessage ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestLazyMessage ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestLazyMessage ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestLazyMessage MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestLazyMessage prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestLazyMessage cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestLazyMessage result; - - private TestLazyMessage PrepareBuilder() { - if (resultIsReadOnly) { - TestLazyMessage original = result; - result = new TestLazyMessage(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestLazyMessage MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestLazyMessage.Descriptor; } - } - - public override TestLazyMessage DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestLazyMessage.DefaultInstance; } - } - - public override TestLazyMessage BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestLazyMessage) { - return MergeFrom((TestLazyMessage) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestLazyMessage other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestLazyMessage.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasSubMessage) { - MergeSubMessage(other.SubMessage); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testLazyMessageFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testLazyMessageFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 10: { - global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.CreateBuilder(); - if (result.hasSubMessage) { - subBuilder.MergeFrom(SubMessage); - } - input.ReadMessage(subBuilder, extensionRegistry); - SubMessage = subBuilder.BuildPartial(); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasSubMessage { - get { return result.hasSubMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes SubMessage { - get { return result.SubMessage; } - set { SetSubMessage(value); } - } - public Builder SetSubMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasSubMessage = true; - result.subMessage_ = value; - return this; - } - public Builder SetSubMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasSubMessage = true; - result.subMessage_ = builderForValue.Build(); - return this; - } - public Builder MergeSubMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasSubMessage && - result.subMessage_ != global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance) { - result.subMessage_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.CreateBuilder(result.subMessage_).MergeFrom(value).BuildPartial(); - } else { - result.subMessage_ = value; - } - result.hasSubMessage = true; - return this; - } - public Builder ClearSubMessage() { - PrepareBuilder(); - result.hasSubMessage = false; - result.subMessage_ = null; - return this; - } - } - static TestLazyMessage() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestNestedMessageHasBits : pb::GeneratedMessage { - private TestNestedMessageHasBits() { } - private static readonly TestNestedMessageHasBits defaultInstance = new TestNestedMessageHasBits().MakeReadOnly(); - private static readonly string[] _testNestedMessageHasBitsFieldNames = new string[] { "optional_nested_message" }; - private static readonly uint[] _testNestedMessageHasBitsFieldTags = new uint[] { 10 }; - public static TestNestedMessageHasBits DefaultInstance { - get { return defaultInstance; } - } - - public override TestNestedMessageHasBits DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestNestedMessageHasBits ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestNestedMessageHasBits__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestNestedMessageHasBits__FieldAccessorTable; } - } - - #region Nested types - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class Types { - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class NestedMessage : pb::GeneratedMessage { - private NestedMessage() { } - private static readonly NestedMessage defaultInstance = new NestedMessage().MakeReadOnly(); - private static readonly string[] _nestedMessageFieldNames = new string[] { "nestedmessage_repeated_foreignmessage", "nestedmessage_repeated_int32" }; - private static readonly uint[] _nestedMessageFieldTags = new uint[] { 18, 8 }; - public static NestedMessage DefaultInstance { - get { return defaultInstance; } - } - - public override NestedMessage DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override NestedMessage ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestNestedMessageHasBits_NestedMessage__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestNestedMessageHasBits_NestedMessage__FieldAccessorTable; } - } - - public const int NestedmessageRepeatedInt32FieldNumber = 1; - private pbc::PopsicleList nestedmessageRepeatedInt32_ = new pbc::PopsicleList(); - public scg::IList NestedmessageRepeatedInt32List { - get { return pbc::Lists.AsReadOnly(nestedmessageRepeatedInt32_); } - } - public int NestedmessageRepeatedInt32Count { - get { return nestedmessageRepeatedInt32_.Count; } - } - public int GetNestedmessageRepeatedInt32(int index) { - return nestedmessageRepeatedInt32_[index]; - } - - public const int NestedmessageRepeatedForeignmessageFieldNumber = 2; - private pbc::PopsicleList nestedmessageRepeatedForeignmessage_ = new pbc::PopsicleList(); - public scg::IList NestedmessageRepeatedForeignmessageList { - get { return nestedmessageRepeatedForeignmessage_; } - } - public int NestedmessageRepeatedForeignmessageCount { - get { return nestedmessageRepeatedForeignmessage_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignMessage GetNestedmessageRepeatedForeignmessage(int index) { - return nestedmessageRepeatedForeignmessage_[index]; - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _nestedMessageFieldNames; - if (nestedmessageRepeatedInt32_.Count > 0) { - output.WriteInt32Array(1, field_names[1], nestedmessageRepeatedInt32_); - } - if (nestedmessageRepeatedForeignmessage_.Count > 0) { - output.WriteMessageArray(2, field_names[0], nestedmessageRepeatedForeignmessage_); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - { - int dataSize = 0; - foreach (int element in NestedmessageRepeatedInt32List) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); - } - size += dataSize; - size += 1 * nestedmessageRepeatedInt32_.Count; - } - foreach (global::Google.ProtocolBuffers.TestProtos.ForeignMessage element in NestedmessageRepeatedForeignmessageList) { - size += pb::CodedOutputStream.ComputeMessageSize(2, element); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static NestedMessage ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static NestedMessage ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static NestedMessage ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static NestedMessage ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static NestedMessage ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static NestedMessage ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static NestedMessage ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static NestedMessage ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static NestedMessage ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static NestedMessage ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private NestedMessage MakeReadOnly() { - nestedmessageRepeatedInt32_.MakeReadOnly(); - nestedmessageRepeatedForeignmessage_.MakeReadOnly(); - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(NestedMessage prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(NestedMessage cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private NestedMessage result; - - private NestedMessage PrepareBuilder() { - if (resultIsReadOnly) { - NestedMessage original = result; - result = new NestedMessage(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override NestedMessage MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestNestedMessageHasBits.Types.NestedMessage.Descriptor; } - } - - public override NestedMessage DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestNestedMessageHasBits.Types.NestedMessage.DefaultInstance; } - } - - public override NestedMessage BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is NestedMessage) { - return MergeFrom((NestedMessage) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(NestedMessage other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestNestedMessageHasBits.Types.NestedMessage.DefaultInstance) return this; - PrepareBuilder(); - if (other.nestedmessageRepeatedInt32_.Count != 0) { - result.nestedmessageRepeatedInt32_.Add(other.nestedmessageRepeatedInt32_); - } - if (other.nestedmessageRepeatedForeignmessage_.Count != 0) { - result.nestedmessageRepeatedForeignmessage_.Add(other.nestedmessageRepeatedForeignmessage_); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_nestedMessageFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _nestedMessageFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 10: - case 8: { - input.ReadInt32Array(tag, field_name, result.nestedmessageRepeatedInt32_); - break; - } - case 18: { - input.ReadMessageArray(tag, field_name, result.nestedmessageRepeatedForeignmessage_, global::Google.ProtocolBuffers.TestProtos.ForeignMessage.DefaultInstance, extensionRegistry); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public pbc::IPopsicleList NestedmessageRepeatedInt32List { - get { return PrepareBuilder().nestedmessageRepeatedInt32_; } - } - public int NestedmessageRepeatedInt32Count { - get { return result.NestedmessageRepeatedInt32Count; } - } - public int GetNestedmessageRepeatedInt32(int index) { - return result.GetNestedmessageRepeatedInt32(index); - } - public Builder SetNestedmessageRepeatedInt32(int index, int value) { - PrepareBuilder(); - result.nestedmessageRepeatedInt32_[index] = value; - return this; - } - public Builder AddNestedmessageRepeatedInt32(int value) { - PrepareBuilder(); - result.nestedmessageRepeatedInt32_.Add(value); - return this; - } - public Builder AddRangeNestedmessageRepeatedInt32(scg::IEnumerable values) { - PrepareBuilder(); - result.nestedmessageRepeatedInt32_.Add(values); - return this; - } - public Builder ClearNestedmessageRepeatedInt32() { - PrepareBuilder(); - result.nestedmessageRepeatedInt32_.Clear(); - return this; - } - - public pbc::IPopsicleList NestedmessageRepeatedForeignmessageList { - get { return PrepareBuilder().nestedmessageRepeatedForeignmessage_; } - } - public int NestedmessageRepeatedForeignmessageCount { - get { return result.NestedmessageRepeatedForeignmessageCount; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignMessage GetNestedmessageRepeatedForeignmessage(int index) { - return result.GetNestedmessageRepeatedForeignmessage(index); - } - public Builder SetNestedmessageRepeatedForeignmessage(int index, global::Google.ProtocolBuffers.TestProtos.ForeignMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.nestedmessageRepeatedForeignmessage_[index] = value; - return this; - } - public Builder SetNestedmessageRepeatedForeignmessage(int index, global::Google.ProtocolBuffers.TestProtos.ForeignMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.nestedmessageRepeatedForeignmessage_[index] = builderForValue.Build(); - return this; - } - public Builder AddNestedmessageRepeatedForeignmessage(global::Google.ProtocolBuffers.TestProtos.ForeignMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.nestedmessageRepeatedForeignmessage_.Add(value); - return this; - } - public Builder AddNestedmessageRepeatedForeignmessage(global::Google.ProtocolBuffers.TestProtos.ForeignMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.nestedmessageRepeatedForeignmessage_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeNestedmessageRepeatedForeignmessage(scg::IEnumerable values) { - PrepareBuilder(); - result.nestedmessageRepeatedForeignmessage_.Add(values); - return this; - } - public Builder ClearNestedmessageRepeatedForeignmessage() { - PrepareBuilder(); - result.nestedmessageRepeatedForeignmessage_.Clear(); - return this; - } - } - static NestedMessage() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - } - #endregion - - public const int OptionalNestedMessageFieldNumber = 1; - private bool hasOptionalNestedMessage; - private global::Google.ProtocolBuffers.TestProtos.TestNestedMessageHasBits.Types.NestedMessage optionalNestedMessage_; - public bool HasOptionalNestedMessage { - get { return hasOptionalNestedMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestNestedMessageHasBits.Types.NestedMessage OptionalNestedMessage { - get { return optionalNestedMessage_ ?? global::Google.ProtocolBuffers.TestProtos.TestNestedMessageHasBits.Types.NestedMessage.DefaultInstance; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testNestedMessageHasBitsFieldNames; - if (hasOptionalNestedMessage) { - output.WriteMessage(1, field_names[0], OptionalNestedMessage); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasOptionalNestedMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(1, OptionalNestedMessage); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestNestedMessageHasBits ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestNestedMessageHasBits ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestNestedMessageHasBits ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestNestedMessageHasBits ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestNestedMessageHasBits ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestNestedMessageHasBits ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestNestedMessageHasBits ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestNestedMessageHasBits ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestNestedMessageHasBits ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestNestedMessageHasBits ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestNestedMessageHasBits MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestNestedMessageHasBits prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestNestedMessageHasBits cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestNestedMessageHasBits result; - - private TestNestedMessageHasBits PrepareBuilder() { - if (resultIsReadOnly) { - TestNestedMessageHasBits original = result; - result = new TestNestedMessageHasBits(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestNestedMessageHasBits MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestNestedMessageHasBits.Descriptor; } - } - - public override TestNestedMessageHasBits DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestNestedMessageHasBits.DefaultInstance; } - } - - public override TestNestedMessageHasBits BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestNestedMessageHasBits) { - return MergeFrom((TestNestedMessageHasBits) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestNestedMessageHasBits other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestNestedMessageHasBits.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasOptionalNestedMessage) { - MergeOptionalNestedMessage(other.OptionalNestedMessage); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testNestedMessageHasBitsFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testNestedMessageHasBitsFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 10: { - global::Google.ProtocolBuffers.TestProtos.TestNestedMessageHasBits.Types.NestedMessage.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestNestedMessageHasBits.Types.NestedMessage.CreateBuilder(); - if (result.hasOptionalNestedMessage) { - subBuilder.MergeFrom(OptionalNestedMessage); - } - input.ReadMessage(subBuilder, extensionRegistry); - OptionalNestedMessage = subBuilder.BuildPartial(); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasOptionalNestedMessage { - get { return result.hasOptionalNestedMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestNestedMessageHasBits.Types.NestedMessage OptionalNestedMessage { - get { return result.OptionalNestedMessage; } - set { SetOptionalNestedMessage(value); } - } - public Builder SetOptionalNestedMessage(global::Google.ProtocolBuffers.TestProtos.TestNestedMessageHasBits.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOptionalNestedMessage = true; - result.optionalNestedMessage_ = value; - return this; - } - public Builder SetOptionalNestedMessage(global::Google.ProtocolBuffers.TestProtos.TestNestedMessageHasBits.Types.NestedMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasOptionalNestedMessage = true; - result.optionalNestedMessage_ = builderForValue.Build(); - return this; - } - public Builder MergeOptionalNestedMessage(global::Google.ProtocolBuffers.TestProtos.TestNestedMessageHasBits.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasOptionalNestedMessage && - result.optionalNestedMessage_ != global::Google.ProtocolBuffers.TestProtos.TestNestedMessageHasBits.Types.NestedMessage.DefaultInstance) { - result.optionalNestedMessage_ = global::Google.ProtocolBuffers.TestProtos.TestNestedMessageHasBits.Types.NestedMessage.CreateBuilder(result.optionalNestedMessage_).MergeFrom(value).BuildPartial(); - } else { - result.optionalNestedMessage_ = value; - } - result.hasOptionalNestedMessage = true; - return this; - } - public Builder ClearOptionalNestedMessage() { - PrepareBuilder(); - result.hasOptionalNestedMessage = false; - result.optionalNestedMessage_ = null; - return this; - } - } - static TestNestedMessageHasBits() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestCamelCaseFieldNames : pb::GeneratedMessage { - private TestCamelCaseFieldNames() { } - private static readonly TestCamelCaseFieldNames defaultInstance = new TestCamelCaseFieldNames().MakeReadOnly(); - private static readonly string[] _testCamelCaseFieldNamesFieldNames = new string[] { "CordField", "EnumField", "MessageField", "PrimitiveField", "RepeatedCordField", "RepeatedEnumField", "RepeatedMessageField", "RepeatedPrimitiveField", "RepeatedStringField", "RepeatedStringPieceField", "StringField", "StringPieceField" }; - private static readonly uint[] _testCamelCaseFieldNamesFieldTags = new uint[] { 50, 24, 34, 8, 98, 72, 82, 56, 66, 90, 18, 42 }; - public static TestCamelCaseFieldNames DefaultInstance { - get { return defaultInstance; } - } - - public override TestCamelCaseFieldNames DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestCamelCaseFieldNames ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestCamelCaseFieldNames__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestCamelCaseFieldNames__FieldAccessorTable; } - } - - public const int PrimitiveFieldFieldNumber = 1; - private bool hasPrimitiveField; - private int primitiveField_; - public bool HasPrimitiveField { - get { return hasPrimitiveField; } - } - public int PrimitiveField { - get { return primitiveField_; } - } - - public const int StringFieldFieldNumber = 2; - private bool hasStringField; - private string stringField_ = ""; - public bool HasStringField { - get { return hasStringField; } - } - public string StringField { - get { return stringField_; } - } - - public const int EnumFieldFieldNumber = 3; - private bool hasEnumField; - private global::Google.ProtocolBuffers.TestProtos.ForeignEnum enumField_ = global::Google.ProtocolBuffers.TestProtos.ForeignEnum.FOREIGN_FOO; - public bool HasEnumField { - get { return hasEnumField; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignEnum EnumField { - get { return enumField_; } - } - - public const int MessageFieldFieldNumber = 4; - private bool hasMessageField; - private global::Google.ProtocolBuffers.TestProtos.ForeignMessage messageField_; - public bool HasMessageField { - get { return hasMessageField; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignMessage MessageField { - get { return messageField_ ?? global::Google.ProtocolBuffers.TestProtos.ForeignMessage.DefaultInstance; } - } - - public const int StringPieceFieldFieldNumber = 5; - private bool hasStringPieceField; - private string stringPieceField_ = ""; - public bool HasStringPieceField { - get { return hasStringPieceField; } - } - public string StringPieceField { - get { return stringPieceField_; } - } - - public const int CordFieldFieldNumber = 6; - private bool hasCordField; - private string cordField_ = ""; - public bool HasCordField { - get { return hasCordField; } - } - public string CordField { - get { return cordField_; } - } - - public const int RepeatedPrimitiveFieldFieldNumber = 7; - private pbc::PopsicleList repeatedPrimitiveField_ = new pbc::PopsicleList(); - public scg::IList RepeatedPrimitiveFieldList { - get { return pbc::Lists.AsReadOnly(repeatedPrimitiveField_); } - } - public int RepeatedPrimitiveFieldCount { - get { return repeatedPrimitiveField_.Count; } - } - public int GetRepeatedPrimitiveField(int index) { - return repeatedPrimitiveField_[index]; - } - - public const int RepeatedStringFieldFieldNumber = 8; - private pbc::PopsicleList repeatedStringField_ = new pbc::PopsicleList(); - public scg::IList RepeatedStringFieldList { - get { return pbc::Lists.AsReadOnly(repeatedStringField_); } - } - public int RepeatedStringFieldCount { - get { return repeatedStringField_.Count; } - } - public string GetRepeatedStringField(int index) { - return repeatedStringField_[index]; - } - - public const int RepeatedEnumFieldFieldNumber = 9; - private pbc::PopsicleList repeatedEnumField_ = new pbc::PopsicleList(); - public scg::IList RepeatedEnumFieldList { - get { return pbc::Lists.AsReadOnly(repeatedEnumField_); } - } - public int RepeatedEnumFieldCount { - get { return repeatedEnumField_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignEnum GetRepeatedEnumField(int index) { - return repeatedEnumField_[index]; - } - - public const int RepeatedMessageFieldFieldNumber = 10; - private pbc::PopsicleList repeatedMessageField_ = new pbc::PopsicleList(); - public scg::IList RepeatedMessageFieldList { - get { return repeatedMessageField_; } - } - public int RepeatedMessageFieldCount { - get { return repeatedMessageField_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignMessage GetRepeatedMessageField(int index) { - return repeatedMessageField_[index]; - } - - public const int RepeatedStringPieceFieldFieldNumber = 11; - private pbc::PopsicleList repeatedStringPieceField_ = new pbc::PopsicleList(); - public scg::IList RepeatedStringPieceFieldList { - get { return pbc::Lists.AsReadOnly(repeatedStringPieceField_); } - } - public int RepeatedStringPieceFieldCount { - get { return repeatedStringPieceField_.Count; } - } - public string GetRepeatedStringPieceField(int index) { - return repeatedStringPieceField_[index]; - } - - public const int RepeatedCordFieldFieldNumber = 12; - private pbc::PopsicleList repeatedCordField_ = new pbc::PopsicleList(); - public scg::IList RepeatedCordFieldList { - get { return pbc::Lists.AsReadOnly(repeatedCordField_); } - } - public int RepeatedCordFieldCount { - get { return repeatedCordField_.Count; } - } - public string GetRepeatedCordField(int index) { - return repeatedCordField_[index]; - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testCamelCaseFieldNamesFieldNames; - if (hasPrimitiveField) { - output.WriteInt32(1, field_names[3], PrimitiveField); - } - if (hasStringField) { - output.WriteString(2, field_names[10], StringField); - } - if (hasEnumField) { - output.WriteEnum(3, field_names[1], (int) EnumField, EnumField); - } - if (hasMessageField) { - output.WriteMessage(4, field_names[2], MessageField); - } - if (hasStringPieceField) { - output.WriteString(5, field_names[11], StringPieceField); - } - if (hasCordField) { - output.WriteString(6, field_names[0], CordField); - } - if (repeatedPrimitiveField_.Count > 0) { - output.WriteInt32Array(7, field_names[7], repeatedPrimitiveField_); - } - if (repeatedStringField_.Count > 0) { - output.WriteStringArray(8, field_names[8], repeatedStringField_); - } - if (repeatedEnumField_.Count > 0) { - output.WriteEnumArray(9, field_names[5], repeatedEnumField_); - } - if (repeatedMessageField_.Count > 0) { - output.WriteMessageArray(10, field_names[6], repeatedMessageField_); - } - if (repeatedStringPieceField_.Count > 0) { - output.WriteStringArray(11, field_names[9], repeatedStringPieceField_); - } - if (repeatedCordField_.Count > 0) { - output.WriteStringArray(12, field_names[4], repeatedCordField_); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasPrimitiveField) { - size += pb::CodedOutputStream.ComputeInt32Size(1, PrimitiveField); - } - if (hasStringField) { - size += pb::CodedOutputStream.ComputeStringSize(2, StringField); - } - if (hasEnumField) { - size += pb::CodedOutputStream.ComputeEnumSize(3, (int) EnumField); - } - if (hasMessageField) { - size += pb::CodedOutputStream.ComputeMessageSize(4, MessageField); - } - if (hasStringPieceField) { - size += pb::CodedOutputStream.ComputeStringSize(5, StringPieceField); - } - if (hasCordField) { - size += pb::CodedOutputStream.ComputeStringSize(6, CordField); - } - { - int dataSize = 0; - foreach (int element in RepeatedPrimitiveFieldList) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); - } - size += dataSize; - size += 1 * repeatedPrimitiveField_.Count; - } - { - int dataSize = 0; - foreach (string element in RepeatedStringFieldList) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); - } - size += dataSize; - size += 1 * repeatedStringField_.Count; - } - { - int dataSize = 0; - if (repeatedEnumField_.Count > 0) { - foreach (global::Google.ProtocolBuffers.TestProtos.ForeignEnum element in repeatedEnumField_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 1 * repeatedEnumField_.Count; - } - } - foreach (global::Google.ProtocolBuffers.TestProtos.ForeignMessage element in RepeatedMessageFieldList) { - size += pb::CodedOutputStream.ComputeMessageSize(10, element); - } - { - int dataSize = 0; - foreach (string element in RepeatedStringPieceFieldList) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); - } - size += dataSize; - size += 1 * repeatedStringPieceField_.Count; - } - { - int dataSize = 0; - foreach (string element in RepeatedCordFieldList) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); - } - size += dataSize; - size += 1 * repeatedCordField_.Count; - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestCamelCaseFieldNames ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestCamelCaseFieldNames ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestCamelCaseFieldNames ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestCamelCaseFieldNames ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestCamelCaseFieldNames ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestCamelCaseFieldNames ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestCamelCaseFieldNames ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestCamelCaseFieldNames ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestCamelCaseFieldNames ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestCamelCaseFieldNames ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestCamelCaseFieldNames MakeReadOnly() { - repeatedPrimitiveField_.MakeReadOnly(); - repeatedStringField_.MakeReadOnly(); - repeatedEnumField_.MakeReadOnly(); - repeatedMessageField_.MakeReadOnly(); - repeatedStringPieceField_.MakeReadOnly(); - repeatedCordField_.MakeReadOnly(); - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestCamelCaseFieldNames prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestCamelCaseFieldNames cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestCamelCaseFieldNames result; - - private TestCamelCaseFieldNames PrepareBuilder() { - if (resultIsReadOnly) { - TestCamelCaseFieldNames original = result; - result = new TestCamelCaseFieldNames(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestCamelCaseFieldNames MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestCamelCaseFieldNames.Descriptor; } - } - - public override TestCamelCaseFieldNames DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestCamelCaseFieldNames.DefaultInstance; } - } - - public override TestCamelCaseFieldNames BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestCamelCaseFieldNames) { - return MergeFrom((TestCamelCaseFieldNames) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestCamelCaseFieldNames other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestCamelCaseFieldNames.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasPrimitiveField) { - PrimitiveField = other.PrimitiveField; - } - if (other.HasStringField) { - StringField = other.StringField; - } - if (other.HasEnumField) { - EnumField = other.EnumField; - } - if (other.HasMessageField) { - MergeMessageField(other.MessageField); - } - if (other.HasStringPieceField) { - StringPieceField = other.StringPieceField; - } - if (other.HasCordField) { - CordField = other.CordField; - } - if (other.repeatedPrimitiveField_.Count != 0) { - result.repeatedPrimitiveField_.Add(other.repeatedPrimitiveField_); - } - if (other.repeatedStringField_.Count != 0) { - result.repeatedStringField_.Add(other.repeatedStringField_); - } - if (other.repeatedEnumField_.Count != 0) { - result.repeatedEnumField_.Add(other.repeatedEnumField_); - } - if (other.repeatedMessageField_.Count != 0) { - result.repeatedMessageField_.Add(other.repeatedMessageField_); - } - if (other.repeatedStringPieceField_.Count != 0) { - result.repeatedStringPieceField_.Add(other.repeatedStringPieceField_); - } - if (other.repeatedCordField_.Count != 0) { - result.repeatedCordField_.Add(other.repeatedCordField_); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testCamelCaseFieldNamesFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testCamelCaseFieldNamesFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasPrimitiveField = input.ReadInt32(ref result.primitiveField_); - break; - } - case 18: { - result.hasStringField = input.ReadString(ref result.stringField_); - break; - } - case 24: { - object unknown; - if(input.ReadEnum(ref result.enumField_, out unknown)) { - result.hasEnumField = true; - } else if(unknown is int) { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - unknownFields.MergeVarintField(3, (ulong)(int)unknown); - } - break; - } - case 34: { - global::Google.ProtocolBuffers.TestProtos.ForeignMessage.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.ForeignMessage.CreateBuilder(); - if (result.hasMessageField) { - subBuilder.MergeFrom(MessageField); - } - input.ReadMessage(subBuilder, extensionRegistry); - MessageField = subBuilder.BuildPartial(); - break; - } - case 42: { - result.hasStringPieceField = input.ReadString(ref result.stringPieceField_); - break; - } - case 50: { - result.hasCordField = input.ReadString(ref result.cordField_); - break; - } - case 58: - case 56: { - input.ReadInt32Array(tag, field_name, result.repeatedPrimitiveField_); - break; - } - case 66: { - input.ReadStringArray(tag, field_name, result.repeatedStringField_); - break; - } - case 74: - case 72: { - scg::ICollection unknownItems; - input.ReadEnumArray(tag, field_name, result.repeatedEnumField_, out unknownItems); - if (unknownItems != null) { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - foreach (object rawValue in unknownItems) - if (rawValue is int) - unknownFields.MergeVarintField(9, (ulong)(int)rawValue); - } - break; - } - case 82: { - input.ReadMessageArray(tag, field_name, result.repeatedMessageField_, global::Google.ProtocolBuffers.TestProtos.ForeignMessage.DefaultInstance, extensionRegistry); - break; - } - case 90: { - input.ReadStringArray(tag, field_name, result.repeatedStringPieceField_); - break; - } - case 98: { - input.ReadStringArray(tag, field_name, result.repeatedCordField_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasPrimitiveField { - get { return result.hasPrimitiveField; } - } - public int PrimitiveField { - get { return result.PrimitiveField; } - set { SetPrimitiveField(value); } - } - public Builder SetPrimitiveField(int value) { - PrepareBuilder(); - result.hasPrimitiveField = true; - result.primitiveField_ = value; - return this; - } - public Builder ClearPrimitiveField() { - PrepareBuilder(); - result.hasPrimitiveField = false; - result.primitiveField_ = 0; - return this; - } - - public bool HasStringField { - get { return result.hasStringField; } - } - public string StringField { - get { return result.StringField; } - set { SetStringField(value); } - } - public Builder SetStringField(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasStringField = true; - result.stringField_ = value; - return this; - } - public Builder ClearStringField() { - PrepareBuilder(); - result.hasStringField = false; - result.stringField_ = ""; - return this; - } - - public bool HasEnumField { - get { return result.hasEnumField; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignEnum EnumField { - get { return result.EnumField; } - set { SetEnumField(value); } - } - public Builder SetEnumField(global::Google.ProtocolBuffers.TestProtos.ForeignEnum value) { - PrepareBuilder(); - result.hasEnumField = true; - result.enumField_ = value; - return this; - } - public Builder ClearEnumField() { - PrepareBuilder(); - result.hasEnumField = false; - result.enumField_ = global::Google.ProtocolBuffers.TestProtos.ForeignEnum.FOREIGN_FOO; - return this; - } - - public bool HasMessageField { - get { return result.hasMessageField; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignMessage MessageField { - get { return result.MessageField; } - set { SetMessageField(value); } - } - public Builder SetMessageField(global::Google.ProtocolBuffers.TestProtos.ForeignMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasMessageField = true; - result.messageField_ = value; - return this; - } - public Builder SetMessageField(global::Google.ProtocolBuffers.TestProtos.ForeignMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasMessageField = true; - result.messageField_ = builderForValue.Build(); - return this; - } - public Builder MergeMessageField(global::Google.ProtocolBuffers.TestProtos.ForeignMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasMessageField && - result.messageField_ != global::Google.ProtocolBuffers.TestProtos.ForeignMessage.DefaultInstance) { - result.messageField_ = global::Google.ProtocolBuffers.TestProtos.ForeignMessage.CreateBuilder(result.messageField_).MergeFrom(value).BuildPartial(); - } else { - result.messageField_ = value; - } - result.hasMessageField = true; - return this; - } - public Builder ClearMessageField() { - PrepareBuilder(); - result.hasMessageField = false; - result.messageField_ = null; - return this; - } - - public bool HasStringPieceField { - get { return result.hasStringPieceField; } - } - public string StringPieceField { - get { return result.StringPieceField; } - set { SetStringPieceField(value); } - } - public Builder SetStringPieceField(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasStringPieceField = true; - result.stringPieceField_ = value; - return this; - } - public Builder ClearStringPieceField() { - PrepareBuilder(); - result.hasStringPieceField = false; - result.stringPieceField_ = ""; - return this; - } - - public bool HasCordField { - get { return result.hasCordField; } - } - public string CordField { - get { return result.CordField; } - set { SetCordField(value); } - } - public Builder SetCordField(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasCordField = true; - result.cordField_ = value; - return this; - } - public Builder ClearCordField() { - PrepareBuilder(); - result.hasCordField = false; - result.cordField_ = ""; - return this; - } - - public pbc::IPopsicleList RepeatedPrimitiveFieldList { - get { return PrepareBuilder().repeatedPrimitiveField_; } - } - public int RepeatedPrimitiveFieldCount { - get { return result.RepeatedPrimitiveFieldCount; } - } - public int GetRepeatedPrimitiveField(int index) { - return result.GetRepeatedPrimitiveField(index); - } - public Builder SetRepeatedPrimitiveField(int index, int value) { - PrepareBuilder(); - result.repeatedPrimitiveField_[index] = value; - return this; - } - public Builder AddRepeatedPrimitiveField(int value) { - PrepareBuilder(); - result.repeatedPrimitiveField_.Add(value); - return this; - } - public Builder AddRangeRepeatedPrimitiveField(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedPrimitiveField_.Add(values); - return this; - } - public Builder ClearRepeatedPrimitiveField() { - PrepareBuilder(); - result.repeatedPrimitiveField_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedStringFieldList { - get { return PrepareBuilder().repeatedStringField_; } - } - public int RepeatedStringFieldCount { - get { return result.RepeatedStringFieldCount; } - } - public string GetRepeatedStringField(int index) { - return result.GetRepeatedStringField(index); - } - public Builder SetRepeatedStringField(int index, string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedStringField_[index] = value; - return this; - } - public Builder AddRepeatedStringField(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedStringField_.Add(value); - return this; - } - public Builder AddRangeRepeatedStringField(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedStringField_.Add(values); - return this; - } - public Builder ClearRepeatedStringField() { - PrepareBuilder(); - result.repeatedStringField_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedEnumFieldList { - get { return PrepareBuilder().repeatedEnumField_; } - } - public int RepeatedEnumFieldCount { - get { return result.RepeatedEnumFieldCount; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignEnum GetRepeatedEnumField(int index) { - return result.GetRepeatedEnumField(index); - } - public Builder SetRepeatedEnumField(int index, global::Google.ProtocolBuffers.TestProtos.ForeignEnum value) { - PrepareBuilder(); - result.repeatedEnumField_[index] = value; - return this; - } - public Builder AddRepeatedEnumField(global::Google.ProtocolBuffers.TestProtos.ForeignEnum value) { - PrepareBuilder(); - result.repeatedEnumField_.Add(value); - return this; - } - public Builder AddRangeRepeatedEnumField(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedEnumField_.Add(values); - return this; - } - public Builder ClearRepeatedEnumField() { - PrepareBuilder(); - result.repeatedEnumField_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedMessageFieldList { - get { return PrepareBuilder().repeatedMessageField_; } - } - public int RepeatedMessageFieldCount { - get { return result.RepeatedMessageFieldCount; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignMessage GetRepeatedMessageField(int index) { - return result.GetRepeatedMessageField(index); - } - public Builder SetRepeatedMessageField(int index, global::Google.ProtocolBuffers.TestProtos.ForeignMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedMessageField_[index] = value; - return this; - } - public Builder SetRepeatedMessageField(int index, global::Google.ProtocolBuffers.TestProtos.ForeignMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.repeatedMessageField_[index] = builderForValue.Build(); - return this; - } - public Builder AddRepeatedMessageField(global::Google.ProtocolBuffers.TestProtos.ForeignMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedMessageField_.Add(value); - return this; - } - public Builder AddRepeatedMessageField(global::Google.ProtocolBuffers.TestProtos.ForeignMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.repeatedMessageField_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeRepeatedMessageField(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedMessageField_.Add(values); - return this; - } - public Builder ClearRepeatedMessageField() { - PrepareBuilder(); - result.repeatedMessageField_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedStringPieceFieldList { - get { return PrepareBuilder().repeatedStringPieceField_; } - } - public int RepeatedStringPieceFieldCount { - get { return result.RepeatedStringPieceFieldCount; } - } - public string GetRepeatedStringPieceField(int index) { - return result.GetRepeatedStringPieceField(index); - } - public Builder SetRepeatedStringPieceField(int index, string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedStringPieceField_[index] = value; - return this; - } - public Builder AddRepeatedStringPieceField(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedStringPieceField_.Add(value); - return this; - } - public Builder AddRangeRepeatedStringPieceField(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedStringPieceField_.Add(values); - return this; - } - public Builder ClearRepeatedStringPieceField() { - PrepareBuilder(); - result.repeatedStringPieceField_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedCordFieldList { - get { return PrepareBuilder().repeatedCordField_; } - } - public int RepeatedCordFieldCount { - get { return result.RepeatedCordFieldCount; } - } - public string GetRepeatedCordField(int index) { - return result.GetRepeatedCordField(index); - } - public Builder SetRepeatedCordField(int index, string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedCordField_[index] = value; - return this; - } - public Builder AddRepeatedCordField(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedCordField_.Add(value); - return this; - } - public Builder AddRangeRepeatedCordField(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedCordField_.Add(values); - return this; - } - public Builder ClearRepeatedCordField() { - PrepareBuilder(); - result.repeatedCordField_.Clear(); - return this; - } - } - static TestCamelCaseFieldNames() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestFieldOrderings : pb::ExtendableMessage { - private TestFieldOrderings() { } - private static readonly TestFieldOrderings defaultInstance = new TestFieldOrderings().MakeReadOnly(); - private static readonly string[] _testFieldOrderingsFieldNames = new string[] { "my_float", "my_int", "my_string", "optional_nested_message" }; - private static readonly uint[] _testFieldOrderingsFieldTags = new uint[] { 813, 8, 90, 1602 }; - public static TestFieldOrderings DefaultInstance { - get { return defaultInstance; } - } - - public override TestFieldOrderings DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestFieldOrderings ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestFieldOrderings__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestFieldOrderings__FieldAccessorTable; } - } - - #region Nested types - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class Types { - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class NestedMessage : pb::GeneratedMessage { - private NestedMessage() { } - private static readonly NestedMessage defaultInstance = new NestedMessage().MakeReadOnly(); - private static readonly string[] _nestedMessageFieldNames = new string[] { "bb", "oo" }; - private static readonly uint[] _nestedMessageFieldTags = new uint[] { 8, 16 }; - public static NestedMessage DefaultInstance { - get { return defaultInstance; } - } - - public override NestedMessage DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override NestedMessage ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestFieldOrderings_NestedMessage__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestFieldOrderings_NestedMessage__FieldAccessorTable; } - } - - public const int OoFieldNumber = 2; - private bool hasOo; - private long oo_; - public bool HasOo { - get { return hasOo; } - } - public long Oo { - get { return oo_; } - } - - public const int BbFieldNumber = 1; - private bool hasBb; - private int bb_; - public bool HasBb { - get { return hasBb; } - } - public int Bb { - get { return bb_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _nestedMessageFieldNames; - if (hasBb) { - output.WriteInt32(1, field_names[0], Bb); - } - if (hasOo) { - output.WriteInt64(2, field_names[1], Oo); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasOo) { - size += pb::CodedOutputStream.ComputeInt64Size(2, Oo); - } - if (hasBb) { - size += pb::CodedOutputStream.ComputeInt32Size(1, Bb); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static NestedMessage ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static NestedMessage ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static NestedMessage ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static NestedMessage ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static NestedMessage ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static NestedMessage ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static NestedMessage ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static NestedMessage ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static NestedMessage ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static NestedMessage ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private NestedMessage MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(NestedMessage prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(NestedMessage cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private NestedMessage result; - - private NestedMessage PrepareBuilder() { - if (resultIsReadOnly) { - NestedMessage original = result; - result = new NestedMessage(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override NestedMessage MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestFieldOrderings.Types.NestedMessage.Descriptor; } - } - - public override NestedMessage DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestFieldOrderings.Types.NestedMessage.DefaultInstance; } - } - - public override NestedMessage BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is NestedMessage) { - return MergeFrom((NestedMessage) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(NestedMessage other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestFieldOrderings.Types.NestedMessage.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasOo) { - Oo = other.Oo; - } - if (other.HasBb) { - Bb = other.Bb; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_nestedMessageFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _nestedMessageFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasBb = input.ReadInt32(ref result.bb_); - break; - } - case 16: { - result.hasOo = input.ReadInt64(ref result.oo_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasOo { - get { return result.hasOo; } - } - public long Oo { - get { return result.Oo; } - set { SetOo(value); } - } - public Builder SetOo(long value) { - PrepareBuilder(); - result.hasOo = true; - result.oo_ = value; - return this; - } - public Builder ClearOo() { - PrepareBuilder(); - result.hasOo = false; - result.oo_ = 0L; - return this; - } - - public bool HasBb { - get { return result.hasBb; } - } - public int Bb { - get { return result.Bb; } - set { SetBb(value); } - } - public Builder SetBb(int value) { - PrepareBuilder(); - result.hasBb = true; - result.bb_ = value; - return this; - } - public Builder ClearBb() { - PrepareBuilder(); - result.hasBb = false; - result.bb_ = 0; - return this; - } - } - static NestedMessage() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - } - #endregion - - public const int MyStringFieldNumber = 11; - private bool hasMyString; - private string myString_ = ""; - public bool HasMyString { - get { return hasMyString; } - } - public string MyString { - get { return myString_; } - } - - public const int MyIntFieldNumber = 1; - private bool hasMyInt; - private long myInt_; - public bool HasMyInt { - get { return hasMyInt; } - } - public long MyInt { - get { return myInt_; } - } - - public const int MyFloatFieldNumber = 101; - private bool hasMyFloat; - private float myFloat_; - public bool HasMyFloat { - get { return hasMyFloat; } - } - public float MyFloat { - get { return myFloat_; } - } - - public const int OptionalNestedMessageFieldNumber = 200; - private bool hasOptionalNestedMessage; - private global::Google.ProtocolBuffers.TestProtos.TestFieldOrderings.Types.NestedMessage optionalNestedMessage_; - public bool HasOptionalNestedMessage { - get { return hasOptionalNestedMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestFieldOrderings.Types.NestedMessage OptionalNestedMessage { - get { return optionalNestedMessage_ ?? global::Google.ProtocolBuffers.TestProtos.TestFieldOrderings.Types.NestedMessage.DefaultInstance; } - } - - public override bool IsInitialized { - get { - if (!ExtensionsAreInitialized) return false; - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testFieldOrderingsFieldNames; - pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); - if (hasMyInt) { - output.WriteInt64(1, field_names[1], MyInt); - } - extensionWriter.WriteUntil(11, output); - if (hasMyString) { - output.WriteString(11, field_names[2], MyString); - } - extensionWriter.WriteUntil(101, output); - if (hasMyFloat) { - output.WriteFloat(101, field_names[0], MyFloat); - } - if (hasOptionalNestedMessage) { - output.WriteMessage(200, field_names[3], OptionalNestedMessage); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasMyString) { - size += pb::CodedOutputStream.ComputeStringSize(11, MyString); - } - if (hasMyInt) { - size += pb::CodedOutputStream.ComputeInt64Size(1, MyInt); - } - if (hasMyFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(101, MyFloat); - } - if (hasOptionalNestedMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(200, OptionalNestedMessage); - } - size += ExtensionsSerializedSize; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestFieldOrderings ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestFieldOrderings ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestFieldOrderings ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestFieldOrderings ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestFieldOrderings ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestFieldOrderings ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestFieldOrderings ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestFieldOrderings ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestFieldOrderings ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestFieldOrderings ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestFieldOrderings MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestFieldOrderings prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::ExtendableBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestFieldOrderings cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestFieldOrderings result; - - private TestFieldOrderings PrepareBuilder() { - if (resultIsReadOnly) { - TestFieldOrderings original = result; - result = new TestFieldOrderings(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestFieldOrderings MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestFieldOrderings.Descriptor; } - } - - public override TestFieldOrderings DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestFieldOrderings.DefaultInstance; } - } - - public override TestFieldOrderings BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestFieldOrderings) { - return MergeFrom((TestFieldOrderings) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestFieldOrderings other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestFieldOrderings.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasMyString) { - MyString = other.MyString; - } - if (other.HasMyInt) { - MyInt = other.MyInt; - } - if (other.HasMyFloat) { - MyFloat = other.MyFloat; - } - if (other.HasOptionalNestedMessage) { - MergeOptionalNestedMessage(other.OptionalNestedMessage); - } - this.MergeExtensionFields(other); - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testFieldOrderingsFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testFieldOrderingsFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasMyInt = input.ReadInt64(ref result.myInt_); - break; - } - case 90: { - result.hasMyString = input.ReadString(ref result.myString_); - break; - } - case 813: { - result.hasMyFloat = input.ReadFloat(ref result.myFloat_); - break; - } - case 1602: { - global::Google.ProtocolBuffers.TestProtos.TestFieldOrderings.Types.NestedMessage.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestFieldOrderings.Types.NestedMessage.CreateBuilder(); - if (result.hasOptionalNestedMessage) { - subBuilder.MergeFrom(OptionalNestedMessage); - } - input.ReadMessage(subBuilder, extensionRegistry); - OptionalNestedMessage = subBuilder.BuildPartial(); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasMyString { - get { return result.hasMyString; } - } - public string MyString { - get { return result.MyString; } - set { SetMyString(value); } - } - public Builder SetMyString(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasMyString = true; - result.myString_ = value; - return this; - } - public Builder ClearMyString() { - PrepareBuilder(); - result.hasMyString = false; - result.myString_ = ""; - return this; - } - - public bool HasMyInt { - get { return result.hasMyInt; } - } - public long MyInt { - get { return result.MyInt; } - set { SetMyInt(value); } - } - public Builder SetMyInt(long value) { - PrepareBuilder(); - result.hasMyInt = true; - result.myInt_ = value; - return this; - } - public Builder ClearMyInt() { - PrepareBuilder(); - result.hasMyInt = false; - result.myInt_ = 0L; - return this; - } - - public bool HasMyFloat { - get { return result.hasMyFloat; } - } - public float MyFloat { - get { return result.MyFloat; } - set { SetMyFloat(value); } - } - public Builder SetMyFloat(float value) { - PrepareBuilder(); - result.hasMyFloat = true; - result.myFloat_ = value; - return this; - } - public Builder ClearMyFloat() { - PrepareBuilder(); - result.hasMyFloat = false; - result.myFloat_ = 0F; - return this; - } - - public bool HasOptionalNestedMessage { - get { return result.hasOptionalNestedMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestFieldOrderings.Types.NestedMessage OptionalNestedMessage { - get { return result.OptionalNestedMessage; } - set { SetOptionalNestedMessage(value); } - } - public Builder SetOptionalNestedMessage(global::Google.ProtocolBuffers.TestProtos.TestFieldOrderings.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOptionalNestedMessage = true; - result.optionalNestedMessage_ = value; - return this; - } - public Builder SetOptionalNestedMessage(global::Google.ProtocolBuffers.TestProtos.TestFieldOrderings.Types.NestedMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasOptionalNestedMessage = true; - result.optionalNestedMessage_ = builderForValue.Build(); - return this; - } - public Builder MergeOptionalNestedMessage(global::Google.ProtocolBuffers.TestProtos.TestFieldOrderings.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasOptionalNestedMessage && - result.optionalNestedMessage_ != global::Google.ProtocolBuffers.TestProtos.TestFieldOrderings.Types.NestedMessage.DefaultInstance) { - result.optionalNestedMessage_ = global::Google.ProtocolBuffers.TestProtos.TestFieldOrderings.Types.NestedMessage.CreateBuilder(result.optionalNestedMessage_).MergeFrom(value).BuildPartial(); - } else { - result.optionalNestedMessage_ = value; - } - result.hasOptionalNestedMessage = true; - return this; - } - public Builder ClearOptionalNestedMessage() { - PrepareBuilder(); - result.hasOptionalNestedMessage = false; - result.optionalNestedMessage_ = null; - return this; - } - } - static TestFieldOrderings() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestExtremeDefaultValues : pb::GeneratedMessage { - private TestExtremeDefaultValues() { } - private static readonly TestExtremeDefaultValues defaultInstance = new TestExtremeDefaultValues().MakeReadOnly(); - private static readonly string[] _testExtremeDefaultValuesFieldNames = new string[] { "bytes_with_zero", "cord_with_zero", "cpp_trigraph", "escaped_bytes", "inf_double", "inf_float", "large_float", "large_uint32", "large_uint64", "nan_double", "nan_float", "neg_inf_double", "neg_inf_float", "negative_float", "negative_one_float", "one_float", "really_small_int32", "really_small_int64", "replacement_string", "small_float", "small_int32", "small_int64", "small_negative_float", "string_piece_with_zero", "string_with_zero", "utf8_string", "zero_float" }; - private static readonly uint[] _testExtremeDefaultValuesFieldTags = new uint[] { 194, 210, 162, 10, 113, 141, 101, 16, 24, 129, 157, 121, 149, 93, 85, 69, 168, 176, 218, 77, 32, 40, 109, 202, 186, 50, 61 }; - public static TestExtremeDefaultValues DefaultInstance { - get { return defaultInstance; } - } - - public override TestExtremeDefaultValues DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestExtremeDefaultValues ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestExtremeDefaultValues__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestExtremeDefaultValues__FieldAccessorTable; } - } - - public const int EscapedBytesFieldNumber = 1; - private bool hasEscapedBytes; - private pb::ByteString escapedBytes_ = (pb::ByteString) global::Google.ProtocolBuffers.TestProtos.TestExtremeDefaultValues.Descriptor.Fields[0].DefaultValue; - public bool HasEscapedBytes { - get { return hasEscapedBytes; } - } - public pb::ByteString EscapedBytes { - get { return escapedBytes_; } - } - - public const int LargeUint32FieldNumber = 2; - private bool hasLargeUint32; - private uint largeUint32_ = 4294967295; - public bool HasLargeUint32 { - get { return hasLargeUint32; } - } - [global::System.CLSCompliant(false)] - public uint LargeUint32 { - get { return largeUint32_; } - } - - public const int LargeUint64FieldNumber = 3; - private bool hasLargeUint64; - private ulong largeUint64_ = 18446744073709551615UL; - public bool HasLargeUint64 { - get { return hasLargeUint64; } - } - [global::System.CLSCompliant(false)] - public ulong LargeUint64 { - get { return largeUint64_; } - } - - public const int SmallInt32FieldNumber = 4; - private bool hasSmallInt32; - private int smallInt32_ = -2147483647; - public bool HasSmallInt32 { - get { return hasSmallInt32; } - } - public int SmallInt32 { - get { return smallInt32_; } - } - - public const int SmallInt64FieldNumber = 5; - private bool hasSmallInt64; - private long smallInt64_ = -9223372036854775807L; - public bool HasSmallInt64 { - get { return hasSmallInt64; } - } - public long SmallInt64 { - get { return smallInt64_; } - } - - public const int ReallySmallInt32FieldNumber = 21; - private bool hasReallySmallInt32; - private int reallySmallInt32_ = -2147483648; - public bool HasReallySmallInt32 { - get { return hasReallySmallInt32; } - } - public int ReallySmallInt32 { - get { return reallySmallInt32_; } - } - - public const int ReallySmallInt64FieldNumber = 22; - private bool hasReallySmallInt64; - private long reallySmallInt64_ = -9223372036854775808L; - public bool HasReallySmallInt64 { - get { return hasReallySmallInt64; } - } - public long ReallySmallInt64 { - get { return reallySmallInt64_; } - } - - public const int Utf8StringFieldNumber = 6; - private bool hasUtf8String; - private string utf8String_ = (string) global::Google.ProtocolBuffers.TestProtos.TestExtremeDefaultValues.Descriptor.Fields[7].DefaultValue; - public bool HasUtf8String { - get { return hasUtf8String; } - } - public string Utf8String { - get { return utf8String_; } - } - - public const int ZeroFloatFieldNumber = 7; - private bool hasZeroFloat; - private float zeroFloat_; - public bool HasZeroFloat { - get { return hasZeroFloat; } - } - public float ZeroFloat { - get { return zeroFloat_; } - } - - public const int OneFloatFieldNumber = 8; - private bool hasOneFloat; - private float oneFloat_ = 1F; - public bool HasOneFloat { - get { return hasOneFloat; } - } - public float OneFloat { - get { return oneFloat_; } - } - - public const int SmallFloatFieldNumber = 9; - private bool hasSmallFloat; - private float smallFloat_ = 1.5F; - public bool HasSmallFloat { - get { return hasSmallFloat; } - } - public float SmallFloat { - get { return smallFloat_; } - } - - public const int NegativeOneFloatFieldNumber = 10; - private bool hasNegativeOneFloat; - private float negativeOneFloat_ = -1F; - public bool HasNegativeOneFloat { - get { return hasNegativeOneFloat; } - } - public float NegativeOneFloat { - get { return negativeOneFloat_; } - } - - public const int NegativeFloatFieldNumber = 11; - private bool hasNegativeFloat; - private float negativeFloat_ = -1.5F; - public bool HasNegativeFloat { - get { return hasNegativeFloat; } - } - public float NegativeFloat { - get { return negativeFloat_; } - } - - public const int LargeFloatFieldNumber = 12; - private bool hasLargeFloat; - private float largeFloat_ = 2e+08F; - public bool HasLargeFloat { - get { return hasLargeFloat; } - } - public float LargeFloat { - get { return largeFloat_; } - } - - public const int SmallNegativeFloatFieldNumber = 13; - private bool hasSmallNegativeFloat; - private float smallNegativeFloat_ = -8e-28F; - public bool HasSmallNegativeFloat { - get { return hasSmallNegativeFloat; } - } - public float SmallNegativeFloat { - get { return smallNegativeFloat_; } - } - - public const int InfDoubleFieldNumber = 14; - private bool hasInfDouble; - private double infDouble_ = double.PositiveInfinity; - public bool HasInfDouble { - get { return hasInfDouble; } - } - public double InfDouble { - get { return infDouble_; } - } - - public const int NegInfDoubleFieldNumber = 15; - private bool hasNegInfDouble; - private double negInfDouble_ = double.NegativeInfinity; - public bool HasNegInfDouble { - get { return hasNegInfDouble; } - } - public double NegInfDouble { - get { return negInfDouble_; } - } - - public const int NanDoubleFieldNumber = 16; - private bool hasNanDouble; - private double nanDouble_ = double.NaN; - public bool HasNanDouble { - get { return hasNanDouble; } - } - public double NanDouble { - get { return nanDouble_; } - } - - public const int InfFloatFieldNumber = 17; - private bool hasInfFloat; - private float infFloat_ = float.PositiveInfinity; - public bool HasInfFloat { - get { return hasInfFloat; } - } - public float InfFloat { - get { return infFloat_; } - } - - public const int NegInfFloatFieldNumber = 18; - private bool hasNegInfFloat; - private float negInfFloat_ = float.NegativeInfinity; - public bool HasNegInfFloat { - get { return hasNegInfFloat; } - } - public float NegInfFloat { - get { return negInfFloat_; } - } - - public const int NanFloatFieldNumber = 19; - private bool hasNanFloat; - private float nanFloat_ = float.NaN; - public bool HasNanFloat { - get { return hasNanFloat; } - } - public float NanFloat { - get { return nanFloat_; } - } - - public const int CppTrigraphFieldNumber = 20; - private bool hasCppTrigraph; - private string cppTrigraph_ = "? ? ?? ?? ??? ??/ ??-"; - public bool HasCppTrigraph { - get { return hasCppTrigraph; } - } - public string CppTrigraph { - get { return cppTrigraph_; } - } - - public const int StringWithZeroFieldNumber = 23; - private bool hasStringWithZero; - private string stringWithZero_ = (string) global::Google.ProtocolBuffers.TestProtos.TestExtremeDefaultValues.Descriptor.Fields[22].DefaultValue; - public bool HasStringWithZero { - get { return hasStringWithZero; } - } - public string StringWithZero { - get { return stringWithZero_; } - } - - public const int BytesWithZeroFieldNumber = 24; - private bool hasBytesWithZero; - private pb::ByteString bytesWithZero_ = (pb::ByteString) global::Google.ProtocolBuffers.TestProtos.TestExtremeDefaultValues.Descriptor.Fields[23].DefaultValue; - public bool HasBytesWithZero { - get { return hasBytesWithZero; } - } - public pb::ByteString BytesWithZero { - get { return bytesWithZero_; } - } - - public const int StringPieceWithZeroFieldNumber = 25; - private bool hasStringPieceWithZero; - private string stringPieceWithZero_ = (string) global::Google.ProtocolBuffers.TestProtos.TestExtremeDefaultValues.Descriptor.Fields[24].DefaultValue; - public bool HasStringPieceWithZero { - get { return hasStringPieceWithZero; } - } - public string StringPieceWithZero { - get { return stringPieceWithZero_; } - } - - public const int CordWithZeroFieldNumber = 26; - private bool hasCordWithZero; - private string cordWithZero_ = (string) global::Google.ProtocolBuffers.TestProtos.TestExtremeDefaultValues.Descriptor.Fields[25].DefaultValue; - public bool HasCordWithZero { - get { return hasCordWithZero; } - } - public string CordWithZero { - get { return cordWithZero_; } - } - - public const int ReplacementStringFieldNumber = 27; - private bool hasReplacementString; - private string replacementString_ = "${unknown}"; - public bool HasReplacementString { - get { return hasReplacementString; } - } - public string ReplacementString { - get { return replacementString_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testExtremeDefaultValuesFieldNames; - if (hasEscapedBytes) { - output.WriteBytes(1, field_names[3], EscapedBytes); - } - if (hasLargeUint32) { - output.WriteUInt32(2, field_names[7], LargeUint32); - } - if (hasLargeUint64) { - output.WriteUInt64(3, field_names[8], LargeUint64); - } - if (hasSmallInt32) { - output.WriteInt32(4, field_names[20], SmallInt32); - } - if (hasSmallInt64) { - output.WriteInt64(5, field_names[21], SmallInt64); - } - if (hasUtf8String) { - output.WriteString(6, field_names[25], Utf8String); - } - if (hasZeroFloat) { - output.WriteFloat(7, field_names[26], ZeroFloat); - } - if (hasOneFloat) { - output.WriteFloat(8, field_names[15], OneFloat); - } - if (hasSmallFloat) { - output.WriteFloat(9, field_names[19], SmallFloat); - } - if (hasNegativeOneFloat) { - output.WriteFloat(10, field_names[14], NegativeOneFloat); - } - if (hasNegativeFloat) { - output.WriteFloat(11, field_names[13], NegativeFloat); - } - if (hasLargeFloat) { - output.WriteFloat(12, field_names[6], LargeFloat); - } - if (hasSmallNegativeFloat) { - output.WriteFloat(13, field_names[22], SmallNegativeFloat); - } - if (hasInfDouble) { - output.WriteDouble(14, field_names[4], InfDouble); - } - if (hasNegInfDouble) { - output.WriteDouble(15, field_names[11], NegInfDouble); - } - if (hasNanDouble) { - output.WriteDouble(16, field_names[9], NanDouble); - } - if (hasInfFloat) { - output.WriteFloat(17, field_names[5], InfFloat); - } - if (hasNegInfFloat) { - output.WriteFloat(18, field_names[12], NegInfFloat); - } - if (hasNanFloat) { - output.WriteFloat(19, field_names[10], NanFloat); - } - if (hasCppTrigraph) { - output.WriteString(20, field_names[2], CppTrigraph); - } - if (hasReallySmallInt32) { - output.WriteInt32(21, field_names[16], ReallySmallInt32); - } - if (hasReallySmallInt64) { - output.WriteInt64(22, field_names[17], ReallySmallInt64); - } - if (hasStringWithZero) { - output.WriteString(23, field_names[24], StringWithZero); - } - if (hasBytesWithZero) { - output.WriteBytes(24, field_names[0], BytesWithZero); - } - if (hasStringPieceWithZero) { - output.WriteString(25, field_names[23], StringPieceWithZero); - } - if (hasCordWithZero) { - output.WriteString(26, field_names[1], CordWithZero); - } - if (hasReplacementString) { - output.WriteString(27, field_names[18], ReplacementString); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasEscapedBytes) { - size += pb::CodedOutputStream.ComputeBytesSize(1, EscapedBytes); - } - if (hasLargeUint32) { - size += pb::CodedOutputStream.ComputeUInt32Size(2, LargeUint32); - } - if (hasLargeUint64) { - size += pb::CodedOutputStream.ComputeUInt64Size(3, LargeUint64); - } - if (hasSmallInt32) { - size += pb::CodedOutputStream.ComputeInt32Size(4, SmallInt32); - } - if (hasSmallInt64) { - size += pb::CodedOutputStream.ComputeInt64Size(5, SmallInt64); - } - if (hasReallySmallInt32) { - size += pb::CodedOutputStream.ComputeInt32Size(21, ReallySmallInt32); - } - if (hasReallySmallInt64) { - size += pb::CodedOutputStream.ComputeInt64Size(22, ReallySmallInt64); - } - if (hasUtf8String) { - size += pb::CodedOutputStream.ComputeStringSize(6, Utf8String); - } - if (hasZeroFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(7, ZeroFloat); - } - if (hasOneFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(8, OneFloat); - } - if (hasSmallFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(9, SmallFloat); - } - if (hasNegativeOneFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(10, NegativeOneFloat); - } - if (hasNegativeFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(11, NegativeFloat); - } - if (hasLargeFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(12, LargeFloat); - } - if (hasSmallNegativeFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(13, SmallNegativeFloat); - } - if (hasInfDouble) { - size += pb::CodedOutputStream.ComputeDoubleSize(14, InfDouble); - } - if (hasNegInfDouble) { - size += pb::CodedOutputStream.ComputeDoubleSize(15, NegInfDouble); - } - if (hasNanDouble) { - size += pb::CodedOutputStream.ComputeDoubleSize(16, NanDouble); - } - if (hasInfFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(17, InfFloat); - } - if (hasNegInfFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(18, NegInfFloat); - } - if (hasNanFloat) { - size += pb::CodedOutputStream.ComputeFloatSize(19, NanFloat); - } - if (hasCppTrigraph) { - size += pb::CodedOutputStream.ComputeStringSize(20, CppTrigraph); - } - if (hasStringWithZero) { - size += pb::CodedOutputStream.ComputeStringSize(23, StringWithZero); - } - if (hasBytesWithZero) { - size += pb::CodedOutputStream.ComputeBytesSize(24, BytesWithZero); - } - if (hasStringPieceWithZero) { - size += pb::CodedOutputStream.ComputeStringSize(25, StringPieceWithZero); - } - if (hasCordWithZero) { - size += pb::CodedOutputStream.ComputeStringSize(26, CordWithZero); - } - if (hasReplacementString) { - size += pb::CodedOutputStream.ComputeStringSize(27, ReplacementString); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestExtremeDefaultValues ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestExtremeDefaultValues ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestExtremeDefaultValues ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestExtremeDefaultValues ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestExtremeDefaultValues ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestExtremeDefaultValues ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestExtremeDefaultValues ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestExtremeDefaultValues ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestExtremeDefaultValues ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestExtremeDefaultValues ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestExtremeDefaultValues MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestExtremeDefaultValues prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestExtremeDefaultValues cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestExtremeDefaultValues result; - - private TestExtremeDefaultValues PrepareBuilder() { - if (resultIsReadOnly) { - TestExtremeDefaultValues original = result; - result = new TestExtremeDefaultValues(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestExtremeDefaultValues MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestExtremeDefaultValues.Descriptor; } - } - - public override TestExtremeDefaultValues DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestExtremeDefaultValues.DefaultInstance; } - } - - public override TestExtremeDefaultValues BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestExtremeDefaultValues) { - return MergeFrom((TestExtremeDefaultValues) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestExtremeDefaultValues other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestExtremeDefaultValues.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasEscapedBytes) { - EscapedBytes = other.EscapedBytes; - } - if (other.HasLargeUint32) { - LargeUint32 = other.LargeUint32; - } - if (other.HasLargeUint64) { - LargeUint64 = other.LargeUint64; - } - if (other.HasSmallInt32) { - SmallInt32 = other.SmallInt32; - } - if (other.HasSmallInt64) { - SmallInt64 = other.SmallInt64; - } - if (other.HasReallySmallInt32) { - ReallySmallInt32 = other.ReallySmallInt32; - } - if (other.HasReallySmallInt64) { - ReallySmallInt64 = other.ReallySmallInt64; - } - if (other.HasUtf8String) { - Utf8String = other.Utf8String; - } - if (other.HasZeroFloat) { - ZeroFloat = other.ZeroFloat; - } - if (other.HasOneFloat) { - OneFloat = other.OneFloat; - } - if (other.HasSmallFloat) { - SmallFloat = other.SmallFloat; - } - if (other.HasNegativeOneFloat) { - NegativeOneFloat = other.NegativeOneFloat; - } - if (other.HasNegativeFloat) { - NegativeFloat = other.NegativeFloat; - } - if (other.HasLargeFloat) { - LargeFloat = other.LargeFloat; - } - if (other.HasSmallNegativeFloat) { - SmallNegativeFloat = other.SmallNegativeFloat; - } - if (other.HasInfDouble) { - InfDouble = other.InfDouble; - } - if (other.HasNegInfDouble) { - NegInfDouble = other.NegInfDouble; - } - if (other.HasNanDouble) { - NanDouble = other.NanDouble; - } - if (other.HasInfFloat) { - InfFloat = other.InfFloat; - } - if (other.HasNegInfFloat) { - NegInfFloat = other.NegInfFloat; - } - if (other.HasNanFloat) { - NanFloat = other.NanFloat; - } - if (other.HasCppTrigraph) { - CppTrigraph = other.CppTrigraph; - } - if (other.HasStringWithZero) { - StringWithZero = other.StringWithZero; - } - if (other.HasBytesWithZero) { - BytesWithZero = other.BytesWithZero; - } - if (other.HasStringPieceWithZero) { - StringPieceWithZero = other.StringPieceWithZero; - } - if (other.HasCordWithZero) { - CordWithZero = other.CordWithZero; - } - if (other.HasReplacementString) { - ReplacementString = other.ReplacementString; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testExtremeDefaultValuesFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testExtremeDefaultValuesFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 10: { - result.hasEscapedBytes = input.ReadBytes(ref result.escapedBytes_); - break; - } - case 16: { - result.hasLargeUint32 = input.ReadUInt32(ref result.largeUint32_); - break; - } - case 24: { - result.hasLargeUint64 = input.ReadUInt64(ref result.largeUint64_); - break; - } - case 32: { - result.hasSmallInt32 = input.ReadInt32(ref result.smallInt32_); - break; - } - case 40: { - result.hasSmallInt64 = input.ReadInt64(ref result.smallInt64_); - break; - } - case 50: { - result.hasUtf8String = input.ReadString(ref result.utf8String_); - break; - } - case 61: { - result.hasZeroFloat = input.ReadFloat(ref result.zeroFloat_); - break; - } - case 69: { - result.hasOneFloat = input.ReadFloat(ref result.oneFloat_); - break; - } - case 77: { - result.hasSmallFloat = input.ReadFloat(ref result.smallFloat_); - break; - } - case 85: { - result.hasNegativeOneFloat = input.ReadFloat(ref result.negativeOneFloat_); - break; - } - case 93: { - result.hasNegativeFloat = input.ReadFloat(ref result.negativeFloat_); - break; - } - case 101: { - result.hasLargeFloat = input.ReadFloat(ref result.largeFloat_); - break; - } - case 109: { - result.hasSmallNegativeFloat = input.ReadFloat(ref result.smallNegativeFloat_); - break; - } - case 113: { - result.hasInfDouble = input.ReadDouble(ref result.infDouble_); - break; - } - case 121: { - result.hasNegInfDouble = input.ReadDouble(ref result.negInfDouble_); - break; - } - case 129: { - result.hasNanDouble = input.ReadDouble(ref result.nanDouble_); - break; - } - case 141: { - result.hasInfFloat = input.ReadFloat(ref result.infFloat_); - break; - } - case 149: { - result.hasNegInfFloat = input.ReadFloat(ref result.negInfFloat_); - break; - } - case 157: { - result.hasNanFloat = input.ReadFloat(ref result.nanFloat_); - break; - } - case 162: { - result.hasCppTrigraph = input.ReadString(ref result.cppTrigraph_); - break; - } - case 168: { - result.hasReallySmallInt32 = input.ReadInt32(ref result.reallySmallInt32_); - break; - } - case 176: { - result.hasReallySmallInt64 = input.ReadInt64(ref result.reallySmallInt64_); - break; - } - case 186: { - result.hasStringWithZero = input.ReadString(ref result.stringWithZero_); - break; - } - case 194: { - result.hasBytesWithZero = input.ReadBytes(ref result.bytesWithZero_); - break; - } - case 202: { - result.hasStringPieceWithZero = input.ReadString(ref result.stringPieceWithZero_); - break; - } - case 210: { - result.hasCordWithZero = input.ReadString(ref result.cordWithZero_); - break; - } - case 218: { - result.hasReplacementString = input.ReadString(ref result.replacementString_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasEscapedBytes { - get { return result.hasEscapedBytes; } - } - public pb::ByteString EscapedBytes { - get { return result.EscapedBytes; } - set { SetEscapedBytes(value); } - } - public Builder SetEscapedBytes(pb::ByteString value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasEscapedBytes = true; - result.escapedBytes_ = value; - return this; - } - public Builder ClearEscapedBytes() { - PrepareBuilder(); - result.hasEscapedBytes = false; - result.escapedBytes_ = (pb::ByteString) global::Google.ProtocolBuffers.TestProtos.TestExtremeDefaultValues.Descriptor.Fields[0].DefaultValue; - return this; - } - - public bool HasLargeUint32 { - get { return result.hasLargeUint32; } - } - [global::System.CLSCompliant(false)] - public uint LargeUint32 { - get { return result.LargeUint32; } - set { SetLargeUint32(value); } - } - [global::System.CLSCompliant(false)] - public Builder SetLargeUint32(uint value) { - PrepareBuilder(); - result.hasLargeUint32 = true; - result.largeUint32_ = value; - return this; - } - public Builder ClearLargeUint32() { - PrepareBuilder(); - result.hasLargeUint32 = false; - result.largeUint32_ = 4294967295; - return this; - } - - public bool HasLargeUint64 { - get { return result.hasLargeUint64; } - } - [global::System.CLSCompliant(false)] - public ulong LargeUint64 { - get { return result.LargeUint64; } - set { SetLargeUint64(value); } - } - [global::System.CLSCompliant(false)] - public Builder SetLargeUint64(ulong value) { - PrepareBuilder(); - result.hasLargeUint64 = true; - result.largeUint64_ = value; - return this; - } - public Builder ClearLargeUint64() { - PrepareBuilder(); - result.hasLargeUint64 = false; - result.largeUint64_ = 18446744073709551615UL; - return this; - } - - public bool HasSmallInt32 { - get { return result.hasSmallInt32; } - } - public int SmallInt32 { - get { return result.SmallInt32; } - set { SetSmallInt32(value); } - } - public Builder SetSmallInt32(int value) { - PrepareBuilder(); - result.hasSmallInt32 = true; - result.smallInt32_ = value; - return this; - } - public Builder ClearSmallInt32() { - PrepareBuilder(); - result.hasSmallInt32 = false; - result.smallInt32_ = -2147483647; - return this; - } - - public bool HasSmallInt64 { - get { return result.hasSmallInt64; } - } - public long SmallInt64 { - get { return result.SmallInt64; } - set { SetSmallInt64(value); } - } - public Builder SetSmallInt64(long value) { - PrepareBuilder(); - result.hasSmallInt64 = true; - result.smallInt64_ = value; - return this; - } - public Builder ClearSmallInt64() { - PrepareBuilder(); - result.hasSmallInt64 = false; - result.smallInt64_ = -9223372036854775807L; - return this; - } - - public bool HasReallySmallInt32 { - get { return result.hasReallySmallInt32; } - } - public int ReallySmallInt32 { - get { return result.ReallySmallInt32; } - set { SetReallySmallInt32(value); } - } - public Builder SetReallySmallInt32(int value) { - PrepareBuilder(); - result.hasReallySmallInt32 = true; - result.reallySmallInt32_ = value; - return this; - } - public Builder ClearReallySmallInt32() { - PrepareBuilder(); - result.hasReallySmallInt32 = false; - result.reallySmallInt32_ = -2147483648; - return this; - } - - public bool HasReallySmallInt64 { - get { return result.hasReallySmallInt64; } - } - public long ReallySmallInt64 { - get { return result.ReallySmallInt64; } - set { SetReallySmallInt64(value); } - } - public Builder SetReallySmallInt64(long value) { - PrepareBuilder(); - result.hasReallySmallInt64 = true; - result.reallySmallInt64_ = value; - return this; - } - public Builder ClearReallySmallInt64() { - PrepareBuilder(); - result.hasReallySmallInt64 = false; - result.reallySmallInt64_ = -9223372036854775808L; - return this; - } - - public bool HasUtf8String { - get { return result.hasUtf8String; } - } - public string Utf8String { - get { return result.Utf8String; } - set { SetUtf8String(value); } - } - public Builder SetUtf8String(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasUtf8String = true; - result.utf8String_ = value; - return this; - } - public Builder ClearUtf8String() { - PrepareBuilder(); - result.hasUtf8String = false; - result.utf8String_ = (string) global::Google.ProtocolBuffers.TestProtos.TestExtremeDefaultValues.Descriptor.Fields[7].DefaultValue; - return this; - } - - public bool HasZeroFloat { - get { return result.hasZeroFloat; } - } - public float ZeroFloat { - get { return result.ZeroFloat; } - set { SetZeroFloat(value); } - } - public Builder SetZeroFloat(float value) { - PrepareBuilder(); - result.hasZeroFloat = true; - result.zeroFloat_ = value; - return this; - } - public Builder ClearZeroFloat() { - PrepareBuilder(); - result.hasZeroFloat = false; - result.zeroFloat_ = 0F; - return this; - } - - public bool HasOneFloat { - get { return result.hasOneFloat; } - } - public float OneFloat { - get { return result.OneFloat; } - set { SetOneFloat(value); } - } - public Builder SetOneFloat(float value) { - PrepareBuilder(); - result.hasOneFloat = true; - result.oneFloat_ = value; - return this; - } - public Builder ClearOneFloat() { - PrepareBuilder(); - result.hasOneFloat = false; - result.oneFloat_ = 1F; - return this; - } - - public bool HasSmallFloat { - get { return result.hasSmallFloat; } - } - public float SmallFloat { - get { return result.SmallFloat; } - set { SetSmallFloat(value); } - } - public Builder SetSmallFloat(float value) { - PrepareBuilder(); - result.hasSmallFloat = true; - result.smallFloat_ = value; - return this; - } - public Builder ClearSmallFloat() { - PrepareBuilder(); - result.hasSmallFloat = false; - result.smallFloat_ = 1.5F; - return this; - } - - public bool HasNegativeOneFloat { - get { return result.hasNegativeOneFloat; } - } - public float NegativeOneFloat { - get { return result.NegativeOneFloat; } - set { SetNegativeOneFloat(value); } - } - public Builder SetNegativeOneFloat(float value) { - PrepareBuilder(); - result.hasNegativeOneFloat = true; - result.negativeOneFloat_ = value; - return this; - } - public Builder ClearNegativeOneFloat() { - PrepareBuilder(); - result.hasNegativeOneFloat = false; - result.negativeOneFloat_ = -1F; - return this; - } - - public bool HasNegativeFloat { - get { return result.hasNegativeFloat; } - } - public float NegativeFloat { - get { return result.NegativeFloat; } - set { SetNegativeFloat(value); } - } - public Builder SetNegativeFloat(float value) { - PrepareBuilder(); - result.hasNegativeFloat = true; - result.negativeFloat_ = value; - return this; - } - public Builder ClearNegativeFloat() { - PrepareBuilder(); - result.hasNegativeFloat = false; - result.negativeFloat_ = -1.5F; - return this; - } - - public bool HasLargeFloat { - get { return result.hasLargeFloat; } - } - public float LargeFloat { - get { return result.LargeFloat; } - set { SetLargeFloat(value); } - } - public Builder SetLargeFloat(float value) { - PrepareBuilder(); - result.hasLargeFloat = true; - result.largeFloat_ = value; - return this; - } - public Builder ClearLargeFloat() { - PrepareBuilder(); - result.hasLargeFloat = false; - result.largeFloat_ = 2e+08F; - return this; - } - - public bool HasSmallNegativeFloat { - get { return result.hasSmallNegativeFloat; } - } - public float SmallNegativeFloat { - get { return result.SmallNegativeFloat; } - set { SetSmallNegativeFloat(value); } - } - public Builder SetSmallNegativeFloat(float value) { - PrepareBuilder(); - result.hasSmallNegativeFloat = true; - result.smallNegativeFloat_ = value; - return this; - } - public Builder ClearSmallNegativeFloat() { - PrepareBuilder(); - result.hasSmallNegativeFloat = false; - result.smallNegativeFloat_ = -8e-28F; - return this; - } - - public bool HasInfDouble { - get { return result.hasInfDouble; } - } - public double InfDouble { - get { return result.InfDouble; } - set { SetInfDouble(value); } - } - public Builder SetInfDouble(double value) { - PrepareBuilder(); - result.hasInfDouble = true; - result.infDouble_ = value; - return this; - } - public Builder ClearInfDouble() { - PrepareBuilder(); - result.hasInfDouble = false; - result.infDouble_ = double.PositiveInfinity; - return this; - } - - public bool HasNegInfDouble { - get { return result.hasNegInfDouble; } - } - public double NegInfDouble { - get { return result.NegInfDouble; } - set { SetNegInfDouble(value); } - } - public Builder SetNegInfDouble(double value) { - PrepareBuilder(); - result.hasNegInfDouble = true; - result.negInfDouble_ = value; - return this; - } - public Builder ClearNegInfDouble() { - PrepareBuilder(); - result.hasNegInfDouble = false; - result.negInfDouble_ = double.NegativeInfinity; - return this; - } - - public bool HasNanDouble { - get { return result.hasNanDouble; } - } - public double NanDouble { - get { return result.NanDouble; } - set { SetNanDouble(value); } - } - public Builder SetNanDouble(double value) { - PrepareBuilder(); - result.hasNanDouble = true; - result.nanDouble_ = value; - return this; - } - public Builder ClearNanDouble() { - PrepareBuilder(); - result.hasNanDouble = false; - result.nanDouble_ = double.NaN; - return this; - } - - public bool HasInfFloat { - get { return result.hasInfFloat; } - } - public float InfFloat { - get { return result.InfFloat; } - set { SetInfFloat(value); } - } - public Builder SetInfFloat(float value) { - PrepareBuilder(); - result.hasInfFloat = true; - result.infFloat_ = value; - return this; - } - public Builder ClearInfFloat() { - PrepareBuilder(); - result.hasInfFloat = false; - result.infFloat_ = float.PositiveInfinity; - return this; - } - - public bool HasNegInfFloat { - get { return result.hasNegInfFloat; } - } - public float NegInfFloat { - get { return result.NegInfFloat; } - set { SetNegInfFloat(value); } - } - public Builder SetNegInfFloat(float value) { - PrepareBuilder(); - result.hasNegInfFloat = true; - result.negInfFloat_ = value; - return this; - } - public Builder ClearNegInfFloat() { - PrepareBuilder(); - result.hasNegInfFloat = false; - result.negInfFloat_ = float.NegativeInfinity; - return this; - } - - public bool HasNanFloat { - get { return result.hasNanFloat; } - } - public float NanFloat { - get { return result.NanFloat; } - set { SetNanFloat(value); } - } - public Builder SetNanFloat(float value) { - PrepareBuilder(); - result.hasNanFloat = true; - result.nanFloat_ = value; - return this; - } - public Builder ClearNanFloat() { - PrepareBuilder(); - result.hasNanFloat = false; - result.nanFloat_ = float.NaN; - return this; - } - - public bool HasCppTrigraph { - get { return result.hasCppTrigraph; } - } - public string CppTrigraph { - get { return result.CppTrigraph; } - set { SetCppTrigraph(value); } - } - public Builder SetCppTrigraph(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasCppTrigraph = true; - result.cppTrigraph_ = value; - return this; - } - public Builder ClearCppTrigraph() { - PrepareBuilder(); - result.hasCppTrigraph = false; - result.cppTrigraph_ = "? ? ?? ?? ??? ??/ ??-"; - return this; - } - - public bool HasStringWithZero { - get { return result.hasStringWithZero; } - } - public string StringWithZero { - get { return result.StringWithZero; } - set { SetStringWithZero(value); } - } - public Builder SetStringWithZero(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasStringWithZero = true; - result.stringWithZero_ = value; - return this; - } - public Builder ClearStringWithZero() { - PrepareBuilder(); - result.hasStringWithZero = false; - result.stringWithZero_ = (string) global::Google.ProtocolBuffers.TestProtos.TestExtremeDefaultValues.Descriptor.Fields[22].DefaultValue; - return this; - } - - public bool HasBytesWithZero { - get { return result.hasBytesWithZero; } - } - public pb::ByteString BytesWithZero { - get { return result.BytesWithZero; } - set { SetBytesWithZero(value); } - } - public Builder SetBytesWithZero(pb::ByteString value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasBytesWithZero = true; - result.bytesWithZero_ = value; - return this; - } - public Builder ClearBytesWithZero() { - PrepareBuilder(); - result.hasBytesWithZero = false; - result.bytesWithZero_ = (pb::ByteString) global::Google.ProtocolBuffers.TestProtos.TestExtremeDefaultValues.Descriptor.Fields[23].DefaultValue; - return this; - } - - public bool HasStringPieceWithZero { - get { return result.hasStringPieceWithZero; } - } - public string StringPieceWithZero { - get { return result.StringPieceWithZero; } - set { SetStringPieceWithZero(value); } - } - public Builder SetStringPieceWithZero(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasStringPieceWithZero = true; - result.stringPieceWithZero_ = value; - return this; - } - public Builder ClearStringPieceWithZero() { - PrepareBuilder(); - result.hasStringPieceWithZero = false; - result.stringPieceWithZero_ = (string) global::Google.ProtocolBuffers.TestProtos.TestExtremeDefaultValues.Descriptor.Fields[24].DefaultValue; - return this; - } - - public bool HasCordWithZero { - get { return result.hasCordWithZero; } - } - public string CordWithZero { - get { return result.CordWithZero; } - set { SetCordWithZero(value); } - } - public Builder SetCordWithZero(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasCordWithZero = true; - result.cordWithZero_ = value; - return this; - } - public Builder ClearCordWithZero() { - PrepareBuilder(); - result.hasCordWithZero = false; - result.cordWithZero_ = (string) global::Google.ProtocolBuffers.TestProtos.TestExtremeDefaultValues.Descriptor.Fields[25].DefaultValue; - return this; - } - - public bool HasReplacementString { - get { return result.hasReplacementString; } - } - public string ReplacementString { - get { return result.ReplacementString; } - set { SetReplacementString(value); } - } - public Builder SetReplacementString(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasReplacementString = true; - result.replacementString_ = value; - return this; - } - public Builder ClearReplacementString() { - PrepareBuilder(); - result.hasReplacementString = false; - result.replacementString_ = "${unknown}"; - return this; - } - } - static TestExtremeDefaultValues() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class SparseEnumMessage : pb::GeneratedMessage { - private SparseEnumMessage() { } - private static readonly SparseEnumMessage defaultInstance = new SparseEnumMessage().MakeReadOnly(); - private static readonly string[] _sparseEnumMessageFieldNames = new string[] { "sparse_enum" }; - private static readonly uint[] _sparseEnumMessageFieldTags = new uint[] { 8 }; - public static SparseEnumMessage DefaultInstance { - get { return defaultInstance; } - } - - public override SparseEnumMessage DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override SparseEnumMessage ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_SparseEnumMessage__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_SparseEnumMessage__FieldAccessorTable; } - } - - public const int SparseEnumFieldNumber = 1; - private bool hasSparseEnum; - private global::Google.ProtocolBuffers.TestProtos.TestSparseEnum sparseEnum_ = global::Google.ProtocolBuffers.TestProtos.TestSparseEnum.SPARSE_A; - public bool HasSparseEnum { - get { return hasSparseEnum; } - } - public global::Google.ProtocolBuffers.TestProtos.TestSparseEnum SparseEnum { - get { return sparseEnum_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _sparseEnumMessageFieldNames; - if (hasSparseEnum) { - output.WriteEnum(1, field_names[0], (int) SparseEnum, SparseEnum); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasSparseEnum) { - size += pb::CodedOutputStream.ComputeEnumSize(1, (int) SparseEnum); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static SparseEnumMessage ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static SparseEnumMessage ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static SparseEnumMessage ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static SparseEnumMessage ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static SparseEnumMessage ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static SparseEnumMessage ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static SparseEnumMessage ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static SparseEnumMessage ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static SparseEnumMessage ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static SparseEnumMessage ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private SparseEnumMessage MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(SparseEnumMessage prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(SparseEnumMessage cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private SparseEnumMessage result; - - private SparseEnumMessage PrepareBuilder() { - if (resultIsReadOnly) { - SparseEnumMessage original = result; - result = new SparseEnumMessage(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override SparseEnumMessage MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.SparseEnumMessage.Descriptor; } - } - - public override SparseEnumMessage DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.SparseEnumMessage.DefaultInstance; } - } - - public override SparseEnumMessage BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is SparseEnumMessage) { - return MergeFrom((SparseEnumMessage) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(SparseEnumMessage other) { - if (other == global::Google.ProtocolBuffers.TestProtos.SparseEnumMessage.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasSparseEnum) { - SparseEnum = other.SparseEnum; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_sparseEnumMessageFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _sparseEnumMessageFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - object unknown; - if(input.ReadEnum(ref result.sparseEnum_, out unknown)) { - result.hasSparseEnum = true; - } else if(unknown is int) { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - unknownFields.MergeVarintField(1, (ulong)(int)unknown); - } - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasSparseEnum { - get { return result.hasSparseEnum; } - } - public global::Google.ProtocolBuffers.TestProtos.TestSparseEnum SparseEnum { - get { return result.SparseEnum; } - set { SetSparseEnum(value); } - } - public Builder SetSparseEnum(global::Google.ProtocolBuffers.TestProtos.TestSparseEnum value) { - PrepareBuilder(); - result.hasSparseEnum = true; - result.sparseEnum_ = value; - return this; - } - public Builder ClearSparseEnum() { - PrepareBuilder(); - result.hasSparseEnum = false; - result.sparseEnum_ = global::Google.ProtocolBuffers.TestProtos.TestSparseEnum.SPARSE_A; - return this; - } - } - static SparseEnumMessage() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class OneString : pb::GeneratedMessage { - private OneString() { } - private static readonly OneString defaultInstance = new OneString().MakeReadOnly(); - private static readonly string[] _oneStringFieldNames = new string[] { "data" }; - private static readonly uint[] _oneStringFieldTags = new uint[] { 10 }; - public static OneString DefaultInstance { - get { return defaultInstance; } - } - - public override OneString DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override OneString ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_OneString__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_OneString__FieldAccessorTable; } - } - - public const int DataFieldNumber = 1; - private bool hasData; - private string data_ = ""; - public bool HasData { - get { return hasData; } - } - public string Data { - get { return data_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _oneStringFieldNames; - if (hasData) { - output.WriteString(1, field_names[0], Data); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasData) { - size += pb::CodedOutputStream.ComputeStringSize(1, Data); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static OneString ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static OneString ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static OneString ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static OneString ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static OneString ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static OneString ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static OneString ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static OneString ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static OneString ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static OneString ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private OneString MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(OneString prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(OneString cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private OneString result; - - private OneString PrepareBuilder() { - if (resultIsReadOnly) { - OneString original = result; - result = new OneString(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override OneString MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.OneString.Descriptor; } - } - - public override OneString DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.OneString.DefaultInstance; } - } - - public override OneString BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is OneString) { - return MergeFrom((OneString) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(OneString other) { - if (other == global::Google.ProtocolBuffers.TestProtos.OneString.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasData) { - Data = other.Data; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_oneStringFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _oneStringFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 10: { - result.hasData = input.ReadString(ref result.data_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasData { - get { return result.hasData; } - } - public string Data { - get { return result.Data; } - set { SetData(value); } - } - public Builder SetData(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasData = true; - result.data_ = value; - return this; - } - public Builder ClearData() { - PrepareBuilder(); - result.hasData = false; - result.data_ = ""; - return this; - } - } - static OneString() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MoreString : pb::GeneratedMessage { - private MoreString() { } - private static readonly MoreString defaultInstance = new MoreString().MakeReadOnly(); - private static readonly string[] _moreStringFieldNames = new string[] { "data" }; - private static readonly uint[] _moreStringFieldTags = new uint[] { 10 }; - public static MoreString DefaultInstance { - get { return defaultInstance; } - } - - public override MoreString DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override MoreString ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_MoreString__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_MoreString__FieldAccessorTable; } - } - - public const int DataFieldNumber = 1; - private pbc::PopsicleList data_ = new pbc::PopsicleList(); - public scg::IList DataList { - get { return pbc::Lists.AsReadOnly(data_); } - } - public int DataCount { - get { return data_.Count; } - } - public string GetData(int index) { - return data_[index]; - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _moreStringFieldNames; - if (data_.Count > 0) { - output.WriteStringArray(1, field_names[0], data_); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - { - int dataSize = 0; - foreach (string element in DataList) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); - } - size += dataSize; - size += 1 * data_.Count; - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static MoreString ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static MoreString ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static MoreString ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static MoreString ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static MoreString ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static MoreString ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static MoreString ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static MoreString ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static MoreString ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static MoreString ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private MoreString MakeReadOnly() { - data_.MakeReadOnly(); - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(MoreString prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(MoreString cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private MoreString result; - - private MoreString PrepareBuilder() { - if (resultIsReadOnly) { - MoreString original = result; - result = new MoreString(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override MoreString MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.MoreString.Descriptor; } - } - - public override MoreString DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.MoreString.DefaultInstance; } - } - - public override MoreString BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is MoreString) { - return MergeFrom((MoreString) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(MoreString other) { - if (other == global::Google.ProtocolBuffers.TestProtos.MoreString.DefaultInstance) return this; - PrepareBuilder(); - if (other.data_.Count != 0) { - result.data_.Add(other.data_); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_moreStringFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _moreStringFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 10: { - input.ReadStringArray(tag, field_name, result.data_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public pbc::IPopsicleList DataList { - get { return PrepareBuilder().data_; } - } - public int DataCount { - get { return result.DataCount; } - } - public string GetData(int index) { - return result.GetData(index); - } - public Builder SetData(int index, string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.data_[index] = value; - return this; - } - public Builder AddData(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.data_.Add(value); - return this; - } - public Builder AddRangeData(scg::IEnumerable values) { - PrepareBuilder(); - result.data_.Add(values); - return this; - } - public Builder ClearData() { - PrepareBuilder(); - result.data_.Clear(); - return this; - } - } - static MoreString() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class OneBytes : pb::GeneratedMessage { - private OneBytes() { } - private static readonly OneBytes defaultInstance = new OneBytes().MakeReadOnly(); - private static readonly string[] _oneBytesFieldNames = new string[] { "data" }; - private static readonly uint[] _oneBytesFieldTags = new uint[] { 10 }; - public static OneBytes DefaultInstance { - get { return defaultInstance; } - } - - public override OneBytes DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override OneBytes ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_OneBytes__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_OneBytes__FieldAccessorTable; } - } - - public const int DataFieldNumber = 1; - private bool hasData; - private pb::ByteString data_ = pb::ByteString.Empty; - public bool HasData { - get { return hasData; } - } - public pb::ByteString Data { - get { return data_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _oneBytesFieldNames; - if (hasData) { - output.WriteBytes(1, field_names[0], Data); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasData) { - size += pb::CodedOutputStream.ComputeBytesSize(1, Data); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static OneBytes ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static OneBytes ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static OneBytes ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static OneBytes ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static OneBytes ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static OneBytes ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static OneBytes ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static OneBytes ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static OneBytes ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static OneBytes ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private OneBytes MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(OneBytes prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(OneBytes cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private OneBytes result; - - private OneBytes PrepareBuilder() { - if (resultIsReadOnly) { - OneBytes original = result; - result = new OneBytes(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override OneBytes MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.OneBytes.Descriptor; } - } - - public override OneBytes DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.OneBytes.DefaultInstance; } - } - - public override OneBytes BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is OneBytes) { - return MergeFrom((OneBytes) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(OneBytes other) { - if (other == global::Google.ProtocolBuffers.TestProtos.OneBytes.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasData) { - Data = other.Data; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_oneBytesFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _oneBytesFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 10: { - result.hasData = input.ReadBytes(ref result.data_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasData { - get { return result.hasData; } - } - public pb::ByteString Data { - get { return result.Data; } - set { SetData(value); } - } - public Builder SetData(pb::ByteString value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasData = true; - result.data_ = value; - return this; - } - public Builder ClearData() { - PrepareBuilder(); - result.hasData = false; - result.data_ = pb::ByteString.Empty; - return this; - } - } - static OneBytes() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MoreBytes : pb::GeneratedMessage { - private MoreBytes() { } - private static readonly MoreBytes defaultInstance = new MoreBytes().MakeReadOnly(); - private static readonly string[] _moreBytesFieldNames = new string[] { "data" }; - private static readonly uint[] _moreBytesFieldTags = new uint[] { 10 }; - public static MoreBytes DefaultInstance { - get { return defaultInstance; } - } - - public override MoreBytes DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override MoreBytes ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_MoreBytes__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_MoreBytes__FieldAccessorTable; } - } - - public const int DataFieldNumber = 1; - private pbc::PopsicleList data_ = new pbc::PopsicleList(); - public scg::IList DataList { - get { return pbc::Lists.AsReadOnly(data_); } - } - public int DataCount { - get { return data_.Count; } - } - public pb::ByteString GetData(int index) { - return data_[index]; - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _moreBytesFieldNames; - if (data_.Count > 0) { - output.WriteBytesArray(1, field_names[0], data_); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - { - int dataSize = 0; - foreach (pb::ByteString element in DataList) { - dataSize += pb::CodedOutputStream.ComputeBytesSizeNoTag(element); - } - size += dataSize; - size += 1 * data_.Count; - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static MoreBytes ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static MoreBytes ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static MoreBytes ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static MoreBytes ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static MoreBytes ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static MoreBytes ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static MoreBytes ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static MoreBytes ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static MoreBytes ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static MoreBytes ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private MoreBytes MakeReadOnly() { - data_.MakeReadOnly(); - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(MoreBytes prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(MoreBytes cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private MoreBytes result; - - private MoreBytes PrepareBuilder() { - if (resultIsReadOnly) { - MoreBytes original = result; - result = new MoreBytes(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override MoreBytes MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.MoreBytes.Descriptor; } - } - - public override MoreBytes DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.MoreBytes.DefaultInstance; } - } - - public override MoreBytes BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is MoreBytes) { - return MergeFrom((MoreBytes) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(MoreBytes other) { - if (other == global::Google.ProtocolBuffers.TestProtos.MoreBytes.DefaultInstance) return this; - PrepareBuilder(); - if (other.data_.Count != 0) { - result.data_.Add(other.data_); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_moreBytesFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _moreBytesFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 10: { - input.ReadBytesArray(tag, field_name, result.data_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public pbc::IPopsicleList DataList { - get { return PrepareBuilder().data_; } - } - public int DataCount { - get { return result.DataCount; } - } - public pb::ByteString GetData(int index) { - return result.GetData(index); - } - public Builder SetData(int index, pb::ByteString value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.data_[index] = value; - return this; - } - public Builder AddData(pb::ByteString value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.data_.Add(value); - return this; - } - public Builder AddRangeData(scg::IEnumerable values) { - PrepareBuilder(); - result.data_.Add(values); - return this; - } - public Builder ClearData() { - PrepareBuilder(); - result.data_.Clear(); - return this; - } - } - static MoreBytes() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Int32Message : pb::GeneratedMessage { - private Int32Message() { } - private static readonly Int32Message defaultInstance = new Int32Message().MakeReadOnly(); - private static readonly string[] _int32MessageFieldNames = new string[] { "data" }; - private static readonly uint[] _int32MessageFieldTags = new uint[] { 8 }; - public static Int32Message DefaultInstance { - get { return defaultInstance; } - } - - public override Int32Message DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override Int32Message ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_Int32Message__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_Int32Message__FieldAccessorTable; } - } - - public const int DataFieldNumber = 1; - private bool hasData; - private int data_; - public bool HasData { - get { return hasData; } - } - public int Data { - get { return data_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _int32MessageFieldNames; - if (hasData) { - output.WriteInt32(1, field_names[0], Data); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasData) { - size += pb::CodedOutputStream.ComputeInt32Size(1, Data); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static Int32Message ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static Int32Message ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static Int32Message ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static Int32Message ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static Int32Message ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static Int32Message ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static Int32Message ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static Int32Message ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static Int32Message ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static Int32Message ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private Int32Message MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(Int32Message prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(Int32Message cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private Int32Message result; - - private Int32Message PrepareBuilder() { - if (resultIsReadOnly) { - Int32Message original = result; - result = new Int32Message(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override Int32Message MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.Int32Message.Descriptor; } - } - - public override Int32Message DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.Int32Message.DefaultInstance; } - } - - public override Int32Message BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is Int32Message) { - return MergeFrom((Int32Message) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(Int32Message other) { - if (other == global::Google.ProtocolBuffers.TestProtos.Int32Message.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasData) { - Data = other.Data; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_int32MessageFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _int32MessageFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasData = input.ReadInt32(ref result.data_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasData { - get { return result.hasData; } - } - public int Data { - get { return result.Data; } - set { SetData(value); } - } - public Builder SetData(int value) { - PrepareBuilder(); - result.hasData = true; - result.data_ = value; - return this; - } - public Builder ClearData() { - PrepareBuilder(); - result.hasData = false; - result.data_ = 0; - return this; - } - } - static Int32Message() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Uint32Message : pb::GeneratedMessage { - private Uint32Message() { } - private static readonly Uint32Message defaultInstance = new Uint32Message().MakeReadOnly(); - private static readonly string[] _uint32MessageFieldNames = new string[] { "data" }; - private static readonly uint[] _uint32MessageFieldTags = new uint[] { 8 }; - public static Uint32Message DefaultInstance { - get { return defaultInstance; } - } - - public override Uint32Message DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override Uint32Message ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_Uint32Message__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_Uint32Message__FieldAccessorTable; } - } - - public const int DataFieldNumber = 1; - private bool hasData; - private uint data_; - public bool HasData { - get { return hasData; } - } - [global::System.CLSCompliant(false)] - public uint Data { - get { return data_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _uint32MessageFieldNames; - if (hasData) { - output.WriteUInt32(1, field_names[0], Data); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasData) { - size += pb::CodedOutputStream.ComputeUInt32Size(1, Data); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static Uint32Message ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static Uint32Message ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static Uint32Message ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static Uint32Message ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static Uint32Message ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static Uint32Message ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static Uint32Message ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static Uint32Message ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static Uint32Message ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static Uint32Message ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private Uint32Message MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(Uint32Message prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(Uint32Message cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private Uint32Message result; - - private Uint32Message PrepareBuilder() { - if (resultIsReadOnly) { - Uint32Message original = result; - result = new Uint32Message(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override Uint32Message MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.Uint32Message.Descriptor; } - } - - public override Uint32Message DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.Uint32Message.DefaultInstance; } - } - - public override Uint32Message BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is Uint32Message) { - return MergeFrom((Uint32Message) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(Uint32Message other) { - if (other == global::Google.ProtocolBuffers.TestProtos.Uint32Message.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasData) { - Data = other.Data; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_uint32MessageFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _uint32MessageFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasData = input.ReadUInt32(ref result.data_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasData { - get { return result.hasData; } - } - [global::System.CLSCompliant(false)] - public uint Data { - get { return result.Data; } - set { SetData(value); } - } - [global::System.CLSCompliant(false)] - public Builder SetData(uint value) { - PrepareBuilder(); - result.hasData = true; - result.data_ = value; - return this; - } - public Builder ClearData() { - PrepareBuilder(); - result.hasData = false; - result.data_ = 0; - return this; - } - } - static Uint32Message() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Int64Message : pb::GeneratedMessage { - private Int64Message() { } - private static readonly Int64Message defaultInstance = new Int64Message().MakeReadOnly(); - private static readonly string[] _int64MessageFieldNames = new string[] { "data" }; - private static readonly uint[] _int64MessageFieldTags = new uint[] { 8 }; - public static Int64Message DefaultInstance { - get { return defaultInstance; } - } - - public override Int64Message DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override Int64Message ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_Int64Message__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_Int64Message__FieldAccessorTable; } - } - - public const int DataFieldNumber = 1; - private bool hasData; - private long data_; - public bool HasData { - get { return hasData; } - } - public long Data { - get { return data_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _int64MessageFieldNames; - if (hasData) { - output.WriteInt64(1, field_names[0], Data); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasData) { - size += pb::CodedOutputStream.ComputeInt64Size(1, Data); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static Int64Message ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static Int64Message ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static Int64Message ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static Int64Message ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static Int64Message ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static Int64Message ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static Int64Message ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static Int64Message ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static Int64Message ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static Int64Message ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private Int64Message MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(Int64Message prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(Int64Message cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private Int64Message result; - - private Int64Message PrepareBuilder() { - if (resultIsReadOnly) { - Int64Message original = result; - result = new Int64Message(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override Int64Message MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.Int64Message.Descriptor; } - } - - public override Int64Message DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.Int64Message.DefaultInstance; } - } - - public override Int64Message BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is Int64Message) { - return MergeFrom((Int64Message) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(Int64Message other) { - if (other == global::Google.ProtocolBuffers.TestProtos.Int64Message.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasData) { - Data = other.Data; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_int64MessageFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _int64MessageFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasData = input.ReadInt64(ref result.data_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasData { - get { return result.hasData; } - } - public long Data { - get { return result.Data; } - set { SetData(value); } - } - public Builder SetData(long value) { - PrepareBuilder(); - result.hasData = true; - result.data_ = value; - return this; - } - public Builder ClearData() { - PrepareBuilder(); - result.hasData = false; - result.data_ = 0L; - return this; - } - } - static Int64Message() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Uint64Message : pb::GeneratedMessage { - private Uint64Message() { } - private static readonly Uint64Message defaultInstance = new Uint64Message().MakeReadOnly(); - private static readonly string[] _uint64MessageFieldNames = new string[] { "data" }; - private static readonly uint[] _uint64MessageFieldTags = new uint[] { 8 }; - public static Uint64Message DefaultInstance { - get { return defaultInstance; } - } - - public override Uint64Message DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override Uint64Message ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_Uint64Message__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_Uint64Message__FieldAccessorTable; } - } - - public const int DataFieldNumber = 1; - private bool hasData; - private ulong data_; - public bool HasData { - get { return hasData; } - } - [global::System.CLSCompliant(false)] - public ulong Data { - get { return data_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _uint64MessageFieldNames; - if (hasData) { - output.WriteUInt64(1, field_names[0], Data); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasData) { - size += pb::CodedOutputStream.ComputeUInt64Size(1, Data); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static Uint64Message ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static Uint64Message ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static Uint64Message ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static Uint64Message ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static Uint64Message ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static Uint64Message ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static Uint64Message ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static Uint64Message ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static Uint64Message ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static Uint64Message ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private Uint64Message MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(Uint64Message prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(Uint64Message cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private Uint64Message result; - - private Uint64Message PrepareBuilder() { - if (resultIsReadOnly) { - Uint64Message original = result; - result = new Uint64Message(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override Uint64Message MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.Uint64Message.Descriptor; } - } - - public override Uint64Message DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.Uint64Message.DefaultInstance; } - } - - public override Uint64Message BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is Uint64Message) { - return MergeFrom((Uint64Message) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(Uint64Message other) { - if (other == global::Google.ProtocolBuffers.TestProtos.Uint64Message.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasData) { - Data = other.Data; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_uint64MessageFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _uint64MessageFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasData = input.ReadUInt64(ref result.data_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasData { - get { return result.hasData; } - } - [global::System.CLSCompliant(false)] - public ulong Data { - get { return result.Data; } - set { SetData(value); } - } - [global::System.CLSCompliant(false)] - public Builder SetData(ulong value) { - PrepareBuilder(); - result.hasData = true; - result.data_ = value; - return this; - } - public Builder ClearData() { - PrepareBuilder(); - result.hasData = false; - result.data_ = 0UL; - return this; - } - } - static Uint64Message() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class BoolMessage : pb::GeneratedMessage { - private BoolMessage() { } - private static readonly BoolMessage defaultInstance = new BoolMessage().MakeReadOnly(); - private static readonly string[] _boolMessageFieldNames = new string[] { "data" }; - private static readonly uint[] _boolMessageFieldTags = new uint[] { 8 }; - public static BoolMessage DefaultInstance { - get { return defaultInstance; } - } - - public override BoolMessage DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override BoolMessage ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_BoolMessage__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_BoolMessage__FieldAccessorTable; } - } - - public const int DataFieldNumber = 1; - private bool hasData; - private bool data_; - public bool HasData { - get { return hasData; } - } - public bool Data { - get { return data_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _boolMessageFieldNames; - if (hasData) { - output.WriteBool(1, field_names[0], Data); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasData) { - size += pb::CodedOutputStream.ComputeBoolSize(1, Data); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static BoolMessage ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static BoolMessage ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static BoolMessage ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static BoolMessage ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static BoolMessage ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static BoolMessage ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static BoolMessage ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static BoolMessage ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static BoolMessage ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static BoolMessage ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private BoolMessage MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(BoolMessage prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(BoolMessage cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private BoolMessage result; - - private BoolMessage PrepareBuilder() { - if (resultIsReadOnly) { - BoolMessage original = result; - result = new BoolMessage(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override BoolMessage MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.BoolMessage.Descriptor; } - } - - public override BoolMessage DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.BoolMessage.DefaultInstance; } - } - - public override BoolMessage BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is BoolMessage) { - return MergeFrom((BoolMessage) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(BoolMessage other) { - if (other == global::Google.ProtocolBuffers.TestProtos.BoolMessage.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasData) { - Data = other.Data; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_boolMessageFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _boolMessageFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasData = input.ReadBool(ref result.data_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasData { - get { return result.hasData; } - } - public bool Data { - get { return result.Data; } - set { SetData(value); } - } - public Builder SetData(bool value) { - PrepareBuilder(); - result.hasData = true; - result.data_ = value; - return this; - } - public Builder ClearData() { - PrepareBuilder(); - result.hasData = false; - result.data_ = false; - return this; - } - } - static BoolMessage() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestOneof : pb::GeneratedMessage { - private TestOneof() { } - private static readonly TestOneof defaultInstance = new TestOneof().MakeReadOnly(); - private static readonly string[] _testOneofFieldNames = new string[] { "foo_int", "foo_message", "foo_string", "foogroup" }; - private static readonly uint[] _testOneofFieldTags = new uint[] { 8, 26, 18, 35 }; - public static TestOneof DefaultInstance { - get { return defaultInstance; } - } - - public override TestOneof DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestOneof ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestOneof__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestOneof__FieldAccessorTable; } - } - - #region Nested types - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class Types { - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class FooGroup : pb::GeneratedMessage { - private FooGroup() { } - private static readonly FooGroup defaultInstance = new FooGroup().MakeReadOnly(); - private static readonly string[] _fooGroupFieldNames = new string[] { "a", "b" }; - private static readonly uint[] _fooGroupFieldTags = new uint[] { 40, 50 }; - public static FooGroup DefaultInstance { - get { return defaultInstance; } - } - - public override FooGroup DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override FooGroup ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestOneof_FooGroup__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestOneof_FooGroup__FieldAccessorTable; } - } - - public const int AFieldNumber = 5; - private bool hasA; - private int a_; - public bool HasA { - get { return hasA; } - } - public int A { - get { return a_; } - } - - public const int BFieldNumber = 6; - private bool hasB; - private string b_ = ""; - public bool HasB { - get { return hasB; } - } - public string B { - get { return b_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _fooGroupFieldNames; - if (hasA) { - output.WriteInt32(5, field_names[0], A); - } - if (hasB) { - output.WriteString(6, field_names[1], B); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(5, A); - } - if (hasB) { - size += pb::CodedOutputStream.ComputeStringSize(6, B); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static FooGroup ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static FooGroup ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static FooGroup ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static FooGroup ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static FooGroup ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static FooGroup ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static FooGroup ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static FooGroup ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static FooGroup ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static FooGroup ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private FooGroup MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(FooGroup prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(FooGroup cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private FooGroup result; - - private FooGroup PrepareBuilder() { - if (resultIsReadOnly) { - FooGroup original = result; - result = new FooGroup(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override FooGroup MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestOneof.Types.FooGroup.Descriptor; } - } - - public override FooGroup DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestOneof.Types.FooGroup.DefaultInstance; } - } - - public override FooGroup BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is FooGroup) { - return MergeFrom((FooGroup) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(FooGroup other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestOneof.Types.FooGroup.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasA) { - A = other.A; - } - if (other.HasB) { - B = other.B; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_fooGroupFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _fooGroupFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 40: { - result.hasA = input.ReadInt32(ref result.a_); - break; - } - case 50: { - result.hasB = input.ReadString(ref result.b_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasA { - get { return result.hasA; } - } - public int A { - get { return result.A; } - set { SetA(value); } - } - public Builder SetA(int value) { - PrepareBuilder(); - result.hasA = true; - result.a_ = value; - return this; - } - public Builder ClearA() { - PrepareBuilder(); - result.hasA = false; - result.a_ = 0; - return this; - } - - public bool HasB { - get { return result.hasB; } - } - public string B { - get { return result.B; } - set { SetB(value); } - } - public Builder SetB(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasB = true; - result.b_ = value; - return this; - } - public Builder ClearB() { - PrepareBuilder(); - result.hasB = false; - result.b_ = ""; - return this; - } - } - static FooGroup() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - } - #endregion - - public const int FooIntFieldNumber = 1; - private bool hasFooInt; - private int fooInt_; - public bool HasFooInt { - get { return hasFooInt; } - } - public int FooInt { - get { return fooInt_; } - } - - public const int FooStringFieldNumber = 2; - private bool hasFooString; - private string fooString_ = ""; - public bool HasFooString { - get { return hasFooString; } - } - public string FooString { - get { return fooString_; } - } - - public const int FooMessageFieldNumber = 3; - private bool hasFooMessage; - private global::Google.ProtocolBuffers.TestProtos.TestAllTypes fooMessage_; - public bool HasFooMessage { - get { return hasFooMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes FooMessage { - get { return fooMessage_ ?? global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance; } - } - - public const int FooGroupFieldNumber = 4; - private bool hasFooGroup; - private global::Google.ProtocolBuffers.TestProtos.TestOneof.Types.FooGroup fooGroup_; - public bool HasFooGroup { - get { return hasFooGroup; } - } - public global::Google.ProtocolBuffers.TestProtos.TestOneof.Types.FooGroup FooGroup { - get { return fooGroup_ ?? global::Google.ProtocolBuffers.TestProtos.TestOneof.Types.FooGroup.DefaultInstance; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testOneofFieldNames; - if (hasFooInt) { - output.WriteInt32(1, field_names[0], FooInt); - } - if (hasFooString) { - output.WriteString(2, field_names[2], FooString); - } - if (hasFooMessage) { - output.WriteMessage(3, field_names[1], FooMessage); - } - if (hasFooGroup) { - output.WriteGroup(4, field_names[3], FooGroup); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasFooInt) { - size += pb::CodedOutputStream.ComputeInt32Size(1, FooInt); - } - if (hasFooString) { - size += pb::CodedOutputStream.ComputeStringSize(2, FooString); - } - if (hasFooMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(3, FooMessage); - } - if (hasFooGroup) { - size += pb::CodedOutputStream.ComputeGroupSize(4, FooGroup); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestOneof ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestOneof ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestOneof ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestOneof ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestOneof ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestOneof ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestOneof ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestOneof ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestOneof ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestOneof ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestOneof MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestOneof prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestOneof cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestOneof result; - - private TestOneof PrepareBuilder() { - if (resultIsReadOnly) { - TestOneof original = result; - result = new TestOneof(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestOneof MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestOneof.Descriptor; } - } - - public override TestOneof DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestOneof.DefaultInstance; } - } - - public override TestOneof BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestOneof) { - return MergeFrom((TestOneof) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestOneof other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestOneof.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasFooInt) { - FooInt = other.FooInt; - } - if (other.HasFooString) { - FooString = other.FooString; - } - if (other.HasFooMessage) { - MergeFooMessage(other.FooMessage); - } - if (other.HasFooGroup) { - MergeFooGroup(other.FooGroup); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testOneofFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testOneofFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasFooInt = input.ReadInt32(ref result.fooInt_); - break; - } - case 18: { - result.hasFooString = input.ReadString(ref result.fooString_); - break; - } - case 26: { - global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.CreateBuilder(); - if (result.hasFooMessage) { - subBuilder.MergeFrom(FooMessage); - } - input.ReadMessage(subBuilder, extensionRegistry); - FooMessage = subBuilder.BuildPartial(); - break; - } - case 35: { - global::Google.ProtocolBuffers.TestProtos.TestOneof.Types.FooGroup.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestOneof.Types.FooGroup.CreateBuilder(); - if (result.hasFooGroup) { - subBuilder.MergeFrom(FooGroup); - } - input.ReadGroup(4, subBuilder, extensionRegistry); - FooGroup = subBuilder.BuildPartial(); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasFooInt { - get { return result.hasFooInt; } - } - public int FooInt { - get { return result.FooInt; } - set { SetFooInt(value); } - } - public Builder SetFooInt(int value) { - PrepareBuilder(); - result.hasFooInt = true; - result.fooInt_ = value; - return this; - } - public Builder ClearFooInt() { - PrepareBuilder(); - result.hasFooInt = false; - result.fooInt_ = 0; - return this; - } - - public bool HasFooString { - get { return result.hasFooString; } - } - public string FooString { - get { return result.FooString; } - set { SetFooString(value); } - } - public Builder SetFooString(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasFooString = true; - result.fooString_ = value; - return this; - } - public Builder ClearFooString() { - PrepareBuilder(); - result.hasFooString = false; - result.fooString_ = ""; - return this; - } - - public bool HasFooMessage { - get { return result.hasFooMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes FooMessage { - get { return result.FooMessage; } - set { SetFooMessage(value); } - } - public Builder SetFooMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasFooMessage = true; - result.fooMessage_ = value; - return this; - } - public Builder SetFooMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasFooMessage = true; - result.fooMessage_ = builderForValue.Build(); - return this; - } - public Builder MergeFooMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasFooMessage && - result.fooMessage_ != global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance) { - result.fooMessage_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.CreateBuilder(result.fooMessage_).MergeFrom(value).BuildPartial(); - } else { - result.fooMessage_ = value; - } - result.hasFooMessage = true; - return this; - } - public Builder ClearFooMessage() { - PrepareBuilder(); - result.hasFooMessage = false; - result.fooMessage_ = null; - return this; - } - - public bool HasFooGroup { - get { return result.hasFooGroup; } - } - public global::Google.ProtocolBuffers.TestProtos.TestOneof.Types.FooGroup FooGroup { - get { return result.FooGroup; } - set { SetFooGroup(value); } - } - public Builder SetFooGroup(global::Google.ProtocolBuffers.TestProtos.TestOneof.Types.FooGroup value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasFooGroup = true; - result.fooGroup_ = value; - return this; - } - public Builder SetFooGroup(global::Google.ProtocolBuffers.TestProtos.TestOneof.Types.FooGroup.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasFooGroup = true; - result.fooGroup_ = builderForValue.Build(); - return this; - } - public Builder MergeFooGroup(global::Google.ProtocolBuffers.TestProtos.TestOneof.Types.FooGroup value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasFooGroup && - result.fooGroup_ != global::Google.ProtocolBuffers.TestProtos.TestOneof.Types.FooGroup.DefaultInstance) { - result.fooGroup_ = global::Google.ProtocolBuffers.TestProtos.TestOneof.Types.FooGroup.CreateBuilder(result.fooGroup_).MergeFrom(value).BuildPartial(); - } else { - result.fooGroup_ = value; - } - result.hasFooGroup = true; - return this; - } - public Builder ClearFooGroup() { - PrepareBuilder(); - result.hasFooGroup = false; - result.fooGroup_ = null; - return this; - } - } - static TestOneof() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestOneofBackwardsCompatible : pb::GeneratedMessage { - private TestOneofBackwardsCompatible() { } - private static readonly TestOneofBackwardsCompatible defaultInstance = new TestOneofBackwardsCompatible().MakeReadOnly(); - private static readonly string[] _testOneofBackwardsCompatibleFieldNames = new string[] { "foo_int", "foo_message", "foo_string", "foogroup" }; - private static readonly uint[] _testOneofBackwardsCompatibleFieldTags = new uint[] { 8, 26, 18, 35 }; - public static TestOneofBackwardsCompatible DefaultInstance { - get { return defaultInstance; } - } - - public override TestOneofBackwardsCompatible DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestOneofBackwardsCompatible ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestOneofBackwardsCompatible__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestOneofBackwardsCompatible__FieldAccessorTable; } - } - - #region Nested types - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class Types { - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class FooGroup : pb::GeneratedMessage { - private FooGroup() { } - private static readonly FooGroup defaultInstance = new FooGroup().MakeReadOnly(); - private static readonly string[] _fooGroupFieldNames = new string[] { "a", "b" }; - private static readonly uint[] _fooGroupFieldTags = new uint[] { 40, 50 }; - public static FooGroup DefaultInstance { - get { return defaultInstance; } - } - - public override FooGroup DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override FooGroup ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestOneofBackwardsCompatible_FooGroup__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestOneofBackwardsCompatible_FooGroup__FieldAccessorTable; } - } - - public const int AFieldNumber = 5; - private bool hasA; - private int a_; - public bool HasA { - get { return hasA; } - } - public int A { - get { return a_; } - } - - public const int BFieldNumber = 6; - private bool hasB; - private string b_ = ""; - public bool HasB { - get { return hasB; } - } - public string B { - get { return b_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _fooGroupFieldNames; - if (hasA) { - output.WriteInt32(5, field_names[0], A); - } - if (hasB) { - output.WriteString(6, field_names[1], B); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(5, A); - } - if (hasB) { - size += pb::CodedOutputStream.ComputeStringSize(6, B); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static FooGroup ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static FooGroup ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static FooGroup ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static FooGroup ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static FooGroup ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static FooGroup ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static FooGroup ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static FooGroup ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static FooGroup ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static FooGroup ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private FooGroup MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(FooGroup prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(FooGroup cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private FooGroup result; - - private FooGroup PrepareBuilder() { - if (resultIsReadOnly) { - FooGroup original = result; - result = new FooGroup(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override FooGroup MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestOneofBackwardsCompatible.Types.FooGroup.Descriptor; } - } - - public override FooGroup DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestOneofBackwardsCompatible.Types.FooGroup.DefaultInstance; } - } - - public override FooGroup BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is FooGroup) { - return MergeFrom((FooGroup) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(FooGroup other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestOneofBackwardsCompatible.Types.FooGroup.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasA) { - A = other.A; - } - if (other.HasB) { - B = other.B; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_fooGroupFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _fooGroupFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 40: { - result.hasA = input.ReadInt32(ref result.a_); - break; - } - case 50: { - result.hasB = input.ReadString(ref result.b_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasA { - get { return result.hasA; } - } - public int A { - get { return result.A; } - set { SetA(value); } - } - public Builder SetA(int value) { - PrepareBuilder(); - result.hasA = true; - result.a_ = value; - return this; - } - public Builder ClearA() { - PrepareBuilder(); - result.hasA = false; - result.a_ = 0; - return this; - } - - public bool HasB { - get { return result.hasB; } - } - public string B { - get { return result.B; } - set { SetB(value); } - } - public Builder SetB(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasB = true; - result.b_ = value; - return this; - } - public Builder ClearB() { - PrepareBuilder(); - result.hasB = false; - result.b_ = ""; - return this; - } - } - static FooGroup() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - } - #endregion - - public const int FooIntFieldNumber = 1; - private bool hasFooInt; - private int fooInt_; - public bool HasFooInt { - get { return hasFooInt; } - } - public int FooInt { - get { return fooInt_; } - } - - public const int FooStringFieldNumber = 2; - private bool hasFooString; - private string fooString_ = ""; - public bool HasFooString { - get { return hasFooString; } - } - public string FooString { - get { return fooString_; } - } - - public const int FooMessageFieldNumber = 3; - private bool hasFooMessage; - private global::Google.ProtocolBuffers.TestProtos.TestAllTypes fooMessage_; - public bool HasFooMessage { - get { return hasFooMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes FooMessage { - get { return fooMessage_ ?? global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance; } - } - - public const int FooGroupFieldNumber = 4; - private bool hasFooGroup; - private global::Google.ProtocolBuffers.TestProtos.TestOneofBackwardsCompatible.Types.FooGroup fooGroup_; - public bool HasFooGroup { - get { return hasFooGroup; } - } - public global::Google.ProtocolBuffers.TestProtos.TestOneofBackwardsCompatible.Types.FooGroup FooGroup { - get { return fooGroup_ ?? global::Google.ProtocolBuffers.TestProtos.TestOneofBackwardsCompatible.Types.FooGroup.DefaultInstance; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testOneofBackwardsCompatibleFieldNames; - if (hasFooInt) { - output.WriteInt32(1, field_names[0], FooInt); - } - if (hasFooString) { - output.WriteString(2, field_names[2], FooString); - } - if (hasFooMessage) { - output.WriteMessage(3, field_names[1], FooMessage); - } - if (hasFooGroup) { - output.WriteGroup(4, field_names[3], FooGroup); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasFooInt) { - size += pb::CodedOutputStream.ComputeInt32Size(1, FooInt); - } - if (hasFooString) { - size += pb::CodedOutputStream.ComputeStringSize(2, FooString); - } - if (hasFooMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(3, FooMessage); - } - if (hasFooGroup) { - size += pb::CodedOutputStream.ComputeGroupSize(4, FooGroup); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestOneofBackwardsCompatible ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestOneofBackwardsCompatible ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestOneofBackwardsCompatible ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestOneofBackwardsCompatible ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestOneofBackwardsCompatible ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestOneofBackwardsCompatible ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestOneofBackwardsCompatible ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestOneofBackwardsCompatible ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestOneofBackwardsCompatible ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestOneofBackwardsCompatible ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestOneofBackwardsCompatible MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestOneofBackwardsCompatible prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestOneofBackwardsCompatible cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestOneofBackwardsCompatible result; - - private TestOneofBackwardsCompatible PrepareBuilder() { - if (resultIsReadOnly) { - TestOneofBackwardsCompatible original = result; - result = new TestOneofBackwardsCompatible(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestOneofBackwardsCompatible MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestOneofBackwardsCompatible.Descriptor; } - } - - public override TestOneofBackwardsCompatible DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestOneofBackwardsCompatible.DefaultInstance; } - } - - public override TestOneofBackwardsCompatible BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestOneofBackwardsCompatible) { - return MergeFrom((TestOneofBackwardsCompatible) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestOneofBackwardsCompatible other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestOneofBackwardsCompatible.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasFooInt) { - FooInt = other.FooInt; - } - if (other.HasFooString) { - FooString = other.FooString; - } - if (other.HasFooMessage) { - MergeFooMessage(other.FooMessage); - } - if (other.HasFooGroup) { - MergeFooGroup(other.FooGroup); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testOneofBackwardsCompatibleFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testOneofBackwardsCompatibleFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasFooInt = input.ReadInt32(ref result.fooInt_); - break; - } - case 18: { - result.hasFooString = input.ReadString(ref result.fooString_); - break; - } - case 26: { - global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.CreateBuilder(); - if (result.hasFooMessage) { - subBuilder.MergeFrom(FooMessage); - } - input.ReadMessage(subBuilder, extensionRegistry); - FooMessage = subBuilder.BuildPartial(); - break; - } - case 35: { - global::Google.ProtocolBuffers.TestProtos.TestOneofBackwardsCompatible.Types.FooGroup.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestOneofBackwardsCompatible.Types.FooGroup.CreateBuilder(); - if (result.hasFooGroup) { - subBuilder.MergeFrom(FooGroup); - } - input.ReadGroup(4, subBuilder, extensionRegistry); - FooGroup = subBuilder.BuildPartial(); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasFooInt { - get { return result.hasFooInt; } - } - public int FooInt { - get { return result.FooInt; } - set { SetFooInt(value); } - } - public Builder SetFooInt(int value) { - PrepareBuilder(); - result.hasFooInt = true; - result.fooInt_ = value; - return this; - } - public Builder ClearFooInt() { - PrepareBuilder(); - result.hasFooInt = false; - result.fooInt_ = 0; - return this; - } - - public bool HasFooString { - get { return result.hasFooString; } - } - public string FooString { - get { return result.FooString; } - set { SetFooString(value); } - } - public Builder SetFooString(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasFooString = true; - result.fooString_ = value; - return this; - } - public Builder ClearFooString() { - PrepareBuilder(); - result.hasFooString = false; - result.fooString_ = ""; - return this; - } - - public bool HasFooMessage { - get { return result.hasFooMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes FooMessage { - get { return result.FooMessage; } - set { SetFooMessage(value); } - } - public Builder SetFooMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasFooMessage = true; - result.fooMessage_ = value; - return this; - } - public Builder SetFooMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasFooMessage = true; - result.fooMessage_ = builderForValue.Build(); - return this; - } - public Builder MergeFooMessage(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasFooMessage && - result.fooMessage_ != global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance) { - result.fooMessage_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.CreateBuilder(result.fooMessage_).MergeFrom(value).BuildPartial(); - } else { - result.fooMessage_ = value; - } - result.hasFooMessage = true; - return this; - } - public Builder ClearFooMessage() { - PrepareBuilder(); - result.hasFooMessage = false; - result.fooMessage_ = null; - return this; - } - - public bool HasFooGroup { - get { return result.hasFooGroup; } - } - public global::Google.ProtocolBuffers.TestProtos.TestOneofBackwardsCompatible.Types.FooGroup FooGroup { - get { return result.FooGroup; } - set { SetFooGroup(value); } - } - public Builder SetFooGroup(global::Google.ProtocolBuffers.TestProtos.TestOneofBackwardsCompatible.Types.FooGroup value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasFooGroup = true; - result.fooGroup_ = value; - return this; - } - public Builder SetFooGroup(global::Google.ProtocolBuffers.TestProtos.TestOneofBackwardsCompatible.Types.FooGroup.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasFooGroup = true; - result.fooGroup_ = builderForValue.Build(); - return this; - } - public Builder MergeFooGroup(global::Google.ProtocolBuffers.TestProtos.TestOneofBackwardsCompatible.Types.FooGroup value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasFooGroup && - result.fooGroup_ != global::Google.ProtocolBuffers.TestProtos.TestOneofBackwardsCompatible.Types.FooGroup.DefaultInstance) { - result.fooGroup_ = global::Google.ProtocolBuffers.TestProtos.TestOneofBackwardsCompatible.Types.FooGroup.CreateBuilder(result.fooGroup_).MergeFrom(value).BuildPartial(); - } else { - result.fooGroup_ = value; - } - result.hasFooGroup = true; - return this; - } - public Builder ClearFooGroup() { - PrepareBuilder(); - result.hasFooGroup = false; - result.fooGroup_ = null; - return this; - } - } - static TestOneofBackwardsCompatible() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestOneof2 : pb::GeneratedMessage { - private TestOneof2() { } - private static readonly TestOneof2 defaultInstance = new TestOneof2().MakeReadOnly(); - private static readonly string[] _testOneof2FieldNames = new string[] { "bar_bytes", "bar_cord", "bar_enum", "bar_int", "bar_string", "bar_string_piece", "baz_int", "baz_string", "foo_bytes", "foo_cord", "foo_enum", "foo_int", "foo_lazy_message", "foo_message", "foo_string", "foo_string_piece", "foogroup" }; - private static readonly uint[] _testOneof2FieldTags = new uint[] { 130, 114, 136, 96, 106, 122, 144, 154, 42, 26, 48, 8, 90, 58, 18, 34, 67 }; - public static TestOneof2 DefaultInstance { - get { return defaultInstance; } - } - - public override TestOneof2 DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestOneof2 ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestOneof2__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestOneof2__FieldAccessorTable; } - } - - #region Nested types - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class Types { - public enum NestedEnum { - FOO = 1, - BAR = 2, - BAZ = 3, - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class FooGroup : pb::GeneratedMessage { - private FooGroup() { } - private static readonly FooGroup defaultInstance = new FooGroup().MakeReadOnly(); - private static readonly string[] _fooGroupFieldNames = new string[] { "a", "b" }; - private static readonly uint[] _fooGroupFieldTags = new uint[] { 72, 82 }; - public static FooGroup DefaultInstance { - get { return defaultInstance; } - } - - public override FooGroup DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override FooGroup ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestOneof2_FooGroup__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestOneof2_FooGroup__FieldAccessorTable; } - } - - public const int AFieldNumber = 9; - private bool hasA; - private int a_; - public bool HasA { - get { return hasA; } - } - public int A { - get { return a_; } - } - - public const int BFieldNumber = 10; - private bool hasB; - private string b_ = ""; - public bool HasB { - get { return hasB; } - } - public string B { - get { return b_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _fooGroupFieldNames; - if (hasA) { - output.WriteInt32(9, field_names[0], A); - } - if (hasB) { - output.WriteString(10, field_names[1], B); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeInt32Size(9, A); - } - if (hasB) { - size += pb::CodedOutputStream.ComputeStringSize(10, B); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static FooGroup ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static FooGroup ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static FooGroup ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static FooGroup ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static FooGroup ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static FooGroup ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static FooGroup ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static FooGroup ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static FooGroup ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static FooGroup ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private FooGroup MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(FooGroup prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(FooGroup cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private FooGroup result; - - private FooGroup PrepareBuilder() { - if (resultIsReadOnly) { - FooGroup original = result; - result = new FooGroup(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override FooGroup MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.FooGroup.Descriptor; } - } - - public override FooGroup DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.FooGroup.DefaultInstance; } - } - - public override FooGroup BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is FooGroup) { - return MergeFrom((FooGroup) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(FooGroup other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.FooGroup.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasA) { - A = other.A; - } - if (other.HasB) { - B = other.B; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_fooGroupFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _fooGroupFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 72: { - result.hasA = input.ReadInt32(ref result.a_); - break; - } - case 82: { - result.hasB = input.ReadString(ref result.b_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasA { - get { return result.hasA; } - } - public int A { - get { return result.A; } - set { SetA(value); } - } - public Builder SetA(int value) { - PrepareBuilder(); - result.hasA = true; - result.a_ = value; - return this; - } - public Builder ClearA() { - PrepareBuilder(); - result.hasA = false; - result.a_ = 0; - return this; - } - - public bool HasB { - get { return result.hasB; } - } - public string B { - get { return result.B; } - set { SetB(value); } - } - public Builder SetB(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasB = true; - result.b_ = value; - return this; - } - public Builder ClearB() { - PrepareBuilder(); - result.hasB = false; - result.b_ = ""; - return this; - } - } - static FooGroup() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class NestedMessage : pb::GeneratedMessage { - private NestedMessage() { } - private static readonly NestedMessage defaultInstance = new NestedMessage().MakeReadOnly(); - private static readonly string[] _nestedMessageFieldNames = new string[] { "corge_int", "qux_int" }; - private static readonly uint[] _nestedMessageFieldTags = new uint[] { 16, 8 }; - public static NestedMessage DefaultInstance { - get { return defaultInstance; } - } - - public override NestedMessage DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override NestedMessage ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestOneof2_NestedMessage__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestOneof2_NestedMessage__FieldAccessorTable; } - } - - public const int QuxIntFieldNumber = 1; - private bool hasQuxInt; - private long quxInt_; - public bool HasQuxInt { - get { return hasQuxInt; } - } - public long QuxInt { - get { return quxInt_; } - } - - public const int CorgeIntFieldNumber = 2; - private pbc::PopsicleList corgeInt_ = new pbc::PopsicleList(); - public scg::IList CorgeIntList { - get { return pbc::Lists.AsReadOnly(corgeInt_); } - } - public int CorgeIntCount { - get { return corgeInt_.Count; } - } - public int GetCorgeInt(int index) { - return corgeInt_[index]; - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _nestedMessageFieldNames; - if (hasQuxInt) { - output.WriteInt64(1, field_names[1], QuxInt); - } - if (corgeInt_.Count > 0) { - output.WriteInt32Array(2, field_names[0], corgeInt_); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasQuxInt) { - size += pb::CodedOutputStream.ComputeInt64Size(1, QuxInt); - } - { - int dataSize = 0; - foreach (int element in CorgeIntList) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); - } - size += dataSize; - size += 1 * corgeInt_.Count; - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static NestedMessage ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static NestedMessage ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static NestedMessage ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static NestedMessage ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static NestedMessage ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static NestedMessage ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static NestedMessage ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static NestedMessage ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static NestedMessage ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static NestedMessage ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private NestedMessage MakeReadOnly() { - corgeInt_.MakeReadOnly(); - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(NestedMessage prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(NestedMessage cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private NestedMessage result; - - private NestedMessage PrepareBuilder() { - if (resultIsReadOnly) { - NestedMessage original = result; - result = new NestedMessage(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override NestedMessage MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage.Descriptor; } - } - - public override NestedMessage DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage.DefaultInstance; } - } - - public override NestedMessage BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is NestedMessage) { - return MergeFrom((NestedMessage) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(NestedMessage other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasQuxInt) { - QuxInt = other.QuxInt; - } - if (other.corgeInt_.Count != 0) { - result.corgeInt_.Add(other.corgeInt_); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_nestedMessageFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _nestedMessageFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasQuxInt = input.ReadInt64(ref result.quxInt_); - break; - } - case 18: - case 16: { - input.ReadInt32Array(tag, field_name, result.corgeInt_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasQuxInt { - get { return result.hasQuxInt; } - } - public long QuxInt { - get { return result.QuxInt; } - set { SetQuxInt(value); } - } - public Builder SetQuxInt(long value) { - PrepareBuilder(); - result.hasQuxInt = true; - result.quxInt_ = value; - return this; - } - public Builder ClearQuxInt() { - PrepareBuilder(); - result.hasQuxInt = false; - result.quxInt_ = 0L; - return this; - } - - public pbc::IPopsicleList CorgeIntList { - get { return PrepareBuilder().corgeInt_; } - } - public int CorgeIntCount { - get { return result.CorgeIntCount; } - } - public int GetCorgeInt(int index) { - return result.GetCorgeInt(index); - } - public Builder SetCorgeInt(int index, int value) { - PrepareBuilder(); - result.corgeInt_[index] = value; - return this; - } - public Builder AddCorgeInt(int value) { - PrepareBuilder(); - result.corgeInt_.Add(value); - return this; - } - public Builder AddRangeCorgeInt(scg::IEnumerable values) { - PrepareBuilder(); - result.corgeInt_.Add(values); - return this; - } - public Builder ClearCorgeInt() { - PrepareBuilder(); - result.corgeInt_.Clear(); - return this; - } - } - static NestedMessage() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - } - #endregion - - public const int FooIntFieldNumber = 1; - private bool hasFooInt; - private int fooInt_; - public bool HasFooInt { - get { return hasFooInt; } - } - public int FooInt { - get { return fooInt_; } - } - - public const int FooStringFieldNumber = 2; - private bool hasFooString; - private string fooString_ = ""; - public bool HasFooString { - get { return hasFooString; } - } - public string FooString { - get { return fooString_; } - } - - public const int FooCordFieldNumber = 3; - private bool hasFooCord; - private string fooCord_ = ""; - public bool HasFooCord { - get { return hasFooCord; } - } - public string FooCord { - get { return fooCord_; } - } - - public const int FooStringPieceFieldNumber = 4; - private bool hasFooStringPiece; - private string fooStringPiece_ = ""; - public bool HasFooStringPiece { - get { return hasFooStringPiece; } - } - public string FooStringPiece { - get { return fooStringPiece_; } - } - - public const int FooBytesFieldNumber = 5; - private bool hasFooBytes; - private pb::ByteString fooBytes_ = pb::ByteString.Empty; - public bool HasFooBytes { - get { return hasFooBytes; } - } - public pb::ByteString FooBytes { - get { return fooBytes_; } - } - - public const int FooEnumFieldNumber = 6; - private bool hasFooEnum; - private global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedEnum fooEnum_ = global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedEnum.FOO; - public bool HasFooEnum { - get { return hasFooEnum; } - } - public global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedEnum FooEnum { - get { return fooEnum_; } - } - - public const int FooMessageFieldNumber = 7; - private bool hasFooMessage; - private global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage fooMessage_; - public bool HasFooMessage { - get { return hasFooMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage FooMessage { - get { return fooMessage_ ?? global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage.DefaultInstance; } - } - - public const int FooGroupFieldNumber = 8; - private bool hasFooGroup; - private global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.FooGroup fooGroup_; - public bool HasFooGroup { - get { return hasFooGroup; } - } - public global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.FooGroup FooGroup { - get { return fooGroup_ ?? global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.FooGroup.DefaultInstance; } - } - - public const int FooLazyMessageFieldNumber = 11; - private bool hasFooLazyMessage; - private global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage fooLazyMessage_; - public bool HasFooLazyMessage { - get { return hasFooLazyMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage FooLazyMessage { - get { return fooLazyMessage_ ?? global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage.DefaultInstance; } - } - - public const int BarIntFieldNumber = 12; - private bool hasBarInt; - private int barInt_ = 5; - public bool HasBarInt { - get { return hasBarInt; } - } - public int BarInt { - get { return barInt_; } - } - - public const int BarStringFieldNumber = 13; - private bool hasBarString; - private string barString_ = "STRING"; - public bool HasBarString { - get { return hasBarString; } - } - public string BarString { - get { return barString_; } - } - - public const int BarCordFieldNumber = 14; - private bool hasBarCord; - private string barCord_ = "CORD"; - public bool HasBarCord { - get { return hasBarCord; } - } - public string BarCord { - get { return barCord_; } - } - - public const int BarStringPieceFieldNumber = 15; - private bool hasBarStringPiece; - private string barStringPiece_ = "SPIECE"; - public bool HasBarStringPiece { - get { return hasBarStringPiece; } - } - public string BarStringPiece { - get { return barStringPiece_; } - } - - public const int BarBytesFieldNumber = 16; - private bool hasBarBytes; - private pb::ByteString barBytes_ = (pb::ByteString) global::Google.ProtocolBuffers.TestProtos.TestOneof2.Descriptor.Fields[13].DefaultValue; - public bool HasBarBytes { - get { return hasBarBytes; } - } - public pb::ByteString BarBytes { - get { return barBytes_; } - } - - public const int BarEnumFieldNumber = 17; - private bool hasBarEnum; - private global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedEnum barEnum_ = global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedEnum.BAR; - public bool HasBarEnum { - get { return hasBarEnum; } - } - public global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedEnum BarEnum { - get { return barEnum_; } - } - - public const int BazIntFieldNumber = 18; - private bool hasBazInt; - private int bazInt_; - public bool HasBazInt { - get { return hasBazInt; } - } - public int BazInt { - get { return bazInt_; } - } - - public const int BazStringFieldNumber = 19; - private bool hasBazString; - private string bazString_ = "BAZ"; - public bool HasBazString { - get { return hasBazString; } - } - public string BazString { - get { return bazString_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testOneof2FieldNames; - if (hasFooInt) { - output.WriteInt32(1, field_names[11], FooInt); - } - if (hasFooString) { - output.WriteString(2, field_names[14], FooString); - } - if (hasFooCord) { - output.WriteString(3, field_names[9], FooCord); - } - if (hasFooStringPiece) { - output.WriteString(4, field_names[15], FooStringPiece); - } - if (hasFooBytes) { - output.WriteBytes(5, field_names[8], FooBytes); - } - if (hasFooEnum) { - output.WriteEnum(6, field_names[10], (int) FooEnum, FooEnum); - } - if (hasFooMessage) { - output.WriteMessage(7, field_names[13], FooMessage); - } - if (hasFooGroup) { - output.WriteGroup(8, field_names[16], FooGroup); - } - if (hasFooLazyMessage) { - output.WriteMessage(11, field_names[12], FooLazyMessage); - } - if (hasBarInt) { - output.WriteInt32(12, field_names[3], BarInt); - } - if (hasBarString) { - output.WriteString(13, field_names[4], BarString); - } - if (hasBarCord) { - output.WriteString(14, field_names[1], BarCord); - } - if (hasBarStringPiece) { - output.WriteString(15, field_names[5], BarStringPiece); - } - if (hasBarBytes) { - output.WriteBytes(16, field_names[0], BarBytes); - } - if (hasBarEnum) { - output.WriteEnum(17, field_names[2], (int) BarEnum, BarEnum); - } - if (hasBazInt) { - output.WriteInt32(18, field_names[6], BazInt); - } - if (hasBazString) { - output.WriteString(19, field_names[7], BazString); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasFooInt) { - size += pb::CodedOutputStream.ComputeInt32Size(1, FooInt); - } - if (hasFooString) { - size += pb::CodedOutputStream.ComputeStringSize(2, FooString); - } - if (hasFooCord) { - size += pb::CodedOutputStream.ComputeStringSize(3, FooCord); - } - if (hasFooStringPiece) { - size += pb::CodedOutputStream.ComputeStringSize(4, FooStringPiece); - } - if (hasFooBytes) { - size += pb::CodedOutputStream.ComputeBytesSize(5, FooBytes); - } - if (hasFooEnum) { - size += pb::CodedOutputStream.ComputeEnumSize(6, (int) FooEnum); - } - if (hasFooMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(7, FooMessage); - } - if (hasFooGroup) { - size += pb::CodedOutputStream.ComputeGroupSize(8, FooGroup); - } - if (hasFooLazyMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(11, FooLazyMessage); - } - if (hasBarInt) { - size += pb::CodedOutputStream.ComputeInt32Size(12, BarInt); - } - if (hasBarString) { - size += pb::CodedOutputStream.ComputeStringSize(13, BarString); - } - if (hasBarCord) { - size += pb::CodedOutputStream.ComputeStringSize(14, BarCord); - } - if (hasBarStringPiece) { - size += pb::CodedOutputStream.ComputeStringSize(15, BarStringPiece); - } - if (hasBarBytes) { - size += pb::CodedOutputStream.ComputeBytesSize(16, BarBytes); - } - if (hasBarEnum) { - size += pb::CodedOutputStream.ComputeEnumSize(17, (int) BarEnum); - } - if (hasBazInt) { - size += pb::CodedOutputStream.ComputeInt32Size(18, BazInt); - } - if (hasBazString) { - size += pb::CodedOutputStream.ComputeStringSize(19, BazString); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestOneof2 ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestOneof2 ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestOneof2 ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestOneof2 ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestOneof2 ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestOneof2 ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestOneof2 ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestOneof2 ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestOneof2 ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestOneof2 ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestOneof2 MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestOneof2 prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestOneof2 cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestOneof2 result; - - private TestOneof2 PrepareBuilder() { - if (resultIsReadOnly) { - TestOneof2 original = result; - result = new TestOneof2(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestOneof2 MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestOneof2.Descriptor; } - } - - public override TestOneof2 DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestOneof2.DefaultInstance; } - } - - public override TestOneof2 BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestOneof2) { - return MergeFrom((TestOneof2) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestOneof2 other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestOneof2.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasFooInt) { - FooInt = other.FooInt; - } - if (other.HasFooString) { - FooString = other.FooString; - } - if (other.HasFooCord) { - FooCord = other.FooCord; - } - if (other.HasFooStringPiece) { - FooStringPiece = other.FooStringPiece; - } - if (other.HasFooBytes) { - FooBytes = other.FooBytes; - } - if (other.HasFooEnum) { - FooEnum = other.FooEnum; - } - if (other.HasFooMessage) { - MergeFooMessage(other.FooMessage); - } - if (other.HasFooGroup) { - MergeFooGroup(other.FooGroup); - } - if (other.HasFooLazyMessage) { - MergeFooLazyMessage(other.FooLazyMessage); - } - if (other.HasBarInt) { - BarInt = other.BarInt; - } - if (other.HasBarString) { - BarString = other.BarString; - } - if (other.HasBarCord) { - BarCord = other.BarCord; - } - if (other.HasBarStringPiece) { - BarStringPiece = other.BarStringPiece; - } - if (other.HasBarBytes) { - BarBytes = other.BarBytes; - } - if (other.HasBarEnum) { - BarEnum = other.BarEnum; - } - if (other.HasBazInt) { - BazInt = other.BazInt; - } - if (other.HasBazString) { - BazString = other.BazString; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testOneof2FieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testOneof2FieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasFooInt = input.ReadInt32(ref result.fooInt_); - break; - } - case 18: { - result.hasFooString = input.ReadString(ref result.fooString_); - break; - } - case 26: { - result.hasFooCord = input.ReadString(ref result.fooCord_); - break; - } - case 34: { - result.hasFooStringPiece = input.ReadString(ref result.fooStringPiece_); - break; - } - case 42: { - result.hasFooBytes = input.ReadBytes(ref result.fooBytes_); - break; - } - case 48: { - object unknown; - if(input.ReadEnum(ref result.fooEnum_, out unknown)) { - result.hasFooEnum = true; - } else if(unknown is int) { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - unknownFields.MergeVarintField(6, (ulong)(int)unknown); - } - break; - } - case 58: { - global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage.CreateBuilder(); - if (result.hasFooMessage) { - subBuilder.MergeFrom(FooMessage); - } - input.ReadMessage(subBuilder, extensionRegistry); - FooMessage = subBuilder.BuildPartial(); - break; - } - case 67: { - global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.FooGroup.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.FooGroup.CreateBuilder(); - if (result.hasFooGroup) { - subBuilder.MergeFrom(FooGroup); - } - input.ReadGroup(8, subBuilder, extensionRegistry); - FooGroup = subBuilder.BuildPartial(); - break; - } - case 90: { - global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage.CreateBuilder(); - if (result.hasFooLazyMessage) { - subBuilder.MergeFrom(FooLazyMessage); - } - input.ReadMessage(subBuilder, extensionRegistry); - FooLazyMessage = subBuilder.BuildPartial(); - break; - } - case 96: { - result.hasBarInt = input.ReadInt32(ref result.barInt_); - break; - } - case 106: { - result.hasBarString = input.ReadString(ref result.barString_); - break; - } - case 114: { - result.hasBarCord = input.ReadString(ref result.barCord_); - break; - } - case 122: { - result.hasBarStringPiece = input.ReadString(ref result.barStringPiece_); - break; - } - case 130: { - result.hasBarBytes = input.ReadBytes(ref result.barBytes_); - break; - } - case 136: { - object unknown; - if(input.ReadEnum(ref result.barEnum_, out unknown)) { - result.hasBarEnum = true; - } else if(unknown is int) { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - unknownFields.MergeVarintField(17, (ulong)(int)unknown); - } - break; - } - case 144: { - result.hasBazInt = input.ReadInt32(ref result.bazInt_); - break; - } - case 154: { - result.hasBazString = input.ReadString(ref result.bazString_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasFooInt { - get { return result.hasFooInt; } - } - public int FooInt { - get { return result.FooInt; } - set { SetFooInt(value); } - } - public Builder SetFooInt(int value) { - PrepareBuilder(); - result.hasFooInt = true; - result.fooInt_ = value; - return this; - } - public Builder ClearFooInt() { - PrepareBuilder(); - result.hasFooInt = false; - result.fooInt_ = 0; - return this; - } - - public bool HasFooString { - get { return result.hasFooString; } - } - public string FooString { - get { return result.FooString; } - set { SetFooString(value); } - } - public Builder SetFooString(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasFooString = true; - result.fooString_ = value; - return this; - } - public Builder ClearFooString() { - PrepareBuilder(); - result.hasFooString = false; - result.fooString_ = ""; - return this; - } - - public bool HasFooCord { - get { return result.hasFooCord; } - } - public string FooCord { - get { return result.FooCord; } - set { SetFooCord(value); } - } - public Builder SetFooCord(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasFooCord = true; - result.fooCord_ = value; - return this; - } - public Builder ClearFooCord() { - PrepareBuilder(); - result.hasFooCord = false; - result.fooCord_ = ""; - return this; - } - - public bool HasFooStringPiece { - get { return result.hasFooStringPiece; } - } - public string FooStringPiece { - get { return result.FooStringPiece; } - set { SetFooStringPiece(value); } - } - public Builder SetFooStringPiece(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasFooStringPiece = true; - result.fooStringPiece_ = value; - return this; - } - public Builder ClearFooStringPiece() { - PrepareBuilder(); - result.hasFooStringPiece = false; - result.fooStringPiece_ = ""; - return this; - } - - public bool HasFooBytes { - get { return result.hasFooBytes; } - } - public pb::ByteString FooBytes { - get { return result.FooBytes; } - set { SetFooBytes(value); } - } - public Builder SetFooBytes(pb::ByteString value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasFooBytes = true; - result.fooBytes_ = value; - return this; - } - public Builder ClearFooBytes() { - PrepareBuilder(); - result.hasFooBytes = false; - result.fooBytes_ = pb::ByteString.Empty; - return this; - } - - public bool HasFooEnum { - get { return result.hasFooEnum; } - } - public global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedEnum FooEnum { - get { return result.FooEnum; } - set { SetFooEnum(value); } - } - public Builder SetFooEnum(global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedEnum value) { - PrepareBuilder(); - result.hasFooEnum = true; - result.fooEnum_ = value; - return this; - } - public Builder ClearFooEnum() { - PrepareBuilder(); - result.hasFooEnum = false; - result.fooEnum_ = global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedEnum.FOO; - return this; - } - - public bool HasFooMessage { - get { return result.hasFooMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage FooMessage { - get { return result.FooMessage; } - set { SetFooMessage(value); } - } - public Builder SetFooMessage(global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasFooMessage = true; - result.fooMessage_ = value; - return this; - } - public Builder SetFooMessage(global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasFooMessage = true; - result.fooMessage_ = builderForValue.Build(); - return this; - } - public Builder MergeFooMessage(global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasFooMessage && - result.fooMessage_ != global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage.DefaultInstance) { - result.fooMessage_ = global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage.CreateBuilder(result.fooMessage_).MergeFrom(value).BuildPartial(); - } else { - result.fooMessage_ = value; - } - result.hasFooMessage = true; - return this; - } - public Builder ClearFooMessage() { - PrepareBuilder(); - result.hasFooMessage = false; - result.fooMessage_ = null; - return this; - } - - public bool HasFooGroup { - get { return result.hasFooGroup; } - } - public global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.FooGroup FooGroup { - get { return result.FooGroup; } - set { SetFooGroup(value); } - } - public Builder SetFooGroup(global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.FooGroup value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasFooGroup = true; - result.fooGroup_ = value; - return this; - } - public Builder SetFooGroup(global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.FooGroup.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasFooGroup = true; - result.fooGroup_ = builderForValue.Build(); - return this; - } - public Builder MergeFooGroup(global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.FooGroup value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasFooGroup && - result.fooGroup_ != global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.FooGroup.DefaultInstance) { - result.fooGroup_ = global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.FooGroup.CreateBuilder(result.fooGroup_).MergeFrom(value).BuildPartial(); - } else { - result.fooGroup_ = value; - } - result.hasFooGroup = true; - return this; - } - public Builder ClearFooGroup() { - PrepareBuilder(); - result.hasFooGroup = false; - result.fooGroup_ = null; - return this; - } - - public bool HasFooLazyMessage { - get { return result.hasFooLazyMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage FooLazyMessage { - get { return result.FooLazyMessage; } - set { SetFooLazyMessage(value); } - } - public Builder SetFooLazyMessage(global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasFooLazyMessage = true; - result.fooLazyMessage_ = value; - return this; - } - public Builder SetFooLazyMessage(global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasFooLazyMessage = true; - result.fooLazyMessage_ = builderForValue.Build(); - return this; - } - public Builder MergeFooLazyMessage(global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasFooLazyMessage && - result.fooLazyMessage_ != global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage.DefaultInstance) { - result.fooLazyMessage_ = global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedMessage.CreateBuilder(result.fooLazyMessage_).MergeFrom(value).BuildPartial(); - } else { - result.fooLazyMessage_ = value; - } - result.hasFooLazyMessage = true; - return this; - } - public Builder ClearFooLazyMessage() { - PrepareBuilder(); - result.hasFooLazyMessage = false; - result.fooLazyMessage_ = null; - return this; - } - - public bool HasBarInt { - get { return result.hasBarInt; } - } - public int BarInt { - get { return result.BarInt; } - set { SetBarInt(value); } - } - public Builder SetBarInt(int value) { - PrepareBuilder(); - result.hasBarInt = true; - result.barInt_ = value; - return this; - } - public Builder ClearBarInt() { - PrepareBuilder(); - result.hasBarInt = false; - result.barInt_ = 5; - return this; - } - - public bool HasBarString { - get { return result.hasBarString; } - } - public string BarString { - get { return result.BarString; } - set { SetBarString(value); } - } - public Builder SetBarString(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasBarString = true; - result.barString_ = value; - return this; - } - public Builder ClearBarString() { - PrepareBuilder(); - result.hasBarString = false; - result.barString_ = "STRING"; - return this; - } - - public bool HasBarCord { - get { return result.hasBarCord; } - } - public string BarCord { - get { return result.BarCord; } - set { SetBarCord(value); } - } - public Builder SetBarCord(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasBarCord = true; - result.barCord_ = value; - return this; - } - public Builder ClearBarCord() { - PrepareBuilder(); - result.hasBarCord = false; - result.barCord_ = "CORD"; - return this; - } - - public bool HasBarStringPiece { - get { return result.hasBarStringPiece; } - } - public string BarStringPiece { - get { return result.BarStringPiece; } - set { SetBarStringPiece(value); } - } - public Builder SetBarStringPiece(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasBarStringPiece = true; - result.barStringPiece_ = value; - return this; - } - public Builder ClearBarStringPiece() { - PrepareBuilder(); - result.hasBarStringPiece = false; - result.barStringPiece_ = "SPIECE"; - return this; - } - - public bool HasBarBytes { - get { return result.hasBarBytes; } - } - public pb::ByteString BarBytes { - get { return result.BarBytes; } - set { SetBarBytes(value); } - } - public Builder SetBarBytes(pb::ByteString value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasBarBytes = true; - result.barBytes_ = value; - return this; - } - public Builder ClearBarBytes() { - PrepareBuilder(); - result.hasBarBytes = false; - result.barBytes_ = (pb::ByteString) global::Google.ProtocolBuffers.TestProtos.TestOneof2.Descriptor.Fields[13].DefaultValue; - return this; - } - - public bool HasBarEnum { - get { return result.hasBarEnum; } - } - public global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedEnum BarEnum { - get { return result.BarEnum; } - set { SetBarEnum(value); } - } - public Builder SetBarEnum(global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedEnum value) { - PrepareBuilder(); - result.hasBarEnum = true; - result.barEnum_ = value; - return this; - } - public Builder ClearBarEnum() { - PrepareBuilder(); - result.hasBarEnum = false; - result.barEnum_ = global::Google.ProtocolBuffers.TestProtos.TestOneof2.Types.NestedEnum.BAR; - return this; - } - - public bool HasBazInt { - get { return result.hasBazInt; } - } - public int BazInt { - get { return result.BazInt; } - set { SetBazInt(value); } - } - public Builder SetBazInt(int value) { - PrepareBuilder(); - result.hasBazInt = true; - result.bazInt_ = value; - return this; - } - public Builder ClearBazInt() { - PrepareBuilder(); - result.hasBazInt = false; - result.bazInt_ = 0; - return this; - } - - public bool HasBazString { - get { return result.hasBazString; } - } - public string BazString { - get { return result.BazString; } - set { SetBazString(value); } - } - public Builder SetBazString(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasBazString = true; - result.bazString_ = value; - return this; - } - public Builder ClearBazString() { - PrepareBuilder(); - result.hasBazString = false; - result.bazString_ = "BAZ"; - return this; - } - } - static TestOneof2() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestRequiredOneof : pb::GeneratedMessage { - private TestRequiredOneof() { } - private static readonly TestRequiredOneof defaultInstance = new TestRequiredOneof().MakeReadOnly(); - private static readonly string[] _testRequiredOneofFieldNames = new string[] { "foo_int", "foo_message", "foo_string" }; - private static readonly uint[] _testRequiredOneofFieldTags = new uint[] { 8, 26, 18 }; - public static TestRequiredOneof DefaultInstance { - get { return defaultInstance; } - } - - public override TestRequiredOneof DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestRequiredOneof ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestRequiredOneof__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestRequiredOneof__FieldAccessorTable; } - } - - #region Nested types - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class Types { - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class NestedMessage : pb::GeneratedMessage { - private NestedMessage() { } - private static readonly NestedMessage defaultInstance = new NestedMessage().MakeReadOnly(); - private static readonly string[] _nestedMessageFieldNames = new string[] { "required_double" }; - private static readonly uint[] _nestedMessageFieldTags = new uint[] { 9 }; - public static NestedMessage DefaultInstance { - get { return defaultInstance; } - } - - public override NestedMessage DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override NestedMessage ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestRequiredOneof_NestedMessage__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestRequiredOneof_NestedMessage__FieldAccessorTable; } - } - - public const int RequiredDoubleFieldNumber = 1; - private bool hasRequiredDouble; - private double requiredDouble_; - public bool HasRequiredDouble { - get { return hasRequiredDouble; } - } - public double RequiredDouble { - get { return requiredDouble_; } - } - - public override bool IsInitialized { - get { - if (!hasRequiredDouble) return false; - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _nestedMessageFieldNames; - if (hasRequiredDouble) { - output.WriteDouble(1, field_names[0], RequiredDouble); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasRequiredDouble) { - size += pb::CodedOutputStream.ComputeDoubleSize(1, RequiredDouble); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static NestedMessage ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static NestedMessage ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static NestedMessage ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static NestedMessage ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static NestedMessage ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static NestedMessage ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static NestedMessage ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static NestedMessage ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static NestedMessage ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static NestedMessage ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private NestedMessage MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(NestedMessage prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(NestedMessage cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private NestedMessage result; - - private NestedMessage PrepareBuilder() { - if (resultIsReadOnly) { - NestedMessage original = result; - result = new NestedMessage(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override NestedMessage MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestRequiredOneof.Types.NestedMessage.Descriptor; } - } - - public override NestedMessage DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestRequiredOneof.Types.NestedMessage.DefaultInstance; } - } - - public override NestedMessage BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is NestedMessage) { - return MergeFrom((NestedMessage) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(NestedMessage other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestRequiredOneof.Types.NestedMessage.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasRequiredDouble) { - RequiredDouble = other.RequiredDouble; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_nestedMessageFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _nestedMessageFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 9: { - result.hasRequiredDouble = input.ReadDouble(ref result.requiredDouble_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasRequiredDouble { - get { return result.hasRequiredDouble; } - } - public double RequiredDouble { - get { return result.RequiredDouble; } - set { SetRequiredDouble(value); } - } - public Builder SetRequiredDouble(double value) { - PrepareBuilder(); - result.hasRequiredDouble = true; - result.requiredDouble_ = value; - return this; - } - public Builder ClearRequiredDouble() { - PrepareBuilder(); - result.hasRequiredDouble = false; - result.requiredDouble_ = 0D; - return this; - } - } - static NestedMessage() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - } - #endregion - - public const int FooIntFieldNumber = 1; - private bool hasFooInt; - private int fooInt_; - public bool HasFooInt { - get { return hasFooInt; } - } - public int FooInt { - get { return fooInt_; } - } - - public const int FooStringFieldNumber = 2; - private bool hasFooString; - private string fooString_ = ""; - public bool HasFooString { - get { return hasFooString; } - } - public string FooString { - get { return fooString_; } - } - - public const int FooMessageFieldNumber = 3; - private bool hasFooMessage; - private global::Google.ProtocolBuffers.TestProtos.TestRequiredOneof.Types.NestedMessage fooMessage_; - public bool HasFooMessage { - get { return hasFooMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestRequiredOneof.Types.NestedMessage FooMessage { - get { return fooMessage_ ?? global::Google.ProtocolBuffers.TestProtos.TestRequiredOneof.Types.NestedMessage.DefaultInstance; } - } - - public override bool IsInitialized { - get { - if (HasFooMessage) { - if (!FooMessage.IsInitialized) return false; - } - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testRequiredOneofFieldNames; - if (hasFooInt) { - output.WriteInt32(1, field_names[0], FooInt); - } - if (hasFooString) { - output.WriteString(2, field_names[2], FooString); - } - if (hasFooMessage) { - output.WriteMessage(3, field_names[1], FooMessage); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasFooInt) { - size += pb::CodedOutputStream.ComputeInt32Size(1, FooInt); - } - if (hasFooString) { - size += pb::CodedOutputStream.ComputeStringSize(2, FooString); - } - if (hasFooMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(3, FooMessage); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestRequiredOneof ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestRequiredOneof ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestRequiredOneof ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestRequiredOneof ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestRequiredOneof ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestRequiredOneof ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestRequiredOneof ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestRequiredOneof ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestRequiredOneof ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestRequiredOneof ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestRequiredOneof MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestRequiredOneof prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestRequiredOneof cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestRequiredOneof result; - - private TestRequiredOneof PrepareBuilder() { - if (resultIsReadOnly) { - TestRequiredOneof original = result; - result = new TestRequiredOneof(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestRequiredOneof MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestRequiredOneof.Descriptor; } - } - - public override TestRequiredOneof DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestRequiredOneof.DefaultInstance; } - } - - public override TestRequiredOneof BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestRequiredOneof) { - return MergeFrom((TestRequiredOneof) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestRequiredOneof other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestRequiredOneof.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasFooInt) { - FooInt = other.FooInt; - } - if (other.HasFooString) { - FooString = other.FooString; - } - if (other.HasFooMessage) { - MergeFooMessage(other.FooMessage); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testRequiredOneofFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testRequiredOneofFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasFooInt = input.ReadInt32(ref result.fooInt_); - break; - } - case 18: { - result.hasFooString = input.ReadString(ref result.fooString_); - break; - } - case 26: { - global::Google.ProtocolBuffers.TestProtos.TestRequiredOneof.Types.NestedMessage.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestRequiredOneof.Types.NestedMessage.CreateBuilder(); - if (result.hasFooMessage) { - subBuilder.MergeFrom(FooMessage); - } - input.ReadMessage(subBuilder, extensionRegistry); - FooMessage = subBuilder.BuildPartial(); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasFooInt { - get { return result.hasFooInt; } - } - public int FooInt { - get { return result.FooInt; } - set { SetFooInt(value); } - } - public Builder SetFooInt(int value) { - PrepareBuilder(); - result.hasFooInt = true; - result.fooInt_ = value; - return this; - } - public Builder ClearFooInt() { - PrepareBuilder(); - result.hasFooInt = false; - result.fooInt_ = 0; - return this; - } - - public bool HasFooString { - get { return result.hasFooString; } - } - public string FooString { - get { return result.FooString; } - set { SetFooString(value); } - } - public Builder SetFooString(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasFooString = true; - result.fooString_ = value; - return this; - } - public Builder ClearFooString() { - PrepareBuilder(); - result.hasFooString = false; - result.fooString_ = ""; - return this; - } - - public bool HasFooMessage { - get { return result.hasFooMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.TestRequiredOneof.Types.NestedMessage FooMessage { - get { return result.FooMessage; } - set { SetFooMessage(value); } - } - public Builder SetFooMessage(global::Google.ProtocolBuffers.TestProtos.TestRequiredOneof.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasFooMessage = true; - result.fooMessage_ = value; - return this; - } - public Builder SetFooMessage(global::Google.ProtocolBuffers.TestProtos.TestRequiredOneof.Types.NestedMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasFooMessage = true; - result.fooMessage_ = builderForValue.Build(); - return this; - } - public Builder MergeFooMessage(global::Google.ProtocolBuffers.TestProtos.TestRequiredOneof.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasFooMessage && - result.fooMessage_ != global::Google.ProtocolBuffers.TestProtos.TestRequiredOneof.Types.NestedMessage.DefaultInstance) { - result.fooMessage_ = global::Google.ProtocolBuffers.TestProtos.TestRequiredOneof.Types.NestedMessage.CreateBuilder(result.fooMessage_).MergeFrom(value).BuildPartial(); - } else { - result.fooMessage_ = value; - } - result.hasFooMessage = true; - return this; - } - public Builder ClearFooMessage() { - PrepareBuilder(); - result.hasFooMessage = false; - result.fooMessage_ = null; - return this; - } - } - static TestRequiredOneof() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestPackedTypes : pb::GeneratedMessage { - private TestPackedTypes() { } - private static readonly TestPackedTypes defaultInstance = new TestPackedTypes().MakeReadOnly(); - private static readonly string[] _testPackedTypesFieldNames = new string[] { "packed_bool", "packed_double", "packed_enum", "packed_fixed32", "packed_fixed64", "packed_float", "packed_int32", "packed_int64", "packed_sfixed32", "packed_sfixed64", "packed_sint32", "packed_sint64", "packed_uint32", "packed_uint64" }; - private static readonly uint[] _testPackedTypesFieldTags = new uint[] { 818, 810, 826, 770, 778, 802, 722, 730, 786, 794, 754, 762, 738, 746 }; - public static TestPackedTypes DefaultInstance { - get { return defaultInstance; } - } - - public override TestPackedTypes DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestPackedTypes ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestPackedTypes__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestPackedTypes__FieldAccessorTable; } - } - - public const int PackedInt32FieldNumber = 90; - private int packedInt32MemoizedSerializedSize; - private pbc::PopsicleList packedInt32_ = new pbc::PopsicleList(); - public scg::IList PackedInt32List { - get { return pbc::Lists.AsReadOnly(packedInt32_); } - } - public int PackedInt32Count { - get { return packedInt32_.Count; } - } - public int GetPackedInt32(int index) { - return packedInt32_[index]; - } - - public const int PackedInt64FieldNumber = 91; - private int packedInt64MemoizedSerializedSize; - private pbc::PopsicleList packedInt64_ = new pbc::PopsicleList(); - public scg::IList PackedInt64List { - get { return pbc::Lists.AsReadOnly(packedInt64_); } - } - public int PackedInt64Count { - get { return packedInt64_.Count; } - } - public long GetPackedInt64(int index) { - return packedInt64_[index]; - } - - public const int PackedUint32FieldNumber = 92; - private int packedUint32MemoizedSerializedSize; - private pbc::PopsicleList packedUint32_ = new pbc::PopsicleList(); - [global::System.CLSCompliant(false)] - public scg::IList PackedUint32List { - get { return pbc::Lists.AsReadOnly(packedUint32_); } - } - public int PackedUint32Count { - get { return packedUint32_.Count; } - } - [global::System.CLSCompliant(false)] - public uint GetPackedUint32(int index) { - return packedUint32_[index]; - } - - public const int PackedUint64FieldNumber = 93; - private int packedUint64MemoizedSerializedSize; - private pbc::PopsicleList packedUint64_ = new pbc::PopsicleList(); - [global::System.CLSCompliant(false)] - public scg::IList PackedUint64List { - get { return pbc::Lists.AsReadOnly(packedUint64_); } - } - public int PackedUint64Count { - get { return packedUint64_.Count; } - } - [global::System.CLSCompliant(false)] - public ulong GetPackedUint64(int index) { - return packedUint64_[index]; - } - - public const int PackedSint32FieldNumber = 94; - private int packedSint32MemoizedSerializedSize; - private pbc::PopsicleList packedSint32_ = new pbc::PopsicleList(); - public scg::IList PackedSint32List { - get { return pbc::Lists.AsReadOnly(packedSint32_); } - } - public int PackedSint32Count { - get { return packedSint32_.Count; } - } - public int GetPackedSint32(int index) { - return packedSint32_[index]; - } - - public const int PackedSint64FieldNumber = 95; - private int packedSint64MemoizedSerializedSize; - private pbc::PopsicleList packedSint64_ = new pbc::PopsicleList(); - public scg::IList PackedSint64List { - get { return pbc::Lists.AsReadOnly(packedSint64_); } - } - public int PackedSint64Count { - get { return packedSint64_.Count; } - } - public long GetPackedSint64(int index) { - return packedSint64_[index]; - } - - public const int PackedFixed32FieldNumber = 96; - private int packedFixed32MemoizedSerializedSize; - private pbc::PopsicleList packedFixed32_ = new pbc::PopsicleList(); - [global::System.CLSCompliant(false)] - public scg::IList PackedFixed32List { - get { return pbc::Lists.AsReadOnly(packedFixed32_); } - } - public int PackedFixed32Count { - get { return packedFixed32_.Count; } - } - [global::System.CLSCompliant(false)] - public uint GetPackedFixed32(int index) { - return packedFixed32_[index]; - } - - public const int PackedFixed64FieldNumber = 97; - private int packedFixed64MemoizedSerializedSize; - private pbc::PopsicleList packedFixed64_ = new pbc::PopsicleList(); - [global::System.CLSCompliant(false)] - public scg::IList PackedFixed64List { - get { return pbc::Lists.AsReadOnly(packedFixed64_); } - } - public int PackedFixed64Count { - get { return packedFixed64_.Count; } - } - [global::System.CLSCompliant(false)] - public ulong GetPackedFixed64(int index) { - return packedFixed64_[index]; - } - - public const int PackedSfixed32FieldNumber = 98; - private int packedSfixed32MemoizedSerializedSize; - private pbc::PopsicleList packedSfixed32_ = new pbc::PopsicleList(); - public scg::IList PackedSfixed32List { - get { return pbc::Lists.AsReadOnly(packedSfixed32_); } - } - public int PackedSfixed32Count { - get { return packedSfixed32_.Count; } - } - public int GetPackedSfixed32(int index) { - return packedSfixed32_[index]; - } - - public const int PackedSfixed64FieldNumber = 99; - private int packedSfixed64MemoizedSerializedSize; - private pbc::PopsicleList packedSfixed64_ = new pbc::PopsicleList(); - public scg::IList PackedSfixed64List { - get { return pbc::Lists.AsReadOnly(packedSfixed64_); } - } - public int PackedSfixed64Count { - get { return packedSfixed64_.Count; } - } - public long GetPackedSfixed64(int index) { - return packedSfixed64_[index]; - } - - public const int PackedFloatFieldNumber = 100; - private int packedFloatMemoizedSerializedSize; - private pbc::PopsicleList packedFloat_ = new pbc::PopsicleList(); - public scg::IList PackedFloatList { - get { return pbc::Lists.AsReadOnly(packedFloat_); } - } - public int PackedFloatCount { - get { return packedFloat_.Count; } - } - public float GetPackedFloat(int index) { - return packedFloat_[index]; - } - - public const int PackedDoubleFieldNumber = 101; - private int packedDoubleMemoizedSerializedSize; - private pbc::PopsicleList packedDouble_ = new pbc::PopsicleList(); - public scg::IList PackedDoubleList { - get { return pbc::Lists.AsReadOnly(packedDouble_); } - } - public int PackedDoubleCount { - get { return packedDouble_.Count; } - } - public double GetPackedDouble(int index) { - return packedDouble_[index]; - } - - public const int PackedBoolFieldNumber = 102; - private int packedBoolMemoizedSerializedSize; - private pbc::PopsicleList packedBool_ = new pbc::PopsicleList(); - public scg::IList PackedBoolList { - get { return pbc::Lists.AsReadOnly(packedBool_); } - } - public int PackedBoolCount { - get { return packedBool_.Count; } - } - public bool GetPackedBool(int index) { - return packedBool_[index]; - } - - public const int PackedEnumFieldNumber = 103; - private int packedEnumMemoizedSerializedSize; - private pbc::PopsicleList packedEnum_ = new pbc::PopsicleList(); - public scg::IList PackedEnumList { - get { return pbc::Lists.AsReadOnly(packedEnum_); } - } - public int PackedEnumCount { - get { return packedEnum_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignEnum GetPackedEnum(int index) { - return packedEnum_[index]; - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testPackedTypesFieldNames; - if (packedInt32_.Count > 0) { - output.WritePackedInt32Array(90, field_names[6], packedInt32MemoizedSerializedSize, packedInt32_); - } - if (packedInt64_.Count > 0) { - output.WritePackedInt64Array(91, field_names[7], packedInt64MemoizedSerializedSize, packedInt64_); - } - if (packedUint32_.Count > 0) { - output.WritePackedUInt32Array(92, field_names[12], packedUint32MemoizedSerializedSize, packedUint32_); - } - if (packedUint64_.Count > 0) { - output.WritePackedUInt64Array(93, field_names[13], packedUint64MemoizedSerializedSize, packedUint64_); - } - if (packedSint32_.Count > 0) { - output.WritePackedSInt32Array(94, field_names[10], packedSint32MemoizedSerializedSize, packedSint32_); - } - if (packedSint64_.Count > 0) { - output.WritePackedSInt64Array(95, field_names[11], packedSint64MemoizedSerializedSize, packedSint64_); - } - if (packedFixed32_.Count > 0) { - output.WritePackedFixed32Array(96, field_names[3], packedFixed32MemoizedSerializedSize, packedFixed32_); - } - if (packedFixed64_.Count > 0) { - output.WritePackedFixed64Array(97, field_names[4], packedFixed64MemoizedSerializedSize, packedFixed64_); - } - if (packedSfixed32_.Count > 0) { - output.WritePackedSFixed32Array(98, field_names[8], packedSfixed32MemoizedSerializedSize, packedSfixed32_); - } - if (packedSfixed64_.Count > 0) { - output.WritePackedSFixed64Array(99, field_names[9], packedSfixed64MemoizedSerializedSize, packedSfixed64_); - } - if (packedFloat_.Count > 0) { - output.WritePackedFloatArray(100, field_names[5], packedFloatMemoizedSerializedSize, packedFloat_); - } - if (packedDouble_.Count > 0) { - output.WritePackedDoubleArray(101, field_names[1], packedDoubleMemoizedSerializedSize, packedDouble_); - } - if (packedBool_.Count > 0) { - output.WritePackedBoolArray(102, field_names[0], packedBoolMemoizedSerializedSize, packedBool_); - } - if (packedEnum_.Count > 0) { - output.WritePackedEnumArray(103, field_names[2], packedEnumMemoizedSerializedSize, packedEnum_); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - { - int dataSize = 0; - foreach (int element in PackedInt32List) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); - } - size += dataSize; - if (packedInt32_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedInt32MemoizedSerializedSize = dataSize; - } - { - int dataSize = 0; - foreach (long element in PackedInt64List) { - dataSize += pb::CodedOutputStream.ComputeInt64SizeNoTag(element); - } - size += dataSize; - if (packedInt64_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedInt64MemoizedSerializedSize = dataSize; - } - { - int dataSize = 0; - foreach (uint element in PackedUint32List) { - dataSize += pb::CodedOutputStream.ComputeUInt32SizeNoTag(element); - } - size += dataSize; - if (packedUint32_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedUint32MemoizedSerializedSize = dataSize; - } - { - int dataSize = 0; - foreach (ulong element in PackedUint64List) { - dataSize += pb::CodedOutputStream.ComputeUInt64SizeNoTag(element); - } - size += dataSize; - if (packedUint64_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedUint64MemoizedSerializedSize = dataSize; - } - { - int dataSize = 0; - foreach (int element in PackedSint32List) { - dataSize += pb::CodedOutputStream.ComputeSInt32SizeNoTag(element); - } - size += dataSize; - if (packedSint32_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedSint32MemoizedSerializedSize = dataSize; - } - { - int dataSize = 0; - foreach (long element in PackedSint64List) { - dataSize += pb::CodedOutputStream.ComputeSInt64SizeNoTag(element); - } - size += dataSize; - if (packedSint64_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedSint64MemoizedSerializedSize = dataSize; - } - { - int dataSize = 0; - dataSize = 4 * packedFixed32_.Count; - size += dataSize; - if (packedFixed32_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedFixed32MemoizedSerializedSize = dataSize; - } - { - int dataSize = 0; - dataSize = 8 * packedFixed64_.Count; - size += dataSize; - if (packedFixed64_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedFixed64MemoizedSerializedSize = dataSize; - } - { - int dataSize = 0; - dataSize = 4 * packedSfixed32_.Count; - size += dataSize; - if (packedSfixed32_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedSfixed32MemoizedSerializedSize = dataSize; - } - { - int dataSize = 0; - dataSize = 8 * packedSfixed64_.Count; - size += dataSize; - if (packedSfixed64_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedSfixed64MemoizedSerializedSize = dataSize; - } - { - int dataSize = 0; - dataSize = 4 * packedFloat_.Count; - size += dataSize; - if (packedFloat_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedFloatMemoizedSerializedSize = dataSize; - } - { - int dataSize = 0; - dataSize = 8 * packedDouble_.Count; - size += dataSize; - if (packedDouble_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedDoubleMemoizedSerializedSize = dataSize; - } - { - int dataSize = 0; - dataSize = 1 * packedBool_.Count; - size += dataSize; - if (packedBool_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedBoolMemoizedSerializedSize = dataSize; - } - { - int dataSize = 0; - if (packedEnum_.Count > 0) { - foreach (global::Google.ProtocolBuffers.TestProtos.ForeignEnum element in packedEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 2; - size += pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize); - } - packedEnumMemoizedSerializedSize = dataSize; - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestPackedTypes ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestPackedTypes ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestPackedTypes ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestPackedTypes ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestPackedTypes ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestPackedTypes ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestPackedTypes ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestPackedTypes ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestPackedTypes ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestPackedTypes ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestPackedTypes MakeReadOnly() { - packedInt32_.MakeReadOnly(); - packedInt64_.MakeReadOnly(); - packedUint32_.MakeReadOnly(); - packedUint64_.MakeReadOnly(); - packedSint32_.MakeReadOnly(); - packedSint64_.MakeReadOnly(); - packedFixed32_.MakeReadOnly(); - packedFixed64_.MakeReadOnly(); - packedSfixed32_.MakeReadOnly(); - packedSfixed64_.MakeReadOnly(); - packedFloat_.MakeReadOnly(); - packedDouble_.MakeReadOnly(); - packedBool_.MakeReadOnly(); - packedEnum_.MakeReadOnly(); - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestPackedTypes prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestPackedTypes cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestPackedTypes result; - - private TestPackedTypes PrepareBuilder() { - if (resultIsReadOnly) { - TestPackedTypes original = result; - result = new TestPackedTypes(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestPackedTypes MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestPackedTypes.Descriptor; } - } - - public override TestPackedTypes DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestPackedTypes.DefaultInstance; } - } - - public override TestPackedTypes BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestPackedTypes) { - return MergeFrom((TestPackedTypes) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestPackedTypes other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestPackedTypes.DefaultInstance) return this; - PrepareBuilder(); - if (other.packedInt32_.Count != 0) { - result.packedInt32_.Add(other.packedInt32_); - } - if (other.packedInt64_.Count != 0) { - result.packedInt64_.Add(other.packedInt64_); - } - if (other.packedUint32_.Count != 0) { - result.packedUint32_.Add(other.packedUint32_); - } - if (other.packedUint64_.Count != 0) { - result.packedUint64_.Add(other.packedUint64_); - } - if (other.packedSint32_.Count != 0) { - result.packedSint32_.Add(other.packedSint32_); - } - if (other.packedSint64_.Count != 0) { - result.packedSint64_.Add(other.packedSint64_); - } - if (other.packedFixed32_.Count != 0) { - result.packedFixed32_.Add(other.packedFixed32_); - } - if (other.packedFixed64_.Count != 0) { - result.packedFixed64_.Add(other.packedFixed64_); - } - if (other.packedSfixed32_.Count != 0) { - result.packedSfixed32_.Add(other.packedSfixed32_); - } - if (other.packedSfixed64_.Count != 0) { - result.packedSfixed64_.Add(other.packedSfixed64_); - } - if (other.packedFloat_.Count != 0) { - result.packedFloat_.Add(other.packedFloat_); - } - if (other.packedDouble_.Count != 0) { - result.packedDouble_.Add(other.packedDouble_); - } - if (other.packedBool_.Count != 0) { - result.packedBool_.Add(other.packedBool_); - } - if (other.packedEnum_.Count != 0) { - result.packedEnum_.Add(other.packedEnum_); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testPackedTypesFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testPackedTypesFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 722: - case 720: { - input.ReadInt32Array(tag, field_name, result.packedInt32_); - break; - } - case 730: - case 728: { - input.ReadInt64Array(tag, field_name, result.packedInt64_); - break; - } - case 738: - case 736: { - input.ReadUInt32Array(tag, field_name, result.packedUint32_); - break; - } - case 746: - case 744: { - input.ReadUInt64Array(tag, field_name, result.packedUint64_); - break; - } - case 754: - case 752: { - input.ReadSInt32Array(tag, field_name, result.packedSint32_); - break; - } - case 762: - case 760: { - input.ReadSInt64Array(tag, field_name, result.packedSint64_); - break; - } - case 770: - case 773: { - input.ReadFixed32Array(tag, field_name, result.packedFixed32_); - break; - } - case 778: - case 777: { - input.ReadFixed64Array(tag, field_name, result.packedFixed64_); - break; - } - case 786: - case 789: { - input.ReadSFixed32Array(tag, field_name, result.packedSfixed32_); - break; - } - case 794: - case 793: { - input.ReadSFixed64Array(tag, field_name, result.packedSfixed64_); - break; - } - case 802: - case 805: { - input.ReadFloatArray(tag, field_name, result.packedFloat_); - break; - } - case 810: - case 809: { - input.ReadDoubleArray(tag, field_name, result.packedDouble_); - break; - } - case 818: - case 816: { - input.ReadBoolArray(tag, field_name, result.packedBool_); - break; - } - case 826: - case 824: { - scg::ICollection unknownItems; - input.ReadEnumArray(tag, field_name, result.packedEnum_, out unknownItems); - if (unknownItems != null) { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - foreach (object rawValue in unknownItems) - if (rawValue is int) - unknownFields.MergeVarintField(103, (ulong)(int)rawValue); - } - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public pbc::IPopsicleList PackedInt32List { - get { return PrepareBuilder().packedInt32_; } - } - public int PackedInt32Count { - get { return result.PackedInt32Count; } - } - public int GetPackedInt32(int index) { - return result.GetPackedInt32(index); - } - public Builder SetPackedInt32(int index, int value) { - PrepareBuilder(); - result.packedInt32_[index] = value; - return this; - } - public Builder AddPackedInt32(int value) { - PrepareBuilder(); - result.packedInt32_.Add(value); - return this; - } - public Builder AddRangePackedInt32(scg::IEnumerable values) { - PrepareBuilder(); - result.packedInt32_.Add(values); - return this; - } - public Builder ClearPackedInt32() { - PrepareBuilder(); - result.packedInt32_.Clear(); - return this; - } - - public pbc::IPopsicleList PackedInt64List { - get { return PrepareBuilder().packedInt64_; } - } - public int PackedInt64Count { - get { return result.PackedInt64Count; } - } - public long GetPackedInt64(int index) { - return result.GetPackedInt64(index); - } - public Builder SetPackedInt64(int index, long value) { - PrepareBuilder(); - result.packedInt64_[index] = value; - return this; - } - public Builder AddPackedInt64(long value) { - PrepareBuilder(); - result.packedInt64_.Add(value); - return this; - } - public Builder AddRangePackedInt64(scg::IEnumerable values) { - PrepareBuilder(); - result.packedInt64_.Add(values); - return this; - } - public Builder ClearPackedInt64() { - PrepareBuilder(); - result.packedInt64_.Clear(); - return this; - } - - [global::System.CLSCompliant(false)] - public pbc::IPopsicleList PackedUint32List { - get { return PrepareBuilder().packedUint32_; } - } - public int PackedUint32Count { - get { return result.PackedUint32Count; } - } - [global::System.CLSCompliant(false)] - public uint GetPackedUint32(int index) { - return result.GetPackedUint32(index); - } - [global::System.CLSCompliant(false)] - public Builder SetPackedUint32(int index, uint value) { - PrepareBuilder(); - result.packedUint32_[index] = value; - return this; - } - [global::System.CLSCompliant(false)] - public Builder AddPackedUint32(uint value) { - PrepareBuilder(); - result.packedUint32_.Add(value); - return this; - } - [global::System.CLSCompliant(false)] - public Builder AddRangePackedUint32(scg::IEnumerable values) { - PrepareBuilder(); - result.packedUint32_.Add(values); - return this; - } - public Builder ClearPackedUint32() { - PrepareBuilder(); - result.packedUint32_.Clear(); - return this; - } - - [global::System.CLSCompliant(false)] - public pbc::IPopsicleList PackedUint64List { - get { return PrepareBuilder().packedUint64_; } - } - public int PackedUint64Count { - get { return result.PackedUint64Count; } - } - [global::System.CLSCompliant(false)] - public ulong GetPackedUint64(int index) { - return result.GetPackedUint64(index); - } - [global::System.CLSCompliant(false)] - public Builder SetPackedUint64(int index, ulong value) { - PrepareBuilder(); - result.packedUint64_[index] = value; - return this; - } - [global::System.CLSCompliant(false)] - public Builder AddPackedUint64(ulong value) { - PrepareBuilder(); - result.packedUint64_.Add(value); - return this; - } - [global::System.CLSCompliant(false)] - public Builder AddRangePackedUint64(scg::IEnumerable values) { - PrepareBuilder(); - result.packedUint64_.Add(values); - return this; - } - public Builder ClearPackedUint64() { - PrepareBuilder(); - result.packedUint64_.Clear(); - return this; - } - - public pbc::IPopsicleList PackedSint32List { - get { return PrepareBuilder().packedSint32_; } - } - public int PackedSint32Count { - get { return result.PackedSint32Count; } - } - public int GetPackedSint32(int index) { - return result.GetPackedSint32(index); - } - public Builder SetPackedSint32(int index, int value) { - PrepareBuilder(); - result.packedSint32_[index] = value; - return this; - } - public Builder AddPackedSint32(int value) { - PrepareBuilder(); - result.packedSint32_.Add(value); - return this; - } - public Builder AddRangePackedSint32(scg::IEnumerable values) { - PrepareBuilder(); - result.packedSint32_.Add(values); - return this; - } - public Builder ClearPackedSint32() { - PrepareBuilder(); - result.packedSint32_.Clear(); - return this; - } - - public pbc::IPopsicleList PackedSint64List { - get { return PrepareBuilder().packedSint64_; } - } - public int PackedSint64Count { - get { return result.PackedSint64Count; } - } - public long GetPackedSint64(int index) { - return result.GetPackedSint64(index); - } - public Builder SetPackedSint64(int index, long value) { - PrepareBuilder(); - result.packedSint64_[index] = value; - return this; - } - public Builder AddPackedSint64(long value) { - PrepareBuilder(); - result.packedSint64_.Add(value); - return this; - } - public Builder AddRangePackedSint64(scg::IEnumerable values) { - PrepareBuilder(); - result.packedSint64_.Add(values); - return this; - } - public Builder ClearPackedSint64() { - PrepareBuilder(); - result.packedSint64_.Clear(); - return this; - } - - [global::System.CLSCompliant(false)] - public pbc::IPopsicleList PackedFixed32List { - get { return PrepareBuilder().packedFixed32_; } - } - public int PackedFixed32Count { - get { return result.PackedFixed32Count; } - } - [global::System.CLSCompliant(false)] - public uint GetPackedFixed32(int index) { - return result.GetPackedFixed32(index); - } - [global::System.CLSCompliant(false)] - public Builder SetPackedFixed32(int index, uint value) { - PrepareBuilder(); - result.packedFixed32_[index] = value; - return this; - } - [global::System.CLSCompliant(false)] - public Builder AddPackedFixed32(uint value) { - PrepareBuilder(); - result.packedFixed32_.Add(value); - return this; - } - [global::System.CLSCompliant(false)] - public Builder AddRangePackedFixed32(scg::IEnumerable values) { - PrepareBuilder(); - result.packedFixed32_.Add(values); - return this; - } - public Builder ClearPackedFixed32() { - PrepareBuilder(); - result.packedFixed32_.Clear(); - return this; - } - - [global::System.CLSCompliant(false)] - public pbc::IPopsicleList PackedFixed64List { - get { return PrepareBuilder().packedFixed64_; } - } - public int PackedFixed64Count { - get { return result.PackedFixed64Count; } - } - [global::System.CLSCompliant(false)] - public ulong GetPackedFixed64(int index) { - return result.GetPackedFixed64(index); - } - [global::System.CLSCompliant(false)] - public Builder SetPackedFixed64(int index, ulong value) { - PrepareBuilder(); - result.packedFixed64_[index] = value; - return this; - } - [global::System.CLSCompliant(false)] - public Builder AddPackedFixed64(ulong value) { - PrepareBuilder(); - result.packedFixed64_.Add(value); - return this; - } - [global::System.CLSCompliant(false)] - public Builder AddRangePackedFixed64(scg::IEnumerable values) { - PrepareBuilder(); - result.packedFixed64_.Add(values); - return this; - } - public Builder ClearPackedFixed64() { - PrepareBuilder(); - result.packedFixed64_.Clear(); - return this; - } - - public pbc::IPopsicleList PackedSfixed32List { - get { return PrepareBuilder().packedSfixed32_; } - } - public int PackedSfixed32Count { - get { return result.PackedSfixed32Count; } - } - public int GetPackedSfixed32(int index) { - return result.GetPackedSfixed32(index); - } - public Builder SetPackedSfixed32(int index, int value) { - PrepareBuilder(); - result.packedSfixed32_[index] = value; - return this; - } - public Builder AddPackedSfixed32(int value) { - PrepareBuilder(); - result.packedSfixed32_.Add(value); - return this; - } - public Builder AddRangePackedSfixed32(scg::IEnumerable values) { - PrepareBuilder(); - result.packedSfixed32_.Add(values); - return this; - } - public Builder ClearPackedSfixed32() { - PrepareBuilder(); - result.packedSfixed32_.Clear(); - return this; - } - - public pbc::IPopsicleList PackedSfixed64List { - get { return PrepareBuilder().packedSfixed64_; } - } - public int PackedSfixed64Count { - get { return result.PackedSfixed64Count; } - } - public long GetPackedSfixed64(int index) { - return result.GetPackedSfixed64(index); - } - public Builder SetPackedSfixed64(int index, long value) { - PrepareBuilder(); - result.packedSfixed64_[index] = value; - return this; - } - public Builder AddPackedSfixed64(long value) { - PrepareBuilder(); - result.packedSfixed64_.Add(value); - return this; - } - public Builder AddRangePackedSfixed64(scg::IEnumerable values) { - PrepareBuilder(); - result.packedSfixed64_.Add(values); - return this; - } - public Builder ClearPackedSfixed64() { - PrepareBuilder(); - result.packedSfixed64_.Clear(); - return this; - } - - public pbc::IPopsicleList PackedFloatList { - get { return PrepareBuilder().packedFloat_; } - } - public int PackedFloatCount { - get { return result.PackedFloatCount; } - } - public float GetPackedFloat(int index) { - return result.GetPackedFloat(index); - } - public Builder SetPackedFloat(int index, float value) { - PrepareBuilder(); - result.packedFloat_[index] = value; - return this; - } - public Builder AddPackedFloat(float value) { - PrepareBuilder(); - result.packedFloat_.Add(value); - return this; - } - public Builder AddRangePackedFloat(scg::IEnumerable values) { - PrepareBuilder(); - result.packedFloat_.Add(values); - return this; - } - public Builder ClearPackedFloat() { - PrepareBuilder(); - result.packedFloat_.Clear(); - return this; - } - - public pbc::IPopsicleList PackedDoubleList { - get { return PrepareBuilder().packedDouble_; } - } - public int PackedDoubleCount { - get { return result.PackedDoubleCount; } - } - public double GetPackedDouble(int index) { - return result.GetPackedDouble(index); - } - public Builder SetPackedDouble(int index, double value) { - PrepareBuilder(); - result.packedDouble_[index] = value; - return this; - } - public Builder AddPackedDouble(double value) { - PrepareBuilder(); - result.packedDouble_.Add(value); - return this; - } - public Builder AddRangePackedDouble(scg::IEnumerable values) { - PrepareBuilder(); - result.packedDouble_.Add(values); - return this; - } - public Builder ClearPackedDouble() { - PrepareBuilder(); - result.packedDouble_.Clear(); - return this; - } - - public pbc::IPopsicleList PackedBoolList { - get { return PrepareBuilder().packedBool_; } - } - public int PackedBoolCount { - get { return result.PackedBoolCount; } - } - public bool GetPackedBool(int index) { - return result.GetPackedBool(index); - } - public Builder SetPackedBool(int index, bool value) { - PrepareBuilder(); - result.packedBool_[index] = value; - return this; - } - public Builder AddPackedBool(bool value) { - PrepareBuilder(); - result.packedBool_.Add(value); - return this; - } - public Builder AddRangePackedBool(scg::IEnumerable values) { - PrepareBuilder(); - result.packedBool_.Add(values); - return this; - } - public Builder ClearPackedBool() { - PrepareBuilder(); - result.packedBool_.Clear(); - return this; - } - - public pbc::IPopsicleList PackedEnumList { - get { return PrepareBuilder().packedEnum_; } - } - public int PackedEnumCount { - get { return result.PackedEnumCount; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignEnum GetPackedEnum(int index) { - return result.GetPackedEnum(index); - } - public Builder SetPackedEnum(int index, global::Google.ProtocolBuffers.TestProtos.ForeignEnum value) { - PrepareBuilder(); - result.packedEnum_[index] = value; - return this; - } - public Builder AddPackedEnum(global::Google.ProtocolBuffers.TestProtos.ForeignEnum value) { - PrepareBuilder(); - result.packedEnum_.Add(value); - return this; - } - public Builder AddRangePackedEnum(scg::IEnumerable values) { - PrepareBuilder(); - result.packedEnum_.Add(values); - return this; - } - public Builder ClearPackedEnum() { - PrepareBuilder(); - result.packedEnum_.Clear(); - return this; - } - } - static TestPackedTypes() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestUnpackedTypes : pb::GeneratedMessage { - private TestUnpackedTypes() { } - private static readonly TestUnpackedTypes defaultInstance = new TestUnpackedTypes().MakeReadOnly(); - private static readonly string[] _testUnpackedTypesFieldNames = new string[] { "unpacked_bool", "unpacked_double", "unpacked_enum", "unpacked_fixed32", "unpacked_fixed64", "unpacked_float", "unpacked_int32", "unpacked_int64", "unpacked_sfixed32", "unpacked_sfixed64", "unpacked_sint32", "unpacked_sint64", "unpacked_uint32", "unpacked_uint64" }; - private static readonly uint[] _testUnpackedTypesFieldTags = new uint[] { 816, 809, 824, 773, 777, 805, 720, 728, 789, 793, 752, 760, 736, 744 }; - public static TestUnpackedTypes DefaultInstance { - get { return defaultInstance; } - } - - public override TestUnpackedTypes DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestUnpackedTypes ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestUnpackedTypes__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestUnpackedTypes__FieldAccessorTable; } - } - - public const int UnpackedInt32FieldNumber = 90; - private pbc::PopsicleList unpackedInt32_ = new pbc::PopsicleList(); - public scg::IList UnpackedInt32List { - get { return pbc::Lists.AsReadOnly(unpackedInt32_); } - } - public int UnpackedInt32Count { - get { return unpackedInt32_.Count; } - } - public int GetUnpackedInt32(int index) { - return unpackedInt32_[index]; - } - - public const int UnpackedInt64FieldNumber = 91; - private pbc::PopsicleList unpackedInt64_ = new pbc::PopsicleList(); - public scg::IList UnpackedInt64List { - get { return pbc::Lists.AsReadOnly(unpackedInt64_); } - } - public int UnpackedInt64Count { - get { return unpackedInt64_.Count; } - } - public long GetUnpackedInt64(int index) { - return unpackedInt64_[index]; - } - - public const int UnpackedUint32FieldNumber = 92; - private pbc::PopsicleList unpackedUint32_ = new pbc::PopsicleList(); - [global::System.CLSCompliant(false)] - public scg::IList UnpackedUint32List { - get { return pbc::Lists.AsReadOnly(unpackedUint32_); } - } - public int UnpackedUint32Count { - get { return unpackedUint32_.Count; } - } - [global::System.CLSCompliant(false)] - public uint GetUnpackedUint32(int index) { - return unpackedUint32_[index]; - } - - public const int UnpackedUint64FieldNumber = 93; - private pbc::PopsicleList unpackedUint64_ = new pbc::PopsicleList(); - [global::System.CLSCompliant(false)] - public scg::IList UnpackedUint64List { - get { return pbc::Lists.AsReadOnly(unpackedUint64_); } - } - public int UnpackedUint64Count { - get { return unpackedUint64_.Count; } - } - [global::System.CLSCompliant(false)] - public ulong GetUnpackedUint64(int index) { - return unpackedUint64_[index]; - } - - public const int UnpackedSint32FieldNumber = 94; - private pbc::PopsicleList unpackedSint32_ = new pbc::PopsicleList(); - public scg::IList UnpackedSint32List { - get { return pbc::Lists.AsReadOnly(unpackedSint32_); } - } - public int UnpackedSint32Count { - get { return unpackedSint32_.Count; } - } - public int GetUnpackedSint32(int index) { - return unpackedSint32_[index]; - } - - public const int UnpackedSint64FieldNumber = 95; - private pbc::PopsicleList unpackedSint64_ = new pbc::PopsicleList(); - public scg::IList UnpackedSint64List { - get { return pbc::Lists.AsReadOnly(unpackedSint64_); } - } - public int UnpackedSint64Count { - get { return unpackedSint64_.Count; } - } - public long GetUnpackedSint64(int index) { - return unpackedSint64_[index]; - } - - public const int UnpackedFixed32FieldNumber = 96; - private pbc::PopsicleList unpackedFixed32_ = new pbc::PopsicleList(); - [global::System.CLSCompliant(false)] - public scg::IList UnpackedFixed32List { - get { return pbc::Lists.AsReadOnly(unpackedFixed32_); } - } - public int UnpackedFixed32Count { - get { return unpackedFixed32_.Count; } - } - [global::System.CLSCompliant(false)] - public uint GetUnpackedFixed32(int index) { - return unpackedFixed32_[index]; - } - - public const int UnpackedFixed64FieldNumber = 97; - private pbc::PopsicleList unpackedFixed64_ = new pbc::PopsicleList(); - [global::System.CLSCompliant(false)] - public scg::IList UnpackedFixed64List { - get { return pbc::Lists.AsReadOnly(unpackedFixed64_); } - } - public int UnpackedFixed64Count { - get { return unpackedFixed64_.Count; } - } - [global::System.CLSCompliant(false)] - public ulong GetUnpackedFixed64(int index) { - return unpackedFixed64_[index]; - } - - public const int UnpackedSfixed32FieldNumber = 98; - private pbc::PopsicleList unpackedSfixed32_ = new pbc::PopsicleList(); - public scg::IList UnpackedSfixed32List { - get { return pbc::Lists.AsReadOnly(unpackedSfixed32_); } - } - public int UnpackedSfixed32Count { - get { return unpackedSfixed32_.Count; } - } - public int GetUnpackedSfixed32(int index) { - return unpackedSfixed32_[index]; - } - - public const int UnpackedSfixed64FieldNumber = 99; - private pbc::PopsicleList unpackedSfixed64_ = new pbc::PopsicleList(); - public scg::IList UnpackedSfixed64List { - get { return pbc::Lists.AsReadOnly(unpackedSfixed64_); } - } - public int UnpackedSfixed64Count { - get { return unpackedSfixed64_.Count; } - } - public long GetUnpackedSfixed64(int index) { - return unpackedSfixed64_[index]; - } - - public const int UnpackedFloatFieldNumber = 100; - private pbc::PopsicleList unpackedFloat_ = new pbc::PopsicleList(); - public scg::IList UnpackedFloatList { - get { return pbc::Lists.AsReadOnly(unpackedFloat_); } - } - public int UnpackedFloatCount { - get { return unpackedFloat_.Count; } - } - public float GetUnpackedFloat(int index) { - return unpackedFloat_[index]; - } - - public const int UnpackedDoubleFieldNumber = 101; - private pbc::PopsicleList unpackedDouble_ = new pbc::PopsicleList(); - public scg::IList UnpackedDoubleList { - get { return pbc::Lists.AsReadOnly(unpackedDouble_); } - } - public int UnpackedDoubleCount { - get { return unpackedDouble_.Count; } - } - public double GetUnpackedDouble(int index) { - return unpackedDouble_[index]; - } - - public const int UnpackedBoolFieldNumber = 102; - private pbc::PopsicleList unpackedBool_ = new pbc::PopsicleList(); - public scg::IList UnpackedBoolList { - get { return pbc::Lists.AsReadOnly(unpackedBool_); } - } - public int UnpackedBoolCount { - get { return unpackedBool_.Count; } - } - public bool GetUnpackedBool(int index) { - return unpackedBool_[index]; - } - - public const int UnpackedEnumFieldNumber = 103; - private pbc::PopsicleList unpackedEnum_ = new pbc::PopsicleList(); - public scg::IList UnpackedEnumList { - get { return pbc::Lists.AsReadOnly(unpackedEnum_); } - } - public int UnpackedEnumCount { - get { return unpackedEnum_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignEnum GetUnpackedEnum(int index) { - return unpackedEnum_[index]; - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testUnpackedTypesFieldNames; - if (unpackedInt32_.Count > 0) { - output.WriteInt32Array(90, field_names[6], unpackedInt32_); - } - if (unpackedInt64_.Count > 0) { - output.WriteInt64Array(91, field_names[7], unpackedInt64_); - } - if (unpackedUint32_.Count > 0) { - output.WriteUInt32Array(92, field_names[12], unpackedUint32_); - } - if (unpackedUint64_.Count > 0) { - output.WriteUInt64Array(93, field_names[13], unpackedUint64_); - } - if (unpackedSint32_.Count > 0) { - output.WriteSInt32Array(94, field_names[10], unpackedSint32_); - } - if (unpackedSint64_.Count > 0) { - output.WriteSInt64Array(95, field_names[11], unpackedSint64_); - } - if (unpackedFixed32_.Count > 0) { - output.WriteFixed32Array(96, field_names[3], unpackedFixed32_); - } - if (unpackedFixed64_.Count > 0) { - output.WriteFixed64Array(97, field_names[4], unpackedFixed64_); - } - if (unpackedSfixed32_.Count > 0) { - output.WriteSFixed32Array(98, field_names[8], unpackedSfixed32_); - } - if (unpackedSfixed64_.Count > 0) { - output.WriteSFixed64Array(99, field_names[9], unpackedSfixed64_); - } - if (unpackedFloat_.Count > 0) { - output.WriteFloatArray(100, field_names[5], unpackedFloat_); - } - if (unpackedDouble_.Count > 0) { - output.WriteDoubleArray(101, field_names[1], unpackedDouble_); - } - if (unpackedBool_.Count > 0) { - output.WriteBoolArray(102, field_names[0], unpackedBool_); - } - if (unpackedEnum_.Count > 0) { - output.WriteEnumArray(103, field_names[2], unpackedEnum_); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - { - int dataSize = 0; - foreach (int element in UnpackedInt32List) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); - } - size += dataSize; - size += 2 * unpackedInt32_.Count; - } - { - int dataSize = 0; - foreach (long element in UnpackedInt64List) { - dataSize += pb::CodedOutputStream.ComputeInt64SizeNoTag(element); - } - size += dataSize; - size += 2 * unpackedInt64_.Count; - } - { - int dataSize = 0; - foreach (uint element in UnpackedUint32List) { - dataSize += pb::CodedOutputStream.ComputeUInt32SizeNoTag(element); - } - size += dataSize; - size += 2 * unpackedUint32_.Count; - } - { - int dataSize = 0; - foreach (ulong element in UnpackedUint64List) { - dataSize += pb::CodedOutputStream.ComputeUInt64SizeNoTag(element); - } - size += dataSize; - size += 2 * unpackedUint64_.Count; - } - { - int dataSize = 0; - foreach (int element in UnpackedSint32List) { - dataSize += pb::CodedOutputStream.ComputeSInt32SizeNoTag(element); - } - size += dataSize; - size += 2 * unpackedSint32_.Count; - } - { - int dataSize = 0; - foreach (long element in UnpackedSint64List) { - dataSize += pb::CodedOutputStream.ComputeSInt64SizeNoTag(element); - } - size += dataSize; - size += 2 * unpackedSint64_.Count; - } - { - int dataSize = 0; - dataSize = 4 * unpackedFixed32_.Count; - size += dataSize; - size += 2 * unpackedFixed32_.Count; - } - { - int dataSize = 0; - dataSize = 8 * unpackedFixed64_.Count; - size += dataSize; - size += 2 * unpackedFixed64_.Count; - } - { - int dataSize = 0; - dataSize = 4 * unpackedSfixed32_.Count; - size += dataSize; - size += 2 * unpackedSfixed32_.Count; - } - { - int dataSize = 0; - dataSize = 8 * unpackedSfixed64_.Count; - size += dataSize; - size += 2 * unpackedSfixed64_.Count; - } - { - int dataSize = 0; - dataSize = 4 * unpackedFloat_.Count; - size += dataSize; - size += 2 * unpackedFloat_.Count; - } - { - int dataSize = 0; - dataSize = 8 * unpackedDouble_.Count; - size += dataSize; - size += 2 * unpackedDouble_.Count; - } - { - int dataSize = 0; - dataSize = 1 * unpackedBool_.Count; - size += dataSize; - size += 2 * unpackedBool_.Count; - } - { - int dataSize = 0; - if (unpackedEnum_.Count > 0) { - foreach (global::Google.ProtocolBuffers.TestProtos.ForeignEnum element in unpackedEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); - } - size += dataSize; - size += 2 * unpackedEnum_.Count; - } - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestUnpackedTypes ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestUnpackedTypes ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestUnpackedTypes ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestUnpackedTypes ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestUnpackedTypes ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestUnpackedTypes ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestUnpackedTypes ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestUnpackedTypes ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestUnpackedTypes ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestUnpackedTypes ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestUnpackedTypes MakeReadOnly() { - unpackedInt32_.MakeReadOnly(); - unpackedInt64_.MakeReadOnly(); - unpackedUint32_.MakeReadOnly(); - unpackedUint64_.MakeReadOnly(); - unpackedSint32_.MakeReadOnly(); - unpackedSint64_.MakeReadOnly(); - unpackedFixed32_.MakeReadOnly(); - unpackedFixed64_.MakeReadOnly(); - unpackedSfixed32_.MakeReadOnly(); - unpackedSfixed64_.MakeReadOnly(); - unpackedFloat_.MakeReadOnly(); - unpackedDouble_.MakeReadOnly(); - unpackedBool_.MakeReadOnly(); - unpackedEnum_.MakeReadOnly(); - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestUnpackedTypes prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestUnpackedTypes cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestUnpackedTypes result; - - private TestUnpackedTypes PrepareBuilder() { - if (resultIsReadOnly) { - TestUnpackedTypes original = result; - result = new TestUnpackedTypes(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestUnpackedTypes MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestUnpackedTypes.Descriptor; } - } - - public override TestUnpackedTypes DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestUnpackedTypes.DefaultInstance; } - } - - public override TestUnpackedTypes BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestUnpackedTypes) { - return MergeFrom((TestUnpackedTypes) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestUnpackedTypes other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestUnpackedTypes.DefaultInstance) return this; - PrepareBuilder(); - if (other.unpackedInt32_.Count != 0) { - result.unpackedInt32_.Add(other.unpackedInt32_); - } - if (other.unpackedInt64_.Count != 0) { - result.unpackedInt64_.Add(other.unpackedInt64_); - } - if (other.unpackedUint32_.Count != 0) { - result.unpackedUint32_.Add(other.unpackedUint32_); - } - if (other.unpackedUint64_.Count != 0) { - result.unpackedUint64_.Add(other.unpackedUint64_); - } - if (other.unpackedSint32_.Count != 0) { - result.unpackedSint32_.Add(other.unpackedSint32_); - } - if (other.unpackedSint64_.Count != 0) { - result.unpackedSint64_.Add(other.unpackedSint64_); - } - if (other.unpackedFixed32_.Count != 0) { - result.unpackedFixed32_.Add(other.unpackedFixed32_); - } - if (other.unpackedFixed64_.Count != 0) { - result.unpackedFixed64_.Add(other.unpackedFixed64_); - } - if (other.unpackedSfixed32_.Count != 0) { - result.unpackedSfixed32_.Add(other.unpackedSfixed32_); - } - if (other.unpackedSfixed64_.Count != 0) { - result.unpackedSfixed64_.Add(other.unpackedSfixed64_); - } - if (other.unpackedFloat_.Count != 0) { - result.unpackedFloat_.Add(other.unpackedFloat_); - } - if (other.unpackedDouble_.Count != 0) { - result.unpackedDouble_.Add(other.unpackedDouble_); - } - if (other.unpackedBool_.Count != 0) { - result.unpackedBool_.Add(other.unpackedBool_); - } - if (other.unpackedEnum_.Count != 0) { - result.unpackedEnum_.Add(other.unpackedEnum_); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testUnpackedTypesFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testUnpackedTypesFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 722: - case 720: { - input.ReadInt32Array(tag, field_name, result.unpackedInt32_); - break; - } - case 730: - case 728: { - input.ReadInt64Array(tag, field_name, result.unpackedInt64_); - break; - } - case 738: - case 736: { - input.ReadUInt32Array(tag, field_name, result.unpackedUint32_); - break; - } - case 746: - case 744: { - input.ReadUInt64Array(tag, field_name, result.unpackedUint64_); - break; - } - case 754: - case 752: { - input.ReadSInt32Array(tag, field_name, result.unpackedSint32_); - break; - } - case 762: - case 760: { - input.ReadSInt64Array(tag, field_name, result.unpackedSint64_); - break; - } - case 770: - case 773: { - input.ReadFixed32Array(tag, field_name, result.unpackedFixed32_); - break; - } - case 778: - case 777: { - input.ReadFixed64Array(tag, field_name, result.unpackedFixed64_); - break; - } - case 786: - case 789: { - input.ReadSFixed32Array(tag, field_name, result.unpackedSfixed32_); - break; - } - case 794: - case 793: { - input.ReadSFixed64Array(tag, field_name, result.unpackedSfixed64_); - break; - } - case 802: - case 805: { - input.ReadFloatArray(tag, field_name, result.unpackedFloat_); - break; - } - case 810: - case 809: { - input.ReadDoubleArray(tag, field_name, result.unpackedDouble_); - break; - } - case 818: - case 816: { - input.ReadBoolArray(tag, field_name, result.unpackedBool_); - break; - } - case 826: - case 824: { - scg::ICollection unknownItems; - input.ReadEnumArray(tag, field_name, result.unpackedEnum_, out unknownItems); - if (unknownItems != null) { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - foreach (object rawValue in unknownItems) - if (rawValue is int) - unknownFields.MergeVarintField(103, (ulong)(int)rawValue); - } - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public pbc::IPopsicleList UnpackedInt32List { - get { return PrepareBuilder().unpackedInt32_; } - } - public int UnpackedInt32Count { - get { return result.UnpackedInt32Count; } - } - public int GetUnpackedInt32(int index) { - return result.GetUnpackedInt32(index); - } - public Builder SetUnpackedInt32(int index, int value) { - PrepareBuilder(); - result.unpackedInt32_[index] = value; - return this; - } - public Builder AddUnpackedInt32(int value) { - PrepareBuilder(); - result.unpackedInt32_.Add(value); - return this; - } - public Builder AddRangeUnpackedInt32(scg::IEnumerable values) { - PrepareBuilder(); - result.unpackedInt32_.Add(values); - return this; - } - public Builder ClearUnpackedInt32() { - PrepareBuilder(); - result.unpackedInt32_.Clear(); - return this; - } - - public pbc::IPopsicleList UnpackedInt64List { - get { return PrepareBuilder().unpackedInt64_; } - } - public int UnpackedInt64Count { - get { return result.UnpackedInt64Count; } - } - public long GetUnpackedInt64(int index) { - return result.GetUnpackedInt64(index); - } - public Builder SetUnpackedInt64(int index, long value) { - PrepareBuilder(); - result.unpackedInt64_[index] = value; - return this; - } - public Builder AddUnpackedInt64(long value) { - PrepareBuilder(); - result.unpackedInt64_.Add(value); - return this; - } - public Builder AddRangeUnpackedInt64(scg::IEnumerable values) { - PrepareBuilder(); - result.unpackedInt64_.Add(values); - return this; - } - public Builder ClearUnpackedInt64() { - PrepareBuilder(); - result.unpackedInt64_.Clear(); - return this; - } - - [global::System.CLSCompliant(false)] - public pbc::IPopsicleList UnpackedUint32List { - get { return PrepareBuilder().unpackedUint32_; } - } - public int UnpackedUint32Count { - get { return result.UnpackedUint32Count; } - } - [global::System.CLSCompliant(false)] - public uint GetUnpackedUint32(int index) { - return result.GetUnpackedUint32(index); - } - [global::System.CLSCompliant(false)] - public Builder SetUnpackedUint32(int index, uint value) { - PrepareBuilder(); - result.unpackedUint32_[index] = value; - return this; - } - [global::System.CLSCompliant(false)] - public Builder AddUnpackedUint32(uint value) { - PrepareBuilder(); - result.unpackedUint32_.Add(value); - return this; - } - [global::System.CLSCompliant(false)] - public Builder AddRangeUnpackedUint32(scg::IEnumerable values) { - PrepareBuilder(); - result.unpackedUint32_.Add(values); - return this; - } - public Builder ClearUnpackedUint32() { - PrepareBuilder(); - result.unpackedUint32_.Clear(); - return this; - } - - [global::System.CLSCompliant(false)] - public pbc::IPopsicleList UnpackedUint64List { - get { return PrepareBuilder().unpackedUint64_; } - } - public int UnpackedUint64Count { - get { return result.UnpackedUint64Count; } - } - [global::System.CLSCompliant(false)] - public ulong GetUnpackedUint64(int index) { - return result.GetUnpackedUint64(index); - } - [global::System.CLSCompliant(false)] - public Builder SetUnpackedUint64(int index, ulong value) { - PrepareBuilder(); - result.unpackedUint64_[index] = value; - return this; - } - [global::System.CLSCompliant(false)] - public Builder AddUnpackedUint64(ulong value) { - PrepareBuilder(); - result.unpackedUint64_.Add(value); - return this; - } - [global::System.CLSCompliant(false)] - public Builder AddRangeUnpackedUint64(scg::IEnumerable values) { - PrepareBuilder(); - result.unpackedUint64_.Add(values); - return this; - } - public Builder ClearUnpackedUint64() { - PrepareBuilder(); - result.unpackedUint64_.Clear(); - return this; - } - - public pbc::IPopsicleList UnpackedSint32List { - get { return PrepareBuilder().unpackedSint32_; } - } - public int UnpackedSint32Count { - get { return result.UnpackedSint32Count; } - } - public int GetUnpackedSint32(int index) { - return result.GetUnpackedSint32(index); - } - public Builder SetUnpackedSint32(int index, int value) { - PrepareBuilder(); - result.unpackedSint32_[index] = value; - return this; - } - public Builder AddUnpackedSint32(int value) { - PrepareBuilder(); - result.unpackedSint32_.Add(value); - return this; - } - public Builder AddRangeUnpackedSint32(scg::IEnumerable values) { - PrepareBuilder(); - result.unpackedSint32_.Add(values); - return this; - } - public Builder ClearUnpackedSint32() { - PrepareBuilder(); - result.unpackedSint32_.Clear(); - return this; - } - - public pbc::IPopsicleList UnpackedSint64List { - get { return PrepareBuilder().unpackedSint64_; } - } - public int UnpackedSint64Count { - get { return result.UnpackedSint64Count; } - } - public long GetUnpackedSint64(int index) { - return result.GetUnpackedSint64(index); - } - public Builder SetUnpackedSint64(int index, long value) { - PrepareBuilder(); - result.unpackedSint64_[index] = value; - return this; - } - public Builder AddUnpackedSint64(long value) { - PrepareBuilder(); - result.unpackedSint64_.Add(value); - return this; - } - public Builder AddRangeUnpackedSint64(scg::IEnumerable values) { - PrepareBuilder(); - result.unpackedSint64_.Add(values); - return this; - } - public Builder ClearUnpackedSint64() { - PrepareBuilder(); - result.unpackedSint64_.Clear(); - return this; - } - - [global::System.CLSCompliant(false)] - public pbc::IPopsicleList UnpackedFixed32List { - get { return PrepareBuilder().unpackedFixed32_; } - } - public int UnpackedFixed32Count { - get { return result.UnpackedFixed32Count; } - } - [global::System.CLSCompliant(false)] - public uint GetUnpackedFixed32(int index) { - return result.GetUnpackedFixed32(index); - } - [global::System.CLSCompliant(false)] - public Builder SetUnpackedFixed32(int index, uint value) { - PrepareBuilder(); - result.unpackedFixed32_[index] = value; - return this; - } - [global::System.CLSCompliant(false)] - public Builder AddUnpackedFixed32(uint value) { - PrepareBuilder(); - result.unpackedFixed32_.Add(value); - return this; - } - [global::System.CLSCompliant(false)] - public Builder AddRangeUnpackedFixed32(scg::IEnumerable values) { - PrepareBuilder(); - result.unpackedFixed32_.Add(values); - return this; - } - public Builder ClearUnpackedFixed32() { - PrepareBuilder(); - result.unpackedFixed32_.Clear(); - return this; - } - - [global::System.CLSCompliant(false)] - public pbc::IPopsicleList UnpackedFixed64List { - get { return PrepareBuilder().unpackedFixed64_; } - } - public int UnpackedFixed64Count { - get { return result.UnpackedFixed64Count; } - } - [global::System.CLSCompliant(false)] - public ulong GetUnpackedFixed64(int index) { - return result.GetUnpackedFixed64(index); - } - [global::System.CLSCompliant(false)] - public Builder SetUnpackedFixed64(int index, ulong value) { - PrepareBuilder(); - result.unpackedFixed64_[index] = value; - return this; - } - [global::System.CLSCompliant(false)] - public Builder AddUnpackedFixed64(ulong value) { - PrepareBuilder(); - result.unpackedFixed64_.Add(value); - return this; - } - [global::System.CLSCompliant(false)] - public Builder AddRangeUnpackedFixed64(scg::IEnumerable values) { - PrepareBuilder(); - result.unpackedFixed64_.Add(values); - return this; - } - public Builder ClearUnpackedFixed64() { - PrepareBuilder(); - result.unpackedFixed64_.Clear(); - return this; - } - - public pbc::IPopsicleList UnpackedSfixed32List { - get { return PrepareBuilder().unpackedSfixed32_; } - } - public int UnpackedSfixed32Count { - get { return result.UnpackedSfixed32Count; } - } - public int GetUnpackedSfixed32(int index) { - return result.GetUnpackedSfixed32(index); - } - public Builder SetUnpackedSfixed32(int index, int value) { - PrepareBuilder(); - result.unpackedSfixed32_[index] = value; - return this; - } - public Builder AddUnpackedSfixed32(int value) { - PrepareBuilder(); - result.unpackedSfixed32_.Add(value); - return this; - } - public Builder AddRangeUnpackedSfixed32(scg::IEnumerable values) { - PrepareBuilder(); - result.unpackedSfixed32_.Add(values); - return this; - } - public Builder ClearUnpackedSfixed32() { - PrepareBuilder(); - result.unpackedSfixed32_.Clear(); - return this; - } - - public pbc::IPopsicleList UnpackedSfixed64List { - get { return PrepareBuilder().unpackedSfixed64_; } - } - public int UnpackedSfixed64Count { - get { return result.UnpackedSfixed64Count; } - } - public long GetUnpackedSfixed64(int index) { - return result.GetUnpackedSfixed64(index); - } - public Builder SetUnpackedSfixed64(int index, long value) { - PrepareBuilder(); - result.unpackedSfixed64_[index] = value; - return this; - } - public Builder AddUnpackedSfixed64(long value) { - PrepareBuilder(); - result.unpackedSfixed64_.Add(value); - return this; - } - public Builder AddRangeUnpackedSfixed64(scg::IEnumerable values) { - PrepareBuilder(); - result.unpackedSfixed64_.Add(values); - return this; - } - public Builder ClearUnpackedSfixed64() { - PrepareBuilder(); - result.unpackedSfixed64_.Clear(); - return this; - } - - public pbc::IPopsicleList UnpackedFloatList { - get { return PrepareBuilder().unpackedFloat_; } - } - public int UnpackedFloatCount { - get { return result.UnpackedFloatCount; } - } - public float GetUnpackedFloat(int index) { - return result.GetUnpackedFloat(index); - } - public Builder SetUnpackedFloat(int index, float value) { - PrepareBuilder(); - result.unpackedFloat_[index] = value; - return this; - } - public Builder AddUnpackedFloat(float value) { - PrepareBuilder(); - result.unpackedFloat_.Add(value); - return this; - } - public Builder AddRangeUnpackedFloat(scg::IEnumerable values) { - PrepareBuilder(); - result.unpackedFloat_.Add(values); - return this; - } - public Builder ClearUnpackedFloat() { - PrepareBuilder(); - result.unpackedFloat_.Clear(); - return this; - } - - public pbc::IPopsicleList UnpackedDoubleList { - get { return PrepareBuilder().unpackedDouble_; } - } - public int UnpackedDoubleCount { - get { return result.UnpackedDoubleCount; } - } - public double GetUnpackedDouble(int index) { - return result.GetUnpackedDouble(index); - } - public Builder SetUnpackedDouble(int index, double value) { - PrepareBuilder(); - result.unpackedDouble_[index] = value; - return this; - } - public Builder AddUnpackedDouble(double value) { - PrepareBuilder(); - result.unpackedDouble_.Add(value); - return this; - } - public Builder AddRangeUnpackedDouble(scg::IEnumerable values) { - PrepareBuilder(); - result.unpackedDouble_.Add(values); - return this; - } - public Builder ClearUnpackedDouble() { - PrepareBuilder(); - result.unpackedDouble_.Clear(); - return this; - } - - public pbc::IPopsicleList UnpackedBoolList { - get { return PrepareBuilder().unpackedBool_; } - } - public int UnpackedBoolCount { - get { return result.UnpackedBoolCount; } - } - public bool GetUnpackedBool(int index) { - return result.GetUnpackedBool(index); - } - public Builder SetUnpackedBool(int index, bool value) { - PrepareBuilder(); - result.unpackedBool_[index] = value; - return this; - } - public Builder AddUnpackedBool(bool value) { - PrepareBuilder(); - result.unpackedBool_.Add(value); - return this; - } - public Builder AddRangeUnpackedBool(scg::IEnumerable values) { - PrepareBuilder(); - result.unpackedBool_.Add(values); - return this; - } - public Builder ClearUnpackedBool() { - PrepareBuilder(); - result.unpackedBool_.Clear(); - return this; - } - - public pbc::IPopsicleList UnpackedEnumList { - get { return PrepareBuilder().unpackedEnum_; } - } - public int UnpackedEnumCount { - get { return result.UnpackedEnumCount; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignEnum GetUnpackedEnum(int index) { - return result.GetUnpackedEnum(index); - } - public Builder SetUnpackedEnum(int index, global::Google.ProtocolBuffers.TestProtos.ForeignEnum value) { - PrepareBuilder(); - result.unpackedEnum_[index] = value; - return this; - } - public Builder AddUnpackedEnum(global::Google.ProtocolBuffers.TestProtos.ForeignEnum value) { - PrepareBuilder(); - result.unpackedEnum_.Add(value); - return this; - } - public Builder AddRangeUnpackedEnum(scg::IEnumerable values) { - PrepareBuilder(); - result.unpackedEnum_.Add(values); - return this; - } - public Builder ClearUnpackedEnum() { - PrepareBuilder(); - result.unpackedEnum_.Clear(); - return this; - } - } - static TestUnpackedTypes() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestPackedExtensions : pb::ExtendableMessage { - private TestPackedExtensions() { } - private static readonly TestPackedExtensions defaultInstance = new TestPackedExtensions().MakeReadOnly(); - private static readonly string[] _testPackedExtensionsFieldNames = new string[] { }; - private static readonly uint[] _testPackedExtensionsFieldTags = new uint[] { }; - public static TestPackedExtensions DefaultInstance { - get { return defaultInstance; } - } - - public override TestPackedExtensions DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestPackedExtensions ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestPackedExtensions__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestPackedExtensions__FieldAccessorTable; } - } - - public override bool IsInitialized { - get { - if (!ExtensionsAreInitialized) return false; - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testPackedExtensionsFieldNames; - pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); - extensionWriter.WriteUntil(536870912, output); - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - size += ExtensionsSerializedSize; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestPackedExtensions ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestPackedExtensions ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestPackedExtensions ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestPackedExtensions ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestPackedExtensions ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestPackedExtensions ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestPackedExtensions ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestPackedExtensions ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestPackedExtensions ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestPackedExtensions ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestPackedExtensions MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestPackedExtensions prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::ExtendableBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestPackedExtensions cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestPackedExtensions result; - - private TestPackedExtensions PrepareBuilder() { - if (resultIsReadOnly) { - TestPackedExtensions original = result; - result = new TestPackedExtensions(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestPackedExtensions MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestPackedExtensions.Descriptor; } - } - - public override TestPackedExtensions DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestPackedExtensions.DefaultInstance; } - } - - public override TestPackedExtensions BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestPackedExtensions) { - return MergeFrom((TestPackedExtensions) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestPackedExtensions other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestPackedExtensions.DefaultInstance) return this; - PrepareBuilder(); - this.MergeExtensionFields(other); - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testPackedExtensionsFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testPackedExtensionsFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - } - static TestPackedExtensions() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestUnpackedExtensions : pb::ExtendableMessage { - private TestUnpackedExtensions() { } - private static readonly TestUnpackedExtensions defaultInstance = new TestUnpackedExtensions().MakeReadOnly(); - private static readonly string[] _testUnpackedExtensionsFieldNames = new string[] { }; - private static readonly uint[] _testUnpackedExtensionsFieldTags = new uint[] { }; - public static TestUnpackedExtensions DefaultInstance { - get { return defaultInstance; } - } - - public override TestUnpackedExtensions DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestUnpackedExtensions ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestUnpackedExtensions__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestUnpackedExtensions__FieldAccessorTable; } - } - - public override bool IsInitialized { - get { - if (!ExtensionsAreInitialized) return false; - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testUnpackedExtensionsFieldNames; - pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); - extensionWriter.WriteUntil(536870912, output); - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - size += ExtensionsSerializedSize; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestUnpackedExtensions ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestUnpackedExtensions ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestUnpackedExtensions ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestUnpackedExtensions ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestUnpackedExtensions ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestUnpackedExtensions ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestUnpackedExtensions ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestUnpackedExtensions ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestUnpackedExtensions ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestUnpackedExtensions ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestUnpackedExtensions MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestUnpackedExtensions prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::ExtendableBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestUnpackedExtensions cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestUnpackedExtensions result; - - private TestUnpackedExtensions PrepareBuilder() { - if (resultIsReadOnly) { - TestUnpackedExtensions original = result; - result = new TestUnpackedExtensions(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestUnpackedExtensions MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestUnpackedExtensions.Descriptor; } - } - - public override TestUnpackedExtensions DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestUnpackedExtensions.DefaultInstance; } - } - - public override TestUnpackedExtensions BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestUnpackedExtensions) { - return MergeFrom((TestUnpackedExtensions) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestUnpackedExtensions other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestUnpackedExtensions.DefaultInstance) return this; - PrepareBuilder(); - this.MergeExtensionFields(other); - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testUnpackedExtensionsFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testUnpackedExtensionsFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - } - static TestUnpackedExtensions() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestDynamicExtensions : pb::GeneratedMessage { - private TestDynamicExtensions() { } - private static readonly TestDynamicExtensions defaultInstance = new TestDynamicExtensions().MakeReadOnly(); - private static readonly string[] _testDynamicExtensionsFieldNames = new string[] { "dynamic_enum_extension", "dynamic_message_extension", "enum_extension", "message_extension", "packed_extension", "repeated_extension", "scalar_extension" }; - private static readonly uint[] _testDynamicExtensionsFieldTags = new uint[] { 16016, 16034, 16008, 16026, 16050, 16042, 16005 }; - public static TestDynamicExtensions DefaultInstance { - get { return defaultInstance; } - } - - public override TestDynamicExtensions DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestDynamicExtensions ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestDynamicExtensions__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestDynamicExtensions__FieldAccessorTable; } - } - - #region Nested types - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class Types { - public enum DynamicEnumType { - DYNAMIC_FOO = 2200, - DYNAMIC_BAR = 2201, - DYNAMIC_BAZ = 2202, - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class DynamicMessageType : pb::GeneratedMessage { - private DynamicMessageType() { } - private static readonly DynamicMessageType defaultInstance = new DynamicMessageType().MakeReadOnly(); - private static readonly string[] _dynamicMessageTypeFieldNames = new string[] { "dynamic_field" }; - private static readonly uint[] _dynamicMessageTypeFieldTags = new uint[] { 16800 }; - public static DynamicMessageType DefaultInstance { - get { return defaultInstance; } - } - - public override DynamicMessageType DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override DynamicMessageType ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestDynamicExtensions_DynamicMessageType__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestDynamicExtensions_DynamicMessageType__FieldAccessorTable; } - } - - public const int DynamicFieldFieldNumber = 2100; - private bool hasDynamicField; - private int dynamicField_; - public bool HasDynamicField { - get { return hasDynamicField; } - } - public int DynamicField { - get { return dynamicField_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _dynamicMessageTypeFieldNames; - if (hasDynamicField) { - output.WriteInt32(2100, field_names[0], DynamicField); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasDynamicField) { - size += pb::CodedOutputStream.ComputeInt32Size(2100, DynamicField); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static DynamicMessageType ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static DynamicMessageType ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static DynamicMessageType ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static DynamicMessageType ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static DynamicMessageType ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static DynamicMessageType ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static DynamicMessageType ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static DynamicMessageType ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static DynamicMessageType ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static DynamicMessageType ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private DynamicMessageType MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(DynamicMessageType prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(DynamicMessageType cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private DynamicMessageType result; - - private DynamicMessageType PrepareBuilder() { - if (resultIsReadOnly) { - DynamicMessageType original = result; - result = new DynamicMessageType(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override DynamicMessageType MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.Types.DynamicMessageType.Descriptor; } - } - - public override DynamicMessageType DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.Types.DynamicMessageType.DefaultInstance; } - } - - public override DynamicMessageType BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is DynamicMessageType) { - return MergeFrom((DynamicMessageType) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(DynamicMessageType other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.Types.DynamicMessageType.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasDynamicField) { - DynamicField = other.DynamicField; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_dynamicMessageTypeFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _dynamicMessageTypeFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 16800: { - result.hasDynamicField = input.ReadInt32(ref result.dynamicField_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasDynamicField { - get { return result.hasDynamicField; } - } - public int DynamicField { - get { return result.DynamicField; } - set { SetDynamicField(value); } - } - public Builder SetDynamicField(int value) { - PrepareBuilder(); - result.hasDynamicField = true; - result.dynamicField_ = value; - return this; - } - public Builder ClearDynamicField() { - PrepareBuilder(); - result.hasDynamicField = false; - result.dynamicField_ = 0; - return this; - } - } - static DynamicMessageType() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - } - #endregion - - public const int ScalarExtensionFieldNumber = 2000; - private bool hasScalarExtension; - private uint scalarExtension_; - public bool HasScalarExtension { - get { return hasScalarExtension; } - } - [global::System.CLSCompliant(false)] - public uint ScalarExtension { - get { return scalarExtension_; } - } - - public const int EnumExtensionFieldNumber = 2001; - private bool hasEnumExtension; - private global::Google.ProtocolBuffers.TestProtos.ForeignEnum enumExtension_ = global::Google.ProtocolBuffers.TestProtos.ForeignEnum.FOREIGN_FOO; - public bool HasEnumExtension { - get { return hasEnumExtension; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignEnum EnumExtension { - get { return enumExtension_; } - } - - public const int DynamicEnumExtensionFieldNumber = 2002; - private bool hasDynamicEnumExtension; - private global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.Types.DynamicEnumType dynamicEnumExtension_ = global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.Types.DynamicEnumType.DYNAMIC_FOO; - public bool HasDynamicEnumExtension { - get { return hasDynamicEnumExtension; } - } - public global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.Types.DynamicEnumType DynamicEnumExtension { - get { return dynamicEnumExtension_; } - } - - public const int MessageExtensionFieldNumber = 2003; - private bool hasMessageExtension; - private global::Google.ProtocolBuffers.TestProtos.ForeignMessage messageExtension_; - public bool HasMessageExtension { - get { return hasMessageExtension; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignMessage MessageExtension { - get { return messageExtension_ ?? global::Google.ProtocolBuffers.TestProtos.ForeignMessage.DefaultInstance; } - } - - public const int DynamicMessageExtensionFieldNumber = 2004; - private bool hasDynamicMessageExtension; - private global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.Types.DynamicMessageType dynamicMessageExtension_; - public bool HasDynamicMessageExtension { - get { return hasDynamicMessageExtension; } - } - public global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.Types.DynamicMessageType DynamicMessageExtension { - get { return dynamicMessageExtension_ ?? global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.Types.DynamicMessageType.DefaultInstance; } - } - - public const int RepeatedExtensionFieldNumber = 2005; - private pbc::PopsicleList repeatedExtension_ = new pbc::PopsicleList(); - public scg::IList RepeatedExtensionList { - get { return pbc::Lists.AsReadOnly(repeatedExtension_); } - } - public int RepeatedExtensionCount { - get { return repeatedExtension_.Count; } - } - public string GetRepeatedExtension(int index) { - return repeatedExtension_[index]; - } - - public const int PackedExtensionFieldNumber = 2006; - private int packedExtensionMemoizedSerializedSize; - private pbc::PopsicleList packedExtension_ = new pbc::PopsicleList(); - public scg::IList PackedExtensionList { - get { return pbc::Lists.AsReadOnly(packedExtension_); } - } - public int PackedExtensionCount { - get { return packedExtension_.Count; } - } - public int GetPackedExtension(int index) { - return packedExtension_[index]; - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testDynamicExtensionsFieldNames; - if (hasScalarExtension) { - output.WriteFixed32(2000, field_names[6], ScalarExtension); - } - if (hasEnumExtension) { - output.WriteEnum(2001, field_names[2], (int) EnumExtension, EnumExtension); - } - if (hasDynamicEnumExtension) { - output.WriteEnum(2002, field_names[0], (int) DynamicEnumExtension, DynamicEnumExtension); - } - if (hasMessageExtension) { - output.WriteMessage(2003, field_names[3], MessageExtension); - } - if (hasDynamicMessageExtension) { - output.WriteMessage(2004, field_names[1], DynamicMessageExtension); - } - if (repeatedExtension_.Count > 0) { - output.WriteStringArray(2005, field_names[5], repeatedExtension_); - } - if (packedExtension_.Count > 0) { - output.WritePackedSInt32Array(2006, field_names[4], packedExtensionMemoizedSerializedSize, packedExtension_); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasScalarExtension) { - size += pb::CodedOutputStream.ComputeFixed32Size(2000, ScalarExtension); - } - if (hasEnumExtension) { - size += pb::CodedOutputStream.ComputeEnumSize(2001, (int) EnumExtension); - } - if (hasDynamicEnumExtension) { - size += pb::CodedOutputStream.ComputeEnumSize(2002, (int) DynamicEnumExtension); - } - if (hasMessageExtension) { - size += pb::CodedOutputStream.ComputeMessageSize(2003, MessageExtension); - } - if (hasDynamicMessageExtension) { - size += pb::CodedOutputStream.ComputeMessageSize(2004, DynamicMessageExtension); - } - { - int dataSize = 0; - foreach (string element in RepeatedExtensionList) { - dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedExtension_.Count; - } - { - int dataSize = 0; - foreach (int element in PackedExtensionList) { - dataSize += pb::CodedOutputStream.ComputeSInt32SizeNoTag(element); - } - size += dataSize; - if (packedExtension_.Count != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize); - } - packedExtensionMemoizedSerializedSize = dataSize; - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestDynamicExtensions ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestDynamicExtensions ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestDynamicExtensions ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestDynamicExtensions ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestDynamicExtensions ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestDynamicExtensions ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestDynamicExtensions ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestDynamicExtensions ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestDynamicExtensions ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestDynamicExtensions ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestDynamicExtensions MakeReadOnly() { - repeatedExtension_.MakeReadOnly(); - packedExtension_.MakeReadOnly(); - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestDynamicExtensions prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestDynamicExtensions cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestDynamicExtensions result; - - private TestDynamicExtensions PrepareBuilder() { - if (resultIsReadOnly) { - TestDynamicExtensions original = result; - result = new TestDynamicExtensions(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestDynamicExtensions MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.Descriptor; } - } - - public override TestDynamicExtensions DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.DefaultInstance; } - } - - public override TestDynamicExtensions BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestDynamicExtensions) { - return MergeFrom((TestDynamicExtensions) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestDynamicExtensions other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasScalarExtension) { - ScalarExtension = other.ScalarExtension; - } - if (other.HasEnumExtension) { - EnumExtension = other.EnumExtension; - } - if (other.HasDynamicEnumExtension) { - DynamicEnumExtension = other.DynamicEnumExtension; - } - if (other.HasMessageExtension) { - MergeMessageExtension(other.MessageExtension); - } - if (other.HasDynamicMessageExtension) { - MergeDynamicMessageExtension(other.DynamicMessageExtension); - } - if (other.repeatedExtension_.Count != 0) { - result.repeatedExtension_.Add(other.repeatedExtension_); - } - if (other.packedExtension_.Count != 0) { - result.packedExtension_.Add(other.packedExtension_); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testDynamicExtensionsFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testDynamicExtensionsFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 16005: { - result.hasScalarExtension = input.ReadFixed32(ref result.scalarExtension_); - break; - } - case 16008: { - object unknown; - if(input.ReadEnum(ref result.enumExtension_, out unknown)) { - result.hasEnumExtension = true; - } else if(unknown is int) { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - unknownFields.MergeVarintField(2001, (ulong)(int)unknown); - } - break; - } - case 16016: { - object unknown; - if(input.ReadEnum(ref result.dynamicEnumExtension_, out unknown)) { - result.hasDynamicEnumExtension = true; - } else if(unknown is int) { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - unknownFields.MergeVarintField(2002, (ulong)(int)unknown); - } - break; - } - case 16026: { - global::Google.ProtocolBuffers.TestProtos.ForeignMessage.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.ForeignMessage.CreateBuilder(); - if (result.hasMessageExtension) { - subBuilder.MergeFrom(MessageExtension); - } - input.ReadMessage(subBuilder, extensionRegistry); - MessageExtension = subBuilder.BuildPartial(); - break; - } - case 16034: { - global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.Types.DynamicMessageType.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.Types.DynamicMessageType.CreateBuilder(); - if (result.hasDynamicMessageExtension) { - subBuilder.MergeFrom(DynamicMessageExtension); - } - input.ReadMessage(subBuilder, extensionRegistry); - DynamicMessageExtension = subBuilder.BuildPartial(); - break; - } - case 16042: { - input.ReadStringArray(tag, field_name, result.repeatedExtension_); - break; - } - case 16050: - case 16048: { - input.ReadSInt32Array(tag, field_name, result.packedExtension_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasScalarExtension { - get { return result.hasScalarExtension; } - } - [global::System.CLSCompliant(false)] - public uint ScalarExtension { - get { return result.ScalarExtension; } - set { SetScalarExtension(value); } - } - [global::System.CLSCompliant(false)] - public Builder SetScalarExtension(uint value) { - PrepareBuilder(); - result.hasScalarExtension = true; - result.scalarExtension_ = value; - return this; - } - public Builder ClearScalarExtension() { - PrepareBuilder(); - result.hasScalarExtension = false; - result.scalarExtension_ = 0; - return this; - } - - public bool HasEnumExtension { - get { return result.hasEnumExtension; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignEnum EnumExtension { - get { return result.EnumExtension; } - set { SetEnumExtension(value); } - } - public Builder SetEnumExtension(global::Google.ProtocolBuffers.TestProtos.ForeignEnum value) { - PrepareBuilder(); - result.hasEnumExtension = true; - result.enumExtension_ = value; - return this; - } - public Builder ClearEnumExtension() { - PrepareBuilder(); - result.hasEnumExtension = false; - result.enumExtension_ = global::Google.ProtocolBuffers.TestProtos.ForeignEnum.FOREIGN_FOO; - return this; - } - - public bool HasDynamicEnumExtension { - get { return result.hasDynamicEnumExtension; } - } - public global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.Types.DynamicEnumType DynamicEnumExtension { - get { return result.DynamicEnumExtension; } - set { SetDynamicEnumExtension(value); } - } - public Builder SetDynamicEnumExtension(global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.Types.DynamicEnumType value) { - PrepareBuilder(); - result.hasDynamicEnumExtension = true; - result.dynamicEnumExtension_ = value; - return this; - } - public Builder ClearDynamicEnumExtension() { - PrepareBuilder(); - result.hasDynamicEnumExtension = false; - result.dynamicEnumExtension_ = global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.Types.DynamicEnumType.DYNAMIC_FOO; - return this; - } - - public bool HasMessageExtension { - get { return result.hasMessageExtension; } - } - public global::Google.ProtocolBuffers.TestProtos.ForeignMessage MessageExtension { - get { return result.MessageExtension; } - set { SetMessageExtension(value); } - } - public Builder SetMessageExtension(global::Google.ProtocolBuffers.TestProtos.ForeignMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasMessageExtension = true; - result.messageExtension_ = value; - return this; - } - public Builder SetMessageExtension(global::Google.ProtocolBuffers.TestProtos.ForeignMessage.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasMessageExtension = true; - result.messageExtension_ = builderForValue.Build(); - return this; - } - public Builder MergeMessageExtension(global::Google.ProtocolBuffers.TestProtos.ForeignMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasMessageExtension && - result.messageExtension_ != global::Google.ProtocolBuffers.TestProtos.ForeignMessage.DefaultInstance) { - result.messageExtension_ = global::Google.ProtocolBuffers.TestProtos.ForeignMessage.CreateBuilder(result.messageExtension_).MergeFrom(value).BuildPartial(); - } else { - result.messageExtension_ = value; - } - result.hasMessageExtension = true; - return this; - } - public Builder ClearMessageExtension() { - PrepareBuilder(); - result.hasMessageExtension = false; - result.messageExtension_ = null; - return this; - } - - public bool HasDynamicMessageExtension { - get { return result.hasDynamicMessageExtension; } - } - public global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.Types.DynamicMessageType DynamicMessageExtension { - get { return result.DynamicMessageExtension; } - set { SetDynamicMessageExtension(value); } - } - public Builder SetDynamicMessageExtension(global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.Types.DynamicMessageType value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasDynamicMessageExtension = true; - result.dynamicMessageExtension_ = value; - return this; - } - public Builder SetDynamicMessageExtension(global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.Types.DynamicMessageType.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasDynamicMessageExtension = true; - result.dynamicMessageExtension_ = builderForValue.Build(); - return this; - } - public Builder MergeDynamicMessageExtension(global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.Types.DynamicMessageType value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasDynamicMessageExtension && - result.dynamicMessageExtension_ != global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.Types.DynamicMessageType.DefaultInstance) { - result.dynamicMessageExtension_ = global::Google.ProtocolBuffers.TestProtos.TestDynamicExtensions.Types.DynamicMessageType.CreateBuilder(result.dynamicMessageExtension_).MergeFrom(value).BuildPartial(); - } else { - result.dynamicMessageExtension_ = value; - } - result.hasDynamicMessageExtension = true; - return this; - } - public Builder ClearDynamicMessageExtension() { - PrepareBuilder(); - result.hasDynamicMessageExtension = false; - result.dynamicMessageExtension_ = null; - return this; - } - - public pbc::IPopsicleList RepeatedExtensionList { - get { return PrepareBuilder().repeatedExtension_; } - } - public int RepeatedExtensionCount { - get { return result.RepeatedExtensionCount; } - } - public string GetRepeatedExtension(int index) { - return result.GetRepeatedExtension(index); - } - public Builder SetRepeatedExtension(int index, string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedExtension_[index] = value; - return this; - } - public Builder AddRepeatedExtension(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedExtension_.Add(value); - return this; - } - public Builder AddRangeRepeatedExtension(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedExtension_.Add(values); - return this; - } - public Builder ClearRepeatedExtension() { - PrepareBuilder(); - result.repeatedExtension_.Clear(); - return this; - } - - public pbc::IPopsicleList PackedExtensionList { - get { return PrepareBuilder().packedExtension_; } - } - public int PackedExtensionCount { - get { return result.PackedExtensionCount; } - } - public int GetPackedExtension(int index) { - return result.GetPackedExtension(index); - } - public Builder SetPackedExtension(int index, int value) { - PrepareBuilder(); - result.packedExtension_[index] = value; - return this; - } - public Builder AddPackedExtension(int value) { - PrepareBuilder(); - result.packedExtension_.Add(value); - return this; - } - public Builder AddRangePackedExtension(scg::IEnumerable values) { - PrepareBuilder(); - result.packedExtension_.Add(values); - return this; - } - public Builder ClearPackedExtension() { - PrepareBuilder(); - result.packedExtension_.Clear(); - return this; - } - } - static TestDynamicExtensions() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestRepeatedScalarDifferentTagSizes : pb::GeneratedMessage { - private TestRepeatedScalarDifferentTagSizes() { } - private static readonly TestRepeatedScalarDifferentTagSizes defaultInstance = new TestRepeatedScalarDifferentTagSizes().MakeReadOnly(); - private static readonly string[] _testRepeatedScalarDifferentTagSizesFieldNames = new string[] { "repeated_fixed32", "repeated_fixed64", "repeated_float", "repeated_int32", "repeated_int64", "repeated_uint64" }; - private static readonly uint[] _testRepeatedScalarDifferentTagSizesFieldTags = new uint[] { 101, 16369, 2097141, 104, 16376, 2097144 }; - public static TestRepeatedScalarDifferentTagSizes DefaultInstance { - get { return defaultInstance; } - } - - public override TestRepeatedScalarDifferentTagSizes DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestRepeatedScalarDifferentTagSizes ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestRepeatedScalarDifferentTagSizes__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestRepeatedScalarDifferentTagSizes__FieldAccessorTable; } - } - - public const int RepeatedFixed32FieldNumber = 12; - private pbc::PopsicleList repeatedFixed32_ = new pbc::PopsicleList(); - [global::System.CLSCompliant(false)] - public scg::IList RepeatedFixed32List { - get { return pbc::Lists.AsReadOnly(repeatedFixed32_); } - } - public int RepeatedFixed32Count { - get { return repeatedFixed32_.Count; } - } - [global::System.CLSCompliant(false)] - public uint GetRepeatedFixed32(int index) { - return repeatedFixed32_[index]; - } - - public const int RepeatedInt32FieldNumber = 13; - private pbc::PopsicleList repeatedInt32_ = new pbc::PopsicleList(); - public scg::IList RepeatedInt32List { - get { return pbc::Lists.AsReadOnly(repeatedInt32_); } - } - public int RepeatedInt32Count { - get { return repeatedInt32_.Count; } - } - public int GetRepeatedInt32(int index) { - return repeatedInt32_[index]; - } - - public const int RepeatedFixed64FieldNumber = 2046; - private pbc::PopsicleList repeatedFixed64_ = new pbc::PopsicleList(); - [global::System.CLSCompliant(false)] - public scg::IList RepeatedFixed64List { - get { return pbc::Lists.AsReadOnly(repeatedFixed64_); } - } - public int RepeatedFixed64Count { - get { return repeatedFixed64_.Count; } - } - [global::System.CLSCompliant(false)] - public ulong GetRepeatedFixed64(int index) { - return repeatedFixed64_[index]; - } - - public const int RepeatedInt64FieldNumber = 2047; - private pbc::PopsicleList repeatedInt64_ = new pbc::PopsicleList(); - public scg::IList RepeatedInt64List { - get { return pbc::Lists.AsReadOnly(repeatedInt64_); } - } - public int RepeatedInt64Count { - get { return repeatedInt64_.Count; } - } - public long GetRepeatedInt64(int index) { - return repeatedInt64_[index]; - } - - public const int RepeatedFloatFieldNumber = 262142; - private pbc::PopsicleList repeatedFloat_ = new pbc::PopsicleList(); - public scg::IList RepeatedFloatList { - get { return pbc::Lists.AsReadOnly(repeatedFloat_); } - } - public int RepeatedFloatCount { - get { return repeatedFloat_.Count; } - } - public float GetRepeatedFloat(int index) { - return repeatedFloat_[index]; - } - - public const int RepeatedUint64FieldNumber = 262143; - private pbc::PopsicleList repeatedUint64_ = new pbc::PopsicleList(); - [global::System.CLSCompliant(false)] - public scg::IList RepeatedUint64List { - get { return pbc::Lists.AsReadOnly(repeatedUint64_); } - } - public int RepeatedUint64Count { - get { return repeatedUint64_.Count; } - } - [global::System.CLSCompliant(false)] - public ulong GetRepeatedUint64(int index) { - return repeatedUint64_[index]; - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testRepeatedScalarDifferentTagSizesFieldNames; - if (repeatedFixed32_.Count > 0) { - output.WriteFixed32Array(12, field_names[0], repeatedFixed32_); - } - if (repeatedInt32_.Count > 0) { - output.WriteInt32Array(13, field_names[3], repeatedInt32_); - } - if (repeatedFixed64_.Count > 0) { - output.WriteFixed64Array(2046, field_names[1], repeatedFixed64_); - } - if (repeatedInt64_.Count > 0) { - output.WriteInt64Array(2047, field_names[4], repeatedInt64_); - } - if (repeatedFloat_.Count > 0) { - output.WriteFloatArray(262142, field_names[2], repeatedFloat_); - } - if (repeatedUint64_.Count > 0) { - output.WriteUInt64Array(262143, field_names[5], repeatedUint64_); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - { - int dataSize = 0; - dataSize = 4 * repeatedFixed32_.Count; - size += dataSize; - size += 1 * repeatedFixed32_.Count; - } - { - int dataSize = 0; - foreach (int element in RepeatedInt32List) { - dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element); - } - size += dataSize; - size += 1 * repeatedInt32_.Count; - } - { - int dataSize = 0; - dataSize = 8 * repeatedFixed64_.Count; - size += dataSize; - size += 2 * repeatedFixed64_.Count; - } - { - int dataSize = 0; - foreach (long element in RepeatedInt64List) { - dataSize += pb::CodedOutputStream.ComputeInt64SizeNoTag(element); - } - size += dataSize; - size += 2 * repeatedInt64_.Count; - } - { - int dataSize = 0; - dataSize = 4 * repeatedFloat_.Count; - size += dataSize; - size += 3 * repeatedFloat_.Count; - } - { - int dataSize = 0; - foreach (ulong element in RepeatedUint64List) { - dataSize += pb::CodedOutputStream.ComputeUInt64SizeNoTag(element); - } - size += dataSize; - size += 3 * repeatedUint64_.Count; - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestRepeatedScalarDifferentTagSizes ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestRepeatedScalarDifferentTagSizes ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestRepeatedScalarDifferentTagSizes ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestRepeatedScalarDifferentTagSizes ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestRepeatedScalarDifferentTagSizes ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestRepeatedScalarDifferentTagSizes ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestRepeatedScalarDifferentTagSizes ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestRepeatedScalarDifferentTagSizes ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestRepeatedScalarDifferentTagSizes ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestRepeatedScalarDifferentTagSizes ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestRepeatedScalarDifferentTagSizes MakeReadOnly() { - repeatedFixed32_.MakeReadOnly(); - repeatedInt32_.MakeReadOnly(); - repeatedFixed64_.MakeReadOnly(); - repeatedInt64_.MakeReadOnly(); - repeatedFloat_.MakeReadOnly(); - repeatedUint64_.MakeReadOnly(); - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestRepeatedScalarDifferentTagSizes prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestRepeatedScalarDifferentTagSizes cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestRepeatedScalarDifferentTagSizes result; - - private TestRepeatedScalarDifferentTagSizes PrepareBuilder() { - if (resultIsReadOnly) { - TestRepeatedScalarDifferentTagSizes original = result; - result = new TestRepeatedScalarDifferentTagSizes(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestRepeatedScalarDifferentTagSizes MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestRepeatedScalarDifferentTagSizes.Descriptor; } - } - - public override TestRepeatedScalarDifferentTagSizes DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestRepeatedScalarDifferentTagSizes.DefaultInstance; } - } - - public override TestRepeatedScalarDifferentTagSizes BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestRepeatedScalarDifferentTagSizes) { - return MergeFrom((TestRepeatedScalarDifferentTagSizes) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestRepeatedScalarDifferentTagSizes other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestRepeatedScalarDifferentTagSizes.DefaultInstance) return this; - PrepareBuilder(); - if (other.repeatedFixed32_.Count != 0) { - result.repeatedFixed32_.Add(other.repeatedFixed32_); - } - if (other.repeatedInt32_.Count != 0) { - result.repeatedInt32_.Add(other.repeatedInt32_); - } - if (other.repeatedFixed64_.Count != 0) { - result.repeatedFixed64_.Add(other.repeatedFixed64_); - } - if (other.repeatedInt64_.Count != 0) { - result.repeatedInt64_.Add(other.repeatedInt64_); - } - if (other.repeatedFloat_.Count != 0) { - result.repeatedFloat_.Add(other.repeatedFloat_); - } - if (other.repeatedUint64_.Count != 0) { - result.repeatedUint64_.Add(other.repeatedUint64_); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testRepeatedScalarDifferentTagSizesFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testRepeatedScalarDifferentTagSizesFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 98: - case 101: { - input.ReadFixed32Array(tag, field_name, result.repeatedFixed32_); - break; - } - case 106: - case 104: { - input.ReadInt32Array(tag, field_name, result.repeatedInt32_); - break; - } - case 16370: - case 16369: { - input.ReadFixed64Array(tag, field_name, result.repeatedFixed64_); - break; - } - case 16378: - case 16376: { - input.ReadInt64Array(tag, field_name, result.repeatedInt64_); - break; - } - case 2097138: - case 2097141: { - input.ReadFloatArray(tag, field_name, result.repeatedFloat_); - break; - } - case 2097146: - case 2097144: { - input.ReadUInt64Array(tag, field_name, result.repeatedUint64_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - [global::System.CLSCompliant(false)] - public pbc::IPopsicleList RepeatedFixed32List { - get { return PrepareBuilder().repeatedFixed32_; } - } - public int RepeatedFixed32Count { - get { return result.RepeatedFixed32Count; } - } - [global::System.CLSCompliant(false)] - public uint GetRepeatedFixed32(int index) { - return result.GetRepeatedFixed32(index); - } - [global::System.CLSCompliant(false)] - public Builder SetRepeatedFixed32(int index, uint value) { - PrepareBuilder(); - result.repeatedFixed32_[index] = value; - return this; - } - [global::System.CLSCompliant(false)] - public Builder AddRepeatedFixed32(uint value) { - PrepareBuilder(); - result.repeatedFixed32_.Add(value); - return this; - } - [global::System.CLSCompliant(false)] - public Builder AddRangeRepeatedFixed32(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedFixed32_.Add(values); - return this; - } - public Builder ClearRepeatedFixed32() { - PrepareBuilder(); - result.repeatedFixed32_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedInt32List { - get { return PrepareBuilder().repeatedInt32_; } - } - public int RepeatedInt32Count { - get { return result.RepeatedInt32Count; } - } - public int GetRepeatedInt32(int index) { - return result.GetRepeatedInt32(index); - } - public Builder SetRepeatedInt32(int index, int value) { - PrepareBuilder(); - result.repeatedInt32_[index] = value; - return this; - } - public Builder AddRepeatedInt32(int value) { - PrepareBuilder(); - result.repeatedInt32_.Add(value); - return this; - } - public Builder AddRangeRepeatedInt32(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedInt32_.Add(values); - return this; - } - public Builder ClearRepeatedInt32() { - PrepareBuilder(); - result.repeatedInt32_.Clear(); - return this; - } - - [global::System.CLSCompliant(false)] - public pbc::IPopsicleList RepeatedFixed64List { - get { return PrepareBuilder().repeatedFixed64_; } - } - public int RepeatedFixed64Count { - get { return result.RepeatedFixed64Count; } - } - [global::System.CLSCompliant(false)] - public ulong GetRepeatedFixed64(int index) { - return result.GetRepeatedFixed64(index); - } - [global::System.CLSCompliant(false)] - public Builder SetRepeatedFixed64(int index, ulong value) { - PrepareBuilder(); - result.repeatedFixed64_[index] = value; - return this; - } - [global::System.CLSCompliant(false)] - public Builder AddRepeatedFixed64(ulong value) { - PrepareBuilder(); - result.repeatedFixed64_.Add(value); - return this; - } - [global::System.CLSCompliant(false)] - public Builder AddRangeRepeatedFixed64(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedFixed64_.Add(values); - return this; - } - public Builder ClearRepeatedFixed64() { - PrepareBuilder(); - result.repeatedFixed64_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedInt64List { - get { return PrepareBuilder().repeatedInt64_; } - } - public int RepeatedInt64Count { - get { return result.RepeatedInt64Count; } - } - public long GetRepeatedInt64(int index) { - return result.GetRepeatedInt64(index); - } - public Builder SetRepeatedInt64(int index, long value) { - PrepareBuilder(); - result.repeatedInt64_[index] = value; - return this; - } - public Builder AddRepeatedInt64(long value) { - PrepareBuilder(); - result.repeatedInt64_.Add(value); - return this; - } - public Builder AddRangeRepeatedInt64(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedInt64_.Add(values); - return this; - } - public Builder ClearRepeatedInt64() { - PrepareBuilder(); - result.repeatedInt64_.Clear(); - return this; - } - - public pbc::IPopsicleList RepeatedFloatList { - get { return PrepareBuilder().repeatedFloat_; } - } - public int RepeatedFloatCount { - get { return result.RepeatedFloatCount; } - } - public float GetRepeatedFloat(int index) { - return result.GetRepeatedFloat(index); - } - public Builder SetRepeatedFloat(int index, float value) { - PrepareBuilder(); - result.repeatedFloat_[index] = value; - return this; - } - public Builder AddRepeatedFloat(float value) { - PrepareBuilder(); - result.repeatedFloat_.Add(value); - return this; - } - public Builder AddRangeRepeatedFloat(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedFloat_.Add(values); - return this; - } - public Builder ClearRepeatedFloat() { - PrepareBuilder(); - result.repeatedFloat_.Clear(); - return this; - } - - [global::System.CLSCompliant(false)] - public pbc::IPopsicleList RepeatedUint64List { - get { return PrepareBuilder().repeatedUint64_; } - } - public int RepeatedUint64Count { - get { return result.RepeatedUint64Count; } - } - [global::System.CLSCompliant(false)] - public ulong GetRepeatedUint64(int index) { - return result.GetRepeatedUint64(index); - } - [global::System.CLSCompliant(false)] - public Builder SetRepeatedUint64(int index, ulong value) { - PrepareBuilder(); - result.repeatedUint64_[index] = value; - return this; - } - [global::System.CLSCompliant(false)] - public Builder AddRepeatedUint64(ulong value) { - PrepareBuilder(); - result.repeatedUint64_.Add(value); - return this; - } - [global::System.CLSCompliant(false)] - public Builder AddRangeRepeatedUint64(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedUint64_.Add(values); - return this; - } - public Builder ClearRepeatedUint64() { - PrepareBuilder(); - result.repeatedUint64_.Clear(); - return this; - } - } - static TestRepeatedScalarDifferentTagSizes() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestParsingMerge : pb::ExtendableMessage { - private TestParsingMerge() { } - private static readonly TestParsingMerge defaultInstance = new TestParsingMerge().MakeReadOnly(); - private static readonly string[] _testParsingMergeFieldNames = new string[] { "optional_all_types", "optionalgroup", "repeated_all_types", "repeatedgroup", "required_all_types" }; - private static readonly uint[] _testParsingMergeFieldTags = new uint[] { 18, 83, 26, 163, 10 }; - public static TestParsingMerge DefaultInstance { - get { return defaultInstance; } - } - - public override TestParsingMerge DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestParsingMerge ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestParsingMerge__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestParsingMerge__FieldAccessorTable; } - } - - public const int OptionalExtFieldNumber = 1000; - public static pb::GeneratedExtensionBase OptionalExt; - public const int RepeatedExtFieldNumber = 1001; - public static pb::GeneratedExtensionBase> RepeatedExt; - #region Nested types - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class Types { - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class RepeatedFieldsGenerator : pb::GeneratedMessage { - private RepeatedFieldsGenerator() { } - private static readonly RepeatedFieldsGenerator defaultInstance = new RepeatedFieldsGenerator().MakeReadOnly(); - private static readonly string[] _repeatedFieldsGeneratorFieldNames = new string[] { "ext1", "ext2", "field1", "field2", "field3", "group1", "group2" }; - private static readonly uint[] _repeatedFieldsGeneratorFieldTags = new uint[] { 8002, 8010, 10, 18, 26, 83, 163 }; - public static RepeatedFieldsGenerator DefaultInstance { - get { return defaultInstance; } - } - - public override RepeatedFieldsGenerator DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override RepeatedFieldsGenerator ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestParsingMerge_RepeatedFieldsGenerator__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestParsingMerge_RepeatedFieldsGenerator__FieldAccessorTable; } - } - - #region Nested types - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class Types { - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Group1 : pb::GeneratedMessage { - private Group1() { } - private static readonly Group1 defaultInstance = new Group1().MakeReadOnly(); - private static readonly string[] _group1FieldNames = new string[] { "field1" }; - private static readonly uint[] _group1FieldTags = new uint[] { 90 }; - public static Group1 DefaultInstance { - get { return defaultInstance; } - } - - public override Group1 DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override Group1 ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestParsingMerge_RepeatedFieldsGenerator_Group1__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestParsingMerge_RepeatedFieldsGenerator_Group1__FieldAccessorTable; } - } - - public const int Field1FieldNumber = 11; - private bool hasField1; - private global::Google.ProtocolBuffers.TestProtos.TestAllTypes field1_; - public bool HasField1 { - get { return hasField1; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes Field1 { - get { return field1_ ?? global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _group1FieldNames; - if (hasField1) { - output.WriteMessage(11, field_names[0], Field1); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasField1) { - size += pb::CodedOutputStream.ComputeMessageSize(11, Field1); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static Group1 ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static Group1 ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static Group1 ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static Group1 ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static Group1 ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static Group1 ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static Group1 ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static Group1 ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static Group1 ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static Group1 ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private Group1 MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(Group1 prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(Group1 cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private Group1 result; - - private Group1 PrepareBuilder() { - if (resultIsReadOnly) { - Group1 original = result; - result = new Group1(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override Group1 MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedFieldsGenerator.Types.Group1.Descriptor; } - } - - public override Group1 DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedFieldsGenerator.Types.Group1.DefaultInstance; } - } - - public override Group1 BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is Group1) { - return MergeFrom((Group1) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(Group1 other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedFieldsGenerator.Types.Group1.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasField1) { - MergeField1(other.Field1); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_group1FieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _group1FieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 90: { - global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.CreateBuilder(); - if (result.hasField1) { - subBuilder.MergeFrom(Field1); - } - input.ReadMessage(subBuilder, extensionRegistry); - Field1 = subBuilder.BuildPartial(); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasField1 { - get { return result.hasField1; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes Field1 { - get { return result.Field1; } - set { SetField1(value); } - } - public Builder SetField1(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasField1 = true; - result.field1_ = value; - return this; - } - public Builder SetField1(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasField1 = true; - result.field1_ = builderForValue.Build(); - return this; - } - public Builder MergeField1(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasField1 && - result.field1_ != global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance) { - result.field1_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.CreateBuilder(result.field1_).MergeFrom(value).BuildPartial(); - } else { - result.field1_ = value; - } - result.hasField1 = true; - return this; - } - public Builder ClearField1() { - PrepareBuilder(); - result.hasField1 = false; - result.field1_ = null; - return this; - } - } - static Group1() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Group2 : pb::GeneratedMessage { - private Group2() { } - private static readonly Group2 defaultInstance = new Group2().MakeReadOnly(); - private static readonly string[] _group2FieldNames = new string[] { "field1" }; - private static readonly uint[] _group2FieldTags = new uint[] { 170 }; - public static Group2 DefaultInstance { - get { return defaultInstance; } - } - - public override Group2 DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override Group2 ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestParsingMerge_RepeatedFieldsGenerator_Group2__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestParsingMerge_RepeatedFieldsGenerator_Group2__FieldAccessorTable; } - } - - public const int Field1FieldNumber = 21; - private bool hasField1; - private global::Google.ProtocolBuffers.TestProtos.TestAllTypes field1_; - public bool HasField1 { - get { return hasField1; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes Field1 { - get { return field1_ ?? global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _group2FieldNames; - if (hasField1) { - output.WriteMessage(21, field_names[0], Field1); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasField1) { - size += pb::CodedOutputStream.ComputeMessageSize(21, Field1); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static Group2 ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static Group2 ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static Group2 ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static Group2 ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static Group2 ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static Group2 ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static Group2 ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static Group2 ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static Group2 ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static Group2 ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private Group2 MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(Group2 prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(Group2 cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private Group2 result; - - private Group2 PrepareBuilder() { - if (resultIsReadOnly) { - Group2 original = result; - result = new Group2(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override Group2 MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedFieldsGenerator.Types.Group2.Descriptor; } - } - - public override Group2 DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedFieldsGenerator.Types.Group2.DefaultInstance; } - } - - public override Group2 BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is Group2) { - return MergeFrom((Group2) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(Group2 other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedFieldsGenerator.Types.Group2.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasField1) { - MergeField1(other.Field1); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_group2FieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _group2FieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 170: { - global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.CreateBuilder(); - if (result.hasField1) { - subBuilder.MergeFrom(Field1); - } - input.ReadMessage(subBuilder, extensionRegistry); - Field1 = subBuilder.BuildPartial(); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasField1 { - get { return result.hasField1; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes Field1 { - get { return result.Field1; } - set { SetField1(value); } - } - public Builder SetField1(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasField1 = true; - result.field1_ = value; - return this; - } - public Builder SetField1(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasField1 = true; - result.field1_ = builderForValue.Build(); - return this; - } - public Builder MergeField1(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasField1 && - result.field1_ != global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance) { - result.field1_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.CreateBuilder(result.field1_).MergeFrom(value).BuildPartial(); - } else { - result.field1_ = value; - } - result.hasField1 = true; - return this; - } - public Builder ClearField1() { - PrepareBuilder(); - result.hasField1 = false; - result.field1_ = null; - return this; - } - } - static Group2() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - } - #endregion - - public const int Field1FieldNumber = 1; - private pbc::PopsicleList field1_ = new pbc::PopsicleList(); - public scg::IList Field1List { - get { return field1_; } - } - public int Field1Count { - get { return field1_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes GetField1(int index) { - return field1_[index]; - } - - public const int Field2FieldNumber = 2; - private pbc::PopsicleList field2_ = new pbc::PopsicleList(); - public scg::IList Field2List { - get { return field2_; } - } - public int Field2Count { - get { return field2_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes GetField2(int index) { - return field2_[index]; - } - - public const int Field3FieldNumber = 3; - private pbc::PopsicleList field3_ = new pbc::PopsicleList(); - public scg::IList Field3List { - get { return field3_; } - } - public int Field3Count { - get { return field3_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes GetField3(int index) { - return field3_[index]; - } - - public const int Group1FieldNumber = 10; - private pbc::PopsicleList group1_ = new pbc::PopsicleList(); - public scg::IList Group1List { - get { return group1_; } - } - public int Group1Count { - get { return group1_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedFieldsGenerator.Types.Group1 GetGroup1(int index) { - return group1_[index]; - } - - public const int Group2FieldNumber = 20; - private pbc::PopsicleList group2_ = new pbc::PopsicleList(); - public scg::IList Group2List { - get { return group2_; } - } - public int Group2Count { - get { return group2_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedFieldsGenerator.Types.Group2 GetGroup2(int index) { - return group2_[index]; - } - - public const int Ext1FieldNumber = 1000; - private pbc::PopsicleList ext1_ = new pbc::PopsicleList(); - public scg::IList Ext1List { - get { return ext1_; } - } - public int Ext1Count { - get { return ext1_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes GetExt1(int index) { - return ext1_[index]; - } - - public const int Ext2FieldNumber = 1001; - private pbc::PopsicleList ext2_ = new pbc::PopsicleList(); - public scg::IList Ext2List { - get { return ext2_; } - } - public int Ext2Count { - get { return ext2_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes GetExt2(int index) { - return ext2_[index]; - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _repeatedFieldsGeneratorFieldNames; - if (field1_.Count > 0) { - output.WriteMessageArray(1, field_names[2], field1_); - } - if (field2_.Count > 0) { - output.WriteMessageArray(2, field_names[3], field2_); - } - if (field3_.Count > 0) { - output.WriteMessageArray(3, field_names[4], field3_); - } - if (group1_.Count > 0) { - output.WriteGroupArray(10, field_names[5], group1_); - } - if (group2_.Count > 0) { - output.WriteGroupArray(20, field_names[6], group2_); - } - if (ext1_.Count > 0) { - output.WriteMessageArray(1000, field_names[0], ext1_); - } - if (ext2_.Count > 0) { - output.WriteMessageArray(1001, field_names[1], ext2_); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypes element in Field1List) { - size += pb::CodedOutputStream.ComputeMessageSize(1, element); - } - foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypes element in Field2List) { - size += pb::CodedOutputStream.ComputeMessageSize(2, element); - } - foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypes element in Field3List) { - size += pb::CodedOutputStream.ComputeMessageSize(3, element); - } - foreach (global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedFieldsGenerator.Types.Group1 element in Group1List) { - size += pb::CodedOutputStream.ComputeGroupSize(10, element); - } - foreach (global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedFieldsGenerator.Types.Group2 element in Group2List) { - size += pb::CodedOutputStream.ComputeGroupSize(20, element); - } - foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypes element in Ext1List) { - size += pb::CodedOutputStream.ComputeMessageSize(1000, element); - } - foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypes element in Ext2List) { - size += pb::CodedOutputStream.ComputeMessageSize(1001, element); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static RepeatedFieldsGenerator ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static RepeatedFieldsGenerator ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static RepeatedFieldsGenerator ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static RepeatedFieldsGenerator ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static RepeatedFieldsGenerator ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static RepeatedFieldsGenerator ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static RepeatedFieldsGenerator ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static RepeatedFieldsGenerator ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static RepeatedFieldsGenerator ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static RepeatedFieldsGenerator ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private RepeatedFieldsGenerator MakeReadOnly() { - field1_.MakeReadOnly(); - field2_.MakeReadOnly(); - field3_.MakeReadOnly(); - group1_.MakeReadOnly(); - group2_.MakeReadOnly(); - ext1_.MakeReadOnly(); - ext2_.MakeReadOnly(); - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(RepeatedFieldsGenerator prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(RepeatedFieldsGenerator cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private RepeatedFieldsGenerator result; - - private RepeatedFieldsGenerator PrepareBuilder() { - if (resultIsReadOnly) { - RepeatedFieldsGenerator original = result; - result = new RepeatedFieldsGenerator(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override RepeatedFieldsGenerator MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedFieldsGenerator.Descriptor; } - } - - public override RepeatedFieldsGenerator DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedFieldsGenerator.DefaultInstance; } - } - - public override RepeatedFieldsGenerator BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is RepeatedFieldsGenerator) { - return MergeFrom((RepeatedFieldsGenerator) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(RepeatedFieldsGenerator other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedFieldsGenerator.DefaultInstance) return this; - PrepareBuilder(); - if (other.field1_.Count != 0) { - result.field1_.Add(other.field1_); - } - if (other.field2_.Count != 0) { - result.field2_.Add(other.field2_); - } - if (other.field3_.Count != 0) { - result.field3_.Add(other.field3_); - } - if (other.group1_.Count != 0) { - result.group1_.Add(other.group1_); - } - if (other.group2_.Count != 0) { - result.group2_.Add(other.group2_); - } - if (other.ext1_.Count != 0) { - result.ext1_.Add(other.ext1_); - } - if (other.ext2_.Count != 0) { - result.ext2_.Add(other.ext2_); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_repeatedFieldsGeneratorFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _repeatedFieldsGeneratorFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 10: { - input.ReadMessageArray(tag, field_name, result.field1_, global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance, extensionRegistry); - break; - } - case 18: { - input.ReadMessageArray(tag, field_name, result.field2_, global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance, extensionRegistry); - break; - } - case 26: { - input.ReadMessageArray(tag, field_name, result.field3_, global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance, extensionRegistry); - break; - } - case 83: { - input.ReadGroupArray(tag, field_name, result.group1_, global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedFieldsGenerator.Types.Group1.DefaultInstance, extensionRegistry); - break; - } - case 163: { - input.ReadGroupArray(tag, field_name, result.group2_, global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedFieldsGenerator.Types.Group2.DefaultInstance, extensionRegistry); - break; - } - case 8002: { - input.ReadMessageArray(tag, field_name, result.ext1_, global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance, extensionRegistry); - break; - } - case 8010: { - input.ReadMessageArray(tag, field_name, result.ext2_, global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance, extensionRegistry); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public pbc::IPopsicleList Field1List { - get { return PrepareBuilder().field1_; } - } - public int Field1Count { - get { return result.Field1Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes GetField1(int index) { - return result.GetField1(index); - } - public Builder SetField1(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.field1_[index] = value; - return this; - } - public Builder SetField1(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.field1_[index] = builderForValue.Build(); - return this; - } - public Builder AddField1(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.field1_.Add(value); - return this; - } - public Builder AddField1(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.field1_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeField1(scg::IEnumerable values) { - PrepareBuilder(); - result.field1_.Add(values); - return this; - } - public Builder ClearField1() { - PrepareBuilder(); - result.field1_.Clear(); - return this; - } - - public pbc::IPopsicleList Field2List { - get { return PrepareBuilder().field2_; } - } - public int Field2Count { - get { return result.Field2Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes GetField2(int index) { - return result.GetField2(index); - } - public Builder SetField2(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.field2_[index] = value; - return this; - } - public Builder SetField2(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.field2_[index] = builderForValue.Build(); - return this; - } - public Builder AddField2(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.field2_.Add(value); - return this; - } - public Builder AddField2(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.field2_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeField2(scg::IEnumerable values) { - PrepareBuilder(); - result.field2_.Add(values); - return this; - } - public Builder ClearField2() { - PrepareBuilder(); - result.field2_.Clear(); - return this; - } - - public pbc::IPopsicleList Field3List { - get { return PrepareBuilder().field3_; } - } - public int Field3Count { - get { return result.Field3Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes GetField3(int index) { - return result.GetField3(index); - } - public Builder SetField3(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.field3_[index] = value; - return this; - } - public Builder SetField3(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.field3_[index] = builderForValue.Build(); - return this; - } - public Builder AddField3(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.field3_.Add(value); - return this; - } - public Builder AddField3(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.field3_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeField3(scg::IEnumerable values) { - PrepareBuilder(); - result.field3_.Add(values); - return this; - } - public Builder ClearField3() { - PrepareBuilder(); - result.field3_.Clear(); - return this; - } - - public pbc::IPopsicleList Group1List { - get { return PrepareBuilder().group1_; } - } - public int Group1Count { - get { return result.Group1Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedFieldsGenerator.Types.Group1 GetGroup1(int index) { - return result.GetGroup1(index); - } - public Builder SetGroup1(int index, global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedFieldsGenerator.Types.Group1 value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.group1_[index] = value; - return this; - } - public Builder SetGroup1(int index, global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedFieldsGenerator.Types.Group1.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.group1_[index] = builderForValue.Build(); - return this; - } - public Builder AddGroup1(global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedFieldsGenerator.Types.Group1 value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.group1_.Add(value); - return this; - } - public Builder AddGroup1(global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedFieldsGenerator.Types.Group1.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.group1_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeGroup1(scg::IEnumerable values) { - PrepareBuilder(); - result.group1_.Add(values); - return this; - } - public Builder ClearGroup1() { - PrepareBuilder(); - result.group1_.Clear(); - return this; - } - - public pbc::IPopsicleList Group2List { - get { return PrepareBuilder().group2_; } - } - public int Group2Count { - get { return result.Group2Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedFieldsGenerator.Types.Group2 GetGroup2(int index) { - return result.GetGroup2(index); - } - public Builder SetGroup2(int index, global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedFieldsGenerator.Types.Group2 value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.group2_[index] = value; - return this; - } - public Builder SetGroup2(int index, global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedFieldsGenerator.Types.Group2.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.group2_[index] = builderForValue.Build(); - return this; - } - public Builder AddGroup2(global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedFieldsGenerator.Types.Group2 value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.group2_.Add(value); - return this; - } - public Builder AddGroup2(global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedFieldsGenerator.Types.Group2.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.group2_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeGroup2(scg::IEnumerable values) { - PrepareBuilder(); - result.group2_.Add(values); - return this; - } - public Builder ClearGroup2() { - PrepareBuilder(); - result.group2_.Clear(); - return this; - } - - public pbc::IPopsicleList Ext1List { - get { return PrepareBuilder().ext1_; } - } - public int Ext1Count { - get { return result.Ext1Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes GetExt1(int index) { - return result.GetExt1(index); - } - public Builder SetExt1(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.ext1_[index] = value; - return this; - } - public Builder SetExt1(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.ext1_[index] = builderForValue.Build(); - return this; - } - public Builder AddExt1(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.ext1_.Add(value); - return this; - } - public Builder AddExt1(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.ext1_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeExt1(scg::IEnumerable values) { - PrepareBuilder(); - result.ext1_.Add(values); - return this; - } - public Builder ClearExt1() { - PrepareBuilder(); - result.ext1_.Clear(); - return this; - } - - public pbc::IPopsicleList Ext2List { - get { return PrepareBuilder().ext2_; } - } - public int Ext2Count { - get { return result.Ext2Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes GetExt2(int index) { - return result.GetExt2(index); - } - public Builder SetExt2(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.ext2_[index] = value; - return this; - } - public Builder SetExt2(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.ext2_[index] = builderForValue.Build(); - return this; - } - public Builder AddExt2(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.ext2_.Add(value); - return this; - } - public Builder AddExt2(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.ext2_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeExt2(scg::IEnumerable values) { - PrepareBuilder(); - result.ext2_.Add(values); - return this; - } - public Builder ClearExt2() { - PrepareBuilder(); - result.ext2_.Clear(); - return this; - } - } - static RepeatedFieldsGenerator() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class OptionalGroup : pb::GeneratedMessage { - private OptionalGroup() { } - private static readonly OptionalGroup defaultInstance = new OptionalGroup().MakeReadOnly(); - private static readonly string[] _optionalGroupFieldNames = new string[] { "optional_group_all_types" }; - private static readonly uint[] _optionalGroupFieldTags = new uint[] { 90 }; - public static OptionalGroup DefaultInstance { - get { return defaultInstance; } - } - - public override OptionalGroup DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override OptionalGroup ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestParsingMerge_OptionalGroup__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestParsingMerge_OptionalGroup__FieldAccessorTable; } - } - - public const int OptionalGroupAllTypesFieldNumber = 11; - private bool hasOptionalGroupAllTypes; - private global::Google.ProtocolBuffers.TestProtos.TestAllTypes optionalGroupAllTypes_; - public bool HasOptionalGroupAllTypes { - get { return hasOptionalGroupAllTypes; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes OptionalGroupAllTypes { - get { return optionalGroupAllTypes_ ?? global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _optionalGroupFieldNames; - if (hasOptionalGroupAllTypes) { - output.WriteMessage(11, field_names[0], OptionalGroupAllTypes); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasOptionalGroupAllTypes) { - size += pb::CodedOutputStream.ComputeMessageSize(11, OptionalGroupAllTypes); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static OptionalGroup ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static OptionalGroup ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static OptionalGroup ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static OptionalGroup ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static OptionalGroup ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static OptionalGroup ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static OptionalGroup ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static OptionalGroup ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static OptionalGroup ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static OptionalGroup ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private OptionalGroup MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(OptionalGroup prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(OptionalGroup cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private OptionalGroup result; - - private OptionalGroup PrepareBuilder() { - if (resultIsReadOnly) { - OptionalGroup original = result; - result = new OptionalGroup(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override OptionalGroup MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.OptionalGroup.Descriptor; } - } - - public override OptionalGroup DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.OptionalGroup.DefaultInstance; } - } - - public override OptionalGroup BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is OptionalGroup) { - return MergeFrom((OptionalGroup) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(OptionalGroup other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.OptionalGroup.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasOptionalGroupAllTypes) { - MergeOptionalGroupAllTypes(other.OptionalGroupAllTypes); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_optionalGroupFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _optionalGroupFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 90: { - global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.CreateBuilder(); - if (result.hasOptionalGroupAllTypes) { - subBuilder.MergeFrom(OptionalGroupAllTypes); - } - input.ReadMessage(subBuilder, extensionRegistry); - OptionalGroupAllTypes = subBuilder.BuildPartial(); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasOptionalGroupAllTypes { - get { return result.hasOptionalGroupAllTypes; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes OptionalGroupAllTypes { - get { return result.OptionalGroupAllTypes; } - set { SetOptionalGroupAllTypes(value); } - } - public Builder SetOptionalGroupAllTypes(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOptionalGroupAllTypes = true; - result.optionalGroupAllTypes_ = value; - return this; - } - public Builder SetOptionalGroupAllTypes(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasOptionalGroupAllTypes = true; - result.optionalGroupAllTypes_ = builderForValue.Build(); - return this; - } - public Builder MergeOptionalGroupAllTypes(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasOptionalGroupAllTypes && - result.optionalGroupAllTypes_ != global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance) { - result.optionalGroupAllTypes_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.CreateBuilder(result.optionalGroupAllTypes_).MergeFrom(value).BuildPartial(); - } else { - result.optionalGroupAllTypes_ = value; - } - result.hasOptionalGroupAllTypes = true; - return this; - } - public Builder ClearOptionalGroupAllTypes() { - PrepareBuilder(); - result.hasOptionalGroupAllTypes = false; - result.optionalGroupAllTypes_ = null; - return this; - } - } - static OptionalGroup() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class RepeatedGroup : pb::GeneratedMessage { - private RepeatedGroup() { } - private static readonly RepeatedGroup defaultInstance = new RepeatedGroup().MakeReadOnly(); - private static readonly string[] _repeatedGroupFieldNames = new string[] { "repeated_group_all_types" }; - private static readonly uint[] _repeatedGroupFieldTags = new uint[] { 170 }; - public static RepeatedGroup DefaultInstance { - get { return defaultInstance; } - } - - public override RepeatedGroup DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override RepeatedGroup ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestParsingMerge_RepeatedGroup__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestParsingMerge_RepeatedGroup__FieldAccessorTable; } - } - - public const int RepeatedGroupAllTypesFieldNumber = 21; - private bool hasRepeatedGroupAllTypes; - private global::Google.ProtocolBuffers.TestProtos.TestAllTypes repeatedGroupAllTypes_; - public bool HasRepeatedGroupAllTypes { - get { return hasRepeatedGroupAllTypes; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes RepeatedGroupAllTypes { - get { return repeatedGroupAllTypes_ ?? global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _repeatedGroupFieldNames; - if (hasRepeatedGroupAllTypes) { - output.WriteMessage(21, field_names[0], RepeatedGroupAllTypes); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasRepeatedGroupAllTypes) { - size += pb::CodedOutputStream.ComputeMessageSize(21, RepeatedGroupAllTypes); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static RepeatedGroup ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static RepeatedGroup ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static RepeatedGroup ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static RepeatedGroup ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static RepeatedGroup ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static RepeatedGroup ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static RepeatedGroup ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static RepeatedGroup ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static RepeatedGroup ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static RepeatedGroup ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private RepeatedGroup MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(RepeatedGroup prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(RepeatedGroup cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private RepeatedGroup result; - - private RepeatedGroup PrepareBuilder() { - if (resultIsReadOnly) { - RepeatedGroup original = result; - result = new RepeatedGroup(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override RepeatedGroup MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedGroup.Descriptor; } - } - - public override RepeatedGroup DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedGroup.DefaultInstance; } - } - - public override RepeatedGroup BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is RepeatedGroup) { - return MergeFrom((RepeatedGroup) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(RepeatedGroup other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedGroup.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasRepeatedGroupAllTypes) { - MergeRepeatedGroupAllTypes(other.RepeatedGroupAllTypes); - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_repeatedGroupFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _repeatedGroupFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 170: { - global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.CreateBuilder(); - if (result.hasRepeatedGroupAllTypes) { - subBuilder.MergeFrom(RepeatedGroupAllTypes); - } - input.ReadMessage(subBuilder, extensionRegistry); - RepeatedGroupAllTypes = subBuilder.BuildPartial(); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasRepeatedGroupAllTypes { - get { return result.hasRepeatedGroupAllTypes; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes RepeatedGroupAllTypes { - get { return result.RepeatedGroupAllTypes; } - set { SetRepeatedGroupAllTypes(value); } - } - public Builder SetRepeatedGroupAllTypes(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasRepeatedGroupAllTypes = true; - result.repeatedGroupAllTypes_ = value; - return this; - } - public Builder SetRepeatedGroupAllTypes(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasRepeatedGroupAllTypes = true; - result.repeatedGroupAllTypes_ = builderForValue.Build(); - return this; - } - public Builder MergeRepeatedGroupAllTypes(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasRepeatedGroupAllTypes && - result.repeatedGroupAllTypes_ != global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance) { - result.repeatedGroupAllTypes_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.CreateBuilder(result.repeatedGroupAllTypes_).MergeFrom(value).BuildPartial(); - } else { - result.repeatedGroupAllTypes_ = value; - } - result.hasRepeatedGroupAllTypes = true; - return this; - } - public Builder ClearRepeatedGroupAllTypes() { - PrepareBuilder(); - result.hasRepeatedGroupAllTypes = false; - result.repeatedGroupAllTypes_ = null; - return this; - } - } - static RepeatedGroup() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - } - #endregion - - public const int RequiredAllTypesFieldNumber = 1; - private bool hasRequiredAllTypes; - private global::Google.ProtocolBuffers.TestProtos.TestAllTypes requiredAllTypes_; - public bool HasRequiredAllTypes { - get { return hasRequiredAllTypes; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes RequiredAllTypes { - get { return requiredAllTypes_ ?? global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance; } - } - - public const int OptionalAllTypesFieldNumber = 2; - private bool hasOptionalAllTypes; - private global::Google.ProtocolBuffers.TestProtos.TestAllTypes optionalAllTypes_; - public bool HasOptionalAllTypes { - get { return hasOptionalAllTypes; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes OptionalAllTypes { - get { return optionalAllTypes_ ?? global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance; } - } - - public const int RepeatedAllTypesFieldNumber = 3; - private pbc::PopsicleList repeatedAllTypes_ = new pbc::PopsicleList(); - public scg::IList RepeatedAllTypesList { - get { return repeatedAllTypes_; } - } - public int RepeatedAllTypesCount { - get { return repeatedAllTypes_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes GetRepeatedAllTypes(int index) { - return repeatedAllTypes_[index]; - } - - public const int OptionalGroupFieldNumber = 10; - private bool hasOptionalGroup; - private global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.OptionalGroup optionalGroup_; - public bool HasOptionalGroup { - get { return hasOptionalGroup; } - } - public global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.OptionalGroup OptionalGroup { - get { return optionalGroup_ ?? global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.OptionalGroup.DefaultInstance; } - } - - public const int RepeatedGroupFieldNumber = 20; - private pbc::PopsicleList repeatedGroup_ = new pbc::PopsicleList(); - public scg::IList RepeatedGroupList { - get { return repeatedGroup_; } - } - public int RepeatedGroupCount { - get { return repeatedGroup_.Count; } - } - public global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedGroup GetRepeatedGroup(int index) { - return repeatedGroup_[index]; - } - - public override bool IsInitialized { - get { - if (!hasRequiredAllTypes) return false; - if (!ExtensionsAreInitialized) return false; - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testParsingMergeFieldNames; - pb::ExtendableMessage.ExtensionWriter extensionWriter = CreateExtensionWriter(this); - if (hasRequiredAllTypes) { - output.WriteMessage(1, field_names[4], RequiredAllTypes); - } - if (hasOptionalAllTypes) { - output.WriteMessage(2, field_names[0], OptionalAllTypes); - } - if (repeatedAllTypes_.Count > 0) { - output.WriteMessageArray(3, field_names[2], repeatedAllTypes_); - } - if (hasOptionalGroup) { - output.WriteGroup(10, field_names[1], OptionalGroup); - } - if (repeatedGroup_.Count > 0) { - output.WriteGroupArray(20, field_names[3], repeatedGroup_); - } - extensionWriter.WriteUntil(536870912, output); - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasRequiredAllTypes) { - size += pb::CodedOutputStream.ComputeMessageSize(1, RequiredAllTypes); - } - if (hasOptionalAllTypes) { - size += pb::CodedOutputStream.ComputeMessageSize(2, OptionalAllTypes); - } - foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypes element in RepeatedAllTypesList) { - size += pb::CodedOutputStream.ComputeMessageSize(3, element); - } - if (hasOptionalGroup) { - size += pb::CodedOutputStream.ComputeGroupSize(10, OptionalGroup); - } - foreach (global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedGroup element in RepeatedGroupList) { - size += pb::CodedOutputStream.ComputeGroupSize(20, element); - } - size += ExtensionsSerializedSize; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestParsingMerge ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestParsingMerge ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestParsingMerge ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestParsingMerge ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestParsingMerge ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestParsingMerge ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestParsingMerge ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestParsingMerge ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestParsingMerge ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestParsingMerge ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestParsingMerge MakeReadOnly() { - repeatedAllTypes_.MakeReadOnly(); - repeatedGroup_.MakeReadOnly(); - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestParsingMerge prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::ExtendableBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestParsingMerge cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestParsingMerge result; - - private TestParsingMerge PrepareBuilder() { - if (resultIsReadOnly) { - TestParsingMerge original = result; - result = new TestParsingMerge(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestParsingMerge MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Descriptor; } - } - - public override TestParsingMerge DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.DefaultInstance; } - } - - public override TestParsingMerge BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestParsingMerge) { - return MergeFrom((TestParsingMerge) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestParsingMerge other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasRequiredAllTypes) { - MergeRequiredAllTypes(other.RequiredAllTypes); - } - if (other.HasOptionalAllTypes) { - MergeOptionalAllTypes(other.OptionalAllTypes); - } - if (other.repeatedAllTypes_.Count != 0) { - result.repeatedAllTypes_.Add(other.repeatedAllTypes_); - } - if (other.HasOptionalGroup) { - MergeOptionalGroup(other.OptionalGroup); - } - if (other.repeatedGroup_.Count != 0) { - result.repeatedGroup_.Add(other.repeatedGroup_); - } - this.MergeExtensionFields(other); - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testParsingMergeFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testParsingMergeFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 10: { - global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.CreateBuilder(); - if (result.hasRequiredAllTypes) { - subBuilder.MergeFrom(RequiredAllTypes); - } - input.ReadMessage(subBuilder, extensionRegistry); - RequiredAllTypes = subBuilder.BuildPartial(); - break; - } - case 18: { - global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.CreateBuilder(); - if (result.hasOptionalAllTypes) { - subBuilder.MergeFrom(OptionalAllTypes); - } - input.ReadMessage(subBuilder, extensionRegistry); - OptionalAllTypes = subBuilder.BuildPartial(); - break; - } - case 26: { - input.ReadMessageArray(tag, field_name, result.repeatedAllTypes_, global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance, extensionRegistry); - break; - } - case 83: { - global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.OptionalGroup.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.OptionalGroup.CreateBuilder(); - if (result.hasOptionalGroup) { - subBuilder.MergeFrom(OptionalGroup); - } - input.ReadGroup(10, subBuilder, extensionRegistry); - OptionalGroup = subBuilder.BuildPartial(); - break; - } - case 163: { - input.ReadGroupArray(tag, field_name, result.repeatedGroup_, global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedGroup.DefaultInstance, extensionRegistry); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasRequiredAllTypes { - get { return result.hasRequiredAllTypes; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes RequiredAllTypes { - get { return result.RequiredAllTypes; } - set { SetRequiredAllTypes(value); } - } - public Builder SetRequiredAllTypes(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasRequiredAllTypes = true; - result.requiredAllTypes_ = value; - return this; - } - public Builder SetRequiredAllTypes(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasRequiredAllTypes = true; - result.requiredAllTypes_ = builderForValue.Build(); - return this; - } - public Builder MergeRequiredAllTypes(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasRequiredAllTypes && - result.requiredAllTypes_ != global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance) { - result.requiredAllTypes_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.CreateBuilder(result.requiredAllTypes_).MergeFrom(value).BuildPartial(); - } else { - result.requiredAllTypes_ = value; - } - result.hasRequiredAllTypes = true; - return this; - } - public Builder ClearRequiredAllTypes() { - PrepareBuilder(); - result.hasRequiredAllTypes = false; - result.requiredAllTypes_ = null; - return this; - } - - public bool HasOptionalAllTypes { - get { return result.hasOptionalAllTypes; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes OptionalAllTypes { - get { return result.OptionalAllTypes; } - set { SetOptionalAllTypes(value); } - } - public Builder SetOptionalAllTypes(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOptionalAllTypes = true; - result.optionalAllTypes_ = value; - return this; - } - public Builder SetOptionalAllTypes(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasOptionalAllTypes = true; - result.optionalAllTypes_ = builderForValue.Build(); - return this; - } - public Builder MergeOptionalAllTypes(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasOptionalAllTypes && - result.optionalAllTypes_ != global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance) { - result.optionalAllTypes_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.CreateBuilder(result.optionalAllTypes_).MergeFrom(value).BuildPartial(); - } else { - result.optionalAllTypes_ = value; - } - result.hasOptionalAllTypes = true; - return this; - } - public Builder ClearOptionalAllTypes() { - PrepareBuilder(); - result.hasOptionalAllTypes = false; - result.optionalAllTypes_ = null; - return this; - } - - public pbc::IPopsicleList RepeatedAllTypesList { - get { return PrepareBuilder().repeatedAllTypes_; } - } - public int RepeatedAllTypesCount { - get { return result.RepeatedAllTypesCount; } - } - public global::Google.ProtocolBuffers.TestProtos.TestAllTypes GetRepeatedAllTypes(int index) { - return result.GetRepeatedAllTypes(index); - } - public Builder SetRepeatedAllTypes(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedAllTypes_[index] = value; - return this; - } - public Builder SetRepeatedAllTypes(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.repeatedAllTypes_[index] = builderForValue.Build(); - return this; - } - public Builder AddRepeatedAllTypes(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedAllTypes_.Add(value); - return this; - } - public Builder AddRepeatedAllTypes(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.repeatedAllTypes_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeRepeatedAllTypes(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedAllTypes_.Add(values); - return this; - } - public Builder ClearRepeatedAllTypes() { - PrepareBuilder(); - result.repeatedAllTypes_.Clear(); - return this; - } - - public bool HasOptionalGroup { - get { return result.hasOptionalGroup; } - } - public global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.OptionalGroup OptionalGroup { - get { return result.OptionalGroup; } - set { SetOptionalGroup(value); } - } - public Builder SetOptionalGroup(global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.OptionalGroup value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasOptionalGroup = true; - result.optionalGroup_ = value; - return this; - } - public Builder SetOptionalGroup(global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.OptionalGroup.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.hasOptionalGroup = true; - result.optionalGroup_ = builderForValue.Build(); - return this; - } - public Builder MergeOptionalGroup(global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.OptionalGroup value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasOptionalGroup && - result.optionalGroup_ != global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.OptionalGroup.DefaultInstance) { - result.optionalGroup_ = global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.OptionalGroup.CreateBuilder(result.optionalGroup_).MergeFrom(value).BuildPartial(); - } else { - result.optionalGroup_ = value; - } - result.hasOptionalGroup = true; - return this; - } - public Builder ClearOptionalGroup() { - PrepareBuilder(); - result.hasOptionalGroup = false; - result.optionalGroup_ = null; - return this; - } - - public pbc::IPopsicleList RepeatedGroupList { - get { return PrepareBuilder().repeatedGroup_; } - } - public int RepeatedGroupCount { - get { return result.RepeatedGroupCount; } - } - public global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedGroup GetRepeatedGroup(int index) { - return result.GetRepeatedGroup(index); - } - public Builder SetRepeatedGroup(int index, global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedGroup value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedGroup_[index] = value; - return this; - } - public Builder SetRepeatedGroup(int index, global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedGroup.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.repeatedGroup_[index] = builderForValue.Build(); - return this; - } - public Builder AddRepeatedGroup(global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedGroup value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.repeatedGroup_.Add(value); - return this; - } - public Builder AddRepeatedGroup(global::Google.ProtocolBuffers.TestProtos.TestParsingMerge.Types.RepeatedGroup.Builder builderForValue) { - pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); - PrepareBuilder(); - result.repeatedGroup_.Add(builderForValue.Build()); - return this; - } - public Builder AddRangeRepeatedGroup(scg::IEnumerable values) { - PrepareBuilder(); - result.repeatedGroup_.Add(values); - return this; - } - public Builder ClearRepeatedGroup() { - PrepareBuilder(); - result.repeatedGroup_.Clear(); - return this; - } - } - static TestParsingMerge() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class TestCommentInjectionMessage : pb::GeneratedMessage { - private TestCommentInjectionMessage() { } - private static readonly TestCommentInjectionMessage defaultInstance = new TestCommentInjectionMessage().MakeReadOnly(); - private static readonly string[] _testCommentInjectionMessageFieldNames = new string[] { "a" }; - private static readonly uint[] _testCommentInjectionMessageFieldTags = new uint[] { 10 }; - public static TestCommentInjectionMessage DefaultInstance { - get { return defaultInstance; } - } - - public override TestCommentInjectionMessage DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override TestCommentInjectionMessage ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestCommentInjectionMessage__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_TestCommentInjectionMessage__FieldAccessorTable; } - } - - public const int AFieldNumber = 1; - private bool hasA; - private string a_ = "*/ <- Neither should this."; - public bool HasA { - get { return hasA; } - } - public string A { - get { return a_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testCommentInjectionMessageFieldNames; - if (hasA) { - output.WriteString(1, field_names[0], A); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasA) { - size += pb::CodedOutputStream.ComputeStringSize(1, A); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static TestCommentInjectionMessage ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestCommentInjectionMessage ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestCommentInjectionMessage ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static TestCommentInjectionMessage ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static TestCommentInjectionMessage ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestCommentInjectionMessage ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static TestCommentInjectionMessage ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static TestCommentInjectionMessage ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static TestCommentInjectionMessage ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static TestCommentInjectionMessage ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private TestCommentInjectionMessage MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(TestCommentInjectionMessage prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(TestCommentInjectionMessage cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private TestCommentInjectionMessage result; - - private TestCommentInjectionMessage PrepareBuilder() { - if (resultIsReadOnly) { - TestCommentInjectionMessage original = result; - result = new TestCommentInjectionMessage(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override TestCommentInjectionMessage MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestCommentInjectionMessage.Descriptor; } - } - - public override TestCommentInjectionMessage DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.TestCommentInjectionMessage.DefaultInstance; } - } - - public override TestCommentInjectionMessage BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is TestCommentInjectionMessage) { - return MergeFrom((TestCommentInjectionMessage) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(TestCommentInjectionMessage other) { - if (other == global::Google.ProtocolBuffers.TestProtos.TestCommentInjectionMessage.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasA) { - A = other.A; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_testCommentInjectionMessageFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _testCommentInjectionMessageFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 10: { - result.hasA = input.ReadString(ref result.a_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasA { - get { return result.hasA; } - } - public string A { - get { return result.A; } - set { SetA(value); } - } - public Builder SetA(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.hasA = true; - result.a_ = value; - return this; - } - public Builder ClearA() { - PrepareBuilder(); - result.hasA = false; - result.a_ = "*/ <- Neither should this."; - return this; - } - } - static TestCommentInjectionMessage() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class FooRequest : pb::GeneratedMessage { - private FooRequest() { } - private static readonly FooRequest defaultInstance = new FooRequest().MakeReadOnly(); - private static readonly string[] _fooRequestFieldNames = new string[] { }; - private static readonly uint[] _fooRequestFieldTags = new uint[] { }; - public static FooRequest DefaultInstance { - get { return defaultInstance; } - } - - public override FooRequest DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override FooRequest ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_FooRequest__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_FooRequest__FieldAccessorTable; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _fooRequestFieldNames; - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static FooRequest ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static FooRequest ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static FooRequest ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static FooRequest ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static FooRequest ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static FooRequest ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static FooRequest ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static FooRequest ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static FooRequest ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static FooRequest ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private FooRequest MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(FooRequest prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(FooRequest cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private FooRequest result; - - private FooRequest PrepareBuilder() { - if (resultIsReadOnly) { - FooRequest original = result; - result = new FooRequest(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override FooRequest MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.FooRequest.Descriptor; } - } - - public override FooRequest DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.FooRequest.DefaultInstance; } - } - - public override FooRequest BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is FooRequest) { - return MergeFrom((FooRequest) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(FooRequest other) { - if (other == global::Google.ProtocolBuffers.TestProtos.FooRequest.DefaultInstance) return this; - PrepareBuilder(); - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_fooRequestFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _fooRequestFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - } - static FooRequest() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class FooResponse : pb::GeneratedMessage { - private FooResponse() { } - private static readonly FooResponse defaultInstance = new FooResponse().MakeReadOnly(); - private static readonly string[] _fooResponseFieldNames = new string[] { }; - private static readonly uint[] _fooResponseFieldTags = new uint[] { }; - public static FooResponse DefaultInstance { - get { return defaultInstance; } - } - - public override FooResponse DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override FooResponse ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_FooResponse__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_FooResponse__FieldAccessorTable; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _fooResponseFieldNames; - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static FooResponse ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static FooResponse ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static FooResponse ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static FooResponse ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static FooResponse ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static FooResponse ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static FooResponse ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static FooResponse ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static FooResponse ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static FooResponse ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private FooResponse MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(FooResponse prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(FooResponse cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private FooResponse result; - - private FooResponse PrepareBuilder() { - if (resultIsReadOnly) { - FooResponse original = result; - result = new FooResponse(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override FooResponse MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.FooResponse.Descriptor; } - } - - public override FooResponse DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.FooResponse.DefaultInstance; } - } - - public override FooResponse BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is FooResponse) { - return MergeFrom((FooResponse) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(FooResponse other) { - if (other == global::Google.ProtocolBuffers.TestProtos.FooResponse.DefaultInstance) return this; - PrepareBuilder(); - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_fooResponseFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _fooResponseFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - } - static FooResponse() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class FooClientMessage : pb::GeneratedMessage { - private FooClientMessage() { } - private static readonly FooClientMessage defaultInstance = new FooClientMessage().MakeReadOnly(); - private static readonly string[] _fooClientMessageFieldNames = new string[] { }; - private static readonly uint[] _fooClientMessageFieldTags = new uint[] { }; - public static FooClientMessage DefaultInstance { - get { return defaultInstance; } - } - - public override FooClientMessage DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override FooClientMessage ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_FooClientMessage__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_FooClientMessage__FieldAccessorTable; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _fooClientMessageFieldNames; - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static FooClientMessage ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static FooClientMessage ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static FooClientMessage ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static FooClientMessage ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static FooClientMessage ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static FooClientMessage ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static FooClientMessage ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static FooClientMessage ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static FooClientMessage ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static FooClientMessage ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private FooClientMessage MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(FooClientMessage prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(FooClientMessage cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private FooClientMessage result; - - private FooClientMessage PrepareBuilder() { - if (resultIsReadOnly) { - FooClientMessage original = result; - result = new FooClientMessage(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override FooClientMessage MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.FooClientMessage.Descriptor; } - } - - public override FooClientMessage DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.FooClientMessage.DefaultInstance; } - } - - public override FooClientMessage BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is FooClientMessage) { - return MergeFrom((FooClientMessage) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(FooClientMessage other) { - if (other == global::Google.ProtocolBuffers.TestProtos.FooClientMessage.DefaultInstance) return this; - PrepareBuilder(); - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_fooClientMessageFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _fooClientMessageFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - } - static FooClientMessage() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class FooServerMessage : pb::GeneratedMessage { - private FooServerMessage() { } - private static readonly FooServerMessage defaultInstance = new FooServerMessage().MakeReadOnly(); - private static readonly string[] _fooServerMessageFieldNames = new string[] { }; - private static readonly uint[] _fooServerMessageFieldTags = new uint[] { }; - public static FooServerMessage DefaultInstance { - get { return defaultInstance; } - } - - public override FooServerMessage DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override FooServerMessage ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_FooServerMessage__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_FooServerMessage__FieldAccessorTable; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _fooServerMessageFieldNames; - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static FooServerMessage ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static FooServerMessage ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static FooServerMessage ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static FooServerMessage ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static FooServerMessage ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static FooServerMessage ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static FooServerMessage ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static FooServerMessage ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static FooServerMessage ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static FooServerMessage ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private FooServerMessage MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(FooServerMessage prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(FooServerMessage cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private FooServerMessage result; - - private FooServerMessage PrepareBuilder() { - if (resultIsReadOnly) { - FooServerMessage original = result; - result = new FooServerMessage(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override FooServerMessage MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.FooServerMessage.Descriptor; } - } - - public override FooServerMessage DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.FooServerMessage.DefaultInstance; } - } - - public override FooServerMessage BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is FooServerMessage) { - return MergeFrom((FooServerMessage) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(FooServerMessage other) { - if (other == global::Google.ProtocolBuffers.TestProtos.FooServerMessage.DefaultInstance) return this; - PrepareBuilder(); - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_fooServerMessageFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _fooServerMessageFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - } - static FooServerMessage() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class BarRequest : pb::GeneratedMessage { - private BarRequest() { } - private static readonly BarRequest defaultInstance = new BarRequest().MakeReadOnly(); - private static readonly string[] _barRequestFieldNames = new string[] { }; - private static readonly uint[] _barRequestFieldTags = new uint[] { }; - public static BarRequest DefaultInstance { - get { return defaultInstance; } - } - - public override BarRequest DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override BarRequest ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_BarRequest__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_BarRequest__FieldAccessorTable; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _barRequestFieldNames; - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static BarRequest ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static BarRequest ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static BarRequest ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static BarRequest ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static BarRequest ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static BarRequest ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static BarRequest ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static BarRequest ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static BarRequest ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static BarRequest ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private BarRequest MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(BarRequest prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(BarRequest cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private BarRequest result; - - private BarRequest PrepareBuilder() { - if (resultIsReadOnly) { - BarRequest original = result; - result = new BarRequest(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override BarRequest MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.BarRequest.Descriptor; } - } - - public override BarRequest DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.BarRequest.DefaultInstance; } - } - - public override BarRequest BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is BarRequest) { - return MergeFrom((BarRequest) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(BarRequest other) { - if (other == global::Google.ProtocolBuffers.TestProtos.BarRequest.DefaultInstance) return this; - PrepareBuilder(); - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_barRequestFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _barRequestFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - } - static BarRequest() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class BarResponse : pb::GeneratedMessage { - private BarResponse() { } - private static readonly BarResponse defaultInstance = new BarResponse().MakeReadOnly(); - private static readonly string[] _barResponseFieldNames = new string[] { }; - private static readonly uint[] _barResponseFieldTags = new uint[] { }; - public static BarResponse DefaultInstance { - get { return defaultInstance; } - } - - public override BarResponse DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override BarResponse ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_BarResponse__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.Unittest.internal__static_protobuf_unittest_BarResponse__FieldAccessorTable; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _barResponseFieldNames; - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static BarResponse ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static BarResponse ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static BarResponse ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static BarResponse ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static BarResponse ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static BarResponse ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static BarResponse ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static BarResponse ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static BarResponse ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static BarResponse ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private BarResponse MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(BarResponse prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(BarResponse cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private BarResponse result; - - private BarResponse PrepareBuilder() { - if (resultIsReadOnly) { - BarResponse original = result; - result = new BarResponse(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override BarResponse MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.BarResponse.Descriptor; } - } - - public override BarResponse DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.BarResponse.DefaultInstance; } - } - - public override BarResponse BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is BarResponse) { - return MergeFrom((BarResponse) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(BarResponse other) { - if (other == global::Google.ProtocolBuffers.TestProtos.BarResponse.DefaultInstance) return this; - PrepareBuilder(); - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_barResponseFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _barResponseFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - } - static BarResponse() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, null); - } - } - - #endregion - -} - -#endregion Designer generated code diff --git a/csharp/src/ProtoBench/UnittestImport.cs b/csharp/src/ProtoBench/UnittestImport.cs deleted file mode 100644 index 81f9ee53..00000000 --- a/csharp/src/ProtoBench/UnittestImport.cs +++ /dev/null @@ -1,347 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/protobuf/unittest_import.proto -#pragma warning disable 1591, 0612, 3021 -#region Designer generated code - -using pb = global::Google.ProtocolBuffers; -using pbc = global::Google.ProtocolBuffers.Collections; -using pbd = global::Google.ProtocolBuffers.Descriptors; -using scg = global::System.Collections.Generic; -namespace Google.ProtocolBuffers.TestProtos { - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class UnittestImport { - - #region Extension registration - public static void RegisterAllExtensions(pb::ExtensionRegistry registry) { - } - #endregion - #region Static variables - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_import_ImportMessage__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_import_ImportMessage__FieldAccessorTable; - #endregion - #region Descriptor - public static pbd::FileDescriptor Descriptor { - get { return descriptor; } - } - private static pbd::FileDescriptor descriptor; - - static UnittestImport() { - byte[] descriptorData = global::System.Convert.FromBase64String( - string.Concat( - "CiVnb29nbGUvcHJvdG9idWYvdW5pdHRlc3RfaW1wb3J0LnByb3RvEhhwcm90", - "b2J1Zl91bml0dGVzdF9pbXBvcnQaLGdvb2dsZS9wcm90b2J1Zi91bml0dGVz", - "dF9pbXBvcnRfcHVibGljLnByb3RvIhoKDUltcG9ydE1lc3NhZ2USCQoBZBgB", - "IAEoBSo8CgpJbXBvcnRFbnVtEg4KCklNUE9SVF9GT08QBxIOCgpJTVBPUlRf", - "QkFSEAgSDgoKSU1QT1JUX0JBWhAJQkMKGGNvbS5nb29nbGUucHJvdG9idWYu", - "dGVzdEgB+AEBqgIhR29vZ2xlLlByb3RvY29sQnVmZmVycy5UZXN0UHJvdG9z", - "UAA=")); - pbd::FileDescriptor.InternalDescriptorAssigner assigner = delegate(pbd::FileDescriptor root) { - descriptor = root; - internal__static_protobuf_unittest_import_ImportMessage__Descriptor = Descriptor.MessageTypes[0]; - internal__static_protobuf_unittest_import_ImportMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_import_ImportMessage__Descriptor, - new string[] { "D", }); - pb::ExtensionRegistry registry = pb::ExtensionRegistry.CreateInstance(); - RegisterAllExtensions(registry); - global::Google.ProtocolBuffers.TestProtos.UnittestImportPublic.RegisterAllExtensions(registry); - return registry; - }; - pbd::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, - new pbd::FileDescriptor[] { - global::Google.ProtocolBuffers.TestProtos.UnittestImportPublic.Descriptor, - }, assigner); - } - #endregion - - } - #region Enums - public enum ImportEnum { - IMPORT_FOO = 7, - IMPORT_BAR = 8, - IMPORT_BAZ = 9, - } - - #endregion - - #region Messages - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class ImportMessage : pb::GeneratedMessage { - private ImportMessage() { } - private static readonly ImportMessage defaultInstance = new ImportMessage().MakeReadOnly(); - private static readonly string[] _importMessageFieldNames = new string[] { "d" }; - private static readonly uint[] _importMessageFieldTags = new uint[] { 8 }; - public static ImportMessage DefaultInstance { - get { return defaultInstance; } - } - - public override ImportMessage DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override ImportMessage ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.UnittestImport.internal__static_protobuf_unittest_import_ImportMessage__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.UnittestImport.internal__static_protobuf_unittest_import_ImportMessage__FieldAccessorTable; } - } - - public const int DFieldNumber = 1; - private bool hasD; - private int d_; - public bool HasD { - get { return hasD; } - } - public int D { - get { return d_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _importMessageFieldNames; - if (hasD) { - output.WriteInt32(1, field_names[0], D); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasD) { - size += pb::CodedOutputStream.ComputeInt32Size(1, D); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static ImportMessage ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static ImportMessage ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static ImportMessage ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static ImportMessage ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static ImportMessage ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static ImportMessage ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static ImportMessage ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static ImportMessage ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static ImportMessage ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static ImportMessage ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private ImportMessage MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(ImportMessage prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(ImportMessage cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private ImportMessage result; - - private ImportMessage PrepareBuilder() { - if (resultIsReadOnly) { - ImportMessage original = result; - result = new ImportMessage(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override ImportMessage MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.ImportMessage.Descriptor; } - } - - public override ImportMessage DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.ImportMessage.DefaultInstance; } - } - - public override ImportMessage BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is ImportMessage) { - return MergeFrom((ImportMessage) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(ImportMessage other) { - if (other == global::Google.ProtocolBuffers.TestProtos.ImportMessage.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasD) { - D = other.D; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_importMessageFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _importMessageFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasD = input.ReadInt32(ref result.d_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasD { - get { return result.hasD; } - } - public int D { - get { return result.D; } - set { SetD(value); } - } - public Builder SetD(int value) { - PrepareBuilder(); - result.hasD = true; - result.d_ = value; - return this; - } - public Builder ClearD() { - PrepareBuilder(); - result.hasD = false; - result.d_ = 0; - return this; - } - } - static ImportMessage() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.UnittestImport.Descriptor, null); - } - } - - #endregion - -} - -#endregion Designer generated code diff --git a/csharp/src/ProtoBench/UnittestImportPublic.cs b/csharp/src/ProtoBench/UnittestImportPublic.cs deleted file mode 100644 index 4185cac7..00000000 --- a/csharp/src/ProtoBench/UnittestImportPublic.cs +++ /dev/null @@ -1,333 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/protobuf/unittest_import_public.proto -#pragma warning disable 1591, 0612, 3021 -#region Designer generated code - -using pb = global::Google.ProtocolBuffers; -using pbc = global::Google.ProtocolBuffers.Collections; -using pbd = global::Google.ProtocolBuffers.Descriptors; -using scg = global::System.Collections.Generic; -namespace Google.ProtocolBuffers.TestProtos { - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class UnittestImportPublic { - - #region Extension registration - public static void RegisterAllExtensions(pb::ExtensionRegistry registry) { - } - #endregion - #region Static variables - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_import_PublicImportMessage__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_import_PublicImportMessage__FieldAccessorTable; - #endregion - #region Descriptor - public static pbd::FileDescriptor Descriptor { - get { return descriptor; } - } - private static pbd::FileDescriptor descriptor; - - static UnittestImportPublic() { - byte[] descriptorData = global::System.Convert.FromBase64String( - string.Concat( - "Cixnb29nbGUvcHJvdG9idWYvdW5pdHRlc3RfaW1wb3J0X3B1YmxpYy5wcm90", - "bxIYcHJvdG9idWZfdW5pdHRlc3RfaW1wb3J0IiAKE1B1YmxpY0ltcG9ydE1l", - "c3NhZ2USCQoBZRgBIAEoBUI+Chhjb20uZ29vZ2xlLnByb3RvYnVmLnRlc3Sq", - "AiFHb29nbGUuUHJvdG9jb2xCdWZmZXJzLlRlc3RQcm90b3M=")); - pbd::FileDescriptor.InternalDescriptorAssigner assigner = delegate(pbd::FileDescriptor root) { - descriptor = root; - internal__static_protobuf_unittest_import_PublicImportMessage__Descriptor = Descriptor.MessageTypes[0]; - internal__static_protobuf_unittest_import_PublicImportMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_import_PublicImportMessage__Descriptor, - new string[] { "E", }); - pb::ExtensionRegistry registry = pb::ExtensionRegistry.CreateInstance(); - RegisterAllExtensions(registry); - return registry; - }; - pbd::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, - new pbd::FileDescriptor[] { - }, assigner); - } - #endregion - - } - #region Messages - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class PublicImportMessage : pb::GeneratedMessage { - private PublicImportMessage() { } - private static readonly PublicImportMessage defaultInstance = new PublicImportMessage().MakeReadOnly(); - private static readonly string[] _publicImportMessageFieldNames = new string[] { "e" }; - private static readonly uint[] _publicImportMessageFieldTags = new uint[] { 8 }; - public static PublicImportMessage DefaultInstance { - get { return defaultInstance; } - } - - public override PublicImportMessage DefaultInstanceForType { - get { return DefaultInstance; } - } - - protected override PublicImportMessage ThisMessage { - get { return this; } - } - - public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.TestProtos.UnittestImportPublic.internal__static_protobuf_unittest_import_PublicImportMessage__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.UnittestImportPublic.internal__static_protobuf_unittest_import_PublicImportMessage__FieldAccessorTable; } - } - - public const int EFieldNumber = 1; - private bool hasE; - private int e_; - public bool HasE { - get { return hasE; } - } - public int E { - get { return e_; } - } - - public override bool IsInitialized { - get { - return true; - } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _publicImportMessageFieldNames; - if (hasE) { - output.WriteInt32(1, field_names[0], E); - } - UnknownFields.WriteTo(output); - } - - private int memoizedSerializedSize = -1; - public override int SerializedSize { - get { - int size = memoizedSerializedSize; - if (size != -1) return size; - return CalcSerializedSize(); - } - } - - private int CalcSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasE) { - size += pb::CodedOutputStream.ComputeInt32Size(1, E); - } - size += UnknownFields.SerializedSize; - memoizedSerializedSize = size; - return size; - } - public static PublicImportMessage ParseFrom(pb::ByteString data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static PublicImportMessage ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static PublicImportMessage ParseFrom(byte[] data) { - return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); - } - public static PublicImportMessage ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); - } - public static PublicImportMessage ParseFrom(global::System.IO.Stream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static PublicImportMessage ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - public static PublicImportMessage ParseDelimitedFrom(global::System.IO.Stream input) { - return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); - } - public static PublicImportMessage ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { - return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); - } - public static PublicImportMessage ParseFrom(pb::ICodedInputStream input) { - return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); - } - public static PublicImportMessage ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); - } - private PublicImportMessage MakeReadOnly() { - return this; - } - - public static Builder CreateBuilder() { return new Builder(); } - public override Builder ToBuilder() { return CreateBuilder(this); } - public override Builder CreateBuilderForType() { return new Builder(); } - public static Builder CreateBuilder(PublicImportMessage prototype) { - return new Builder(prototype); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Builder : pb::GeneratedBuilder { - protected override Builder ThisBuilder { - get { return this; } - } - public Builder() { - result = DefaultInstance; - resultIsReadOnly = true; - } - internal Builder(PublicImportMessage cloneFrom) { - result = cloneFrom; - resultIsReadOnly = true; - } - - private bool resultIsReadOnly; - private PublicImportMessage result; - - private PublicImportMessage PrepareBuilder() { - if (resultIsReadOnly) { - PublicImportMessage original = result; - result = new PublicImportMessage(); - resultIsReadOnly = false; - MergeFrom(original); - } - return result; - } - - public override bool IsInitialized { - get { return result.IsInitialized; } - } - - protected override PublicImportMessage MessageBeingBuilt { - get { return PrepareBuilder(); } - } - - public override Builder Clear() { - result = DefaultInstance; - resultIsReadOnly = true; - return this; - } - - public override Builder Clone() { - if (resultIsReadOnly) { - return new Builder(result); - } else { - return new Builder().MergeFrom(result); - } - } - - public override pbd::MessageDescriptor DescriptorForType { - get { return global::Google.ProtocolBuffers.TestProtos.PublicImportMessage.Descriptor; } - } - - public override PublicImportMessage DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.PublicImportMessage.DefaultInstance; } - } - - public override PublicImportMessage BuildPartial() { - if (resultIsReadOnly) { - return result; - } - resultIsReadOnly = true; - return result.MakeReadOnly(); - } - - public override Builder MergeFrom(pb::IMessage other) { - if (other is PublicImportMessage) { - return MergeFrom((PublicImportMessage) other); - } else { - base.MergeFrom(other); - return this; - } - } - - public override Builder MergeFrom(PublicImportMessage other) { - if (other == global::Google.ProtocolBuffers.TestProtos.PublicImportMessage.DefaultInstance) return this; - PrepareBuilder(); - if (other.HasE) { - E = other.E; - } - this.MergeUnknownFields(other.UnknownFields); - return this; - } - - public override Builder MergeFrom(pb::ICodedInputStream input) { - return MergeFrom(input, pb::ExtensionRegistry.Empty); - } - - public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { - PrepareBuilder(); - pb::UnknownFieldSet.Builder unknownFields = null; - uint tag; - string field_name; - while (input.ReadTag(out tag, out field_name)) { - if(tag == 0 && field_name != null) { - int field_ordinal = global::System.Array.BinarySearch(_publicImportMessageFieldNames, field_name, global::System.StringComparer.Ordinal); - if(field_ordinal >= 0) - tag = _publicImportMessageFieldTags[field_ordinal]; - else { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - continue; - } - } - switch (tag) { - case 0: { - throw pb::InvalidProtocolBufferException.InvalidTag(); - } - default: { - if (pb::WireFormat.IsEndGroupTag(tag)) { - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name); - break; - } - case 8: { - result.hasE = input.ReadInt32(ref result.e_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public bool HasE { - get { return result.hasE; } - } - public int E { - get { return result.E; } - set { SetE(value); } - } - public Builder SetE(int value) { - PrepareBuilder(); - result.hasE = true; - result.e_ = value; - return this; - } - public Builder ClearE() { - PrepareBuilder(); - result.hasE = false; - result.e_ = 0; - return this; - } - } - static PublicImportMessage() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.UnittestImportPublic.Descriptor, null); - } - } - - #endregion - -} - -#endregion Designer generated code diff --git a/csharp/src/ProtoBench/app.config b/csharp/src/ProtoBench/app.config deleted file mode 100644 index e2a5a187..00000000 --- a/csharp/src/ProtoBench/app.config +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/csharp/src/ProtoBench/google_message1.dat b/csharp/src/ProtoBench/google_message1.dat deleted file mode 100644 index bc0f064c..00000000 Binary files a/csharp/src/ProtoBench/google_message1.dat and /dev/null differ diff --git a/csharp/src/ProtoBench/google_message2.dat b/csharp/src/ProtoBench/google_message2.dat deleted file mode 100644 index 06c09441..00000000 Binary files a/csharp/src/ProtoBench/google_message2.dat and /dev/null differ diff --git a/csharp/src/ProtoDump/Program.cs b/csharp/src/ProtoDump/Program.cs index a935e780..d2eee9b7 100644 --- a/csharp/src/ProtoDump/Program.cs +++ b/csharp/src/ProtoDump/Program.cs @@ -36,6 +36,7 @@ using System; using System.IO; +using Google.Protobuf; namespace Google.ProtocolBuffers.ProtoDump { @@ -53,36 +54,24 @@ namespace Google.ProtocolBuffers.ProtoDump Console.Error.WriteLine("including assembly e.g. ProjectNamespace.Message,Company.Project"); return 1; } - IMessage defaultMessage; - try + Type type = Type.GetType(args[0]); + if (type == null) { - defaultMessage = MessageUtil.GetDefaultMessage(args[0]); - } - catch (ArgumentException e) - { - Console.Error.WriteLine(e.Message); + Console.Error.WriteLine("Unable to load type {0}.", args[0]); return 1; } - try + if (!typeof(IMessage).IsAssignableFrom(type)) { - IBuilder builder = defaultMessage.WeakCreateBuilderForType(); - if (builder == null) - { - Console.Error.WriteLine("Unable to create builder"); - return 1; - } - byte[] inputData = File.ReadAllBytes(args[1]); - builder.WeakMergeFrom(ByteString.CopyFrom(inputData)); - Console.WriteLine(TextFormat.PrintToString(builder.WeakBuild())); - return 0; + Console.Error.WriteLine("Type {0} doesn't implement IMessage.", args[0]); + return 1; } - catch (Exception e) + IMessage message = (IMessage) Activator.CreateInstance(type); + using (var input = File.OpenRead(args[1])) { - Console.Error.WriteLine("Error: {0}", e.Message); - Console.Error.WriteLine(); - Console.Error.WriteLine("Detailed exception information: {0}", e); - return 1; + message.MergeFrom(input); } + Console.WriteLine(message); + return 0; } } } \ No newline at end of file diff --git a/csharp/src/ProtoMunge/Program.cs b/csharp/src/ProtoMunge/Program.cs deleted file mode 100644 index 6379f30b..00000000 --- a/csharp/src/ProtoMunge/Program.cs +++ /dev/null @@ -1,307 +0,0 @@ -#region Copyright notice and license - -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/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.Collections; -using System.Collections.Generic; -using System.IO; -using Google.Protobuf; -using Google.Protobuf.Descriptors; -using Google.ProtocolBuffers.Descriptors; - -namespace Google.ProtocolBuffers.ProtoMunge -{ - /// - /// Utility console application which takes a message descriptor and a corresponding message, - /// and produces a new message with similar but random data. The data is the same length - /// as the original, but with random values within appropriate bands. (For instance, a compressed - /// integer in the range 0-127 will end up as another integer in the same range, to keep the length - /// the same.) - /// TODO(jonskeet): Potentially refactor to use an instance instead, making it simpler to - /// be thread-safe for external use. - /// - public sealed class Program - { - private static readonly Random rng = new Random(); - - private static int Main(string[] args) - { - if (args.Length != 3) - { - Console.Error.WriteLine("Usage: ProtoMunge "); - Console.Error.WriteLine( - "The descriptor type name is the fully-qualified message name, including assembly."); - Console.Error.WriteLine( - "(At a future date it may be possible to do this without building the .NET assembly at all.)"); - return 1; - } - IMessage defaultMessage; - try - { - defaultMessage = MessageUtil.GetDefaultMessage(args[0]); - } - catch (ArgumentException e) - { - Console.Error.WriteLine(e.Message); - return 1; - } - try - { - IBuilder builder = defaultMessage.WeakCreateBuilderForType(); - byte[] inputData = File.ReadAllBytes(args[1]); - builder.WeakMergeFrom(ByteString.CopyFrom(inputData)); - IMessage original = builder.WeakBuild(); - IMessage munged = Munge(original); - if (original.SerializedSize != munged.SerializedSize) - { - throw new Exception("Serialized sizes don't match"); - } - File.WriteAllBytes(args[2], munged.ToByteArray()); - return 0; - } - catch (Exception e) - { - Console.Error.WriteLine("Error: {0}", e.Message); - Console.Error.WriteLine(); - Console.Error.WriteLine("Detailed exception information: {0}", e); - return 1; - } - } - - /// - /// Munges a message recursively. - /// - /// A new message of the same type as the original message, - /// but munged so that all the data is desensitised. - private static IMessage Munge(IMessage message) - { - IBuilder builder = message.WeakCreateBuilderForType(); - foreach (var pair in message.AllFields) - { - if (pair.Key.IsRepeated) - { - foreach (object singleValue in (IEnumerable) pair.Value) - { - builder.WeakAddRepeatedField(pair.Key, CheckedMungeValue(pair.Key, singleValue)); - } - } - else - { - builder[pair.Key] = CheckedMungeValue(pair.Key, pair.Value); - } - } - IMessage munged = builder.WeakBuild(); - if (message.SerializedSize != munged.SerializedSize) - { - Console.WriteLine("Sub message sizes: {0}/{1}", message.SerializedSize, munged.SerializedSize); - } - return munged; - } - - /// - /// Munges a single value and checks that the length ends up the same as it was before. - /// - private static object CheckedMungeValue(FieldDescriptor fieldDescriptor, object value) - { - int currentSize = CodedOutputStream.ComputeFieldSize(fieldDescriptor.FieldType, fieldDescriptor.FieldNumber, - value); - object mungedValue = MungeValue(fieldDescriptor, value); - int mungedSize = CodedOutputStream.ComputeFieldSize(fieldDescriptor.FieldType, fieldDescriptor.FieldNumber, - mungedValue); - // Exceptions log more easily than assertions - if (currentSize != mungedSize) - { - throw new Exception("Munged value had wrong size. Field type: " + fieldDescriptor.FieldType - + "; old value: " + value + "; new value: " + mungedValue); - } - return mungedValue; - } - - /// - /// Munges a single value of the specified field descriptor. (i.e. if the field is - /// actually a repeated int, this method receives a single int value to munge, and - /// is called multiple times). - /// - private static object MungeValue(FieldDescriptor fieldDescriptor, object value) - { - switch (fieldDescriptor.FieldType) - { - case FieldType.SInt64: - case FieldType.Int64: - return (long) MungeVarint64((ulong) (long) value); - case FieldType.UInt64: - return MungeVarint64((ulong) value); - case FieldType.SInt32: - return (int) MungeVarint32((uint) (int) value); - case FieldType.Int32: - return MungeInt32((int) value); - case FieldType.UInt32: - return MungeVarint32((uint) value); - case FieldType.Double: - return rng.NextDouble(); - case FieldType.Float: - return (float) rng.NextDouble(); - case FieldType.Fixed64: - { - byte[] data = new byte[8]; - rng.NextBytes(data); - return BitConverter.ToUInt64(data, 0); - } - case FieldType.Fixed32: - { - byte[] data = new byte[4]; - rng.NextBytes(data); - return BitConverter.ToUInt32(data, 0); - } - case FieldType.Bool: - return rng.Next(2) == 1; - case FieldType.String: - return MungeString((string) value); - case FieldType.Group: - case FieldType.Message: - return Munge((IMessage) value); - case FieldType.Bytes: - return MungeByteString((ByteString) value); - case FieldType.SFixed64: - { - byte[] data = new byte[8]; - rng.NextBytes(data); - return BitConverter.ToInt64(data, 0); - } - case FieldType.SFixed32: - { - byte[] data = new byte[4]; - rng.NextBytes(data); - return BitConverter.ToInt32(data, 0); - } - case FieldType.Enum: - return MungeEnum(fieldDescriptor, (EnumValueDescriptor) value); - default: - // TODO(jonskeet): Different exception? - throw new ArgumentException("Invalid field descriptor"); - } - } - - private static object MungeString(string original) - { - foreach (char c in original) - { - if (c > 127) - { - throw new ArgumentException("Can't handle non-ascii yet"); - } - } - char[] chars = new char[original.Length]; - // Convert to pure ASCII - no control characters. - for (int i = 0; i < chars.Length; i++) - { - chars[i] = (char) rng.Next(32, 127); - } - return new string(chars); - } - - /// - /// Int32 fields are slightly strange - we need to keep the sign the same way it is: - /// negative numbers can munge to any other negative number (it'll always take - /// 10 bytes) but positive numbers have to stay positive, so we can't use the - /// full range of 32 bits. - /// - private static int MungeInt32(int value) - { - if (value < 0) - { - return rng.Next(int.MinValue, 0); - } - int length = CodedOutputStream.ComputeRawVarint32Size((uint) value); - uint min = length == 1 ? 0 : 1U << ((length - 1)*7); - uint max = length == 5 ? int.MaxValue : (1U << (length*7)) - 1; - return (int) NextRandomUInt64(min, max); - } - - private static uint MungeVarint32(uint original) - { - int length = CodedOutputStream.ComputeRawVarint32Size(original); - uint min = length == 1 ? 0 : 1U << ((length - 1)*7); - uint max = length == 5 ? uint.MaxValue : (1U << (length*7)) - 1; - return (uint) NextRandomUInt64(min, max); - } - - private static ulong MungeVarint64(ulong original) - { - int length = CodedOutputStream.ComputeRawVarint64Size(original); - ulong min = length == 1 ? 0 : 1UL << ((length - 1)*7); - ulong max = length == 10 ? ulong.MaxValue : (1UL << (length*7)) - 1; - return NextRandomUInt64(min, max); - } - - /// - /// Returns a random number in the range [min, max] (both inclusive). - /// - private static ulong NextRandomUInt64(ulong min, ulong max) - { - if (min > max) - { - throw new ArgumentException("min must be <= max; min=" + min + "; max = " + max); - } - ulong range = max - min; - // This isn't actually terribly good at very large ranges - but it doesn't really matter for the sake - // of this program. - return min + (ulong) (range*rng.NextDouble()); - } - - private static object MungeEnum(FieldDescriptor fieldDescriptor, EnumValueDescriptor original) - { - // Find all the values which get encoded to the same size as the current value, and pick one at random - int originalSize = CodedOutputStream.ComputeRawVarint32Size((uint) original.Number); - List sameSizeValues = new List(); - foreach (EnumValueDescriptor candidate in fieldDescriptor.EnumType.Values) - { - if (CodedOutputStream.ComputeRawVarint32Size((uint) candidate.Number) == originalSize) - { - sameSizeValues.Add(candidate); - } - } - return sameSizeValues[rng.Next(sameSizeValues.Count)]; - } - - private static object MungeByteString(ByteString byteString) - { - byte[] data = new byte[byteString.Length]; - rng.NextBytes(data); - return ByteString.CopyFrom(data); - } - } -} \ No newline at end of file diff --git a/csharp/src/ProtoMunge/Properties/AssemblyInfo.cs b/csharp/src/ProtoMunge/Properties/AssemblyInfo.cs deleted file mode 100644 index b78271b9..00000000 --- a/csharp/src/ProtoMunge/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. - -[assembly: AssemblyTitle("ProtoMunge")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("ProtoMunge")] -[assembly: AssemblyCopyright("Copyright © 2008")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("2.4.1.555")] - -[assembly: AssemblyVersion("2.4.1.555")] -[assembly: AssemblyFileVersion("2.4.1.555")] \ No newline at end of file diff --git a/csharp/src/ProtoMunge/ProtoMunge.csproj b/csharp/src/ProtoMunge/ProtoMunge.csproj deleted file mode 100644 index 60c907b1..00000000 --- a/csharp/src/ProtoMunge/ProtoMunge.csproj +++ /dev/null @@ -1,67 +0,0 @@ - - - - CLIENTPROFILE - NET35 - Debug - AnyCPU - 9.0.30729 - 2.0 - {8F09AF72-3327-4FA7-BC09-070B80221AB9} - Exe - Properties - Google.ProtocolBuffers.ProtoMunge - ProtoMunge - v4.0 - 512 - Client - - - true - full - false - bin\Debug - obj\Debug\ - DEBUG;TRACE - prompt - 4 - true - Off - - - pdbonly - true - bin\Release - obj\Release\ - TRACE - prompt - 4 - true - Off - - - - - - - - - - - - {6908BDCE-D925-43F3-94AC-A531E6DF2591} - ProtocolBuffers - - - - - - - - \ No newline at end of file diff --git a/csharp/src/ProtoMunge/app.config b/csharp/src/ProtoMunge/app.config deleted file mode 100644 index e2a5a187..00000000 --- a/csharp/src/ProtoMunge/app.config +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/csharp/src/ProtocolBuffers.Test/ByteStringTest.cs b/csharp/src/ProtocolBuffers.Test/ByteStringTest.cs index f7ddb23f..0edd149b 100644 --- a/csharp/src/ProtocolBuffers.Test/ByteStringTest.cs +++ b/csharp/src/ProtocolBuffers.Test/ByteStringTest.cs @@ -40,7 +40,6 @@ using NUnit.Framework; namespace Google.Protobuf { - [TestFixture] public class ByteStringTest { [Test] diff --git a/csharp/src/ProtocolBuffers.sln b/csharp/src/ProtocolBuffers.sln index 7413122f..c5708fd5 100644 --- a/csharp/src/ProtocolBuffers.sln +++ b/csharp/src/ProtocolBuffers.sln @@ -10,10 +10,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AddressBook", "AddressBook\ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProtoDump", "ProtoDump\ProtoDump.csproj", "{D7282E99-2DC3-405B-946F-177DB2FD2AE2}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProtoMunge", "ProtoMunge\ProtoMunge.csproj", "{8F09AF72-3327-4FA7-BC09-070B80221AB9}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProtoBench", "ProtoBench\ProtoBench.csproj", "{C7A4A435-2813-41C8-AA87-BD914BA5223D}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -36,14 +32,6 @@ Global {D7282E99-2DC3-405B-946F-177DB2FD2AE2}.Debug|Any CPU.Build.0 = Debug|Any CPU {D7282E99-2DC3-405B-946F-177DB2FD2AE2}.Release|Any CPU.ActiveCfg = Release|Any CPU {D7282E99-2DC3-405B-946F-177DB2FD2AE2}.Release|Any CPU.Build.0 = Release|Any CPU - {8F09AF72-3327-4FA7-BC09-070B80221AB9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8F09AF72-3327-4FA7-BC09-070B80221AB9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8F09AF72-3327-4FA7-BC09-070B80221AB9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8F09AF72-3327-4FA7-BC09-070B80221AB9}.Release|Any CPU.Build.0 = Release|Any CPU - {C7A4A435-2813-41C8-AA87-BD914BA5223D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C7A4A435-2813-41C8-AA87-BD914BA5223D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C7A4A435-2813-41C8-AA87-BD914BA5223D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C7A4A435-2813-41C8-AA87-BD914BA5223D}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE -- cgit v1.2.3 From aa5104143cca3bf3e9f44a79f96e394960f45662 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Thu, 25 Jun 2015 16:42:09 +0100 Subject: Remove a lot of code which wasn't needed any more. --- csharp/src/ProtocolBuffers.Test/DescriptorsTest.cs | 5 - .../ProtocolBuffers.Test.csproj | 1 - csharp/src/ProtocolBuffers.Test/WireFormatTest.cs | 60 ------- csharp/src/ProtocolBuffers/ByteArray.cs | 18 +- csharp/src/ProtocolBuffers/ByteString.cs | 32 ---- .../ProtocolBuffers/Collections/Dictionaries.cs | 122 -------------- .../src/ProtocolBuffers/Collections/Enumerables.cs | 74 -------- csharp/src/ProtocolBuffers/Collections/Lists.cs | 110 ------------ .../ProtocolBuffers/Collections/RepeatedField.cs | 10 ++ .../Collections/RepeatedFieldExtensions.cs | 47 ------ .../ProtocolBuffers/Descriptors/DescriptorUtil.cs | 4 +- .../ProtocolBuffers/Descriptors/FieldDescriptor.cs | 186 ++------------------- .../Descriptors/FieldMappingAttribute.cs | 85 ---------- .../src/ProtocolBuffers/Descriptors/FieldType.cs | 36 ++-- .../ProtocolBuffers/Descriptors/FileDescriptor.cs | 65 +------ .../src/ProtocolBuffers/Descriptors/MappedType.cs | 52 ------ .../Descriptors/MessageDescriptor.cs | 106 +----------- .../FieldAccess/FieldAccessorTable.cs | 7 - csharp/src/ProtocolBuffers/ProtocolBuffers.csproj | 7 - csharp/src/ProtocolBuffers/TextGenerator.cs | 159 ------------------ csharp/src/ProtocolBuffers/ThrowHelper.cs | 26 --- csharp/src/ProtocolBuffers/WireFormat.cs | 1 - 22 files changed, 59 insertions(+), 1154 deletions(-) delete mode 100644 csharp/src/ProtocolBuffers.Test/WireFormatTest.cs delete mode 100644 csharp/src/ProtocolBuffers/Collections/Dictionaries.cs delete mode 100644 csharp/src/ProtocolBuffers/Collections/Enumerables.cs delete mode 100644 csharp/src/ProtocolBuffers/Collections/Lists.cs delete mode 100644 csharp/src/ProtocolBuffers/Collections/RepeatedFieldExtensions.cs delete mode 100644 csharp/src/ProtocolBuffers/Descriptors/FieldMappingAttribute.cs delete mode 100644 csharp/src/ProtocolBuffers/Descriptors/MappedType.cs delete mode 100644 csharp/src/ProtocolBuffers/TextGenerator.cs diff --git a/csharp/src/ProtocolBuffers.Test/DescriptorsTest.cs b/csharp/src/ProtocolBuffers.Test/DescriptorsTest.cs index 8c01e16a..fbbdce28 100644 --- a/csharp/src/ProtocolBuffers.Test/DescriptorsTest.cs +++ b/csharp/src/ProtocolBuffers.Test/DescriptorsTest.cs @@ -147,17 +147,14 @@ namespace Google.Protobuf Assert.AreEqual(messageType, primitiveField.ContainingType); Assert.AreEqual(UnittestProto3.Descriptor, primitiveField.File); Assert.AreEqual(FieldType.Int32, primitiveField.FieldType); - Assert.AreEqual(MappedType.Int32, primitiveField.MappedType); Assert.IsNull(primitiveField.Options); Assert.AreEqual("single_nested_enum", enumField.Name); Assert.AreEqual(FieldType.Enum, enumField.FieldType); - Assert.AreEqual(MappedType.Enum, enumField.MappedType); // Assert.AreEqual(TestAllTypes.Types.NestedEnum.DescriptorProtoFile, enumField.EnumType); Assert.AreEqual("single_foreign_message", messageField.Name); Assert.AreEqual(FieldType.Message, messageField.FieldType); - Assert.AreEqual(MappedType.Message, messageField.MappedType); Assert.AreEqual(ForeignMessage.Descriptor, messageField.MessageType); } @@ -169,9 +166,7 @@ namespace Google.Protobuf FieldDescriptor repeatedField = TestAllTypes.Descriptor.FindDescriptor("repeated_int32"); - Assert.IsFalse(singleField.IsRequired); Assert.IsFalse(singleField.IsRepeated); - Assert.IsFalse(repeatedField.IsRequired); Assert.IsTrue(repeatedField.IsRepeated); } diff --git a/csharp/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj b/csharp/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj index e90be51d..80b504aa 100644 --- a/csharp/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj +++ b/csharp/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj @@ -89,7 +89,6 @@ - diff --git a/csharp/src/ProtocolBuffers.Test/WireFormatTest.cs b/csharp/src/ProtocolBuffers.Test/WireFormatTest.cs deleted file mode 100644 index dc112565..00000000 --- a/csharp/src/ProtocolBuffers.Test/WireFormatTest.cs +++ /dev/null @@ -1,60 +0,0 @@ -#region Copyright notice and license - -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/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.Reflection; -using Google.Protobuf.Descriptors; -using NUnit.Framework; - -namespace Google.Protobuf -{ - public class WireFormatTest - { - /// - /// Keeps the attributes on FieldType and the switch statement in WireFormat in sync. - /// - [Test] - public void FieldTypeToWireTypeMapping() - { - foreach (FieldInfo field in typeof(FieldType).GetFields(BindingFlags.Static | BindingFlags.Public)) - { - FieldType fieldType = (FieldType) field.GetValue(null); - FieldMappingAttribute mapping = - (FieldMappingAttribute) field.GetCustomAttributes(typeof(FieldMappingAttribute), false)[0]; - Assert.AreEqual(mapping.WireType, WireFormat.GetWireType(fieldType)); - } - } - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/ByteArray.cs b/csharp/src/ProtocolBuffers/ByteArray.cs index 211a0e11..14e2744a 100644 --- a/csharp/src/ProtocolBuffers/ByteArray.cs +++ b/csharp/src/ProtocolBuffers/ByteArray.cs @@ -59,19 +59,11 @@ namespace Google.Protobuf } else { - ByteCopy(src, srcOffset, dst, dstOffset, count); - } - } - - /// - /// Copy the bytes provided with a for loop, faster when there are only a few bytes to copy - /// - internal static void ByteCopy(byte[] src, int srcOffset, byte[] dst, int dstOffset, int count) - { - int stop = srcOffset + count; - for (int i = srcOffset; i < stop; i++) - { - dst[dstOffset++] = src[i]; + int stop = srcOffset + count; + for (int i = srcOffset; i < stop; i++) + { + dst[dstOffset++] = src[i]; + } } } diff --git a/csharp/src/ProtocolBuffers/ByteString.cs b/csharp/src/ProtocolBuffers/ByteString.cs index e3a7ee50..a4afc5e2 100644 --- a/csharp/src/ProtocolBuffers/ByteString.cs +++ b/csharp/src/ProtocolBuffers/ByteString.cs @@ -264,38 +264,6 @@ namespace Google.Protobuf return true; } - /// - /// Builder for ByteStrings which allows them to be created without extra - /// copying being involved. This has to be a nested type in order to have access - /// to the private ByteString constructor. - /// - internal sealed class CodedBuilder - { - private readonly CodedOutputStream output; - private readonly byte[] buffer; - - internal CodedBuilder(int size) - { - buffer = new byte[size]; - output = CodedOutputStream.CreateInstance(buffer); - } - - internal ByteString Build() - { - output.CheckNoSpaceLeft(); - - // We can be confident that the CodedOutputStream will not modify the - // underlying bytes anymore because it already wrote all of them. So, - // no need to make a copy. - return new ByteString(buffer); - } - - internal CodedOutputStream CodedOutput - { - get { return output; } - } - } - /// /// Used internally by CodedOutputStream to avoid creating a copy for the write /// diff --git a/csharp/src/ProtocolBuffers/Collections/Dictionaries.cs b/csharp/src/ProtocolBuffers/Collections/Dictionaries.cs deleted file mode 100644 index 22fe90a6..00000000 --- a/csharp/src/ProtocolBuffers/Collections/Dictionaries.cs +++ /dev/null @@ -1,122 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/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. -using System; -using System.Collections; -using System.Collections.Generic; - -namespace Google.Protobuf.Collections -{ - /// - /// Utility class for dictionaries. - /// - public static class Dictionaries - { - /// - /// Compares two dictionaries for equality. Each value is compared with equality using Equals - /// for non-IEnumerable implementations, and using EnumerableEquals otherwise. - /// TODO(jonskeet): This is clearly pretty slow, and involves lots of boxing/unboxing... - /// - public static bool Equals(IDictionary left, IDictionary right) - { - if (left.Count != right.Count) - { - return false; - } - foreach (KeyValuePair leftEntry in left) - { - TValue rightValue; - if (!right.TryGetValue(leftEntry.Key, out rightValue)) - { - return false; - } - - IEnumerable leftEnumerable = leftEntry.Value as IEnumerable; - IEnumerable rightEnumerable = rightValue as IEnumerable; - if (leftEnumerable == null || rightEnumerable == null) - { - if (!Equals(leftEntry.Value, rightValue)) - { - return false; - } - } - else - { - if (!Enumerables.Equals(leftEnumerable, rightEnumerable)) - { - return false; - } - } - } - return true; - } - - public static IDictionary AsReadOnly(IDictionary dictionary) - { - return dictionary.IsReadOnly ? dictionary : new ReadOnlyDictionary(dictionary); - } - - /// - /// Creates a hashcode for a dictionary by XORing the hashcodes of all the fields - /// and values. (By XORing, we avoid ordering issues.) - /// TODO(jonskeet): Currently XORs other stuff too, and assumes non-null values. - /// - public static int GetHashCode(IDictionary dictionary) - { - int ret = 31; - foreach (KeyValuePair entry in dictionary) - { - int hash = entry.Key.GetHashCode() ^ GetDeepHashCode(entry.Value); - ret ^= hash; - } - return ret; - } - - /// - /// Determines the hash of a value by either taking it directly or hashing all the elements - /// for IEnumerable implementations. - /// - private static int GetDeepHashCode(object value) - { - IEnumerable iterable = value as IEnumerable; - if (iterable == null) - { - return value.GetHashCode(); - } - int hash = 29; - foreach (object element in iterable) - { - hash = hash*37 + element.GetHashCode(); - } - return hash; - } - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/Collections/Enumerables.cs b/csharp/src/ProtocolBuffers/Collections/Enumerables.cs deleted file mode 100644 index 217aefd7..00000000 --- a/csharp/src/ProtocolBuffers/Collections/Enumerables.cs +++ /dev/null @@ -1,74 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/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. -using System; -using System.Collections; - -namespace Google.Protobuf.Collections -{ - /// - /// Utility class for IEnumerable (and potentially the generic version in the future). - /// - public static class Enumerables - { - public static bool Equals(IEnumerable left, IEnumerable right) - { - IEnumerator leftEnumerator = left.GetEnumerator(); - try - { - foreach (object rightObject in right) - { - if (!leftEnumerator.MoveNext()) - { - return false; - } - if (!Equals(leftEnumerator.Current, rightObject)) - { - return false; - } - } - if (leftEnumerator.MoveNext()) - { - return false; - } - } - finally - { - IDisposable leftEnumeratorDisposable = leftEnumerator as IDisposable; - if (leftEnumeratorDisposable != null) - { - leftEnumeratorDisposable.Dispose(); - } - } - return true; - } - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/Collections/Lists.cs b/csharp/src/ProtocolBuffers/Collections/Lists.cs deleted file mode 100644 index cf681767..00000000 --- a/csharp/src/ProtocolBuffers/Collections/Lists.cs +++ /dev/null @@ -1,110 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/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. -using System.Collections.Generic; -using System.Collections.ObjectModel; - -namespace Google.Protobuf.Collections -{ - /// - /// Utility non-generic class for calling into Lists{T} using type inference. - /// - public static class Lists - { - /// - /// Returns a read-only view of the specified list. - /// - public static IList AsReadOnly(IList list) - { - return Lists.AsReadOnly(list); - } - - public static bool Equals(IList left, IList right) - { - if (left == right) - { - return true; - } - if (left == null || right == null) - { - return false; - } - if (left.Count != right.Count) - { - return false; - } - IEqualityComparer comparer = EqualityComparer.Default; - for (int i = 0; i < left.Count; i++) - { - if (!comparer.Equals(left[i], right[i])) - { - return false; - } - } - return true; - } - - public static int GetHashCode(IList list) - { - int hash = 31; - foreach (T element in list) - { - hash = hash*29 + element.GetHashCode(); - } - return hash; - } - } - - /// - /// Utility class for dealing with lists. - /// - public static class Lists - { - private static readonly ReadOnlyCollection empty = new ReadOnlyCollection(new T[0]); - - /// - /// Returns an immutable empty list. - /// - public static ReadOnlyCollection Empty - { - get { return empty; } - } - - /// - /// Returns either the original reference if it's already read-only, - /// or a new ReadOnlyCollection wrapping the original list. - /// - public static IList AsReadOnly(IList list) - { - return list.IsReadOnly ? list : new ReadOnlyCollection(list); - } - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs b/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs index 4d4212cb..39d4f351 100644 --- a/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs +++ b/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs @@ -298,6 +298,16 @@ namespace Google.Protobuf.Collections } } + internal uint CalculateSize(Func sizeComputer) + { + int size = 0; + for (int i = 0; i < count; i++) + { + size += sizeComputer(array[i]); + } + return (uint)size; + } + public struct Enumerator : IEnumerator { private int index; diff --git a/csharp/src/ProtocolBuffers/Collections/RepeatedFieldExtensions.cs b/csharp/src/ProtocolBuffers/Collections/RepeatedFieldExtensions.cs deleted file mode 100644 index c5a934a1..00000000 --- a/csharp/src/ProtocolBuffers/Collections/RepeatedFieldExtensions.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Google.Protobuf.Collections -{ - public static class RepeatedFieldExtensions - { - internal static uint CalculateSize(this RepeatedField list, Func sizeComputer) - { - int size = 0; - foreach (var item in list) - { - size += sizeComputer(item); - } - return (uint)size; - } - - /* - /// - /// Calculates the serialized data size, including one tag per value. - /// - public static int CalculateTotalSize(this RepeatedField list, int tagSize, Func sizeComputer) - { - if (list.Count == 0) - { - return 0; - } - return (int)(dataSize + tagSize * list.Count); - } - - /// - /// Calculates the serialized data size, as a packed array (tag, length, data). - /// - public static int CalculateTotalPackedSize(int tagSize) - { - if (Count == 0) - { - return 0; - } - uint dataSize = CalculateSize(); - return tagSize + CodedOutputStream.ComputeRawVarint32Size(dataSize) + (int)dataSize; - } - */ - } -} diff --git a/csharp/src/ProtocolBuffers/Descriptors/DescriptorUtil.cs b/csharp/src/ProtocolBuffers/Descriptors/DescriptorUtil.cs index 9fc84c3e..db3e21f5 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/DescriptorUtil.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/DescriptorUtil.cs @@ -30,7 +30,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. using System.Collections.Generic; -using Google.Protobuf.Collections; +using System.Collections.ObjectModel; namespace Google.Protobuf.Descriptors { @@ -58,7 +58,7 @@ namespace Google.Protobuf.Descriptors { array[i] = converter(input[i], i); } - return Lists.AsReadOnly(array); + return new ReadOnlyCollection(array); } } } \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs index c7d2e683..9605ee9a 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs @@ -43,24 +43,21 @@ namespace Google.Protobuf.Descriptors public sealed class FieldDescriptor : IndexedDescriptorBase, IComparable { - private readonly MessageDescriptor extensionScope; private EnumDescriptor enumType; private MessageDescriptor messageType; private MessageDescriptor containingType; private OneofDescriptor containingOneof; private FieldType fieldType; - private MappedType mappedType; private readonly object optionsLock = new object(); internal FieldDescriptor(FieldDescriptorProto proto, FileDescriptor file, - MessageDescriptor parent, int index, bool isExtension) + MessageDescriptor parent, int index) : base(proto, file, ComputeFullName(file, parent, proto.Name), index) { if (proto.Type != 0) { fieldType = GetFieldTypeFromProtoType(proto.Type); - mappedType = FieldTypeToMappedTypeMap[fieldType]; } if (FieldNumber <= 0) @@ -68,38 +65,16 @@ namespace Google.Protobuf.Descriptors throw new DescriptorValidationException(this, "Field numbers must be positive integers."); } - - if (isExtension) + containingType = parent; + if (proto.OneofIndex != 0) { - if (proto.Extendee != "") + if (proto.OneofIndex < 0 || proto.OneofIndex >= parent.Proto.OneofDecl.Count) { throw new DescriptorValidationException(this, - "FieldDescriptorProto.Extendee not set for extension field."); - } - containingType = null; // Will be filled in when cross-linking - if (parent != null) - { - extensionScope = parent; - } - else - { - extensionScope = null; + "FieldDescriptorProto.oneof_index is out of range for type " + parent.Name); } - } - else - { - containingType = parent; - if (proto.OneofIndex != 0) - { - if (proto.OneofIndex < 0 || proto.OneofIndex >= parent.Proto.OneofDecl.Count) - { - throw new DescriptorValidationException(this, - "FieldDescriptorProto.oneof_index is out of range for type " + parent.Name); - } - containingOneof = parent.Oneofs[proto.OneofIndex]; - containingOneof.fieldCount ++; - } - extensionScope = null; + containingOneof = parent.Oneofs[proto.OneofIndex]; + containingOneof.fieldCount ++; } file.DescriptorPool.AddSymbol(this); @@ -151,51 +126,7 @@ namespace Google.Protobuf.Descriptors default: throw new ArgumentException("Invalid type specified"); } - } - - /// - /// Returns the default value for a mapped type. - /// - private static object GetDefaultValueForMappedType(MappedType type) - { - switch (type) - { - case MappedType.Int32: - return 0; - case MappedType.Int64: - return (long) 0; - case MappedType.UInt32: - return (uint) 0; - case MappedType.UInt64: - return (ulong) 0; - case MappedType.Single: - return (float) 0; - case MappedType.Double: - return (double) 0; - case MappedType.Boolean: - return false; - case MappedType.String: - return ""; - case MappedType.ByteString: - return ByteString.Empty; - case MappedType.Message: - return null; - case MappedType.Enum: - return null; - default: - throw new ArgumentException("Invalid type specified"); - } - } - - public bool IsRequired - { - get { return Proto.Label == FieldDescriptorProto.Types.Label.LABEL_REQUIRED; } - } - - public bool IsOptional - { - get { return Proto.Label == FieldDescriptorProto.Types.Label.LABEL_OPTIONAL; } - } + } public bool IsRepeated { @@ -205,16 +136,7 @@ namespace Google.Protobuf.Descriptors public bool IsPacked { get { return Proto.Options.Packed; } - } - - /// - /// Indicates whether or not this field is an extension. (Only relevant when parsing - /// the proto2 descriptor...) - /// - internal bool IsExtension - { - get { return Proto.Extendee != ""; } - } + } /// /// Get the field's containing type. For extensions, this is the type being @@ -229,46 +151,7 @@ namespace Google.Protobuf.Descriptors public OneofDescriptor ContainingOneof { get { return containingOneof; } - } - - /// - /// For extensions defined nested within message types, gets - /// the outer type. Not valid for non-extension fields. - /// - /// - /// - /// message Foo { - /// extensions 1000 to max; - /// } - /// extend Foo { - /// optional int32 baz = 1234; - /// } - /// message Bar { - /// extend Foo { - /// optional int32 qux = 4321; - /// } - /// } - /// - /// The containing type for both baz and qux is Foo. - /// However, the extension scope for baz is null while - /// the extension scope for qux is Bar. - /// - public MessageDescriptor ExtensionScope - { - get - { - if (!IsExtension) - { - throw new InvalidOperationException("This field is not an extension."); - } - return extensionScope; - } - } - - public MappedType MappedType - { - get { return mappedType; } - } + } public FieldType FieldType { @@ -303,7 +186,7 @@ namespace Google.Protobuf.Descriptors { get { - if (MappedType != MappedType.Enum) + if (fieldType != FieldType.Enum) { throw new InvalidOperationException("EnumType is only valid for enum fields."); } @@ -318,7 +201,7 @@ namespace Google.Protobuf.Descriptors { get { - if (MappedType != MappedType.Message) + if (fieldType != FieldType.Message) { throw new InvalidOperationException("MessageType is only valid for enum fields."); } @@ -326,25 +209,6 @@ namespace Google.Protobuf.Descriptors } } - /// - /// Immutable mapping from field type to mapped type. Built using the attributes on - /// FieldType values. - /// - public static readonly IDictionary FieldTypeToMappedTypeMap = MapFieldTypes(); - - private static IDictionary MapFieldTypes() - { - var map = new Dictionary(); - foreach (FieldInfo field in typeof(FieldType).GetFields(BindingFlags.Static | BindingFlags.Public)) - { - FieldType fieldType = (FieldType) field.GetValue(null); - FieldMappingAttribute mapping = - (FieldMappingAttribute) field.GetCustomAttributes(typeof(FieldMappingAttribute), false)[0]; - map[fieldType] = mapping.MappedType; - } - return Dictionaries.AsReadOnly(map); - } - /// /// Look up and cross-link all field types etc. /// @@ -361,12 +225,10 @@ namespace Google.Protobuf.Descriptors if (typeDescriptor is MessageDescriptor) { fieldType = FieldType.Message; - mappedType = MappedType.Message; } else if (typeDescriptor is EnumDescriptor) { fieldType = FieldType.Enum; - mappedType = MappedType.Enum; } else { @@ -374,7 +236,7 @@ namespace Google.Protobuf.Descriptors } } - if (MappedType == MappedType.Message) + if (fieldType == FieldType.Message) { if (!(typeDescriptor is MessageDescriptor)) { @@ -388,7 +250,7 @@ namespace Google.Protobuf.Descriptors throw new DescriptorValidationException(this, "Messages can't have default values."); } } - else if (MappedType == Descriptors.MappedType.Enum) + else if (fieldType == FieldType.Enum) { if (!(typeDescriptor is EnumDescriptor)) { @@ -403,7 +265,7 @@ namespace Google.Protobuf.Descriptors } else { - if (MappedType == MappedType.Message || MappedType == MappedType.Enum) + if (fieldType == FieldType.Message || fieldType == FieldType.Enum) { throw new DescriptorValidationException(this, "Field with message or enum type missing type_name."); } @@ -411,25 +273,11 @@ namespace Google.Protobuf.Descriptors // Note: no attempt to perform any default value parsing - if (!IsExtension) - { - File.DescriptorPool.AddFieldByNumber(this); - } + File.DescriptorPool.AddFieldByNumber(this); if (containingType != null && containingType.Options != null && containingType.Options.MessageSetWireFormat) { - if (IsExtension) - { - if (!IsOptional || FieldType != FieldType.Message) - { - throw new DescriptorValidationException(this, - "Extensions of MessageSets must be optional messages."); - } - } - else - { - throw new DescriptorValidationException(this, "MessageSets cannot have fields, only extensions."); - } + throw new DescriptorValidationException(this, "MessageSet format is not supported."); } } } diff --git a/csharp/src/ProtocolBuffers/Descriptors/FieldMappingAttribute.cs b/csharp/src/ProtocolBuffers/Descriptors/FieldMappingAttribute.cs deleted file mode 100644 index ab15eb01..00000000 --- a/csharp/src/ProtocolBuffers/Descriptors/FieldMappingAttribute.cs +++ /dev/null @@ -1,85 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/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. -using System; -using System.Collections.Generic; -using System.Reflection; -using Google.Protobuf.Collections; - -namespace Google.Protobuf.Descriptors -{ - /// - /// Defined specifically for the enumeration, - /// this allows each field type to specify the mapped type and wire type. - /// - [AttributeUsage(AttributeTargets.Field)] - public sealed class FieldMappingAttribute : Attribute - { - public FieldMappingAttribute(MappedType mappedType, WireFormat.WireType wireType) - { - MappedType = mappedType; - WireType = wireType; - } - - public MappedType MappedType { get; private set; } - public WireFormat.WireType WireType { get; private set; } - - - /// - /// Immutable mapping from field type to mapped type. Built using the attributes on - /// FieldType values. - /// - private static readonly IDictionary FieldTypeToMappedTypeMap = MapFieldTypes(); - - private static IDictionary MapFieldTypes() - { - var map = new Dictionary(); - foreach (FieldInfo field in typeof(FieldType).GetFields(BindingFlags.Static | BindingFlags.Public)) - { - FieldType fieldType = (FieldType) field.GetValue(null); - FieldMappingAttribute mapping = - (FieldMappingAttribute) field.GetCustomAttributes(typeof(FieldMappingAttribute), false)[0]; - map[fieldType] = mapping; - } - return Dictionaries.AsReadOnly(map); - } - - internal static MappedType MappedTypeFromFieldType(FieldType type) - { - return FieldTypeToMappedTypeMap[type].MappedType; - } - - internal static WireFormat.WireType WireTypeFromFieldType(FieldType type, bool packed) - { - return packed ? WireFormat.WireType.LengthDelimited : FieldTypeToMappedTypeMap[type].WireType; - } - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/Descriptors/FieldType.cs b/csharp/src/ProtocolBuffers/Descriptors/FieldType.cs index f7ec898e..628a6f78 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/FieldType.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/FieldType.cs @@ -38,23 +38,23 @@ namespace Google.Protobuf.Descriptors /// public enum FieldType { - [FieldMapping(MappedType.Double, WireFormat.WireType.Fixed64)] Double, - [FieldMapping(MappedType.Single, WireFormat.WireType.Fixed32)] Float, - [FieldMapping(MappedType.Int64, WireFormat.WireType.Varint)] Int64, - [FieldMapping(MappedType.UInt64, WireFormat.WireType.Varint)] UInt64, - [FieldMapping(MappedType.Int32, WireFormat.WireType.Varint)] Int32, - [FieldMapping(MappedType.UInt64, WireFormat.WireType.Fixed64)] Fixed64, - [FieldMapping(MappedType.UInt32, WireFormat.WireType.Fixed32)] Fixed32, - [FieldMapping(MappedType.Boolean, WireFormat.WireType.Varint)] Bool, - [FieldMapping(MappedType.String, WireFormat.WireType.LengthDelimited)] String, - [FieldMapping(MappedType.Message, WireFormat.WireType.StartGroup)] Group, - [FieldMapping(MappedType.Message, WireFormat.WireType.LengthDelimited)] Message, - [FieldMapping(MappedType.ByteString, WireFormat.WireType.LengthDelimited)] Bytes, - [FieldMapping(MappedType.UInt32, WireFormat.WireType.Varint)] UInt32, - [FieldMapping(MappedType.Int32, WireFormat.WireType.Fixed32)] SFixed32, - [FieldMapping(MappedType.Int64, WireFormat.WireType.Fixed64)] SFixed64, - [FieldMapping(MappedType.Int32, WireFormat.WireType.Varint)] SInt32, - [FieldMapping(MappedType.Int64, WireFormat.WireType.Varint)] SInt64, - [FieldMapping(MappedType.Enum, WireFormat.WireType.Varint)] Enum + Double, + Float, + Int64, + UInt64, + Int32, + Fixed64, + Fixed32, + Bool, + String, + Group, + Message, + Bytes, + UInt32, + SFixed32, + SFixed64, + SInt32, + SInt64, + Enum } } \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/Descriptors/FileDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/FileDescriptor.cs index 164406f9..5c933818 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/FileDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/FileDescriptor.cs @@ -45,11 +45,10 @@ namespace Google.Protobuf.Descriptors /// public sealed class FileDescriptor : IDescriptor { - private FileDescriptorProto proto; + private readonly FileDescriptorProto proto; private readonly IList messageTypes; private readonly IList enumTypes; private readonly IList services; - private readonly IList extensions; private readonly IList dependencies; private readonly IList publicDependencies; private readonly DescriptorPool pool; @@ -86,10 +85,6 @@ namespace Google.Protobuf.Descriptors services = DescriptorUtil.ConvertAndMakeReadOnly(proto.Service, (service, index) => new ServiceDescriptor(service, this, index)); - - extensions = DescriptorUtil.ConvertAndMakeReadOnly(proto.Extension, - (field, index) => - new FieldDescriptor(field, this, null, index, true)); } /// @@ -129,9 +124,6 @@ namespace Google.Protobuf.Descriptors return new ReadOnlyCollection(publicDependencies); } - - static readonly char[] PathSeperators = new char[] { '/', '\\' }; - /// /// The descriptor in its protocol message representation. /// @@ -189,14 +181,6 @@ namespace Google.Protobuf.Descriptors get { return services; } } - /// - /// Unmodifiable list of top-level extensions declared in this file. - /// - public IList Extensions - { - get { return extensions; } - } - /// /// Unmodifiable list of this file's dependencies (imports). /// @@ -350,16 +334,6 @@ namespace Google.Protobuf.Descriptors { service.CrossLink(); } - - foreach (FieldDescriptor extension in extensions) - { - extension.CrossLink(); - } - - foreach (MessageDescriptor message in messageTypes) - { - message.CheckRequiredFields(); - } } /// @@ -415,42 +389,7 @@ namespace Google.Protobuf.Descriptors descriptorAssigner(result); return result; } - - /// - /// Replace our FileDescriptorProto with the given one, which is - /// identical except that it might contain extensions that weren't present - /// in the original. This method is needed for bootstrapping when a file - /// defines custom options. The options may be defined in the file itself, - /// so we can't actually parse them until we've constructed the descriptors, - /// but to construct the decsriptors we have to have parsed the descriptor - /// protos. So, we have to parse the descriptor protos a second time after - /// constructing the descriptors. - /// - private void ReplaceProto(FileDescriptorProto newProto) - { - proto = newProto; - - for (int i = 0; i < messageTypes.Count; i++) - { - messageTypes[i].ReplaceProto(proto.MessageType[i]); - } - - for (int i = 0; i < enumTypes.Count; i++) - { - enumTypes[i].ReplaceProto(proto.EnumType[i]); - } - - for (int i = 0; i < services.Count; i++) - { - services[i].ReplaceProto(proto.Service[i]); - } - - for (int i = 0; i < extensions.Count; i++) - { - extensions[i].ReplaceProto(proto.Extension[i]); - } - } - + public override string ToString() { return "FileDescriptor for " + proto.Name; diff --git a/csharp/src/ProtocolBuffers/Descriptors/MappedType.cs b/csharp/src/ProtocolBuffers/Descriptors/MappedType.cs deleted file mode 100644 index 97eed683..00000000 --- a/csharp/src/ProtocolBuffers/Descriptors/MappedType.cs +++ /dev/null @@ -1,52 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/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. - -namespace Google.Protobuf.Descriptors -{ - /// - /// Type as it's mapped onto a .NET type. - /// - public enum MappedType - { - Int32, - Int64, - UInt32, - UInt64, - Single, - Double, - Boolean, - String, - ByteString, - Message, - Enum - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/Descriptors/MessageDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/MessageDescriptor.cs index f0ac70ff..747cdc9a 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/MessageDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/MessageDescriptor.cs @@ -44,10 +44,8 @@ namespace Google.Protobuf.Descriptors private readonly IList nestedTypes; private readonly IList enumTypes; private readonly IList fields; - private readonly IList extensions; private readonly IList oneofs; - private bool hasRequiredFields; - + internal MessageDescriptor(DescriptorProto proto, FileDescriptor file, MessageDescriptor parent, int typeIndex) : base(proto, file, ComputeFullName(file, parent, proto.Name), typeIndex) { @@ -68,11 +66,7 @@ namespace Google.Protobuf.Descriptors // TODO(jonskeet): Sort fields first? fields = DescriptorUtil.ConvertAndMakeReadOnly(proto.Field, (field, index) => - new FieldDescriptor(field, file, this, index, false)); - - extensions = DescriptorUtil.ConvertAndMakeReadOnly(proto.Extension, - (field, index) => - new FieldDescriptor(field, file, this, index, true)); + new FieldDescriptor(field, file, this, index)); for (int i = 0; i < proto.OneofDecl.Count; i++) { @@ -106,14 +100,6 @@ namespace Google.Protobuf.Descriptors get { return fields; } } - /// - /// An unmodifiable list of this message type's extensions. - /// - public IList Extensions - { - get { return extensions; } - } - /// /// An unmodifiable list of this message type's nested types. /// @@ -135,32 +121,6 @@ namespace Google.Protobuf.Descriptors get { return oneofs; } } - /// - /// Returns a pre-computed result as to whether this message - /// has required fields. This includes optional fields which are - /// message types which in turn have required fields, and any - /// extension fields. - /// - internal bool HasRequiredFields - { - get { return hasRequiredFields; } - } - - /// - /// Determines if the given field number is an extension. - /// - public bool IsExtensionNumber(int number) - { - foreach (DescriptorProto.Types.ExtensionRange range in Proto.ExtensionRange) - { - if (range.Start <= number && number < range.End) - { - return true; - } - } - return false; - } - /// /// Finds a field by field name. /// @@ -194,7 +154,7 @@ namespace Google.Protobuf.Descriptors } /// - /// Looks up and cross-links all fields, nested types, and extensions. + /// Looks up and cross-links all fields and nested types. /// internal void CrossLink() { @@ -208,62 +168,11 @@ namespace Google.Protobuf.Descriptors field.CrossLink(); } - foreach (FieldDescriptor extension in extensions) - { - extension.CrossLink(); - } - foreach (OneofDescriptor oneof in oneofs) { - // oneof.C - } - } - - internal void CheckRequiredFields() - { - IDictionary alreadySeen = new Dictionary(); - hasRequiredFields = CheckRequiredFields(alreadySeen); - } - - private bool CheckRequiredFields(IDictionary alreadySeen) - { - if (alreadySeen.ContainsKey(this)) - { - // The type is already in the cache. This means that either: - // a. The type has no required fields. - // b. We are in the midst of checking if the type has required fields, - // somewhere up the stack. In this case, we know that if the type - // has any required fields, they'll be found when we return to it, - // and the whole call to HasRequiredFields() will return true. - // Therefore, we don't have to check if this type has required fields - // here. - return false; - } - alreadySeen[this] = 0; // Value is irrelevant; we want set semantics - - // If the type allows extensions, an extension with message type could contain - // required fields, so we have to be conservative and assume such an - // extension exists. - if (Proto.ExtensionRange.Count != 0) - { - return true; + // TODO(jonskeet): Do we need to do this? + // oneof.C } - - foreach (FieldDescriptor field in Fields) - { - if (field.IsRequired) - { - return true; - } - if (field.MappedType == MappedType.Message) - { - if (field.MessageType.CheckRequiredFields(alreadySeen)) - { - return true; - } - } - } - return false; } /// @@ -287,11 +196,6 @@ namespace Google.Protobuf.Descriptors { fields[i].ReplaceProto(newProto.Field[i]); } - - for (int i = 0; i < extensions.Count; i++) - { - extensions[i].ReplaceProto(newProto.Extension[i]); - } } } } \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/FieldAccess/FieldAccessorTable.cs b/csharp/src/ProtocolBuffers/FieldAccess/FieldAccessorTable.cs index c3dbb75a..e463f486 100644 --- a/csharp/src/ProtocolBuffers/FieldAccess/FieldAccessorTable.cs +++ b/csharp/src/ProtocolBuffers/FieldAccess/FieldAccessorTable.cs @@ -69,7 +69,6 @@ namespace Google.Protobuf.FieldAccess get { FieldDescriptor field = descriptor.FindFieldByNumber(fieldNumber); - // TODO: Handle extensions. return accessors[field.Index]; } } @@ -82,12 +81,6 @@ namespace Google.Protobuf.FieldAccess { throw new ArgumentException("FieldDescriptor does not match message type."); } - else if (field.IsExtension) - { - // If this type had extensions, it would subclass ExtendableMessage, - // which overrides the reflection interface to handle extensions. - throw new ArgumentException("This type does not have extensions."); - } return accessors[field.Index]; } } diff --git a/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj b/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj index 5edeff70..1e7408ea 100644 --- a/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj +++ b/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj @@ -54,16 +54,12 @@ - - - - @@ -74,13 +70,11 @@ - - @@ -101,7 +95,6 @@ - diff --git a/csharp/src/ProtocolBuffers/TextGenerator.cs b/csharp/src/ProtocolBuffers/TextGenerator.cs deleted file mode 100644 index 80910ba1..00000000 --- a/csharp/src/ProtocolBuffers/TextGenerator.cs +++ /dev/null @@ -1,159 +0,0 @@ -#region Copyright notice and license - -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/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 System.Text; - -namespace Google.Protobuf -{ - /// - /// Helper class to control indentation. Used for TextFormat and by ProtoGen. - /// - public sealed class TextGenerator - { - /// - /// The string to use at the end of each line. We assume that "Print" is only called using \n - /// to indicate a line break; that's what we use to detect when we need to indent etc, and - /// *just* the \n is replaced with the contents of lineBreak. - /// - private readonly string lineBreak; - - /// - /// Writer to write formatted text to. - /// - private readonly TextWriter writer; - - /// - /// Keeps track of whether the next piece of text should be indented - /// - private bool atStartOfLine = true; - - /// - /// Keeps track of the current level of indentation - /// - private readonly StringBuilder indent = new StringBuilder(); - - /// - /// Creates a generator writing to the given writer. The writer - /// is not closed by this class. - /// - public TextGenerator(TextWriter writer, string lineBreak) - { - this.writer = writer; - this.lineBreak = lineBreak; - } - - /// - /// Indents text by two spaces. After calling Indent(), two spaces - /// will be inserted at the beginning of each line of text. Indent() may - /// be called multiple times to produce deeper indents. - /// - public void Indent() - { - indent.Append(" "); - } - - /// - /// Reduces the current indent level by two spaces. - /// - public void Outdent() - { - if (indent.Length == 0) - { - throw new InvalidOperationException("Too many calls to Outdent()"); - } - indent.Length -= 2; - } - - public void WriteLine(string text) - { - Print(text); - Print("\n"); - } - - public void WriteLine(string format, params object[] args) - { - WriteLine(string.Format(format, args)); - } - - public void WriteLine() - { - WriteLine(""); - } - - /// - /// Prints the given text to the output stream, indenting at line boundaries. - /// - /// - public void Print(string text) - { - int pos = 0; - - for (int i = 0; i < text.Length; i++) - { - if (text[i] == '\n') - { - // Strip off the \n from what we write - Write(text.Substring(pos, i - pos)); - Write(lineBreak); - pos = i + 1; - atStartOfLine = true; - } - } - Write(text.Substring(pos)); - } - - public void Write(string format, params object[] args) - { - Write(string.Format(format, args)); - } - - private void Write(string data) - { - if (data.Length == 0) - { - return; - } - if (atStartOfLine) - { - atStartOfLine = false; - writer.Write(indent); - } - writer.Write(data); - } - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/ThrowHelper.cs b/csharp/src/ProtocolBuffers/ThrowHelper.cs index c12a48a3..00ef23e5 100644 --- a/csharp/src/ProtocolBuffers/ThrowHelper.cs +++ b/csharp/src/ProtocolBuffers/ThrowHelper.cs @@ -35,7 +35,6 @@ #endregion using System; -using System.Collections.Generic; namespace Google.Protobuf { @@ -54,30 +53,5 @@ namespace Google.Protobuf throw new ArgumentNullException(name); } } - - /// - /// Throws an ArgumentNullException if the given value is null. - /// - internal static void ThrowIfNull(object value) - { - if (value == null) - { - throw new ArgumentNullException(); - } - } - - /// - /// Throws an ArgumentNullException if the given value or any element within it is null. - /// - internal static void ThrowIfAnyNull(IEnumerable sequence) - { - foreach (T t in sequence) - { - if (t == null) - { - throw new ArgumentNullException(); - } - } - } } } \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/WireFormat.cs b/csharp/src/ProtocolBuffers/WireFormat.cs index 87f7c358..221ffef6 100644 --- a/csharp/src/ProtocolBuffers/WireFormat.cs +++ b/csharp/src/ProtocolBuffers/WireFormat.cs @@ -114,7 +114,6 @@ namespace Google.Protobuf /// /// Makes a tag value given a field number and wire type. - /// TODO(jonskeet): Should we just have a Tag structure? /// public static uint MakeTag(int fieldNumber, WireType wireType) { -- cgit v1.2.3 From fb77cc9d9f066a8ce4f12e8d5f76188d48101444 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Fri, 26 Jun 2015 11:23:33 +0100 Subject: More cleanup, based around searches for "Google.ProtocolBuffers" - Remove some old proto2-based C#-only messages - Remove the "build" directory which only contained out-of-date files - Remove the csharp_namespace option from proto2 messages - Change "Google.ProtocolBuffers" to "Google.Protobuf" in other messages --- benchmarks/google_size.proto | 1 - benchmarks/google_speed.proto | 1 - csharp/build/BuildAll.bat | 8 - csharp/build/Common.targets | 122 ---------- csharp/build/Google.ProtocolBuffers.nuspec | 59 ----- csharp/build/Google.ProtocolBuffersLite.nuspec | 60 ----- csharp/build/RunBenchmarks.bat | 2 - csharp/build/build.bat | 20 -- csharp/build/build.csproj | 241 -------------------- csharp/build/googlecode_upload.py | 248 --------------------- csharp/build/nuspec.xsd | 79 ------- csharp/build/publish.csproj | 186 ---------------- csharp/build/target.csproj | 167 -------------- csharp/protos/extest/unittest_extras_full.proto | 71 ------ csharp/protos/extest/unittest_extras_lite.proto | 115 ---------- csharp/protos/extest/unittest_extras_xmltest.proto | 53 ----- csharp/src/AddressBook/AddPerson.cs | 3 +- csharp/src/AddressBook/AddressBook.csproj | 4 +- csharp/src/AddressBook/Addressbook.cs | 62 +++--- csharp/src/AddressBook/ListPeople.cs | 2 +- csharp/src/AddressBook/Program.cs | 2 +- csharp/src/AddressBook/SampleUsage.cs | 5 +- csharp/src/ProtoDump/Program.cs | 3 +- csharp/src/ProtoDump/ProtoDump.csproj | 2 +- csharp/src/ProtocolBuffers.Test/App.xaml | 8 - csharp/src/ProtocolBuffers.Test/App.xaml.cs | 60 ----- csharp/testdata/golden_message | Bin 487 -> 0 bytes csharp/testdata/golden_packed_fields_message | Bin 142 -> 0 bytes csharp/testdata/text_format_unittest_data.txt | 116 ---------- .../text_format_unittest_extensions_data.txt | 116 ---------- examples/addressbook.proto | 2 +- src/google/protobuf/any.proto | 2 +- src/google/protobuf/duration.proto | 2 +- src/google/protobuf/field_mask.proto | 2 +- src/google/protobuf/map_lite_unittest.proto | 1 - src/google/protobuf/map_proto2_unittest.proto | 2 - src/google/protobuf/map_unittest.proto | 1 - src/google/protobuf/struct.proto | 2 +- src/google/protobuf/timestamp.proto | 2 +- src/google/protobuf/unittest.proto | 1 - src/google/protobuf/unittest_custom_options.proto | 1 - .../protobuf/unittest_drop_unknown_fields.proto | 2 +- .../protobuf/unittest_embed_optimize_for.proto | 2 - .../protobuf/unittest_enormous_descriptor.proto | 1 - src/google/protobuf/unittest_import.proto | 1 - src/google/protobuf/unittest_import_lite.proto | 1 - src/google/protobuf/unittest_import_public.proto | 1 - .../protobuf/unittest_import_public_lite.proto | 1 - src/google/protobuf/unittest_lite.proto | 1 - .../protobuf/unittest_lite_imports_nonlite.proto | 1 - src/google/protobuf/unittest_mset.proto | 1 - .../protobuf/unittest_no_field_presence.proto | 2 - src/google/protobuf/unittest_optimize_for.proto | 1 - .../protobuf/unittest_preserve_unknown_enum.proto | 2 +- .../protobuf/unittest_preserve_unknown_enum2.proto | 2 - src/google/protobuf/unknown_enum_test.proto | 2 - src/google/protobuf/wrappers.proto | 2 +- 57 files changed, 49 insertions(+), 1808 deletions(-) delete mode 100644 csharp/build/BuildAll.bat delete mode 100644 csharp/build/Common.targets delete mode 100644 csharp/build/Google.ProtocolBuffers.nuspec delete mode 100644 csharp/build/Google.ProtocolBuffersLite.nuspec delete mode 100644 csharp/build/RunBenchmarks.bat delete mode 100644 csharp/build/build.bat delete mode 100644 csharp/build/build.csproj delete mode 100644 csharp/build/googlecode_upload.py delete mode 100644 csharp/build/nuspec.xsd delete mode 100644 csharp/build/publish.csproj delete mode 100644 csharp/build/target.csproj delete mode 100644 csharp/protos/extest/unittest_extras_full.proto delete mode 100644 csharp/protos/extest/unittest_extras_lite.proto delete mode 100644 csharp/protos/extest/unittest_extras_xmltest.proto delete mode 100644 csharp/src/ProtocolBuffers.Test/App.xaml delete mode 100644 csharp/src/ProtocolBuffers.Test/App.xaml.cs delete mode 100644 csharp/testdata/golden_message delete mode 100644 csharp/testdata/golden_packed_fields_message delete mode 100644 csharp/testdata/text_format_unittest_data.txt delete mode 100644 csharp/testdata/text_format_unittest_extensions_data.txt diff --git a/benchmarks/google_size.proto b/benchmarks/google_size.proto index e0fcb2e0..d2d319f3 100644 --- a/benchmarks/google_size.proto +++ b/benchmarks/google_size.proto @@ -4,7 +4,6 @@ package benchmarks; option java_outer_classname = "GoogleSize"; option optimize_for = CODE_SIZE; -option csharp_namespace = "Google.ProtocolBuffers.TestProtos"; message SizeMessage1 { required string field1 = 1; diff --git a/benchmarks/google_speed.proto b/benchmarks/google_speed.proto index 3bc5fd2d..16f6d678 100644 --- a/benchmarks/google_speed.proto +++ b/benchmarks/google_speed.proto @@ -4,7 +4,6 @@ package benchmarks; option java_outer_classname = "GoogleSpeed"; option optimize_for = SPEED; -option csharp_namespace = "Google.ProtocolBuffers.TestProtos"; message SpeedMessage1 { required string field1 = 1; diff --git a/csharp/build/BuildAll.bat b/csharp/build/BuildAll.bat deleted file mode 100644 index 9bee73c7..00000000 --- a/csharp/build/BuildAll.bat +++ /dev/null @@ -1,8 +0,0 @@ -@echo off -SET BUILD_TARGET=%~1 -SET BUILD_CONFIG=%~2 - -IF "%BUILD_TARGET%"=="" SET BUILD_TARGET=Rebuild -IF "%BUILD_CONFIG%"=="" SET BUILD_CONFIG=Debug - -CMD.exe /Q /C "CD %~dp0 && %WINDIR%\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /nologo build.csproj /t:%BUILD_TARGET% /toolsversion:4.0 "/p:Configuration=%BUILD_CONFIG%" %3 %4 %5 %6 diff --git a/csharp/build/Common.targets b/csharp/build/Common.targets deleted file mode 100644 index 2aa74dfe..00000000 --- a/csharp/build/Common.targets +++ /dev/null @@ -1,122 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/csharp/build/Google.ProtocolBuffers.nuspec b/csharp/build/Google.ProtocolBuffers.nuspec deleted file mode 100644 index c355cd4a..00000000 --- a/csharp/build/Google.ProtocolBuffers.nuspec +++ /dev/null @@ -1,59 +0,0 @@ - - - - Google.ProtocolBuffers - $version$ - Jon Skeet - Jon Skeet - http://code.google.com/p/protobuf-csharp-port/source/browse/license.txt - http://code.google.com/p/protobuf-csharp-port/ - false - Copyright 2008 Google Inc. All rights reserved. - Protocol Buffers Binary Serialization Format Google - - Google.ProtocolBuffers - A managed code generator and library for Google's data interchange format. - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/csharp/build/Google.ProtocolBuffersLite.nuspec b/csharp/build/Google.ProtocolBuffersLite.nuspec deleted file mode 100644 index 8b9107f5..00000000 --- a/csharp/build/Google.ProtocolBuffersLite.nuspec +++ /dev/null @@ -1,60 +0,0 @@ - - - - Google.ProtocolBuffersLite - $version$ - Jon Skeet - Jon Skeet - http://code.google.com/p/protobuf-csharp-port/source/browse/license.txt - http://code.google.com/p/protobuf-csharp-port/ - false - Copyright 2008 Google Inc. All rights reserved. - Protocol Buffers Binary Serialization Format Google - - Google.ProtocolBuffersLite - A managed code generator and library for Google's data interchange format. - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/csharp/build/RunBenchmarks.bat b/csharp/build/RunBenchmarks.bat deleted file mode 100644 index d0e65010..00000000 --- a/csharp/build/RunBenchmarks.bat +++ /dev/null @@ -1,2 +0,0 @@ -@echo off -CMD.exe /Q /C "CD %~dp0 && %WINDIR%\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /nologo build.csproj /toolsversion:4.0 /t:RunBenchmarks %1 %2 %3 %4 diff --git a/csharp/build/build.bat b/csharp/build/build.bat deleted file mode 100644 index bd7bd2a0..00000000 --- a/csharp/build/build.bat +++ /dev/null @@ -1,20 +0,0 @@ -@echo off -SET BUILD_VERSION=%~1 -SET BUILD_TARGET=%~2 -SET BUILD_CONFIG=%~3 - -IF NOT "%BUILD_VERSION%"=="" GOTO RUN -ECHO. -ECHO Usage: build.bat platform [target] [config] [msbuild arguments] -ECHO. -ECHO - platform: CF20, CF35, NET20, NET35, NET40, PL40, SL20, SL30, or SL40 -ECHO - [target]: Rebuild, Clean, Build, Test, or Publish -ECHO - [config]: Debug or Release -ECHO. -EXIT /B 1 - -:RUN -IF "%BUILD_TARGET%"=="" SET BUILD_TARGET=Rebuild -IF "%BUILD_CONFIG%"=="" SET BUILD_CONFIG=Debug - -CMD.exe /Q /C "CD %~dp0 && %WINDIR%\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /nologo target.csproj /toolsversion:4.0 %4 %5 %6 "/t:%BUILD_TARGET%" "/p:Configuration=%BUILD_CONFIG%;TargetVersion=%BUILD_VERSION%" diff --git a/csharp/build/build.csproj b/csharp/build/build.csproj deleted file mode 100644 index e78b2efb..00000000 --- a/csharp/build/build.csproj +++ /dev/null @@ -1,241 +0,0 @@ - - - - - - - - - - - - - - - - - - Protocol Buffers - Release - Any CPU - - - $(MSBuildProjectDirectory)\.. - $(ProjectDirectory)\src - $(ProjectDirectory)\lib - $(ProjectDirectory)\protos - - $(ProjectDirectory)\build_temp\GeneratedSource - $(ProjectDirectory)\build_temp - $(ProjectDirectory)\build_output - $(BuildOutputDirectory) - - /v2 /fast /formats - $(BuildTempDirectory)\..\BenchmarkResults.txt - $(ProjectDirectory)\benchmarks - - $(Configuration) - - - $(BuildOutputDirectory)\tools\protoc.exe - $(BuildOutputDirectory)\tools\protogen.exe - $(LibDirectory)\NUnit\tools\nunit-console.exe - $(LibDirectory)\CsProjectProjector\CsProjectProjector.exe - $(LibDirectory)\7-Zip 9.20\7za.exe - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $(SourceDirectory)\ProtocolBuffers\DescriptorProtos - - - $(SourceDirectory)\ProtocolBuffers\DescriptorProtos - - - - - $(SourceDirectory)\AddressBook - - - - $(SourceDirectory)\ProtocolBuffers.Test\TestProtos - - - $(SourceDirectory)\ProtocolBuffers.Test\TestProtos - - - $(SourceDirectory)\ProtocolBuffers.Test\TestProtos - - - $(SourceDirectory)\ProtocolBuffers.Test\TestProtos - - - $(SourceDirectory)\ProtocolBuffers.Test\TestProtos - - - $(SourceDirectory)\ProtocolBuffers.Test\TestProtos - - - $(SourceDirectory)\ProtocolBuffers.Test\TestProtos - - - $(SourceDirectory)\ProtocolBuffers.Test\TestProtos - - - $(SourceDirectory)\ProtocolBuffers.Test\TestProtos - - - $(SourceDirectory)\ProtocolBuffers.Test\TestProtos - - - $(SourceDirectory)\ProtocolBuffers.Test\TestProtos - - - $(SourceDirectory)\ProtocolBuffers.Test\TestProtos - - - $(SourceDirectory)\ProtocolBuffers.Test\TestProtos - - - $(SourceDirectory)\ProtocolBuffers.Test\TestProtos - - - $(SourceDirectory)\ProtocolBuffersLite.Test\TestProtos - - - $(SourceDirectory)\ProtocolBuffers.Test\TestProtos - - - - $(SourceDirectory)\ProtocolBuffersLite.Test\TestProtos - - - $(SourceDirectory)\ProtocolBuffersLite.Test\TestProtos - - - $(SourceDirectory)\ProtocolBuffersLite.Test\TestProtos - - - $(SourceDirectory)\ProtocolBuffersLite.Test\TestProtos - - - $(SourceDirectory)\ProtocolBuffersLite.Test\TestProtos - - - $(SourceDirectory)\ProtocolBuffersLite.Test\TestProtos - - - $(SourceDirectory)\ProtocolBuffersLite.Test\TestProtos - - - $(SourceDirectory)\ProtocolBuffers.Test\TestProtos - - - $(SourceDirectory)\ProtocolBuffers.Test\TestProtos - - - $(SourceDirectory)\ProtoBench\TestProtos - - - $(SourceDirectory)\ProtoBench\TestProtos - - - $(SourceDirectory)\ProtoBench\TestProtos - - - $(SourceDirectory)\ProtoBench\TestProtos - - - - - - - - \protos\google\protobuf - - - \protos\google\protobuf\compiler - - - \protos\google\protobuf - - - \protos\tutorial - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/csharp/build/googlecode_upload.py b/csharp/build/googlecode_upload.py deleted file mode 100644 index d2d5f974..00000000 --- a/csharp/build/googlecode_upload.py +++ /dev/null @@ -1,248 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2006, 2007 Google Inc. All Rights Reserved. -# Author: danderson@google.com (David Anderson) -# -# Script for uploading files to a Google Code project. -# -# This is intended to be both a useful script for people who want to -# streamline project uploads and a reference implementation for -# uploading files to Google Code projects. -# -# To upload a file to Google Code, you need to provide a path to the -# file on your local machine, a small summary of what the file is, a -# project name, and a valid account that is a member or owner of that -# project. You can optionally provide a list of labels that apply to -# the file. The file will be uploaded under the same name that it has -# in your local filesystem (that is, the "basename" or last path -# component). Run the script with '--help' to get the exact syntax -# and available options. -# -# Note that the upload script requests that you enter your -# googlecode.com password. This is NOT your Gmail account password! -# This is the password you use on googlecode.com for committing to -# Subversion and uploading files. You can find your password by going -# to http://code.google.com/hosting/settings when logged in with your -# Gmail account. If you have already committed to your project's -# Subversion repository, the script will automatically retrieve your -# credentials from there (unless disabled, see the output of '--help' -# for details). -# -# If you are looking at this script as a reference for implementing -# your own Google Code file uploader, then you should take a look at -# the upload() function, which is the meat of the uploader. You -# basically need to build a multipart/form-data POST request with the -# right fields and send it to https://PROJECT.googlecode.com/files . -# Authenticate the request using HTTP Basic authentication, as is -# shown below. -# -# Licensed under the terms of the Apache Software License 2.0: -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Questions, comments, feature requests and patches are most welcome. -# Please direct all of these to the Google Code users group: -# http://groups.google.com/group/google-code-hosting - -"""Google Code file uploader script. -""" - -__author__ = 'danderson@google.com (David Anderson)' - -import httplib -import os.path -import optparse -import getpass -import base64 -import sys - - -def upload(file, project_name, user_name, password, summary, labels=None): - """Upload a file to a Google Code project's file server. - - Args: - file: The local path to the file. - project_name: The name of your project on Google Code. - user_name: Your Google account name. - password: The googlecode.com password for your account. - Note that this is NOT your global Google Account password! - summary: A small description for the file. - labels: an optional list of label strings with which to tag the file. - - Returns: a tuple: - http_status: 201 if the upload succeeded, something else if an - error occured. - http_reason: The human-readable string associated with http_status - file_url: If the upload succeeded, the URL of the file on Google - Code, None otherwise. - """ - # The login is the user part of user@gmail.com. If the login provided - # is in the full user@domain form, strip it down. - if user_name.endswith('@gmail.com'): - user_name = user_name[:user_name.index('@gmail.com')] - - form_fields = [('summary', summary)] - if labels is not None: - form_fields.extend([('label', l.strip()) for l in labels]) - - content_type, body = encode_upload_request(form_fields, file) - - upload_host = '%s.googlecode.com' % project_name - upload_uri = '/files' - auth_token = base64.b64encode('%s:%s'% (user_name, password)) - headers = { - 'Authorization': 'Basic %s' % auth_token, - 'User-Agent': 'Googlecode.com uploader v0.9.4', - 'Content-Type': content_type, - } - - server = httplib.HTTPSConnection(upload_host) - server.request('POST', upload_uri, body, headers) - resp = server.getresponse() - server.close() - - if resp.status == 201: - location = resp.getheader('Location', None) - else: - location = None - return resp.status, resp.reason, location - - -def encode_upload_request(fields, file_path): - """Encode the given fields and file into a multipart form body. - - fields is a sequence of (name, value) pairs. file is the path of - the file to upload. The file will be uploaded to Google Code with - the same file name. - - Returns: (content_type, body) ready for httplib.HTTP instance - """ - BOUNDARY = '----------Googlecode_boundary_reindeer_flotilla' - CRLF = '\r\n' - - body = [] - - # Add the metadata about the upload first - for key, value in fields: - body.extend( - ['--' + BOUNDARY, - 'Content-Disposition: form-data; name="%s"' % key, - '', - value, - ]) - - # Now add the file itself - file_name = os.path.basename(file_path) - f = open(file_path, 'rb') - file_content = f.read() - f.close() - - body.extend( - ['--' + BOUNDARY, - 'Content-Disposition: form-data; name="filename"; filename="%s"' - % file_name, - # The upload server determines the mime-type, no need to set it. - 'Content-Type: application/octet-stream', - '', - file_content, - ]) - - # Finalize the form body - body.extend(['--' + BOUNDARY + '--', '']) - - return 'multipart/form-data; boundary=%s' % BOUNDARY, CRLF.join(body) - - -def upload_find_auth(file_path, project_name, summary, labels=None, - user_name=None, password=None, tries=3): - """Find credentials and upload a file to a Google Code project's file server. - - file_path, project_name, summary, and labels are passed as-is to upload. - - Args: - file_path: The local path to the file. - project_name: The name of your project on Google Code. - summary: A small description for the file. - labels: an optional list of label strings with which to tag the file. - config_dir: Path to Subversion configuration directory, 'none', or None. - user_name: Your Google account name. - tries: How many attempts to make. - """ - - while tries > 0: - if user_name is None: - # Read username if not specified or loaded from svn config, or on - # subsequent tries. - sys.stdout.write('Please enter your googlecode.com username: ') - sys.stdout.flush() - user_name = sys.stdin.readline().rstrip() - if password is None: - # Read password if not loaded from svn config, or on subsequent tries. - print 'Please enter your googlecode.com password.' - print '** Note that this is NOT your Gmail account password! **' - print 'It is the password you use to access Subversion repositories,' - print 'and can be found here: http://code.google.com/hosting/settings' - password = getpass.getpass() - - status, reason, url = upload(file_path, project_name, user_name, password, - summary, labels) - # Returns 403 Forbidden instead of 401 Unauthorized for bad - # credentials as of 2007-07-17. - if status in [httplib.FORBIDDEN, httplib.UNAUTHORIZED]: - # Rest for another try. - user_name = password = None - tries = tries - 1 - else: - # We're done. - break - - return status, reason, url - - -def main(): - parser = optparse.OptionParser(usage='googlecode-upload.py -s SUMMARY ' - '-p PROJECT [options] FILE') - parser.add_option('-s', '--summary', dest='summary', - help='Short description of the file') - parser.add_option('-p', '--project', dest='project', - help='Google Code project name') - parser.add_option('-u', '--user', dest='user', - help='Your Google Code username') - parser.add_option('-w', '--password', dest='password', - help='Your Google Code password') - parser.add_option('-l', '--labels', dest='labels', - help='An optional list of comma-separated labels to attach ' - 'to the file') - - options, args = parser.parse_args() - - if not options.summary: - parser.error('File summary is missing.') - elif not options.project: - parser.error('Project name is missing.') - elif len(args) < 1: - parser.error('File to upload not provided.') - elif len(args) > 1: - parser.error('Only one file may be specified.') - - file_path = args[0] - - if options.labels: - labels = options.labels.split(',') - else: - labels = None - - status, reason, url = upload_find_auth(file_path, options.project, - options.summary, labels, - options.user, options.password) - if url: - print 'The file was uploaded successfully.' - print 'URL: %s' % url - return 0 - else: - print 'An error occurred. Your file was not uploaded.' - print 'Google Code upload server said: %s (%s)' % (reason, status) - return 1 - - -if __name__ == '__main__': - sys.exit(main()) diff --git a/csharp/build/nuspec.xsd b/csharp/build/nuspec.xsd deleted file mode 100644 index db744d1a..00000000 --- a/csharp/build/nuspec.xsd +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/csharp/build/publish.csproj b/csharp/build/publish.csproj deleted file mode 100644 index bbe71df5..00000000 --- a/csharp/build/publish.csproj +++ /dev/null @@ -1,186 +0,0 @@ - - - - - - - - - - - - - - Protocol Buffers - 2 - 4 - 1 - - - - protobuf-csharp-port- - false - - - - - - $(MSBuildProjectDirectory)\.. - $(ProjectDirectory)\build_temp - $(ProjectDirectory)\build_output - $(ProjectDirectory)\src - $(ProjectDirectory)\lib - - - $(ProjectDirectory)\release-key\Google.ProtocolBuffers.snk - - - hg.exe - C:\Python25\python.exe - $(registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A@InstallationFolder)Bin\sn.exe - $(LibDirectory)\StampVersion.exe - $(LibDirectory)\7-Zip 9.20\7za.exe - $(LibDirectory)\NuGet.exe - $(BuildOutputDirectory)\tools\protogen.exe - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $(VersionMajor).$(VersionMinor).$(VersionBuild).$(VersionRevision) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $(Python) "$(MSBuildProjectDirectory)\googlecode_upload.py" --project protobuf-csharp-port --user "$(GoogleUsername)" --password "$(GooglePassword)" - - $(BuildTempDirectory)\$(PackagePrefix)$(VersionLabel)-source.zip - $(BuildTempDirectory)\$(PackagePrefix)$(VersionLabel)-release-binaries.zip - $(BuildTempDirectory)\$(PackagePrefix)$(VersionLabel)-release-symbols.zip - $(BuildTempDirectory)\$(PackagePrefix)$(VersionLabel)-full-binaries.zip - $(BuildTempDirectory)\$(PackagePrefix)$(VersionLabel)-full-symbols.zip - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/csharp/build/target.csproj b/csharp/build/target.csproj deleted file mode 100644 index 09a9d50b..00000000 --- a/csharp/build/target.csproj +++ /dev/null @@ -1,167 +0,0 @@ - - - - - - - - - - - - - - - Debug - Any CPU - NET20 - - - - $(MSBuildProjectDirectory)\.. - $(ProjectDirectory)\src - $(ProjectDirectory)\lib - - - $(ProjectDirectory)\build_temp\$(Configuration)\$(TargetVersion) - $(ProjectDirectory)\build_output\$(Configuration)\$(TargetVersion) - $(SourceDirectory)\ProtocolBuffersLibrary.$(TargetVersion).sln - - - $(LibDirectory)\NUnit\tools\nunit-console.exe - $(LibDirectory)\StatLight\tools\StatLight.exe - - - - - - 3.5 - NUNIT - v2.0 - - - 3.5 - NUNIT - v3.5 - - - 4.0 - NUNIT - v4.0 - - - 3.5 - NONE - v2.0 - - - 3.5 - NONE - v3.5 - - - 3.5 - SILVERLIGHT - v2.0 - - - 3.5 - SILVERLIGHT - v3.5 - - - 4.0 - SILVERLIGHT - v4.0 - - - 4.0 - SILVERLIGHT - v4.0 - $(ProjectDirectory)\build_output\$(Configuration)\portable-net40+sl4+sl5+wp7+wp8+win8 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/csharp/protos/extest/unittest_extras_full.proto b/csharp/protos/extest/unittest_extras_full.proto deleted file mode 100644 index 1b546053..00000000 --- a/csharp/protos/extest/unittest_extras_full.proto +++ /dev/null @@ -1,71 +0,0 @@ -syntax = "proto2"; - -package protobuf_unittest_extra; - -option csharp_namespace = "Google.ProtocolBuffers.TestProtos"; -option optimize_for = CODE_SIZE; -option java_package = "com.google.protobuf"; - -message TestInteropPerson { - required string name = 1; - required int32 id = 2; - optional string email = 3; - repeated int32 codes = 10 [packed=true]; - - enum PhoneType { - MOBILE = 0; - HOME = 1; - WORK = 2; - } - - message PhoneNumber { - required string number = 1; - optional PhoneType type = 2 [default = HOME]; - } - - repeated PhoneNumber phone = 4; - - repeated group Addresses = 5 { - required string address = 1; - optional string address2 = 2; - required string city = 3; - required string state = 4; - required fixed32 zip = 5; - } - - extensions 100 to 199; -} - -message TestInteropEmployeeId { - required string number = 1; -} - -extend TestInteropPerson { - // Note: changed from required to optional, as required fields are not - // permitted in extensions. (The fact that this was allowed in protogen - // before was almost certainly a bug.) - optional TestInteropEmployeeId employee_id = 126; -} - -message TestMissingFieldsA { - required string name = 1; - required int32 id = 2; - optional string email = 3; - - message SubA { - required int32 count = 5; - repeated string values = 6; - } - optional SubA testA = 11; -} - -message TestMissingFieldsB { - required string name = 1; - required int32 id = 2; - optional string website = 4; - - message SubB { - repeated string values = 7; - } - optional SubB testB = 12; -} diff --git a/csharp/protos/extest/unittest_extras_lite.proto b/csharp/protos/extest/unittest_extras_lite.proto deleted file mode 100644 index 0c242d2f..00000000 --- a/csharp/protos/extest/unittest_extras_lite.proto +++ /dev/null @@ -1,115 +0,0 @@ -syntax = "proto2"; - -package protobuf_unittest_extra; - -option csharp_namespace = "Google.ProtocolBuffers.TestProtos"; -option optimize_for = LITE_RUNTIME; -option java_package = "com.google.protobuf"; - -message TestRequiredLite { - required int32 d = 1; - required ExtraEnum en = 2 [default = DEFAULT]; -} - -enum ExtraEnum { - DEFAULT = 10; - EXLITE_FOO = 7; - EXLITE_BAR = 8; - EXLITE_BAZ = 9; -} - -message TestInteropPersonLite { - required string name = 1; - required int32 id = 2; - optional string email = 3; - repeated int32 codes = 10 [packed=true]; - - enum PhoneType { - MOBILE = 0; - HOME = 1; - WORK = 2; - } - - message PhoneNumber { - required string number = 1; - optional PhoneType type = 2 [default = HOME]; - } - - repeated PhoneNumber phone = 4; - - repeated group Addresses = 5 { - required string address = 1; - optional string address2 = 2; - required string city = 3; - required string state = 4; - required fixed32 zip = 5; - } - - extensions 100 to 199; -} - -message TestInteropEmployeeIdLite { - required string number = 1; -} - -extend TestInteropPersonLite { - // Note: changed from required to optional, as required fields are not - // permitted in extensions. (The fact that this was allowed in protogen - // before was almost certainly a bug.) - optional TestInteropEmployeeIdLite employee_id_lite = 126; -} - -/* Removed from unittest_lite.proto and added back here */ - -message TestUnpackedExtensionsLite { - extensions 1 to max; -} - -message TestUnpackedTypesLite { - repeated int32 unpacked_int32 = 90; - repeated int64 unpacked_int64 = 91; - repeated uint32 unpacked_uint32 = 92; - repeated uint64 unpacked_uint64 = 93; - repeated sint32 unpacked_sint32 = 94; - repeated sint64 unpacked_sint64 = 95; - repeated fixed32 unpacked_fixed32 = 96; - repeated fixed64 unpacked_fixed64 = 97; - repeated sfixed32 unpacked_sfixed32 = 98; - repeated sfixed64 unpacked_sfixed64 = 99; - repeated float unpacked_float = 100; - repeated double unpacked_double = 101; - repeated bool unpacked_bool = 102; - repeated UnpackedTypesForeignEnumLite unpacked_enum = 103; -} - -extend TestUnpackedExtensionsLite { - repeated int32 unpacked_int32_extension_lite = 90; - repeated int64 unpacked_int64_extension_lite = 91; - repeated uint32 unpacked_uint32_extension_lite = 92; - repeated uint64 unpacked_uint64_extension_lite = 93; - repeated sint32 unpacked_sint32_extension_lite = 94; - repeated sint64 unpacked_sint64_extension_lite = 95; - repeated fixed32 unpacked_fixed32_extension_lite = 96; - repeated fixed64 unpacked_fixed64_extension_lite = 97; - repeated sfixed32 unpacked_sfixed32_extension_lite = 98; - repeated sfixed64 unpacked_sfixed64_extension_lite = 99; - repeated float unpacked_float_extension_lite = 100; - repeated double unpacked_double_extension_lite = 101; - repeated bool unpacked_bool_extension_lite = 102; - repeated UnpackedTypesForeignEnumLite unpacked_enum_extension_lite = 103; -} - -enum UnpackedTypesForeignEnumLite { - FOREIGN_LITE_FOO = 4; - FOREIGN_LITE_BAR = 5; - FOREIGN_LITE_BAZ = 6; -} - -message BucketOfBytes { - optional bytes value = 1; - -} -message BucketOfBytesEx { - optional bytes value = 1; - optional bytes value2 = 255; -} \ No newline at end of file diff --git a/csharp/protos/extest/unittest_extras_xmltest.proto b/csharp/protos/extest/unittest_extras_xmltest.proto deleted file mode 100644 index fae36165..00000000 --- a/csharp/protos/extest/unittest_extras_xmltest.proto +++ /dev/null @@ -1,53 +0,0 @@ -syntax = "proto2"; - -option csharp_namespace = "Google.ProtocolBuffers.TestProtos"; - -package protobuf_unittest_extra; - -option optimize_for = SPEED; - -enum EnumOptions { - ONE = 0; - TWO = 1; - THREE = 2; -} - -message TestXmlChild { - repeated EnumOptions options = 3; - optional bytes binary = 4; -} - -message TestXmlNoFields { -} - -message TestXmlRescursive { - optional TestXmlRescursive child = 1; -} - -message TestXmlMessage { - - optional int64 number = 6; - repeated int32 numbers = 2; - optional string text = 3; - repeated string textlines = 700; - optional bool valid = 5; - - optional TestXmlChild child = 1; - repeated group Children = 401 { - repeated EnumOptions options = 3; - optional bytes binary = 4; - } - -extensions 100 to 199; -} - -message TestXmlExtension { - required int32 number = 1; -} - -extend TestXmlMessage { - optional EnumOptions extension_enum = 101; - optional string extension_text = 102; - repeated int32 extension_number = 103 [packed = true]; - optional TestXmlExtension extension_message = 199; -} diff --git a/csharp/src/AddressBook/AddPerson.cs b/csharp/src/AddressBook/AddPerson.cs index 630108cf..5a4de39e 100644 --- a/csharp/src/AddressBook/AddPerson.cs +++ b/csharp/src/AddressBook/AddPerson.cs @@ -36,9 +36,8 @@ using System; using System.IO; -using Google.Protobuf; -namespace Google.ProtocolBuffers.Examples.AddressBook +namespace Google.Protobuf.Examples.AddressBook { internal class AddPerson { diff --git a/csharp/src/AddressBook/AddressBook.csproj b/csharp/src/AddressBook/AddressBook.csproj index f7e0d6be..b338af9c 100644 --- a/csharp/src/AddressBook/AddressBook.csproj +++ b/csharp/src/AddressBook/AddressBook.csproj @@ -8,11 +8,11 @@ {A31F5FB2-4FF3-432A-B35B-5CD203606311} Exe Properties - Google.ProtocolBuffers.Examples.AddressBook + Google.Protobuf.Examples.AddressBook AddressBook v4.0 512 - Google.ProtocolBuffers.Examples.AddressBook.Program + Google.Protobuf.Examples.AddressBook.Program Client diff --git a/csharp/src/AddressBook/Addressbook.cs b/csharp/src/AddressBook/Addressbook.cs index 1d8b8f10..c88ca424 100644 --- a/csharp/src/AddressBook/Addressbook.cs +++ b/csharp/src/AddressBook/Addressbook.cs @@ -7,18 +7,18 @@ using pb = global::Google.Protobuf; using pbc = global::Google.Protobuf.Collections; using pbd = global::Google.Protobuf.Descriptors; using scg = global::System.Collections.Generic; -namespace Google.ProtocolBuffers.Examples.AddressBook { +namespace Google.Protobuf.Examples.AddressBook { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class Addressbook { #region Static variables internal static pbd::MessageDescriptor internal__static_tutorial_Person__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_tutorial_Person__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_tutorial_Person__FieldAccessorTable; internal static pbd::MessageDescriptor internal__static_tutorial_Person_PhoneNumber__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_tutorial_Person_PhoneNumber__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_tutorial_Person_PhoneNumber__FieldAccessorTable; internal static pbd::MessageDescriptor internal__static_tutorial_AddressBook__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_tutorial_AddressBook__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_tutorial_AddressBook__FieldAccessorTable; #endregion #region Descriptor public static pbd::FileDescriptor Descriptor { @@ -35,22 +35,22 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { "TnVtYmVyEg4KBm51bWJlchgBIAIoCRIuCgR0eXBlGAIgASgOMhoudHV0b3Jp", "YWwuUGVyc29uLlBob25lVHlwZToESE9NRSIrCglQaG9uZVR5cGUSCgoGTU9C", "SUxFEAASCAoESE9NRRABEggKBFdPUksQAiIvCgtBZGRyZXNzQm9vaxIgCgZw", - "ZXJzb24YASADKAsyEC50dXRvcmlhbC5QZXJzb25CVwoUY29tLmV4YW1wbGUu", - "dHV0b3JpYWxCEUFkZHJlc3NCb29rUHJvdG9zqgIrR29vZ2xlLlByb3RvY29s", - "QnVmZmVycy5FeGFtcGxlcy5BZGRyZXNzQm9vaw==")); + "ZXJzb24YASADKAsyEC50dXRvcmlhbC5QZXJzb25CUAoUY29tLmV4YW1wbGUu", + "dHV0b3JpYWxCEUFkZHJlc3NCb29rUHJvdG9zqgIkR29vZ2xlLlByb3RvYnVm", + "LkV4YW1wbGVzLkFkZHJlc3NCb29r")); pbd::FileDescriptor.InternalDescriptorAssigner assigner = delegate(pbd::FileDescriptor root) { descriptor = root; internal__static_tutorial_Person__Descriptor = Descriptor.MessageTypes[0]; internal__static_tutorial_Person__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_tutorial_Person__Descriptor, + new pb::FieldAccess.FieldAccessorTable(internal__static_tutorial_Person__Descriptor, new string[] { "Name", "Id", "Email", "Phone", }); internal__static_tutorial_Person_PhoneNumber__Descriptor = internal__static_tutorial_Person__Descriptor.NestedTypes[0]; internal__static_tutorial_Person_PhoneNumber__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_tutorial_Person_PhoneNumber__Descriptor, + new pb::FieldAccess.FieldAccessorTable(internal__static_tutorial_Person_PhoneNumber__Descriptor, new string[] { "Number", "Type", }); internal__static_tutorial_AddressBook__Descriptor = Descriptor.MessageTypes[1]; internal__static_tutorial_AddressBook__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_tutorial_AddressBook__Descriptor, + new pb::FieldAccess.FieldAccessorTable(internal__static_tutorial_AddressBook__Descriptor, new string[] { "Person", }); }; pbd::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, @@ -69,11 +69,11 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { private static readonly string[] _fieldNames = new string[] { "email", "id", "name", "phone" }; private static readonly uint[] _fieldTags = new uint[] { 26, 16, 10, 34 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.Examples.AddressBook.Addressbook.internal__static_tutorial_Person__Descriptor; } + get { return global::Google.Protobuf.Examples.AddressBook.Addressbook.internal__static_tutorial_Person__Descriptor; } } public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.ProtocolBuffers.Examples.AddressBook.Addressbook.internal__static_tutorial_Person__FieldAccessorTable; } + get { return global::Google.Protobuf.Examples.AddressBook.Addressbook.internal__static_tutorial_Person__FieldAccessorTable; } } private bool _frozen = false; @@ -131,8 +131,8 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { } public const int PhoneFieldNumber = 4; - private readonly pbc::RepeatedField phone_ = new pbc::RepeatedField(); - public pbc::RepeatedField Phone { + private readonly pbc::RepeatedField phone_ = new pbc::RepeatedField(); + public pbc::RepeatedField Phone { get { return phone_; } } @@ -193,7 +193,7 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { size += 1 + pb::CodedOutputStream.ComputeStringSize(Email); } if (phone_.Count > 0) { - foreach (global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneNumber element in phone_) { + foreach (global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneNumber element in phone_) { size += pb::CodedOutputStream.ComputeMessageSize(element); } size += 1 * phone_.Count; @@ -241,7 +241,7 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { break; } case 34: { - input.ReadMessageArray(phone_, global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneNumber.Parser); + input.ReadMessageArray(phone_, global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneNumber.Parser); break; } } @@ -265,11 +265,11 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { private static readonly string[] _fieldNames = new string[] { "number", "type" }; private static readonly uint[] _fieldTags = new uint[] { 10, 16 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.Examples.AddressBook.Addressbook.internal__static_tutorial_Person_PhoneNumber__Descriptor; } + get { return global::Google.Protobuf.Examples.AddressBook.Addressbook.internal__static_tutorial_Person_PhoneNumber__Descriptor; } } public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.ProtocolBuffers.Examples.AddressBook.Addressbook.internal__static_tutorial_Person_PhoneNumber__FieldAccessorTable; } + get { return global::Google.Protobuf.Examples.AddressBook.Addressbook.internal__static_tutorial_Person_PhoneNumber__FieldAccessorTable; } } private bool _frozen = false; @@ -304,8 +304,8 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { } public const int TypeFieldNumber = 2; - private global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneType type_ = global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneType.HOME; - public global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneType Type { + private global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType type_ = global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType.HOME; + public global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType Type { get { return type_; } set { pb::Freezable.CheckMutable(this); @@ -332,7 +332,7 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { public override int GetHashCode() { int hash = 1; if (Number.Length != 0) hash ^= Number.GetHashCode(); - if (Type != global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneType.HOME) hash ^= Type.GetHashCode(); + if (Type != global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType.HOME) hash ^= Type.GetHashCode(); return hash; } @@ -341,7 +341,7 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { output.WriteRawTag(10); output.WriteString(Number); } - if (Type != global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneType.HOME) { + if (Type != global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType.HOME) { output.WriteRawTag(16); output.WriteEnum((int) Type); } @@ -352,7 +352,7 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { if (Number.Length != 0) { size += 1 + pb::CodedOutputStream.ComputeStringSize(Number); } - if (Type != global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneType.HOME) { + if (Type != global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType.HOME) { size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Type); } return size; @@ -365,7 +365,7 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { if (other.Number.Length != 0) { Number = other.Number; } - if (other.Type != global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneType.HOME) { + if (other.Type != global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType.HOME) { Type = other.Type; } } @@ -386,7 +386,7 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { break; } case 16: { - type_ = (global::Google.ProtocolBuffers.Examples.AddressBook.Person.Types.PhoneType) input.ReadEnum(); + type_ = (global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType) input.ReadEnum(); break; } } @@ -408,11 +408,11 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { private static readonly string[] _fieldNames = new string[] { "person" }; private static readonly uint[] _fieldTags = new uint[] { 10 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.ProtocolBuffers.Examples.AddressBook.Addressbook.internal__static_tutorial_AddressBook__Descriptor; } + get { return global::Google.Protobuf.Examples.AddressBook.Addressbook.internal__static_tutorial_AddressBook__Descriptor; } } public pb::FieldAccess.FieldAccessorTable Fields { - get { return global::Google.ProtocolBuffers.Examples.AddressBook.Addressbook.internal__static_tutorial_AddressBook__FieldAccessorTable; } + get { return global::Google.Protobuf.Examples.AddressBook.Addressbook.internal__static_tutorial_AddressBook__FieldAccessorTable; } } private bool _frozen = false; @@ -437,8 +437,8 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { } public const int PersonFieldNumber = 1; - private readonly pbc::RepeatedField person_ = new pbc::RepeatedField(); - public pbc::RepeatedField Person { + private readonly pbc::RepeatedField person_ = new pbc::RepeatedField(); + public pbc::RepeatedField Person { get { return person_; } } @@ -472,7 +472,7 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { public int CalculateSize() { int size = 0; if (person_.Count > 0) { - foreach (global::Google.ProtocolBuffers.Examples.AddressBook.Person element in person_) { + foreach (global::Google.Protobuf.Examples.AddressBook.Person element in person_) { size += pb::CodedOutputStream.ComputeMessageSize(element); } size += 1 * person_.Count; @@ -499,7 +499,7 @@ namespace Google.ProtocolBuffers.Examples.AddressBook { } break; case 10: { - input.ReadMessageArray(person_, global::Google.ProtocolBuffers.Examples.AddressBook.Person.Parser); + input.ReadMessageArray(person_, global::Google.Protobuf.Examples.AddressBook.Person.Parser); break; } } diff --git a/csharp/src/AddressBook/ListPeople.cs b/csharp/src/AddressBook/ListPeople.cs index 9666c425..5ae73e53 100644 --- a/csharp/src/AddressBook/ListPeople.cs +++ b/csharp/src/AddressBook/ListPeople.cs @@ -37,7 +37,7 @@ using System; using System.IO; -namespace Google.ProtocolBuffers.Examples.AddressBook +namespace Google.Protobuf.Examples.AddressBook { internal class ListPeople { diff --git a/csharp/src/AddressBook/Program.cs b/csharp/src/AddressBook/Program.cs index e0d6d49b..19c677c0 100644 --- a/csharp/src/AddressBook/Program.cs +++ b/csharp/src/AddressBook/Program.cs @@ -36,7 +36,7 @@ using System; -namespace Google.ProtocolBuffers.Examples.AddressBook +namespace Google.Protobuf.Examples.AddressBook { /// /// Entry point. Repeatedly prompts user for an action to take, delegating actual behaviour diff --git a/csharp/src/AddressBook/SampleUsage.cs b/csharp/src/AddressBook/SampleUsage.cs index c06188b4..b9a61497 100644 --- a/csharp/src/AddressBook/SampleUsage.cs +++ b/csharp/src/AddressBook/SampleUsage.cs @@ -1,8 +1,7 @@ -using Google.Protobuf; -using System; +using System; using System.IO; -namespace Google.ProtocolBuffers.Examples.AddressBook +namespace Google.Protobuf.Examples.AddressBook { internal class SampleUsage { diff --git a/csharp/src/ProtoDump/Program.cs b/csharp/src/ProtoDump/Program.cs index d2eee9b7..ebe4255d 100644 --- a/csharp/src/ProtoDump/Program.cs +++ b/csharp/src/ProtoDump/Program.cs @@ -36,9 +36,8 @@ using System; using System.IO; -using Google.Protobuf; -namespace Google.ProtocolBuffers.ProtoDump +namespace Google.Protobuf.ProtoDump { /// /// Small utility to load a binary message and dump it in text form diff --git a/csharp/src/ProtoDump/ProtoDump.csproj b/csharp/src/ProtoDump/ProtoDump.csproj index b7e6c1a3..a74067e4 100644 --- a/csharp/src/ProtoDump/ProtoDump.csproj +++ b/csharp/src/ProtoDump/ProtoDump.csproj @@ -10,7 +10,7 @@ {D7282E99-2DC3-405B-946F-177DB2FD2AE2} Exe Properties - Google.ProtocolBuffers.ProtoDump + Google.Protobuf.ProtoDump ProtoDump v4.0 512 diff --git a/csharp/src/ProtocolBuffers.Test/App.xaml b/csharp/src/ProtocolBuffers.Test/App.xaml deleted file mode 100644 index d4f1f2e3..00000000 --- a/csharp/src/ProtocolBuffers.Test/App.xaml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - diff --git a/csharp/src/ProtocolBuffers.Test/App.xaml.cs b/csharp/src/ProtocolBuffers.Test/App.xaml.cs deleted file mode 100644 index 0c9fd9e6..00000000 --- a/csharp/src/ProtocolBuffers.Test/App.xaml.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System; -using System.Windows; -using Microsoft.Silverlight.Testing; - -namespace Google.ProtocolBuffers -{ - public partial class App : Application - { - - public App() - { - this.Startup += this.Application_Startup; - this.Exit += this.Application_Exit; - this.UnhandledException += this.Application_UnhandledException; - - //InitializeComponent(); - } - - private void Application_Startup(object sender, StartupEventArgs e) - { - this.RootVisual = UnitTestSystem.CreateTestPage(); - } - - private void Application_Exit(object sender, EventArgs e) - { - - } - private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e) - { - // If the app is running outside of the debugger then report the exception using - // the browser's exception mechanism. On IE this will display it a yellow alert - // icon in the status bar and Firefox will display a script error. - if (!System.Diagnostics.Debugger.IsAttached) - { - - // NOTE: This will allow the application to continue running after an exception has been thrown - // but not handled. - // For production applications this error handling should be replaced with something that will - // report the error to the website and stop the application. - e.Handled = true; - Deployment.Current.Dispatcher.BeginInvoke( - new EventHandler(ReportErrorToDOM), - new object[] { sender, e } ); - } - } - private void ReportErrorToDOM(object sender, ApplicationUnhandledExceptionEventArgs e) - { - try - { - string errorMsg = e.ExceptionObject.Message + e.ExceptionObject.StackTrace; - errorMsg = errorMsg.Replace('"', '\'').Replace("\r\n", @"\n"); - - System.Windows.Browser.HtmlPage.Window.Eval("throw new Error(\"Unhandled Error in Silverlight 2 Application " + errorMsg + "\");"); - } - catch (Exception) - { - } - } - } -} \ No newline at end of file diff --git a/csharp/testdata/golden_message b/csharp/testdata/golden_message deleted file mode 100644 index 94898e49..00000000 Binary files a/csharp/testdata/golden_message and /dev/null differ diff --git a/csharp/testdata/golden_packed_fields_message b/csharp/testdata/golden_packed_fields_message deleted file mode 100644 index ee28d388..00000000 Binary files a/csharp/testdata/golden_packed_fields_message and /dev/null differ diff --git a/csharp/testdata/text_format_unittest_data.txt b/csharp/testdata/text_format_unittest_data.txt deleted file mode 100644 index d3e27b71..00000000 --- a/csharp/testdata/text_format_unittest_data.txt +++ /dev/null @@ -1,116 +0,0 @@ -optional_int32: 101 -optional_int64: 102 -optional_uint32: 103 -optional_uint64: 104 -optional_sint32: 105 -optional_sint64: 106 -optional_fixed32: 107 -optional_fixed64: 108 -optional_sfixed32: 109 -optional_sfixed64: 110 -optional_float: 111 -optional_double: 112 -optional_bool: true -optional_string: "115" -optional_bytes: "116" -OptionalGroup { - a: 117 -} -optional_nested_message { - bb: 118 -} -optional_foreign_message { - c: 119 -} -optional_import_message { - d: 120 -} -optional_nested_enum: BAZ -optional_foreign_enum: FOREIGN_BAZ -optional_import_enum: IMPORT_BAZ -optional_string_piece: "124" -optional_cord: "125" -repeated_int32: 201 -repeated_int32: 301 -repeated_int64: 202 -repeated_int64: 302 -repeated_uint32: 203 -repeated_uint32: 303 -repeated_uint64: 204 -repeated_uint64: 304 -repeated_sint32: 205 -repeated_sint32: 305 -repeated_sint64: 206 -repeated_sint64: 306 -repeated_fixed32: 207 -repeated_fixed32: 307 -repeated_fixed64: 208 -repeated_fixed64: 308 -repeated_sfixed32: 209 -repeated_sfixed32: 309 -repeated_sfixed64: 210 -repeated_sfixed64: 310 -repeated_float: 211 -repeated_float: 311 -repeated_double: 212 -repeated_double: 312 -repeated_bool: true -repeated_bool: false -repeated_string: "215" -repeated_string: "315" -repeated_bytes: "216" -repeated_bytes: "316" -RepeatedGroup { - a: 217 -} -RepeatedGroup { - a: 317 -} -repeated_nested_message { - bb: 218 -} -repeated_nested_message { - bb: 318 -} -repeated_foreign_message { - c: 219 -} -repeated_foreign_message { - c: 319 -} -repeated_import_message { - d: 220 -} -repeated_import_message { - d: 320 -} -repeated_nested_enum: BAR -repeated_nested_enum: BAZ -repeated_foreign_enum: FOREIGN_BAR -repeated_foreign_enum: FOREIGN_BAZ -repeated_import_enum: IMPORT_BAR -repeated_import_enum: IMPORT_BAZ -repeated_string_piece: "224" -repeated_string_piece: "324" -repeated_cord: "225" -repeated_cord: "325" -default_int32: 401 -default_int64: 402 -default_uint32: 403 -default_uint64: 404 -default_sint32: 405 -default_sint64: 406 -default_fixed32: 407 -default_fixed64: 408 -default_sfixed32: 409 -default_sfixed64: 410 -default_float: 411 -default_double: 412 -default_bool: false -default_string: "415" -default_bytes: "416" -default_nested_enum: FOO -default_foreign_enum: FOREIGN_FOO -default_import_enum: IMPORT_FOO -default_string_piece: "424" -default_cord: "425" diff --git a/csharp/testdata/text_format_unittest_extensions_data.txt b/csharp/testdata/text_format_unittest_extensions_data.txt deleted file mode 100644 index 4fc282c1..00000000 --- a/csharp/testdata/text_format_unittest_extensions_data.txt +++ /dev/null @@ -1,116 +0,0 @@ -[protobuf_unittest.optional_int32_extension]: 101 -[protobuf_unittest.optional_int64_extension]: 102 -[protobuf_unittest.optional_uint32_extension]: 103 -[protobuf_unittest.optional_uint64_extension]: 104 -[protobuf_unittest.optional_sint32_extension]: 105 -[protobuf_unittest.optional_sint64_extension]: 106 -[protobuf_unittest.optional_fixed32_extension]: 107 -[protobuf_unittest.optional_fixed64_extension]: 108 -[protobuf_unittest.optional_sfixed32_extension]: 109 -[protobuf_unittest.optional_sfixed64_extension]: 110 -[protobuf_unittest.optional_float_extension]: 111 -[protobuf_unittest.optional_double_extension]: 112 -[protobuf_unittest.optional_bool_extension]: true -[protobuf_unittest.optional_string_extension]: "115" -[protobuf_unittest.optional_bytes_extension]: "116" -[protobuf_unittest.optionalgroup_extension] { - a: 117 -} -[protobuf_unittest.optional_nested_message_extension] { - bb: 118 -} -[protobuf_unittest.optional_foreign_message_extension] { - c: 119 -} -[protobuf_unittest.optional_import_message_extension] { - d: 120 -} -[protobuf_unittest.optional_nested_enum_extension]: BAZ -[protobuf_unittest.optional_foreign_enum_extension]: FOREIGN_BAZ -[protobuf_unittest.optional_import_enum_extension]: IMPORT_BAZ -[protobuf_unittest.optional_string_piece_extension]: "124" -[protobuf_unittest.optional_cord_extension]: "125" -[protobuf_unittest.repeated_int32_extension]: 201 -[protobuf_unittest.repeated_int32_extension]: 301 -[protobuf_unittest.repeated_int64_extension]: 202 -[protobuf_unittest.repeated_int64_extension]: 302 -[protobuf_unittest.repeated_uint32_extension]: 203 -[protobuf_unittest.repeated_uint32_extension]: 303 -[protobuf_unittest.repeated_uint64_extension]: 204 -[protobuf_unittest.repeated_uint64_extension]: 304 -[protobuf_unittest.repeated_sint32_extension]: 205 -[protobuf_unittest.repeated_sint32_extension]: 305 -[protobuf_unittest.repeated_sint64_extension]: 206 -[protobuf_unittest.repeated_sint64_extension]: 306 -[protobuf_unittest.repeated_fixed32_extension]: 207 -[protobuf_unittest.repeated_fixed32_extension]: 307 -[protobuf_unittest.repeated_fixed64_extension]: 208 -[protobuf_unittest.repeated_fixed64_extension]: 308 -[protobuf_unittest.repeated_sfixed32_extension]: 209 -[protobuf_unittest.repeated_sfixed32_extension]: 309 -[protobuf_unittest.repeated_sfixed64_extension]: 210 -[protobuf_unittest.repeated_sfixed64_extension]: 310 -[protobuf_unittest.repeated_float_extension]: 211 -[protobuf_unittest.repeated_float_extension]: 311 -[protobuf_unittest.repeated_double_extension]: 212 -[protobuf_unittest.repeated_double_extension]: 312 -[protobuf_unittest.repeated_bool_extension]: true -[protobuf_unittest.repeated_bool_extension]: false -[protobuf_unittest.repeated_string_extension]: "215" -[protobuf_unittest.repeated_string_extension]: "315" -[protobuf_unittest.repeated_bytes_extension]: "216" -[protobuf_unittest.repeated_bytes_extension]: "316" -[protobuf_unittest.repeatedgroup_extension] { - a: 217 -} -[protobuf_unittest.repeatedgroup_extension] { - a: 317 -} -[protobuf_unittest.repeated_nested_message_extension] { - bb: 218 -} -[protobuf_unittest.repeated_nested_message_extension] { - bb: 318 -} -[protobuf_unittest.repeated_foreign_message_extension] { - c: 219 -} -[protobuf_unittest.repeated_foreign_message_extension] { - c: 319 -} -[protobuf_unittest.repeated_import_message_extension] { - d: 220 -} -[protobuf_unittest.repeated_import_message_extension] { - d: 320 -} -[protobuf_unittest.repeated_nested_enum_extension]: BAR -[protobuf_unittest.repeated_nested_enum_extension]: BAZ -[protobuf_unittest.repeated_foreign_enum_extension]: FOREIGN_BAR -[protobuf_unittest.repeated_foreign_enum_extension]: FOREIGN_BAZ -[protobuf_unittest.repeated_import_enum_extension]: IMPORT_BAR -[protobuf_unittest.repeated_import_enum_extension]: IMPORT_BAZ -[protobuf_unittest.repeated_string_piece_extension]: "224" -[protobuf_unittest.repeated_string_piece_extension]: "324" -[protobuf_unittest.repeated_cord_extension]: "225" -[protobuf_unittest.repeated_cord_extension]: "325" -[protobuf_unittest.default_int32_extension]: 401 -[protobuf_unittest.default_int64_extension]: 402 -[protobuf_unittest.default_uint32_extension]: 403 -[protobuf_unittest.default_uint64_extension]: 404 -[protobuf_unittest.default_sint32_extension]: 405 -[protobuf_unittest.default_sint64_extension]: 406 -[protobuf_unittest.default_fixed32_extension]: 407 -[protobuf_unittest.default_fixed64_extension]: 408 -[protobuf_unittest.default_sfixed32_extension]: 409 -[protobuf_unittest.default_sfixed64_extension]: 410 -[protobuf_unittest.default_float_extension]: 411 -[protobuf_unittest.default_double_extension]: 412 -[protobuf_unittest.default_bool_extension]: false -[protobuf_unittest.default_string_extension]: "415" -[protobuf_unittest.default_bytes_extension]: "416" -[protobuf_unittest.default_nested_enum_extension]: FOO -[protobuf_unittest.default_foreign_enum_extension]: FOREIGN_FOO -[protobuf_unittest.default_import_enum_extension]: IMPORT_FOO -[protobuf_unittest.default_string_piece_extension]: "424" -[protobuf_unittest.default_cord_extension]: "425" diff --git a/examples/addressbook.proto b/examples/addressbook.proto index 91c9ffc4..9ab45427 100644 --- a/examples/addressbook.proto +++ b/examples/addressbook.proto @@ -6,7 +6,7 @@ package tutorial; option java_package = "com.example.tutorial"; option java_outer_classname = "AddressBookProtos"; -option csharp_namespace = "Google.ProtocolBuffers.Examples.AddressBook"; +option csharp_namespace = "Google.Protobuf.Examples.AddressBook"; message Person { required string name = 1; diff --git a/src/google/protobuf/any.proto b/src/google/protobuf/any.proto index e1780fe5..458dfff2 100644 --- a/src/google/protobuf/any.proto +++ b/src/google/protobuf/any.proto @@ -35,7 +35,7 @@ option java_generate_equals_and_hash = true; option java_multiple_files = true; option java_outer_classname = "AnyProto"; option java_package = "com.google.protobuf"; -option csharp_namespace = "Google.ProtocolBuffers"; +option csharp_namespace = "Google.Protobuf"; option objc_class_prefix = "GPB"; diff --git a/src/google/protobuf/duration.proto b/src/google/protobuf/duration.proto index e466341a..dc6b575f 100644 --- a/src/google/protobuf/duration.proto +++ b/src/google/protobuf/duration.proto @@ -35,7 +35,7 @@ option java_generate_equals_and_hash = true; option java_multiple_files = true; option java_outer_classname = "DurationProto"; option java_package = "com.google.protobuf"; -option csharp_namespace = "Google.ProtocolBuffers"; +option csharp_namespace = "Google.Protobuf"; option objc_class_prefix = "GPB"; // A Duration represents a signed, fixed-length span of time represented diff --git a/src/google/protobuf/field_mask.proto b/src/google/protobuf/field_mask.proto index 35b1acc3..ad7a1dfa 100644 --- a/src/google/protobuf/field_mask.proto +++ b/src/google/protobuf/field_mask.proto @@ -34,7 +34,7 @@ package google.protobuf; option java_multiple_files = true; option java_outer_classname = "FieldMaskProto"; option java_package = "com.google.protobuf"; -option csharp_namespace = "Google.ProtocolBuffers"; +option csharp_namespace = "Google.Protobuf"; option objc_class_prefix = "GPB"; diff --git a/src/google/protobuf/map_lite_unittest.proto b/src/google/protobuf/map_lite_unittest.proto index febfe5f6..c69e8d94 100644 --- a/src/google/protobuf/map_lite_unittest.proto +++ b/src/google/protobuf/map_lite_unittest.proto @@ -32,7 +32,6 @@ syntax = "proto2"; option cc_enable_arenas = true; option optimize_for = LITE_RUNTIME; -option csharp_namespace = "Google.ProtocolBuffers.TestProtos"; import "google/protobuf/unittest_lite.proto"; diff --git a/src/google/protobuf/map_proto2_unittest.proto b/src/google/protobuf/map_proto2_unittest.proto index 04ca6170..3d4af28e 100644 --- a/src/google/protobuf/map_proto2_unittest.proto +++ b/src/google/protobuf/map_proto2_unittest.proto @@ -36,8 +36,6 @@ syntax = "proto2"; // In map_test_util.h we do "using namespace unittest = protobuf_unittest". package protobuf_unittest; -option csharp_namespace = "Google.ProtocolBuffers.TestProtos"; - enum Proto2MapEnum { PROTO2_MAP_ENUM_FOO = 0; PROTO2_MAP_ENUM_BAR = 1; diff --git a/src/google/protobuf/map_unittest.proto b/src/google/protobuf/map_unittest.proto index cbf747d9..b308c7ff 100644 --- a/src/google/protobuf/map_unittest.proto +++ b/src/google/protobuf/map_unittest.proto @@ -31,7 +31,6 @@ syntax = "proto3"; option cc_enable_arenas = true; -option csharp_namespace = "Google.ProtocolBuffers.TestProtos"; import "google/protobuf/unittest.proto"; diff --git a/src/google/protobuf/struct.proto b/src/google/protobuf/struct.proto index cd102731..a0ec961d 100644 --- a/src/google/protobuf/struct.proto +++ b/src/google/protobuf/struct.proto @@ -35,7 +35,7 @@ option java_generate_equals_and_hash = true; option java_multiple_files = true; option java_outer_classname = "StructProto"; option java_package = "com.google.protobuf"; -option csharp_namespace = "Google.ProtocolBuffers"; +option csharp_namespace = "Google.Protobuf"; option objc_class_prefix = "GPB"; diff --git a/src/google/protobuf/timestamp.proto b/src/google/protobuf/timestamp.proto index 381ff997..d49bd766 100644 --- a/src/google/protobuf/timestamp.proto +++ b/src/google/protobuf/timestamp.proto @@ -35,7 +35,7 @@ option java_generate_equals_and_hash = true; option java_multiple_files = true; option java_outer_classname = "TimestampProto"; option java_package = "com.google.protobuf"; -option csharp_namespace = "Google.ProtocolBuffers"; +option csharp_namespace = "Google.Protobuf"; option objc_class_prefix = "GPB"; diff --git a/src/google/protobuf/unittest.proto b/src/google/protobuf/unittest.proto index 834c9b56..85fe6153 100644 --- a/src/google/protobuf/unittest.proto +++ b/src/google/protobuf/unittest.proto @@ -42,7 +42,6 @@ option cc_generic_services = true; // auto-added option java_generic_services = true; // auto-added option py_generic_services = true; // auto-added option cc_enable_arenas = true; -option csharp_namespace = "Google.ProtocolBuffers.TestProtos"; import "google/protobuf/unittest_import.proto"; diff --git a/src/google/protobuf/unittest_custom_options.proto b/src/google/protobuf/unittest_custom_options.proto index 8f9fb582..d4d6e869 100644 --- a/src/google/protobuf/unittest_custom_options.proto +++ b/src/google/protobuf/unittest_custom_options.proto @@ -41,7 +41,6 @@ syntax = "proto2"; option cc_generic_services = true; // auto-added option java_generic_services = true; // auto-added option py_generic_services = true; -option csharp_namespace = "Google.ProtocolBuffers.TestProtos"; // A custom file option (defined below). option (file_opt1) = 9876543210; diff --git a/src/google/protobuf/unittest_drop_unknown_fields.proto b/src/google/protobuf/unittest_drop_unknown_fields.proto index faaddc6e..8aa3a37b 100644 --- a/src/google/protobuf/unittest_drop_unknown_fields.proto +++ b/src/google/protobuf/unittest_drop_unknown_fields.proto @@ -33,7 +33,7 @@ syntax = "proto3"; package unittest_drop_unknown_fields; option objc_class_prefix = "DropUnknowns"; -option csharp_namespace = "Google.ProtocolBuffers.TestProtos"; +option csharp_namespace = "Google.Protobuf.TestProtos"; message Foo { enum NestedEnum { diff --git a/src/google/protobuf/unittest_embed_optimize_for.proto b/src/google/protobuf/unittest_embed_optimize_for.proto index c4ccccb7..d8b0f9b9 100644 --- a/src/google/protobuf/unittest_embed_optimize_for.proto +++ b/src/google/protobuf/unittest_embed_optimize_for.proto @@ -39,8 +39,6 @@ import "google/protobuf/unittest_optimize_for.proto"; package protobuf_unittest; -option csharp_namespace = "Google.ProtocolBuffers.TestProtos"; - // We optimize for speed here, but we are importing a proto that is optimized // for code size. option optimize_for = SPEED; diff --git a/src/google/protobuf/unittest_enormous_descriptor.proto b/src/google/protobuf/unittest_enormous_descriptor.proto index f8fcc9c0..6e65dc18 100644 --- a/src/google/protobuf/unittest_enormous_descriptor.proto +++ b/src/google/protobuf/unittest_enormous_descriptor.proto @@ -40,7 +40,6 @@ syntax = "proto2"; package google.protobuf; option java_package = "com.google.protobuf"; -option csharp_namespace = "Google.ProtocolBuffers.TestProtos"; // Avoid generating insanely long methods. option optimize_for = CODE_SIZE; diff --git a/src/google/protobuf/unittest_import.proto b/src/google/protobuf/unittest_import.proto index ae2e90b8..7e165220 100644 --- a/src/google/protobuf/unittest_import.proto +++ b/src/google/protobuf/unittest_import.proto @@ -47,7 +47,6 @@ option cc_enable_arenas = true; // Exercise the java_package option. option java_package = "com.google.protobuf.test"; -option csharp_namespace = "Google.ProtocolBuffers.TestProtos"; // Do not set a java_outer_classname here to verify that Proto2 works without // one. diff --git a/src/google/protobuf/unittest_import_lite.proto b/src/google/protobuf/unittest_import_lite.proto index ca208582..a7afa452 100644 --- a/src/google/protobuf/unittest_import_lite.proto +++ b/src/google/protobuf/unittest_import_lite.proto @@ -38,7 +38,6 @@ package protobuf_unittest_import; option optimize_for = LITE_RUNTIME; option java_package = "com.google.protobuf"; -option csharp_namespace = "Google.ProtocolBuffers.TestProtos"; import public "google/protobuf/unittest_import_public_lite.proto"; diff --git a/src/google/protobuf/unittest_import_public.proto b/src/google/protobuf/unittest_import_public.proto index 0bc5d617..ffaf7736 100644 --- a/src/google/protobuf/unittest_import_public.proto +++ b/src/google/protobuf/unittest_import_public.proto @@ -35,7 +35,6 @@ syntax = "proto2"; package protobuf_unittest_import; option java_package = "com.google.protobuf.test"; -option csharp_namespace = "Google.ProtocolBuffers.TestProtos"; message PublicImportMessage { optional int32 e = 1; diff --git a/src/google/protobuf/unittest_import_public_lite.proto b/src/google/protobuf/unittest_import_public_lite.proto index 231ab9dd..33549c22 100644 --- a/src/google/protobuf/unittest_import_public_lite.proto +++ b/src/google/protobuf/unittest_import_public_lite.proto @@ -37,7 +37,6 @@ package protobuf_unittest_import; option optimize_for = LITE_RUNTIME; option java_package = "com.google.protobuf"; -option csharp_namespace = "Google.ProtocolBuffers.TestProtos"; message PublicImportMessageLite { optional int32 e = 1; diff --git a/src/google/protobuf/unittest_lite.proto b/src/google/protobuf/unittest_lite.proto index 0040874b..662c0e46 100644 --- a/src/google/protobuf/unittest_lite.proto +++ b/src/google/protobuf/unittest_lite.proto @@ -40,7 +40,6 @@ import "google/protobuf/unittest_import_lite.proto"; option optimize_for = LITE_RUNTIME; option java_package = "com.google.protobuf"; -option csharp_namespace = "Google.ProtocolBuffers.TestProtos"; // Same as TestAllTypes but with the lite runtime. message TestAllTypesLite { diff --git a/src/google/protobuf/unittest_lite_imports_nonlite.proto b/src/google/protobuf/unittest_lite_imports_nonlite.proto index d955cc14..132d6a82 100644 --- a/src/google/protobuf/unittest_lite_imports_nonlite.proto +++ b/src/google/protobuf/unittest_lite_imports_nonlite.proto @@ -38,7 +38,6 @@ package protobuf_unittest; import "google/protobuf/unittest.proto"; option optimize_for = LITE_RUNTIME; -option csharp_namespace = "Google.ProtocolBuffers.TestProtos"; message TestLiteImportsNonlite { optional TestAllTypes message = 1; diff --git a/src/google/protobuf/unittest_mset.proto b/src/google/protobuf/unittest_mset.proto index 425c9a5a..3aa31fa9 100644 --- a/src/google/protobuf/unittest_mset.proto +++ b/src/google/protobuf/unittest_mset.proto @@ -39,7 +39,6 @@ package protobuf_unittest; option cc_enable_arenas = true; option optimize_for = SPEED; -option csharp_namespace = "Google.ProtocolBuffers.TestProtos"; // A message with message_set_wire_format. message TestMessageSet { diff --git a/src/google/protobuf/unittest_no_field_presence.proto b/src/google/protobuf/unittest_no_field_presence.proto index f5cc4cc3..994afff4 100644 --- a/src/google/protobuf/unittest_no_field_presence.proto +++ b/src/google/protobuf/unittest_no_field_presence.proto @@ -37,8 +37,6 @@ import "google/protobuf/unittest.proto"; package proto2_nofieldpresence_unittest; -option csharp_namespace = "Google.ProtocolBuffers.TestProtos.Proto3"; - // This proto includes every type of field in both singular and repeated // forms. message TestAllTypes { diff --git a/src/google/protobuf/unittest_optimize_for.proto b/src/google/protobuf/unittest_optimize_for.proto index 2bcd16e4..ee9cc7bd 100644 --- a/src/google/protobuf/unittest_optimize_for.proto +++ b/src/google/protobuf/unittest_optimize_for.proto @@ -40,7 +40,6 @@ import "google/protobuf/unittest.proto"; package protobuf_unittest; option optimize_for = CODE_SIZE; -option csharp_namespace = "Google.ProtocolBuffers.TestProtos"; message TestOptimizedForSize { optional int32 i = 1; diff --git a/src/google/protobuf/unittest_preserve_unknown_enum.proto b/src/google/protobuf/unittest_preserve_unknown_enum.proto index abc3de28..2f91332c 100644 --- a/src/google/protobuf/unittest_preserve_unknown_enum.proto +++ b/src/google/protobuf/unittest_preserve_unknown_enum.proto @@ -33,7 +33,7 @@ syntax = "proto3"; package proto3_preserve_unknown_enum_unittest; option objc_class_prefix = "UnknownEnums"; -option csharp_namespace = "Google.ProtocolBuffers.TestProtos"; +option csharp_namespace = "Google.Protobuf.TestProtos"; enum MyEnum { FOO = 0; diff --git a/src/google/protobuf/unittest_preserve_unknown_enum2.proto b/src/google/protobuf/unittest_preserve_unknown_enum2.proto index 168b2407..adf42968 100644 --- a/src/google/protobuf/unittest_preserve_unknown_enum2.proto +++ b/src/google/protobuf/unittest_preserve_unknown_enum2.proto @@ -32,8 +32,6 @@ syntax = "proto2"; package proto2_preserve_unknown_enum_unittest; -option csharp_namespace = "Google.ProtocolBuffers.TestProtos"; - enum MyEnum { FOO = 0; BAR = 1; diff --git a/src/google/protobuf/unknown_enum_test.proto b/src/google/protobuf/unknown_enum_test.proto index 3c549cc7..0ea1ede3 100644 --- a/src/google/protobuf/unknown_enum_test.proto +++ b/src/google/protobuf/unknown_enum_test.proto @@ -36,8 +36,6 @@ syntax = "proto2"; package google.protobuf.util; -option csharp_namespace = "Google.ProtocolBuffers.TestProtos"; - message DownRevision { enum Enum { DEFAULT_VALUE = 2; diff --git a/src/google/protobuf/wrappers.proto b/src/google/protobuf/wrappers.proto index a13e6edb..14725524 100644 --- a/src/google/protobuf/wrappers.proto +++ b/src/google/protobuf/wrappers.proto @@ -40,7 +40,7 @@ package google.protobuf; option java_multiple_files = true; option java_outer_classname = "WrappersProto"; option java_package = "com.google.protobuf"; -option csharp_namespace = "Google.ProtocolBuffers"; +option csharp_namespace = "Google.Protobuf"; option objc_class_prefix = "GPB"; -- cgit v1.2.3 From 8d83f8d13e48507ab3d0de345184bf8f5ccc7da9 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Thu, 25 Jun 2015 17:46:57 +0100 Subject: Fix for doubly-nested types - issue #307. No specific test case - if the generated code compiles, the issue is fixed :) --- csharp/protos/extest/unittest_issues.proto | 9 + .../TestProtos/UnittestIssues.cs | 325 +++++++++++++++++++-- .../protobuf/compiler/csharp/csharp_helpers.cc | 2 +- 3 files changed, 314 insertions(+), 22 deletions(-) diff --git a/csharp/protos/extest/unittest_issues.proto b/csharp/protos/extest/unittest_issues.proto index c123acf1..33ce7d9b 100644 --- a/csharp/protos/extest/unittest_issues.proto +++ b/csharp/protos/extest/unittest_issues.proto @@ -9,6 +9,15 @@ option csharp_namespace = "UnitTest.Issues.TestProtos"; package unittest_issues; option optimize_for = SPEED; +// Issue 307: when generating doubly-nested types, any references +// should be of the form A.Types.B.Types.C. +message Issue307 { + message NestedOnce { + message NestedTwice { + } + } +} + // Old issue 13: http://code.google.com/p/protobuf-csharp-port/issues/detail?id=13 // New issue 309: https://github.com/google/protobuf/issues/309 diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs index 73876b8c..19de87de 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs @@ -13,6 +13,12 @@ namespace UnitTest.Issues.TestProtos { public static partial class UnittestIssues { #region Static variables + internal static pbd::MessageDescriptor internal__static_unittest_issues_Issue307__Descriptor; + internal static pb::FieldAccess.FieldAccessorTable internal__static_unittest_issues_Issue307__FieldAccessorTable; + internal static pbd::MessageDescriptor internal__static_unittest_issues_Issue307_NestedOnce__Descriptor; + internal static pb::FieldAccess.FieldAccessorTable internal__static_unittest_issues_Issue307_NestedOnce__FieldAccessorTable; + internal static pbd::MessageDescriptor internal__static_unittest_issues_Issue307_NestedOnce_NestedTwice__Descriptor; + internal static pb::FieldAccess.FieldAccessorTable internal__static_unittest_issues_Issue307_NestedOnce_NestedTwice__FieldAccessorTable; internal static pbd::MessageDescriptor internal__static_unittest_issues_NegativeEnumMessage__Descriptor; internal static pb::FieldAccess.FieldAccessorTable internal__static_unittest_issues_NegativeEnumMessage__FieldAccessorTable; internal static pbd::MessageDescriptor internal__static_unittest_issues_DeprecatedChild__Descriptor; @@ -31,38 +37,51 @@ namespace UnitTest.Issues.TestProtos { static UnittestIssues() { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( - "ChV1bml0dGVzdF9pc3N1ZXMucHJvdG8SD3VuaXR0ZXN0X2lzc3VlcyKwAQoT", - "TmVnYXRpdmVFbnVtTWVzc2FnZRIsCgV2YWx1ZRgBIAEoDjIdLnVuaXR0ZXN0", - "X2lzc3Vlcy5OZWdhdGl2ZUVudW0SMQoGdmFsdWVzGAIgAygOMh0udW5pdHRl", - "c3RfaXNzdWVzLk5lZ2F0aXZlRW51bUICEAASOAoNcGFja2VkX3ZhbHVlcxgD", - "IAMoDjIdLnVuaXR0ZXN0X2lzc3Vlcy5OZWdhdGl2ZUVudW1CAhABIhEKD0Rl", - "cHJlY2F0ZWRDaGlsZCK5AgoXRGVwcmVjYXRlZEZpZWxkc01lc3NhZ2USGgoO", - "UHJpbWl0aXZlVmFsdWUYASABKAVCAhgBEhoKDlByaW1pdGl2ZUFycmF5GAIg", - "AygFQgIYARI6CgxNZXNzYWdlVmFsdWUYAyABKAsyIC51bml0dGVzdF9pc3N1", - "ZXMuRGVwcmVjYXRlZENoaWxkQgIYARI6CgxNZXNzYWdlQXJyYXkYBCADKAsy", - "IC51bml0dGVzdF9pc3N1ZXMuRGVwcmVjYXRlZENoaWxkQgIYARI2CglFbnVt", - "VmFsdWUYBSABKA4yHy51bml0dGVzdF9pc3N1ZXMuRGVwcmVjYXRlZEVudW1C", - "AhgBEjYKCUVudW1BcnJheRgGIAMoDjIfLnVuaXR0ZXN0X2lzc3Vlcy5EZXBy", - "ZWNhdGVkRW51bUICGAEiGQoJSXRlbUZpZWxkEgwKBGl0ZW0YASABKAUqVQoM", - "TmVnYXRpdmVFbnVtEhYKEk5FR0FUSVZFX0VOVU1fWkVSTxAAEhYKCUZpdmVC", - "ZWxvdxD7//////////8BEhUKCE1pbnVzT25lEP///////////wEqLgoORGVw", - "cmVjYXRlZEVudW0SEwoPREVQUkVDQVRFRF9aRVJPEAASBwoDb25lEAFCH0gB", - "qgIaVW5pdFRlc3QuSXNzdWVzLlRlc3RQcm90b3NiBnByb3RvMw==")); + "ChV1bml0dGVzdF9pc3N1ZXMucHJvdG8SD3VuaXR0ZXN0X2lzc3VlcyInCghJ", + "c3N1ZTMwNxobCgpOZXN0ZWRPbmNlGg0KC05lc3RlZFR3aWNlIrABChNOZWdh", + "dGl2ZUVudW1NZXNzYWdlEiwKBXZhbHVlGAEgASgOMh0udW5pdHRlc3RfaXNz", + "dWVzLk5lZ2F0aXZlRW51bRIxCgZ2YWx1ZXMYAiADKA4yHS51bml0dGVzdF9p", + "c3N1ZXMuTmVnYXRpdmVFbnVtQgIQABI4Cg1wYWNrZWRfdmFsdWVzGAMgAygO", + "Mh0udW5pdHRlc3RfaXNzdWVzLk5lZ2F0aXZlRW51bUICEAEiEQoPRGVwcmVj", + "YXRlZENoaWxkIrkCChdEZXByZWNhdGVkRmllbGRzTWVzc2FnZRIaCg5Qcmlt", + "aXRpdmVWYWx1ZRgBIAEoBUICGAESGgoOUHJpbWl0aXZlQXJyYXkYAiADKAVC", + "AhgBEjoKDE1lc3NhZ2VWYWx1ZRgDIAEoCzIgLnVuaXR0ZXN0X2lzc3Vlcy5E", + "ZXByZWNhdGVkQ2hpbGRCAhgBEjoKDE1lc3NhZ2VBcnJheRgEIAMoCzIgLnVu", + "aXR0ZXN0X2lzc3Vlcy5EZXByZWNhdGVkQ2hpbGRCAhgBEjYKCUVudW1WYWx1", + "ZRgFIAEoDjIfLnVuaXR0ZXN0X2lzc3Vlcy5EZXByZWNhdGVkRW51bUICGAES", + "NgoJRW51bUFycmF5GAYgAygOMh8udW5pdHRlc3RfaXNzdWVzLkRlcHJlY2F0", + "ZWRFbnVtQgIYASIZCglJdGVtRmllbGQSDAoEaXRlbRgBIAEoBSpVCgxOZWdh", + "dGl2ZUVudW0SFgoSTkVHQVRJVkVfRU5VTV9aRVJPEAASFgoJRml2ZUJlbG93", + "EPv//////////wESFQoITWludXNPbmUQ////////////ASouCg5EZXByZWNh", + "dGVkRW51bRITCg9ERVBSRUNBVEVEX1pFUk8QABIHCgNvbmUQAUIfSAGqAhpV", + "bml0VGVzdC5Jc3N1ZXMuVGVzdFByb3Rvc2IGcHJvdG8z")); pbd::FileDescriptor.InternalDescriptorAssigner assigner = delegate(pbd::FileDescriptor root) { descriptor = root; - internal__static_unittest_issues_NegativeEnumMessage__Descriptor = Descriptor.MessageTypes[0]; + internal__static_unittest_issues_Issue307__Descriptor = Descriptor.MessageTypes[0]; + internal__static_unittest_issues_Issue307__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(internal__static_unittest_issues_Issue307__Descriptor, + new string[] { }); + internal__static_unittest_issues_Issue307_NestedOnce__Descriptor = internal__static_unittest_issues_Issue307__Descriptor.NestedTypes[0]; + internal__static_unittest_issues_Issue307_NestedOnce__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(internal__static_unittest_issues_Issue307_NestedOnce__Descriptor, + new string[] { }); + internal__static_unittest_issues_Issue307_NestedOnce_NestedTwice__Descriptor = internal__static_unittest_issues_Issue307_NestedOnce__Descriptor.NestedTypes[0]; + internal__static_unittest_issues_Issue307_NestedOnce_NestedTwice__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(internal__static_unittest_issues_Issue307_NestedOnce_NestedTwice__Descriptor, + new string[] { }); + internal__static_unittest_issues_NegativeEnumMessage__Descriptor = Descriptor.MessageTypes[1]; internal__static_unittest_issues_NegativeEnumMessage__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(internal__static_unittest_issues_NegativeEnumMessage__Descriptor, new string[] { "Value", "Values", "PackedValues", }); - internal__static_unittest_issues_DeprecatedChild__Descriptor = Descriptor.MessageTypes[1]; + internal__static_unittest_issues_DeprecatedChild__Descriptor = Descriptor.MessageTypes[2]; internal__static_unittest_issues_DeprecatedChild__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(internal__static_unittest_issues_DeprecatedChild__Descriptor, new string[] { }); - internal__static_unittest_issues_DeprecatedFieldsMessage__Descriptor = Descriptor.MessageTypes[2]; + internal__static_unittest_issues_DeprecatedFieldsMessage__Descriptor = Descriptor.MessageTypes[3]; internal__static_unittest_issues_DeprecatedFieldsMessage__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(internal__static_unittest_issues_DeprecatedFieldsMessage__Descriptor, new string[] { "PrimitiveValue", "PrimitiveArray", "MessageValue", "MessageArray", "EnumValue", "EnumArray", }); - internal__static_unittest_issues_ItemField__Descriptor = Descriptor.MessageTypes[3]; + internal__static_unittest_issues_ItemField__Descriptor = Descriptor.MessageTypes[4]; internal__static_unittest_issues_ItemField__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(internal__static_unittest_issues_ItemField__Descriptor, new string[] { "Item", }); @@ -89,6 +108,270 @@ namespace UnitTest.Issues.TestProtos { #endregion #region Messages + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class Issue307 : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Issue307()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { }; + private static readonly uint[] _fieldTags = new uint[] { }; + public static pbd::MessageDescriptor Descriptor { + get { return global::UnitTest.Issues.TestProtos.UnittestIssues.internal__static_unittest_issues_Issue307__Descriptor; } + } + + public pb::FieldAccess.FieldAccessorTable Fields { + get { return global::UnitTest.Issues.TestProtos.UnittestIssues.internal__static_unittest_issues_Issue307__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public Issue307() { } + + public Issue307(Issue307 other) { + } + + public Issue307 Clone() { + return new Issue307(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public override bool Equals(object other) { + return Equals(other as Issue307); + } + + public bool Equals(Issue307 other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + return true; + } + + public override int GetHashCode() { + int hash = 1; + return hash; + } + + public void WriteTo(pb::CodedOutputStream output) { + } + + public int CalculateSize() { + int size = 0; + return size; + } + + public void MergeFrom(Issue307 other) { + if (other == null) { + return; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + } + } + } + + #region Nested types + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static partial class Types { + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class NestedOnce : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedOnce()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { }; + private static readonly uint[] _fieldTags = new uint[] { }; + public static pbd::MessageDescriptor Descriptor { + get { return global::UnitTest.Issues.TestProtos.UnittestIssues.internal__static_unittest_issues_Issue307_NestedOnce__Descriptor; } + } + + public pb::FieldAccess.FieldAccessorTable Fields { + get { return global::UnitTest.Issues.TestProtos.UnittestIssues.internal__static_unittest_issues_Issue307_NestedOnce__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public NestedOnce() { } + + public NestedOnce(NestedOnce other) { + } + + public NestedOnce Clone() { + return new NestedOnce(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public override bool Equals(object other) { + return Equals(other as NestedOnce); + } + + public bool Equals(NestedOnce other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + return true; + } + + public override int GetHashCode() { + int hash = 1; + return hash; + } + + public void WriteTo(pb::CodedOutputStream output) { + } + + public int CalculateSize() { + int size = 0; + return size; + } + + public void MergeFrom(NestedOnce other) { + if (other == null) { + return; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + } + } + } + + #region Nested types + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static partial class Types { + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class NestedTwice : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedTwice()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { }; + private static readonly uint[] _fieldTags = new uint[] { }; + public static pbd::MessageDescriptor Descriptor { + get { return global::UnitTest.Issues.TestProtos.UnittestIssues.internal__static_unittest_issues_Issue307_NestedOnce_NestedTwice__Descriptor; } + } + + public pb::FieldAccess.FieldAccessorTable Fields { + get { return global::UnitTest.Issues.TestProtos.UnittestIssues.internal__static_unittest_issues_Issue307_NestedOnce_NestedTwice__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public NestedTwice() { } + + public NestedTwice(NestedTwice other) { + } + + public NestedTwice Clone() { + return new NestedTwice(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public override bool Equals(object other) { + return Equals(other as NestedTwice); + } + + public bool Equals(NestedTwice other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + return true; + } + + public override int GetHashCode() { + int hash = 1; + return hash; + } + + public void WriteTo(pb::CodedOutputStream output) { + } + + public int CalculateSize() { + int size = 0; + return size; + } + + public void MergeFrom(NestedTwice other) { + if (other == null) { + return; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + } + } + } + + } + + } + #endregion + + } + + } + #endregion + + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class NegativeEnumMessage : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NegativeEnumMessage()); diff --git a/src/google/protobuf/compiler/csharp/csharp_helpers.cc b/src/google/protobuf/compiler/csharp/csharp_helpers.cc index 927fea97..156ee328 100644 --- a/src/google/protobuf/compiler/csharp/csharp_helpers.cc +++ b/src/google/protobuf/compiler/csharp/csharp_helpers.cc @@ -206,7 +206,7 @@ std::string ToCSharpName(const std::string& name, const FileDescriptor* file) { // the C# namespace. classname = name.substr(file->package().size() + 1); } - result += StringReplace(classname, ".", ".Types.", false); + result += StringReplace(classname, ".", ".Types.", true); return "global::" + result; } -- cgit v1.2.3 From f2a27cc2c71b4dae3ff230574a73c1de88dd61b7 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Fri, 26 Jun 2015 17:37:14 +0100 Subject: First pass (not yet compiling) at removing all the array handling code from Coded*Stream. Prod code works, but some tests are broken. Obviously those need fixing, then more tests, and review benchmarks. --- csharp/src/AddressBook/Addressbook.cs | 30 +- .../TestProtos/UnittestIssues.cs | 89 +- .../TestProtos/UnittestProto3.cs | 1038 ++++++-------------- csharp/src/ProtocolBuffers/CodedInputStream.cs | 288 +----- csharp/src/ProtocolBuffers/CodedOutputStream.cs | 325 ------ csharp/src/ProtocolBuffers/Collections/MapField.cs | 10 +- .../ProtocolBuffers/Collections/RepeatedField.cs | 182 ++-- .../DescriptorProtos/DescriptorProtoFile.cs | 466 +++------ csharp/src/ProtocolBuffers/FieldCodec.cs | 56 +- .../compiler/csharp/csharp_repeated_enum_field.cc | 47 +- .../csharp/csharp_repeated_message_field.cc | 19 +- .../csharp/csharp_repeated_primitive_field.cc | 63 +- 12 files changed, 693 insertions(+), 1920 deletions(-) diff --git a/csharp/src/AddressBook/Addressbook.cs b/csharp/src/AddressBook/Addressbook.cs index c88ca424..4fd46471 100644 --- a/csharp/src/AddressBook/Addressbook.cs +++ b/csharp/src/AddressBook/Addressbook.cs @@ -131,6 +131,8 @@ namespace Google.Protobuf.Examples.AddressBook { } public const int PhoneFieldNumber = 4; + private static readonly pb::FieldCodec _repeated_phone_codec + = pb::FieldCodec.ForMessage(34, global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneNumber.Parser); private readonly pbc::RepeatedField phone_ = new pbc::RepeatedField(); public pbc::RepeatedField Phone { get { return phone_; } @@ -176,9 +178,7 @@ namespace Google.Protobuf.Examples.AddressBook { output.WriteRawTag(26); output.WriteString(Email); } - if (phone_.Count > 0) { - output.WriteMessageArray(4, phone_); - } + phone_.WriteTo(output, _repeated_phone_codec); } public int CalculateSize() { @@ -192,12 +192,7 @@ namespace Google.Protobuf.Examples.AddressBook { if (Email.Length != 0) { size += 1 + pb::CodedOutputStream.ComputeStringSize(Email); } - if (phone_.Count > 0) { - foreach (global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneNumber element in phone_) { - size += pb::CodedOutputStream.ComputeMessageSize(element); - } - size += 1 * phone_.Count; - } + size += phone_.CalculateSize(_repeated_phone_codec); return size; } @@ -241,7 +236,7 @@ namespace Google.Protobuf.Examples.AddressBook { break; } case 34: { - input.ReadMessageArray(phone_, global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneNumber.Parser); + phone_.AddEntriesFrom(input, _repeated_phone_codec); break; } } @@ -437,6 +432,8 @@ namespace Google.Protobuf.Examples.AddressBook { } public const int PersonFieldNumber = 1; + private static readonly pb::FieldCodec _repeated_person_codec + = pb::FieldCodec.ForMessage(10, global::Google.Protobuf.Examples.AddressBook.Person.Parser); private readonly pbc::RepeatedField person_ = new pbc::RepeatedField(); public pbc::RepeatedField Person { get { return person_; } @@ -464,19 +461,12 @@ namespace Google.Protobuf.Examples.AddressBook { } public void WriteTo(pb::CodedOutputStream output) { - if (person_.Count > 0) { - output.WriteMessageArray(1, person_); - } + person_.WriteTo(output, _repeated_person_codec); } public int CalculateSize() { int size = 0; - if (person_.Count > 0) { - foreach (global::Google.Protobuf.Examples.AddressBook.Person element in person_) { - size += pb::CodedOutputStream.ComputeMessageSize(element); - } - size += 1 * person_.Count; - } + size += person_.CalculateSize(_repeated_person_codec); return size; } @@ -499,7 +489,7 @@ namespace Google.Protobuf.Examples.AddressBook { } break; case 10: { - input.ReadMessageArray(person_, global::Google.Protobuf.Examples.AddressBook.Person.Parser); + person_.AddEntriesFrom(input, _repeated_person_codec); break; } } diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs index 19de87de..16bdb3f2 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs @@ -422,13 +422,15 @@ namespace UnitTest.Issues.TestProtos { } public const int ValuesFieldNumber = 2; - private readonly pbc::RepeatedField values_ = new pbc::RepeatedField(); + private static readonly pb::FieldCodec _repeated_values_codec + = pb::FieldCodec.ForEnum(16, x => (int) x, x => (global::UnitTest.Issues.TestProtos.NegativeEnum) x);private readonly pbc::RepeatedField values_ = new pbc::RepeatedField(); public pbc::RepeatedField Values { get { return values_; } } public const int PackedValuesFieldNumber = 3; - private readonly pbc::RepeatedField packedValues_ = new pbc::RepeatedField(); + private static readonly pb::FieldCodec _repeated_packedValues_codec + = pb::FieldCodec.ForEnum(26, x => (int) x, x => (global::UnitTest.Issues.TestProtos.NegativeEnum) x);private readonly pbc::RepeatedField packedValues_ = new pbc::RepeatedField(); public pbc::RepeatedField PackedValues { get { return packedValues_; } } @@ -463,13 +465,8 @@ namespace UnitTest.Issues.TestProtos { output.WriteRawTag(8); output.WriteEnum((int) Value); } - if (values_.Count > 0) { - output.WriteEnumArray(2, values_); - } - if (packedValues_.Count > 0) { - output.WriteRawTag(26); - output.WritePackedEnumArray(packedValues_); - } + values_.WriteTo(output, _repeated_values_codec); + packedValues_.WriteTo(output, _repeated_packedValues_codec); } public int CalculateSize() { @@ -477,22 +474,8 @@ namespace UnitTest.Issues.TestProtos { if (Value != global::UnitTest.Issues.TestProtos.NegativeEnum.NEGATIVE_ENUM_ZERO) { size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Value); } - if (values_.Count > 0) { - int dataSize = 0; - foreach (global::UnitTest.Issues.TestProtos.NegativeEnum element in values_) { - dataSize += pb::CodedOutputStream.ComputeEnumSize((int) element); - } - size += dataSize; - size += 1 * values_.Count; - } - if (packedValues_.Count > 0) { - int dataSize = 0; - foreach (global::UnitTest.Issues.TestProtos.NegativeEnum element in packedValues_) { - dataSize += pb::CodedOutputStream.ComputeEnumSize((int) element); - } - size += dataSize; - size += 1 + pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize); - } + size += values_.CalculateSize(_repeated_values_codec); + size += packedValues_.CalculateSize(_repeated_packedValues_codec); return size; } @@ -524,12 +507,12 @@ namespace UnitTest.Issues.TestProtos { } case 18: case 16: { - input.ReadEnumArray(values_); + values_.AddEntriesFrom(input, _repeated_values_codec); break; } case 26: case 24: { - input.ReadEnumArray(packedValues_); + packedValues_.AddEntriesFrom(input, _repeated_packedValues_codec); break; } } @@ -678,6 +661,8 @@ namespace UnitTest.Issues.TestProtos { } public const int PrimitiveArrayFieldNumber = 2; + private static readonly pb::FieldCodec _repeated_primitiveArray_codec + = pb::FieldCodec.ForInt32(18); private readonly pbc::RepeatedField primitiveArray_ = new pbc::RepeatedField(); [global::System.ObsoleteAttribute()] public pbc::RepeatedField PrimitiveArray { @@ -696,6 +681,8 @@ namespace UnitTest.Issues.TestProtos { } public const int MessageArrayFieldNumber = 4; + private static readonly pb::FieldCodec _repeated_messageArray_codec + = pb::FieldCodec.ForMessage(34, global::UnitTest.Issues.TestProtos.DeprecatedChild.Parser); private readonly pbc::RepeatedField messageArray_ = new pbc::RepeatedField(); [global::System.ObsoleteAttribute()] public pbc::RepeatedField MessageArray { @@ -714,7 +701,8 @@ namespace UnitTest.Issues.TestProtos { } public const int EnumArrayFieldNumber = 6; - private readonly pbc::RepeatedField enumArray_ = new pbc::RepeatedField(); + private static readonly pb::FieldCodec _repeated_enumArray_codec + = pb::FieldCodec.ForEnum(50, x => (int) x, x => (global::UnitTest.Issues.TestProtos.DeprecatedEnum) x);private readonly pbc::RepeatedField enumArray_ = new pbc::RepeatedField(); [global::System.ObsoleteAttribute()] public pbc::RepeatedField EnumArray { get { return enumArray_; } @@ -756,25 +744,17 @@ namespace UnitTest.Issues.TestProtos { output.WriteRawTag(8); output.WriteInt32(PrimitiveValue); } - if (primitiveArray_.Count > 0) { - output.WriteRawTag(18); - output.WritePackedInt32Array(primitiveArray_); - } + primitiveArray_.WriteTo(output, _repeated_primitiveArray_codec); if (messageValue_ != null) { output.WriteRawTag(26); output.WriteMessage(MessageValue); } - if (messageArray_.Count > 0) { - output.WriteMessageArray(4, messageArray_); - } + messageArray_.WriteTo(output, _repeated_messageArray_codec); if (EnumValue != global::UnitTest.Issues.TestProtos.DeprecatedEnum.DEPRECATED_ZERO) { output.WriteRawTag(40); output.WriteEnum((int) EnumValue); } - if (enumArray_.Count > 0) { - output.WriteRawTag(50); - output.WritePackedEnumArray(enumArray_); - } + enumArray_.WriteTo(output, _repeated_enumArray_codec); } public int CalculateSize() { @@ -782,34 +762,15 @@ namespace UnitTest.Issues.TestProtos { if (PrimitiveValue != 0) { size += 1 + pb::CodedOutputStream.ComputeInt32Size(PrimitiveValue); } - if (primitiveArray_.Count > 0) { - int dataSize = 0; - foreach (int element in primitiveArray_) { - dataSize += pb::CodedOutputStream.ComputeInt32Size(element); - } - size += dataSize; - size += 1 + pb::CodedOutputStream.ComputeInt32Size(dataSize); - } + size += primitiveArray_.CalculateSize(_repeated_primitiveArray_codec); if (messageValue_ != null) { size += 1 + pb::CodedOutputStream.ComputeMessageSize(MessageValue); } - if (messageArray_.Count > 0) { - foreach (global::UnitTest.Issues.TestProtos.DeprecatedChild element in messageArray_) { - size += pb::CodedOutputStream.ComputeMessageSize(element); - } - size += 1 * messageArray_.Count; - } + size += messageArray_.CalculateSize(_repeated_messageArray_codec); if (EnumValue != global::UnitTest.Issues.TestProtos.DeprecatedEnum.DEPRECATED_ZERO) { size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) EnumValue); } - if (enumArray_.Count > 0) { - int dataSize = 0; - foreach (global::UnitTest.Issues.TestProtos.DeprecatedEnum element in enumArray_) { - dataSize += pb::CodedOutputStream.ComputeEnumSize((int) element); - } - size += dataSize; - size += 1 + pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize); - } + size += enumArray_.CalculateSize(_repeated_enumArray_codec); return size; } @@ -851,7 +812,7 @@ namespace UnitTest.Issues.TestProtos { } case 18: case 16: { - input.ReadInt32Array(primitiveArray_); + primitiveArray_.AddEntriesFrom(input, _repeated_primitiveArray_codec); break; } case 26: { @@ -862,7 +823,7 @@ namespace UnitTest.Issues.TestProtos { break; } case 34: { - input.ReadMessageArray(messageArray_, global::UnitTest.Issues.TestProtos.DeprecatedChild.Parser); + messageArray_.AddEntriesFrom(input, _repeated_messageArray_codec); break; } case 40: { @@ -871,7 +832,7 @@ namespace UnitTest.Issues.TestProtos { } case 50: case 48: { - input.ReadEnumArray(enumArray_); + enumArray_.AddEntriesFrom(input, _repeated_enumArray_codec); break; } } diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs index 1ae2d9a9..ea486fcc 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs @@ -742,132 +742,173 @@ namespace Google.Protobuf.TestProtos { } public const int RepeatedInt32FieldNumber = 31; + private static readonly pb::FieldCodec _repeated_repeatedInt32_codec + = pb::FieldCodec.ForInt32(250); private readonly pbc::RepeatedField repeatedInt32_ = new pbc::RepeatedField(); public pbc::RepeatedField RepeatedInt32 { get { return repeatedInt32_; } } public const int RepeatedInt64FieldNumber = 32; + private static readonly pb::FieldCodec _repeated_repeatedInt64_codec + = pb::FieldCodec.ForInt64(258); private readonly pbc::RepeatedField repeatedInt64_ = new pbc::RepeatedField(); public pbc::RepeatedField RepeatedInt64 { get { return repeatedInt64_; } } public const int RepeatedUint32FieldNumber = 33; + private static readonly pb::FieldCodec _repeated_repeatedUint32_codec + = pb::FieldCodec.ForUInt32(266); private readonly pbc::RepeatedField repeatedUint32_ = new pbc::RepeatedField(); public pbc::RepeatedField RepeatedUint32 { get { return repeatedUint32_; } } public const int RepeatedUint64FieldNumber = 34; + private static readonly pb::FieldCodec _repeated_repeatedUint64_codec + = pb::FieldCodec.ForUInt64(274); private readonly pbc::RepeatedField repeatedUint64_ = new pbc::RepeatedField(); public pbc::RepeatedField RepeatedUint64 { get { return repeatedUint64_; } } public const int RepeatedSint32FieldNumber = 35; + private static readonly pb::FieldCodec _repeated_repeatedSint32_codec + = pb::FieldCodec.ForSInt32(282); private readonly pbc::RepeatedField repeatedSint32_ = new pbc::RepeatedField(); public pbc::RepeatedField RepeatedSint32 { get { return repeatedSint32_; } } public const int RepeatedSint64FieldNumber = 36; + private static readonly pb::FieldCodec _repeated_repeatedSint64_codec + = pb::FieldCodec.ForSInt64(290); private readonly pbc::RepeatedField repeatedSint64_ = new pbc::RepeatedField(); public pbc::RepeatedField RepeatedSint64 { get { return repeatedSint64_; } } public const int RepeatedFixed32FieldNumber = 37; + private static readonly pb::FieldCodec _repeated_repeatedFixed32_codec + = pb::FieldCodec.ForFixed32(298); private readonly pbc::RepeatedField repeatedFixed32_ = new pbc::RepeatedField(); public pbc::RepeatedField RepeatedFixed32 { get { return repeatedFixed32_; } } public const int RepeatedFixed64FieldNumber = 38; + private static readonly pb::FieldCodec _repeated_repeatedFixed64_codec + = pb::FieldCodec.ForFixed64(306); private readonly pbc::RepeatedField repeatedFixed64_ = new pbc::RepeatedField(); public pbc::RepeatedField RepeatedFixed64 { get { return repeatedFixed64_; } } public const int RepeatedSfixed32FieldNumber = 39; + private static readonly pb::FieldCodec _repeated_repeatedSfixed32_codec + = pb::FieldCodec.ForSFixed32(314); private readonly pbc::RepeatedField repeatedSfixed32_ = new pbc::RepeatedField(); public pbc::RepeatedField RepeatedSfixed32 { get { return repeatedSfixed32_; } } public const int RepeatedSfixed64FieldNumber = 40; + private static readonly pb::FieldCodec _repeated_repeatedSfixed64_codec + = pb::FieldCodec.ForSFixed64(322); private readonly pbc::RepeatedField repeatedSfixed64_ = new pbc::RepeatedField(); public pbc::RepeatedField RepeatedSfixed64 { get { return repeatedSfixed64_; } } public const int RepeatedFloatFieldNumber = 41; + private static readonly pb::FieldCodec _repeated_repeatedFloat_codec + = pb::FieldCodec.ForFloat(330); private readonly pbc::RepeatedField repeatedFloat_ = new pbc::RepeatedField(); public pbc::RepeatedField RepeatedFloat { get { return repeatedFloat_; } } public const int RepeatedDoubleFieldNumber = 42; + private static readonly pb::FieldCodec _repeated_repeatedDouble_codec + = pb::FieldCodec.ForDouble(338); private readonly pbc::RepeatedField repeatedDouble_ = new pbc::RepeatedField(); public pbc::RepeatedField RepeatedDouble { get { return repeatedDouble_; } } public const int RepeatedBoolFieldNumber = 43; + private static readonly pb::FieldCodec _repeated_repeatedBool_codec + = pb::FieldCodec.ForBool(346); private readonly pbc::RepeatedField repeatedBool_ = new pbc::RepeatedField(); public pbc::RepeatedField RepeatedBool { get { return repeatedBool_; } } public const int RepeatedStringFieldNumber = 44; + private static readonly pb::FieldCodec _repeated_repeatedString_codec + = pb::FieldCodec.ForString(354); private readonly pbc::RepeatedField repeatedString_ = new pbc::RepeatedField(); public pbc::RepeatedField RepeatedString { get { return repeatedString_; } } public const int RepeatedBytesFieldNumber = 45; + private static readonly pb::FieldCodec _repeated_repeatedBytes_codec + = pb::FieldCodec.ForBytes(362); private readonly pbc::RepeatedField repeatedBytes_ = new pbc::RepeatedField(); public pbc::RepeatedField RepeatedBytes { get { return repeatedBytes_; } } public const int RepeatedNestedMessageFieldNumber = 48; + private static readonly pb::FieldCodec _repeated_repeatedNestedMessage_codec + = pb::FieldCodec.ForMessage(386, global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage.Parser); private readonly pbc::RepeatedField repeatedNestedMessage_ = new pbc::RepeatedField(); public pbc::RepeatedField RepeatedNestedMessage { get { return repeatedNestedMessage_; } } public const int RepeatedForeignMessageFieldNumber = 49; + private static readonly pb::FieldCodec _repeated_repeatedForeignMessage_codec + = pb::FieldCodec.ForMessage(394, global::Google.Protobuf.TestProtos.ForeignMessage.Parser); private readonly pbc::RepeatedField repeatedForeignMessage_ = new pbc::RepeatedField(); public pbc::RepeatedField RepeatedForeignMessage { get { return repeatedForeignMessage_; } } public const int RepeatedImportMessageFieldNumber = 50; + private static readonly pb::FieldCodec _repeated_repeatedImportMessage_codec + = pb::FieldCodec.ForMessage(402, global::Google.Protobuf.TestProtos.ImportMessage.Parser); private readonly pbc::RepeatedField repeatedImportMessage_ = new pbc::RepeatedField(); public pbc::RepeatedField RepeatedImportMessage { get { return repeatedImportMessage_; } } public const int RepeatedNestedEnumFieldNumber = 51; - private readonly pbc::RepeatedField repeatedNestedEnum_ = new pbc::RepeatedField(); + private static readonly pb::FieldCodec _repeated_repeatedNestedEnum_codec + = pb::FieldCodec.ForEnum(410, x => (int) x, x => (global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum) x);private readonly pbc::RepeatedField repeatedNestedEnum_ = new pbc::RepeatedField(); public pbc::RepeatedField RepeatedNestedEnum { get { return repeatedNestedEnum_; } } public const int RepeatedForeignEnumFieldNumber = 52; - private readonly pbc::RepeatedField repeatedForeignEnum_ = new pbc::RepeatedField(); + private static readonly pb::FieldCodec _repeated_repeatedForeignEnum_codec + = pb::FieldCodec.ForEnum(418, x => (int) x, x => (global::Google.Protobuf.TestProtos.ForeignEnum) x);private readonly pbc::RepeatedField repeatedForeignEnum_ = new pbc::RepeatedField(); public pbc::RepeatedField RepeatedForeignEnum { get { return repeatedForeignEnum_; } } public const int RepeatedImportEnumFieldNumber = 53; - private readonly pbc::RepeatedField repeatedImportEnum_ = new pbc::RepeatedField(); + private static readonly pb::FieldCodec _repeated_repeatedImportEnum_codec + = pb::FieldCodec.ForEnum(426, x => (int) x, x => (global::Google.Protobuf.TestProtos.ImportEnum) x);private readonly pbc::RepeatedField repeatedImportEnum_ = new pbc::RepeatedField(); public pbc::RepeatedField RepeatedImportEnum { get { return repeatedImportEnum_; } } public const int RepeatedPublicImportMessageFieldNumber = 54; + private static readonly pb::FieldCodec _repeated_repeatedPublicImportMessage_codec + = pb::FieldCodec.ForMessage(434, global::Google.Protobuf.TestProtos.PublicImportMessage.Parser); private readonly pbc::RepeatedField repeatedPublicImportMessage_ = new pbc::RepeatedField(); public pbc::RepeatedField RepeatedPublicImportMessage { get { return repeatedPublicImportMessage_; } @@ -1136,88 +1177,28 @@ namespace Google.Protobuf.TestProtos { output.WriteRawTag(210, 1); output.WriteMessage(SinglePublicImportMessage); } - if (repeatedInt32_.Count > 0) { - output.WriteRawTag(250, 1); - output.WritePackedInt32Array(repeatedInt32_); - } - if (repeatedInt64_.Count > 0) { - output.WriteRawTag(130, 2); - output.WritePackedInt64Array(repeatedInt64_); - } - if (repeatedUint32_.Count > 0) { - output.WriteRawTag(138, 2); - output.WritePackedUInt32Array(repeatedUint32_); - } - if (repeatedUint64_.Count > 0) { - output.WriteRawTag(146, 2); - output.WritePackedUInt64Array(repeatedUint64_); - } - if (repeatedSint32_.Count > 0) { - output.WriteRawTag(154, 2); - output.WritePackedSInt32Array(repeatedSint32_); - } - if (repeatedSint64_.Count > 0) { - output.WriteRawTag(162, 2); - output.WritePackedSInt64Array(repeatedSint64_); - } - if (repeatedFixed32_.Count > 0) { - output.WriteRawTag(170, 2); - output.WritePackedFixed32Array(repeatedFixed32_); - } - if (repeatedFixed64_.Count > 0) { - output.WriteRawTag(178, 2); - output.WritePackedFixed64Array(repeatedFixed64_); - } - if (repeatedSfixed32_.Count > 0) { - output.WriteRawTag(186, 2); - output.WritePackedSFixed32Array(repeatedSfixed32_); - } - if (repeatedSfixed64_.Count > 0) { - output.WriteRawTag(194, 2); - output.WritePackedSFixed64Array(repeatedSfixed64_); - } - if (repeatedFloat_.Count > 0) { - output.WriteRawTag(202, 2); - output.WritePackedFloatArray(repeatedFloat_); - } - if (repeatedDouble_.Count > 0) { - output.WriteRawTag(210, 2); - output.WritePackedDoubleArray(repeatedDouble_); - } - if (repeatedBool_.Count > 0) { - output.WriteRawTag(218, 2); - output.WritePackedBoolArray(repeatedBool_); - } - if (repeatedString_.Count > 0) { - output.WriteStringArray(44, repeatedString_); - } - if (repeatedBytes_.Count > 0) { - output.WriteBytesArray(45, repeatedBytes_); - } - if (repeatedNestedMessage_.Count > 0) { - output.WriteMessageArray(48, repeatedNestedMessage_); - } - if (repeatedForeignMessage_.Count > 0) { - output.WriteMessageArray(49, repeatedForeignMessage_); - } - if (repeatedImportMessage_.Count > 0) { - output.WriteMessageArray(50, repeatedImportMessage_); - } - if (repeatedNestedEnum_.Count > 0) { - output.WriteRawTag(154, 3); - output.WritePackedEnumArray(repeatedNestedEnum_); - } - if (repeatedForeignEnum_.Count > 0) { - output.WriteRawTag(162, 3); - output.WritePackedEnumArray(repeatedForeignEnum_); - } - if (repeatedImportEnum_.Count > 0) { - output.WriteRawTag(170, 3); - output.WritePackedEnumArray(repeatedImportEnum_); - } - if (repeatedPublicImportMessage_.Count > 0) { - output.WriteMessageArray(54, repeatedPublicImportMessage_); - } + repeatedInt32_.WriteTo(output, _repeated_repeatedInt32_codec); + repeatedInt64_.WriteTo(output, _repeated_repeatedInt64_codec); + repeatedUint32_.WriteTo(output, _repeated_repeatedUint32_codec); + repeatedUint64_.WriteTo(output, _repeated_repeatedUint64_codec); + repeatedSint32_.WriteTo(output, _repeated_repeatedSint32_codec); + repeatedSint64_.WriteTo(output, _repeated_repeatedSint64_codec); + repeatedFixed32_.WriteTo(output, _repeated_repeatedFixed32_codec); + repeatedFixed64_.WriteTo(output, _repeated_repeatedFixed64_codec); + repeatedSfixed32_.WriteTo(output, _repeated_repeatedSfixed32_codec); + repeatedSfixed64_.WriteTo(output, _repeated_repeatedSfixed64_codec); + repeatedFloat_.WriteTo(output, _repeated_repeatedFloat_codec); + repeatedDouble_.WriteTo(output, _repeated_repeatedDouble_codec); + repeatedBool_.WriteTo(output, _repeated_repeatedBool_codec); + repeatedString_.WriteTo(output, _repeated_repeatedString_codec); + repeatedBytes_.WriteTo(output, _repeated_repeatedBytes_codec); + repeatedNestedMessage_.WriteTo(output, _repeated_repeatedNestedMessage_codec); + repeatedForeignMessage_.WriteTo(output, _repeated_repeatedForeignMessage_codec); + repeatedImportMessage_.WriteTo(output, _repeated_repeatedImportMessage_codec); + repeatedNestedEnum_.WriteTo(output, _repeated_repeatedNestedEnum_codec); + repeatedForeignEnum_.WriteTo(output, _repeated_repeatedForeignEnum_codec); + repeatedImportEnum_.WriteTo(output, _repeated_repeatedImportEnum_codec); + repeatedPublicImportMessage_.WriteTo(output, _repeated_repeatedPublicImportMessage_codec); if (oneofFieldCase_ == OneofFieldOneofCase.OneofUint32) { output.WriteRawTag(248, 6); output.WriteUInt32(OneofUint32); @@ -1304,160 +1285,28 @@ namespace Google.Protobuf.TestProtos { if (singlePublicImportMessage_ != null) { size += 2 + pb::CodedOutputStream.ComputeMessageSize(SinglePublicImportMessage); } - if (repeatedInt32_.Count > 0) { - int dataSize = 0; - foreach (int element in repeatedInt32_) { - dataSize += pb::CodedOutputStream.ComputeInt32Size(element); - } - size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); - } - if (repeatedInt64_.Count > 0) { - int dataSize = 0; - foreach (long element in repeatedInt64_) { - dataSize += pb::CodedOutputStream.ComputeInt64Size(element); - } - size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); - } - if (repeatedUint32_.Count > 0) { - int dataSize = 0; - foreach (uint element in repeatedUint32_) { - dataSize += pb::CodedOutputStream.ComputeUInt32Size(element); - } - size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); - } - if (repeatedUint64_.Count > 0) { - int dataSize = 0; - foreach (ulong element in repeatedUint64_) { - dataSize += pb::CodedOutputStream.ComputeUInt64Size(element); - } - size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); - } - if (repeatedSint32_.Count > 0) { - int dataSize = 0; - foreach (int element in repeatedSint32_) { - dataSize += pb::CodedOutputStream.ComputeSInt32Size(element); - } - size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); - } - if (repeatedSint64_.Count > 0) { - int dataSize = 0; - foreach (long element in repeatedSint64_) { - dataSize += pb::CodedOutputStream.ComputeSInt64Size(element); - } - size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); - } - if (repeatedFixed32_.Count > 0) { - int dataSize = 0; - dataSize = 4 * repeatedFixed32_.Count; - size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); - } - if (repeatedFixed64_.Count > 0) { - int dataSize = 0; - dataSize = 8 * repeatedFixed64_.Count; - size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); - } - if (repeatedSfixed32_.Count > 0) { - int dataSize = 0; - dataSize = 4 * repeatedSfixed32_.Count; - size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); - } - if (repeatedSfixed64_.Count > 0) { - int dataSize = 0; - dataSize = 8 * repeatedSfixed64_.Count; - size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); - } - if (repeatedFloat_.Count > 0) { - int dataSize = 0; - dataSize = 4 * repeatedFloat_.Count; - size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); - } - if (repeatedDouble_.Count > 0) { - int dataSize = 0; - dataSize = 8 * repeatedDouble_.Count; - size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); - } - if (repeatedBool_.Count > 0) { - int dataSize = 0; - dataSize = 1 * repeatedBool_.Count; - size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); - } - if (repeatedString_.Count > 0) { - int dataSize = 0; - foreach (string element in repeatedString_) { - dataSize += pb::CodedOutputStream.ComputeStringSize(element); - } - size += dataSize; - size += 2 * repeatedString_.Count; - } - if (repeatedBytes_.Count > 0) { - int dataSize = 0; - foreach (pb::ByteString element in repeatedBytes_) { - dataSize += pb::CodedOutputStream.ComputeBytesSize(element); - } - size += dataSize; - size += 2 * repeatedBytes_.Count; - } - if (repeatedNestedMessage_.Count > 0) { - foreach (global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage element in repeatedNestedMessage_) { - size += pb::CodedOutputStream.ComputeMessageSize(element); - } - size += 2 * repeatedNestedMessage_.Count; - } - if (repeatedForeignMessage_.Count > 0) { - foreach (global::Google.Protobuf.TestProtos.ForeignMessage element in repeatedForeignMessage_) { - size += pb::CodedOutputStream.ComputeMessageSize(element); - } - size += 2 * repeatedForeignMessage_.Count; - } - if (repeatedImportMessage_.Count > 0) { - foreach (global::Google.Protobuf.TestProtos.ImportMessage element in repeatedImportMessage_) { - size += pb::CodedOutputStream.ComputeMessageSize(element); - } - size += 2 * repeatedImportMessage_.Count; - } - if (repeatedNestedEnum_.Count > 0) { - int dataSize = 0; - foreach (global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum element in repeatedNestedEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSize((int) element); - } - size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize); - } - if (repeatedForeignEnum_.Count > 0) { - int dataSize = 0; - foreach (global::Google.Protobuf.TestProtos.ForeignEnum element in repeatedForeignEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSize((int) element); - } - size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize); - } - if (repeatedImportEnum_.Count > 0) { - int dataSize = 0; - foreach (global::Google.Protobuf.TestProtos.ImportEnum element in repeatedImportEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSize((int) element); - } - size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize); - } - if (repeatedPublicImportMessage_.Count > 0) { - foreach (global::Google.Protobuf.TestProtos.PublicImportMessage element in repeatedPublicImportMessage_) { - size += pb::CodedOutputStream.ComputeMessageSize(element); - } - size += 2 * repeatedPublicImportMessage_.Count; - } + size += repeatedInt32_.CalculateSize(_repeated_repeatedInt32_codec); + size += repeatedInt64_.CalculateSize(_repeated_repeatedInt64_codec); + size += repeatedUint32_.CalculateSize(_repeated_repeatedUint32_codec); + size += repeatedUint64_.CalculateSize(_repeated_repeatedUint64_codec); + size += repeatedSint32_.CalculateSize(_repeated_repeatedSint32_codec); + size += repeatedSint64_.CalculateSize(_repeated_repeatedSint64_codec); + size += repeatedFixed32_.CalculateSize(_repeated_repeatedFixed32_codec); + size += repeatedFixed64_.CalculateSize(_repeated_repeatedFixed64_codec); + size += repeatedSfixed32_.CalculateSize(_repeated_repeatedSfixed32_codec); + size += repeatedSfixed64_.CalculateSize(_repeated_repeatedSfixed64_codec); + size += repeatedFloat_.CalculateSize(_repeated_repeatedFloat_codec); + size += repeatedDouble_.CalculateSize(_repeated_repeatedDouble_codec); + size += repeatedBool_.CalculateSize(_repeated_repeatedBool_codec); + size += repeatedString_.CalculateSize(_repeated_repeatedString_codec); + size += repeatedBytes_.CalculateSize(_repeated_repeatedBytes_codec); + size += repeatedNestedMessage_.CalculateSize(_repeated_repeatedNestedMessage_codec); + size += repeatedForeignMessage_.CalculateSize(_repeated_repeatedForeignMessage_codec); + size += repeatedImportMessage_.CalculateSize(_repeated_repeatedImportMessage_codec); + size += repeatedNestedEnum_.CalculateSize(_repeated_repeatedNestedEnum_codec); + size += repeatedForeignEnum_.CalculateSize(_repeated_repeatedForeignEnum_codec); + size += repeatedImportEnum_.CalculateSize(_repeated_repeatedImportEnum_codec); + size += repeatedPublicImportMessage_.CalculateSize(_repeated_repeatedPublicImportMessage_codec); if (oneofFieldCase_ == OneofFieldOneofCase.OneofUint32) { size += 2 + pb::CodedOutputStream.ComputeUInt32Size(OneofUint32); } @@ -1707,106 +1556,106 @@ namespace Google.Protobuf.TestProtos { } case 250: case 248: { - input.ReadInt32Array(repeatedInt32_); + repeatedInt32_.AddEntriesFrom(input, _repeated_repeatedInt32_codec); break; } case 258: case 256: { - input.ReadInt64Array(repeatedInt64_); + repeatedInt64_.AddEntriesFrom(input, _repeated_repeatedInt64_codec); break; } case 266: case 264: { - input.ReadUInt32Array(repeatedUint32_); + repeatedUint32_.AddEntriesFrom(input, _repeated_repeatedUint32_codec); break; } case 274: case 272: { - input.ReadUInt64Array(repeatedUint64_); + repeatedUint64_.AddEntriesFrom(input, _repeated_repeatedUint64_codec); break; } case 282: case 280: { - input.ReadSInt32Array(repeatedSint32_); + repeatedSint32_.AddEntriesFrom(input, _repeated_repeatedSint32_codec); break; } case 290: case 288: { - input.ReadSInt64Array(repeatedSint64_); + repeatedSint64_.AddEntriesFrom(input, _repeated_repeatedSint64_codec); break; } case 298: case 301: { - input.ReadFixed32Array(repeatedFixed32_); + repeatedFixed32_.AddEntriesFrom(input, _repeated_repeatedFixed32_codec); break; } case 306: case 305: { - input.ReadFixed64Array(repeatedFixed64_); + repeatedFixed64_.AddEntriesFrom(input, _repeated_repeatedFixed64_codec); break; } case 314: case 317: { - input.ReadSFixed32Array(repeatedSfixed32_); + repeatedSfixed32_.AddEntriesFrom(input, _repeated_repeatedSfixed32_codec); break; } case 322: case 321: { - input.ReadSFixed64Array(repeatedSfixed64_); + repeatedSfixed64_.AddEntriesFrom(input, _repeated_repeatedSfixed64_codec); break; } case 330: case 333: { - input.ReadFloatArray(repeatedFloat_); + repeatedFloat_.AddEntriesFrom(input, _repeated_repeatedFloat_codec); break; } case 338: case 337: { - input.ReadDoubleArray(repeatedDouble_); + repeatedDouble_.AddEntriesFrom(input, _repeated_repeatedDouble_codec); break; } case 346: case 344: { - input.ReadBoolArray(repeatedBool_); + repeatedBool_.AddEntriesFrom(input, _repeated_repeatedBool_codec); break; } case 354: { - input.ReadStringArray(repeatedString_); + repeatedString_.AddEntriesFrom(input, _repeated_repeatedString_codec); break; } case 362: { - input.ReadBytesArray(repeatedBytes_); + repeatedBytes_.AddEntriesFrom(input, _repeated_repeatedBytes_codec); break; } case 386: { - input.ReadMessageArray(repeatedNestedMessage_, global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage.Parser); + repeatedNestedMessage_.AddEntriesFrom(input, _repeated_repeatedNestedMessage_codec); break; } case 394: { - input.ReadMessageArray(repeatedForeignMessage_, global::Google.Protobuf.TestProtos.ForeignMessage.Parser); + repeatedForeignMessage_.AddEntriesFrom(input, _repeated_repeatedForeignMessage_codec); break; } case 402: { - input.ReadMessageArray(repeatedImportMessage_, global::Google.Protobuf.TestProtos.ImportMessage.Parser); + repeatedImportMessage_.AddEntriesFrom(input, _repeated_repeatedImportMessage_codec); break; } case 410: case 408: { - input.ReadEnumArray(repeatedNestedEnum_); + repeatedNestedEnum_.AddEntriesFrom(input, _repeated_repeatedNestedEnum_codec); break; } case 418: case 416: { - input.ReadEnumArray(repeatedForeignEnum_); + repeatedForeignEnum_.AddEntriesFrom(input, _repeated_repeatedForeignEnum_codec); break; } case 426: case 424: { - input.ReadEnumArray(repeatedImportEnum_); + repeatedImportEnum_.AddEntriesFrom(input, _repeated_repeatedImportEnum_codec); break; } case 434: { - input.ReadMessageArray(repeatedPublicImportMessage_, global::Google.Protobuf.TestProtos.PublicImportMessage.Parser); + repeatedPublicImportMessage_.AddEntriesFrom(input, _repeated_repeatedPublicImportMessage_codec); break; } case 888: { @@ -2022,6 +1871,8 @@ namespace Google.Protobuf.TestProtos { } public const int RepeatedChildFieldNumber = 3; + private static readonly pb::FieldCodec _repeated_repeatedChild_codec + = pb::FieldCodec.ForMessage(26, global::Google.Protobuf.TestProtos.NestedTestAllTypes.Parser); private readonly pbc::RepeatedField repeatedChild_ = new pbc::RepeatedField(); public pbc::RepeatedField RepeatedChild { get { return repeatedChild_; } @@ -2061,9 +1912,7 @@ namespace Google.Protobuf.TestProtos { output.WriteRawTag(18); output.WriteMessage(Payload); } - if (repeatedChild_.Count > 0) { - output.WriteMessageArray(3, repeatedChild_); - } + repeatedChild_.WriteTo(output, _repeated_repeatedChild_codec); } public int CalculateSize() { @@ -2074,12 +1923,7 @@ namespace Google.Protobuf.TestProtos { if (payload_ != null) { size += 1 + pb::CodedOutputStream.ComputeMessageSize(Payload); } - if (repeatedChild_.Count > 0) { - foreach (global::Google.Protobuf.TestProtos.NestedTestAllTypes element in repeatedChild_) { - size += pb::CodedOutputStream.ComputeMessageSize(element); - } - size += 1 * repeatedChild_.Count; - } + size += repeatedChild_.CalculateSize(_repeated_repeatedChild_codec); return size; } @@ -2128,7 +1972,7 @@ namespace Google.Protobuf.TestProtos { break; } case 26: { - input.ReadMessageArray(repeatedChild_, global::Google.Protobuf.TestProtos.NestedTestAllTypes.Parser); + repeatedChild_.AddEntriesFrom(input, _repeated_repeatedChild_codec); break; } } @@ -3196,24 +3040,31 @@ namespace Google.Protobuf.TestProtos { } public const int RepeatedPrimitiveFieldFieldNumber = 7; + private static readonly pb::FieldCodec _repeated_repeatedPrimitiveField_codec + = pb::FieldCodec.ForInt32(58); private readonly pbc::RepeatedField repeatedPrimitiveField_ = new pbc::RepeatedField(); public pbc::RepeatedField RepeatedPrimitiveField { get { return repeatedPrimitiveField_; } } public const int RepeatedStringFieldFieldNumber = 8; + private static readonly pb::FieldCodec _repeated_repeatedStringField_codec + = pb::FieldCodec.ForString(66); private readonly pbc::RepeatedField repeatedStringField_ = new pbc::RepeatedField(); public pbc::RepeatedField RepeatedStringField { get { return repeatedStringField_; } } public const int RepeatedEnumFieldFieldNumber = 9; - private readonly pbc::RepeatedField repeatedEnumField_ = new pbc::RepeatedField(); + private static readonly pb::FieldCodec _repeated_repeatedEnumField_codec + = pb::FieldCodec.ForEnum(74, x => (int) x, x => (global::Google.Protobuf.TestProtos.ForeignEnum) x);private readonly pbc::RepeatedField repeatedEnumField_ = new pbc::RepeatedField(); public pbc::RepeatedField RepeatedEnumField { get { return repeatedEnumField_; } } public const int RepeatedMessageFieldFieldNumber = 10; + private static readonly pb::FieldCodec _repeated_repeatedMessageField_codec + = pb::FieldCodec.ForMessage(82, global::Google.Protobuf.TestProtos.ForeignMessage.Parser); private readonly pbc::RepeatedField repeatedMessageField_ = new pbc::RepeatedField(); public pbc::RepeatedField RepeatedMessageField { get { return repeatedMessageField_; } @@ -3271,20 +3122,10 @@ namespace Google.Protobuf.TestProtos { output.WriteRawTag(34); output.WriteMessage(MessageField); } - if (repeatedPrimitiveField_.Count > 0) { - output.WriteRawTag(58); - output.WritePackedInt32Array(repeatedPrimitiveField_); - } - if (repeatedStringField_.Count > 0) { - output.WriteStringArray(8, repeatedStringField_); - } - if (repeatedEnumField_.Count > 0) { - output.WriteRawTag(74); - output.WritePackedEnumArray(repeatedEnumField_); - } - if (repeatedMessageField_.Count > 0) { - output.WriteMessageArray(10, repeatedMessageField_); - } + repeatedPrimitiveField_.WriteTo(output, _repeated_repeatedPrimitiveField_codec); + repeatedStringField_.WriteTo(output, _repeated_repeatedStringField_codec); + repeatedEnumField_.WriteTo(output, _repeated_repeatedEnumField_codec); + repeatedMessageField_.WriteTo(output, _repeated_repeatedMessageField_codec); } public int CalculateSize() { @@ -3301,36 +3142,10 @@ namespace Google.Protobuf.TestProtos { if (messageField_ != null) { size += 1 + pb::CodedOutputStream.ComputeMessageSize(MessageField); } - if (repeatedPrimitiveField_.Count > 0) { - int dataSize = 0; - foreach (int element in repeatedPrimitiveField_) { - dataSize += pb::CodedOutputStream.ComputeInt32Size(element); - } - size += dataSize; - size += 1 + pb::CodedOutputStream.ComputeInt32Size(dataSize); - } - if (repeatedStringField_.Count > 0) { - int dataSize = 0; - foreach (string element in repeatedStringField_) { - dataSize += pb::CodedOutputStream.ComputeStringSize(element); - } - size += dataSize; - size += 1 * repeatedStringField_.Count; - } - if (repeatedEnumField_.Count > 0) { - int dataSize = 0; - foreach (global::Google.Protobuf.TestProtos.ForeignEnum element in repeatedEnumField_) { - dataSize += pb::CodedOutputStream.ComputeEnumSize((int) element); - } - size += dataSize; - size += 1 + pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize); - } - if (repeatedMessageField_.Count > 0) { - foreach (global::Google.Protobuf.TestProtos.ForeignMessage element in repeatedMessageField_) { - size += pb::CodedOutputStream.ComputeMessageSize(element); - } - size += 1 * repeatedMessageField_.Count; - } + size += repeatedPrimitiveField_.CalculateSize(_repeated_repeatedPrimitiveField_codec); + size += repeatedStringField_.CalculateSize(_repeated_repeatedStringField_codec); + size += repeatedEnumField_.CalculateSize(_repeated_repeatedEnumField_codec); + size += repeatedMessageField_.CalculateSize(_repeated_repeatedMessageField_codec); return size; } @@ -3391,20 +3206,20 @@ namespace Google.Protobuf.TestProtos { } case 58: case 56: { - input.ReadInt32Array(repeatedPrimitiveField_); + repeatedPrimitiveField_.AddEntriesFrom(input, _repeated_repeatedPrimitiveField_codec); break; } case 66: { - input.ReadStringArray(repeatedStringField_); + repeatedStringField_.AddEntriesFrom(input, _repeated_repeatedStringField_codec); break; } case 74: case 72: { - input.ReadEnumArray(repeatedEnumField_); + repeatedEnumField_.AddEntriesFrom(input, _repeated_repeatedEnumField_codec); break; } case 82: { - input.ReadMessageArray(repeatedMessageField_, global::Google.Protobuf.TestProtos.ForeignMessage.Parser); + repeatedMessageField_.AddEntriesFrom(input, _repeated_repeatedMessageField_codec); break; } } @@ -4015,6 +3830,8 @@ namespace Google.Protobuf.TestProtos { } public const int DataFieldNumber = 1; + private static readonly pb::FieldCodec _repeated_data_codec + = pb::FieldCodec.ForString(10); private readonly pbc::RepeatedField data_ = new pbc::RepeatedField(); public pbc::RepeatedField Data { get { return data_; } @@ -4042,21 +3859,12 @@ namespace Google.Protobuf.TestProtos { } public void WriteTo(pb::CodedOutputStream output) { - if (data_.Count > 0) { - output.WriteStringArray(1, data_); - } + data_.WriteTo(output, _repeated_data_codec); } public int CalculateSize() { int size = 0; - if (data_.Count > 0) { - int dataSize = 0; - foreach (string element in data_) { - dataSize += pb::CodedOutputStream.ComputeStringSize(element); - } - size += dataSize; - size += 1 * data_.Count; - } + size += data_.CalculateSize(_repeated_data_codec); return size; } @@ -4079,7 +3887,7 @@ namespace Google.Protobuf.TestProtos { } break; case 10: { - input.ReadStringArray(data_); + data_.AddEntriesFrom(input, _repeated_data_codec); break; } } @@ -5129,85 +4937,112 @@ namespace Google.Protobuf.TestProtos { } public const int PackedInt32FieldNumber = 90; + private static readonly pb::FieldCodec _repeated_packedInt32_codec + = pb::FieldCodec.ForInt32(722); private readonly pbc::RepeatedField packedInt32_ = new pbc::RepeatedField(); public pbc::RepeatedField PackedInt32 { get { return packedInt32_; } } public const int PackedInt64FieldNumber = 91; + private static readonly pb::FieldCodec _repeated_packedInt64_codec + = pb::FieldCodec.ForInt64(730); private readonly pbc::RepeatedField packedInt64_ = new pbc::RepeatedField(); public pbc::RepeatedField PackedInt64 { get { return packedInt64_; } } public const int PackedUint32FieldNumber = 92; + private static readonly pb::FieldCodec _repeated_packedUint32_codec + = pb::FieldCodec.ForUInt32(738); private readonly pbc::RepeatedField packedUint32_ = new pbc::RepeatedField(); public pbc::RepeatedField PackedUint32 { get { return packedUint32_; } } public const int PackedUint64FieldNumber = 93; + private static readonly pb::FieldCodec _repeated_packedUint64_codec + = pb::FieldCodec.ForUInt64(746); private readonly pbc::RepeatedField packedUint64_ = new pbc::RepeatedField(); public pbc::RepeatedField PackedUint64 { get { return packedUint64_; } } public const int PackedSint32FieldNumber = 94; + private static readonly pb::FieldCodec _repeated_packedSint32_codec + = pb::FieldCodec.ForSInt32(754); private readonly pbc::RepeatedField packedSint32_ = new pbc::RepeatedField(); public pbc::RepeatedField PackedSint32 { get { return packedSint32_; } } public const int PackedSint64FieldNumber = 95; + private static readonly pb::FieldCodec _repeated_packedSint64_codec + = pb::FieldCodec.ForSInt64(762); private readonly pbc::RepeatedField packedSint64_ = new pbc::RepeatedField(); public pbc::RepeatedField PackedSint64 { get { return packedSint64_; } } public const int PackedFixed32FieldNumber = 96; + private static readonly pb::FieldCodec _repeated_packedFixed32_codec + = pb::FieldCodec.ForFixed32(770); private readonly pbc::RepeatedField packedFixed32_ = new pbc::RepeatedField(); public pbc::RepeatedField PackedFixed32 { get { return packedFixed32_; } } public const int PackedFixed64FieldNumber = 97; + private static readonly pb::FieldCodec _repeated_packedFixed64_codec + = pb::FieldCodec.ForFixed64(778); private readonly pbc::RepeatedField packedFixed64_ = new pbc::RepeatedField(); public pbc::RepeatedField PackedFixed64 { get { return packedFixed64_; } } public const int PackedSfixed32FieldNumber = 98; + private static readonly pb::FieldCodec _repeated_packedSfixed32_codec + = pb::FieldCodec.ForSFixed32(786); private readonly pbc::RepeatedField packedSfixed32_ = new pbc::RepeatedField(); public pbc::RepeatedField PackedSfixed32 { get { return packedSfixed32_; } } public const int PackedSfixed64FieldNumber = 99; + private static readonly pb::FieldCodec _repeated_packedSfixed64_codec + = pb::FieldCodec.ForSFixed64(794); private readonly pbc::RepeatedField packedSfixed64_ = new pbc::RepeatedField(); public pbc::RepeatedField PackedSfixed64 { get { return packedSfixed64_; } } public const int PackedFloatFieldNumber = 100; + private static readonly pb::FieldCodec _repeated_packedFloat_codec + = pb::FieldCodec.ForFloat(802); private readonly pbc::RepeatedField packedFloat_ = new pbc::RepeatedField(); public pbc::RepeatedField PackedFloat { get { return packedFloat_; } } public const int PackedDoubleFieldNumber = 101; + private static readonly pb::FieldCodec _repeated_packedDouble_codec + = pb::FieldCodec.ForDouble(810); private readonly pbc::RepeatedField packedDouble_ = new pbc::RepeatedField(); public pbc::RepeatedField PackedDouble { get { return packedDouble_; } } public const int PackedBoolFieldNumber = 102; + private static readonly pb::FieldCodec _repeated_packedBool_codec + = pb::FieldCodec.ForBool(818); private readonly pbc::RepeatedField packedBool_ = new pbc::RepeatedField(); public pbc::RepeatedField PackedBool { get { return packedBool_; } } public const int PackedEnumFieldNumber = 103; - private readonly pbc::RepeatedField packedEnum_ = new pbc::RepeatedField(); + private static readonly pb::FieldCodec _repeated_packedEnum_codec + = pb::FieldCodec.ForEnum(826, x => (int) x, x => (global::Google.Protobuf.TestProtos.ForeignEnum) x);private readonly pbc::RepeatedField packedEnum_ = new pbc::RepeatedField(); public pbc::RepeatedField PackedEnum { get { return packedEnum_; } } @@ -5260,164 +5095,38 @@ namespace Google.Protobuf.TestProtos { } public void WriteTo(pb::CodedOutputStream output) { - if (packedInt32_.Count > 0) { - output.WriteRawTag(210, 5); - output.WritePackedInt32Array(packedInt32_); - } - if (packedInt64_.Count > 0) { - output.WriteRawTag(218, 5); - output.WritePackedInt64Array(packedInt64_); - } - if (packedUint32_.Count > 0) { - output.WriteRawTag(226, 5); - output.WritePackedUInt32Array(packedUint32_); - } - if (packedUint64_.Count > 0) { - output.WriteRawTag(234, 5); - output.WritePackedUInt64Array(packedUint64_); - } - if (packedSint32_.Count > 0) { - output.WriteRawTag(242, 5); - output.WritePackedSInt32Array(packedSint32_); - } - if (packedSint64_.Count > 0) { - output.WriteRawTag(250, 5); - output.WritePackedSInt64Array(packedSint64_); - } - if (packedFixed32_.Count > 0) { - output.WriteRawTag(130, 6); - output.WritePackedFixed32Array(packedFixed32_); - } - if (packedFixed64_.Count > 0) { - output.WriteRawTag(138, 6); - output.WritePackedFixed64Array(packedFixed64_); - } - if (packedSfixed32_.Count > 0) { - output.WriteRawTag(146, 6); - output.WritePackedSFixed32Array(packedSfixed32_); - } - if (packedSfixed64_.Count > 0) { - output.WriteRawTag(154, 6); - output.WritePackedSFixed64Array(packedSfixed64_); - } - if (packedFloat_.Count > 0) { - output.WriteRawTag(162, 6); - output.WritePackedFloatArray(packedFloat_); - } - if (packedDouble_.Count > 0) { - output.WriteRawTag(170, 6); - output.WritePackedDoubleArray(packedDouble_); - } - if (packedBool_.Count > 0) { - output.WriteRawTag(178, 6); - output.WritePackedBoolArray(packedBool_); - } - if (packedEnum_.Count > 0) { - output.WriteRawTag(186, 6); - output.WritePackedEnumArray(packedEnum_); - } + packedInt32_.WriteTo(output, _repeated_packedInt32_codec); + packedInt64_.WriteTo(output, _repeated_packedInt64_codec); + packedUint32_.WriteTo(output, _repeated_packedUint32_codec); + packedUint64_.WriteTo(output, _repeated_packedUint64_codec); + packedSint32_.WriteTo(output, _repeated_packedSint32_codec); + packedSint64_.WriteTo(output, _repeated_packedSint64_codec); + packedFixed32_.WriteTo(output, _repeated_packedFixed32_codec); + packedFixed64_.WriteTo(output, _repeated_packedFixed64_codec); + packedSfixed32_.WriteTo(output, _repeated_packedSfixed32_codec); + packedSfixed64_.WriteTo(output, _repeated_packedSfixed64_codec); + packedFloat_.WriteTo(output, _repeated_packedFloat_codec); + packedDouble_.WriteTo(output, _repeated_packedDouble_codec); + packedBool_.WriteTo(output, _repeated_packedBool_codec); + packedEnum_.WriteTo(output, _repeated_packedEnum_codec); } public int CalculateSize() { int size = 0; - if (packedInt32_.Count > 0) { - int dataSize = 0; - foreach (int element in packedInt32_) { - dataSize += pb::CodedOutputStream.ComputeInt32Size(element); - } - size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); - } - if (packedInt64_.Count > 0) { - int dataSize = 0; - foreach (long element in packedInt64_) { - dataSize += pb::CodedOutputStream.ComputeInt64Size(element); - } - size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); - } - if (packedUint32_.Count > 0) { - int dataSize = 0; - foreach (uint element in packedUint32_) { - dataSize += pb::CodedOutputStream.ComputeUInt32Size(element); - } - size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); - } - if (packedUint64_.Count > 0) { - int dataSize = 0; - foreach (ulong element in packedUint64_) { - dataSize += pb::CodedOutputStream.ComputeUInt64Size(element); - } - size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); - } - if (packedSint32_.Count > 0) { - int dataSize = 0; - foreach (int element in packedSint32_) { - dataSize += pb::CodedOutputStream.ComputeSInt32Size(element); - } - size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); - } - if (packedSint64_.Count > 0) { - int dataSize = 0; - foreach (long element in packedSint64_) { - dataSize += pb::CodedOutputStream.ComputeSInt64Size(element); - } - size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); - } - if (packedFixed32_.Count > 0) { - int dataSize = 0; - dataSize = 4 * packedFixed32_.Count; - size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); - } - if (packedFixed64_.Count > 0) { - int dataSize = 0; - dataSize = 8 * packedFixed64_.Count; - size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); - } - if (packedSfixed32_.Count > 0) { - int dataSize = 0; - dataSize = 4 * packedSfixed32_.Count; - size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); - } - if (packedSfixed64_.Count > 0) { - int dataSize = 0; - dataSize = 8 * packedSfixed64_.Count; - size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); - } - if (packedFloat_.Count > 0) { - int dataSize = 0; - dataSize = 4 * packedFloat_.Count; - size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); - } - if (packedDouble_.Count > 0) { - int dataSize = 0; - dataSize = 8 * packedDouble_.Count; - size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); - } - if (packedBool_.Count > 0) { - int dataSize = 0; - dataSize = 1 * packedBool_.Count; - size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); - } - if (packedEnum_.Count > 0) { - int dataSize = 0; - foreach (global::Google.Protobuf.TestProtos.ForeignEnum element in packedEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSize((int) element); - } - size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize); - } + size += packedInt32_.CalculateSize(_repeated_packedInt32_codec); + size += packedInt64_.CalculateSize(_repeated_packedInt64_codec); + size += packedUint32_.CalculateSize(_repeated_packedUint32_codec); + size += packedUint64_.CalculateSize(_repeated_packedUint64_codec); + size += packedSint32_.CalculateSize(_repeated_packedSint32_codec); + size += packedSint64_.CalculateSize(_repeated_packedSint64_codec); + size += packedFixed32_.CalculateSize(_repeated_packedFixed32_codec); + size += packedFixed64_.CalculateSize(_repeated_packedFixed64_codec); + size += packedSfixed32_.CalculateSize(_repeated_packedSfixed32_codec); + size += packedSfixed64_.CalculateSize(_repeated_packedSfixed64_codec); + size += packedFloat_.CalculateSize(_repeated_packedFloat_codec); + size += packedDouble_.CalculateSize(_repeated_packedDouble_codec); + size += packedBool_.CalculateSize(_repeated_packedBool_codec); + size += packedEnum_.CalculateSize(_repeated_packedEnum_codec); return size; } @@ -5454,72 +5163,72 @@ namespace Google.Protobuf.TestProtos { break; case 722: case 720: { - input.ReadInt32Array(packedInt32_); + packedInt32_.AddEntriesFrom(input, _repeated_packedInt32_codec); break; } case 730: case 728: { - input.ReadInt64Array(packedInt64_); + packedInt64_.AddEntriesFrom(input, _repeated_packedInt64_codec); break; } case 738: case 736: { - input.ReadUInt32Array(packedUint32_); + packedUint32_.AddEntriesFrom(input, _repeated_packedUint32_codec); break; } case 746: case 744: { - input.ReadUInt64Array(packedUint64_); + packedUint64_.AddEntriesFrom(input, _repeated_packedUint64_codec); break; } case 754: case 752: { - input.ReadSInt32Array(packedSint32_); + packedSint32_.AddEntriesFrom(input, _repeated_packedSint32_codec); break; } case 762: case 760: { - input.ReadSInt64Array(packedSint64_); + packedSint64_.AddEntriesFrom(input, _repeated_packedSint64_codec); break; } case 770: case 773: { - input.ReadFixed32Array(packedFixed32_); + packedFixed32_.AddEntriesFrom(input, _repeated_packedFixed32_codec); break; } case 778: case 777: { - input.ReadFixed64Array(packedFixed64_); + packedFixed64_.AddEntriesFrom(input, _repeated_packedFixed64_codec); break; } case 786: case 789: { - input.ReadSFixed32Array(packedSfixed32_); + packedSfixed32_.AddEntriesFrom(input, _repeated_packedSfixed32_codec); break; } case 794: case 793: { - input.ReadSFixed64Array(packedSfixed64_); + packedSfixed64_.AddEntriesFrom(input, _repeated_packedSfixed64_codec); break; } case 802: case 805: { - input.ReadFloatArray(packedFloat_); + packedFloat_.AddEntriesFrom(input, _repeated_packedFloat_codec); break; } case 810: case 809: { - input.ReadDoubleArray(packedDouble_); + packedDouble_.AddEntriesFrom(input, _repeated_packedDouble_codec); break; } case 818: case 816: { - input.ReadBoolArray(packedBool_); + packedBool_.AddEntriesFrom(input, _repeated_packedBool_codec); break; } case 826: case 824: { - input.ReadEnumArray(packedEnum_); + packedEnum_.AddEntriesFrom(input, _repeated_packedEnum_codec); break; } } @@ -5591,85 +5300,112 @@ namespace Google.Protobuf.TestProtos { } public const int UnpackedInt32FieldNumber = 90; + private static readonly pb::FieldCodec _repeated_unpackedInt32_codec + = pb::FieldCodec.ForInt32(720); private readonly pbc::RepeatedField unpackedInt32_ = new pbc::RepeatedField(); public pbc::RepeatedField UnpackedInt32 { get { return unpackedInt32_; } } public const int UnpackedInt64FieldNumber = 91; + private static readonly pb::FieldCodec _repeated_unpackedInt64_codec + = pb::FieldCodec.ForInt64(728); private readonly pbc::RepeatedField unpackedInt64_ = new pbc::RepeatedField(); public pbc::RepeatedField UnpackedInt64 { get { return unpackedInt64_; } } public const int UnpackedUint32FieldNumber = 92; + private static readonly pb::FieldCodec _repeated_unpackedUint32_codec + = pb::FieldCodec.ForUInt32(736); private readonly pbc::RepeatedField unpackedUint32_ = new pbc::RepeatedField(); public pbc::RepeatedField UnpackedUint32 { get { return unpackedUint32_; } } public const int UnpackedUint64FieldNumber = 93; + private static readonly pb::FieldCodec _repeated_unpackedUint64_codec + = pb::FieldCodec.ForUInt64(744); private readonly pbc::RepeatedField unpackedUint64_ = new pbc::RepeatedField(); public pbc::RepeatedField UnpackedUint64 { get { return unpackedUint64_; } } public const int UnpackedSint32FieldNumber = 94; + private static readonly pb::FieldCodec _repeated_unpackedSint32_codec + = pb::FieldCodec.ForSInt32(752); private readonly pbc::RepeatedField unpackedSint32_ = new pbc::RepeatedField(); public pbc::RepeatedField UnpackedSint32 { get { return unpackedSint32_; } } public const int UnpackedSint64FieldNumber = 95; + private static readonly pb::FieldCodec _repeated_unpackedSint64_codec + = pb::FieldCodec.ForSInt64(760); private readonly pbc::RepeatedField unpackedSint64_ = new pbc::RepeatedField(); public pbc::RepeatedField UnpackedSint64 { get { return unpackedSint64_; } } public const int UnpackedFixed32FieldNumber = 96; + private static readonly pb::FieldCodec _repeated_unpackedFixed32_codec + = pb::FieldCodec.ForFixed32(773); private readonly pbc::RepeatedField unpackedFixed32_ = new pbc::RepeatedField(); public pbc::RepeatedField UnpackedFixed32 { get { return unpackedFixed32_; } } public const int UnpackedFixed64FieldNumber = 97; + private static readonly pb::FieldCodec _repeated_unpackedFixed64_codec + = pb::FieldCodec.ForFixed64(777); private readonly pbc::RepeatedField unpackedFixed64_ = new pbc::RepeatedField(); public pbc::RepeatedField UnpackedFixed64 { get { return unpackedFixed64_; } } public const int UnpackedSfixed32FieldNumber = 98; + private static readonly pb::FieldCodec _repeated_unpackedSfixed32_codec + = pb::FieldCodec.ForSFixed32(789); private readonly pbc::RepeatedField unpackedSfixed32_ = new pbc::RepeatedField(); public pbc::RepeatedField UnpackedSfixed32 { get { return unpackedSfixed32_; } } public const int UnpackedSfixed64FieldNumber = 99; + private static readonly pb::FieldCodec _repeated_unpackedSfixed64_codec + = pb::FieldCodec.ForSFixed64(793); private readonly pbc::RepeatedField unpackedSfixed64_ = new pbc::RepeatedField(); public pbc::RepeatedField UnpackedSfixed64 { get { return unpackedSfixed64_; } } public const int UnpackedFloatFieldNumber = 100; + private static readonly pb::FieldCodec _repeated_unpackedFloat_codec + = pb::FieldCodec.ForFloat(805); private readonly pbc::RepeatedField unpackedFloat_ = new pbc::RepeatedField(); public pbc::RepeatedField UnpackedFloat { get { return unpackedFloat_; } } public const int UnpackedDoubleFieldNumber = 101; + private static readonly pb::FieldCodec _repeated_unpackedDouble_codec + = pb::FieldCodec.ForDouble(809); private readonly pbc::RepeatedField unpackedDouble_ = new pbc::RepeatedField(); public pbc::RepeatedField UnpackedDouble { get { return unpackedDouble_; } } public const int UnpackedBoolFieldNumber = 102; + private static readonly pb::FieldCodec _repeated_unpackedBool_codec + = pb::FieldCodec.ForBool(816); private readonly pbc::RepeatedField unpackedBool_ = new pbc::RepeatedField(); public pbc::RepeatedField UnpackedBool { get { return unpackedBool_; } } public const int UnpackedEnumFieldNumber = 103; - private readonly pbc::RepeatedField unpackedEnum_ = new pbc::RepeatedField(); + private static readonly pb::FieldCodec _repeated_unpackedEnum_codec + = pb::FieldCodec.ForEnum(824, x => (int) x, x => (global::Google.Protobuf.TestProtos.ForeignEnum) x);private readonly pbc::RepeatedField unpackedEnum_ = new pbc::RepeatedField(); public pbc::RepeatedField UnpackedEnum { get { return unpackedEnum_; } } @@ -5722,150 +5458,38 @@ namespace Google.Protobuf.TestProtos { } public void WriteTo(pb::CodedOutputStream output) { - if (unpackedInt32_.Count > 0) { - output.WriteInt32Array(90, unpackedInt32_); - } - if (unpackedInt64_.Count > 0) { - output.WriteInt64Array(91, unpackedInt64_); - } - if (unpackedUint32_.Count > 0) { - output.WriteUInt32Array(92, unpackedUint32_); - } - if (unpackedUint64_.Count > 0) { - output.WriteUInt64Array(93, unpackedUint64_); - } - if (unpackedSint32_.Count > 0) { - output.WriteSInt32Array(94, unpackedSint32_); - } - if (unpackedSint64_.Count > 0) { - output.WriteSInt64Array(95, unpackedSint64_); - } - if (unpackedFixed32_.Count > 0) { - output.WriteFixed32Array(96, unpackedFixed32_); - } - if (unpackedFixed64_.Count > 0) { - output.WriteFixed64Array(97, unpackedFixed64_); - } - if (unpackedSfixed32_.Count > 0) { - output.WriteSFixed32Array(98, unpackedSfixed32_); - } - if (unpackedSfixed64_.Count > 0) { - output.WriteSFixed64Array(99, unpackedSfixed64_); - } - if (unpackedFloat_.Count > 0) { - output.WriteFloatArray(100, unpackedFloat_); - } - if (unpackedDouble_.Count > 0) { - output.WriteDoubleArray(101, unpackedDouble_); - } - if (unpackedBool_.Count > 0) { - output.WriteBoolArray(102, unpackedBool_); - } - if (unpackedEnum_.Count > 0) { - output.WriteEnumArray(103, unpackedEnum_); - } + unpackedInt32_.WriteTo(output, _repeated_unpackedInt32_codec); + unpackedInt64_.WriteTo(output, _repeated_unpackedInt64_codec); + unpackedUint32_.WriteTo(output, _repeated_unpackedUint32_codec); + unpackedUint64_.WriteTo(output, _repeated_unpackedUint64_codec); + unpackedSint32_.WriteTo(output, _repeated_unpackedSint32_codec); + unpackedSint64_.WriteTo(output, _repeated_unpackedSint64_codec); + unpackedFixed32_.WriteTo(output, _repeated_unpackedFixed32_codec); + unpackedFixed64_.WriteTo(output, _repeated_unpackedFixed64_codec); + unpackedSfixed32_.WriteTo(output, _repeated_unpackedSfixed32_codec); + unpackedSfixed64_.WriteTo(output, _repeated_unpackedSfixed64_codec); + unpackedFloat_.WriteTo(output, _repeated_unpackedFloat_codec); + unpackedDouble_.WriteTo(output, _repeated_unpackedDouble_codec); + unpackedBool_.WriteTo(output, _repeated_unpackedBool_codec); + unpackedEnum_.WriteTo(output, _repeated_unpackedEnum_codec); } public int CalculateSize() { int size = 0; - if (unpackedInt32_.Count > 0) { - int dataSize = 0; - foreach (int element in unpackedInt32_) { - dataSize += pb::CodedOutputStream.ComputeInt32Size(element); - } - size += dataSize; - size += 2 * unpackedInt32_.Count; - } - if (unpackedInt64_.Count > 0) { - int dataSize = 0; - foreach (long element in unpackedInt64_) { - dataSize += pb::CodedOutputStream.ComputeInt64Size(element); - } - size += dataSize; - size += 2 * unpackedInt64_.Count; - } - if (unpackedUint32_.Count > 0) { - int dataSize = 0; - foreach (uint element in unpackedUint32_) { - dataSize += pb::CodedOutputStream.ComputeUInt32Size(element); - } - size += dataSize; - size += 2 * unpackedUint32_.Count; - } - if (unpackedUint64_.Count > 0) { - int dataSize = 0; - foreach (ulong element in unpackedUint64_) { - dataSize += pb::CodedOutputStream.ComputeUInt64Size(element); - } - size += dataSize; - size += 2 * unpackedUint64_.Count; - } - if (unpackedSint32_.Count > 0) { - int dataSize = 0; - foreach (int element in unpackedSint32_) { - dataSize += pb::CodedOutputStream.ComputeSInt32Size(element); - } - size += dataSize; - size += 2 * unpackedSint32_.Count; - } - if (unpackedSint64_.Count > 0) { - int dataSize = 0; - foreach (long element in unpackedSint64_) { - dataSize += pb::CodedOutputStream.ComputeSInt64Size(element); - } - size += dataSize; - size += 2 * unpackedSint64_.Count; - } - if (unpackedFixed32_.Count > 0) { - int dataSize = 0; - dataSize = 4 * unpackedFixed32_.Count; - size += dataSize; - size += 2 * unpackedFixed32_.Count; - } - if (unpackedFixed64_.Count > 0) { - int dataSize = 0; - dataSize = 8 * unpackedFixed64_.Count; - size += dataSize; - size += 2 * unpackedFixed64_.Count; - } - if (unpackedSfixed32_.Count > 0) { - int dataSize = 0; - dataSize = 4 * unpackedSfixed32_.Count; - size += dataSize; - size += 2 * unpackedSfixed32_.Count; - } - if (unpackedSfixed64_.Count > 0) { - int dataSize = 0; - dataSize = 8 * unpackedSfixed64_.Count; - size += dataSize; - size += 2 * unpackedSfixed64_.Count; - } - if (unpackedFloat_.Count > 0) { - int dataSize = 0; - dataSize = 4 * unpackedFloat_.Count; - size += dataSize; - size += 2 * unpackedFloat_.Count; - } - if (unpackedDouble_.Count > 0) { - int dataSize = 0; - dataSize = 8 * unpackedDouble_.Count; - size += dataSize; - size += 2 * unpackedDouble_.Count; - } - if (unpackedBool_.Count > 0) { - int dataSize = 0; - dataSize = 1 * unpackedBool_.Count; - size += dataSize; - size += 2 * unpackedBool_.Count; - } - if (unpackedEnum_.Count > 0) { - int dataSize = 0; - foreach (global::Google.Protobuf.TestProtos.ForeignEnum element in unpackedEnum_) { - dataSize += pb::CodedOutputStream.ComputeEnumSize((int) element); - } - size += dataSize; - size += 2 * unpackedEnum_.Count; - } + size += unpackedInt32_.CalculateSize(_repeated_unpackedInt32_codec); + size += unpackedInt64_.CalculateSize(_repeated_unpackedInt64_codec); + size += unpackedUint32_.CalculateSize(_repeated_unpackedUint32_codec); + size += unpackedUint64_.CalculateSize(_repeated_unpackedUint64_codec); + size += unpackedSint32_.CalculateSize(_repeated_unpackedSint32_codec); + size += unpackedSint64_.CalculateSize(_repeated_unpackedSint64_codec); + size += unpackedFixed32_.CalculateSize(_repeated_unpackedFixed32_codec); + size += unpackedFixed64_.CalculateSize(_repeated_unpackedFixed64_codec); + size += unpackedSfixed32_.CalculateSize(_repeated_unpackedSfixed32_codec); + size += unpackedSfixed64_.CalculateSize(_repeated_unpackedSfixed64_codec); + size += unpackedFloat_.CalculateSize(_repeated_unpackedFloat_codec); + size += unpackedDouble_.CalculateSize(_repeated_unpackedDouble_codec); + size += unpackedBool_.CalculateSize(_repeated_unpackedBool_codec); + size += unpackedEnum_.CalculateSize(_repeated_unpackedEnum_codec); return size; } @@ -5902,72 +5526,72 @@ namespace Google.Protobuf.TestProtos { break; case 722: case 720: { - input.ReadInt32Array(unpackedInt32_); + unpackedInt32_.AddEntriesFrom(input, _repeated_unpackedInt32_codec); break; } case 730: case 728: { - input.ReadInt64Array(unpackedInt64_); + unpackedInt64_.AddEntriesFrom(input, _repeated_unpackedInt64_codec); break; } case 738: case 736: { - input.ReadUInt32Array(unpackedUint32_); + unpackedUint32_.AddEntriesFrom(input, _repeated_unpackedUint32_codec); break; } case 746: case 744: { - input.ReadUInt64Array(unpackedUint64_); + unpackedUint64_.AddEntriesFrom(input, _repeated_unpackedUint64_codec); break; } case 754: case 752: { - input.ReadSInt32Array(unpackedSint32_); + unpackedSint32_.AddEntriesFrom(input, _repeated_unpackedSint32_codec); break; } case 762: case 760: { - input.ReadSInt64Array(unpackedSint64_); + unpackedSint64_.AddEntriesFrom(input, _repeated_unpackedSint64_codec); break; } case 770: case 773: { - input.ReadFixed32Array(unpackedFixed32_); + unpackedFixed32_.AddEntriesFrom(input, _repeated_unpackedFixed32_codec); break; } case 778: case 777: { - input.ReadFixed64Array(unpackedFixed64_); + unpackedFixed64_.AddEntriesFrom(input, _repeated_unpackedFixed64_codec); break; } case 786: case 789: { - input.ReadSFixed32Array(unpackedSfixed32_); + unpackedSfixed32_.AddEntriesFrom(input, _repeated_unpackedSfixed32_codec); break; } case 794: case 793: { - input.ReadSFixed64Array(unpackedSfixed64_); + unpackedSfixed64_.AddEntriesFrom(input, _repeated_unpackedSfixed64_codec); break; } case 802: case 805: { - input.ReadFloatArray(unpackedFloat_); + unpackedFloat_.AddEntriesFrom(input, _repeated_unpackedFloat_codec); break; } case 810: case 809: { - input.ReadDoubleArray(unpackedDouble_); + unpackedDouble_.AddEntriesFrom(input, _repeated_unpackedDouble_codec); break; } case 818: case 816: { - input.ReadBoolArray(unpackedBool_); + unpackedBool_.AddEntriesFrom(input, _repeated_unpackedBool_codec); break; } case 826: case 824: { - input.ReadEnumArray(unpackedEnum_); + unpackedEnum_.AddEntriesFrom(input, _repeated_unpackedEnum_codec); break; } } @@ -6023,36 +5647,48 @@ namespace Google.Protobuf.TestProtos { } public const int RepeatedFixed32FieldNumber = 12; + private static readonly pb::FieldCodec _repeated_repeatedFixed32_codec + = pb::FieldCodec.ForFixed32(98); private readonly pbc::RepeatedField repeatedFixed32_ = new pbc::RepeatedField(); public pbc::RepeatedField RepeatedFixed32 { get { return repeatedFixed32_; } } public const int RepeatedInt32FieldNumber = 13; + private static readonly pb::FieldCodec _repeated_repeatedInt32_codec + = pb::FieldCodec.ForInt32(106); private readonly pbc::RepeatedField repeatedInt32_ = new pbc::RepeatedField(); public pbc::RepeatedField RepeatedInt32 { get { return repeatedInt32_; } } public const int RepeatedFixed64FieldNumber = 2046; + private static readonly pb::FieldCodec _repeated_repeatedFixed64_codec + = pb::FieldCodec.ForFixed64(16370); private readonly pbc::RepeatedField repeatedFixed64_ = new pbc::RepeatedField(); public pbc::RepeatedField RepeatedFixed64 { get { return repeatedFixed64_; } } public const int RepeatedInt64FieldNumber = 2047; + private static readonly pb::FieldCodec _repeated_repeatedInt64_codec + = pb::FieldCodec.ForInt64(16378); private readonly pbc::RepeatedField repeatedInt64_ = new pbc::RepeatedField(); public pbc::RepeatedField RepeatedInt64 { get { return repeatedInt64_; } } public const int RepeatedFloatFieldNumber = 262142; + private static readonly pb::FieldCodec _repeated_repeatedFloat_codec + = pb::FieldCodec.ForFloat(2097138); private readonly pbc::RepeatedField repeatedFloat_ = new pbc::RepeatedField(); public pbc::RepeatedField RepeatedFloat { get { return repeatedFloat_; } } public const int RepeatedUint64FieldNumber = 262143; + private static readonly pb::FieldCodec _repeated_repeatedUint64_codec + = pb::FieldCodec.ForUInt64(2097146); private readonly pbc::RepeatedField repeatedUint64_ = new pbc::RepeatedField(); public pbc::RepeatedField RepeatedUint64 { get { return repeatedUint64_; } @@ -6090,76 +5726,22 @@ namespace Google.Protobuf.TestProtos { } public void WriteTo(pb::CodedOutputStream output) { - if (repeatedFixed32_.Count > 0) { - output.WriteRawTag(98); - output.WritePackedFixed32Array(repeatedFixed32_); - } - if (repeatedInt32_.Count > 0) { - output.WriteRawTag(106); - output.WritePackedInt32Array(repeatedInt32_); - } - if (repeatedFixed64_.Count > 0) { - output.WriteRawTag(242, 127); - output.WritePackedFixed64Array(repeatedFixed64_); - } - if (repeatedInt64_.Count > 0) { - output.WriteRawTag(250, 127); - output.WritePackedInt64Array(repeatedInt64_); - } - if (repeatedFloat_.Count > 0) { - output.WriteRawTag(242, 255, 127); - output.WritePackedFloatArray(repeatedFloat_); - } - if (repeatedUint64_.Count > 0) { - output.WriteRawTag(250, 255, 127); - output.WritePackedUInt64Array(repeatedUint64_); - } + repeatedFixed32_.WriteTo(output, _repeated_repeatedFixed32_codec); + repeatedInt32_.WriteTo(output, _repeated_repeatedInt32_codec); + repeatedFixed64_.WriteTo(output, _repeated_repeatedFixed64_codec); + repeatedInt64_.WriteTo(output, _repeated_repeatedInt64_codec); + repeatedFloat_.WriteTo(output, _repeated_repeatedFloat_codec); + repeatedUint64_.WriteTo(output, _repeated_repeatedUint64_codec); } public int CalculateSize() { int size = 0; - if (repeatedFixed32_.Count > 0) { - int dataSize = 0; - dataSize = 4 * repeatedFixed32_.Count; - size += dataSize; - size += 1 + pb::CodedOutputStream.ComputeInt32Size(dataSize); - } - if (repeatedInt32_.Count > 0) { - int dataSize = 0; - foreach (int element in repeatedInt32_) { - dataSize += pb::CodedOutputStream.ComputeInt32Size(element); - } - size += dataSize; - size += 1 + pb::CodedOutputStream.ComputeInt32Size(dataSize); - } - if (repeatedFixed64_.Count > 0) { - int dataSize = 0; - dataSize = 8 * repeatedFixed64_.Count; - size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); - } - if (repeatedInt64_.Count > 0) { - int dataSize = 0; - foreach (long element in repeatedInt64_) { - dataSize += pb::CodedOutputStream.ComputeInt64Size(element); - } - size += dataSize; - size += 2 + pb::CodedOutputStream.ComputeInt32Size(dataSize); - } - if (repeatedFloat_.Count > 0) { - int dataSize = 0; - dataSize = 4 * repeatedFloat_.Count; - size += dataSize; - size += 3 + pb::CodedOutputStream.ComputeInt32Size(dataSize); - } - if (repeatedUint64_.Count > 0) { - int dataSize = 0; - foreach (ulong element in repeatedUint64_) { - dataSize += pb::CodedOutputStream.ComputeUInt64Size(element); - } - size += dataSize; - size += 3 + pb::CodedOutputStream.ComputeInt32Size(dataSize); - } + size += repeatedFixed32_.CalculateSize(_repeated_repeatedFixed32_codec); + size += repeatedInt32_.CalculateSize(_repeated_repeatedInt32_codec); + size += repeatedFixed64_.CalculateSize(_repeated_repeatedFixed64_codec); + size += repeatedInt64_.CalculateSize(_repeated_repeatedInt64_codec); + size += repeatedFloat_.CalculateSize(_repeated_repeatedFloat_codec); + size += repeatedUint64_.CalculateSize(_repeated_repeatedUint64_codec); return size; } @@ -6188,32 +5770,32 @@ namespace Google.Protobuf.TestProtos { break; case 98: case 101: { - input.ReadFixed32Array(repeatedFixed32_); + repeatedFixed32_.AddEntriesFrom(input, _repeated_repeatedFixed32_codec); break; } case 106: case 104: { - input.ReadInt32Array(repeatedInt32_); + repeatedInt32_.AddEntriesFrom(input, _repeated_repeatedInt32_codec); break; } case 16370: case 16369: { - input.ReadFixed64Array(repeatedFixed64_); + repeatedFixed64_.AddEntriesFrom(input, _repeated_repeatedFixed64_codec); break; } case 16378: case 16376: { - input.ReadInt64Array(repeatedInt64_); + repeatedInt64_.AddEntriesFrom(input, _repeated_repeatedInt64_codec); break; } case 2097138: case 2097141: { - input.ReadFloatArray(repeatedFloat_); + repeatedFloat_.AddEntriesFrom(input, _repeated_repeatedFloat_codec); break; } case 2097146: case 2097144: { - input.ReadUInt64Array(repeatedUint64_); + repeatedUint64_.AddEntriesFrom(input, _repeated_repeatedUint64_codec); break; } } diff --git a/csharp/src/ProtocolBuffers/CodedInputStream.cs b/csharp/src/ProtocolBuffers/CodedInputStream.cs index dab3e5e3..75178d14 100644 --- a/csharp/src/ProtocolBuffers/CodedInputStream.cs +++ b/csharp/src/ProtocolBuffers/CodedInputStream.cs @@ -172,6 +172,12 @@ namespace Google.Protobuf } } + /// + /// Returns the last tag read, or 0 if no tags have been read or we've read beyond + /// the end of the stream. + /// + internal uint LastTag { get { return lastTag; } } + #region Validation /// @@ -435,26 +441,6 @@ namespace Google.Protobuf return DecodeZigZag64(ReadRawVarint64()); } - private bool BeginArray(uint fieldTag, out bool isPacked, out int oldLimit) - { - isPacked = WireFormat.GetTagWireType(fieldTag) == WireFormat.WireType.LengthDelimited; - - if (isPacked) - { - int length = (int) (ReadRawVarint32() & int.MaxValue); - if (length > 0) - { - oldLimit = PushLimit(length); - return true; - } - oldLimit = -1; - return false; //packed but empty - } - - oldLimit = -1; - return true; - } - /// /// Peeks at the next tag in the stream. If it matches , /// the tag is consumed and the method returns true; otherwise, the @@ -474,268 +460,6 @@ namespace Google.Protobuf return false; } - /// - /// Returns true if the next tag is also part of the same array, which may or may not be packed. - /// - private bool ContinueArray(uint currentTag, bool packed, int oldLimit) - { - if (packed) - { - if (ReachedLimit) - { - PopLimit(oldLimit); - return false; - } - return true; - } - return MaybeConsumeTag(currentTag); - } - - /// - /// Reads a string array. - /// - /// The stream is assumed to be positioned after a tag indicating the field - /// repeated string value. A string is read, and then if the next tag is the same, - /// the process is repeated, until the next tag is a different one. - /// - public void ReadStringArray(ICollection list) - { - uint fieldTag = lastTag; - do - { - list.Add(ReadString()); - } while (MaybeConsumeTag(fieldTag)); - } - - public void ReadBytesArray(ICollection list) - { - uint fieldTag = lastTag; - do - { - list.Add(ReadBytes()); - } while (MaybeConsumeTag(fieldTag)); - } - - public void ReadBoolArray(ICollection list) - { - uint fieldTag = lastTag; - bool isPacked; - int holdLimit; - if (BeginArray(fieldTag, out isPacked, out holdLimit)) - { - do - { - list.Add(ReadBool()); - } while (ContinueArray(fieldTag, isPacked, holdLimit)); - } - } - - public void ReadInt32Array(ICollection list) - { - uint fieldTag = lastTag; - bool isPacked; - int holdLimit; - if (BeginArray(fieldTag, out isPacked, out holdLimit)) - { - do - { - list.Add(ReadInt32()); - } while (ContinueArray(fieldTag, isPacked, holdLimit)); - } - } - - public void ReadSInt32Array(ICollection list) - { - uint fieldTag = lastTag; - bool isPacked; - int holdLimit; - if (BeginArray(fieldTag, out isPacked, out holdLimit)) - { - do - { - list.Add(ReadSInt32()); - } while (ContinueArray(fieldTag, isPacked, holdLimit)); - } - } - - public void ReadUInt32Array(ICollection list) - { - uint fieldTag = lastTag; - bool isPacked; - int holdLimit; - if (BeginArray(fieldTag, out isPacked, out holdLimit)) - { - do - { - list.Add(ReadUInt32()); - } while (ContinueArray(fieldTag, isPacked, holdLimit)); - } - } - - public void ReadFixed32Array(ICollection list) - { - uint fieldTag = lastTag; - bool isPacked; - int holdLimit; - if (BeginArray(fieldTag, out isPacked, out holdLimit)) - { - do - { - list.Add(ReadFixed32()); - } while (ContinueArray(fieldTag, isPacked, holdLimit)); - } - } - - public void ReadSFixed32Array(ICollection list) - { - uint fieldTag = lastTag; - bool isPacked; - int holdLimit; - if (BeginArray(fieldTag, out isPacked, out holdLimit)) - { - do - { - list.Add(ReadSFixed32()); - } while (ContinueArray(fieldTag, isPacked, holdLimit)); - } - } - - public void ReadInt64Array(ICollection list) - { - uint fieldTag = lastTag; - bool isPacked; - int holdLimit; - if (BeginArray(fieldTag, out isPacked, out holdLimit)) - { - do - { - list.Add(ReadInt64()); - } while (ContinueArray(fieldTag, isPacked, holdLimit)); - } - } - - public void ReadSInt64Array(ICollection list) - { - uint fieldTag = lastTag; - bool isPacked; - int holdLimit; - if (BeginArray(fieldTag, out isPacked, out holdLimit)) - { - do - { - list.Add(ReadSInt64()); - } while (ContinueArray(fieldTag, isPacked, holdLimit)); - } - } - - public void ReadUInt64Array(ICollection list) - { - uint fieldTag = lastTag; - bool isPacked; - int holdLimit; - if (BeginArray(fieldTag, out isPacked, out holdLimit)) - { - do - { - list.Add(ReadUInt64()); - } while (ContinueArray(fieldTag, isPacked, holdLimit)); - } - } - - public void ReadFixed64Array(ICollection list) - { - uint fieldTag = lastTag; - bool isPacked; - int holdLimit; - if (BeginArray(fieldTag, out isPacked, out holdLimit)) - { - do - { - list.Add(ReadFixed64()); - } while (ContinueArray(fieldTag, isPacked, holdLimit)); - } - } - - public void ReadSFixed64Array(ICollection list) - { - uint fieldTag = lastTag; - bool isPacked; - int holdLimit; - if (BeginArray(fieldTag, out isPacked, out holdLimit)) - { - do - { - list.Add(ReadSFixed64()); - } while (ContinueArray(fieldTag, isPacked, holdLimit)); - } - } - - public void ReadDoubleArray(ICollection list) - { - uint fieldTag = lastTag; - bool isPacked; - int holdLimit; - if (BeginArray(fieldTag, out isPacked, out holdLimit)) - { - do - { - list.Add(ReadDouble()); - } while (ContinueArray(fieldTag, isPacked, holdLimit)); - } - } - - public void ReadFloatArray(ICollection list) - { - uint fieldTag = lastTag; - bool isPacked; - int holdLimit; - if (BeginArray(fieldTag, out isPacked, out holdLimit)) - { - do - { - list.Add(ReadFloat()); - } while (ContinueArray(fieldTag, isPacked, holdLimit)); - } - } - - public void ReadEnumArray(RepeatedField list) - where T : struct, IComparable, IFormattable - { - uint fieldTag = lastTag; - WireFormat.WireType wformat = WireFormat.GetTagWireType(fieldTag); - - // 2.3 allows packed form even if the field is not declared packed. - if (wformat == WireFormat.WireType.LengthDelimited) - { - int length = (int) (ReadRawVarint32() & int.MaxValue); - int limit = PushLimit(length); - while (!ReachedLimit) - { - // Ghastly hack, but it works... - list.AddInt32(ReadEnum()); - } - PopLimit(limit); - } - else - { - do - { - list.Add((T)(object) ReadEnum()); - } while (MaybeConsumeTag(fieldTag)); - } - } - - public void ReadMessageArray(ICollection list, MessageParser messageParser) - where T : IMessage - { - uint fieldTag = lastTag; - do - { - T message = messageParser.CreateTemplate(); - ReadMessage(message); - list.Add(message); - } while (MaybeConsumeTag(fieldTag)); - } #endregion #region Underlying reading primitives diff --git a/csharp/src/ProtocolBuffers/CodedOutputStream.cs b/csharp/src/ProtocolBuffers/CodedOutputStream.cs index def874c0..99a99ae2 100644 --- a/csharp/src/ProtocolBuffers/CodedOutputStream.cs +++ b/csharp/src/ProtocolBuffers/CodedOutputStream.cs @@ -306,166 +306,6 @@ namespace Google.Protobuf #endregion - #region Write array members, with fields. - public void WriteMessageArray(int fieldNumber, RepeatedField list) - where T : IMessage - { - foreach (T value in list) - { - WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited); - WriteMessage(value); - } - } - - public void WriteStringArray(int fieldNumber, RepeatedField list) - { - foreach (var value in list) - { - WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited); - WriteString(value); - } - } - - public void WriteBytesArray(int fieldNumber, RepeatedField list) - { - foreach (var value in list) - { - WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited); - WriteBytes(value); - } - } - - public void WriteBoolArray(int fieldNumber, RepeatedField list) - { - foreach (var value in list) - { - WriteTag(fieldNumber, WireFormat.WireType.Varint); - WriteBool(value); - } - } - - public void WriteInt32Array(int fieldNumber, RepeatedField list) - { - foreach (var value in list) - { - WriteTag(fieldNumber, WireFormat.WireType.Varint); - WriteInt32(value); - } - } - - public void WriteSInt32Array(int fieldNumber, RepeatedField list) - { - foreach (var value in list) - { - WriteTag(fieldNumber, WireFormat.WireType.Varint); - WriteSInt32(value); - } - } - - public void WriteUInt32Array(int fieldNumber, RepeatedField list) - { - foreach (var value in list) - { - WriteTag(fieldNumber, WireFormat.WireType.Varint); - WriteUInt32(value); - } - } - - public void WriteFixed32Array(int fieldNumber, RepeatedField list) - { - foreach (var value in list) - { - WriteTag(fieldNumber, WireFormat.WireType.Fixed32); - WriteFixed32(value); - } - } - - public void WriteSFixed32Array(int fieldNumber, RepeatedField list) - { - foreach (var value in list) - { - WriteTag(fieldNumber, WireFormat.WireType.Fixed32); - WriteSFixed32(value); - } - } - - public void WriteInt64Array(int fieldNumber, RepeatedField list) - { - foreach (var value in list) - { - WriteTag(fieldNumber, WireFormat.WireType.Fixed64); - WriteInt64(value); - } - } - - public void WriteSInt64Array(int fieldNumber, RepeatedField list) - { - foreach (var value in list) - { - WriteTag(fieldNumber, WireFormat.WireType.Varint); - WriteSInt64(value); - } - } - - public void WriteUInt64Array(int fieldNumber, RepeatedField list) - { - foreach (var value in list) - { - WriteTag(fieldNumber, WireFormat.WireType.Varint); - WriteUInt64(value); - } - } - - public void WriteFixed64Array(int fieldNumber, RepeatedField list) - { - foreach (var value in list) - { - WriteTag(fieldNumber, WireFormat.WireType.Fixed64); - WriteFixed64(value); - } - } - - public void WriteSFixed64Array(int fieldNumber, RepeatedField list) - { - foreach (var value in list) - { - WriteTag(fieldNumber, WireFormat.WireType.Fixed64); - WriteSFixed64(value); - } - } - - public void WriteDoubleArray(int fieldNumber, RepeatedField list) - { - foreach (var value in list) - { - WriteTag(fieldNumber, WireFormat.WireType.Fixed64); - WriteDouble(value); - } - } - - public void WriteFloatArray(int fieldNumber, RepeatedField list) - { - foreach (var value in list) - { - WriteTag(fieldNumber, WireFormat.WireType.Fixed32); - WriteFloat(value); - } - } - - public void WriteEnumArray(int fieldNumber, RepeatedField list) - where T : struct, IComparable, IFormattable - { - // Bit of a hack, to access the values as ints - var iterator = list.GetInt32Enumerator(); - while (iterator.MoveNext()) - { - WriteTag(fieldNumber, WireFormat.WireType.Varint); - WriteEnum(iterator.Current); - } - } - - #endregion - #region Raw tag writing /// /// Encodes and writes a tag. @@ -534,171 +374,6 @@ namespace Google.Protobuf } #endregion - #region Write packed array members - // TODO(jonskeet): A lot of these are really inefficient, due to method group conversions. Fix! - // (Alternatively, add extension methods to RepeatedField, accepting the Write* methods via delegates too.) - public void WritePackedBoolArray(RepeatedField list) - { - uint size = (uint)list.Count; - WriteRawVarint32(size); - foreach (var value in list) - { - WriteBool(value); - } - } - - public void WritePackedInt32Array(RepeatedField list) - { - uint size = list.CalculateSize(ComputeInt32Size); - WriteRawVarint32(size); - foreach (var value in list) - { - WriteInt32(value); - } - } - - public void WritePackedSInt32Array(RepeatedField list) - { - uint size = list.CalculateSize(ComputeSInt32Size); - WriteRawVarint32(size); - foreach (var value in list) - { - WriteSInt32(value); - } - } - - public void WritePackedUInt32Array(RepeatedField list) - { - uint size = list.CalculateSize(ComputeUInt32Size); - WriteRawVarint32(size); - foreach (var value in list) - { - WriteUInt32(value); - } - } - - public void WritePackedFixed32Array(RepeatedField list) - { - uint size = (uint) list.Count * 4; - WriteRawVarint32(size); - foreach (var value in list) - { - WriteFixed32(value); - } - } - - public void WritePackedSFixed32Array(RepeatedField list) - { - uint size = (uint) list.Count * 4; - WriteRawVarint32(size); - foreach (var value in list) - { - WriteSFixed32(value); - } - } - - public void WritePackedInt64Array(RepeatedField list) - { - uint size = list.CalculateSize(ComputeInt64Size); - WriteRawVarint32(size); - foreach (var value in list) - { - WriteInt64(value); - } - } - - public void WritePackedSInt64Array(RepeatedField list) - { - uint size = list.CalculateSize(ComputeSInt64Size); - WriteRawVarint32(size); - foreach (var value in list) - { - WriteSInt64(value); - } - } - - public void WritePackedUInt64Array(RepeatedField list) - { - if (list.Count == 0) - { - return; - } - uint size = list.CalculateSize(ComputeUInt64Size); - WriteRawVarint32(size); - foreach (var value in list) - { - WriteUInt64(value); - } - } - - public void WritePackedFixed64Array(RepeatedField list) - { - uint size = (uint) list.Count * 8; - WriteRawVarint32(size); - foreach (var value in list) - { - WriteFixed64(value); - } - } - - public void WritePackedSFixed64Array(RepeatedField list) - { - uint size = (uint) list.Count * 8; - WriteRawVarint32(size); - foreach (var value in list) - { - WriteSFixed64(value); - } - } - - public void WritePackedDoubleArray(RepeatedField list) - { - uint size = (uint) list.Count * 8; - WriteRawVarint32(size); - foreach (var value in list) - { - WriteDouble(value); - } - } - - public void WritePackedFloatArray(RepeatedField list) - { - if (list.Count == 0) - { - return; - } - uint size = (uint) list.Count * 4; - WriteRawVarint32(size); - foreach (var value in list) - { - WriteFloat(value); - } - } - - public void WritePackedEnumArray(RepeatedField list) - where T : struct, IComparable, IFormattable - { - if (list.Count == 0) - { - return; - } - // Bit of a hack, to access the values as ints - var iterator = list.GetInt32Enumerator(); - uint size = 0; - while (iterator.MoveNext()) - { - size += (uint) ComputeEnumSize(iterator.Current); - } - iterator.Reset(); - WriteRawVarint32(size); - while (iterator.MoveNext()) - { - WriteEnum(iterator.Current); - } - } - - #endregion - #region Underlying writing primitives /// /// Writes a 32 bit value as a varint. The fast route is taken when diff --git a/csharp/src/ProtocolBuffers/Collections/MapField.cs b/csharp/src/ProtocolBuffers/Collections/MapField.cs index 9eed833f..6d1097a6 100644 --- a/csharp/src/ProtocolBuffers/Collections/MapField.cs +++ b/csharp/src/ProtocolBuffers/Collections/MapField.cs @@ -334,6 +334,10 @@ namespace Google.Protobuf.Collections public int CalculateSize(Codec codec) { + if (Count == 0) + { + return 0; + } var message = new Codec.MessageAdapter(codec); int size = 0; foreach (var entry in list) @@ -419,13 +423,13 @@ namespace Google.Protobuf.Collections public void WriteTo(CodedOutputStream output) { - codec.keyCodec.Write(output, Key); - codec.valueCodec.Write(output, Value); + codec.keyCodec.WriteTagAndValue(output, Key); + codec.valueCodec.WriteTagAndValue(output, Value); } public int CalculateSize() { - return codec.keyCodec.CalculateSize(Key) + codec.valueCodec.CalculateSize(Value); + return codec.keyCodec.CalculateSizeWithTag(Key) + codec.valueCodec.CalculateSizeWithTag(Value); } } } diff --git a/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs b/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs index 39d4f351..588f66a4 100644 --- a/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs +++ b/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs @@ -49,6 +49,112 @@ namespace Google.Protobuf.Collections return clone; } + public void AddEntriesFrom(CodedInputStream input, FieldCodec codec) + { + uint tag = input.LastTag; + var reader = codec.ValueReader; + // Value types can be packed or not. + if (typeof(T).IsValueType && WireFormat.GetTagWireType(tag) == WireFormat.WireType.LengthDelimited) + { + int length = (int)(input.ReadRawVarint32() & int.MaxValue); + if (length > 0) + { + int oldLimit = input.PushLimit(length); + while (!input.ReachedLimit) + { + Add(reader(input)); + } + input.PopLimit(oldLimit); + } + // Empty packed field. Odd, but valid - just ignore. + } + else + { + // Not packed... (possibly not packable) + do + { + Add(reader(input)); + } while (input.MaybeConsumeTag(tag)); + } + } + + public int CalculateSize(FieldCodec codec) + { + if (count == 0) + { + return 0; + } + uint tag = codec.Tag; + if (typeof(T).IsValueType && WireFormat.GetTagWireType(tag) == WireFormat.WireType.LengthDelimited) + { + int dataSize = CalculatePackedDataSize(codec); + return CodedOutputStream.ComputeRawVarint32Size(tag) + + CodedOutputStream.ComputeRawVarint32Size((uint)dataSize) + + dataSize; + } + else + { + var sizeCalculator = codec.ValueSizeCalculator; + int size = count * CodedOutputStream.ComputeRawVarint32Size(tag); + for (int i = 0; i < count; i++) + { + size += sizeCalculator(array[i]); + } + return size; + } + } + + private int CalculatePackedDataSize(FieldCodec codec) + { + int fixedSize = codec.FixedSize; + if (fixedSize == 0) + { + var calculator = codec.ValueSizeCalculator; + int tmp = 0; + for (int i = 0; i < count; i++) + { + tmp += calculator(array[i]); + } + return tmp; + } + else + { + return fixedSize * Count; + } + } + + public void WriteTo(CodedOutputStream output, FieldCodec codec) + { + // TODO: Assert that T is a value type, and that codec.Tag is packed? + if (count == 0) + { + return; + } + var writer = codec.ValueWriter; + var tag = codec.Tag; + if (typeof(T).IsValueType && WireFormat.GetTagWireType(tag) == WireFormat.WireType.LengthDelimited) + { + // Packed primitive type + uint size = (uint)CalculatePackedDataSize(codec); + output.WriteTag(tag); + output.WriteRawVarint32(size); + for (int i = 0; i < count; i++) + { + writer(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(output, array[i]); + } + } + } + public bool IsFrozen { get { return frozen; } } public void Freeze() @@ -87,18 +193,6 @@ namespace Google.Protobuf.Collections array[count++] = item; } - /// - /// Hack to allow us to add enums easily... will only work with int-based types. - /// - /// - internal void AddInt32(int item) - { - this.CheckMutable(); - EnsureSize(count + 1); - int[] castArray = (int[]) (object) array; - castArray[count++] = item; - } - public void Clear() { this.CheckMutable(); @@ -180,16 +274,7 @@ namespace Google.Protobuf.Collections IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); - } - - /// - /// Returns an enumerator of the values in this list as integers. - /// Used for enum types. - /// - internal Int32Enumerator GetInt32Enumerator() - { - return new Int32Enumerator((int[])(object)array, count); - } + } public override int GetHashCode() { @@ -297,17 +382,7 @@ namespace Google.Protobuf.Collections array[index] = value; } } - - internal uint CalculateSize(Func sizeComputer) - { - int size = 0; - for (int i = 0; i < count; i++) - { - size += sizeComputer(array[i]); - } - return (uint)size; - } - + public struct Enumerator : IEnumerator { private int index; @@ -355,46 +430,5 @@ namespace Google.Protobuf.Collections { } } - - internal struct Int32Enumerator : IEnumerator - { - private int index; - private readonly int[] array; - private readonly int count; - - public Int32Enumerator(int[] array, int count) - { - this.array = array; - this.index = -1; - this.count = count; - } - - public bool MoveNext() - { - if (index + 1 >= count) - { - return false; - } - index++; - return true; - } - - public void Reset() - { - index = -1; - } - - // No guard here, as we're only going to use this internally... - public int Current { get { return array[index]; } } - - object IEnumerator.Current - { - get { return Current; } - } - - public void Dispose() - { - } - } } } diff --git a/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs b/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs index bc0419b0..80166a34 100644 --- a/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs +++ b/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs @@ -314,6 +314,8 @@ namespace Google.Protobuf.DescriptorProtos { } public const int FileFieldNumber = 1; + private static readonly pb::FieldCodec _repeated_file_codec + = pb::FieldCodec.ForMessage(10, global::Google.Protobuf.DescriptorProtos.FileDescriptorProto.Parser); private readonly pbc::RepeatedField file_ = new pbc::RepeatedField(); public pbc::RepeatedField File { get { return file_; } @@ -341,19 +343,12 @@ namespace Google.Protobuf.DescriptorProtos { } public void WriteTo(pb::CodedOutputStream output) { - if (file_.Count > 0) { - output.WriteMessageArray(1, file_); - } + file_.WriteTo(output, _repeated_file_codec); } public int CalculateSize() { int size = 0; - if (file_.Count > 0) { - foreach (global::Google.Protobuf.DescriptorProtos.FileDescriptorProto element in file_) { - size += pb::CodedOutputStream.ComputeMessageSize(element); - } - size += 1 * file_.Count; - } + size += file_.CalculateSize(_repeated_file_codec); return size; } @@ -376,7 +371,7 @@ namespace Google.Protobuf.DescriptorProtos { } break; case 10: { - input.ReadMessageArray(file_, global::Google.Protobuf.DescriptorProtos.FileDescriptorProto.Parser); + file_.AddEntriesFrom(input, _repeated_file_codec); break; } } @@ -461,42 +456,56 @@ namespace Google.Protobuf.DescriptorProtos { } public const int DependencyFieldNumber = 3; + private static readonly pb::FieldCodec _repeated_dependency_codec + = pb::FieldCodec.ForString(26); private readonly pbc::RepeatedField dependency_ = new pbc::RepeatedField(); public pbc::RepeatedField Dependency { get { return dependency_; } } public const int PublicDependencyFieldNumber = 10; + private static readonly pb::FieldCodec _repeated_publicDependency_codec + = pb::FieldCodec.ForInt32(80); private readonly pbc::RepeatedField publicDependency_ = new pbc::RepeatedField(); public pbc::RepeatedField PublicDependency { get { return publicDependency_; } } public const int WeakDependencyFieldNumber = 11; + private static readonly pb::FieldCodec _repeated_weakDependency_codec + = pb::FieldCodec.ForInt32(88); private readonly pbc::RepeatedField weakDependency_ = new pbc::RepeatedField(); public pbc::RepeatedField WeakDependency { get { return weakDependency_; } } public const int MessageTypeFieldNumber = 4; + private static readonly pb::FieldCodec _repeated_messageType_codec + = pb::FieldCodec.ForMessage(34, global::Google.Protobuf.DescriptorProtos.DescriptorProto.Parser); private readonly pbc::RepeatedField messageType_ = new pbc::RepeatedField(); public pbc::RepeatedField MessageType { get { return messageType_; } } public const int EnumTypeFieldNumber = 5; + private static readonly pb::FieldCodec _repeated_enumType_codec + = pb::FieldCodec.ForMessage(42, global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto.Parser); private readonly pbc::RepeatedField enumType_ = new pbc::RepeatedField(); public pbc::RepeatedField EnumType { get { return enumType_; } } public const int ServiceFieldNumber = 6; + private static readonly pb::FieldCodec _repeated_service_codec + = pb::FieldCodec.ForMessage(50, global::Google.Protobuf.DescriptorProtos.ServiceDescriptorProto.Parser); private readonly pbc::RepeatedField service_ = new pbc::RepeatedField(); public pbc::RepeatedField Service { get { return service_; } } public const int ExtensionFieldNumber = 7; + private static readonly pb::FieldCodec _repeated_extension_codec + = pb::FieldCodec.ForMessage(58, global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Parser); private readonly pbc::RepeatedField extension_ = new pbc::RepeatedField(); public pbc::RepeatedField Extension { get { return extension_; } @@ -584,21 +593,11 @@ namespace Google.Protobuf.DescriptorProtos { output.WriteRawTag(18); output.WriteString(Package); } - if (dependency_.Count > 0) { - output.WriteStringArray(3, dependency_); - } - if (messageType_.Count > 0) { - output.WriteMessageArray(4, messageType_); - } - if (enumType_.Count > 0) { - output.WriteMessageArray(5, enumType_); - } - if (service_.Count > 0) { - output.WriteMessageArray(6, service_); - } - if (extension_.Count > 0) { - output.WriteMessageArray(7, extension_); - } + dependency_.WriteTo(output, _repeated_dependency_codec); + messageType_.WriteTo(output, _repeated_messageType_codec); + enumType_.WriteTo(output, _repeated_enumType_codec); + service_.WriteTo(output, _repeated_service_codec); + extension_.WriteTo(output, _repeated_extension_codec); if (options_ != null) { output.WriteRawTag(66); output.WriteMessage(Options); @@ -607,12 +606,8 @@ namespace Google.Protobuf.DescriptorProtos { output.WriteRawTag(74); output.WriteMessage(SourceCodeInfo); } - if (publicDependency_.Count > 0) { - output.WriteInt32Array(10, publicDependency_); - } - if (weakDependency_.Count > 0) { - output.WriteInt32Array(11, weakDependency_); - } + publicDependency_.WriteTo(output, _repeated_publicDependency_codec); + weakDependency_.WriteTo(output, _repeated_weakDependency_codec); if (Syntax.Length != 0) { output.WriteRawTag(98); output.WriteString(Syntax); @@ -627,54 +622,13 @@ namespace Google.Protobuf.DescriptorProtos { if (Package.Length != 0) { size += 1 + pb::CodedOutputStream.ComputeStringSize(Package); } - if (dependency_.Count > 0) { - int dataSize = 0; - foreach (string element in dependency_) { - dataSize += pb::CodedOutputStream.ComputeStringSize(element); - } - size += dataSize; - size += 1 * dependency_.Count; - } - if (publicDependency_.Count > 0) { - int dataSize = 0; - foreach (int element in publicDependency_) { - dataSize += pb::CodedOutputStream.ComputeInt32Size(element); - } - size += dataSize; - size += 1 * publicDependency_.Count; - } - if (weakDependency_.Count > 0) { - int dataSize = 0; - foreach (int element in weakDependency_) { - dataSize += pb::CodedOutputStream.ComputeInt32Size(element); - } - size += dataSize; - size += 1 * weakDependency_.Count; - } - if (messageType_.Count > 0) { - foreach (global::Google.Protobuf.DescriptorProtos.DescriptorProto element in messageType_) { - size += pb::CodedOutputStream.ComputeMessageSize(element); - } - size += 1 * messageType_.Count; - } - if (enumType_.Count > 0) { - foreach (global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto element in enumType_) { - size += pb::CodedOutputStream.ComputeMessageSize(element); - } - size += 1 * enumType_.Count; - } - if (service_.Count > 0) { - foreach (global::Google.Protobuf.DescriptorProtos.ServiceDescriptorProto element in service_) { - size += pb::CodedOutputStream.ComputeMessageSize(element); - } - size += 1 * service_.Count; - } - if (extension_.Count > 0) { - foreach (global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto element in extension_) { - size += pb::CodedOutputStream.ComputeMessageSize(element); - } - size += 1 * extension_.Count; - } + size += dependency_.CalculateSize(_repeated_dependency_codec); + size += publicDependency_.CalculateSize(_repeated_publicDependency_codec); + size += weakDependency_.CalculateSize(_repeated_weakDependency_codec); + size += messageType_.CalculateSize(_repeated_messageType_codec); + size += enumType_.CalculateSize(_repeated_enumType_codec); + size += service_.CalculateSize(_repeated_service_codec); + size += extension_.CalculateSize(_repeated_extension_codec); if (options_ != null) { size += 1 + pb::CodedOutputStream.ComputeMessageSize(Options); } @@ -741,23 +695,23 @@ namespace Google.Protobuf.DescriptorProtos { break; } case 26: { - input.ReadStringArray(dependency_); + dependency_.AddEntriesFrom(input, _repeated_dependency_codec); break; } case 34: { - input.ReadMessageArray(messageType_, global::Google.Protobuf.DescriptorProtos.DescriptorProto.Parser); + messageType_.AddEntriesFrom(input, _repeated_messageType_codec); break; } case 42: { - input.ReadMessageArray(enumType_, global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto.Parser); + enumType_.AddEntriesFrom(input, _repeated_enumType_codec); break; } case 50: { - input.ReadMessageArray(service_, global::Google.Protobuf.DescriptorProtos.ServiceDescriptorProto.Parser); + service_.AddEntriesFrom(input, _repeated_service_codec); break; } case 58: { - input.ReadMessageArray(extension_, global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Parser); + extension_.AddEntriesFrom(input, _repeated_extension_codec); break; } case 66: { @@ -776,12 +730,12 @@ namespace Google.Protobuf.DescriptorProtos { } case 82: case 80: { - input.ReadInt32Array(publicDependency_); + publicDependency_.AddEntriesFrom(input, _repeated_publicDependency_codec); break; } case 90: case 88: { - input.ReadInt32Array(weakDependency_); + weakDependency_.AddEntriesFrom(input, _repeated_weakDependency_codec); break; } case 98: { @@ -858,36 +812,48 @@ namespace Google.Protobuf.DescriptorProtos { } public const int FieldFieldNumber = 2; + private static readonly pb::FieldCodec _repeated_field_codec + = pb::FieldCodec.ForMessage(18, global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Parser); private readonly pbc::RepeatedField field_ = new pbc::RepeatedField(); public pbc::RepeatedField Field { get { return field_; } } public const int ExtensionFieldNumber = 6; + private static readonly pb::FieldCodec _repeated_extension_codec + = pb::FieldCodec.ForMessage(50, global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Parser); private readonly pbc::RepeatedField extension_ = new pbc::RepeatedField(); public pbc::RepeatedField Extension { get { return extension_; } } public const int NestedTypeFieldNumber = 3; + private static readonly pb::FieldCodec _repeated_nestedType_codec + = pb::FieldCodec.ForMessage(26, global::Google.Protobuf.DescriptorProtos.DescriptorProto.Parser); private readonly pbc::RepeatedField nestedType_ = new pbc::RepeatedField(); public pbc::RepeatedField NestedType { get { return nestedType_; } } public const int EnumTypeFieldNumber = 4; + private static readonly pb::FieldCodec _repeated_enumType_codec + = pb::FieldCodec.ForMessage(34, global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto.Parser); private readonly pbc::RepeatedField enumType_ = new pbc::RepeatedField(); public pbc::RepeatedField EnumType { get { return enumType_; } } public const int ExtensionRangeFieldNumber = 5; + private static readonly pb::FieldCodec _repeated_extensionRange_codec + = pb::FieldCodec.ForMessage(42, global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ExtensionRange.Parser); private readonly pbc::RepeatedField extensionRange_ = new pbc::RepeatedField(); public pbc::RepeatedField ExtensionRange { get { return extensionRange_; } } public const int OneofDeclFieldNumber = 8; + private static readonly pb::FieldCodec _repeated_oneofDecl_codec + = pb::FieldCodec.ForMessage(66, global::Google.Protobuf.DescriptorProtos.OneofDescriptorProto.Parser); private readonly pbc::RepeatedField oneofDecl_ = new pbc::RepeatedField(); public pbc::RepeatedField OneofDecl { get { return oneofDecl_; } @@ -904,12 +870,16 @@ namespace Google.Protobuf.DescriptorProtos { } public const int ReservedRangeFieldNumber = 9; + private static readonly pb::FieldCodec _repeated_reservedRange_codec + = pb::FieldCodec.ForMessage(74, global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ReservedRange.Parser); private readonly pbc::RepeatedField reservedRange_ = new pbc::RepeatedField(); public pbc::RepeatedField ReservedRange { get { return reservedRange_; } } public const int ReservedNameFieldNumber = 10; + private static readonly pb::FieldCodec _repeated_reservedName_codec + = pb::FieldCodec.ForString(82); private readonly pbc::RepeatedField reservedName_ = new pbc::RepeatedField(); public pbc::RepeatedField ReservedName { get { return reservedName_; } @@ -959,34 +929,18 @@ namespace Google.Protobuf.DescriptorProtos { output.WriteRawTag(10); output.WriteString(Name); } - if (field_.Count > 0) { - output.WriteMessageArray(2, field_); - } - if (nestedType_.Count > 0) { - output.WriteMessageArray(3, nestedType_); - } - if (enumType_.Count > 0) { - output.WriteMessageArray(4, enumType_); - } - if (extensionRange_.Count > 0) { - output.WriteMessageArray(5, extensionRange_); - } - if (extension_.Count > 0) { - output.WriteMessageArray(6, extension_); - } + field_.WriteTo(output, _repeated_field_codec); + nestedType_.WriteTo(output, _repeated_nestedType_codec); + enumType_.WriteTo(output, _repeated_enumType_codec); + extensionRange_.WriteTo(output, _repeated_extensionRange_codec); + extension_.WriteTo(output, _repeated_extension_codec); if (options_ != null) { output.WriteRawTag(58); output.WriteMessage(Options); } - if (oneofDecl_.Count > 0) { - output.WriteMessageArray(8, oneofDecl_); - } - if (reservedRange_.Count > 0) { - output.WriteMessageArray(9, reservedRange_); - } - if (reservedName_.Count > 0) { - output.WriteStringArray(10, reservedName_); - } + oneofDecl_.WriteTo(output, _repeated_oneofDecl_codec); + reservedRange_.WriteTo(output, _repeated_reservedRange_codec); + reservedName_.WriteTo(output, _repeated_reservedName_codec); } public int CalculateSize() { @@ -994,59 +948,17 @@ namespace Google.Protobuf.DescriptorProtos { if (Name.Length != 0) { size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); } - if (field_.Count > 0) { - foreach (global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto element in field_) { - size += pb::CodedOutputStream.ComputeMessageSize(element); - } - size += 1 * field_.Count; - } - if (extension_.Count > 0) { - foreach (global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto element in extension_) { - size += pb::CodedOutputStream.ComputeMessageSize(element); - } - size += 1 * extension_.Count; - } - if (nestedType_.Count > 0) { - foreach (global::Google.Protobuf.DescriptorProtos.DescriptorProto element in nestedType_) { - size += pb::CodedOutputStream.ComputeMessageSize(element); - } - size += 1 * nestedType_.Count; - } - if (enumType_.Count > 0) { - foreach (global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto element in enumType_) { - size += pb::CodedOutputStream.ComputeMessageSize(element); - } - size += 1 * enumType_.Count; - } - if (extensionRange_.Count > 0) { - foreach (global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ExtensionRange element in extensionRange_) { - size += pb::CodedOutputStream.ComputeMessageSize(element); - } - size += 1 * extensionRange_.Count; - } - if (oneofDecl_.Count > 0) { - foreach (global::Google.Protobuf.DescriptorProtos.OneofDescriptorProto element in oneofDecl_) { - size += pb::CodedOutputStream.ComputeMessageSize(element); - } - size += 1 * oneofDecl_.Count; - } + size += field_.CalculateSize(_repeated_field_codec); + size += extension_.CalculateSize(_repeated_extension_codec); + size += nestedType_.CalculateSize(_repeated_nestedType_codec); + size += enumType_.CalculateSize(_repeated_enumType_codec); + size += extensionRange_.CalculateSize(_repeated_extensionRange_codec); + size += oneofDecl_.CalculateSize(_repeated_oneofDecl_codec); if (options_ != null) { size += 1 + pb::CodedOutputStream.ComputeMessageSize(Options); } - if (reservedRange_.Count > 0) { - foreach (global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ReservedRange element in reservedRange_) { - size += pb::CodedOutputStream.ComputeMessageSize(element); - } - size += 1 * reservedRange_.Count; - } - if (reservedName_.Count > 0) { - int dataSize = 0; - foreach (string element in reservedName_) { - dataSize += pb::CodedOutputStream.ComputeStringSize(element); - } - size += dataSize; - size += 1 * reservedName_.Count; - } + size += reservedRange_.CalculateSize(_repeated_reservedRange_codec); + size += reservedName_.CalculateSize(_repeated_reservedName_codec); return size; } @@ -1089,23 +1001,23 @@ namespace Google.Protobuf.DescriptorProtos { break; } case 18: { - input.ReadMessageArray(field_, global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Parser); + field_.AddEntriesFrom(input, _repeated_field_codec); break; } case 26: { - input.ReadMessageArray(nestedType_, global::Google.Protobuf.DescriptorProtos.DescriptorProto.Parser); + nestedType_.AddEntriesFrom(input, _repeated_nestedType_codec); break; } case 34: { - input.ReadMessageArray(enumType_, global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto.Parser); + enumType_.AddEntriesFrom(input, _repeated_enumType_codec); break; } case 42: { - input.ReadMessageArray(extensionRange_, global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ExtensionRange.Parser); + extensionRange_.AddEntriesFrom(input, _repeated_extensionRange_codec); break; } case 50: { - input.ReadMessageArray(extension_, global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Parser); + extension_.AddEntriesFrom(input, _repeated_extension_codec); break; } case 58: { @@ -1116,15 +1028,15 @@ namespace Google.Protobuf.DescriptorProtos { break; } case 66: { - input.ReadMessageArray(oneofDecl_, global::Google.Protobuf.DescriptorProtos.OneofDescriptorProto.Parser); + oneofDecl_.AddEntriesFrom(input, _repeated_oneofDecl_codec); break; } case 74: { - input.ReadMessageArray(reservedRange_, global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ReservedRange.Parser); + reservedRange_.AddEntriesFrom(input, _repeated_reservedRange_codec); break; } case 82: { - input.ReadStringArray(reservedName_); + reservedName_.AddEntriesFrom(input, _repeated_reservedName_codec); break; } } @@ -1943,6 +1855,8 @@ namespace Google.Protobuf.DescriptorProtos { } public const int ValueFieldNumber = 2; + private static readonly pb::FieldCodec _repeated_value_codec + = pb::FieldCodec.ForMessage(18, global::Google.Protobuf.DescriptorProtos.EnumValueDescriptorProto.Parser); private readonly pbc::RepeatedField value_ = new pbc::RepeatedField(); public pbc::RepeatedField Value { get { return value_; } @@ -1988,9 +1902,7 @@ namespace Google.Protobuf.DescriptorProtos { output.WriteRawTag(10); output.WriteString(Name); } - if (value_.Count > 0) { - output.WriteMessageArray(2, value_); - } + value_.WriteTo(output, _repeated_value_codec); if (options_ != null) { output.WriteRawTag(26); output.WriteMessage(Options); @@ -2002,12 +1914,7 @@ namespace Google.Protobuf.DescriptorProtos { if (Name.Length != 0) { size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); } - if (value_.Count > 0) { - foreach (global::Google.Protobuf.DescriptorProtos.EnumValueDescriptorProto element in value_) { - size += pb::CodedOutputStream.ComputeMessageSize(element); - } - size += 1 * value_.Count; - } + size += value_.CalculateSize(_repeated_value_codec); if (options_ != null) { size += 1 + pb::CodedOutputStream.ComputeMessageSize(Options); } @@ -2046,7 +1953,7 @@ namespace Google.Protobuf.DescriptorProtos { break; } case 18: { - input.ReadMessageArray(value_, global::Google.Protobuf.DescriptorProtos.EnumValueDescriptorProto.Parser); + value_.AddEntriesFrom(input, _repeated_value_codec); break; } case 26: { @@ -2284,6 +2191,8 @@ namespace Google.Protobuf.DescriptorProtos { } public const int MethodFieldNumber = 2; + private static readonly pb::FieldCodec _repeated_method_codec + = pb::FieldCodec.ForMessage(18, global::Google.Protobuf.DescriptorProtos.MethodDescriptorProto.Parser); private readonly pbc::RepeatedField method_ = new pbc::RepeatedField(); public pbc::RepeatedField Method { get { return method_; } @@ -2329,9 +2238,7 @@ namespace Google.Protobuf.DescriptorProtos { output.WriteRawTag(10); output.WriteString(Name); } - if (method_.Count > 0) { - output.WriteMessageArray(2, method_); - } + method_.WriteTo(output, _repeated_method_codec); if (options_ != null) { output.WriteRawTag(26); output.WriteMessage(Options); @@ -2343,12 +2250,7 @@ namespace Google.Protobuf.DescriptorProtos { if (Name.Length != 0) { size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); } - if (method_.Count > 0) { - foreach (global::Google.Protobuf.DescriptorProtos.MethodDescriptorProto element in method_) { - size += pb::CodedOutputStream.ComputeMessageSize(element); - } - size += 1 * method_.Count; - } + size += method_.CalculateSize(_repeated_method_codec); if (options_ != null) { size += 1 + pb::CodedOutputStream.ComputeMessageSize(Options); } @@ -2387,7 +2289,7 @@ namespace Google.Protobuf.DescriptorProtos { break; } case 18: { - input.ReadMessageArray(method_, global::Google.Protobuf.DescriptorProtos.MethodDescriptorProto.Parser); + method_.AddEntriesFrom(input, _repeated_method_codec); break; } case 26: { @@ -2847,6 +2749,8 @@ namespace Google.Protobuf.DescriptorProtos { } public const int UninterpretedOptionFieldNumber = 999; + private static readonly pb::FieldCodec _repeated_uninterpretedOption_codec + = pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); private readonly pbc::RepeatedField uninterpretedOption_ = new pbc::RepeatedField(); public pbc::RepeatedField UninterpretedOption { get { return uninterpretedOption_; } @@ -2958,9 +2862,7 @@ namespace Google.Protobuf.DescriptorProtos { output.WriteRawTag(170, 2); output.WriteString(CsharpNamespace); } - if (uninterpretedOption_.Count > 0) { - output.WriteMessageArray(999, uninterpretedOption_); - } + uninterpretedOption_.WriteTo(output, _repeated_uninterpretedOption_codec); } public int CalculateSize() { @@ -3007,12 +2909,7 @@ namespace Google.Protobuf.DescriptorProtos { if (CsharpNamespace.Length != 0) { size += 2 + pb::CodedOutputStream.ComputeStringSize(CsharpNamespace); } - if (uninterpretedOption_.Count > 0) { - foreach (global::Google.Protobuf.DescriptorProtos.UninterpretedOption element in uninterpretedOption_) { - size += pb::CodedOutputStream.ComputeMessageSize(element); - } - size += 2 * uninterpretedOption_.Count; - } + size += uninterpretedOption_.CalculateSize(_repeated_uninterpretedOption_codec); return size; } @@ -3133,7 +3030,7 @@ namespace Google.Protobuf.DescriptorProtos { break; } case 7994: { - input.ReadMessageArray(uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); + uninterpretedOption_.AddEntriesFrom(input, _repeated_uninterpretedOption_codec); break; } } @@ -3235,6 +3132,8 @@ namespace Google.Protobuf.DescriptorProtos { } public const int UninterpretedOptionFieldNumber = 999; + private static readonly pb::FieldCodec _repeated_uninterpretedOption_codec + = pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); private readonly pbc::RepeatedField uninterpretedOption_ = new pbc::RepeatedField(); public pbc::RepeatedField UninterpretedOption { get { return uninterpretedOption_; } @@ -3286,9 +3185,7 @@ namespace Google.Protobuf.DescriptorProtos { output.WriteRawTag(56); output.WriteBool(MapEntry); } - if (uninterpretedOption_.Count > 0) { - output.WriteMessageArray(999, uninterpretedOption_); - } + uninterpretedOption_.WriteTo(output, _repeated_uninterpretedOption_codec); } public int CalculateSize() { @@ -3305,12 +3202,7 @@ namespace Google.Protobuf.DescriptorProtos { if (MapEntry != false) { size += 1 + 1; } - if (uninterpretedOption_.Count > 0) { - foreach (global::Google.Protobuf.DescriptorProtos.UninterpretedOption element in uninterpretedOption_) { - size += pb::CodedOutputStream.ComputeMessageSize(element); - } - size += 2 * uninterpretedOption_.Count; - } + size += uninterpretedOption_.CalculateSize(_repeated_uninterpretedOption_codec); return size; } @@ -3361,7 +3253,7 @@ namespace Google.Protobuf.DescriptorProtos { break; } case 7994: { - input.ReadMessageArray(uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); + uninterpretedOption_.AddEntriesFrom(input, _repeated_uninterpretedOption_codec); break; } } @@ -3473,6 +3365,8 @@ namespace Google.Protobuf.DescriptorProtos { } public const int UninterpretedOptionFieldNumber = 999; + private static readonly pb::FieldCodec _repeated_uninterpretedOption_codec + = pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); private readonly pbc::RepeatedField uninterpretedOption_ = new pbc::RepeatedField(); public pbc::RepeatedField UninterpretedOption { get { return uninterpretedOption_; } @@ -3536,9 +3430,7 @@ namespace Google.Protobuf.DescriptorProtos { output.WriteRawTag(80); output.WriteBool(Weak); } - if (uninterpretedOption_.Count > 0) { - output.WriteMessageArray(999, uninterpretedOption_); - } + uninterpretedOption_.WriteTo(output, _repeated_uninterpretedOption_codec); } public int CalculateSize() { @@ -3561,12 +3453,7 @@ namespace Google.Protobuf.DescriptorProtos { if (Weak != false) { size += 1 + 1; } - if (uninterpretedOption_.Count > 0) { - foreach (global::Google.Protobuf.DescriptorProtos.UninterpretedOption element in uninterpretedOption_) { - size += pb::CodedOutputStream.ComputeMessageSize(element); - } - size += 2 * uninterpretedOption_.Count; - } + size += uninterpretedOption_.CalculateSize(_repeated_uninterpretedOption_codec); return size; } @@ -3631,7 +3518,7 @@ namespace Google.Protobuf.DescriptorProtos { break; } case 7994: { - input.ReadMessageArray(uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); + uninterpretedOption_.AddEntriesFrom(input, _repeated_uninterpretedOption_codec); break; } } @@ -3717,6 +3604,8 @@ namespace Google.Protobuf.DescriptorProtos { } public const int UninterpretedOptionFieldNumber = 999; + private static readonly pb::FieldCodec _repeated_uninterpretedOption_codec + = pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); private readonly pbc::RepeatedField uninterpretedOption_ = new pbc::RepeatedField(); public pbc::RepeatedField UninterpretedOption { get { return uninterpretedOption_; } @@ -3756,9 +3645,7 @@ namespace Google.Protobuf.DescriptorProtos { output.WriteRawTag(24); output.WriteBool(Deprecated); } - if (uninterpretedOption_.Count > 0) { - output.WriteMessageArray(999, uninterpretedOption_); - } + uninterpretedOption_.WriteTo(output, _repeated_uninterpretedOption_codec); } public int CalculateSize() { @@ -3769,12 +3656,7 @@ namespace Google.Protobuf.DescriptorProtos { if (Deprecated != false) { size += 1 + 1; } - if (uninterpretedOption_.Count > 0) { - foreach (global::Google.Protobuf.DescriptorProtos.UninterpretedOption element in uninterpretedOption_) { - size += pb::CodedOutputStream.ComputeMessageSize(element); - } - size += 2 * uninterpretedOption_.Count; - } + size += uninterpretedOption_.CalculateSize(_repeated_uninterpretedOption_codec); return size; } @@ -3811,7 +3693,7 @@ namespace Google.Protobuf.DescriptorProtos { break; } case 7994: { - input.ReadMessageArray(uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); + uninterpretedOption_.AddEntriesFrom(input, _repeated_uninterpretedOption_codec); break; } } @@ -3868,6 +3750,8 @@ namespace Google.Protobuf.DescriptorProtos { } public const int UninterpretedOptionFieldNumber = 999; + private static readonly pb::FieldCodec _repeated_uninterpretedOption_codec + = pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); private readonly pbc::RepeatedField uninterpretedOption_ = new pbc::RepeatedField(); public pbc::RepeatedField UninterpretedOption { get { return uninterpretedOption_; } @@ -3901,9 +3785,7 @@ namespace Google.Protobuf.DescriptorProtos { output.WriteRawTag(8); output.WriteBool(Deprecated); } - if (uninterpretedOption_.Count > 0) { - output.WriteMessageArray(999, uninterpretedOption_); - } + uninterpretedOption_.WriteTo(output, _repeated_uninterpretedOption_codec); } public int CalculateSize() { @@ -3911,12 +3793,7 @@ namespace Google.Protobuf.DescriptorProtos { if (Deprecated != false) { size += 1 + 1; } - if (uninterpretedOption_.Count > 0) { - foreach (global::Google.Protobuf.DescriptorProtos.UninterpretedOption element in uninterpretedOption_) { - size += pb::CodedOutputStream.ComputeMessageSize(element); - } - size += 2 * uninterpretedOption_.Count; - } + size += uninterpretedOption_.CalculateSize(_repeated_uninterpretedOption_codec); return size; } @@ -3946,7 +3823,7 @@ namespace Google.Protobuf.DescriptorProtos { break; } case 7994: { - input.ReadMessageArray(uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); + uninterpretedOption_.AddEntriesFrom(input, _repeated_uninterpretedOption_codec); break; } } @@ -4003,6 +3880,8 @@ namespace Google.Protobuf.DescriptorProtos { } public const int UninterpretedOptionFieldNumber = 999; + private static readonly pb::FieldCodec _repeated_uninterpretedOption_codec + = pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); private readonly pbc::RepeatedField uninterpretedOption_ = new pbc::RepeatedField(); public pbc::RepeatedField UninterpretedOption { get { return uninterpretedOption_; } @@ -4036,9 +3915,7 @@ namespace Google.Protobuf.DescriptorProtos { output.WriteRawTag(136, 2); output.WriteBool(Deprecated); } - if (uninterpretedOption_.Count > 0) { - output.WriteMessageArray(999, uninterpretedOption_); - } + uninterpretedOption_.WriteTo(output, _repeated_uninterpretedOption_codec); } public int CalculateSize() { @@ -4046,12 +3923,7 @@ namespace Google.Protobuf.DescriptorProtos { if (Deprecated != false) { size += 2 + 1; } - if (uninterpretedOption_.Count > 0) { - foreach (global::Google.Protobuf.DescriptorProtos.UninterpretedOption element in uninterpretedOption_) { - size += pb::CodedOutputStream.ComputeMessageSize(element); - } - size += 2 * uninterpretedOption_.Count; - } + size += uninterpretedOption_.CalculateSize(_repeated_uninterpretedOption_codec); return size; } @@ -4081,7 +3953,7 @@ namespace Google.Protobuf.DescriptorProtos { break; } case 7994: { - input.ReadMessageArray(uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); + uninterpretedOption_.AddEntriesFrom(input, _repeated_uninterpretedOption_codec); break; } } @@ -4138,6 +4010,8 @@ namespace Google.Protobuf.DescriptorProtos { } public const int UninterpretedOptionFieldNumber = 999; + private static readonly pb::FieldCodec _repeated_uninterpretedOption_codec + = pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); private readonly pbc::RepeatedField uninterpretedOption_ = new pbc::RepeatedField(); public pbc::RepeatedField UninterpretedOption { get { return uninterpretedOption_; } @@ -4171,9 +4045,7 @@ namespace Google.Protobuf.DescriptorProtos { output.WriteRawTag(136, 2); output.WriteBool(Deprecated); } - if (uninterpretedOption_.Count > 0) { - output.WriteMessageArray(999, uninterpretedOption_); - } + uninterpretedOption_.WriteTo(output, _repeated_uninterpretedOption_codec); } public int CalculateSize() { @@ -4181,12 +4053,7 @@ namespace Google.Protobuf.DescriptorProtos { if (Deprecated != false) { size += 2 + 1; } - if (uninterpretedOption_.Count > 0) { - foreach (global::Google.Protobuf.DescriptorProtos.UninterpretedOption element in uninterpretedOption_) { - size += pb::CodedOutputStream.ComputeMessageSize(element); - } - size += 2 * uninterpretedOption_.Count; - } + size += uninterpretedOption_.CalculateSize(_repeated_uninterpretedOption_codec); return size; } @@ -4216,7 +4083,7 @@ namespace Google.Protobuf.DescriptorProtos { break; } case 7994: { - input.ReadMessageArray(uninterpretedOption_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); + uninterpretedOption_.AddEntriesFrom(input, _repeated_uninterpretedOption_codec); break; } } @@ -4268,6 +4135,8 @@ namespace Google.Protobuf.DescriptorProtos { } public const int NameFieldNumber = 2; + private static readonly pb::FieldCodec _repeated_name_codec + = pb::FieldCodec.ForMessage(18, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Types.NamePart.Parser); private readonly pbc::RepeatedField name_ = new pbc::RepeatedField(); public pbc::RepeatedField Name { get { return name_; } @@ -4367,9 +4236,7 @@ namespace Google.Protobuf.DescriptorProtos { } public void WriteTo(pb::CodedOutputStream output) { - if (name_.Count > 0) { - output.WriteMessageArray(2, name_); - } + name_.WriteTo(output, _repeated_name_codec); if (IdentifierValue.Length != 0) { output.WriteRawTag(26); output.WriteString(IdentifierValue); @@ -4398,12 +4265,7 @@ namespace Google.Protobuf.DescriptorProtos { public int CalculateSize() { int size = 0; - if (name_.Count > 0) { - foreach (global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Types.NamePart element in name_) { - size += pb::CodedOutputStream.ComputeMessageSize(element); - } - size += 1 * name_.Count; - } + size += name_.CalculateSize(_repeated_name_codec); if (IdentifierValue.Length != 0) { size += 1 + pb::CodedOutputStream.ComputeStringSize(IdentifierValue); } @@ -4462,7 +4324,7 @@ namespace Google.Protobuf.DescriptorProtos { } break; case 18: { - input.ReadMessageArray(name_, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Types.NamePart.Parser); + name_.AddEntriesFrom(input, _repeated_name_codec); break; } case 26: { @@ -4676,6 +4538,8 @@ namespace Google.Protobuf.DescriptorProtos { } public const int LocationFieldNumber = 1; + private static readonly pb::FieldCodec _repeated_location_codec + = pb::FieldCodec.ForMessage(10, global::Google.Protobuf.DescriptorProtos.SourceCodeInfo.Types.Location.Parser); private readonly pbc::RepeatedField location_ = new pbc::RepeatedField(); public pbc::RepeatedField Location { get { return location_; } @@ -4703,19 +4567,12 @@ namespace Google.Protobuf.DescriptorProtos { } public void WriteTo(pb::CodedOutputStream output) { - if (location_.Count > 0) { - output.WriteMessageArray(1, location_); - } + location_.WriteTo(output, _repeated_location_codec); } public int CalculateSize() { int size = 0; - if (location_.Count > 0) { - foreach (global::Google.Protobuf.DescriptorProtos.SourceCodeInfo.Types.Location element in location_) { - size += pb::CodedOutputStream.ComputeMessageSize(element); - } - size += 1 * location_.Count; - } + size += location_.CalculateSize(_repeated_location_codec); return size; } @@ -4738,7 +4595,7 @@ namespace Google.Protobuf.DescriptorProtos { } break; case 10: { - input.ReadMessageArray(location_, global::Google.Protobuf.DescriptorProtos.SourceCodeInfo.Types.Location.Parser); + location_.AddEntriesFrom(input, _repeated_location_codec); break; } } @@ -4791,12 +4648,16 @@ namespace Google.Protobuf.DescriptorProtos { } public const int PathFieldNumber = 1; + private static readonly pb::FieldCodec _repeated_path_codec + = pb::FieldCodec.ForInt32(10); private readonly pbc::RepeatedField path_ = new pbc::RepeatedField(); public pbc::RepeatedField Path { get { return path_; } } public const int SpanFieldNumber = 2; + private static readonly pb::FieldCodec _repeated_span_codec + = pb::FieldCodec.ForInt32(18); private readonly pbc::RepeatedField span_ = new pbc::RepeatedField(); public pbc::RepeatedField Span { get { return span_; } @@ -4823,6 +4684,8 @@ namespace Google.Protobuf.DescriptorProtos { } public const int LeadingDetachedCommentsFieldNumber = 6; + private static readonly pb::FieldCodec _repeated_leadingDetachedComments_codec + = pb::FieldCodec.ForString(50); private readonly pbc::RepeatedField leadingDetachedComments_ = new pbc::RepeatedField(); public pbc::RepeatedField LeadingDetachedComments { get { return leadingDetachedComments_; } @@ -4858,14 +4721,8 @@ namespace Google.Protobuf.DescriptorProtos { } public void WriteTo(pb::CodedOutputStream output) { - if (path_.Count > 0) { - output.WriteRawTag(10); - output.WritePackedInt32Array(path_); - } - if (span_.Count > 0) { - output.WriteRawTag(18); - output.WritePackedInt32Array(span_); - } + path_.WriteTo(output, _repeated_path_codec); + span_.WriteTo(output, _repeated_span_codec); if (LeadingComments.Length != 0) { output.WriteRawTag(26); output.WriteString(LeadingComments); @@ -4874,43 +4731,20 @@ namespace Google.Protobuf.DescriptorProtos { output.WriteRawTag(34); output.WriteString(TrailingComments); } - if (leadingDetachedComments_.Count > 0) { - output.WriteStringArray(6, leadingDetachedComments_); - } + leadingDetachedComments_.WriteTo(output, _repeated_leadingDetachedComments_codec); } public int CalculateSize() { int size = 0; - if (path_.Count > 0) { - int dataSize = 0; - foreach (int element in path_) { - dataSize += pb::CodedOutputStream.ComputeInt32Size(element); - } - size += dataSize; - size += 1 + pb::CodedOutputStream.ComputeInt32Size(dataSize); - } - if (span_.Count > 0) { - int dataSize = 0; - foreach (int element in span_) { - dataSize += pb::CodedOutputStream.ComputeInt32Size(element); - } - size += dataSize; - size += 1 + pb::CodedOutputStream.ComputeInt32Size(dataSize); - } + size += path_.CalculateSize(_repeated_path_codec); + size += span_.CalculateSize(_repeated_span_codec); if (LeadingComments.Length != 0) { size += 1 + pb::CodedOutputStream.ComputeStringSize(LeadingComments); } if (TrailingComments.Length != 0) { size += 1 + pb::CodedOutputStream.ComputeStringSize(TrailingComments); } - if (leadingDetachedComments_.Count > 0) { - int dataSize = 0; - foreach (string element in leadingDetachedComments_) { - dataSize += pb::CodedOutputStream.ComputeStringSize(element); - } - size += dataSize; - size += 1 * leadingDetachedComments_.Count; - } + size += leadingDetachedComments_.CalculateSize(_repeated_leadingDetachedComments_codec); return size; } @@ -4942,12 +4776,12 @@ namespace Google.Protobuf.DescriptorProtos { break; case 10: case 8: { - input.ReadInt32Array(path_); + path_.AddEntriesFrom(input, _repeated_path_codec); break; } case 18: case 16: { - input.ReadInt32Array(span_); + span_.AddEntriesFrom(input, _repeated_span_codec); break; } case 26: { @@ -4959,7 +4793,7 @@ namespace Google.Protobuf.DescriptorProtos { break; } case 50: { - input.ReadStringArray(leadingDetachedComments_); + leadingDetachedComments_.AddEntriesFrom(input, _repeated_leadingDetachedComments_codec); break; } } diff --git a/csharp/src/ProtocolBuffers/FieldCodec.cs b/csharp/src/ProtocolBuffers/FieldCodec.cs index 4cab9cc4..d3fc2f71 100644 --- a/csharp/src/ProtocolBuffers/FieldCodec.cs +++ b/csharp/src/ProtocolBuffers/FieldCodec.cs @@ -145,28 +145,68 @@ namespace Google.Protobuf private readonly Func reader; private readonly Action writer; - private readonly Func sizeComputer; + private readonly Func sizeCalculator; private readonly uint tag; private readonly int tagSize; + private readonly int fixedSize; internal FieldCodec( Func reader, Action writer, - Func sizeComputer, + Func sizeCalculator, uint tag) { this.reader = reader; this.writer = writer; - this.sizeComputer = sizeComputer; + this.sizeCalculator = sizeCalculator; + this.fixedSize = 0; this.tag = tag; tagSize = CodedOutputStream.ComputeRawVarint32Size(tag); } + internal FieldCodec( + Func reader, + Action writer, + int fixedSize, + uint tag) + { + this.reader = reader; + this.writer = writer; + this.sizeCalculator = _ => fixedSize; + this.fixedSize = fixedSize; + this.tag = tag; + tagSize = CodedOutputStream.ComputeRawVarint32Size(tag); + } + + /// + /// Returns the size calculator for just a value. + /// + internal Func ValueSizeCalculator { get { return sizeCalculator; } } + + /// + /// Returns a delegate to write a value (unconditionally) to a coded output stream. + /// + internal Action ValueWriter { get { return writer; } } + + /// + /// Returns a delegate to read a value from a coded input stream. It is assumed that + /// the stream is already positioned on the appropriate tag. + /// + internal Func ValueReader { get { return reader; } } + + /// + /// Returns the fixed size for an entry, or 0 if sizes vary. + /// + internal int FixedSize { get { return fixedSize; } } + public uint Tag { get { return tag; } } public T DefaultValue { get { return Default; } } - public void Write(CodedOutputStream output, T value) + /// + /// Write a tag and the given value, *if* the value is not the default. + /// + public void WriteTagAndValue(CodedOutputStream output, T value) { if (!IsDefault(value)) { @@ -180,9 +220,13 @@ namespace Google.Protobuf return reader(input); } - public int CalculateSize(T value) + /// + /// Calculates the size required to write the given value, with a tag, + /// if the value is not the default. + /// + public int CalculateSizeWithTag(T value) { - return IsDefault(value) ? 0 : sizeComputer(value) + CodedOutputStream.ComputeRawVarint32Size(tag); + return IsDefault(value) ? 0 : sizeCalculator(value) + tagSize; } } } diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc b/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc index d223273c..4445c281 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc @@ -49,7 +49,6 @@ namespace csharp { RepeatedEnumFieldGenerator::RepeatedEnumFieldGenerator( const FieldDescriptor* descriptor, int fieldOrdinal) : FieldGeneratorBase(descriptor, fieldOrdinal) { - variables_["packed"] = descriptor->is_packed() ? "Packed" : ""; } RepeatedEnumFieldGenerator::~RepeatedEnumFieldGenerator() { @@ -57,6 +56,10 @@ RepeatedEnumFieldGenerator::~RepeatedEnumFieldGenerator() { } void RepeatedEnumFieldGenerator::GenerateMembers(io::Printer* printer) { + printer->Print( + variables_, + "private static readonly pb::FieldCodec<$type_name$> _repeated_$name$_codec\n" + " = pb::FieldCodec.ForEnum($tag$, x => (int) x, x => ($type_name$) x);"); printer->Print(variables_, "private readonly pbc::RepeatedField<$type_name$> $name$_ = new pbc::RepeatedField<$type_name$>();\n"); AddDeprecatedFlag(printer); @@ -76,53 +79,19 @@ void RepeatedEnumFieldGenerator::GenerateMergingCode(io::Printer* printer) { void RepeatedEnumFieldGenerator::GenerateParsingCode(io::Printer* printer) { printer->Print( variables_, - "input.ReadEnumArray<$type_name$>($name$_);\n"); + "$name$_.AddEntriesFrom(input, _repeated_$name$_codec);\n"); } void RepeatedEnumFieldGenerator::GenerateSerializationCode(io::Printer* printer) { printer->Print( variables_, - "if ($name$_.Count > 0) {\n"); - printer->Indent(); - if (descriptor_->is_packed()) { - printer->Print( - variables_, - "output.WriteRawTag($tag_bytes$);\n" - "output.WritePackedEnumArray($name$_);\n"); - } else { - printer->Print( - variables_, - "output.Write$capitalized_type_name$Array($number$, $name$_);\n"); - } - printer->Outdent(); - printer->Print("}\n"); + "$name$_.WriteTo(output, _repeated_$name$_codec);\n"); } -void RepeatedEnumFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) { - // TODO(jonskeet): Move all this code into CodedOutputStream? It's a lot to repeat everywhere... - printer->Print( - variables_, - "if ($name$_.Count > 0) {\n"); - printer->Indent(); - printer->Print("int dataSize = 0;\n"); +void RepeatedEnumFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) { printer->Print( variables_, - "foreach ($type_name$ element in $name$_) {\n" - " dataSize += pb::CodedOutputStream.ComputeEnumSize((int) element);\n" - "}\n" - "size += dataSize;\n"); - int tagSize = internal::WireFormat::TagSize(descriptor_->number(), descriptor_->type()); - if (descriptor_->is_packed()) { - printer->Print( - "size += $tag_size$ + pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize);\n", - "tag_size", SimpleItoa(tagSize)); - } else { - printer->Print( - "size += $tag_size$ * $name$_.Count;\n", - "tag_size", SimpleItoa(tagSize), "name", name()); - } - printer->Outdent(); - printer->Print("}\n"); + "size += $name$_.CalculateSize(_repeated_$name$_codec);\n"); } void RepeatedEnumFieldGenerator::WriteHash(io::Printer* printer) { diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc b/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc index 400f0e4f..c74e5d0d 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc @@ -55,6 +55,10 @@ RepeatedMessageFieldGenerator::~RepeatedMessageFieldGenerator() { } void RepeatedMessageFieldGenerator::GenerateMembers(io::Printer* printer) { + printer->Print( + variables_, + "private static readonly pb::FieldCodec<$type_name$> _repeated_$name$_codec\n" + " = pb::FieldCodec.ForMessage($tag$, $type_name$.Parser);\n"); printer->Print( variables_, "private readonly pbc::RepeatedField<$type_name$> $name$_ = new pbc::RepeatedField<$type_name$>();\n"); @@ -75,28 +79,19 @@ void RepeatedMessageFieldGenerator::GenerateMergingCode(io::Printer* printer) { void RepeatedMessageFieldGenerator::GenerateParsingCode(io::Printer* printer) { printer->Print( variables_, - "input.ReadMessageArray($name$_, $type_name$.Parser);\n"); + "$name$_.AddEntriesFrom(input, _repeated_$name$_codec);\n"); } void RepeatedMessageFieldGenerator::GenerateSerializationCode(io::Printer* printer) { - // TODO(jonskeet): Bake the foreach loop into the generated code? We lose the - // advantage of knowing the tag bytes this way :( printer->Print( variables_, - "if ($name$_.Count > 0) {\n" - " output.WriteMessageArray($number$, $name$_);\n" - "}\n"); + "$name$_.WriteTo(output, _repeated_$name$_codec);\n"); } void RepeatedMessageFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) { printer->Print( variables_, - "if ($name$_.Count > 0) {\n" - " foreach ($type_name$ element in $name$_) {\n" - " size += pb::CodedOutputStream.ComputeMessageSize(element);\n" - " }\n" - " size += $tag_size$ * $name$_.Count;\n" - "}\n"); + "size += $name$_.CalculateSize(_repeated_$name$_codec);\n"); } void RepeatedMessageFieldGenerator::WriteHash(io::Printer* printer) { diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc b/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc index a78a74c0..a3014da8 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc @@ -49,7 +49,6 @@ namespace csharp { RepeatedPrimitiveFieldGenerator::RepeatedPrimitiveFieldGenerator( const FieldDescriptor* descriptor, int fieldOrdinal) : FieldGeneratorBase(descriptor, fieldOrdinal) { - variables_["packed"] = descriptor->is_packed() ? "Packed" : ""; } RepeatedPrimitiveFieldGenerator::~RepeatedPrimitiveFieldGenerator() { @@ -57,6 +56,10 @@ RepeatedPrimitiveFieldGenerator::~RepeatedPrimitiveFieldGenerator() { } void RepeatedPrimitiveFieldGenerator::GenerateMembers(io::Printer* printer) { + printer->Print( + variables_, + "private static readonly pb::FieldCodec<$type_name$> _repeated_$name$_codec\n" + " = pb::FieldCodec.For$capitalized_type_name$($tag$);\n"); printer->Print(variables_, "private readonly pbc::RepeatedField<$type_name$> $name$_ = new pbc::RepeatedField<$type_name$>();\n"); AddDeprecatedFlag(printer); @@ -74,63 +77,21 @@ void RepeatedPrimitiveFieldGenerator::GenerateMergingCode(io::Printer* printer) } void RepeatedPrimitiveFieldGenerator::GenerateParsingCode(io::Printer* printer) { - printer->Print(variables_, - "input.Read$capitalized_type_name$Array($name$_);\n"); + printer->Print( + variables_, + "$name$_.AddEntriesFrom(input, _repeated_$name$_codec);\n"); } -void RepeatedPrimitiveFieldGenerator::GenerateSerializationCode( - io::Printer* printer) { +void RepeatedPrimitiveFieldGenerator::GenerateSerializationCode(io::Printer* printer) { printer->Print( variables_, - "if ($name$_.Count > 0) {\n"); - printer->Indent(); - if (descriptor_->is_packed()) { - printer->Print( - variables_, - "output.WriteRawTag($tag_bytes$);\n" - "output.WritePacked$capitalized_type_name$Array($name$_);\n"); - } else { - printer->Print( - variables_, - "output.Write$capitalized_type_name$Array($number$, $name$_);\n"); - } - printer->Outdent(); - printer->Print("}\n"); + "$name$_.WriteTo(output, _repeated_$name$_codec);\n"); } -void RepeatedPrimitiveFieldGenerator::GenerateSerializedSizeCode( - io::Printer* printer) { - // TODO(jonskeet): Do this in the runtime if possible. It's a pain, but it must be feasible... +void RepeatedPrimitiveFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) { printer->Print( - "if ($name$_.Count > 0) {\n", - "name", name()); - printer->Indent(); - printer->Print("int dataSize = 0;\n"); - int fixedSize = GetFixedSize(descriptor_->type()); - if (fixedSize == -1) { - printer->Print( - variables_, - "foreach ($type_name$ element in $name$_) {\n" - " dataSize += pb::CodedOutputStream.Compute$capitalized_type_name$Size(element);\n" - "}\n"); - } else { - printer->Print( - "dataSize = $size$ * $name$_.Count;\n", - "size", SimpleItoa(fixedSize), "name", name()); - } - printer->Print("size += dataSize;\n"); - int tagSize = internal::WireFormat::TagSize(descriptor_->number(), descriptor_->type()); - if (descriptor_->is_packed()) { - printer->Print( - "size += $tag_size$ + pb::CodedOutputStream.ComputeInt32Size(dataSize);\n", - "tag_size", SimpleItoa(tagSize)); - } else { - printer->Print( - "size += $tag_size$ * $name$_.Count;\n", - "tag_size", SimpleItoa(tagSize), "name", name()); - } - printer->Outdent(); - printer->Print("}\n"); + variables_, + "size += $name$_.CalculateSize(_repeated_$name$_codec);\n"); } void RepeatedPrimitiveFieldGenerator::WriteHash(io::Printer* printer) { -- cgit v1.2.3 From b9d1d3891f4e68886398bbf0caf40229275a448a Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Mon, 29 Jun 2015 10:30:09 +0100 Subject: Tests changed enough to build --- .../ProtocolBuffers.Test/CodedInputStreamTest.cs | 39 ++++++++++++++++------ .../ProtocolBuffers.Test/CodedOutputStreamTest.cs | 2 ++ csharp/src/ProtocolBuffers.Test/FieldCodecTest.cs | 10 +++--- 3 files changed, 36 insertions(+), 15 deletions(-) diff --git a/csharp/src/ProtocolBuffers.Test/CodedInputStreamTest.cs b/csharp/src/ProtocolBuffers.Test/CodedInputStreamTest.cs index 52757d4d..47b5e0ac 100644 --- a/csharp/src/ProtocolBuffers.Test/CodedInputStreamTest.cs +++ b/csharp/src/ProtocolBuffers.Test/CodedInputStreamTest.cs @@ -479,22 +479,34 @@ namespace Google.Protobuf int msgSize = 1 + 1 + arraySize; byte[] bytes = new byte[msgSize]; CodedOutputStream output = CodedOutputStream.CreateInstance(bytes); - output.WriteTag(8, WireFormat.WireType.LengthDelimited); - output.WritePackedInt32Array(new RepeatedField { 0, -1, -2, -3, -4, -5 }); - + // Length-delimited to show we want the packed representation + uint tag = WireFormat.MakeTag(8, WireFormat.WireType.LengthDelimited); + output.WriteTag(tag); + int size = 0; + for (int i = 0; i >= -5; i--) + { + size += CodedOutputStream.ComputeEnumSize(i); + } + output.WriteRawVarint32((uint) size); + for (int i = 0; i >= -5; i--) + { + output.WriteEnum(i); + } Assert.AreEqual(0, output.SpaceLeft); CodedInputStream input = CodedInputStream.CreateInstance(bytes); - uint tag; Assert.IsTrue(input.ReadTag(out tag)); RepeatedField values = new RepeatedField(); - input.ReadEnumArray(values); + values.AddEntriesFrom(input, FieldCodec.ForEnum(tag, x => (int) x, x => (TestNegEnum) x)); Assert.AreEqual(6, values.Count); Assert.AreEqual(TestNegEnum.None, values[0]); + Assert.AreEqual(((TestNegEnum) (-1)), values[1]); Assert.AreEqual(TestNegEnum.Value, values[2]); - // TODO(jonskeet): Test unknown value preservation + Assert.AreEqual(((TestNegEnum)(-3)), values[3]); + Assert.AreEqual(((TestNegEnum)(-4)), values[4]); + Assert.AreEqual(((TestNegEnum)(-5)), values[5]); } [Test] @@ -504,21 +516,28 @@ namespace Google.Protobuf int msgSize = arraySize; byte[] bytes = new byte[msgSize]; CodedOutputStream output = CodedOutputStream.CreateInstance(bytes); - output.WriteInt32Array(8, new RepeatedField { 0, -1, -2, -3, -4, -5 }); + uint tag = WireFormat.MakeTag(8, WireFormat.WireType.Varint); + for (int i = 0; i >= -5; i--) + { + output.WriteTag(tag); + output.WriteEnum(i); + } Assert.AreEqual(0, output.SpaceLeft); CodedInputStream input = CodedInputStream.CreateInstance(bytes); - uint tag; Assert.IsTrue(input.ReadTag(out tag)); RepeatedField values = new RepeatedField(); - input.ReadEnumArray(values); + values.AddEntriesFrom(input, FieldCodec.ForEnum(tag, x => (int)x, x => (TestNegEnum)x)); Assert.AreEqual(6, values.Count); Assert.AreEqual(TestNegEnum.None, values[0]); + Assert.AreEqual(((TestNegEnum)(-1)), values[1]); Assert.AreEqual(TestNegEnum.Value, values[2]); - // TODO(jonskeet): Test unknown value preservation + Assert.AreEqual(((TestNegEnum)(-3)), values[3]); + Assert.AreEqual(((TestNegEnum)(-4)), values[4]); + Assert.AreEqual(((TestNegEnum)(-5)), values[5]); } //Issue 71: CodedInputStream.ReadBytes go to slow path unnecessarily diff --git a/csharp/src/ProtocolBuffers.Test/CodedOutputStreamTest.cs b/csharp/src/ProtocolBuffers.Test/CodedOutputStreamTest.cs index 223374e0..dd49e3d8 100644 --- a/csharp/src/ProtocolBuffers.Test/CodedOutputStreamTest.cs +++ b/csharp/src/ProtocolBuffers.Test/CodedOutputStreamTest.cs @@ -308,6 +308,7 @@ namespace Google.Protobuf enum TestNegEnum { None = 0, Value = -2 } + /* [Test] public void TestNegativeEnumArrayPacked() { @@ -355,6 +356,7 @@ namespace Google.Protobuf for (int i = 0; i > -6; i--) Assert.AreEqual(i, values[Math.Abs(i)]); } + */ [Test] public void TestCodedInputOutputPosition() diff --git a/csharp/src/ProtocolBuffers.Test/FieldCodecTest.cs b/csharp/src/ProtocolBuffers.Test/FieldCodecTest.cs index e2b8e3ef..50141621 100644 --- a/csharp/src/ProtocolBuffers.Test/FieldCodecTest.cs +++ b/csharp/src/ProtocolBuffers.Test/FieldCodecTest.cs @@ -104,7 +104,7 @@ namespace Google.Protobuf { var stream = new MemoryStream(); var codedOutput = CodedOutputStream.CreateInstance(stream); - codec.Write(codedOutput, sampleValue); + codec.WriteTagAndValue(codedOutput, sampleValue); codedOutput.Flush(); stream.Position = 0; var codedInput = CodedInputStream.CreateInstance(stream); @@ -119,19 +119,19 @@ namespace Google.Protobuf { var stream = new MemoryStream(); var codedOutput = CodedOutputStream.CreateInstance(stream); - codec.Write(codedOutput, sampleValue); + codec.WriteTagAndValue(codedOutput, sampleValue); codedOutput.Flush(); - Assert.AreEqual(stream.Position, codec.CalculateSize(sampleValue)); + Assert.AreEqual(stream.Position, codec.CalculateSizeWithTag(sampleValue)); } public void TestDefaultValue() { var stream = new MemoryStream(); var codedOutput = CodedOutputStream.CreateInstance(stream); - codec.Write(codedOutput, codec.DefaultValue); + codec.WriteTagAndValue(codedOutput, codec.DefaultValue); codedOutput.Flush(); Assert.AreEqual(0, stream.Position); - Assert.AreEqual(0, codec.CalculateSize(codec.DefaultValue)); + Assert.AreEqual(0, codec.CalculateSizeWithTag(codec.DefaultValue)); if (typeof(T).IsValueType) { Assert.AreEqual(default(T), codec.DefaultValue); -- cgit v1.2.3 From f34d37a3d4d64621bc87aa0a65a05cab64062399 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Tue, 30 Jun 2015 13:16:20 +0100 Subject: Tidying up and extra tests. This is mostly just making things internal instead of public, removing and reordering a bunch of code in CodedInputStream/CodedOutputStream, and generally tidying up. --- .../CodedInputStreamExtensions.cs | 54 ++++ .../ProtocolBuffers.Test/CodedInputStreamTest.cs | 153 ++--------- .../ProtocolBuffers.Test/CodedOutputStreamTest.cs | 93 +------ .../Collections/RepeatedFieldTest.cs | 291 +++++++++++++++++++- csharp/src/ProtocolBuffers.Test/FieldCodecTest.cs | 53 +++- .../ProtocolBuffers.Test/GeneratedMessageTest.cs | 133 +++++++++ .../ProtocolBuffers.Test.csproj | 2 + csharp/src/ProtocolBuffers.Test/SampleEnum.cs | 42 +++ csharp/src/ProtocolBuffers/CodedInputStream.cs | 302 ++++++++++----------- .../CodedOutputStream.ComputeSize.cs | 51 ++-- csharp/src/ProtocolBuffers/CodedOutputStream.cs | 97 ++++++- .../Collections/ReadOnlyDictionary.cs | 2 +- .../ProtocolBuffers/Collections/RepeatedField.cs | 7 +- csharp/src/ProtocolBuffers/FieldCodec.cs | 3 +- csharp/src/ProtocolBuffers/MessageExtensions.cs | 2 +- .../src/ProtocolBuffers/Properties/AssemblyInfo.cs | 7 + csharp/src/ProtocolBuffers/WireFormat.cs | 36 +-- 17 files changed, 871 insertions(+), 457 deletions(-) create mode 100644 csharp/src/ProtocolBuffers.Test/CodedInputStreamExtensions.cs create mode 100644 csharp/src/ProtocolBuffers.Test/SampleEnum.cs diff --git a/csharp/src/ProtocolBuffers.Test/CodedInputStreamExtensions.cs b/csharp/src/ProtocolBuffers.Test/CodedInputStreamExtensions.cs new file mode 100644 index 00000000..408c7cb9 --- /dev/null +++ b/csharp/src/ProtocolBuffers.Test/CodedInputStreamExtensions.cs @@ -0,0 +1,54 @@ +#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; + +namespace Google.Protobuf +{ + internal static class CodedInputStreamExtensions + { + public static void AssertNextTag(this CodedInputStream input, uint expectedTag) + { + uint tag; + Assert.IsTrue(input.ReadTag(out tag)); + Assert.AreEqual(expectedTag, tag); + } + + public static T ReadMessage(this CodedInputStream stream, MessageParser parser) + where T : IMessage + { + var message = parser.CreateTemplate(); + stream.ReadMessage(message); + return message; + } + } +} diff --git a/csharp/src/ProtocolBuffers.Test/CodedInputStreamTest.cs b/csharp/src/ProtocolBuffers.Test/CodedInputStreamTest.cs index 47b5e0ac..a64994fd 100644 --- a/csharp/src/ProtocolBuffers.Test/CodedInputStreamTest.cs +++ b/csharp/src/ProtocolBuffers.Test/CodedInputStreamTest.cs @@ -35,10 +35,8 @@ #endregion using System; -using System.Collections.Generic; using System.IO; using Google.Protobuf.Collections; -using Google.Protobuf.Descriptors; using Google.Protobuf.TestProtos; using NUnit.Framework; @@ -62,7 +60,7 @@ namespace Google.Protobuf } /// - /// Parses the given bytes using ReadRawVarint32() and ReadRawVarint64() and + /// Parses the given bytes using ReadRawVarint32() and ReadRawVarint64() /// private static void AssertReadVarint(byte[] data, ulong value) { @@ -232,66 +230,26 @@ namespace Google.Protobuf Assert.AreEqual(0x7FFFFFFFFFFFFFFFL, CodedInputStream.DecodeZigZag64(0xFFFFFFFFFFFFFFFEL)); Assert.AreEqual(unchecked((long) 0x8000000000000000L), CodedInputStream.DecodeZigZag64(0xFFFFFFFFFFFFFFFFL)); } - /* + [Test] - public void ReadWholeMessage() + public void ReadWholeMessage_VaryingBlockSizes() { - TestAllTypes message = TestUtil.GetAllSet(); + TestAllTypes message = GeneratedMessageTest.GetSampleMessage(); byte[] rawBytes = message.ToByteArray(); - Assert.AreEqual(rawBytes.Length, message.SerializedSize); - TestAllTypes message2 = TestAllTypes.ParseFrom(rawBytes); - TestUtil.AssertAllFieldsSet(message2); + Assert.AreEqual(rawBytes.Length, message.CalculateSize()); + TestAllTypes message2 = TestAllTypes.Parser.ParseFrom(rawBytes); + Assert.AreEqual(message, message2); // Try different block sizes. for (int blockSize = 1; blockSize < 256; blockSize *= 2) { - message2 = TestAllTypes.ParseFrom(new SmallBlockInputStream(rawBytes, blockSize)); - TestUtil.AssertAllFieldsSet(message2); + message2 = TestAllTypes.Parser.ParseFrom(new SmallBlockInputStream(rawBytes, blockSize)); + Assert.AreEqual(message, message2); } } - + [Test] - public void SkipWholeMessage() - { - TestAllTypes message = TestUtil.GetAllSet(); - byte[] rawBytes = message.ToByteArray(); - - // Create two parallel inputs. Parse one as unknown fields while using - // skipField() to skip each field on the other. Expect the same tags. - CodedInputStream input1 = CodedInputStream.CreateInstance(rawBytes); - CodedInputStream input2 = CodedInputStream.CreateInstance(rawBytes); - UnknownFieldSet.Builder unknownFields = UnknownFieldSet.CreateBuilder(); - - uint tag; - string name; - while (input1.ReadTag(out tag, out name)) - { - uint tag2; - Assert.IsTrue(input2.ReadTag(out tag2, out name)); - Assert.AreEqual(tag, tag2); - - unknownFields.MergeFieldFrom(tag, input1); - input2.SkipField(); - } - }*/ - - /// - /// Test that a bug in SkipRawBytes has been fixed: if the skip - /// skips exactly up to a limit, this should bnot break things - /// - [Test] - public void SkipRawBytesBug() - { - byte[] rawBytes = new byte[] {1, 2}; - CodedInputStream input = CodedInputStream.CreateInstance(rawBytes); - - int limit = input.PushLimit(1); - input.SkipRawBytes(1); - input.PopLimit(limit); - Assert.AreEqual(2, input.ReadRawByte()); - } - /* public void ReadHugeBlob() { // Allocate and initialize a 1MB blob. @@ -302,24 +260,15 @@ namespace Google.Protobuf } // Make a message containing it. - TestAllTypes.Builder builder = TestAllTypes.CreateBuilder(); - TestUtil.SetAllFields(builder); - builder.SetOptionalBytes(ByteString.CopyFrom(blob)); - TestAllTypes message = builder.Build(); + 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.ParseFrom(message.ToByteString().CreateCodedInput()); + TestAllTypes message2 = TestAllTypes.Parser.ParseFrom(message.ToByteString()); - Assert.AreEqual(message.OptionalBytes, message2.OptionalBytes); - - // Make sure all the other fields were parsed correctly. - TestAllTypes message3 = TestAllTypes.CreateBuilder(message2) - .SetOptionalBytes(TestUtil.GetAllSet().OptionalBytes) - .Build(); - TestUtil.AssertAllFieldsSet(message3); - }*/ + Assert.AreEqual(message, message2); + } [Test] public void ReadMaliciouslyLargeBlob() @@ -461,85 +410,15 @@ namespace Google.Protobuf } } - enum TestNegEnum { None = 0, Value = -2 } - [Test] public void TestNegativeEnum() { - byte[] bytes = new byte[10] { 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01 }; + byte[] bytes = { 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01 }; CodedInputStream input = CodedInputStream.CreateInstance(bytes); - Assert.AreEqual((int)TestNegEnum.Value, input.ReadEnum()); + Assert.AreEqual((int)SampleEnum.NegativeValue, input.ReadEnum()); Assert.IsTrue(input.IsAtEnd); } - [Test] - public void TestNegativeEnumPackedArray() - { - int arraySize = 1 + (10 * 5); - int msgSize = 1 + 1 + arraySize; - byte[] bytes = new byte[msgSize]; - CodedOutputStream output = CodedOutputStream.CreateInstance(bytes); - // Length-delimited to show we want the packed representation - uint tag = WireFormat.MakeTag(8, WireFormat.WireType.LengthDelimited); - output.WriteTag(tag); - int size = 0; - for (int i = 0; i >= -5; i--) - { - size += CodedOutputStream.ComputeEnumSize(i); - } - output.WriteRawVarint32((uint) size); - for (int i = 0; i >= -5; i--) - { - output.WriteEnum(i); - } - Assert.AreEqual(0, output.SpaceLeft); - - CodedInputStream input = CodedInputStream.CreateInstance(bytes); - Assert.IsTrue(input.ReadTag(out tag)); - - RepeatedField values = new RepeatedField(); - values.AddEntriesFrom(input, FieldCodec.ForEnum(tag, x => (int) x, x => (TestNegEnum) x)); - - Assert.AreEqual(6, values.Count); - Assert.AreEqual(TestNegEnum.None, values[0]); - Assert.AreEqual(((TestNegEnum) (-1)), values[1]); - Assert.AreEqual(TestNegEnum.Value, values[2]); - Assert.AreEqual(((TestNegEnum)(-3)), values[3]); - Assert.AreEqual(((TestNegEnum)(-4)), values[4]); - Assert.AreEqual(((TestNegEnum)(-5)), values[5]); - } - - [Test] - public void TestNegativeEnumArray() - { - int arraySize = 1 + 1 + (11 * 5); - int msgSize = arraySize; - byte[] bytes = new byte[msgSize]; - CodedOutputStream output = CodedOutputStream.CreateInstance(bytes); - uint tag = WireFormat.MakeTag(8, WireFormat.WireType.Varint); - for (int i = 0; i >= -5; i--) - { - output.WriteTag(tag); - output.WriteEnum(i); - } - - Assert.AreEqual(0, output.SpaceLeft); - - CodedInputStream input = CodedInputStream.CreateInstance(bytes); - Assert.IsTrue(input.ReadTag(out tag)); - - RepeatedField values = new RepeatedField(); - values.AddEntriesFrom(input, FieldCodec.ForEnum(tag, x => (int)x, x => (TestNegEnum)x)); - - Assert.AreEqual(6, values.Count); - Assert.AreEqual(TestNegEnum.None, values[0]); - Assert.AreEqual(((TestNegEnum)(-1)), values[1]); - Assert.AreEqual(TestNegEnum.Value, values[2]); - Assert.AreEqual(((TestNegEnum)(-3)), values[3]); - Assert.AreEqual(((TestNegEnum)(-4)), values[4]); - Assert.AreEqual(((TestNegEnum)(-5)), values[5]); - } - //Issue 71: CodedInputStream.ReadBytes go to slow path unnecessarily [Test] public void TestSlowPathAvoidance() diff --git a/csharp/src/ProtocolBuffers.Test/CodedOutputStreamTest.cs b/csharp/src/ProtocolBuffers.Test/CodedOutputStreamTest.cs index dd49e3d8..ab5dcbd6 100644 --- a/csharp/src/ProtocolBuffers.Test/CodedOutputStreamTest.cs +++ b/csharp/src/ProtocolBuffers.Test/CodedOutputStreamTest.cs @@ -35,9 +35,8 @@ #endregion using System; -using System.Collections.Generic; using System.IO; -using Google.Protobuf.Collections; +using Google.Protobuf.TestProtos; using NUnit.Framework; namespace Google.Protobuf @@ -195,42 +194,24 @@ namespace Google.Protobuf 0x9abcdef012345678UL); } - /* [Test] - public void WriteWholeMessage() + public void WriteWholeMessage_VaryingBlockSizes() { - TestAllTypes message = TestUtil.GetAllSet(); + TestAllTypes message = GeneratedMessageTest.GetSampleMessage(); byte[] rawBytes = message.ToByteArray(); - TestUtil.AssertEqualBytes(TestUtil.GoldenMessage.ToByteArray(), rawBytes); // Try different block sizes. for (int blockSize = 1; blockSize < 256; blockSize *= 2) { MemoryStream rawOutput = new MemoryStream(); - CodedOutputStream output = - CodedOutputStream.CreateInstance(rawOutput, blockSize); + CodedOutputStream output = CodedOutputStream.CreateInstance(rawOutput, blockSize); message.WriteTo(output); output.Flush(); - TestUtil.AssertEqualBytes(rawBytes, rawOutput.ToArray()); + Assert.AreEqual(rawBytes, rawOutput.ToArray()); } } - - /// - /// Tests writing a whole message with every packed field type. Ensures the - /// wire format of packed fields is compatible with C++. - /// - [Test] - public void WriteWholePackedFieldsMessage() - { - TestPackedTypes message = TestUtil.GetPackedSet(); - - byte[] rawBytes = message.ToByteArray(); - TestUtil.AssertEqualBytes(TestUtil.GetGoldenPackedFieldsMessage().ToByteArray(), - rawBytes); - } - */ - + [Test] public void EncodeZigZag32() { @@ -296,68 +277,16 @@ namespace Google.Protobuf public void TestNegativeEnumNoTag() { Assert.AreEqual(10, CodedOutputStream.ComputeInt32Size(-2)); - Assert.AreEqual(10, CodedOutputStream.ComputeEnumSize((int) TestNegEnum.Value)); + Assert.AreEqual(10, CodedOutputStream.ComputeEnumSize((int) SampleEnum.NegativeValue)); byte[] bytes = new byte[10]; CodedOutputStream output = CodedOutputStream.CreateInstance(bytes); - output.WriteEnum((int) TestNegEnum.Value); + 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)); } - enum TestNegEnum { None = 0, Value = -2 } - - /* - [Test] - public void TestNegativeEnumArrayPacked() - { - int arraySize = 1 + (10 * 5); - int msgSize = 1 + 1 + arraySize; - byte[] bytes = new byte[msgSize]; - CodedOutputStream output = CodedOutputStream.CreateInstance(bytes); - output.WriteTag(8, WireFormat.WireType.LengthDelimited); - output.WritePackedEnumArray(new RepeatedField { - 0, (TestNegEnum) (-1), TestNegEnum.Value, (TestNegEnum) (-3), (TestNegEnum) (-4), (TestNegEnum) (-5) }); - - Assert.AreEqual(0, output.SpaceLeft); - - CodedInputStream input = CodedInputStream.CreateInstance(bytes); - uint tag; - Assert.IsTrue(input.ReadTag(out tag)); - - List values = new List(); - input.ReadInt32Array(values); - - Assert.AreEqual(6, values.Count); - for (int i = 0; i > -6; i--) - Assert.AreEqual(i, values[Math.Abs(i)]); - } - - [Test] - public void TestNegativeEnumArray() - { - int arraySize = 1 + 1 + (11 * 5); - int msgSize = arraySize; - byte[] bytes = new byte[msgSize]; - CodedOutputStream output = CodedOutputStream.CreateInstance(bytes); - output.WriteEnumArray(8, new RepeatedField { - 0, (TestNegEnum) (-1), TestNegEnum.Value, (TestNegEnum) (-3), (TestNegEnum) (-4), (TestNegEnum) (-5) }); - Assert.AreEqual(0, output.SpaceLeft); - - CodedInputStream input = CodedInputStream.CreateInstance(bytes); - uint tag; - Assert.IsTrue(input.ReadTag(out tag)); - - List values = new List(); - input.ReadInt32Array(values); - - Assert.AreEqual(6, values.Count); - for (int i = 0; i > -6; i--) - Assert.AreEqual(i, values[Math.Abs(i)]); - } - */ - [Test] public void TestCodedInputOutputPosition() { @@ -407,7 +336,7 @@ namespace Google.Protobuf Assert.AreEqual(130, cout.Position); cout.Flush(); } - //Now test Input stream: + // Now test Input stream: { CodedInputStream cin = CodedInputStream.CreateInstance(new MemoryStream(bytes), new byte[50]); uint tag; @@ -420,8 +349,8 @@ namespace Google.Protobuf //Field 2: Assert.IsTrue(cin.ReadTag(out tag) && tag >> 3 == 2); Assert.AreEqual(4, cin.Position); - uint childlen = cin.ReadRawVarint32(); - Assert.AreEqual(120u, childlen); + int childlen = cin.ReadLength(); + Assert.AreEqual(120, childlen); Assert.AreEqual(5, cin.Position); int oldlimit = cin.PushLimit((int)childlen); Assert.AreEqual(5, cin.Position); diff --git a/csharp/src/ProtocolBuffers.Test/Collections/RepeatedFieldTest.cs b/csharp/src/ProtocolBuffers.Test/Collections/RepeatedFieldTest.cs index 29945c36..988801b7 100644 --- a/csharp/src/ProtocolBuffers.Test/Collections/RepeatedFieldTest.cs +++ b/csharp/src/ProtocolBuffers.Test/Collections/RepeatedFieldTest.cs @@ -1,5 +1,39 @@ -using System; +#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 System; using System.Collections.Generic; +using System.IO; +using System.Linq; using Google.Protobuf.TestProtos; using NUnit.Framework; @@ -89,5 +123,260 @@ namespace Google.Protobuf.Collections var clone = list.Clone(); clone[0] = 1; } + + [Test] + public void AddEntriesFrom_PackedInt32() + { + uint packedTag = WireFormat.MakeTag(10, WireFormat.WireType.LengthDelimited); + var stream = new MemoryStream(); + var output = CodedOutputStream.CreateInstance(stream); + var length = CodedOutputStream.ComputeInt32Size(10) + + CodedOutputStream.ComputeInt32Size(999) + + CodedOutputStream.ComputeInt32Size(-1000); + output.WriteTag(packedTag); + output.WriteRawVarint32((uint) length); + output.WriteInt32(10); + output.WriteInt32(999); + output.WriteInt32(-1000); + output.Flush(); + stream.Position = 0; + + // Deliberately "expecting" a non-packed tag, but we detect that the data is + // actually packed. + uint nonPackedTag = WireFormat.MakeTag(10, WireFormat.WireType.LengthDelimited); + var field = new RepeatedField(); + var input = CodedInputStream.CreateInstance(stream); + input.AssertNextTag(packedTag); + field.AddEntriesFrom(input, FieldCodec.ForInt32(nonPackedTag)); + CollectionAssert.AreEqual(new[] { 10, 999, -1000 }, field); + Assert.IsTrue(input.IsAtEnd); + } + + [Test] + public void AddEntriesFrom_NonPackedInt32() + { + uint nonPackedTag = WireFormat.MakeTag(10, WireFormat.WireType.Varint); + var stream = new MemoryStream(); + var output = CodedOutputStream.CreateInstance(stream); + output.WriteTag(nonPackedTag); + output.WriteInt32(10); + output.WriteTag(nonPackedTag); + output.WriteInt32(999); + output.WriteTag(nonPackedTag); + output.WriteInt32(-1000); // Just for variety... + output.Flush(); + stream.Position = 0; + + // Deliberately "expecting" a packed tag, but we detect that the data is + // actually not packed. + uint packedTag = WireFormat.MakeTag(10, WireFormat.WireType.LengthDelimited); + var field = new RepeatedField(); + var input = CodedInputStream.CreateInstance(stream); + input.AssertNextTag(nonPackedTag); + field.AddEntriesFrom(input, FieldCodec.ForInt32(packedTag)); + CollectionAssert.AreEqual(new[] { 10, 999, -1000 }, field); + Assert.IsTrue(input.IsAtEnd); + } + + [Test] + public void AddEntriesFrom_String() + { + uint tag = WireFormat.MakeTag(10, WireFormat.WireType.LengthDelimited); + var stream = new MemoryStream(); + var output = CodedOutputStream.CreateInstance(stream); + output.WriteTag(tag); + output.WriteString("Foo"); + output.WriteTag(tag); + output.WriteString(""); + output.WriteTag(tag); + output.WriteString("Bar"); + output.Flush(); + stream.Position = 0; + + var field = new RepeatedField(); + var input = CodedInputStream.CreateInstance(stream); + input.AssertNextTag(tag); + field.AddEntriesFrom(input, FieldCodec.ForString(tag)); + CollectionAssert.AreEqual(new[] { "Foo", "", "Bar" }, field); + Assert.IsTrue(input.IsAtEnd); + } + + [Test] + public void AddEntriesFrom_Message() + { + var message1 = new ForeignMessage { C = 2000 }; + var message2 = new ForeignMessage { C = -250 }; + + uint tag = WireFormat.MakeTag(10, WireFormat.WireType.LengthDelimited); + var stream = new MemoryStream(); + var output = CodedOutputStream.CreateInstance(stream); + output.WriteTag(tag); + output.WriteMessage(message1); + output.WriteTag(tag); + output.WriteMessage(message2); + output.Flush(); + stream.Position = 0; + + var field = new RepeatedField(); + var input = CodedInputStream.CreateInstance(stream); + input.AssertNextTag(tag); + field.AddEntriesFrom(input, FieldCodec.ForMessage(tag, ForeignMessage.Parser)); + CollectionAssert.AreEqual(new[] { message1, message2}, field); + Assert.IsTrue(input.IsAtEnd); + } + + [Test] + public void WriteTo_PackedInt32() + { + uint tag = WireFormat.MakeTag(10, WireFormat.WireType.LengthDelimited); + var field = new RepeatedField { 10, 1000, 1000000 }; + var stream = new MemoryStream(); + var output = CodedOutputStream.CreateInstance(stream); + field.WriteTo(output, FieldCodec.ForInt32(tag)); + output.Flush(); + stream.Position = 0; + + var input = CodedInputStream.CreateInstance(stream); + input.AssertNextTag(tag); + var length = input.ReadLength(); + Assert.AreEqual(10, input.ReadInt32()); + Assert.AreEqual(1000, input.ReadInt32()); + Assert.AreEqual(1000000, input.ReadInt32()); + Assert.IsTrue(input.IsAtEnd); + Assert.AreEqual(1 + CodedOutputStream.ComputeLengthSize(length) + length, stream.Length); + } + + [Test] + public void WriteTo_NonPackedInt32() + { + uint tag = WireFormat.MakeTag(10, WireFormat.WireType.Varint); + var field = new RepeatedField { 10, 1000, 1000000}; + var stream = new MemoryStream(); + var output = CodedOutputStream.CreateInstance(stream); + field.WriteTo(output, FieldCodec.ForInt32(tag)); + output.Flush(); + stream.Position = 0; + + var input = CodedInputStream.CreateInstance(stream); + input.AssertNextTag(tag); + Assert.AreEqual(10, input.ReadInt32()); + input.AssertNextTag(tag); + Assert.AreEqual(1000, input.ReadInt32()); + input.AssertNextTag(tag); + Assert.AreEqual(1000000, input.ReadInt32()); + Assert.IsTrue(input.IsAtEnd); + } + + [Test] + public void WriteTo_String() + { + uint tag = WireFormat.MakeTag(10, WireFormat.WireType.LengthDelimited); + var field = new RepeatedField { "Foo", "", "Bar" }; + var stream = new MemoryStream(); + var output = CodedOutputStream.CreateInstance(stream); + field.WriteTo(output, FieldCodec.ForString(tag)); + output.Flush(); + stream.Position = 0; + + var input = CodedInputStream.CreateInstance(stream); + input.AssertNextTag(tag); + Assert.AreEqual("Foo", input.ReadString()); + input.AssertNextTag(tag); + Assert.AreEqual("", input.ReadString()); + input.AssertNextTag(tag); + Assert.AreEqual("Bar", input.ReadString()); + Assert.IsTrue(input.IsAtEnd); + } + + [Test] + public void WriteTo_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 stream = new MemoryStream(); + var output = CodedOutputStream.CreateInstance(stream); + field.WriteTo(output, FieldCodec.ForMessage(tag, ForeignMessage.Parser)); + output.Flush(); + stream.Position = 0; + + var input = CodedInputStream.CreateInstance(stream); + input.AssertNextTag(tag); + Assert.AreEqual(message1, input.ReadMessage(ForeignMessage.Parser)); + input.AssertNextTag(tag); + Assert.AreEqual(message2, input.ReadMessage(ForeignMessage.Parser)); + Assert.IsTrue(input.IsAtEnd); + } + + + [Test] + public void TestNegativeEnumArray() + { + int arraySize = 1 + 1 + (11 * 5); + int msgSize = arraySize; + byte[] bytes = new byte[msgSize]; + CodedOutputStream output = CodedOutputStream.CreateInstance(bytes); + uint tag = WireFormat.MakeTag(8, WireFormat.WireType.Varint); + for (int i = 0; i >= -5; i--) + { + output.WriteTag(tag); + output.WriteEnum(i); + } + + Assert.AreEqual(0, output.SpaceLeft); + + CodedInputStream input = CodedInputStream.CreateInstance(bytes); + Assert.IsTrue(input.ReadTag(out tag)); + + RepeatedField values = new RepeatedField(); + values.AddEntriesFrom(input, FieldCodec.ForEnum(tag, x => (int)x, x => (SampleEnum)x)); + + Assert.AreEqual(6, values.Count); + Assert.AreEqual(SampleEnum.None, values[0]); + Assert.AreEqual(((SampleEnum)(-1)), values[1]); + Assert.AreEqual(SampleEnum.NegativeValue, values[2]); + Assert.AreEqual(((SampleEnum)(-3)), values[3]); + Assert.AreEqual(((SampleEnum)(-4)), values[4]); + Assert.AreEqual(((SampleEnum)(-5)), values[5]); + } + + + [Test] + public void TestNegativeEnumPackedArray() + { + int arraySize = 1 + (10 * 5); + int msgSize = 1 + 1 + arraySize; + byte[] bytes = new byte[msgSize]; + CodedOutputStream output = CodedOutputStream.CreateInstance(bytes); + // Length-delimited to show we want the packed representation + uint tag = WireFormat.MakeTag(8, WireFormat.WireType.LengthDelimited); + output.WriteTag(tag); + int size = 0; + for (int i = 0; i >= -5; i--) + { + size += CodedOutputStream.ComputeEnumSize(i); + } + output.WriteRawVarint32((uint)size); + for (int i = 0; i >= -5; i--) + { + output.WriteEnum(i); + } + Assert.AreEqual(0, output.SpaceLeft); + + CodedInputStream input = CodedInputStream.CreateInstance(bytes); + Assert.IsTrue(input.ReadTag(out tag)); + + RepeatedField values = new RepeatedField(); + values.AddEntriesFrom(input, FieldCodec.ForEnum(tag, x => (int)x, x => (SampleEnum)x)); + + Assert.AreEqual(6, values.Count); + Assert.AreEqual(SampleEnum.None, values[0]); + Assert.AreEqual(((SampleEnum)(-1)), values[1]); + Assert.AreEqual(SampleEnum.NegativeValue, values[2]); + Assert.AreEqual(((SampleEnum)(-3)), values[3]); + Assert.AreEqual(((SampleEnum)(-4)), values[4]); + Assert.AreEqual(((SampleEnum)(-5)), values[5]); + } } } diff --git a/csharp/src/ProtocolBuffers.Test/FieldCodecTest.cs b/csharp/src/ProtocolBuffers.Test/FieldCodecTest.cs index 50141621..a14040d1 100644 --- a/csharp/src/ProtocolBuffers.Test/FieldCodecTest.cs +++ b/csharp/src/ProtocolBuffers.Test/FieldCodecTest.cs @@ -63,15 +63,21 @@ namespace Google.Protobuf }; [Test, TestCaseSource("Codecs")] - public void RoundTrip(ICodecTestData codec) + public void RoundTripWithTag(ICodecTestData codec) { - codec.TestRoundTrip(); + codec.TestRoundTripWithTag(); + } + + [Test, TestCaseSource("Codecs")] + public void RoundTripRaw(ICodecTestData codec) + { + codec.TestRoundTripRaw(); } [Test, TestCaseSource("Codecs")] public void CalculateSize(ICodecTestData codec) { - codec.TestCalculateSize(); + codec.TestCalculateSizeWithTag(); } [Test, TestCaseSource("Codecs")] @@ -82,8 +88,9 @@ namespace Google.Protobuf public interface ICodecTestData { - void TestRoundTrip(); - void TestCalculateSize(); + void TestRoundTripRaw(); + void TestRoundTripWithTag(); + void TestCalculateSizeWithTag(); void TestDefaultValue(); } @@ -100,7 +107,19 @@ namespace Google.Protobuf this.name = name; } - public void TestRoundTrip() + public void TestRoundTripRaw() + { + var stream = new MemoryStream(); + var codedOutput = CodedOutputStream.CreateInstance(stream); + codec.ValueWriter(codedOutput, sampleValue); + codedOutput.Flush(); + stream.Position = 0; + var codedInput = CodedInputStream.CreateInstance(stream); + Assert.AreEqual(sampleValue, codec.ValueReader(codedInput)); + Assert.IsTrue(codedInput.IsAtEnd); + } + + public void TestRoundTripWithTag() { var stream = new MemoryStream(); var codedOutput = CodedOutputStream.CreateInstance(stream); @@ -108,14 +127,12 @@ namespace Google.Protobuf codedOutput.Flush(); stream.Position = 0; var codedInput = CodedInputStream.CreateInstance(stream); - uint tag; - Assert.IsTrue(codedInput.ReadTag(out tag)); - Assert.AreEqual(codec.Tag, tag); + codedInput.AssertNextTag(codec.Tag); Assert.AreEqual(sampleValue, codec.Read(codedInput)); Assert.IsTrue(codedInput.IsAtEnd); } - public void TestCalculateSize() + public void TestCalculateSizeWithTag() { var stream = new MemoryStream(); var codedOutput = CodedOutputStream.CreateInstance(stream); @@ -126,6 +143,7 @@ namespace Google.Protobuf public void TestDefaultValue() { + // WriteTagAndValue ignores default values var stream = new MemoryStream(); var codedOutput = CodedOutputStream.CreateInstance(stream); codec.WriteTagAndValue(codedOutput, codec.DefaultValue); @@ -136,9 +154,20 @@ namespace Google.Protobuf { Assert.AreEqual(default(T), codec.DefaultValue); } - } - public string Description { get { return name; } } + // The plain ValueWriter/ValueReader delegates don't. + if (codec.DefaultValue != null) // This part isn't appropriate for message types. + { + codedOutput = CodedOutputStream.CreateInstance(stream); + codec.ValueWriter(codedOutput, codec.DefaultValue); + codedOutput.Flush(); + Assert.AreNotEqual(0, stream.Position); + Assert.AreEqual(stream.Position, codec.ValueSizeCalculator(codec.DefaultValue)); + stream.Position = 0; + var codedInput = CodedInputStream.CreateInstance(stream); + Assert.AreEqual(codec.DefaultValue, codec.ValueReader(codedInput)); + } + } public override string ToString() { diff --git a/csharp/src/ProtocolBuffers.Test/GeneratedMessageTest.cs b/csharp/src/ProtocolBuffers.Test/GeneratedMessageTest.cs index f8668662..a094e46b 100644 --- a/csharp/src/ProtocolBuffers.Test/GeneratedMessageTest.cs +++ b/csharp/src/ProtocolBuffers.Test/GeneratedMessageTest.cs @@ -10,6 +10,61 @@ namespace Google.Protobuf /// public class GeneratedMessageTest { + /// + /// Returns a sample TestAllTypes with all fields populated + /// + public static TestAllTypes GetSampleMessage() + { + return new TestAllTypes + { + SingleBool = true, + SingleBytes = ByteString.CopyFrom(1, 2, 3, 4), + SingleDouble = 23.5, + SingleFixed32 = 23, + SingleFixed64 = 1234567890123, + SingleFloat = 12.25f, + SingleForeignEnum = ForeignEnum.FOREIGN_BAR, + SingleForeignMessage = new ForeignMessage { C = 10 }, + SingleImportEnum = ImportEnum.IMPORT_BAZ, + SingleImportMessage = new ImportMessage { D = 20 }, + SingleInt32 = 100, + SingleInt64 = 3210987654321, + SingleNestedEnum = TestAllTypes.Types.NestedEnum.FOO, + SingleNestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 35 }, + SinglePublicImportMessage = new PublicImportMessage { E = 54 }, + SingleSfixed32 = -123, + SingleSfixed64 = -12345678901234, + SingleSint32 = -456, + SingleSint64 = -12345678901235, + SingleString = "test", + SingleUint32 = uint.MaxValue, + SingleUint64 = ulong.MaxValue, + RepeatedBool = { true, false }, + RepeatedBytes = { ByteString.CopyFrom(1, 2, 3, 4), ByteString.CopyFrom(5, 6), ByteString.CopyFrom(new byte[1000]) }, + RepeatedDouble = { -12.25, 23.5 }, + RepeatedFixed32 = { uint.MaxValue, 23 }, + RepeatedFixed64 = { ulong.MaxValue, 1234567890123 }, + RepeatedFloat = { 100f, 12.25f }, + RepeatedForeignEnum = { ForeignEnum.FOREIGN_FOO, ForeignEnum.FOREIGN_BAR }, + RepeatedForeignMessage = { new ForeignMessage(), new ForeignMessage { C = 10 } }, + RepeatedImportEnum = { ImportEnum.IMPORT_BAZ, ImportEnum.IMPORT_ENUM_UNSPECIFIED }, + RepeatedImportMessage = { new ImportMessage { D = 20 }, new ImportMessage { D = 25 } }, + RepeatedInt32 = { 100, 200 }, + RepeatedInt64 = { 3210987654321, long.MaxValue }, + RepeatedNestedEnum = { TestAllTypes.Types.NestedEnum.FOO, TestAllTypes.Types.NestedEnum.NEG }, + RepeatedNestedMessage = { new TestAllTypes.Types.NestedMessage { Bb = 35 }, new TestAllTypes.Types.NestedMessage { Bb = 10 } }, + RepeatedPublicImportMessage = { new PublicImportMessage { E = 54 }, new PublicImportMessage { E = -1 } }, + RepeatedSfixed32 = { -123, 123 }, + RepeatedSfixed64 = { -12345678901234, 12345678901234 }, + RepeatedSint32 = { -456, 100 }, + RepeatedSint64 = { -12345678901235, 123 }, + RepeatedString = { "foo", "bar" }, + RepeatedUint32 = { uint.MaxValue, uint.MinValue }, + RepeatedUint64 = { ulong.MaxValue, uint.MinValue }, + OneofString = "Oneof string" + }; + } + [Test] public void EmptyMessageFieldDistinctFromMissingMessageField() { @@ -485,5 +540,83 @@ namespace Google.Protobuf Assert.Throws(() => frozen.RepeatedDouble.Add(0.0)); Assert.Throws(() => frozen.RepeatedNestedMessage.Add(new TestAllTypes.Types.NestedMessage())); } + + [Test] + public void OneofProperties() + { + // Switch the oneof case between each of the different options, and check everything behaves + // as expected in each case. + var message = new TestAllTypes(); + Assert.AreEqual("", message.OneofString); + Assert.AreEqual(0, message.OneofUint32); + Assert.AreEqual(ByteString.Empty, message.OneofBytes); + Assert.IsNull(message.OneofNestedMessage); + Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.None, message.OneofFieldCase); + + message.OneofString = "sample"; + Assert.AreEqual("sample", message.OneofString); + Assert.AreEqual(0, message.OneofUint32); + Assert.AreEqual(ByteString.Empty, message.OneofBytes); + Assert.IsNull(message.OneofNestedMessage); + Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofString, message.OneofFieldCase); + + var bytes = ByteString.CopyFrom(1, 2, 3); + message.OneofBytes = bytes; + Assert.AreEqual("", message.OneofString); + Assert.AreEqual(0, message.OneofUint32); + Assert.AreEqual(bytes, message.OneofBytes); + Assert.IsNull(message.OneofNestedMessage); + Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofBytes, message.OneofFieldCase); + + message.OneofUint32 = 20; + Assert.AreEqual("", message.OneofString); + Assert.AreEqual(20, message.OneofUint32); + Assert.AreEqual(ByteString.Empty, message.OneofBytes); + Assert.IsNull(message.OneofNestedMessage); + Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofUint32, message.OneofFieldCase); + + var nestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 25 }; + message.OneofNestedMessage = nestedMessage; + Assert.AreEqual("", message.OneofString); + Assert.AreEqual(0, message.OneofUint32); + Assert.AreEqual(ByteString.Empty, message.OneofBytes); + Assert.AreEqual(nestedMessage, message.OneofNestedMessage); + Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofNestedMessage, message.OneofFieldCase); + + message.ClearOneofField(); + Assert.AreEqual("", message.OneofString); + Assert.AreEqual(0, message.OneofUint32); + Assert.AreEqual(ByteString.Empty, message.OneofBytes); + Assert.IsNull(message.OneofNestedMessage); + Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.None, message.OneofFieldCase); + } + + [Test] + public void OneofSerialization_NonDefaultValue() + { + var message = new TestAllTypes(); + message.OneofString = "this would take a bit of space"; + message.OneofUint32 = 10; + 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); + } + + [Test] + public void OneofSerialization_DefaultValue() + { + var message = new TestAllTypes(); + message.OneofString = "this would take a bit of space"; + message.OneofUint32 = 0; // This is the default value for UInt32; normally wouldn't be serialized + 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); + } } } diff --git a/csharp/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj b/csharp/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj index 80b504aa..ae7d7575 100644 --- a/csharp/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj +++ b/csharp/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj @@ -72,6 +72,7 @@ + @@ -79,6 +80,7 @@ + diff --git a/csharp/src/ProtocolBuffers.Test/SampleEnum.cs b/csharp/src/ProtocolBuffers.Test/SampleEnum.cs new file mode 100644 index 00000000..001f9b08 --- /dev/null +++ b/csharp/src/ProtocolBuffers.Test/SampleEnum.cs @@ -0,0 +1,42 @@ +#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 + +namespace Google.Protobuf +{ + // Just a sample enum with positive and negative values to be used in tests. + internal enum SampleEnum + { + NegativeValue = -2, + None = 0, + PositiveValue = 3 + } +} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/CodedInputStream.cs b/csharp/src/ProtocolBuffers/CodedInputStream.cs index 75178d14..5c64fd97 100644 --- a/csharp/src/ProtocolBuffers/CodedInputStream.cs +++ b/csharp/src/ProtocolBuffers/CodedInputStream.cs @@ -37,7 +37,6 @@ using System; using System.Collections.Generic; using System.IO; -using Google.Protobuf.Collections; namespace Google.Protobuf { @@ -178,8 +177,61 @@ namespace Google.Protobuf /// internal uint LastTag { get { return lastTag; } } - #region Validation + #region Limits for recursion and length + /// + /// Set the maximum message recursion depth. + /// + /// + /// In order to prevent malicious + /// messages from causing stack overflows, CodedInputStream limits + /// how deeply messages may be nested. The default limit is 64. + /// + public int SetRecursionLimit(int limit) + { + if (limit < 0) + { + throw new ArgumentOutOfRangeException("Recursion limit cannot be negative: " + limit); + } + int oldLimit = recursionLimit; + recursionLimit = limit; + return oldLimit; + } + + /// + /// Set the maximum message size. + /// + /// + /// In order to prevent malicious messages from exhausting memory or + /// causing integer overflows, CodedInputStream limits how large a message may be. + /// The default limit is 64MB. You should set this limit as small + /// as you can without harming your app's functionality. Note that + /// size limits only apply when reading from an InputStream, not + /// when constructed around a raw byte array (nor with ByteString.NewCodedInput). + /// If you want to read several messages from a single CodedInputStream, you + /// can call ResetSizeCounter() after each message to avoid hitting the + /// size limit. + /// + public int SetSizeLimit(int limit) + { + if (limit < 0) + { + throw new ArgumentOutOfRangeException("Size limit cannot be negative: " + limit); + } + int oldLimit = sizeLimit; + sizeLimit = limit; + return oldLimit; + } + + /// + /// Resets the current size counter to zero (see ). + /// + public void ResetSizeCounter() + { + totalBytesRetired = 0; + } + #endregion + #region Validation /// /// Verifies that the last call to ReadTag() returned the given tag value. /// This is used to verify that a nested group ended with the correct @@ -194,13 +246,12 @@ namespace Google.Protobuf throw InvalidProtocolBufferException.InvalidEndTag(); } } - #endregion #region Reading of tags etc /// - /// Attempt to peek at the next field tag. + /// Attempts to peek at the next field tag. /// public bool PeekNextTag(out uint fieldTag) { @@ -218,7 +269,7 @@ namespace Google.Protobuf } /// - /// Attempt to read a field tag, returning false if we have reached the end + /// Attempts to read a field tag, returning false if we have reached the end /// of the input data. /// /// The 'tag' of the field (id * 8 + wire-format) @@ -233,14 +284,42 @@ namespace Google.Protobuf return true; } - if (IsAtEnd) + // Optimize for the incredibly common case of having at least two bytes left in the buffer, + // and those two bytes being enough to get the tag. This will be true for fields up to 4095. + if (bufferPos + 2 <= bufferSize) { - fieldTag = 0; - lastTag = fieldTag; - return false; + int tmp = buffer[bufferPos++]; + if (tmp < 128) + { + fieldTag = (uint)tmp; + } + else + { + int result = tmp & 0x7f; + if ((tmp = buffer[bufferPos++]) < 128) + { + result |= tmp << 7; + fieldTag = (uint) result; + } + else + { + // Nope, rewind and go the potentially slow route. + bufferPos -= 2; + fieldTag = ReadRawVarint32(); + } + } } + else + { + if (IsAtEnd) + { + fieldTag = 0; + lastTag = fieldTag; + return false; + } - fieldTag = ReadRawVarint32(); + fieldTag = ReadRawVarint32(); + } lastTag = fieldTag; if (lastTag == 0) { @@ -251,7 +330,7 @@ namespace Google.Protobuf } /// - /// Read a double field from the stream. + /// Reads a double field from the stream. /// public double ReadDouble() { @@ -259,7 +338,7 @@ namespace Google.Protobuf } /// - /// Read a float field from the stream. + /// Reads a float field from the stream. /// public float ReadFloat() { @@ -281,7 +360,7 @@ namespace Google.Protobuf } /// - /// Read a uint64 field from the stream. + /// Reads a uint64 field from the stream. /// public ulong ReadUInt64() { @@ -289,7 +368,7 @@ namespace Google.Protobuf } /// - /// Read an int64 field from the stream. + /// Reads an int64 field from the stream. /// public long ReadInt64() { @@ -297,7 +376,7 @@ namespace Google.Protobuf } /// - /// Read an int32 field from the stream. + /// Reads an int32 field from the stream. /// public int ReadInt32() { @@ -305,7 +384,7 @@ namespace Google.Protobuf } /// - /// Read a fixed64 field from the stream. + /// Reads a fixed64 field from the stream. /// public ulong ReadFixed64() { @@ -313,7 +392,7 @@ namespace Google.Protobuf } /// - /// Read a fixed32 field from the stream. + /// Reads a fixed32 field from the stream. /// public uint ReadFixed32() { @@ -321,7 +400,7 @@ namespace Google.Protobuf } /// - /// Read a bool field from the stream. + /// Reads a bool field from the stream. /// public bool ReadBool() { @@ -333,22 +412,22 @@ namespace Google.Protobuf /// public string ReadString() { - int size = (int) ReadRawVarint32(); + int length = ReadLength(); // No need to read any data for an empty string. - if (size == 0) + if (length == 0) { return ""; } - if (size <= bufferSize - bufferPos) + if (length <= bufferSize - bufferPos) { // Fast path: We already have the bytes in a contiguous buffer, so // just copy directly from it. - String result = CodedOutputStream.Utf8Encoding.GetString(buffer, bufferPos, size); - bufferPos += size; + String result = CodedOutputStream.Utf8Encoding.GetString(buffer, bufferPos, length); + bufferPos += length; return result; } // Slow path: Build a byte array first then copy it. - return CodedOutputStream.Utf8Encoding.GetString(ReadRawBytes(size), 0, size); + return CodedOutputStream.Utf8Encoding.GetString(ReadRawBytes(length), 0, length); } /// @@ -356,7 +435,7 @@ namespace Google.Protobuf /// public void ReadMessage(IMessage builder) { - int length = (int) ReadRawVarint32(); + int length = ReadLength(); if (recursionDepth >= recursionLimit) { throw InvalidProtocolBufferException.RecursionLimitExceeded(); @@ -374,19 +453,19 @@ namespace Google.Protobuf /// public ByteString ReadBytes() { - int size = (int) ReadRawVarint32(); - if (size <= bufferSize - bufferPos && size > 0) + int length = ReadLength(); + if (length <= bufferSize - bufferPos && length > 0) { // Fast path: We already have the bytes in a contiguous buffer, so // just copy directly from it. - ByteString result = ByteString.CopyFrom(buffer, bufferPos, size); - bufferPos += size; + ByteString result = ByteString.CopyFrom(buffer, bufferPos, length); + bufferPos += length; return result; } else { // Slow path: Build a byte array and attach it to a new ByteString. - return ByteString.AttachBytes(ReadRawBytes(size)); + return ByteString.AttachBytes(ReadRawBytes(length)); } } @@ -441,6 +520,18 @@ namespace Google.Protobuf return 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 stream. If it matches , /// the tag is consumed and the method returns true; otherwise, the @@ -517,12 +608,12 @@ namespace Google.Protobuf } /// - /// Read a raw Varint from the stream. If larger than 32 bits, discard the upper bits. + /// Reads a raw Varint from the stream. 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. /// - public uint ReadRawVarint32() + internal uint ReadRawVarint32() { if (bufferPos + 5 > bufferSize) { @@ -581,13 +672,13 @@ namespace Google.Protobuf /// /// Reads a varint from the input one byte at a time, so that it does not /// read any bytes after the end of the varint. If you simply wrapped the - /// stream in a CodedInputStream and used ReadRawVarint32(Stream)} + /// stream in a CodedInputStream and used ReadRawVarint32(Stream) /// then you would probably end up reading past the end of the varint since /// CodedInputStream buffers its input. /// /// /// - public static uint ReadRawVarint32(Stream input) + internal static uint ReadRawVarint32(Stream input) { int result = 0; int offset = 0; @@ -621,9 +712,9 @@ namespace Google.Protobuf } /// - /// Read a raw varint from the stream. + /// Reads a raw varint from the stream. /// - public ulong ReadRawVarint64() + internal ulong ReadRawVarint64() { int shift = 0; ulong result = 0; @@ -641,9 +732,9 @@ namespace Google.Protobuf } /// - /// Read a 32-bit little-endian integer from the stream. + /// Reads a 32-bit little-endian integer from the stream. /// - public uint ReadRawLittleEndian32() + internal uint ReadRawLittleEndian32() { uint b1 = ReadRawByte(); uint b2 = ReadRawByte(); @@ -653,9 +744,9 @@ namespace Google.Protobuf } /// - /// Read a 64-bit little-endian integer from the stream. + /// Reads a 64-bit little-endian integer from the stream. /// - public ulong ReadRawLittleEndian64() + internal ulong ReadRawLittleEndian64() { ulong b1 = ReadRawByte(); ulong b2 = ReadRawByte(); @@ -669,8 +760,6 @@ namespace Google.Protobuf | (b5 << 32) | (b6 << 40) | (b7 << 48) | (b8 << 56); } - #endregion - /// /// Decode a 32-bit value with ZigZag encoding. /// @@ -680,9 +769,9 @@ namespace Google.Protobuf /// sign-extended to 64 bits to be varint encoded, thus always taking /// 10 bytes on the wire.) /// - public static int DecodeZigZag32(uint n) + internal static int DecodeZigZag32(uint n) { - return (int) (n >> 1) ^ -(int) (n & 1); + return (int)(n >> 1) ^ -(int)(n & 1); } /// @@ -694,72 +783,21 @@ namespace Google.Protobuf /// sign-extended to 64 bits to be varint encoded, thus always taking /// 10 bytes on the wire.) /// - public static long DecodeZigZag64(ulong n) - { - return (long) (n >> 1) ^ -(long) (n & 1); - } - - /// - /// Set the maximum message recursion depth. - /// - /// - /// In order to prevent malicious - /// messages from causing stack overflows, CodedInputStream limits - /// how deeply messages may be nested. The default limit is 64. - /// - public int SetRecursionLimit(int limit) - { - if (limit < 0) - { - throw new ArgumentOutOfRangeException("Recursion limit cannot be negative: " + limit); - } - int oldLimit = recursionLimit; - recursionLimit = limit; - return oldLimit; - } - - /// - /// Set the maximum message size. - /// - /// - /// In order to prevent malicious messages from exhausting memory or - /// causing integer overflows, CodedInputStream limits how large a message may be. - /// The default limit is 64MB. You should set this limit as small - /// as you can without harming your app's functionality. Note that - /// size limits only apply when reading from an InputStream, not - /// when constructed around a raw byte array (nor with ByteString.NewCodedInput). - /// If you want to read several messages from a single CodedInputStream, you - /// can call ResetSizeCounter() after each message to avoid hitting the - /// size limit. - /// - public int SetSizeLimit(int limit) + internal static long DecodeZigZag64(ulong n) { - if (limit < 0) - { - throw new ArgumentOutOfRangeException("Size limit cannot be negative: " + limit); - } - int oldLimit = sizeLimit; - sizeLimit = limit; - return oldLimit; + return (long)(n >> 1) ^ -(long)(n & 1); } + #endregion #region Internal reading and buffer management - /// - /// Resets the current size counter to zero (see SetSizeLimit). - /// - public void ResetSizeCounter() - { - totalBytesRetired = 0; - } - /// /// 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. - public int PushLimit(int byteLimit) + internal int PushLimit(int byteLimit) { if (byteLimit < 0) { @@ -797,7 +835,7 @@ namespace Google.Protobuf /// /// Discards the current limit, returning the previous limit. /// - public void PopLimit(int oldLimit) + internal void PopLimit(int oldLimit) { currentLimit = oldLimit; RecomputeBufferSizeAfterLimit(); @@ -807,7 +845,7 @@ namespace Google.Protobuf /// Returns whether or not all the data before the limit has been read. /// /// - public bool ReachedLimit + internal bool ReachedLimit { get { @@ -897,7 +935,7 @@ namespace Google.Protobuf /// /// the end of the stream or the current limit was reached /// - public byte ReadRawByte() + internal byte ReadRawByte() { if (bufferPos == bufferSize) { @@ -907,12 +945,12 @@ namespace Google.Protobuf } /// - /// Read a fixed size of bytes from the input. + /// Reads a fixed size of bytes from the input. /// /// /// the end of the stream or the current limit was reached /// - public byte[] ReadRawBytes(int size) + internal byte[] ReadRawBytes(int size) { if (size < 0) { @@ -921,7 +959,8 @@ namespace Google.Protobuf if (totalBytesRetired + bufferPos + size > currentLimit) { - // Read to the end of the stream anyway. + // Read to the end of the stream (up to the current limit) anyway. + // TODO(jonskeet): This is the only usage of SkipRawBytes. Do we really need to do it? SkipRawBytes(currentLimit - totalBytesRetired - bufferPos); // Then fail. throw InvalidProtocolBufferException.TruncatedMessage(); @@ -1025,63 +1064,12 @@ namespace Google.Protobuf } } - /// - /// Reads and discards a single field, given its tag value. - /// - /// false if the tag is an end-group tag, in which case - /// nothing is skipped. Otherwise, returns true. - public bool SkipField() - { - uint tag = lastTag; - switch (WireFormat.GetTagWireType(tag)) - { - case WireFormat.WireType.Varint: - ReadRawVarint64(); - return true; - case WireFormat.WireType.Fixed64: - ReadRawLittleEndian64(); - return true; - case WireFormat.WireType.LengthDelimited: - SkipRawBytes((int) ReadRawVarint32()); - return true; - case WireFormat.WireType.StartGroup: - SkipMessage(); - CheckLastTagWas( - WireFormat.MakeTag(WireFormat.GetTagFieldNumber(tag), - WireFormat.WireType.EndGroup)); - return true; - case WireFormat.WireType.EndGroup: - return false; - case WireFormat.WireType.Fixed32: - ReadRawLittleEndian32(); - return true; - default: - throw InvalidProtocolBufferException.InvalidWireType(); - } - } - - /// - /// Reads and discards an entire message. This will read either until EOF - /// or until an endgroup tag, whichever comes first. - /// - public void SkipMessage() - { - uint tag; - while (ReadTag(out tag)) - { - if (!SkipField()) - { - return; - } - } - } - /// /// Reads and discards bytes. /// /// the end of the stream /// or the current limit was reached - public void SkipRawBytes(int size) + private void SkipRawBytes(int size) { if (size < 0) { diff --git a/csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs b/csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs index ef1f4c0c..82aba51b 100644 --- a/csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs +++ b/csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs @@ -50,7 +50,7 @@ namespace Google.Protobuf private const int LittleEndian32Size = 4; /// - /// Compute the number of bytes that would be needed to encode a + /// Computes the number of bytes that would be needed to encode a /// double field, including the tag. /// public static int ComputeDoubleSize(double value) @@ -59,7 +59,7 @@ namespace Google.Protobuf } /// - /// Compute the number of bytes that would be needed to encode a + /// Computes the number of bytes that would be needed to encode a /// float field, including the tag. /// public static int ComputeFloatSize(float value) @@ -68,7 +68,7 @@ namespace Google.Protobuf } /// - /// Compute the number of bytes that would be needed to encode a + /// Computes the number of bytes that would be needed to encode a /// uint64 field, including the tag. /// public static int ComputeUInt64Size(ulong value) @@ -77,7 +77,7 @@ namespace Google.Protobuf } /// - /// Compute the number of bytes that would be needed to encode an + /// Computes the number of bytes that would be needed to encode an /// int64 field, including the tag. /// public static int ComputeInt64Size(long value) @@ -86,7 +86,7 @@ namespace Google.Protobuf } /// - /// Compute the number of bytes that would be needed to encode an + /// Computes the number of bytes that would be needed to encode an /// int32 field, including the tag. /// public static int ComputeInt32Size(int value) @@ -103,7 +103,7 @@ namespace Google.Protobuf } /// - /// Compute the number of bytes that would be needed to encode a + /// Computes the number of bytes that would be needed to encode a /// fixed64 field, including the tag. /// public static int ComputeFixed64Size(ulong value) @@ -112,7 +112,7 @@ namespace Google.Protobuf } /// - /// Compute the number of bytes that would be needed to encode a + /// Computes the number of bytes that would be needed to encode a /// fixed32 field, including the tag. /// public static int ComputeFixed32Size(uint value) @@ -121,7 +121,7 @@ namespace Google.Protobuf } /// - /// Compute the number of bytes that would be needed to encode a + /// Computes the number of bytes that would be needed to encode a /// bool field, including the tag. /// public static int ComputeBoolSize(bool value) @@ -130,7 +130,7 @@ namespace Google.Protobuf } /// - /// Compute the number of bytes that would be needed to encode a + /// Computes the number of bytes that would be needed to encode a /// string field, including the tag. /// public static int ComputeStringSize(String value) @@ -141,7 +141,7 @@ namespace Google.Protobuf } /// - /// Compute the number of bytes that would be needed to encode a + /// Computes the number of bytes that would be needed to encode a /// group field, including the tag. /// public static int ComputeGroupSize(IMessage value) @@ -150,7 +150,7 @@ namespace Google.Protobuf } /// - /// Compute the number of bytes that would be needed to encode an + /// Computes the number of bytes that would be needed to encode an /// embedded message field, including the tag. /// public static int ComputeMessageSize(IMessage value) @@ -160,7 +160,7 @@ namespace Google.Protobuf } /// - /// Compute the number of bytes that would be needed to encode a + /// Computes the number of bytes that would be needed to encode a /// bytes field, including the tag. /// public static int ComputeBytesSize(ByteString value) @@ -170,7 +170,7 @@ namespace Google.Protobuf } /// - /// Compute the number of bytes that would be needed to encode a + /// Computes the number of bytes that would be needed to encode a /// uint32 field, including the tag. /// public static int ComputeUInt32Size(uint value) @@ -179,7 +179,7 @@ namespace Google.Protobuf } /// - /// Compute the number of bytes that would be needed to encode a + /// Computes the number of bytes that would be needed to encode a /// enum field, including the tag. The caller is responsible for /// converting the enum value to its numeric value. /// @@ -190,7 +190,7 @@ namespace Google.Protobuf } /// - /// Compute the number of bytes that would be needed to encode an + /// Computes the number of bytes that would be needed to encode an /// sfixed32 field, including the tag. /// public static int ComputeSFixed32Size(int value) @@ -199,7 +199,7 @@ namespace Google.Protobuf } /// - /// Compute the number of bytes that would be needed to encode an + /// Computes the number of bytes that would be needed to encode an /// sfixed64 field, including the tag. /// public static int ComputeSFixed64Size(long value) @@ -208,7 +208,7 @@ namespace Google.Protobuf } /// - /// Compute the number of bytes that would be needed to encode an + /// Computes the number of bytes that would be needed to encode an /// sint32 field, including the tag. /// public static int ComputeSInt32Size(int value) @@ -217,7 +217,7 @@ namespace Google.Protobuf } /// - /// Compute the number of bytes that would be needed to encode an + /// Computes the number of bytes that would be needed to encode an /// sint64 field, including the tag. /// public static int ComputeSInt64Size(long value) @@ -226,7 +226,16 @@ namespace Google.Protobuf } /// - /// Compute the number of bytes that would be needed to encode a varint. + /// Computes the number of bytes that would be needed to encode a length, + /// as written by . + /// + public static int ComputeLengthSize(int length) + { + return ComputeRawVarint32Size((uint) length); + } + + /// + /// Computes the number of bytes that would be needed to encode a varint. /// public static int ComputeRawVarint32Size(uint value) { @@ -250,7 +259,7 @@ namespace Google.Protobuf } /// - /// Compute the number of bytes that would be needed to encode a varint. + /// Computes the number of bytes that would be needed to encode a varint. /// public static int ComputeRawVarint64Size(ulong value) { @@ -294,7 +303,7 @@ namespace Google.Protobuf } /// - /// Compute the number of bytes that would be needed to encode a tag. + /// Computes the number of bytes that would be needed to encode a tag. /// public static int ComputeTagSize(int fieldNumber) { diff --git a/csharp/src/ProtocolBuffers/CodedOutputStream.cs b/csharp/src/ProtocolBuffers/CodedOutputStream.cs index 99a99ae2..161f48f4 100644 --- a/csharp/src/ProtocolBuffers/CodedOutputStream.cs +++ b/csharp/src/ProtocolBuffers/CodedOutputStream.cs @@ -37,7 +37,6 @@ using System; using System.IO; using System.Text; -using Google.Protobuf.Collections; namespace Google.Protobuf { @@ -141,11 +140,12 @@ namespace Google.Protobuf } } - #region Writing of values without tags + #region Writing of values (not including tags) /// - /// Writes a double field value, including tag, to the stream. + /// 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)); @@ -154,6 +154,7 @@ namespace Google.Protobuf /// /// Writes a float field value, without a tag, to the stream. /// + /// The value to write public void WriteFloat(float value) { byte[] rawBytes = BitConverter.GetBytes(value); @@ -178,6 +179,7 @@ namespace Google.Protobuf /// /// Writes a uint64 field value, without a tag, to the stream. /// + /// The value to write public void WriteUInt64(ulong value) { WriteRawVarint64(value); @@ -186,6 +188,7 @@ namespace Google.Protobuf /// /// Writes an int64 field value, without a tag, to the stream. /// + /// The value to write public void WriteInt64(long value) { WriteRawVarint64((ulong) value); @@ -194,6 +197,7 @@ namespace Google.Protobuf /// /// Writes an int32 field value, without a tag, to the stream. /// + /// The value to write public void WriteInt32(int value) { if (value >= 0) @@ -210,6 +214,7 @@ namespace Google.Protobuf /// /// Writes a fixed64 field value, without a tag, to the stream. /// + /// The value to write public void WriteFixed64(ulong value) { WriteRawLittleEndian64(value); @@ -218,6 +223,7 @@ namespace Google.Protobuf /// /// Writes a fixed32 field value, without a tag, to the stream. /// + /// The value to write public void WriteFixed32(uint value) { WriteRawLittleEndian32(value); @@ -226,6 +232,7 @@ namespace Google.Protobuf /// /// 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); @@ -233,13 +240,15 @@ namespace Google.Protobuf /// /// 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) { // Optimise the case where we have enough space to write // the string directly to the buffer, which should be common. int length = Utf8Encoding.GetByteCount(value); - WriteRawVarint32((uint)length); + WriteLength(length); if (limit - position >= length) { if (length == value.Length) // Must be all ASCII... @@ -262,23 +271,41 @@ namespace Google.Protobuf } } + /// + /// Writes a message, without a tag, to the stream. + /// The data is length-prefixed. + /// + /// The value to write public void WriteMessage(IMessage value) { WriteRawVarint32((uint) value.CalculateSize()); value.WriteTo(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) { WriteRawVarint32((uint) value.Length); value.WriteRawBytesTo(this); } + /// + /// 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); @@ -289,27 +316,53 @@ namespace Google.Protobuf 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(EncodeZigZag32(value)); } + /// + /// Writes an sint64 value, without a tag, to the stream. + /// + /// The value to write public void WriteSInt64(long value) { WriteRawVarint64(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)); @@ -318,6 +371,7 @@ namespace Google.Protobuf /// /// Writes an already-encoded tag. /// + /// The encoded tag public void WriteTag(uint tag) { WriteRawVarint32(tag); @@ -326,6 +380,7 @@ namespace Google.Protobuf /// /// Writes the given single-byte tag directly to the stream. /// + /// The encoded tag public void WriteRawTag(byte b1) { WriteRawByte(b1); @@ -334,6 +389,8 @@ namespace Google.Protobuf /// /// 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) { WriteRawByte(b1); @@ -343,6 +400,9 @@ namespace Google.Protobuf /// /// 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) { WriteRawByte(b1); @@ -353,6 +413,10 @@ namespace Google.Protobuf /// /// 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) { WriteRawByte(b1); @@ -364,6 +428,11 @@ namespace Google.Protobuf /// /// 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) { WriteRawByte(b1); @@ -380,7 +449,7 @@ namespace Google.Protobuf /// there's enough buffer space left to whizz through without checking /// for each byte; otherwise, we resort to calling WriteRawByte each time. /// - public void WriteRawVarint32(uint value) + internal void WriteRawVarint32(uint value) { // Optimize for the common case of a single byte value if (value < 128 && position < limit) @@ -409,7 +478,7 @@ namespace Google.Protobuf } } - public void WriteRawVarint64(ulong value) + internal void WriteRawVarint64(ulong value) { while (value > 127 && position < limit) { @@ -431,7 +500,7 @@ namespace Google.Protobuf } } - public void WriteRawLittleEndian32(uint value) + internal void WriteRawLittleEndian32(uint value) { if (position + 4 > limit) { @@ -449,7 +518,7 @@ namespace Google.Protobuf } } - public void WriteRawLittleEndian64(ulong value) + internal void WriteRawLittleEndian64(ulong value) { if (position + 8 > limit) { @@ -475,7 +544,7 @@ namespace Google.Protobuf } } - public void WriteRawByte(byte value) + internal void WriteRawByte(byte value) { if (position == limit) { @@ -485,7 +554,7 @@ namespace Google.Protobuf buffer[position++] = value; } - public void WriteRawByte(uint value) + internal void WriteRawByte(uint value) { WriteRawByte((byte) value); } @@ -493,7 +562,7 @@ namespace Google.Protobuf /// /// Writes out an array of bytes. /// - public void WriteRawBytes(byte[] value) + internal void WriteRawBytes(byte[] value) { WriteRawBytes(value, 0, value.Length); } @@ -501,7 +570,7 @@ namespace Google.Protobuf /// /// Writes out part of an array of bytes. /// - public void WriteRawBytes(byte[] value, int offset, int length) + internal void WriteRawBytes(byte[] value, int offset, int length) { if (limit - position >= length) { @@ -548,7 +617,7 @@ namespace Google.Protobuf /// sign-extended to 64 bits to be varint encoded, thus always taking /// 10 bytes on the wire.) /// - public static uint EncodeZigZag32(int n) + internal static uint EncodeZigZag32(int n) { // Note: the right-shift must be arithmetic return (uint) ((n << 1) ^ (n >> 31)); @@ -563,7 +632,7 @@ namespace Google.Protobuf /// sign-extended to 64 bits to be varint encoded, thus always taking /// 10 bytes on the wire.) /// - public static ulong EncodeZigZag64(long n) + internal static ulong EncodeZigZag64(long n) { return (ulong) ((n << 1) ^ (n >> 63)); } diff --git a/csharp/src/ProtocolBuffers/Collections/ReadOnlyDictionary.cs b/csharp/src/ProtocolBuffers/Collections/ReadOnlyDictionary.cs index 031ebd02..cf3ff83c 100644 --- a/csharp/src/ProtocolBuffers/Collections/ReadOnlyDictionary.cs +++ b/csharp/src/ProtocolBuffers/Collections/ReadOnlyDictionary.cs @@ -38,7 +38,7 @@ namespace Google.Protobuf.Collections /// /// Read-only wrapper around another dictionary. /// - public sealed class ReadOnlyDictionary : IDictionary + internal sealed class ReadOnlyDictionary : IDictionary { private readonly IDictionary wrapped; diff --git a/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs b/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs index 588f66a4..0d82e3bc 100644 --- a/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs +++ b/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs @@ -51,12 +51,14 @@ namespace Google.Protobuf.Collections public void AddEntriesFrom(CodedInputStream input, FieldCodec codec) { + // TODO: Inline some of the Add code, so we can avoid checking the size on every + // iteration and the mutability. uint tag = input.LastTag; var reader = codec.ValueReader; // Value types can be packed or not. if (typeof(T).IsValueType && WireFormat.GetTagWireType(tag) == WireFormat.WireType.LengthDelimited) { - int length = (int)(input.ReadRawVarint32() & int.MaxValue); + int length = input.ReadLength(); if (length > 0) { int oldLimit = input.PushLimit(length); @@ -125,7 +127,6 @@ namespace Google.Protobuf.Collections public void WriteTo(CodedOutputStream output, FieldCodec codec) { - // TODO: Assert that T is a value type, and that codec.Tag is packed? if (count == 0) { return; @@ -172,9 +173,9 @@ namespace Google.Protobuf.Collections private void EnsureSize(int size) { - size = Math.Max(size, MinArraySize); if (array.Length < size) { + size = Math.Max(size, MinArraySize); int newSize = Math.Max(array.Length * 2, size); var tmp = new T[newSize]; Array.Copy(array, 0, tmp, 0, array.Length); diff --git a/csharp/src/ProtocolBuffers/FieldCodec.cs b/csharp/src/ProtocolBuffers/FieldCodec.cs index d3fc2f71..f075dbbf 100644 --- a/csharp/src/ProtocolBuffers/FieldCodec.cs +++ b/csharp/src/ProtocolBuffers/FieldCodec.cs @@ -8,6 +8,7 @@ namespace Google.Protobuf /// public static class FieldCodec { + // TODO: Avoid the "dual hit" of lambda expressions: create open delegates instead. (At least test...) public static FieldCodec ForString(uint tag) { return new FieldCodec(input => input.ReadString(), (output, value) => output.WriteString(value), CodedOutputStream.ComputeStringSize, tag); @@ -84,7 +85,7 @@ namespace Google.Protobuf } // Enums are tricky. We can probably use expression trees to build these delegates automatically, - // but it's easy to generate the code fdor it. + // but it's easy to generate the code for it. public static FieldCodec ForEnum(uint tag, Func toInt32, Func fromInt32) { return new FieldCodec(input => fromInt32( diff --git a/csharp/src/ProtocolBuffers/MessageExtensions.cs b/csharp/src/ProtocolBuffers/MessageExtensions.cs index 57cecfd4..253c18ae 100644 --- a/csharp/src/ProtocolBuffers/MessageExtensions.cs +++ b/csharp/src/ProtocolBuffers/MessageExtensions.cs @@ -38,7 +38,7 @@ namespace Google.Protobuf { ThrowHelper.ThrowIfNull(message, "message"); ThrowHelper.ThrowIfNull(input, "input"); - int size = (int)CodedInputStream.ReadRawVarint32(input); + int size = (int) CodedInputStream.ReadRawVarint32(input); Stream limitedStream = new LimitedInputStream(input, size); message.MergeFrom(limitedStream); } diff --git a/csharp/src/ProtocolBuffers/Properties/AssemblyInfo.cs b/csharp/src/ProtocolBuffers/Properties/AssemblyInfo.cs index 806bd5d5..27ccddbc 100644 --- a/csharp/src/ProtocolBuffers/Properties/AssemblyInfo.cs +++ b/csharp/src/ProtocolBuffers/Properties/AssemblyInfo.cs @@ -61,6 +61,13 @@ using System.Security; [assembly: AssemblyVersion("2.4.1.555")] +[assembly: InternalsVisibleTo("Google.Protobuf.Test, PublicKey=" + + "00240000048000009400000006020000002400005253413100040000110000003b4611704c5379" + + "39c3e0fbe9447dd6fa5462507f9dd4fd9fbf0712457e415b037da6d2c4eb5d2c7d29c86380af68" + + "7cf400401bb183f2a70bd3b631c1fcb7db8aa66c766694a9fb53fa765df6303104da8c978f3b6d" + + "53909cd30685b8bc9922c726cd82b5995e9e2cfca6df7a2d189d851492e49f4b76f269ce6dfd08" + + "c34a7d98")] + #if !NOFILEVERSION [assembly: AssemblyFileVersion("2.4.1.555")] #endif diff --git a/csharp/src/ProtocolBuffers/WireFormat.cs b/csharp/src/ProtocolBuffers/WireFormat.cs index 221ffef6..974665f1 100644 --- a/csharp/src/ProtocolBuffers/WireFormat.cs +++ b/csharp/src/ProtocolBuffers/WireFormat.cs @@ -53,13 +53,13 @@ namespace Google.Protobuf #region Fixed sizes. // TODO(jonskeet): Move these somewhere else. They're messy. Consider making FieldType a smarter kind of enum - public const int Fixed32Size = 4; - public const int Fixed64Size = 8; - public const int SFixed32Size = 4; - public const int SFixed64Size = 8; - public const int FloatSize = 4; - public const int DoubleSize = 8; - public const int BoolSize = 1; + internal const int Fixed32Size = 4; + internal const int Fixed64Size = 8; + internal const int SFixed32Size = 4; + internal const int SFixed64Size = 8; + internal const int FloatSize = 4; + internal const int DoubleSize = 8; + internal const int BoolSize = 1; #endregion @@ -72,22 +72,7 @@ namespace Google.Protobuf EndGroup = 4, Fixed32 = 5 } - - internal static class MessageSetField - { - internal const int Item = 1; - internal const int TypeID = 2; - internal const int Message = 3; - } - - internal static class MessageSetTag - { - internal static readonly uint ItemStart = MakeTag(MessageSetField.Item, WireType.StartGroup); - internal static readonly uint ItemEnd = MakeTag(MessageSetField.Item, WireType.EndGroup); - internal static readonly uint TypeID = MakeTag(MessageSetField.TypeID, WireType.Varint); - internal static readonly uint Message = MakeTag(MessageSetField.Message, WireType.LengthDelimited); - } - + private const int TagTypeBits = 3; private const uint TagTypeMask = (1 << TagTypeBits) - 1; @@ -120,7 +105,6 @@ namespace Google.Protobuf return (uint) (fieldNumber << TagTypeBits) | (uint) wireType; } -#if !LITE public static uint MakeTag(FieldDescriptor field) { return MakeTag(field.FieldNumber, GetWireType(field)); @@ -135,8 +119,6 @@ namespace Google.Protobuf return descriptor.IsPacked ? WireType.LengthDelimited : GetWireType(descriptor.FieldType); } -#endif - /// /// Converts a field type to its wire type. Done with a switch for the sake /// of speed - this is significantly faster than a dictionary lookup. @@ -177,7 +159,7 @@ namespace Google.Protobuf case FieldType.Enum: return WireType.Varint; default: - throw new ArgumentOutOfRangeException("No such field type"); + throw new ArgumentOutOfRangeException("fieldType", "No such field type"); } } } -- cgit v1.2.3 From ee835a3fe44d929512601045fb4e4e527d26e547 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Tue, 30 Jun 2015 17:22:26 +0100 Subject: Fix copyright lines for all C# code. Everything should now be consistent - the only difference between files is the year (aside from generated files). Fixes issue #531. --- csharp/src/AddressBook/AddPerson.cs | 6 +--- csharp/src/AddressBook/ListPeople.cs | 6 +--- csharp/src/AddressBook/Program.cs | 6 +--- csharp/src/AddressBook/SampleUsage.cs | 34 ++++++++++++++++++- csharp/src/ProtoDump/Program.cs | 6 +--- csharp/src/ProtocolBuffers.Test/ByteStringTest.cs | 6 +--- .../ProtocolBuffers.Test/CodedInputStreamTest.cs | 7 +--- .../ProtocolBuffers.Test/CodedOutputStreamTest.cs | 6 +--- .../ProtocolBuffers.Test/DeprecatedMemberTest.cs | 34 ++++++++++++++++++- csharp/src/ProtocolBuffers.Test/DescriptorsTest.cs | 6 +--- csharp/src/ProtocolBuffers.Test/EqualityTester.cs | 4 --- .../ProtocolBuffers.Test/GeneratedMessageTest.cs | 34 ++++++++++++++++++- csharp/src/ProtocolBuffers.Test/IssuesTest.cs | 6 +--- csharp/src/ProtocolBuffers.Test/TestCornerCases.cs | 34 ++++++++++++++++++- csharp/src/ProtocolBuffers/ByteArray.cs | 6 +--- csharp/src/ProtocolBuffers/ByteString.cs | 6 +--- csharp/src/ProtocolBuffers/CodedInputStream.cs | 6 +--- .../CodedOutputStream.ComputeSize.cs | 9 +---- csharp/src/ProtocolBuffers/CodedOutputStream.cs | 6 +--- .../Collections/ReadOnlyDictionary.cs | 7 ++-- .../ProtocolBuffers/Collections/RepeatedField.cs | 34 ++++++++++++++++++- .../DescriptorProtos/IDescriptorProto.cs | 7 ++-- .../DescriptorProtos/PartialClasses.cs | 6 ++-- .../ProtocolBuffers/Descriptors/DescriptorBase.cs | 7 ++-- .../ProtocolBuffers/Descriptors/DescriptorPool.cs | 7 ++-- .../ProtocolBuffers/Descriptors/DescriptorUtil.cs | 7 ++-- .../Descriptors/DescriptorValidationException.cs | 7 ++-- .../ProtocolBuffers/Descriptors/EnumDescriptor.cs | 7 ++-- .../Descriptors/EnumValueDescriptor.cs | 7 ++-- .../ProtocolBuffers/Descriptors/FieldDescriptor.cs | 10 +++--- .../src/ProtocolBuffers/Descriptors/FieldType.cs | 6 ++-- .../ProtocolBuffers/Descriptors/FileDescriptor.cs | 8 ++--- .../src/ProtocolBuffers/Descriptors/IDescriptor.cs | 6 ++-- .../Descriptors/IndexedDescriptorBase.cs | 7 ++-- .../Descriptors/MessageDescriptor.cs | 7 ++-- .../Descriptors/MethodDescriptor.cs | 7 ++-- .../ProtocolBuffers/Descriptors/OneofDescriptor.cs | 10 +++--- .../Descriptors/PackageDescriptor.cs | 6 ++-- .../Descriptors/ServiceDescriptor.cs | 7 ++-- .../FieldAccess/FieldAccessorBase.cs | 39 ++++++++++++++++++---- .../FieldAccess/FieldAccessorTable.cs | 7 ++-- .../ProtocolBuffers/FieldAccess/IFieldAccessor.cs | 6 ++-- .../ProtocolBuffers/FieldAccess/OneofAccessor.cs | 9 +++-- .../ProtocolBuffers/FieldAccess/ReflectionUtil.cs | 7 ++-- .../FieldAccess/RepeatedFieldAccessor.cs | 38 ++++++++++++++++++--- .../FieldAccess/SingleFieldAccessor.cs | 39 ++++++++++++++++++---- csharp/src/ProtocolBuffers/FieldCodec.cs | 34 ++++++++++++++++++- csharp/src/ProtocolBuffers/FrameworkPortability.cs | 6 +--- csharp/src/ProtocolBuffers/Freezable.cs | 4 +-- csharp/src/ProtocolBuffers/IMessage.cs | 6 +--- .../InvalidProtocolBufferException.cs | 6 +--- csharp/src/ProtocolBuffers/LimitedInputStream.cs | 34 ++++++++++++++++++- csharp/src/ProtocolBuffers/MessageExtensions.cs | 34 ++++++++++++++++++- csharp/src/ProtocolBuffers/MessageParser.cs | 34 ++++++++++++++++++- .../src/ProtocolBuffers/Properties/AssemblyInfo.cs | 10 +++--- csharp/src/ProtocolBuffers/ThrowHelper.cs | 6 +--- csharp/src/ProtocolBuffers/WireFormat.cs | 6 +--- 57 files changed, 508 insertions(+), 215 deletions(-) diff --git a/csharp/src/AddressBook/AddPerson.cs b/csharp/src/AddressBook/AddPerson.cs index 5a4de39e..9a6ef601 100644 --- a/csharp/src/AddressBook/AddPerson.cs +++ b/csharp/src/AddressBook/AddPerson.cs @@ -1,10 +1,7 @@ #region Copyright notice and license - // Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/protobuf/ +// 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 @@ -31,7 +28,6 @@ // 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; diff --git a/csharp/src/AddressBook/ListPeople.cs b/csharp/src/AddressBook/ListPeople.cs index 5ae73e53..cc13aa19 100644 --- a/csharp/src/AddressBook/ListPeople.cs +++ b/csharp/src/AddressBook/ListPeople.cs @@ -1,10 +1,7 @@ #region Copyright notice and license - // Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/protobuf/ +// 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 @@ -31,7 +28,6 @@ // 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; diff --git a/csharp/src/AddressBook/Program.cs b/csharp/src/AddressBook/Program.cs index 19c677c0..ff7b9c08 100644 --- a/csharp/src/AddressBook/Program.cs +++ b/csharp/src/AddressBook/Program.cs @@ -1,10 +1,7 @@ #region Copyright notice and license - // Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/protobuf/ +// 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 @@ -31,7 +28,6 @@ // 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; diff --git a/csharp/src/AddressBook/SampleUsage.cs b/csharp/src/AddressBook/SampleUsage.cs index b9a61497..0a48508e 100644 --- a/csharp/src/AddressBook/SampleUsage.cs +++ b/csharp/src/AddressBook/SampleUsage.cs @@ -1,4 +1,36 @@ -using System; +#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; using System.IO; namespace Google.Protobuf.Examples.AddressBook diff --git a/csharp/src/ProtoDump/Program.cs b/csharp/src/ProtoDump/Program.cs index ebe4255d..6d42076d 100644 --- a/csharp/src/ProtoDump/Program.cs +++ b/csharp/src/ProtoDump/Program.cs @@ -1,10 +1,7 @@ #region Copyright notice and license - // Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/protobuf/ +// 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 @@ -31,7 +28,6 @@ // 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; diff --git a/csharp/src/ProtocolBuffers.Test/ByteStringTest.cs b/csharp/src/ProtocolBuffers.Test/ByteStringTest.cs index 0edd149b..dadd0d33 100644 --- a/csharp/src/ProtocolBuffers.Test/ByteStringTest.cs +++ b/csharp/src/ProtocolBuffers.Test/ByteStringTest.cs @@ -1,10 +1,7 @@ #region Copyright notice and license - // Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/protobuf/ +// 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 @@ -31,7 +28,6 @@ // 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; diff --git a/csharp/src/ProtocolBuffers.Test/CodedInputStreamTest.cs b/csharp/src/ProtocolBuffers.Test/CodedInputStreamTest.cs index a64994fd..b15a25b1 100644 --- a/csharp/src/ProtocolBuffers.Test/CodedInputStreamTest.cs +++ b/csharp/src/ProtocolBuffers.Test/CodedInputStreamTest.cs @@ -1,10 +1,7 @@ #region Copyright notice and license - // Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/protobuf/ +// 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 @@ -31,12 +28,10 @@ // 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 Google.Protobuf.Collections; using Google.Protobuf.TestProtos; using NUnit.Framework; diff --git a/csharp/src/ProtocolBuffers.Test/CodedOutputStreamTest.cs b/csharp/src/ProtocolBuffers.Test/CodedOutputStreamTest.cs index ab5dcbd6..02c998cb 100644 --- a/csharp/src/ProtocolBuffers.Test/CodedOutputStreamTest.cs +++ b/csharp/src/ProtocolBuffers.Test/CodedOutputStreamTest.cs @@ -1,10 +1,7 @@ #region Copyright notice and license - // Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/protobuf/ +// 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 @@ -31,7 +28,6 @@ // 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; diff --git a/csharp/src/ProtocolBuffers.Test/DeprecatedMemberTest.cs b/csharp/src/ProtocolBuffers.Test/DeprecatedMemberTest.cs index c962df54..34d5b9f9 100644 --- a/csharp/src/ProtocolBuffers.Test/DeprecatedMemberTest.cs +++ b/csharp/src/ProtocolBuffers.Test/DeprecatedMemberTest.cs @@ -1,4 +1,36 @@ -using System; +#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 System; using System.Reflection; using Google.Protobuf.TestProtos; using NUnit.Framework; diff --git a/csharp/src/ProtocolBuffers.Test/DescriptorsTest.cs b/csharp/src/ProtocolBuffers.Test/DescriptorsTest.cs index fbbdce28..e0fef912 100644 --- a/csharp/src/ProtocolBuffers.Test/DescriptorsTest.cs +++ b/csharp/src/ProtocolBuffers.Test/DescriptorsTest.cs @@ -1,10 +1,7 @@ #region Copyright notice and license - // Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/protobuf/ +// 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 @@ -31,7 +28,6 @@ // 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 Google.Protobuf.Descriptors; diff --git a/csharp/src/ProtocolBuffers.Test/EqualityTester.cs b/csharp/src/ProtocolBuffers.Test/EqualityTester.cs index 816f2be1..b372443b 100644 --- a/csharp/src/ProtocolBuffers.Test/EqualityTester.cs +++ b/csharp/src/ProtocolBuffers.Test/EqualityTester.cs @@ -31,10 +31,6 @@ #endregion using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using NUnit.Framework; namespace Google.Protobuf diff --git a/csharp/src/ProtocolBuffers.Test/GeneratedMessageTest.cs b/csharp/src/ProtocolBuffers.Test/GeneratedMessageTest.cs index a094e46b..b42fc31c 100644 --- a/csharp/src/ProtocolBuffers.Test/GeneratedMessageTest.cs +++ b/csharp/src/ProtocolBuffers.Test/GeneratedMessageTest.cs @@ -1,4 +1,36 @@ -using System; +#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 System; using System.IO; using Google.Protobuf.TestProtos; using NUnit.Framework; diff --git a/csharp/src/ProtocolBuffers.Test/IssuesTest.cs b/csharp/src/ProtocolBuffers.Test/IssuesTest.cs index 87960aab..d2248158 100644 --- a/csharp/src/ProtocolBuffers.Test/IssuesTest.cs +++ b/csharp/src/ProtocolBuffers.Test/IssuesTest.cs @@ -1,10 +1,7 @@ #region Copyright notice and license - // Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/protobuf/ +// 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 @@ -31,7 +28,6 @@ // 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 Google.Protobuf.Descriptors; diff --git a/csharp/src/ProtocolBuffers.Test/TestCornerCases.cs b/csharp/src/ProtocolBuffers.Test/TestCornerCases.cs index 5897c2f9..b270a6f9 100644 --- a/csharp/src/ProtocolBuffers.Test/TestCornerCases.cs +++ b/csharp/src/ProtocolBuffers.Test/TestCornerCases.cs @@ -1,4 +1,36 @@ -using UnitTest.Issues.TestProtos; +#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 UnitTest.Issues.TestProtos; using NUnit.Framework; namespace Google.Protobuf diff --git a/csharp/src/ProtocolBuffers/ByteArray.cs b/csharp/src/ProtocolBuffers/ByteArray.cs index 14e2744a..69b6ef8d 100644 --- a/csharp/src/ProtocolBuffers/ByteArray.cs +++ b/csharp/src/ProtocolBuffers/ByteArray.cs @@ -1,10 +1,7 @@ #region Copyright notice and license - // Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/protobuf/ +// 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 @@ -31,7 +28,6 @@ // 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; diff --git a/csharp/src/ProtocolBuffers/ByteString.cs b/csharp/src/ProtocolBuffers/ByteString.cs index a4afc5e2..d5b7aee9 100644 --- a/csharp/src/ProtocolBuffers/ByteString.cs +++ b/csharp/src/ProtocolBuffers/ByteString.cs @@ -1,10 +1,7 @@ #region Copyright notice and license - // Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/protobuf/ +// 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 @@ -31,7 +28,6 @@ // 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; diff --git a/csharp/src/ProtocolBuffers/CodedInputStream.cs b/csharp/src/ProtocolBuffers/CodedInputStream.cs index 5c64fd97..ef7cf114 100644 --- a/csharp/src/ProtocolBuffers/CodedInputStream.cs +++ b/csharp/src/ProtocolBuffers/CodedInputStream.cs @@ -1,10 +1,7 @@ #region Copyright notice and license - // Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/protobuf/ +// 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 @@ -31,7 +28,6 @@ // 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; diff --git a/csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs b/csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs index 82aba51b..a3e7c1bb 100644 --- a/csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs +++ b/csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs @@ -1,10 +1,7 @@ #region Copyright notice and license - // Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/protobuf/ +// 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 @@ -31,13 +28,9 @@ // 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.Globalization; -using System.Text; -using Google.Protobuf.Descriptors; namespace Google.Protobuf { diff --git a/csharp/src/ProtocolBuffers/CodedOutputStream.cs b/csharp/src/ProtocolBuffers/CodedOutputStream.cs index 161f48f4..53f04c77 100644 --- a/csharp/src/ProtocolBuffers/CodedOutputStream.cs +++ b/csharp/src/ProtocolBuffers/CodedOutputStream.cs @@ -1,10 +1,7 @@ #region Copyright notice and license - // Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/protobuf/ +// 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 @@ -31,7 +28,6 @@ // 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; diff --git a/csharp/src/ProtocolBuffers/Collections/ReadOnlyDictionary.cs b/csharp/src/ProtocolBuffers/Collections/ReadOnlyDictionary.cs index cf3ff83c..84360667 100644 --- a/csharp/src/ProtocolBuffers/Collections/ReadOnlyDictionary.cs +++ b/csharp/src/ProtocolBuffers/Collections/ReadOnlyDictionary.cs @@ -1,8 +1,7 @@ +#region Copyright notice and license // Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/protobuf/ +// 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 @@ -29,6 +28,8 @@ // 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.Collections; using System.Collections.Generic; diff --git a/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs b/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs index 0d82e3bc..ed311494 100644 --- a/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs +++ b/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs @@ -1,4 +1,36 @@ -using System; +#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 System; using System.Collections; using System.Collections.Generic; diff --git a/csharp/src/ProtocolBuffers/DescriptorProtos/IDescriptorProto.cs b/csharp/src/ProtocolBuffers/DescriptorProtos/IDescriptorProto.cs index 1f7c17fe..c0f27427 100644 --- a/csharp/src/ProtocolBuffers/DescriptorProtos/IDescriptorProto.cs +++ b/csharp/src/ProtocolBuffers/DescriptorProtos/IDescriptorProto.cs @@ -1,8 +1,7 @@ +#region Copyright notice and license // Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/protobuf/ +// 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 @@ -29,6 +28,8 @@ // 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.DescriptorProtos { /// diff --git a/csharp/src/ProtocolBuffers/DescriptorProtos/PartialClasses.cs b/csharp/src/ProtocolBuffers/DescriptorProtos/PartialClasses.cs index 9c84aa9d..15f339ba 100644 --- a/csharp/src/ProtocolBuffers/DescriptorProtos/PartialClasses.cs +++ b/csharp/src/ProtocolBuffers/DescriptorProtos/PartialClasses.cs @@ -1,8 +1,7 @@ +#region Copyright notice and license // Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/protobuf/ +// 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 @@ -29,6 +28,7 @@ // 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 // This file just contains partial classes for each of the // autogenerated classes, so that they implement diff --git a/csharp/src/ProtocolBuffers/Descriptors/DescriptorBase.cs b/csharp/src/ProtocolBuffers/Descriptors/DescriptorBase.cs index 39f6d843..ccde34ab 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/DescriptorBase.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/DescriptorBase.cs @@ -1,8 +1,7 @@ +#region Copyright notice and license // Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/protobuf/ +// 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 @@ -29,6 +28,8 @@ // 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 Google.Protobuf.DescriptorProtos; namespace Google.Protobuf.Descriptors diff --git a/csharp/src/ProtocolBuffers/Descriptors/DescriptorPool.cs b/csharp/src/ProtocolBuffers/Descriptors/DescriptorPool.cs index 02b59d76..57c4ba03 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/DescriptorPool.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/DescriptorPool.cs @@ -1,8 +1,7 @@ +#region Copyright notice and license // Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/protobuf/ +// 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 @@ -29,6 +28,8 @@ // 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.Collections.Generic; using System.Text; diff --git a/csharp/src/ProtocolBuffers/Descriptors/DescriptorUtil.cs b/csharp/src/ProtocolBuffers/Descriptors/DescriptorUtil.cs index db3e21f5..eb4ced60 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/DescriptorUtil.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/DescriptorUtil.cs @@ -1,8 +1,7 @@ +#region Copyright notice and license // Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/protobuf/ +// 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 @@ -29,6 +28,8 @@ // 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.Collections.Generic; using System.Collections.ObjectModel; diff --git a/csharp/src/ProtocolBuffers/Descriptors/DescriptorValidationException.cs b/csharp/src/ProtocolBuffers/Descriptors/DescriptorValidationException.cs index 08516951..855eda61 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/DescriptorValidationException.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/DescriptorValidationException.cs @@ -1,8 +1,7 @@ +#region Copyright notice and license // Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/protobuf/ +// 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 @@ -29,6 +28,8 @@ // 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; namespace Google.Protobuf.Descriptors diff --git a/csharp/src/ProtocolBuffers/Descriptors/EnumDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/EnumDescriptor.cs index 3f2abcaa..9f10990b 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/EnumDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/EnumDescriptor.cs @@ -1,8 +1,7 @@ +#region Copyright notice and license // Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/protobuf/ +// 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 @@ -29,6 +28,8 @@ // 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.Collections.Generic; using Google.Protobuf.DescriptorProtos; diff --git a/csharp/src/ProtocolBuffers/Descriptors/EnumValueDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/EnumValueDescriptor.cs index 6a5eb558..b553ee55 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/EnumValueDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/EnumValueDescriptor.cs @@ -1,8 +1,7 @@ +#region Copyright notice and license // Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/protobuf/ +// 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 @@ -29,6 +28,8 @@ // 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 Google.Protobuf.DescriptorProtos; namespace Google.Protobuf.Descriptors diff --git a/csharp/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs index 9605ee9a..2f2c5806 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs @@ -1,8 +1,7 @@ +#region Copyright notice and license // Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/protobuf/ +// 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 @@ -29,10 +28,9 @@ // 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.Collections.Generic; -using System.Reflection; -using Google.Protobuf.Collections; using Google.Protobuf.DescriptorProtos; namespace Google.Protobuf.Descriptors diff --git a/csharp/src/ProtocolBuffers/Descriptors/FieldType.cs b/csharp/src/ProtocolBuffers/Descriptors/FieldType.cs index 628a6f78..69851464 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/FieldType.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/FieldType.cs @@ -1,8 +1,7 @@ +#region Copyright notice and license // Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/protobuf/ +// 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 @@ -29,6 +28,7 @@ // 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.Descriptors { diff --git a/csharp/src/ProtocolBuffers/Descriptors/FileDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/FileDescriptor.cs index 5c933818..7da14a54 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/FileDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/FileDescriptor.cs @@ -1,8 +1,7 @@ +#region Copyright notice and license // Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/protobuf/ +// 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 @@ -29,10 +28,11 @@ // 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.Collections.Generic; using System.Collections.ObjectModel; -using System.IO; using Google.Protobuf.DescriptorProtos; using FileOptions = Google.Protobuf.DescriptorProtos.FileOptions; diff --git a/csharp/src/ProtocolBuffers/Descriptors/IDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/IDescriptor.cs index afed09a9..2c2db127 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/IDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/IDescriptor.cs @@ -1,8 +1,7 @@ +#region Copyright notice and license // Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/protobuf/ +// 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 @@ -29,6 +28,7 @@ // 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.Descriptors { diff --git a/csharp/src/ProtocolBuffers/Descriptors/IndexedDescriptorBase.cs b/csharp/src/ProtocolBuffers/Descriptors/IndexedDescriptorBase.cs index 3bc3a911..6c515726 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/IndexedDescriptorBase.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/IndexedDescriptorBase.cs @@ -1,8 +1,7 @@ +#region Copyright notice and license // Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/protobuf/ +// 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 @@ -29,6 +28,8 @@ // 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 Google.Protobuf.DescriptorProtos; namespace Google.Protobuf.Descriptors diff --git a/csharp/src/ProtocolBuffers/Descriptors/MessageDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/MessageDescriptor.cs index 747cdc9a..cbf4c0f2 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/MessageDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/MessageDescriptor.cs @@ -1,8 +1,7 @@ +#region Copyright notice and license // Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/protobuf/ +// 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 @@ -29,6 +28,8 @@ // 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.Collections.Generic; using Google.Protobuf.DescriptorProtos; diff --git a/csharp/src/ProtocolBuffers/Descriptors/MethodDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/MethodDescriptor.cs index c7c5f9db..6a4ad4ea 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/MethodDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/MethodDescriptor.cs @@ -1,8 +1,7 @@ +#region Copyright notice and license // Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/protobuf/ +// 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 @@ -29,6 +28,8 @@ // 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 Google.Protobuf.DescriptorProtos; namespace Google.Protobuf.Descriptors diff --git a/csharp/src/ProtocolBuffers/Descriptors/OneofDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/OneofDescriptor.cs index 8997cb63..ab3b76ec 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/OneofDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/OneofDescriptor.cs @@ -1,6 +1,7 @@ -// Protocol Buffers - Google's data interchange format +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format // Copyright 2015 Google Inc. All rights reserved. -// Author: jieluo@google.com (Jie Luo) +// 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 @@ -27,10 +28,9 @@ // 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. -using System; +#endregion + using System.Collections.Generic; -using System.Linq; -using System.Text; using Google.Protobuf.DescriptorProtos; namespace Google.Protobuf.Descriptors diff --git a/csharp/src/ProtocolBuffers/Descriptors/PackageDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/PackageDescriptor.cs index f63b9cf4..9af677d7 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/PackageDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/PackageDescriptor.cs @@ -1,8 +1,7 @@ +#region Copyright notice and license // Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/protobuf/ +// 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 @@ -29,6 +28,7 @@ // 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.Descriptors { diff --git a/csharp/src/ProtocolBuffers/Descriptors/ServiceDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/ServiceDescriptor.cs index 52a5cb8f..ef712b46 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/ServiceDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/ServiceDescriptor.cs @@ -1,8 +1,7 @@ +#region Copyright notice and license // Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/protobuf/ +// 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 @@ -29,6 +28,8 @@ // 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.Collections.Generic; using Google.Protobuf.DescriptorProtos; diff --git a/csharp/src/ProtocolBuffers/FieldAccess/FieldAccessorBase.cs b/csharp/src/ProtocolBuffers/FieldAccess/FieldAccessorBase.cs index 51b94931..73d777b2 100644 --- a/csharp/src/ProtocolBuffers/FieldAccess/FieldAccessorBase.cs +++ b/csharp/src/ProtocolBuffers/FieldAccess/FieldAccessorBase.cs @@ -1,10 +1,37 @@ -using System; -using System.Collections.Generic; -using System.Linq; +#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 System; using System.Reflection; -using System.Text; -using Google.Protobuf; -using Google.Protobuf.FieldAccess; namespace Google.Protobuf.FieldAccess { diff --git a/csharp/src/ProtocolBuffers/FieldAccess/FieldAccessorTable.cs b/csharp/src/ProtocolBuffers/FieldAccess/FieldAccessorTable.cs index e463f486..6379ff25 100644 --- a/csharp/src/ProtocolBuffers/FieldAccess/FieldAccessorTable.cs +++ b/csharp/src/ProtocolBuffers/FieldAccess/FieldAccessorTable.cs @@ -1,8 +1,7 @@ +#region Copyright notice and license // Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/protobuf/ +// 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 @@ -29,6 +28,8 @@ // 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 Google.Protobuf.Descriptors; diff --git a/csharp/src/ProtocolBuffers/FieldAccess/IFieldAccessor.cs b/csharp/src/ProtocolBuffers/FieldAccess/IFieldAccessor.cs index 7767fb02..61838543 100644 --- a/csharp/src/ProtocolBuffers/FieldAccess/IFieldAccessor.cs +++ b/csharp/src/ProtocolBuffers/FieldAccess/IFieldAccessor.cs @@ -1,8 +1,7 @@ +#region Copyright notice and license // Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/protobuf/ +// 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 @@ -29,6 +28,7 @@ // 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.FieldAccess { diff --git a/csharp/src/ProtocolBuffers/FieldAccess/OneofAccessor.cs b/csharp/src/ProtocolBuffers/FieldAccess/OneofAccessor.cs index 85a929b7..feaa6232 100644 --- a/csharp/src/ProtocolBuffers/FieldAccess/OneofAccessor.cs +++ b/csharp/src/ProtocolBuffers/FieldAccess/OneofAccessor.cs @@ -1,6 +1,7 @@ -// Protocol Buffers - Google's data interchange format +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format // Copyright 2015 Google Inc. All rights reserved. -// Author: jieluo@google.com (Jie Luo) +// 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 @@ -27,9 +28,7 @@ // 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. -using System; -using System.Reflection; -using Google.Protobuf.Descriptors; +#endregion namespace Google.Protobuf.FieldAccess { diff --git a/csharp/src/ProtocolBuffers/FieldAccess/ReflectionUtil.cs b/csharp/src/ProtocolBuffers/FieldAccess/ReflectionUtil.cs index b3d1c90d..29399b0c 100644 --- a/csharp/src/ProtocolBuffers/FieldAccess/ReflectionUtil.cs +++ b/csharp/src/ProtocolBuffers/FieldAccess/ReflectionUtil.cs @@ -1,8 +1,7 @@ +#region Copyright notice and license // Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/protobuf/ +// 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 @@ -29,6 +28,8 @@ // 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.Reflection; diff --git a/csharp/src/ProtocolBuffers/FieldAccess/RepeatedFieldAccessor.cs b/csharp/src/ProtocolBuffers/FieldAccess/RepeatedFieldAccessor.cs index aea721de..b12278f9 100644 --- a/csharp/src/ProtocolBuffers/FieldAccess/RepeatedFieldAccessor.cs +++ b/csharp/src/ProtocolBuffers/FieldAccess/RepeatedFieldAccessor.cs @@ -1,9 +1,37 @@ -using System; +#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 System; using System.Collections; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Google.Protobuf; namespace Google.Protobuf.FieldAccess { diff --git a/csharp/src/ProtocolBuffers/FieldAccess/SingleFieldAccessor.cs b/csharp/src/ProtocolBuffers/FieldAccess/SingleFieldAccessor.cs index a352d3a2..7a8f726e 100644 --- a/csharp/src/ProtocolBuffers/FieldAccess/SingleFieldAccessor.cs +++ b/csharp/src/ProtocolBuffers/FieldAccess/SingleFieldAccessor.cs @@ -1,11 +1,38 @@ -using System; -using System.Collections.Generic; -using System.Linq; +#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 System; using System.Reflection; -using System.Text; -using Google.Protobuf; using Google.Protobuf.Descriptors; -using Google.Protobuf.FieldAccess; namespace Google.Protobuf.FieldAccess { diff --git a/csharp/src/ProtocolBuffers/FieldCodec.cs b/csharp/src/ProtocolBuffers/FieldCodec.cs index f075dbbf..2cebc1bb 100644 --- a/csharp/src/ProtocolBuffers/FieldCodec.cs +++ b/csharp/src/ProtocolBuffers/FieldCodec.cs @@ -1,4 +1,36 @@ -using System; +#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 System; using System.Collections.Generic; namespace Google.Protobuf diff --git a/csharp/src/ProtocolBuffers/FrameworkPortability.cs b/csharp/src/ProtocolBuffers/FrameworkPortability.cs index 06246a9e..f3da5333 100644 --- a/csharp/src/ProtocolBuffers/FrameworkPortability.cs +++ b/csharp/src/ProtocolBuffers/FrameworkPortability.cs @@ -1,10 +1,7 @@ #region Copyright notice and license - // Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/protobuf/ +// 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 @@ -31,7 +28,6 @@ // 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; diff --git a/csharp/src/ProtocolBuffers/Freezable.cs b/csharp/src/ProtocolBuffers/Freezable.cs index 40b4398a..d16e1b42 100644 --- a/csharp/src/ProtocolBuffers/Freezable.cs +++ b/csharp/src/ProtocolBuffers/Freezable.cs @@ -1,8 +1,7 @@ #region Copyright notice and license - // Protocol Buffers - Google's data interchange format // Copyright 2015 Google Inc. All rights reserved. -// http://github.com/google/protobuf +// 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 @@ -29,7 +28,6 @@ // 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; diff --git a/csharp/src/ProtocolBuffers/IMessage.cs b/csharp/src/ProtocolBuffers/IMessage.cs index d606aee1..27bcc117 100644 --- a/csharp/src/ProtocolBuffers/IMessage.cs +++ b/csharp/src/ProtocolBuffers/IMessage.cs @@ -1,10 +1,7 @@ #region Copyright notice and license - // Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/protobuf/ +// 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 @@ -31,7 +28,6 @@ // 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; diff --git a/csharp/src/ProtocolBuffers/InvalidProtocolBufferException.cs b/csharp/src/ProtocolBuffers/InvalidProtocolBufferException.cs index 97e80cac..87b283f2 100644 --- a/csharp/src/ProtocolBuffers/InvalidProtocolBufferException.cs +++ b/csharp/src/ProtocolBuffers/InvalidProtocolBufferException.cs @@ -1,10 +1,7 @@ #region Copyright notice and license - // Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/protobuf/ +// 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 @@ -31,7 +28,6 @@ // 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; diff --git a/csharp/src/ProtocolBuffers/LimitedInputStream.cs b/csharp/src/ProtocolBuffers/LimitedInputStream.cs index cfbf47de..f11d19d9 100644 --- a/csharp/src/ProtocolBuffers/LimitedInputStream.cs +++ b/csharp/src/ProtocolBuffers/LimitedInputStream.cs @@ -1,4 +1,36 @@ -using System; +#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 System; using System.IO; namespace Google.Protobuf diff --git a/csharp/src/ProtocolBuffers/MessageExtensions.cs b/csharp/src/ProtocolBuffers/MessageExtensions.cs index 253c18ae..ee2863d1 100644 --- a/csharp/src/ProtocolBuffers/MessageExtensions.cs +++ b/csharp/src/ProtocolBuffers/MessageExtensions.cs @@ -1,4 +1,36 @@ -using System.IO; +#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 System.IO; namespace Google.Protobuf { diff --git a/csharp/src/ProtocolBuffers/MessageParser.cs b/csharp/src/ProtocolBuffers/MessageParser.cs index 18cda2dc..5407de06 100644 --- a/csharp/src/ProtocolBuffers/MessageParser.cs +++ b/csharp/src/ProtocolBuffers/MessageParser.cs @@ -1,4 +1,36 @@ -using System; +#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 System; using System.IO; namespace Google.Protobuf diff --git a/csharp/src/ProtocolBuffers/Properties/AssemblyInfo.cs b/csharp/src/ProtocolBuffers/Properties/AssemblyInfo.cs index 27ccddbc..c6918e70 100644 --- a/csharp/src/ProtocolBuffers/Properties/AssemblyInfo.cs +++ b/csharp/src/ProtocolBuffers/Properties/AssemblyInfo.cs @@ -1,8 +1,7 @@ +#region Copyright notice and license // Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/protobuf/ +// 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 @@ -29,15 +28,14 @@ // 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. -using System; +#endregion + using System.Reflection; -using System.Runtime.InteropServices; using System.Runtime.CompilerServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. -using System.Security; [assembly: AssemblyTitle("ProtocolBuffers")] [assembly: AssemblyDescription("")] diff --git a/csharp/src/ProtocolBuffers/ThrowHelper.cs b/csharp/src/ProtocolBuffers/ThrowHelper.cs index 00ef23e5..62d9ea60 100644 --- a/csharp/src/ProtocolBuffers/ThrowHelper.cs +++ b/csharp/src/ProtocolBuffers/ThrowHelper.cs @@ -1,10 +1,7 @@ #region Copyright notice and license - // Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/protobuf/ +// 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 @@ -31,7 +28,6 @@ // 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; diff --git a/csharp/src/ProtocolBuffers/WireFormat.cs b/csharp/src/ProtocolBuffers/WireFormat.cs index 974665f1..7489c2fc 100644 --- a/csharp/src/ProtocolBuffers/WireFormat.cs +++ b/csharp/src/ProtocolBuffers/WireFormat.cs @@ -1,10 +1,7 @@ #region Copyright notice and license - // Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/protobuf/ +// 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 @@ -31,7 +28,6 @@ // 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; -- cgit v1.2.3 From 38d8d3948a2bd83f36d85fb67e1d3c621c5db571 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Tue, 30 Jun 2015 18:43:57 +0100 Subject: Remove unused code in C# codegen --- .../protobuf/compiler/csharp/csharp_helpers.cc | 42 +--------------------- .../protobuf/compiler/csharp/csharp_helpers.h | 6 ---- 2 files changed, 1 insertion(+), 47 deletions(-) diff --git a/src/google/protobuf/compiler/csharp/csharp_helpers.cc b/src/google/protobuf/compiler/csharp/csharp_helpers.cc index 156ee328..da6a7633 100644 --- a/src/google/protobuf/compiler/csharp/csharp_helpers.cc +++ b/src/google/protobuf/compiler/csharp/csharp_helpers.cc @@ -391,47 +391,7 @@ FieldGeneratorBase* CreateFieldGenerator(const FieldDescriptor* descriptor, } } -bool HasRequiredFields(const Descriptor* descriptor, std::set* already_seen) { - if (already_seen->find(descriptor) != already_seen->end()) { - // The type is already in cache. This means that either: - // a. The type has no required fields. - // b. We are in the midst of checking if the type has required fields, - // somewhere up the stack. In this case, we know that if the type - // has any required fields, they'll be found when we return to it, - // and the whole call to HasRequiredFields() will return true. - // Therefore, we don't have to check if this type has required fields - // here. - return false; - } - already_seen->insert(descriptor); - - // If the type has extensions, an extension with message type could contain - // required fields, so we have to be conservative and assume such an - // extension exists. - if (descriptor->extension_count() > 0) { - return true; - } - - for (int i = 0; i < descriptor->field_count(); i++) { - const FieldDescriptor* field = descriptor->field(i); - if (field->is_required()) { - return true; - } - if (GetCSharpType(field->type()) == CSHARPTYPE_MESSAGE) { - if (HasRequiredFields(field->message_type(), already_seen)) { - return true; - } - } - } - return false; -} - -bool HasRequiredFields(const Descriptor* descriptor) { - std::set already_seen; - return HasRequiredFields(descriptor, &already_seen); -} - -} // namespace java +} // namespace csharp } // namespace compiler } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/compiler/csharp/csharp_helpers.h b/src/google/protobuf/compiler/csharp/csharp_helpers.h index d2ee8fbe..a8c1fa18 100644 --- a/src/google/protobuf/compiler/csharp/csharp_helpers.h +++ b/src/google/protobuf/compiler/csharp/csharp_helpers.h @@ -101,12 +101,6 @@ uint FixedMakeTag(const FieldDescriptor* descriptor); FieldGeneratorBase* CreateFieldGenerator(const FieldDescriptor* descriptor, int fieldOrdinal); -bool HasRequiredFields(const Descriptor* descriptor); - -inline bool SupportFieldPresence(const FileDescriptor* file) { - return file->syntax() != FileDescriptor::SYNTAX_PROTO3; -} - } // namespace csharp } // namespace compiler } // namespace protobuf -- cgit v1.2.3 From 3cce11ce1c349ca3674b579acd2ced1db8ad81aa Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Thu, 9 Jul 2015 08:12:44 +0100 Subject: Minor fix-ups as suggested in PR #560. - Added new line at the end of SampleEnum - Moved GeneratedMessageTest.GetSampleMessage to a new class, SampleMessages, and renamed it to CreateFullTestAllTypes. --- .../ProtocolBuffers.Test/CodedInputStreamTest.cs | 2 +- .../ProtocolBuffers.Test/CodedOutputStreamTest.cs | 2 +- .../ProtocolBuffers.Test/GeneratedMessageTest.cs | 55 ------------ .../ProtocolBuffers.Test.csproj | 1 + csharp/src/ProtocolBuffers.Test/SampleEnum.cs | 2 +- csharp/src/ProtocolBuffers.Test/SampleMessages.cs | 99 ++++++++++++++++++++++ 6 files changed, 103 insertions(+), 58 deletions(-) create mode 100644 csharp/src/ProtocolBuffers.Test/SampleMessages.cs diff --git a/csharp/src/ProtocolBuffers.Test/CodedInputStreamTest.cs b/csharp/src/ProtocolBuffers.Test/CodedInputStreamTest.cs index b15a25b1..fa88d407 100644 --- a/csharp/src/ProtocolBuffers.Test/CodedInputStreamTest.cs +++ b/csharp/src/ProtocolBuffers.Test/CodedInputStreamTest.cs @@ -229,7 +229,7 @@ namespace Google.Protobuf [Test] public void ReadWholeMessage_VaryingBlockSizes() { - TestAllTypes message = GeneratedMessageTest.GetSampleMessage(); + TestAllTypes message = SampleMessages.CreateFullTestAllTypes(); byte[] rawBytes = message.ToByteArray(); Assert.AreEqual(rawBytes.Length, message.CalculateSize()); diff --git a/csharp/src/ProtocolBuffers.Test/CodedOutputStreamTest.cs b/csharp/src/ProtocolBuffers.Test/CodedOutputStreamTest.cs index 02c998cb..c3d92a66 100644 --- a/csharp/src/ProtocolBuffers.Test/CodedOutputStreamTest.cs +++ b/csharp/src/ProtocolBuffers.Test/CodedOutputStreamTest.cs @@ -193,7 +193,7 @@ namespace Google.Protobuf [Test] public void WriteWholeMessage_VaryingBlockSizes() { - TestAllTypes message = GeneratedMessageTest.GetSampleMessage(); + TestAllTypes message = SampleMessages.CreateFullTestAllTypes(); byte[] rawBytes = message.ToByteArray(); diff --git a/csharp/src/ProtocolBuffers.Test/GeneratedMessageTest.cs b/csharp/src/ProtocolBuffers.Test/GeneratedMessageTest.cs index b42fc31c..e98ffabc 100644 --- a/csharp/src/ProtocolBuffers.Test/GeneratedMessageTest.cs +++ b/csharp/src/ProtocolBuffers.Test/GeneratedMessageTest.cs @@ -42,61 +42,6 @@ namespace Google.Protobuf /// public class GeneratedMessageTest { - /// - /// Returns a sample TestAllTypes with all fields populated - /// - public static TestAllTypes GetSampleMessage() - { - return new TestAllTypes - { - SingleBool = true, - SingleBytes = ByteString.CopyFrom(1, 2, 3, 4), - SingleDouble = 23.5, - SingleFixed32 = 23, - SingleFixed64 = 1234567890123, - SingleFloat = 12.25f, - SingleForeignEnum = ForeignEnum.FOREIGN_BAR, - SingleForeignMessage = new ForeignMessage { C = 10 }, - SingleImportEnum = ImportEnum.IMPORT_BAZ, - SingleImportMessage = new ImportMessage { D = 20 }, - SingleInt32 = 100, - SingleInt64 = 3210987654321, - SingleNestedEnum = TestAllTypes.Types.NestedEnum.FOO, - SingleNestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 35 }, - SinglePublicImportMessage = new PublicImportMessage { E = 54 }, - SingleSfixed32 = -123, - SingleSfixed64 = -12345678901234, - SingleSint32 = -456, - SingleSint64 = -12345678901235, - SingleString = "test", - SingleUint32 = uint.MaxValue, - SingleUint64 = ulong.MaxValue, - RepeatedBool = { true, false }, - RepeatedBytes = { ByteString.CopyFrom(1, 2, 3, 4), ByteString.CopyFrom(5, 6), ByteString.CopyFrom(new byte[1000]) }, - RepeatedDouble = { -12.25, 23.5 }, - RepeatedFixed32 = { uint.MaxValue, 23 }, - RepeatedFixed64 = { ulong.MaxValue, 1234567890123 }, - RepeatedFloat = { 100f, 12.25f }, - RepeatedForeignEnum = { ForeignEnum.FOREIGN_FOO, ForeignEnum.FOREIGN_BAR }, - RepeatedForeignMessage = { new ForeignMessage(), new ForeignMessage { C = 10 } }, - RepeatedImportEnum = { ImportEnum.IMPORT_BAZ, ImportEnum.IMPORT_ENUM_UNSPECIFIED }, - RepeatedImportMessage = { new ImportMessage { D = 20 }, new ImportMessage { D = 25 } }, - RepeatedInt32 = { 100, 200 }, - RepeatedInt64 = { 3210987654321, long.MaxValue }, - RepeatedNestedEnum = { TestAllTypes.Types.NestedEnum.FOO, TestAllTypes.Types.NestedEnum.NEG }, - RepeatedNestedMessage = { new TestAllTypes.Types.NestedMessage { Bb = 35 }, new TestAllTypes.Types.NestedMessage { Bb = 10 } }, - RepeatedPublicImportMessage = { new PublicImportMessage { E = 54 }, new PublicImportMessage { E = -1 } }, - RepeatedSfixed32 = { -123, 123 }, - RepeatedSfixed64 = { -12345678901234, 12345678901234 }, - RepeatedSint32 = { -456, 100 }, - RepeatedSint64 = { -12345678901235, 123 }, - RepeatedString = { "foo", "bar" }, - RepeatedUint32 = { uint.MaxValue, uint.MinValue }, - RepeatedUint64 = { ulong.MaxValue, uint.MinValue }, - OneofString = "Oneof string" - }; - } - [Test] public void EmptyMessageFieldDistinctFromMissingMessageField() { diff --git a/csharp/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj b/csharp/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj index ae7d7575..b02abe70 100644 --- a/csharp/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj +++ b/csharp/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj @@ -81,6 +81,7 @@ + diff --git a/csharp/src/ProtocolBuffers.Test/SampleEnum.cs b/csharp/src/ProtocolBuffers.Test/SampleEnum.cs index 001f9b08..77447afa 100644 --- a/csharp/src/ProtocolBuffers.Test/SampleEnum.cs +++ b/csharp/src/ProtocolBuffers.Test/SampleEnum.cs @@ -39,4 +39,4 @@ namespace Google.Protobuf None = 0, PositiveValue = 3 } -} \ No newline at end of file +} diff --git a/csharp/src/ProtocolBuffers.Test/SampleMessages.cs b/csharp/src/ProtocolBuffers.Test/SampleMessages.cs new file mode 100644 index 00000000..8a9c7f86 --- /dev/null +++ b/csharp/src/ProtocolBuffers.Test/SampleMessages.cs @@ -0,0 +1,99 @@ +#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 System; +using Google.Protobuf.TestProtos; + +namespace Google.Protobuf +{ + /// + /// Helper methods to create sample instances of types generated from unit test messages. + /// + public class SampleMessages + { + /// + /// Creates a new sample TestAllTypes message with all fields populated. + /// The "oneof" field is populated with the string property (OneofString). + /// + public static TestAllTypes CreateFullTestAllTypes() + { + return new TestAllTypes + { + SingleBool = true, + SingleBytes = ByteString.CopyFrom(1, 2, 3, 4), + SingleDouble = 23.5, + SingleFixed32 = 23, + SingleFixed64 = 1234567890123, + SingleFloat = 12.25f, + SingleForeignEnum = ForeignEnum.FOREIGN_BAR, + SingleForeignMessage = new ForeignMessage { C = 10 }, + SingleImportEnum = ImportEnum.IMPORT_BAZ, + SingleImportMessage = new ImportMessage { D = 20 }, + SingleInt32 = 100, + SingleInt64 = 3210987654321, + SingleNestedEnum = TestAllTypes.Types.NestedEnum.FOO, + SingleNestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 35 }, + SinglePublicImportMessage = new PublicImportMessage { E = 54 }, + SingleSfixed32 = -123, + SingleSfixed64 = -12345678901234, + SingleSint32 = -456, + SingleSint64 = -12345678901235, + SingleString = "test", + SingleUint32 = UInt32.MaxValue, + SingleUint64 = UInt64.MaxValue, + RepeatedBool = { true, false }, + RepeatedBytes = { ByteString.CopyFrom(1, 2, 3, 4), ByteString.CopyFrom(5, 6), ByteString.CopyFrom(new byte[1000]) }, + RepeatedDouble = { -12.25, 23.5 }, + RepeatedFixed32 = { UInt32.MaxValue, 23 }, + RepeatedFixed64 = { UInt64.MaxValue, 1234567890123 }, + RepeatedFloat = { 100f, 12.25f }, + RepeatedForeignEnum = { ForeignEnum.FOREIGN_FOO, ForeignEnum.FOREIGN_BAR }, + RepeatedForeignMessage = { new ForeignMessage(), new ForeignMessage { C = 10 } }, + RepeatedImportEnum = { ImportEnum.IMPORT_BAZ, ImportEnum.IMPORT_ENUM_UNSPECIFIED }, + RepeatedImportMessage = { new ImportMessage { D = 20 }, new ImportMessage { D = 25 } }, + RepeatedInt32 = { 100, 200 }, + RepeatedInt64 = { 3210987654321, Int64.MaxValue }, + RepeatedNestedEnum = { TestAllTypes.Types.NestedEnum.FOO, TestAllTypes.Types.NestedEnum.NEG }, + RepeatedNestedMessage = { new TestAllTypes.Types.NestedMessage { Bb = 35 }, new TestAllTypes.Types.NestedMessage { Bb = 10 } }, + RepeatedPublicImportMessage = { new PublicImportMessage { E = 54 }, new PublicImportMessage { E = -1 } }, + RepeatedSfixed32 = { -123, 123 }, + RepeatedSfixed64 = { -12345678901234, 12345678901234 }, + RepeatedSint32 = { -456, 100 }, + RepeatedSint64 = { -12345678901235, 123 }, + RepeatedString = { "foo", "bar" }, + RepeatedUint32 = { UInt32.MaxValue, UInt32.MinValue }, + RepeatedUint64 = { UInt64.MaxValue, UInt32.MinValue }, + OneofString = "Oneof string" + }; + } + } +} -- cgit v1.2.3 From 78ea98f56f7a0a028e378aee6394549707e199bc Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Wed, 1 Jul 2015 14:47:03 +0100 Subject: Implement reflection properly for fields. - FieldAccessorTable is now non-generic - We don't have a static field per message type in the umbrella class. (Message descriptors are accessed via the file descriptor.) - Removed the "descriptor assigner" complication from the descriptor fixup; without extensions, we don't need it - MapField implements IDictionary (more tests would be good...) - RepeatedField implements IList (more tests would be good) - Use expression trees to build accessors. (Will need to test this on various platforms... probably need a fallback strategy just using reflection directly.) - Added FieldDescriptor.IsMap - Added tests for reflection with generated messages Changes to generated code coming in next commit. --- .../ProtocolBuffers.Test/GeneratedMessageTest.cs | 141 ++++++++++++++++++++- csharp/src/ProtocolBuffers/Collections/MapField.cs | 69 +++++++++- .../ProtocolBuffers/Collections/RepeatedField.cs | 63 ++++++++- .../ProtocolBuffers/Descriptors/FieldDescriptor.cs | 5 + .../ProtocolBuffers/Descriptors/FileDescriptor.cs | 33 +---- .../FieldAccess/FieldAccessorBase.cs | 23 ++-- .../FieldAccess/FieldAccessorTable.cs | 32 +++-- .../ProtocolBuffers/FieldAccess/IFieldAccessor.cs | 32 ++--- .../FieldAccess/MapFieldAccessor.cs | 59 +++++++++ .../ProtocolBuffers/FieldAccess/ReflectionUtil.cs | 110 ++++------------ .../FieldAccess/RepeatedFieldAccessor.cs | 17 +-- .../FieldAccess/SingleFieldAccessor.cs | 64 +++------- csharp/src/ProtocolBuffers/IMessage.cs | 7 +- csharp/src/ProtocolBuffers/ProtocolBuffers.csproj | 1 + .../protobuf/compiler/csharp/csharp_message.cc | 37 +++--- .../compiler/csharp/csharp_umbrella_class.cc | 22 ++-- 16 files changed, 466 insertions(+), 249 deletions(-) create mode 100644 csharp/src/ProtocolBuffers/FieldAccess/MapFieldAccessor.cs diff --git a/csharp/src/ProtocolBuffers.Test/GeneratedMessageTest.cs b/csharp/src/ProtocolBuffers.Test/GeneratedMessageTest.cs index e98ffabc..8c9e0514 100644 --- a/csharp/src/ProtocolBuffers.Test/GeneratedMessageTest.cs +++ b/csharp/src/ProtocolBuffers.Test/GeneratedMessageTest.cs @@ -29,11 +29,13 @@ // (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 Google.Protobuf.TestProtos; using NUnit.Framework; +using System.Collections; +using System.Collections.Generic; namespace Google.Protobuf { @@ -595,5 +597,142 @@ namespace Google.Protobuf Assert.AreEqual(message, message2); Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofUint32, message2.OneofFieldCase); } + + // TODO: Consider moving these tests to a separate reflection test - although they do require generated messages. + + [Test] + public void Reflection_GetValue() + { + var message = GetSampleMessage(); + var fields = message.Fields; + Assert.AreEqual(message.SingleBool, fields[TestAllTypes.SingleBoolFieldNumber].GetValue(message)); + Assert.AreEqual(message.SingleBytes, fields[TestAllTypes.SingleBytesFieldNumber].GetValue(message)); + Assert.AreEqual(message.SingleDouble, fields[TestAllTypes.SingleDoubleFieldNumber].GetValue(message)); + Assert.AreEqual(message.SingleFixed32, fields[TestAllTypes.SingleFixed32FieldNumber].GetValue(message)); + Assert.AreEqual(message.SingleFixed64, fields[TestAllTypes.SingleFixed64FieldNumber].GetValue(message)); + Assert.AreEqual(message.SingleFloat, fields[TestAllTypes.SingleFloatFieldNumber].GetValue(message)); + Assert.AreEqual(message.SingleForeignEnum, fields[TestAllTypes.SingleForeignEnumFieldNumber].GetValue(message)); + Assert.AreEqual(message.SingleForeignMessage, fields[TestAllTypes.SingleForeignMessageFieldNumber].GetValue(message)); + Assert.AreEqual(message.SingleImportEnum, fields[TestAllTypes.SingleImportEnumFieldNumber].GetValue(message)); + Assert.AreEqual(message.SingleImportMessage, fields[TestAllTypes.SingleImportMessageFieldNumber].GetValue(message)); + Assert.AreEqual(message.SingleInt32, fields[TestAllTypes.SingleInt32FieldNumber].GetValue(message)); + Assert.AreEqual(message.SingleInt64, fields[TestAllTypes.SingleInt64FieldNumber].GetValue(message)); + Assert.AreEqual(message.SingleNestedEnum, fields[TestAllTypes.SingleNestedEnumFieldNumber].GetValue(message)); + Assert.AreEqual(message.SingleNestedMessage, fields[TestAllTypes.SingleNestedMessageFieldNumber].GetValue(message)); + Assert.AreEqual(message.SinglePublicImportMessage, fields[TestAllTypes.SinglePublicImportMessageFieldNumber].GetValue(message)); + Assert.AreEqual(message.SingleSint32, fields[TestAllTypes.SingleSint32FieldNumber].GetValue(message)); + Assert.AreEqual(message.SingleSint64, fields[TestAllTypes.SingleSint64FieldNumber].GetValue(message)); + Assert.AreEqual(message.SingleString, fields[TestAllTypes.SingleStringFieldNumber].GetValue(message)); + Assert.AreEqual(message.SingleSfixed32, fields[TestAllTypes.SingleSfixed32FieldNumber].GetValue(message)); + Assert.AreEqual(message.SingleSfixed64, fields[TestAllTypes.SingleSfixed64FieldNumber].GetValue(message)); + Assert.AreEqual(message.SingleUint32, fields[TestAllTypes.SingleUint32FieldNumber].GetValue(message)); + Assert.AreEqual(message.SingleUint64, fields[TestAllTypes.SingleUint64FieldNumber].GetValue(message)); + Assert.AreEqual(message.OneofBytes, fields[TestAllTypes.OneofBytesFieldNumber].GetValue(message)); + Assert.AreEqual(message.OneofString, fields[TestAllTypes.OneofStringFieldNumber].GetValue(message)); + Assert.AreEqual(message.OneofNestedMessage, fields[TestAllTypes.OneofNestedMessageFieldNumber].GetValue(message)); + Assert.AreEqual(message.OneofUint32, fields[TestAllTypes.OneofUint32FieldNumber].GetValue(message)); + + // Just one example for repeated fields - they're all just returning the list + var list = (IList)fields[TestAllTypes.RepeatedInt32FieldNumber].GetValue(message); + Assert.AreEqual(message.RepeatedInt32, list); + Assert.AreEqual(message.RepeatedInt32[0], list[0]); // Just in case there was any doubt... + + // Just a single map field, for the same reason + var mapMessage = new TestMap { MapStringString = { { "key1", "value1" }, { "key2", "value2" } } }; + var dictionary = (IDictionary)mapMessage.Fields[TestMap.MapStringStringFieldNumber].GetValue(mapMessage); + Assert.AreEqual(mapMessage.MapStringString, dictionary); + Assert.AreEqual("value1", dictionary["key1"]); + } + + [Test] + public void Reflection_Clear() + { + var message = GetSampleMessage(); + var fields = message.Fields; + fields[TestAllTypes.SingleBoolFieldNumber].Clear(message); + fields[TestAllTypes.SingleInt32FieldNumber].Clear(message); + fields[TestAllTypes.SingleStringFieldNumber].Clear(message); + fields[TestAllTypes.SingleBytesFieldNumber].Clear(message); + fields[TestAllTypes.SingleForeignEnumFieldNumber].Clear(message); + fields[TestAllTypes.SingleForeignMessageFieldNumber].Clear(message); + fields[TestAllTypes.RepeatedDoubleFieldNumber].Clear(message); + + var expected = new TestAllTypes(GetSampleMessage()) + { + SingleBool = false, + SingleInt32 = 0, + SingleString = "", + SingleBytes = ByteString.Empty, + SingleForeignEnum = 0, + SingleForeignMessage = null, + }; + expected.RepeatedDouble.Clear(); + + Assert.AreEqual(expected, message); + + // Separately, maps. + var mapMessage = new TestMap { MapStringString = { { "key1", "value1" }, { "key2", "value2" } } }; + mapMessage.Fields[TestMap.MapStringStringFieldNumber].Clear(mapMessage); + Assert.AreEqual(0, mapMessage.MapStringString.Count); + } + + [Test] + public void Reflection_SetValue_SingleFields() + { + // Just a sample (primitives, messages, enums, strings, byte strings) + var message = GetSampleMessage(); + var fields = message.Fields; + fields[TestAllTypes.SingleBoolFieldNumber].SetValue(message, false); + fields[TestAllTypes.SingleInt32FieldNumber].SetValue(message, 500); + fields[TestAllTypes.SingleStringFieldNumber].SetValue(message, "It's a string"); + fields[TestAllTypes.SingleBytesFieldNumber].SetValue(message, ByteString.CopyFrom(99, 98, 97)); + fields[TestAllTypes.SingleForeignEnumFieldNumber].SetValue(message, ForeignEnum.FOREIGN_FOO); + fields[TestAllTypes.SingleForeignMessageFieldNumber].SetValue(message, new ForeignMessage { C = 12345 }); + fields[TestAllTypes.SingleDoubleFieldNumber].SetValue(message, 20150701.5); + + var expected = new TestAllTypes(GetSampleMessage()) + { + SingleBool = false, + SingleInt32 = 500, + SingleString = "It's a string", + SingleBytes = ByteString.CopyFrom(99, 98, 97), + SingleForeignEnum = ForeignEnum.FOREIGN_FOO, + SingleForeignMessage = new ForeignMessage { C = 12345 }, + SingleDouble = 20150701.5 + }; + + Assert.AreEqual(expected, message); + } + + [Test] + public void Reflection_SetValue_SingleFields_WrongType() + { + var message = GetSampleMessage(); + var fields = message.Fields; + Assert.Throws(() => fields[TestAllTypes.SingleBoolFieldNumber].SetValue(message, "This isn't a bool")); + } + + [Test] + public void Reflection_SetValue_MapFields() + { + var message = new TestMap(); + var fields = message.Fields; + Assert.Throws(() => fields[TestMap.MapStringStringFieldNumber].SetValue(message, new Dictionary())); + } + + [Test] + public void Reflection_SetValue_RepeatedFields() + { + var message = GetSampleMessage(); + var fields = message.Fields; + Assert.Throws(() => fields[TestAllTypes.RepeatedDoubleFieldNumber].SetValue(message, new double[10])); + } + + [Test] + public void Reflection_GetValue_IncorrectType() + { + var message = GetSampleMessage(); + Assert.Throws(() => message.Fields[TestAllTypes.SingleBoolFieldNumber].GetValue(new TestMap())); + } } } diff --git a/csharp/src/ProtocolBuffers/Collections/MapField.cs b/csharp/src/ProtocolBuffers/Collections/MapField.cs index 6d1097a6..779ff061 100644 --- a/csharp/src/ProtocolBuffers/Collections/MapField.cs +++ b/csharp/src/ProtocolBuffers/Collections/MapField.cs @@ -48,7 +48,7 @@ namespace Google.Protobuf.Collections /// /// Key type in the map. Must be a type supported by Protocol Buffer map keys. /// Value type in the map. Must be a type supported by Protocol Buffers. - public sealed class MapField : IDeepCloneable>, IFreezable, IDictionary, IEquatable> + public sealed class MapField : IDeepCloneable>, IFreezable, IDictionary, IEquatable>, IDictionary { // TODO: Don't create the map/list until we have an entry. (Assume many maps will be empty.) private bool frozen; @@ -64,7 +64,7 @@ namespace Google.Protobuf.Collections { foreach (var pair in list) { - clone.Add(pair.Key, pair.Value == null ? pair.Value : ((IDeepCloneable) pair.Value).Clone()); + clone.Add(pair.Key, pair.Value == null ? pair.Value : ((IDeepCloneable)pair.Value).Clone()); } } else @@ -309,7 +309,7 @@ namespace Google.Protobuf.Collections /// /// Stream to read from /// Codec describing how the key/value pairs are encoded - public void AddEntriesFrom(CodedInputStream input, Codec codec) + public void AddEntriesFrom(CodedInputStream input, Codec codec) { var adapter = new Codec.MessageAdapter(codec); do @@ -318,7 +318,7 @@ namespace Google.Protobuf.Collections input.ReadMessage(adapter); this[adapter.Key] = adapter.Value; } while (input.MaybeConsumeTag(codec.MapTag)); - } + } public void WriteTo(CodedOutputStream output, Codec codec) { @@ -350,6 +350,67 @@ namespace Google.Protobuf.Collections return size; } + #region IDictionary explicit interface implementation + void IDictionary.Add(object key, object value) + { + Add((TKey)key, (TValue)value); + } + + bool IDictionary.Contains(object key) + { + if (!(key is TKey)) + { + return false; + } + return ContainsKey((TKey)key); + } + + IDictionaryEnumerator IDictionary.GetEnumerator() + { + throw new NotImplementedException(); + } + + void IDictionary.Remove(object key) + { + if (!(key is TKey)) + { + return; + } + Remove((TKey)key); + } + + void ICollection.CopyTo(Array array, int index) + { + throw new NotImplementedException(); + } + + bool IDictionary.IsFixedSize { get { return IsFrozen; } } + + ICollection IDictionary.Keys { get { return (ICollection)Keys; } } + + ICollection IDictionary.Values { get { return (ICollection)Values; } } + + bool ICollection.IsSynchronized { get { return false; } } + + object ICollection.SyncRoot { get { return null; } } + + object IDictionary.this[object key] + { + get + { + if (!(key is TKey)) + { + return null; + } + TValue value; + TryGetValue((TKey)key, out value); + return value; + } + + set { this[(TKey)key] = (TValue)value; } + } + #endregion + /// /// A codec for a specific map field. This contains all the information required to encoded and /// decode the nested messages. diff --git a/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs b/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs index ed311494..ebc711de 100644 --- a/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs +++ b/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs @@ -41,7 +41,7 @@ namespace Google.Protobuf.Collections /// restrictions (no null values) and capabilities (deep cloning and freezing). /// /// The element type of the repeated field. - public sealed class RepeatedField : IList, IDeepCloneable>, IEquatable>, IFreezable + public sealed class RepeatedField : IList, IList, IDeepCloneable>, IEquatable>, IFreezable { private static readonly T[] EmptyArray = new T[0]; @@ -415,7 +415,66 @@ namespace Google.Protobuf.Collections array[index] = value; } } - + + #region Explicit interface implementation for IList and ICollection. + bool IList.IsFixedSize { get { return IsFrozen; } } + + void ICollection.CopyTo(Array array, int index) + { + ThrowHelper.ThrowIfNull(array, "array"); + T[] strongArray = array as T[]; + if (strongArray == null) + { + throw new ArgumentException("Array is of incorrect type", "array"); + } + CopyTo(strongArray, index); + } + + bool ICollection.IsSynchronized { get { return false; } } + + object ICollection.SyncRoot { get { return null; } } + + object IList.this[int index] + { + get { return this[index]; } + set { this[index] = (T)value; } + } + + int IList.Add(object value) + { + Add((T) value); + return count - 1; + } + + bool IList.Contains(object value) + { + return (value is T && Contains((T)value)); + } + + int IList.IndexOf(object value) + { + if (!(value is T)) + { + return -1; + } + return IndexOf((T)value); + } + + void IList.Insert(int index, object value) + { + Insert(index, (T) value); + } + + void IList.Remove(object value) + { + if (!(value is T)) + { + return; + } + Remove((T)value); + } + #endregion + public struct Enumerator : IEnumerator { private int index; diff --git a/csharp/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs index 2f2c5806..3b36a280 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs @@ -131,6 +131,11 @@ namespace Google.Protobuf.Descriptors get { return Proto.Label == FieldDescriptorProto.Types.Label.LABEL_REPEATED; } } + public bool IsMap + { + get { return fieldType == FieldType.Message && messageType.Options != null && messageType.Options.MapEntry; } + } + public bool IsPacked { get { return Proto.Options.Packed; } diff --git a/csharp/src/ProtocolBuffers/Descriptors/FileDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/FileDescriptor.cs index 7da14a54..a6320a31 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/FileDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/FileDescriptor.cs @@ -336,33 +336,8 @@ namespace Google.Protobuf.Descriptors } } - /// - /// This method is to be called by generated code only. It is equivalent - /// to BuildFrom except that the FileDescriptorProto is encoded in - /// protocol buffer wire format. This overload is maintained for backward - /// compatibility with source code generated before the custom options were available - /// (and working). - /// - public static FileDescriptor InternalBuildGeneratedFileFrom(byte[] descriptorData, FileDescriptor[] dependencies) - { - return InternalBuildGeneratedFileFrom(descriptorData, dependencies, x => { }); - } - - /// - /// This delegate should be used by generated code only. When calling - /// FileDescriptor.InternalBuildGeneratedFileFrom, the caller can provide - /// a callback which assigns the global variables defined in the generated code - /// which point at parts of the FileDescriptor. The callback returns an - /// Extension Registry which contains any extensions which might be used in - /// the descriptor - that is, extensions of the various "Options" messages defined - /// in descriptor.proto. The callback may also return null to indicate that - /// no extensions are used in the descriptor. - /// - public delegate void InternalDescriptorAssigner(FileDescriptor descriptor); - public static FileDescriptor InternalBuildGeneratedFileFrom(byte[] descriptorData, - FileDescriptor[] dependencies, - InternalDescriptorAssigner descriptorAssigner) + FileDescriptor[] dependencies) { FileDescriptorProto proto; try @@ -374,20 +349,16 @@ namespace Google.Protobuf.Descriptors throw new ArgumentException("Failed to parse protocol buffer descriptor for generated code.", e); } - FileDescriptor result; try { // When building descriptors for generated code, we allow unknown // dependencies by default. - result = BuildFrom(proto, dependencies, true); + return BuildFrom(proto, dependencies, true); } catch (DescriptorValidationException e) { throw new ArgumentException("Invalid embedded descriptor for \"" + proto.Name + "\".", e); } - - descriptorAssigner(result); - return result; } public override string ToString() diff --git a/csharp/src/ProtocolBuffers/FieldAccess/FieldAccessorBase.cs b/csharp/src/ProtocolBuffers/FieldAccess/FieldAccessorBase.cs index 73d777b2..2a3e5b8b 100644 --- a/csharp/src/ProtocolBuffers/FieldAccess/FieldAccessorBase.cs +++ b/csharp/src/ProtocolBuffers/FieldAccess/FieldAccessorBase.cs @@ -32,34 +32,37 @@ using System; using System.Reflection; +using Google.Protobuf.Descriptors; namespace Google.Protobuf.FieldAccess { /// /// Base class for field accessors. /// - /// Type of message containing the field - internal abstract class FieldAccessorBase : IFieldAccessor where T : IMessage + internal abstract class FieldAccessorBase : IFieldAccessor { - private readonly Func getValueDelegate; + private readonly Func getValueDelegate; + private readonly FieldDescriptor descriptor; - internal FieldAccessorBase(string name) + internal FieldAccessorBase(Type type, string propertyName, FieldDescriptor descriptor) { - PropertyInfo property = typeof(T).GetProperty(name); + PropertyInfo property = type.GetProperty(propertyName); if (property == null || !property.CanRead) { throw new ArgumentException("Not all required properties/methods available"); } - getValueDelegate = ReflectionUtil.CreateUpcastDelegate(property.GetGetMethod()); + this.descriptor = descriptor; + getValueDelegate = ReflectionUtil.CreateFuncObjectObject(property.GetGetMethod()); } - public object GetValue(T message) + public FieldDescriptor Descriptor { get { return descriptor; } } + + public object GetValue(object message) { return getValueDelegate(message); } - public abstract bool HasValue(T message); - public abstract void Clear(T message); - public abstract void SetValue(T message, object value); + public abstract void Clear(object message); + public abstract void SetValue(object message, object value); } } diff --git a/csharp/src/ProtocolBuffers/FieldAccess/FieldAccessorTable.cs b/csharp/src/ProtocolBuffers/FieldAccess/FieldAccessorTable.cs index 6379ff25..57ea9c87 100644 --- a/csharp/src/ProtocolBuffers/FieldAccess/FieldAccessorTable.cs +++ b/csharp/src/ProtocolBuffers/FieldAccess/FieldAccessorTable.cs @@ -31,6 +31,7 @@ #endregion using System; +using System.Collections.ObjectModel; using Google.Protobuf.Descriptors; namespace Google.Protobuf.FieldAccess @@ -38,34 +39,43 @@ namespace Google.Protobuf.FieldAccess /// /// Provides access to fields in generated messages via reflection. /// - public sealed class FieldAccessorTable where T : IMessage + public sealed class FieldAccessorTable { - private readonly IFieldAccessor[] accessors; + private readonly ReadOnlyCollection accessors; private readonly MessageDescriptor descriptor; /// /// Constructs a FieldAccessorTable for a particular message class. /// Only one FieldAccessorTable should be constructed per class. /// + /// The CLR type for the message. /// The type's descriptor /// The Pascal-case names of all the field-based properties in the message. - public FieldAccessorTable(MessageDescriptor descriptor, string[] propertyNames) + public FieldAccessorTable(Type type, MessageDescriptor descriptor, string[] propertyNames) { this.descriptor = descriptor; - accessors = new IFieldAccessor[descriptor.Fields.Count]; - bool supportFieldPresence = descriptor.File.Syntax == FileDescriptor.ProtoSyntax.Proto2; - for (int i = 0; i < accessors.Length; i++) + var accessorsArray = new IFieldAccessor[descriptor.Fields.Count]; + for (int i = 0; i < accessorsArray.Length; i++) { var field = descriptor.Fields[i]; var name = propertyNames[i]; - accessors[i] = field.IsRepeated - ? (IFieldAccessor) new RepeatedFieldAccessor(propertyNames[i]) - : new SingleFieldAccessor(field, name, supportFieldPresence); + accessorsArray[i] = + field.IsMap ? new MapFieldAccessor(type, name, field) + : field.IsRepeated ? new RepeatedFieldAccessor(type, name, field) + : (IFieldAccessor) new SingleFieldAccessor(type, name, field); } + accessors = new ReadOnlyCollection(accessorsArray); // TODO(jonskeet): Oneof support } - internal IFieldAccessor this[int fieldNumber] + // TODO: Validate the name here... should possibly make this type a more "general reflection access" type, + // bearing in mind the oneof parts to come as well. + /// + /// Returns all of the field accessors for the message type. + /// + public ReadOnlyCollection Accessors { get { return accessors; } } + + public IFieldAccessor this[int fieldNumber] { get { @@ -74,7 +84,7 @@ namespace Google.Protobuf.FieldAccess } } - internal IFieldAccessor this[FieldDescriptor field] + internal IFieldAccessor this[FieldDescriptor field] { get { diff --git a/csharp/src/ProtocolBuffers/FieldAccess/IFieldAccessor.cs b/csharp/src/ProtocolBuffers/FieldAccess/IFieldAccessor.cs index 61838543..77e7146d 100644 --- a/csharp/src/ProtocolBuffers/FieldAccess/IFieldAccessor.cs +++ b/csharp/src/ProtocolBuffers/FieldAccess/IFieldAccessor.cs @@ -30,39 +30,41 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #endregion +using Google.Protobuf.Descriptors; + namespace Google.Protobuf.FieldAccess { /// - /// Allows fields to be reflectively accessed in a smart manner. - /// The property descriptors for each field are created once and then cached. - /// In addition, this interface holds knowledge of repeated fields, builders etc. + /// Allows fields to be reflectively accessed. /// - internal interface IFieldAccessor where T : IMessage + public interface IFieldAccessor { /// - /// Indicates whether the specified message contains the field. For primitive fields - /// declared in proto3-syntax messages, this simply checks whether the value is the default one. + /// Returns the descriptor associated with this field. /// - /// The field is a repeated field, or a single primitive field. - bool HasValue(T message); + FieldDescriptor Descriptor { get; } /// /// Clears the field in the specified message. (For repeated fields, /// this clears the list.) /// - void Clear(T message); + void Clear(object message); /// /// Fetches the field value. For repeated values, this will be an - /// implementation. + /// implementation. For map values, this will be an + /// implementation. /// - object GetValue(T message); + object GetValue(object message); /// - /// Mutator for single fields only. (Repeated fields must be mutated - /// by fetching the list, then mutating that.) + /// Mutator for single "simple" fields only. /// - /// The field is a repeated field. - void SetValue(T message, object value); + /// + /// Repeated fields are mutated by fetching the value and manipulating it as a list. + /// Map fields are mutated by fetching the value and manipulating it as a dictionary. + /// + /// The field is not a "simple" field, or the message is frozen. + void SetValue(object message, object value); } } \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/FieldAccess/MapFieldAccessor.cs b/csharp/src/ProtocolBuffers/FieldAccess/MapFieldAccessor.cs new file mode 100644 index 00000000..100dbb37 --- /dev/null +++ b/csharp/src/ProtocolBuffers/FieldAccess/MapFieldAccessor.cs @@ -0,0 +1,59 @@ +#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 System; +using System.Collections; +using Google.Protobuf.Descriptors; + +namespace Google.Protobuf.FieldAccess +{ + /// + /// Accessor for map fields. + /// + internal sealed class MapFieldAccessor : FieldAccessorBase + { + internal MapFieldAccessor(Type type, string propertyName, FieldDescriptor descriptor) : base(type, propertyName, descriptor) + { + } + + public override void Clear(object message) + { + IDictionary list = (IDictionary) GetValue(message); + list.Clear(); + } + + public override void SetValue(object message, object value) + { + throw new InvalidOperationException("SetValue is not implemented for map fields"); + } + } +} diff --git a/csharp/src/ProtocolBuffers/FieldAccess/ReflectionUtil.cs b/csharp/src/ProtocolBuffers/FieldAccess/ReflectionUtil.cs index 29399b0c..d3053920 100644 --- a/csharp/src/ProtocolBuffers/FieldAccess/ReflectionUtil.cs +++ b/csharp/src/ProtocolBuffers/FieldAccess/ReflectionUtil.cs @@ -31,6 +31,7 @@ #endregion using System; +using System.Linq.Expressions; using System.Reflection; namespace Google.Protobuf.FieldAccess @@ -51,101 +52,42 @@ namespace Google.Protobuf.FieldAccess internal static readonly Type[] EmptyTypes = new Type[0]; /// - /// Creates a delegate which will execute the given method and then return - /// the result as an object. + /// Creates a delegate which will cast the argument to the appropriate method target type, + /// call the method on it, then convert the result to object. /// - public static Func CreateUpcastDelegate(MethodInfo method) + internal static Func CreateFuncObjectObject(MethodInfo method) { - // The tricky bit is invoking CreateCreateUpcastDelegateImpl with the right type parameters - MethodInfo openImpl = typeof(ReflectionUtil).GetMethod("CreateUpcastDelegateImpl"); - MethodInfo closedImpl = openImpl.MakeGenericMethod(typeof(T), method.ReturnType); - return (Func) closedImpl.Invoke(null, new object[] {method}); + ParameterExpression parameter = Expression.Parameter(typeof(object), "p"); + Expression downcast = Expression.Convert(parameter, method.DeclaringType); + Expression call = Expression.Call(downcast, method); + Expression upcast = Expression.Convert(call, typeof(object)); + return Expression.Lambda>(upcast, parameter).Compile(); } - + /// - /// Method used solely for implementing CreateUpcastDelegate. Public to avoid trust issues - /// in low-trust scenarios. + /// Creates a delegate which will execute the given method after casting the first argument to + /// the target type of the method, and the second argument to the first parameter type of the method. /// - public static Func CreateUpcastDelegateImpl(MethodInfo method) + internal static Action CreateActionObjectObject(MethodInfo method) { - // Convert the reflection call into an open delegate, i.e. instead of calling x.Method() - // we'll call getter(x). - Func getter = ReflectionUtil.CreateDelegateFunc(method); - - // Implicit upcast to object (within the delegate) - return source => getter(source); + ParameterExpression targetParameter = Expression.Parameter(typeof(object), "target"); + ParameterExpression argParameter = Expression.Parameter(typeof(object), "arg"); + Expression castTarget = Expression.Convert(targetParameter, method.DeclaringType); + Expression castArgument = Expression.Convert(argParameter, method.GetParameters()[0].ParameterType); + Expression call = Expression.Call(castTarget, method, castArgument); + return Expression.Lambda>(call, targetParameter, argParameter).Compile(); } /// - /// Creates a delegate which will execute the given method after casting the parameter - /// down from object to the required parameter type. + /// Creates a delegate which will execute the given method after casting the first argument to + /// the target type of the method. /// - public static Action CreateDowncastDelegate(MethodInfo method) - { - MethodInfo openImpl = typeof(ReflectionUtil).GetMethod("CreateDowncastDelegateImpl"); - MethodInfo closedImpl = openImpl.MakeGenericMethod(typeof(T), method.GetParameters()[0].ParameterType); - return (Action) closedImpl.Invoke(null, new object[] {method}); - } - - public static Action CreateDowncastDelegateImpl(MethodInfo method) - { - // Convert the reflection call into an open delegate, i.e. instead of calling x.Method(y) we'll - // call Method(x, y) - Action call = ReflectionUtil.CreateDelegateAction(method); - - return (source, parameter) => call(source, (TParam) parameter); - } - - /// - /// Creates a delegate which will execute the given method after casting the parameter - /// down from object to the required parameter type. - /// - public static Action CreateDowncastDelegateIgnoringReturn(MethodInfo method) - { - MethodInfo openImpl = typeof(ReflectionUtil).GetMethod("CreateDowncastDelegateIgnoringReturnImpl"); - MethodInfo closedImpl = openImpl.MakeGenericMethod(typeof(T), method.GetParameters()[0].ParameterType, - method.ReturnType); - return (Action) closedImpl.Invoke(null, new object[] {method}); - } - - public static Action CreateDowncastDelegateIgnoringReturnImpl( - MethodInfo method) - { - // Convert the reflection call into an open delegate, i.e. instead of calling x.Method(y) we'll - // call Method(x, y) - Func call = ReflectionUtil.CreateDelegateFunc(method); - - return delegate(TSource source, object parameter) { call(source, (TParam) parameter); }; - } - - internal static Func CreateDelegateFunc(MethodInfo method) - { - object tdelegate = Delegate.CreateDelegate(typeof(Func), null, method); - return (Func)tdelegate; - } - - internal static Func CreateDelegateFunc(MethodInfo method) - { - object tdelegate = Delegate.CreateDelegate(typeof(Func), null, method); - return (Func)tdelegate; - } - - internal static Func CreateDelegateFunc(MethodInfo method) - { - object tdelegate = Delegate.CreateDelegate(typeof(Func), null, method); - return (Func)tdelegate; - } - - internal static Action CreateDelegateAction(MethodInfo method) - { - object tdelegate = Delegate.CreateDelegate(typeof(Action), null, method); - return (Action)tdelegate; - } - - internal static Action CreateDelegateAction(MethodInfo method) + internal static Action CreateActionObject(MethodInfo method) { - object tdelegate = Delegate.CreateDelegate(typeof(Action), null, method); - return (Action)tdelegate; + ParameterExpression targetParameter = Expression.Parameter(typeof(object), "target"); + Expression castTarget = Expression.Convert(targetParameter, method.DeclaringType); + Expression call = Expression.Call(castTarget, method); + return Expression.Lambda>(call, targetParameter).Compile(); } } } \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/FieldAccess/RepeatedFieldAccessor.cs b/csharp/src/ProtocolBuffers/FieldAccess/RepeatedFieldAccessor.cs index b12278f9..8d7ecbaf 100644 --- a/csharp/src/ProtocolBuffers/FieldAccess/RepeatedFieldAccessor.cs +++ b/csharp/src/ProtocolBuffers/FieldAccess/RepeatedFieldAccessor.cs @@ -32,33 +32,28 @@ using System; using System.Collections; +using Google.Protobuf.Descriptors; namespace Google.Protobuf.FieldAccess { /// /// Accessor for repeated fields. /// - /// The type of message containing the field. - internal sealed class RepeatedFieldAccessor : FieldAccessorBase where T : IMessage + internal sealed class RepeatedFieldAccessor : FieldAccessorBase { - internal RepeatedFieldAccessor(string name) : base(name) + internal RepeatedFieldAccessor(Type type, string propertyName, FieldDescriptor descriptor) : base(type, propertyName, descriptor) { } - public override void Clear(T message) + public override void Clear(object message) { IList list = (IList) GetValue(message); list.Clear(); } - public override bool HasValue(T message) + public override void SetValue(object message, object value) { - throw new NotImplementedException("HasValue is not implemented for repeated fields"); - } - - public override void SetValue(T message, object value) - { - throw new NotImplementedException("SetValue is not implemented for repeated fields"); + throw new InvalidOperationException("SetValue is not implemented for repeated fields"); } } diff --git a/csharp/src/ProtocolBuffers/FieldAccess/SingleFieldAccessor.cs b/csharp/src/ProtocolBuffers/FieldAccess/SingleFieldAccessor.cs index 7a8f726e..cdc89e8d 100644 --- a/csharp/src/ProtocolBuffers/FieldAccess/SingleFieldAccessor.cs +++ b/csharp/src/ProtocolBuffers/FieldAccess/SingleFieldAccessor.cs @@ -39,76 +39,46 @@ namespace Google.Protobuf.FieldAccess /// /// Accessor for single fields. /// - /// The type of message containing the field. - internal sealed class SingleFieldAccessor : FieldAccessorBase where T : IMessage + internal sealed class SingleFieldAccessor : FieldAccessorBase { // All the work here is actually done in the constructor - it creates the appropriate delegates. // There are various cases to consider, based on the property type (message, string/bytes, or "genuine" primitive) // and proto2 vs proto3 for non-message types, as proto3 doesn't support "full" presence detection or default // values. - private readonly Action setValueDelegate; - private readonly Action clearDelegate; - private readonly Func hasValueDelegate; + private readonly Action setValueDelegate; + private readonly Action clearDelegate; - internal SingleFieldAccessor(FieldDescriptor descriptor, string name, bool supportsFieldPresence) : base(name) + internal SingleFieldAccessor(Type type, string propertyName, FieldDescriptor descriptor) : base(type, propertyName, descriptor) { - PropertyInfo property = typeof(T).GetProperty(name); + PropertyInfo property = type.GetProperty(propertyName); // We know there *is* such a property, or the base class constructor would have thrown. We should be able to write // to it though. if (!property.CanWrite) { throw new ArgumentException("Not all required properties/methods available"); } - setValueDelegate = ReflectionUtil.CreateDowncastDelegate(property.GetSetMethod()); + setValueDelegate = ReflectionUtil.CreateActionObjectObject(property.GetSetMethod()); var clrType = property.PropertyType; + + // TODO: What should clear on a oneof member do? Clear the oneof? - if (typeof(IMessage).IsAssignableFrom(clrType)) - { - // Message types are simple - we only need to detect nullity. - clearDelegate = message => SetValue(message, null); - hasValueDelegate = message => GetValue(message) == null; - } - - if (supportsFieldPresence) - { - // Proto2: we expect a HasFoo property and a ClearFoo method. - // For strings and byte arrays, setting the property to null would have the equivalent effect, - // but we generate the method for consistency, which makes this simpler. - PropertyInfo hasProperty = typeof(T).GetProperty("Has" + name); - MethodInfo clearMethod = typeof(T).GetMethod("Clear" + name); - if (hasProperty == null || clearMethod == null || !hasProperty.CanRead) - { - throw new ArgumentException("Not all required properties/methods available"); - } - hasValueDelegate = ReflectionUtil.CreateDelegateFunc(hasProperty.GetGetMethod()); - clearDelegate = ReflectionUtil.CreateDelegateAction(clearMethod); - } - else - { - /* - // TODO(jonskeet): Reimplement. We need a better way of working out default values. - // Proto3: for field detection, we just need the default value of the field (0, "", byte[0] etc) - // To clear a field, we set the value to that default. - object defaultValue = descriptor.DefaultValue; - hasValueDelegate = message => GetValue(message).Equals(defaultValue); - clearDelegate = message => SetValue(message, defaultValue); - */ - } - } - - public override bool HasValue(T message) - { - return hasValueDelegate(message); + // TODO: Validate that this is a reasonable single field? (Should be a value type, a message type, or string/ByteString.) + object defaultValue = + typeof(IMessage).IsAssignableFrom(clrType) ? null + : clrType == typeof(string) ? "" + : clrType == typeof(ByteString) ? ByteString.Empty + : Activator.CreateInstance(clrType); + clearDelegate = message => SetValue(message, defaultValue); } - public override void Clear(T message) + public override void Clear(object message) { clearDelegate(message); } - public override void SetValue(T message, object value) + public override void SetValue(object message, object value) { setValueDelegate(message, value); } diff --git a/csharp/src/ProtocolBuffers/IMessage.cs b/csharp/src/ProtocolBuffers/IMessage.cs index 27bcc117..ad44668c 100644 --- a/csharp/src/ProtocolBuffers/IMessage.cs +++ b/csharp/src/ProtocolBuffers/IMessage.cs @@ -40,12 +40,11 @@ namespace Google.Protobuf // TODO(jonskeet): Split these interfaces into separate files when we're happy with them. /// - /// Reflection support for a specific message type. message + /// Reflection support for a specific message type. /// - /// The message type being reflected. - public interface IReflectedMessage where T : IMessage + public interface IReflectedMessage { - FieldAccessorTable Fields { get; } + FieldAccessorTable Fields { get; } // TODO(jonskeet): Descriptor? Or a single property which has "all you need for reflection"? } diff --git a/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj b/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj index 1e7408ea..4078589e 100644 --- a/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj +++ b/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj @@ -79,6 +79,7 @@ + diff --git a/src/google/protobuf/compiler/csharp/csharp_message.cc b/src/google/protobuf/compiler/csharp/csharp_message.cc index 9e2fe9b6..c7a1e290 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message.cc @@ -116,8 +116,7 @@ void MessageGenerator::GenerateStaticVariables(io::Printer* printer) { // The descriptor for this type. printer->Print( - "internal static pbd::MessageDescriptor internal__$identifier$__Descriptor;\n" - "internal static pb::FieldAccess.FieldAccessorTable<$full_class_name$> internal__$identifier$__FieldAccessorTable;\n", + "internal static pb::FieldAccess.FieldAccessorTable internal__$identifier$__FieldAccessorTable;\n", "identifier", GetUniqueFileScopeIdentifier(descriptor_), "full_class_name", full_class_name()); @@ -130,24 +129,23 @@ void MessageGenerator::GenerateStaticVariables(io::Printer* printer) { void MessageGenerator::GenerateStaticVariableInitializers(io::Printer* printer) { map vars; vars["identifier"] = GetUniqueFileScopeIdentifier(descriptor_); - vars["index"] = SimpleItoa(descriptor_->index()); vars["full_class_name"] = full_class_name(); - if (descriptor_->containing_type() != NULL) { - vars["parent"] = GetUniqueFileScopeIdentifier( - descriptor_->containing_type()); - } - printer->Print(vars, "internal__$identifier$__Descriptor = "); - if (!descriptor_->containing_type()) { - printer->Print(vars, "Descriptor.MessageTypes[$index$];\n"); - } else { - printer->Print(vars, "internal__$parent$__Descriptor.NestedTypes[$index$];\n"); + // Work out how to get to the message descriptor (which may be multiply nested) from the file + // descriptor. + string descriptor_chain; + const Descriptor* current_descriptor = descriptor_; + while (current_descriptor->containing_type()) { + descriptor_chain = ".NestedTypes[" + SimpleItoa(current_descriptor->index()) + "]" + descriptor_chain; + current_descriptor = current_descriptor->containing_type(); } + descriptor_chain = "descriptor.MessageTypes[" + SimpleItoa(current_descriptor->index()) + "]" + descriptor_chain; + vars["descriptor_chain"] = descriptor_chain; printer->Print( vars, "internal__$identifier$__FieldAccessorTable = \n" - " new pb::FieldAccess.FieldAccessorTable<$full_class_name$>(internal__$identifier$__Descriptor,\n"); + " new pb::FieldAccess.FieldAccessorTable(typeof($full_class_name$), $descriptor_chain$,\n"); printer->Print(" new string[] { "); for (int i = 0; i < descriptor_->field_count(); i++) { printer->Print("\"$property_name$\", ", @@ -201,13 +199,22 @@ void MessageGenerator::Generate(io::Printer* printer) { "private static readonly uint[] _fieldTags = new uint[] { $tags$ };\n", "tags", JoinStrings(tags, ", ")); + // Access the message descriptor via the relevant file descriptor or containing message descriptor. + if (!descriptor_->containing_type()) { + vars["descriptor_accessor"] = GetFullUmbrellaClassName(descriptor_->file()) + + ".Descriptor.MessageTypes[" + SimpleItoa(descriptor_->index()) + "]"; + } else { + vars["descriptor_accessor"] = GetClassName(descriptor_->containing_type()) + + ".Descriptor.NestedTypes[" + SimpleItoa(descriptor_->index()) + "]"; + } + printer->Print( vars, "public static pbd::MessageDescriptor Descriptor {\n" - " get { return $umbrella_class_name$.internal__$identifier$__Descriptor; }\n" + " get { return $descriptor_accessor$; }\n" "}\n" "\n" - "public pb::FieldAccess.FieldAccessorTable<$class_name$> Fields {\n" + "public pb::FieldAccess.FieldAccessorTable Fields {\n" " get { return $umbrella_class_name$.internal__$identifier$__FieldAccessorTable; }\n" "}\n" "\n" diff --git a/src/google/protobuf/compiler/csharp/csharp_umbrella_class.cc b/src/google/protobuf/compiler/csharp/csharp_umbrella_class.cc index 03a3b8df..8fbd3e9a 100644 --- a/src/google/protobuf/compiler/csharp/csharp_umbrella_class.cc +++ b/src/google/protobuf/compiler/csharp/csharp_umbrella_class.cc @@ -176,22 +176,11 @@ void UmbrellaClassGenerator::WriteDescriptor(io::Printer* printer) { printer->Print("\"$base64$\"));\n", "base64", base64); printer->Outdent(); printer->Outdent(); - printer->Print( - "pbd::FileDescriptor.InternalDescriptorAssigner assigner = delegate(pbd::FileDescriptor root) {\n"); - printer->Indent(); - printer->Print("descriptor = root;\n"); - for (int i = 0; i < file_->message_type_count(); i++) { - MessageGenerator messageGenerator(file_->message_type(i)); - messageGenerator.GenerateStaticVariableInitializers(printer); - } - - printer->Outdent(); - printer->Print("};\n"); // ----------------------------------------------------------------- - // Invoke internalBuildGeneratedFileFrom() to build the file. + // Invoke InternalBuildGeneratedFileFrom() to build the file. printer->Print( - "pbd::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData,\n"); + "descriptor = pbd::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData,\n"); printer->Print(" new pbd::FileDescriptor[] {\n"); for (int i = 0; i < file_->dependency_count(); i++) { printer->Print( @@ -199,7 +188,12 @@ void UmbrellaClassGenerator::WriteDescriptor(io::Printer* printer) { "full_umbrella_class_name", GetFullUmbrellaClassName(file_->dependency(i))); } - printer->Print(" }, assigner);\n"); + printer->Print(" });\n"); + // Then invoke any other static variable initializers, e.g. field accessors. + for (int i = 0; i < file_->message_type_count(); i++) { + MessageGenerator messageGenerator(file_->message_type(i)); + messageGenerator.GenerateStaticVariableInitializers(printer); + } printer->Outdent(); printer->Print("}\n"); printer->Print("#endregion\n\n"); -- cgit v1.2.3 From 462d569ec0eb8f6a7b81f0423566cba20fb2bf9f Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Wed, 1 Jul 2015 14:47:36 +0100 Subject: Changes to generated code due to previous commit. --- csharp/src/AddressBook/Addressbook.cs | 49 +- .../TestProtos/MapUnittestProto3.cs | 623 +++++++++------------ .../TestProtos/UnittestImportProto3.cs | 21 +- .../TestProtos/UnittestImportPublicProto3.cs | 21 +- .../TestProtos/UnittestIssues.cs | 105 ++-- .../TestProtos/UnittestProto3.cs | 497 +++++++--------- .../DescriptorProtos/DescriptorProtoFile.cs | 315 +++++------ 7 files changed, 692 insertions(+), 939 deletions(-) diff --git a/csharp/src/AddressBook/Addressbook.cs b/csharp/src/AddressBook/Addressbook.cs index 4fd46471..0b77ebf1 100644 --- a/csharp/src/AddressBook/Addressbook.cs +++ b/csharp/src/AddressBook/Addressbook.cs @@ -13,12 +13,9 @@ namespace Google.Protobuf.Examples.AddressBook { public static partial class Addressbook { #region Static variables - internal static pbd::MessageDescriptor internal__static_tutorial_Person__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_tutorial_Person__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_tutorial_Person_PhoneNumber__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_tutorial_Person_PhoneNumber__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_tutorial_AddressBook__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_tutorial_AddressBook__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_tutorial_Person__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_tutorial_Person_PhoneNumber__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_tutorial_AddressBook__FieldAccessorTable; #endregion #region Descriptor public static pbd::FileDescriptor Descriptor { @@ -38,24 +35,18 @@ namespace Google.Protobuf.Examples.AddressBook { "ZXJzb24YASADKAsyEC50dXRvcmlhbC5QZXJzb25CUAoUY29tLmV4YW1wbGUu", "dHV0b3JpYWxCEUFkZHJlc3NCb29rUHJvdG9zqgIkR29vZ2xlLlByb3RvYnVm", "LkV4YW1wbGVzLkFkZHJlc3NCb29r")); - pbd::FileDescriptor.InternalDescriptorAssigner assigner = delegate(pbd::FileDescriptor root) { - descriptor = root; - internal__static_tutorial_Person__Descriptor = Descriptor.MessageTypes[0]; - internal__static_tutorial_Person__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_tutorial_Person__Descriptor, - new string[] { "Name", "Id", "Email", "Phone", }); - internal__static_tutorial_Person_PhoneNumber__Descriptor = internal__static_tutorial_Person__Descriptor.NestedTypes[0]; - internal__static_tutorial_Person_PhoneNumber__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_tutorial_Person_PhoneNumber__Descriptor, - new string[] { "Number", "Type", }); - internal__static_tutorial_AddressBook__Descriptor = Descriptor.MessageTypes[1]; - internal__static_tutorial_AddressBook__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_tutorial_AddressBook__Descriptor, - new string[] { "Person", }); - }; - pbd::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, + descriptor = pbd::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, new pbd::FileDescriptor[] { - }, assigner); + }); + internal__static_tutorial_Person__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.Examples.AddressBook.Person), descriptor.MessageTypes[0], + new string[] { "Name", "Id", "Email", "Phone", }); + internal__static_tutorial_Person_PhoneNumber__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneNumber), descriptor.MessageTypes[0].NestedTypes[0], + new string[] { "Number", "Type", }); + internal__static_tutorial_AddressBook__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.Examples.AddressBook.AddressBook), descriptor.MessageTypes[1], + new string[] { "Person", }); } #endregion @@ -69,10 +60,10 @@ namespace Google.Protobuf.Examples.AddressBook { private static readonly string[] _fieldNames = new string[] { "email", "id", "name", "phone" }; private static readonly uint[] _fieldTags = new uint[] { 26, 16, 10, 34 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.Examples.AddressBook.Addressbook.internal__static_tutorial_Person__Descriptor; } + get { return global::Google.Protobuf.Examples.AddressBook.Addressbook.Descriptor.MessageTypes[0]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.Examples.AddressBook.Addressbook.internal__static_tutorial_Person__FieldAccessorTable; } } @@ -260,10 +251,10 @@ namespace Google.Protobuf.Examples.AddressBook { private static readonly string[] _fieldNames = new string[] { "number", "type" }; private static readonly uint[] _fieldTags = new uint[] { 10, 16 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.Examples.AddressBook.Addressbook.internal__static_tutorial_Person_PhoneNumber__Descriptor; } + get { return global::Google.Protobuf.Examples.AddressBook.Person.Descriptor.NestedTypes[0]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.Examples.AddressBook.Addressbook.internal__static_tutorial_Person_PhoneNumber__FieldAccessorTable; } } @@ -403,10 +394,10 @@ namespace Google.Protobuf.Examples.AddressBook { private static readonly string[] _fieldNames = new string[] { "person" }; private static readonly uint[] _fieldTags = new uint[] { 10 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.Examples.AddressBook.Addressbook.internal__static_tutorial_AddressBook__Descriptor; } + get { return global::Google.Protobuf.Examples.AddressBook.Addressbook.Descriptor.MessageTypes[1]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.Examples.AddressBook.Addressbook.internal__static_tutorial_AddressBook__FieldAccessorTable; } } diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/MapUnittestProto3.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/MapUnittestProto3.cs index 54c8880c..365c03a7 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/MapUnittestProto3.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/MapUnittestProto3.cs @@ -13,94 +13,50 @@ namespace Google.Protobuf.TestProtos { public static partial class MapUnittestProto3 { #region Static variables - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestMap__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestMap_MapInt32Int32Entry__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap_MapInt32Int32Entry__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestMap_MapInt64Int64Entry__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap_MapInt64Int64Entry__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestMap_MapUint32Uint32Entry__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap_MapUint32Uint32Entry__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestMap_MapUint64Uint64Entry__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap_MapUint64Uint64Entry__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestMap_MapSint32Sint32Entry__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap_MapSint32Sint32Entry__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestMap_MapSint64Sint64Entry__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap_MapSint64Sint64Entry__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestMap_MapFixed32Fixed32Entry__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap_MapFixed32Fixed32Entry__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestMap_MapFixed64Fixed64Entry__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap_MapFixed64Fixed64Entry__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestMap_MapSfixed32Sfixed32Entry__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap_MapSfixed32Sfixed32Entry__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestMap_MapSfixed64Sfixed64Entry__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap_MapSfixed64Sfixed64Entry__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestMap_MapInt32FloatEntry__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap_MapInt32FloatEntry__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestMap_MapInt32DoubleEntry__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap_MapInt32DoubleEntry__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestMap_MapBoolBoolEntry__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap_MapBoolBoolEntry__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestMap_MapStringStringEntry__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap_MapStringStringEntry__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestMap_MapInt32BytesEntry__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap_MapInt32BytesEntry__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestMap_MapInt32EnumEntry__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap_MapInt32EnumEntry__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestMap_MapInt32ForeignMessageEntry__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap_MapInt32ForeignMessageEntry__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestMapSubmessage__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMapSubmessage__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestMessageMap__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMessageMap__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestMessageMap_MapInt32MessageEntry__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMessageMap_MapInt32MessageEntry__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestSameTypeMap__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestSameTypeMap__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestSameTypeMap_Map1Entry__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestSameTypeMap_Map1Entry__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestSameTypeMap_Map2Entry__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestSameTypeMap_Map2Entry__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestArenaMap__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestArenaMap__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestArenaMap_MapInt32Int32Entry__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestArenaMap_MapInt32Int32Entry__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestArenaMap_MapInt64Int64Entry__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestArenaMap_MapInt64Int64Entry__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestArenaMap_MapUint32Uint32Entry__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestArenaMap_MapUint32Uint32Entry__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestArenaMap_MapUint64Uint64Entry__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestArenaMap_MapUint64Uint64Entry__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestArenaMap_MapSint32Sint32Entry__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestArenaMap_MapSint32Sint32Entry__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestArenaMap_MapSint64Sint64Entry__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestArenaMap_MapSint64Sint64Entry__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestArenaMap_MapFixed32Fixed32Entry__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestArenaMap_MapFixed32Fixed32Entry__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestArenaMap_MapFixed64Fixed64Entry__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestArenaMap_MapFixed64Fixed64Entry__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestArenaMap_MapSfixed32Sfixed32Entry__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestArenaMap_MapSfixed32Sfixed32Entry__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestArenaMap_MapSfixed64Sfixed64Entry__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestArenaMap_MapSfixed64Sfixed64Entry__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestArenaMap_MapInt32FloatEntry__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestArenaMap_MapInt32FloatEntry__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestArenaMap_MapInt32DoubleEntry__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestArenaMap_MapInt32DoubleEntry__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestArenaMap_MapBoolBoolEntry__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestArenaMap_MapBoolBoolEntry__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestArenaMap_MapInt32EnumEntry__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestArenaMap_MapInt32EnumEntry__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestArenaMap_MapInt32ForeignMessageEntry__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestArenaMap_MapInt32ForeignMessageEntry__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_MessageContainingEnumCalledType__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_MessageContainingEnumCalledType__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_MessageContainingEnumCalledType_TypeEntry__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_MessageContainingEnumCalledType_TypeEntry__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_MessageContainingMapCalledEntry__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_MessageContainingMapCalledEntry__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_MessageContainingMapCalledEntry_EntryEntry__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_MessageContainingMapCalledEntry_EntryEntry__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap_MapInt32Int32Entry__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap_MapInt64Int64Entry__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap_MapUint32Uint32Entry__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap_MapUint64Uint64Entry__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap_MapSint32Sint32Entry__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap_MapSint64Sint64Entry__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap_MapFixed32Fixed32Entry__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap_MapFixed64Fixed64Entry__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap_MapSfixed32Sfixed32Entry__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap_MapSfixed64Sfixed64Entry__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap_MapInt32FloatEntry__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap_MapInt32DoubleEntry__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap_MapBoolBoolEntry__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap_MapStringStringEntry__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap_MapInt32BytesEntry__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap_MapInt32EnumEntry__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMap_MapInt32ForeignMessageEntry__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMapSubmessage__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMessageMap__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMessageMap_MapInt32MessageEntry__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestSameTypeMap__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestSameTypeMap_Map1Entry__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestSameTypeMap_Map2Entry__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestArenaMap__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestArenaMap_MapInt32Int32Entry__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestArenaMap_MapInt64Int64Entry__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestArenaMap_MapUint32Uint32Entry__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestArenaMap_MapUint64Uint64Entry__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestArenaMap_MapSint32Sint32Entry__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestArenaMap_MapSint64Sint64Entry__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestArenaMap_MapFixed32Fixed32Entry__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestArenaMap_MapFixed64Fixed64Entry__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestArenaMap_MapSfixed32Sfixed32Entry__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestArenaMap_MapSfixed64Sfixed64Entry__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestArenaMap_MapInt32FloatEntry__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestArenaMap_MapInt32DoubleEntry__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestArenaMap_MapBoolBoolEntry__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestArenaMap_MapInt32EnumEntry__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestArenaMap_MapInt32ForeignMessageEntry__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_MessageContainingEnumCalledType__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_MessageContainingEnumCalledType_TypeEntry__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_MessageContainingMapCalledEntry__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_MessageContainingMapCalledEntry_EntryEntry__FieldAccessorTable; #endregion #region Descriptor public static pbd::FileDescriptor Descriptor { @@ -235,189 +191,142 @@ namespace Google.Protobuf.TestProtos { "dmFsdWUYAiABKAU6AjgBKj8KB01hcEVudW0SEAoMTUFQX0VOVU1fRk9PEAAS", "EAoMTUFQX0VOVU1fQkFSEAESEAoMTUFQX0VOVU1fQkFaEAJCIPgBAaoCGkdv", "b2dsZS5Qcm90b2J1Zi5UZXN0UHJvdG9zYgZwcm90bzM=")); - pbd::FileDescriptor.InternalDescriptorAssigner assigner = delegate(pbd::FileDescriptor root) { - descriptor = root; - internal__static_protobuf_unittest_TestMap__Descriptor = Descriptor.MessageTypes[0]; - internal__static_protobuf_unittest_TestMap__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestMap__Descriptor, - new string[] { "MapInt32Int32", "MapInt64Int64", "MapUint32Uint32", "MapUint64Uint64", "MapSint32Sint32", "MapSint64Sint64", "MapFixed32Fixed32", "MapFixed64Fixed64", "MapSfixed32Sfixed32", "MapSfixed64Sfixed64", "MapInt32Float", "MapInt32Double", "MapBoolBool", "MapStringString", "MapInt32Bytes", "MapInt32Enum", "MapInt32ForeignMessage", }); - internal__static_protobuf_unittest_TestMap_MapInt32Int32Entry__Descriptor = internal__static_protobuf_unittest_TestMap__Descriptor.NestedTypes[0]; - internal__static_protobuf_unittest_TestMap_MapInt32Int32Entry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestMap_MapInt32Int32Entry__Descriptor, - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestMap_MapInt64Int64Entry__Descriptor = internal__static_protobuf_unittest_TestMap__Descriptor.NestedTypes[1]; - internal__static_protobuf_unittest_TestMap_MapInt64Int64Entry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestMap_MapInt64Int64Entry__Descriptor, - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestMap_MapUint32Uint32Entry__Descriptor = internal__static_protobuf_unittest_TestMap__Descriptor.NestedTypes[2]; - internal__static_protobuf_unittest_TestMap_MapUint32Uint32Entry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestMap_MapUint32Uint32Entry__Descriptor, - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestMap_MapUint64Uint64Entry__Descriptor = internal__static_protobuf_unittest_TestMap__Descriptor.NestedTypes[3]; - internal__static_protobuf_unittest_TestMap_MapUint64Uint64Entry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestMap_MapUint64Uint64Entry__Descriptor, - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestMap_MapSint32Sint32Entry__Descriptor = internal__static_protobuf_unittest_TestMap__Descriptor.NestedTypes[4]; - internal__static_protobuf_unittest_TestMap_MapSint32Sint32Entry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestMap_MapSint32Sint32Entry__Descriptor, - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestMap_MapSint64Sint64Entry__Descriptor = internal__static_protobuf_unittest_TestMap__Descriptor.NestedTypes[5]; - internal__static_protobuf_unittest_TestMap_MapSint64Sint64Entry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestMap_MapSint64Sint64Entry__Descriptor, - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestMap_MapFixed32Fixed32Entry__Descriptor = internal__static_protobuf_unittest_TestMap__Descriptor.NestedTypes[6]; - internal__static_protobuf_unittest_TestMap_MapFixed32Fixed32Entry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestMap_MapFixed32Fixed32Entry__Descriptor, - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestMap_MapFixed64Fixed64Entry__Descriptor = internal__static_protobuf_unittest_TestMap__Descriptor.NestedTypes[7]; - internal__static_protobuf_unittest_TestMap_MapFixed64Fixed64Entry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestMap_MapFixed64Fixed64Entry__Descriptor, - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestMap_MapSfixed32Sfixed32Entry__Descriptor = internal__static_protobuf_unittest_TestMap__Descriptor.NestedTypes[8]; - internal__static_protobuf_unittest_TestMap_MapSfixed32Sfixed32Entry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestMap_MapSfixed32Sfixed32Entry__Descriptor, - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestMap_MapSfixed64Sfixed64Entry__Descriptor = internal__static_protobuf_unittest_TestMap__Descriptor.NestedTypes[9]; - internal__static_protobuf_unittest_TestMap_MapSfixed64Sfixed64Entry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestMap_MapSfixed64Sfixed64Entry__Descriptor, - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestMap_MapInt32FloatEntry__Descriptor = internal__static_protobuf_unittest_TestMap__Descriptor.NestedTypes[10]; - internal__static_protobuf_unittest_TestMap_MapInt32FloatEntry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestMap_MapInt32FloatEntry__Descriptor, - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestMap_MapInt32DoubleEntry__Descriptor = internal__static_protobuf_unittest_TestMap__Descriptor.NestedTypes[11]; - internal__static_protobuf_unittest_TestMap_MapInt32DoubleEntry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestMap_MapInt32DoubleEntry__Descriptor, - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestMap_MapBoolBoolEntry__Descriptor = internal__static_protobuf_unittest_TestMap__Descriptor.NestedTypes[12]; - internal__static_protobuf_unittest_TestMap_MapBoolBoolEntry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestMap_MapBoolBoolEntry__Descriptor, - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestMap_MapStringStringEntry__Descriptor = internal__static_protobuf_unittest_TestMap__Descriptor.NestedTypes[13]; - internal__static_protobuf_unittest_TestMap_MapStringStringEntry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestMap_MapStringStringEntry__Descriptor, - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestMap_MapInt32BytesEntry__Descriptor = internal__static_protobuf_unittest_TestMap__Descriptor.NestedTypes[14]; - internal__static_protobuf_unittest_TestMap_MapInt32BytesEntry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestMap_MapInt32BytesEntry__Descriptor, - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestMap_MapInt32EnumEntry__Descriptor = internal__static_protobuf_unittest_TestMap__Descriptor.NestedTypes[15]; - internal__static_protobuf_unittest_TestMap_MapInt32EnumEntry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestMap_MapInt32EnumEntry__Descriptor, - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestMap_MapInt32ForeignMessageEntry__Descriptor = internal__static_protobuf_unittest_TestMap__Descriptor.NestedTypes[16]; - internal__static_protobuf_unittest_TestMap_MapInt32ForeignMessageEntry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestMap_MapInt32ForeignMessageEntry__Descriptor, - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestMapSubmessage__Descriptor = Descriptor.MessageTypes[1]; - internal__static_protobuf_unittest_TestMapSubmessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestMapSubmessage__Descriptor, - new string[] { "TestMap", }); - internal__static_protobuf_unittest_TestMessageMap__Descriptor = Descriptor.MessageTypes[2]; - internal__static_protobuf_unittest_TestMessageMap__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestMessageMap__Descriptor, - new string[] { "MapInt32Message", }); - internal__static_protobuf_unittest_TestMessageMap_MapInt32MessageEntry__Descriptor = internal__static_protobuf_unittest_TestMessageMap__Descriptor.NestedTypes[0]; - internal__static_protobuf_unittest_TestMessageMap_MapInt32MessageEntry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestMessageMap_MapInt32MessageEntry__Descriptor, - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestSameTypeMap__Descriptor = Descriptor.MessageTypes[3]; - internal__static_protobuf_unittest_TestSameTypeMap__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestSameTypeMap__Descriptor, - new string[] { "Map1", "Map2", }); - internal__static_protobuf_unittest_TestSameTypeMap_Map1Entry__Descriptor = internal__static_protobuf_unittest_TestSameTypeMap__Descriptor.NestedTypes[0]; - internal__static_protobuf_unittest_TestSameTypeMap_Map1Entry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestSameTypeMap_Map1Entry__Descriptor, - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestSameTypeMap_Map2Entry__Descriptor = internal__static_protobuf_unittest_TestSameTypeMap__Descriptor.NestedTypes[1]; - internal__static_protobuf_unittest_TestSameTypeMap_Map2Entry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestSameTypeMap_Map2Entry__Descriptor, - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestArenaMap__Descriptor = Descriptor.MessageTypes[4]; - internal__static_protobuf_unittest_TestArenaMap__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestArenaMap__Descriptor, - new string[] { "MapInt32Int32", "MapInt64Int64", "MapUint32Uint32", "MapUint64Uint64", "MapSint32Sint32", "MapSint64Sint64", "MapFixed32Fixed32", "MapFixed64Fixed64", "MapSfixed32Sfixed32", "MapSfixed64Sfixed64", "MapInt32Float", "MapInt32Double", "MapBoolBool", "MapInt32Enum", "MapInt32ForeignMessage", }); - internal__static_protobuf_unittest_TestArenaMap_MapInt32Int32Entry__Descriptor = internal__static_protobuf_unittest_TestArenaMap__Descriptor.NestedTypes[0]; - internal__static_protobuf_unittest_TestArenaMap_MapInt32Int32Entry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestArenaMap_MapInt32Int32Entry__Descriptor, - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestArenaMap_MapInt64Int64Entry__Descriptor = internal__static_protobuf_unittest_TestArenaMap__Descriptor.NestedTypes[1]; - internal__static_protobuf_unittest_TestArenaMap_MapInt64Int64Entry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestArenaMap_MapInt64Int64Entry__Descriptor, - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestArenaMap_MapUint32Uint32Entry__Descriptor = internal__static_protobuf_unittest_TestArenaMap__Descriptor.NestedTypes[2]; - internal__static_protobuf_unittest_TestArenaMap_MapUint32Uint32Entry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestArenaMap_MapUint32Uint32Entry__Descriptor, - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestArenaMap_MapUint64Uint64Entry__Descriptor = internal__static_protobuf_unittest_TestArenaMap__Descriptor.NestedTypes[3]; - internal__static_protobuf_unittest_TestArenaMap_MapUint64Uint64Entry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestArenaMap_MapUint64Uint64Entry__Descriptor, - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestArenaMap_MapSint32Sint32Entry__Descriptor = internal__static_protobuf_unittest_TestArenaMap__Descriptor.NestedTypes[4]; - internal__static_protobuf_unittest_TestArenaMap_MapSint32Sint32Entry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestArenaMap_MapSint32Sint32Entry__Descriptor, - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestArenaMap_MapSint64Sint64Entry__Descriptor = internal__static_protobuf_unittest_TestArenaMap__Descriptor.NestedTypes[5]; - internal__static_protobuf_unittest_TestArenaMap_MapSint64Sint64Entry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestArenaMap_MapSint64Sint64Entry__Descriptor, - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestArenaMap_MapFixed32Fixed32Entry__Descriptor = internal__static_protobuf_unittest_TestArenaMap__Descriptor.NestedTypes[6]; - internal__static_protobuf_unittest_TestArenaMap_MapFixed32Fixed32Entry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestArenaMap_MapFixed32Fixed32Entry__Descriptor, - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestArenaMap_MapFixed64Fixed64Entry__Descriptor = internal__static_protobuf_unittest_TestArenaMap__Descriptor.NestedTypes[7]; - internal__static_protobuf_unittest_TestArenaMap_MapFixed64Fixed64Entry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestArenaMap_MapFixed64Fixed64Entry__Descriptor, - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestArenaMap_MapSfixed32Sfixed32Entry__Descriptor = internal__static_protobuf_unittest_TestArenaMap__Descriptor.NestedTypes[8]; - internal__static_protobuf_unittest_TestArenaMap_MapSfixed32Sfixed32Entry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestArenaMap_MapSfixed32Sfixed32Entry__Descriptor, - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestArenaMap_MapSfixed64Sfixed64Entry__Descriptor = internal__static_protobuf_unittest_TestArenaMap__Descriptor.NestedTypes[9]; - internal__static_protobuf_unittest_TestArenaMap_MapSfixed64Sfixed64Entry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestArenaMap_MapSfixed64Sfixed64Entry__Descriptor, - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestArenaMap_MapInt32FloatEntry__Descriptor = internal__static_protobuf_unittest_TestArenaMap__Descriptor.NestedTypes[10]; - internal__static_protobuf_unittest_TestArenaMap_MapInt32FloatEntry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestArenaMap_MapInt32FloatEntry__Descriptor, - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestArenaMap_MapInt32DoubleEntry__Descriptor = internal__static_protobuf_unittest_TestArenaMap__Descriptor.NestedTypes[11]; - internal__static_protobuf_unittest_TestArenaMap_MapInt32DoubleEntry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestArenaMap_MapInt32DoubleEntry__Descriptor, - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestArenaMap_MapBoolBoolEntry__Descriptor = internal__static_protobuf_unittest_TestArenaMap__Descriptor.NestedTypes[12]; - internal__static_protobuf_unittest_TestArenaMap_MapBoolBoolEntry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestArenaMap_MapBoolBoolEntry__Descriptor, - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestArenaMap_MapInt32EnumEntry__Descriptor = internal__static_protobuf_unittest_TestArenaMap__Descriptor.NestedTypes[13]; - internal__static_protobuf_unittest_TestArenaMap_MapInt32EnumEntry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestArenaMap_MapInt32EnumEntry__Descriptor, - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_TestArenaMap_MapInt32ForeignMessageEntry__Descriptor = internal__static_protobuf_unittest_TestArenaMap__Descriptor.NestedTypes[14]; - internal__static_protobuf_unittest_TestArenaMap_MapInt32ForeignMessageEntry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestArenaMap_MapInt32ForeignMessageEntry__Descriptor, - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_MessageContainingEnumCalledType__Descriptor = Descriptor.MessageTypes[5]; - internal__static_protobuf_unittest_MessageContainingEnumCalledType__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_MessageContainingEnumCalledType__Descriptor, - new string[] { "Type", }); - internal__static_protobuf_unittest_MessageContainingEnumCalledType_TypeEntry__Descriptor = internal__static_protobuf_unittest_MessageContainingEnumCalledType__Descriptor.NestedTypes[0]; - internal__static_protobuf_unittest_MessageContainingEnumCalledType_TypeEntry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_MessageContainingEnumCalledType_TypeEntry__Descriptor, - new string[] { "Key", "Value", }); - internal__static_protobuf_unittest_MessageContainingMapCalledEntry__Descriptor = Descriptor.MessageTypes[6]; - internal__static_protobuf_unittest_MessageContainingMapCalledEntry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_MessageContainingMapCalledEntry__Descriptor, - new string[] { "Entry", }); - internal__static_protobuf_unittest_MessageContainingMapCalledEntry_EntryEntry__Descriptor = internal__static_protobuf_unittest_MessageContainingMapCalledEntry__Descriptor.NestedTypes[0]; - internal__static_protobuf_unittest_MessageContainingMapCalledEntry_EntryEntry__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_MessageContainingMapCalledEntry_EntryEntry__Descriptor, - new string[] { "Key", "Value", }); - }; - pbd::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, + descriptor = pbd::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, new pbd::FileDescriptor[] { global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor, - }, assigner); + }); + internal__static_protobuf_unittest_TestMap__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap), descriptor.MessageTypes[0], + new string[] { "MapInt32Int32", "MapInt64Int64", "MapUint32Uint32", "MapUint64Uint64", "MapSint32Sint32", "MapSint64Sint64", "MapFixed32Fixed32", "MapFixed64Fixed64", "MapSfixed32Sfixed32", "MapSfixed64Sfixed64", "MapInt32Float", "MapInt32Double", "MapBoolBool", "MapStringString", "MapInt32Bytes", "MapInt32Enum", "MapInt32ForeignMessage", }); + internal__static_protobuf_unittest_TestMap_MapInt32Int32Entry__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap.Types.MapInt32Int32Entry), descriptor.MessageTypes[0].NestedTypes[0], + new string[] { "Key", "Value", }); + internal__static_protobuf_unittest_TestMap_MapInt64Int64Entry__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap.Types.MapInt64Int64Entry), descriptor.MessageTypes[0].NestedTypes[1], + new string[] { "Key", "Value", }); + internal__static_protobuf_unittest_TestMap_MapUint32Uint32Entry__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap.Types.MapUint32Uint32Entry), descriptor.MessageTypes[0].NestedTypes[2], + new string[] { "Key", "Value", }); + internal__static_protobuf_unittest_TestMap_MapUint64Uint64Entry__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap.Types.MapUint64Uint64Entry), descriptor.MessageTypes[0].NestedTypes[3], + new string[] { "Key", "Value", }); + internal__static_protobuf_unittest_TestMap_MapSint32Sint32Entry__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap.Types.MapSint32Sint32Entry), descriptor.MessageTypes[0].NestedTypes[4], + new string[] { "Key", "Value", }); + internal__static_protobuf_unittest_TestMap_MapSint64Sint64Entry__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap.Types.MapSint64Sint64Entry), descriptor.MessageTypes[0].NestedTypes[5], + new string[] { "Key", "Value", }); + internal__static_protobuf_unittest_TestMap_MapFixed32Fixed32Entry__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap.Types.MapFixed32Fixed32Entry), descriptor.MessageTypes[0].NestedTypes[6], + new string[] { "Key", "Value", }); + internal__static_protobuf_unittest_TestMap_MapFixed64Fixed64Entry__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap.Types.MapFixed64Fixed64Entry), descriptor.MessageTypes[0].NestedTypes[7], + new string[] { "Key", "Value", }); + internal__static_protobuf_unittest_TestMap_MapSfixed32Sfixed32Entry__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap.Types.MapSfixed32Sfixed32Entry), descriptor.MessageTypes[0].NestedTypes[8], + new string[] { "Key", "Value", }); + internal__static_protobuf_unittest_TestMap_MapSfixed64Sfixed64Entry__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap.Types.MapSfixed64Sfixed64Entry), descriptor.MessageTypes[0].NestedTypes[9], + new string[] { "Key", "Value", }); + internal__static_protobuf_unittest_TestMap_MapInt32FloatEntry__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap.Types.MapInt32FloatEntry), descriptor.MessageTypes[0].NestedTypes[10], + new string[] { "Key", "Value", }); + internal__static_protobuf_unittest_TestMap_MapInt32DoubleEntry__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap.Types.MapInt32DoubleEntry), descriptor.MessageTypes[0].NestedTypes[11], + new string[] { "Key", "Value", }); + internal__static_protobuf_unittest_TestMap_MapBoolBoolEntry__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap.Types.MapBoolBoolEntry), descriptor.MessageTypes[0].NestedTypes[12], + new string[] { "Key", "Value", }); + internal__static_protobuf_unittest_TestMap_MapStringStringEntry__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap.Types.MapStringStringEntry), descriptor.MessageTypes[0].NestedTypes[13], + new string[] { "Key", "Value", }); + internal__static_protobuf_unittest_TestMap_MapInt32BytesEntry__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap.Types.MapInt32BytesEntry), descriptor.MessageTypes[0].NestedTypes[14], + new string[] { "Key", "Value", }); + internal__static_protobuf_unittest_TestMap_MapInt32EnumEntry__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap.Types.MapInt32EnumEntry), descriptor.MessageTypes[0].NestedTypes[15], + new string[] { "Key", "Value", }); + internal__static_protobuf_unittest_TestMap_MapInt32ForeignMessageEntry__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap.Types.MapInt32ForeignMessageEntry), descriptor.MessageTypes[0].NestedTypes[16], + new string[] { "Key", "Value", }); + internal__static_protobuf_unittest_TestMapSubmessage__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMapSubmessage), descriptor.MessageTypes[1], + new string[] { "TestMap", }); + internal__static_protobuf_unittest_TestMessageMap__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMessageMap), descriptor.MessageTypes[2], + new string[] { "MapInt32Message", }); + internal__static_protobuf_unittest_TestMessageMap_MapInt32MessageEntry__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMessageMap.Types.MapInt32MessageEntry), descriptor.MessageTypes[2].NestedTypes[0], + new string[] { "Key", "Value", }); + internal__static_protobuf_unittest_TestSameTypeMap__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestSameTypeMap), descriptor.MessageTypes[3], + new string[] { "Map1", "Map2", }); + internal__static_protobuf_unittest_TestSameTypeMap_Map1Entry__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestSameTypeMap.Types.Map1Entry), descriptor.MessageTypes[3].NestedTypes[0], + new string[] { "Key", "Value", }); + internal__static_protobuf_unittest_TestSameTypeMap_Map2Entry__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestSameTypeMap.Types.Map2Entry), descriptor.MessageTypes[3].NestedTypes[1], + new string[] { "Key", "Value", }); + internal__static_protobuf_unittest_TestArenaMap__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestArenaMap), descriptor.MessageTypes[4], + new string[] { "MapInt32Int32", "MapInt64Int64", "MapUint32Uint32", "MapUint64Uint64", "MapSint32Sint32", "MapSint64Sint64", "MapFixed32Fixed32", "MapFixed64Fixed64", "MapSfixed32Sfixed32", "MapSfixed64Sfixed64", "MapInt32Float", "MapInt32Double", "MapBoolBool", "MapInt32Enum", "MapInt32ForeignMessage", }); + internal__static_protobuf_unittest_TestArenaMap_MapInt32Int32Entry__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestArenaMap.Types.MapInt32Int32Entry), descriptor.MessageTypes[4].NestedTypes[0], + new string[] { "Key", "Value", }); + internal__static_protobuf_unittest_TestArenaMap_MapInt64Int64Entry__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestArenaMap.Types.MapInt64Int64Entry), descriptor.MessageTypes[4].NestedTypes[1], + new string[] { "Key", "Value", }); + internal__static_protobuf_unittest_TestArenaMap_MapUint32Uint32Entry__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestArenaMap.Types.MapUint32Uint32Entry), descriptor.MessageTypes[4].NestedTypes[2], + new string[] { "Key", "Value", }); + internal__static_protobuf_unittest_TestArenaMap_MapUint64Uint64Entry__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestArenaMap.Types.MapUint64Uint64Entry), descriptor.MessageTypes[4].NestedTypes[3], + new string[] { "Key", "Value", }); + internal__static_protobuf_unittest_TestArenaMap_MapSint32Sint32Entry__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestArenaMap.Types.MapSint32Sint32Entry), descriptor.MessageTypes[4].NestedTypes[4], + new string[] { "Key", "Value", }); + internal__static_protobuf_unittest_TestArenaMap_MapSint64Sint64Entry__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestArenaMap.Types.MapSint64Sint64Entry), descriptor.MessageTypes[4].NestedTypes[5], + new string[] { "Key", "Value", }); + internal__static_protobuf_unittest_TestArenaMap_MapFixed32Fixed32Entry__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestArenaMap.Types.MapFixed32Fixed32Entry), descriptor.MessageTypes[4].NestedTypes[6], + new string[] { "Key", "Value", }); + internal__static_protobuf_unittest_TestArenaMap_MapFixed64Fixed64Entry__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestArenaMap.Types.MapFixed64Fixed64Entry), descriptor.MessageTypes[4].NestedTypes[7], + new string[] { "Key", "Value", }); + internal__static_protobuf_unittest_TestArenaMap_MapSfixed32Sfixed32Entry__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestArenaMap.Types.MapSfixed32Sfixed32Entry), descriptor.MessageTypes[4].NestedTypes[8], + new string[] { "Key", "Value", }); + internal__static_protobuf_unittest_TestArenaMap_MapSfixed64Sfixed64Entry__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestArenaMap.Types.MapSfixed64Sfixed64Entry), descriptor.MessageTypes[4].NestedTypes[9], + new string[] { "Key", "Value", }); + internal__static_protobuf_unittest_TestArenaMap_MapInt32FloatEntry__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestArenaMap.Types.MapInt32FloatEntry), descriptor.MessageTypes[4].NestedTypes[10], + new string[] { "Key", "Value", }); + internal__static_protobuf_unittest_TestArenaMap_MapInt32DoubleEntry__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestArenaMap.Types.MapInt32DoubleEntry), descriptor.MessageTypes[4].NestedTypes[11], + new string[] { "Key", "Value", }); + internal__static_protobuf_unittest_TestArenaMap_MapBoolBoolEntry__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestArenaMap.Types.MapBoolBoolEntry), descriptor.MessageTypes[4].NestedTypes[12], + new string[] { "Key", "Value", }); + internal__static_protobuf_unittest_TestArenaMap_MapInt32EnumEntry__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestArenaMap.Types.MapInt32EnumEntry), descriptor.MessageTypes[4].NestedTypes[13], + new string[] { "Key", "Value", }); + internal__static_protobuf_unittest_TestArenaMap_MapInt32ForeignMessageEntry__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestArenaMap.Types.MapInt32ForeignMessageEntry), descriptor.MessageTypes[4].NestedTypes[14], + new string[] { "Key", "Value", }); + internal__static_protobuf_unittest_MessageContainingEnumCalledType__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.MessageContainingEnumCalledType), descriptor.MessageTypes[5], + new string[] { "Type", }); + internal__static_protobuf_unittest_MessageContainingEnumCalledType_TypeEntry__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.MessageContainingEnumCalledType.Types.TypeEntry), descriptor.MessageTypes[5].NestedTypes[0], + new string[] { "Key", "Value", }); + internal__static_protobuf_unittest_MessageContainingMapCalledEntry__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.MessageContainingMapCalledEntry), descriptor.MessageTypes[6], + new string[] { "Entry", }); + internal__static_protobuf_unittest_MessageContainingMapCalledEntry_EntryEntry__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.MessageContainingMapCalledEntry.Types.EntryEntry), descriptor.MessageTypes[6].NestedTypes[0], + new string[] { "Key", "Value", }); } #endregion @@ -440,10 +349,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "map_bool_bool", "map_fixed32_fixed32", "map_fixed64_fixed64", "map_int32_bytes", "map_int32_double", "map_int32_enum", "map_int32_float", "map_int32_foreign_message", "map_int32_int32", "map_int64_int64", "map_sfixed32_sfixed32", "map_sfixed64_sfixed64", "map_sint32_sint32", "map_sint64_sint64", "map_string_string", "map_uint32_uint32", "map_uint64_uint64" }; private static readonly uint[] _fieldTags = new uint[] { 106, 58, 66, 122, 98, 130, 90, 138, 10, 18, 74, 82, 42, 50, 114, 26, 34 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap__Descriptor; } + get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.Descriptor.MessageTypes[0]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap__FieldAccessorTable; } } @@ -848,10 +757,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "key", "value" }; private static readonly uint[] _fieldTags = new uint[] { 8, 16 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap_MapInt32Int32Entry__Descriptor; } + get { return global::Google.Protobuf.TestProtos.TestMap.Descriptor.NestedTypes[0]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap_MapInt32Int32Entry__FieldAccessorTable; } } @@ -986,10 +895,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "key", "value" }; private static readonly uint[] _fieldTags = new uint[] { 8, 16 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap_MapInt64Int64Entry__Descriptor; } + get { return global::Google.Protobuf.TestProtos.TestMap.Descriptor.NestedTypes[1]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap_MapInt64Int64Entry__FieldAccessorTable; } } @@ -1124,10 +1033,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "key", "value" }; private static readonly uint[] _fieldTags = new uint[] { 8, 16 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap_MapUint32Uint32Entry__Descriptor; } + get { return global::Google.Protobuf.TestProtos.TestMap.Descriptor.NestedTypes[2]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap_MapUint32Uint32Entry__FieldAccessorTable; } } @@ -1262,10 +1171,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "key", "value" }; private static readonly uint[] _fieldTags = new uint[] { 8, 16 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap_MapUint64Uint64Entry__Descriptor; } + get { return global::Google.Protobuf.TestProtos.TestMap.Descriptor.NestedTypes[3]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap_MapUint64Uint64Entry__FieldAccessorTable; } } @@ -1400,10 +1309,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "key", "value" }; private static readonly uint[] _fieldTags = new uint[] { 8, 16 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap_MapSint32Sint32Entry__Descriptor; } + get { return global::Google.Protobuf.TestProtos.TestMap.Descriptor.NestedTypes[4]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap_MapSint32Sint32Entry__FieldAccessorTable; } } @@ -1538,10 +1447,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "key", "value" }; private static readonly uint[] _fieldTags = new uint[] { 8, 16 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap_MapSint64Sint64Entry__Descriptor; } + get { return global::Google.Protobuf.TestProtos.TestMap.Descriptor.NestedTypes[5]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap_MapSint64Sint64Entry__FieldAccessorTable; } } @@ -1676,10 +1585,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "key", "value" }; private static readonly uint[] _fieldTags = new uint[] { 13, 21 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap_MapFixed32Fixed32Entry__Descriptor; } + get { return global::Google.Protobuf.TestProtos.TestMap.Descriptor.NestedTypes[6]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap_MapFixed32Fixed32Entry__FieldAccessorTable; } } @@ -1814,10 +1723,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "key", "value" }; private static readonly uint[] _fieldTags = new uint[] { 9, 17 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap_MapFixed64Fixed64Entry__Descriptor; } + get { return global::Google.Protobuf.TestProtos.TestMap.Descriptor.NestedTypes[7]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap_MapFixed64Fixed64Entry__FieldAccessorTable; } } @@ -1952,10 +1861,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "key", "value" }; private static readonly uint[] _fieldTags = new uint[] { 13, 21 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap_MapSfixed32Sfixed32Entry__Descriptor; } + get { return global::Google.Protobuf.TestProtos.TestMap.Descriptor.NestedTypes[8]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap_MapSfixed32Sfixed32Entry__FieldAccessorTable; } } @@ -2090,10 +1999,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "key", "value" }; private static readonly uint[] _fieldTags = new uint[] { 9, 17 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap_MapSfixed64Sfixed64Entry__Descriptor; } + get { return global::Google.Protobuf.TestProtos.TestMap.Descriptor.NestedTypes[9]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap_MapSfixed64Sfixed64Entry__FieldAccessorTable; } } @@ -2228,10 +2137,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "key", "value" }; private static readonly uint[] _fieldTags = new uint[] { 8, 21 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap_MapInt32FloatEntry__Descriptor; } + get { return global::Google.Protobuf.TestProtos.TestMap.Descriptor.NestedTypes[10]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap_MapInt32FloatEntry__FieldAccessorTable; } } @@ -2366,10 +2275,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "key", "value" }; private static readonly uint[] _fieldTags = new uint[] { 8, 17 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap_MapInt32DoubleEntry__Descriptor; } + get { return global::Google.Protobuf.TestProtos.TestMap.Descriptor.NestedTypes[11]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap_MapInt32DoubleEntry__FieldAccessorTable; } } @@ -2504,10 +2413,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "key", "value" }; private static readonly uint[] _fieldTags = new uint[] { 8, 16 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap_MapBoolBoolEntry__Descriptor; } + get { return global::Google.Protobuf.TestProtos.TestMap.Descriptor.NestedTypes[12]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap_MapBoolBoolEntry__FieldAccessorTable; } } @@ -2642,10 +2551,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "key", "value" }; private static readonly uint[] _fieldTags = new uint[] { 10, 18 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap_MapStringStringEntry__Descriptor; } + get { return global::Google.Protobuf.TestProtos.TestMap.Descriptor.NestedTypes[13]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap_MapStringStringEntry__FieldAccessorTable; } } @@ -2780,10 +2689,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "key", "value" }; private static readonly uint[] _fieldTags = new uint[] { 8, 18 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap_MapInt32BytesEntry__Descriptor; } + get { return global::Google.Protobuf.TestProtos.TestMap.Descriptor.NestedTypes[14]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap_MapInt32BytesEntry__FieldAccessorTable; } } @@ -2918,10 +2827,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "key", "value" }; private static readonly uint[] _fieldTags = new uint[] { 8, 16 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap_MapInt32EnumEntry__Descriptor; } + get { return global::Google.Protobuf.TestProtos.TestMap.Descriptor.NestedTypes[15]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap_MapInt32EnumEntry__FieldAccessorTable; } } @@ -3056,10 +2965,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "key", "value" }; private static readonly uint[] _fieldTags = new uint[] { 8, 18 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap_MapInt32ForeignMessageEntry__Descriptor; } + get { return global::Google.Protobuf.TestProtos.TestMap.Descriptor.NestedTypes[16]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap_MapInt32ForeignMessageEntry__FieldAccessorTable; } } @@ -3206,10 +3115,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "test_map" }; private static readonly uint[] _fieldTags = new uint[] { 10 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMapSubmessage__Descriptor; } + get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.Descriptor.MessageTypes[1]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMapSubmessage__FieldAccessorTable; } } @@ -3324,10 +3233,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "map_int32_message" }; private static readonly uint[] _fieldTags = new uint[] { 10 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMessageMap__Descriptor; } + get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.Descriptor.MessageTypes[2]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMessageMap__FieldAccessorTable; } } @@ -3428,10 +3337,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "key", "value" }; private static readonly uint[] _fieldTags = new uint[] { 8, 18 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMessageMap_MapInt32MessageEntry__Descriptor; } + get { return global::Google.Protobuf.TestProtos.TestMessageMap.Descriptor.NestedTypes[0]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMessageMap_MapInt32MessageEntry__FieldAccessorTable; } } @@ -3578,10 +3487,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "map1", "map2" }; private static readonly uint[] _fieldTags = new uint[] { 10, 18 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestSameTypeMap__Descriptor; } + get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.Descriptor.MessageTypes[3]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestSameTypeMap__FieldAccessorTable; } } @@ -3701,10 +3610,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "key", "value" }; private static readonly uint[] _fieldTags = new uint[] { 8, 16 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestSameTypeMap_Map1Entry__Descriptor; } + get { return global::Google.Protobuf.TestProtos.TestSameTypeMap.Descriptor.NestedTypes[0]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestSameTypeMap_Map1Entry__FieldAccessorTable; } } @@ -3839,10 +3748,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "key", "value" }; private static readonly uint[] _fieldTags = new uint[] { 8, 16 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestSameTypeMap_Map2Entry__Descriptor; } + get { return global::Google.Protobuf.TestProtos.TestSameTypeMap.Descriptor.NestedTypes[1]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestSameTypeMap_Map2Entry__FieldAccessorTable; } } @@ -3982,10 +3891,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "map_bool_bool", "map_fixed32_fixed32", "map_fixed64_fixed64", "map_int32_double", "map_int32_enum", "map_int32_float", "map_int32_foreign_message", "map_int32_int32", "map_int64_int64", "map_sfixed32_sfixed32", "map_sfixed64_sfixed64", "map_sint32_sint32", "map_sint64_sint64", "map_uint32_uint32", "map_uint64_uint64" }; private static readonly uint[] _fieldTags = new uint[] { 106, 58, 66, 98, 114, 90, 122, 10, 18, 74, 82, 42, 50, 26, 34 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestArenaMap__Descriptor; } + get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.Descriptor.MessageTypes[4]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestArenaMap__FieldAccessorTable; } } @@ -4352,10 +4261,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "key", "value" }; private static readonly uint[] _fieldTags = new uint[] { 8, 16 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestArenaMap_MapInt32Int32Entry__Descriptor; } + get { return global::Google.Protobuf.TestProtos.TestArenaMap.Descriptor.NestedTypes[0]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestArenaMap_MapInt32Int32Entry__FieldAccessorTable; } } @@ -4490,10 +4399,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "key", "value" }; private static readonly uint[] _fieldTags = new uint[] { 8, 16 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestArenaMap_MapInt64Int64Entry__Descriptor; } + get { return global::Google.Protobuf.TestProtos.TestArenaMap.Descriptor.NestedTypes[1]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestArenaMap_MapInt64Int64Entry__FieldAccessorTable; } } @@ -4628,10 +4537,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "key", "value" }; private static readonly uint[] _fieldTags = new uint[] { 8, 16 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestArenaMap_MapUint32Uint32Entry__Descriptor; } + get { return global::Google.Protobuf.TestProtos.TestArenaMap.Descriptor.NestedTypes[2]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestArenaMap_MapUint32Uint32Entry__FieldAccessorTable; } } @@ -4766,10 +4675,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "key", "value" }; private static readonly uint[] _fieldTags = new uint[] { 8, 16 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestArenaMap_MapUint64Uint64Entry__Descriptor; } + get { return global::Google.Protobuf.TestProtos.TestArenaMap.Descriptor.NestedTypes[3]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestArenaMap_MapUint64Uint64Entry__FieldAccessorTable; } } @@ -4904,10 +4813,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "key", "value" }; private static readonly uint[] _fieldTags = new uint[] { 8, 16 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestArenaMap_MapSint32Sint32Entry__Descriptor; } + get { return global::Google.Protobuf.TestProtos.TestArenaMap.Descriptor.NestedTypes[4]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestArenaMap_MapSint32Sint32Entry__FieldAccessorTable; } } @@ -5042,10 +4951,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "key", "value" }; private static readonly uint[] _fieldTags = new uint[] { 8, 16 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestArenaMap_MapSint64Sint64Entry__Descriptor; } + get { return global::Google.Protobuf.TestProtos.TestArenaMap.Descriptor.NestedTypes[5]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestArenaMap_MapSint64Sint64Entry__FieldAccessorTable; } } @@ -5180,10 +5089,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "key", "value" }; private static readonly uint[] _fieldTags = new uint[] { 13, 21 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestArenaMap_MapFixed32Fixed32Entry__Descriptor; } + get { return global::Google.Protobuf.TestProtos.TestArenaMap.Descriptor.NestedTypes[6]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestArenaMap_MapFixed32Fixed32Entry__FieldAccessorTable; } } @@ -5318,10 +5227,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "key", "value" }; private static readonly uint[] _fieldTags = new uint[] { 9, 17 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestArenaMap_MapFixed64Fixed64Entry__Descriptor; } + get { return global::Google.Protobuf.TestProtos.TestArenaMap.Descriptor.NestedTypes[7]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestArenaMap_MapFixed64Fixed64Entry__FieldAccessorTable; } } @@ -5456,10 +5365,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "key", "value" }; private static readonly uint[] _fieldTags = new uint[] { 13, 21 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestArenaMap_MapSfixed32Sfixed32Entry__Descriptor; } + get { return global::Google.Protobuf.TestProtos.TestArenaMap.Descriptor.NestedTypes[8]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestArenaMap_MapSfixed32Sfixed32Entry__FieldAccessorTable; } } @@ -5594,10 +5503,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "key", "value" }; private static readonly uint[] _fieldTags = new uint[] { 9, 17 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestArenaMap_MapSfixed64Sfixed64Entry__Descriptor; } + get { return global::Google.Protobuf.TestProtos.TestArenaMap.Descriptor.NestedTypes[9]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestArenaMap_MapSfixed64Sfixed64Entry__FieldAccessorTable; } } @@ -5732,10 +5641,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "key", "value" }; private static readonly uint[] _fieldTags = new uint[] { 8, 21 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestArenaMap_MapInt32FloatEntry__Descriptor; } + get { return global::Google.Protobuf.TestProtos.TestArenaMap.Descriptor.NestedTypes[10]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestArenaMap_MapInt32FloatEntry__FieldAccessorTable; } } @@ -5870,10 +5779,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "key", "value" }; private static readonly uint[] _fieldTags = new uint[] { 8, 17 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestArenaMap_MapInt32DoubleEntry__Descriptor; } + get { return global::Google.Protobuf.TestProtos.TestArenaMap.Descriptor.NestedTypes[11]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestArenaMap_MapInt32DoubleEntry__FieldAccessorTable; } } @@ -6008,10 +5917,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "key", "value" }; private static readonly uint[] _fieldTags = new uint[] { 8, 16 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestArenaMap_MapBoolBoolEntry__Descriptor; } + get { return global::Google.Protobuf.TestProtos.TestArenaMap.Descriptor.NestedTypes[12]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestArenaMap_MapBoolBoolEntry__FieldAccessorTable; } } @@ -6146,10 +6055,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "key", "value" }; private static readonly uint[] _fieldTags = new uint[] { 8, 16 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestArenaMap_MapInt32EnumEntry__Descriptor; } + get { return global::Google.Protobuf.TestProtos.TestArenaMap.Descriptor.NestedTypes[13]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestArenaMap_MapInt32EnumEntry__FieldAccessorTable; } } @@ -6284,10 +6193,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "key", "value" }; private static readonly uint[] _fieldTags = new uint[] { 8, 18 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestArenaMap_MapInt32ForeignMessageEntry__Descriptor; } + get { return global::Google.Protobuf.TestProtos.TestArenaMap.Descriptor.NestedTypes[14]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestArenaMap_MapInt32ForeignMessageEntry__FieldAccessorTable; } } @@ -6434,10 +6343,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "type" }; private static readonly uint[] _fieldTags = new uint[] { 10 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_MessageContainingEnumCalledType__Descriptor; } + get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.Descriptor.MessageTypes[5]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_MessageContainingEnumCalledType__FieldAccessorTable; } } @@ -6542,10 +6451,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "key", "value" }; private static readonly uint[] _fieldTags = new uint[] { 8, 18 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_MessageContainingEnumCalledType_TypeEntry__Descriptor; } + get { return global::Google.Protobuf.TestProtos.MessageContainingEnumCalledType.Descriptor.NestedTypes[0]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_MessageContainingEnumCalledType_TypeEntry__FieldAccessorTable; } } @@ -6692,10 +6601,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "entry" }; private static readonly uint[] _fieldTags = new uint[] { 10 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_MessageContainingMapCalledEntry__Descriptor; } + get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.Descriptor.MessageTypes[6]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_MessageContainingMapCalledEntry__FieldAccessorTable; } } @@ -6796,10 +6705,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "key", "value" }; private static readonly uint[] _fieldTags = new uint[] { 8, 16 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_MessageContainingMapCalledEntry_EntryEntry__Descriptor; } + get { return global::Google.Protobuf.TestProtos.MessageContainingMapCalledEntry.Descriptor.NestedTypes[0]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_MessageContainingMapCalledEntry_EntryEntry__FieldAccessorTable; } } diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportProto3.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportProto3.cs index 939be74a..5afcb4e0 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportProto3.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportProto3.cs @@ -13,8 +13,7 @@ namespace Google.Protobuf.TestProtos { public static partial class UnittestImportProto3 { #region Static variables - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_import_ImportMessage__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_import_ImportMessage__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_import_ImportMessage__FieldAccessorTable; #endregion #region Descriptor public static pbd::FileDescriptor Descriptor { @@ -33,17 +32,13 @@ namespace Google.Protobuf.TestProtos { "UhAIEg4KCklNUE9SVF9CQVoQCUI8Chhjb20uZ29vZ2xlLnByb3RvYnVmLnRl", "c3RIAfgBAaoCGkdvb2dsZS5Qcm90b2J1Zi5UZXN0UHJvdG9zUABiBnByb3Rv", "Mw==")); - pbd::FileDescriptor.InternalDescriptorAssigner assigner = delegate(pbd::FileDescriptor root) { - descriptor = root; - internal__static_protobuf_unittest_import_ImportMessage__Descriptor = Descriptor.MessageTypes[0]; - internal__static_protobuf_unittest_import_ImportMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_import_ImportMessage__Descriptor, - new string[] { "D", }); - }; - pbd::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, + descriptor = pbd::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, new pbd::FileDescriptor[] { global::Google.Protobuf.TestProtos.UnittestImportPublicProto3.Descriptor, - }, assigner); + }); + internal__static_protobuf_unittest_import_ImportMessage__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.ImportMessage), descriptor.MessageTypes[0], + new string[] { "D", }); } #endregion @@ -67,10 +62,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "d" }; private static readonly uint[] _fieldTags = new uint[] { 8 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestImportProto3.internal__static_protobuf_unittest_import_ImportMessage__Descriptor; } + get { return global::Google.Protobuf.TestProtos.UnittestImportProto3.Descriptor.MessageTypes[0]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.UnittestImportProto3.internal__static_protobuf_unittest_import_ImportMessage__FieldAccessorTable; } } diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportPublicProto3.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportPublicProto3.cs index a5a33ea7..79c0876e 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportPublicProto3.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportPublicProto3.cs @@ -13,8 +13,7 @@ namespace Google.Protobuf.TestProtos { public static partial class UnittestImportPublicProto3 { #region Static variables - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_import_PublicImportMessage__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_import_PublicImportMessage__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_import_PublicImportMessage__FieldAccessorTable; #endregion #region Descriptor public static pbd::FileDescriptor Descriptor { @@ -29,16 +28,12 @@ namespace Google.Protobuf.TestProtos { "bzMucHJvdG8SGHByb3RvYnVmX3VuaXR0ZXN0X2ltcG9ydCIgChNQdWJsaWNJ", "bXBvcnRNZXNzYWdlEgkKAWUYASABKAVCNwoYY29tLmdvb2dsZS5wcm90b2J1", "Zi50ZXN0qgIaR29vZ2xlLlByb3RvYnVmLlRlc3RQcm90b3NiBnByb3RvMw==")); - pbd::FileDescriptor.InternalDescriptorAssigner assigner = delegate(pbd::FileDescriptor root) { - descriptor = root; - internal__static_protobuf_unittest_import_PublicImportMessage__Descriptor = Descriptor.MessageTypes[0]; - internal__static_protobuf_unittest_import_PublicImportMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_import_PublicImportMessage__Descriptor, - new string[] { "E", }); - }; - pbd::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, + descriptor = pbd::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, new pbd::FileDescriptor[] { - }, assigner); + }); + internal__static_protobuf_unittest_import_PublicImportMessage__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.PublicImportMessage), descriptor.MessageTypes[0], + new string[] { "E", }); } #endregion @@ -52,10 +47,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "e" }; private static readonly uint[] _fieldTags = new uint[] { 8 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestImportPublicProto3.internal__static_protobuf_unittest_import_PublicImportMessage__Descriptor; } + get { return global::Google.Protobuf.TestProtos.UnittestImportPublicProto3.Descriptor.MessageTypes[0]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.UnittestImportPublicProto3.internal__static_protobuf_unittest_import_PublicImportMessage__FieldAccessorTable; } } diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs index 16bdb3f2..124f2de7 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs @@ -13,20 +13,13 @@ namespace UnitTest.Issues.TestProtos { public static partial class UnittestIssues { #region Static variables - internal static pbd::MessageDescriptor internal__static_unittest_issues_Issue307__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_unittest_issues_Issue307__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_unittest_issues_Issue307_NestedOnce__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_unittest_issues_Issue307_NestedOnce__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_unittest_issues_Issue307_NestedOnce_NestedTwice__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_unittest_issues_Issue307_NestedOnce_NestedTwice__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_unittest_issues_NegativeEnumMessage__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_unittest_issues_NegativeEnumMessage__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_unittest_issues_DeprecatedChild__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_unittest_issues_DeprecatedChild__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_unittest_issues_DeprecatedFieldsMessage__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_unittest_issues_DeprecatedFieldsMessage__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_unittest_issues_ItemField__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_unittest_issues_ItemField__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_unittest_issues_Issue307__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_unittest_issues_Issue307_NestedOnce__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_unittest_issues_Issue307_NestedOnce_NestedTwice__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_unittest_issues_NegativeEnumMessage__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_unittest_issues_DeprecatedChild__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_unittest_issues_DeprecatedFieldsMessage__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_unittest_issues_ItemField__FieldAccessorTable; #endregion #region Descriptor public static pbd::FileDescriptor Descriptor { @@ -55,40 +48,30 @@ namespace UnitTest.Issues.TestProtos { "EPv//////////wESFQoITWludXNPbmUQ////////////ASouCg5EZXByZWNh", "dGVkRW51bRITCg9ERVBSRUNBVEVEX1pFUk8QABIHCgNvbmUQAUIfSAGqAhpV", "bml0VGVzdC5Jc3N1ZXMuVGVzdFByb3Rvc2IGcHJvdG8z")); - pbd::FileDescriptor.InternalDescriptorAssigner assigner = delegate(pbd::FileDescriptor root) { - descriptor = root; - internal__static_unittest_issues_Issue307__Descriptor = Descriptor.MessageTypes[0]; - internal__static_unittest_issues_Issue307__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_unittest_issues_Issue307__Descriptor, - new string[] { }); - internal__static_unittest_issues_Issue307_NestedOnce__Descriptor = internal__static_unittest_issues_Issue307__Descriptor.NestedTypes[0]; - internal__static_unittest_issues_Issue307_NestedOnce__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_unittest_issues_Issue307_NestedOnce__Descriptor, - new string[] { }); - internal__static_unittest_issues_Issue307_NestedOnce_NestedTwice__Descriptor = internal__static_unittest_issues_Issue307_NestedOnce__Descriptor.NestedTypes[0]; - internal__static_unittest_issues_Issue307_NestedOnce_NestedTwice__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_unittest_issues_Issue307_NestedOnce_NestedTwice__Descriptor, - new string[] { }); - internal__static_unittest_issues_NegativeEnumMessage__Descriptor = Descriptor.MessageTypes[1]; - internal__static_unittest_issues_NegativeEnumMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_unittest_issues_NegativeEnumMessage__Descriptor, - new string[] { "Value", "Values", "PackedValues", }); - internal__static_unittest_issues_DeprecatedChild__Descriptor = Descriptor.MessageTypes[2]; - internal__static_unittest_issues_DeprecatedChild__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_unittest_issues_DeprecatedChild__Descriptor, - new string[] { }); - internal__static_unittest_issues_DeprecatedFieldsMessage__Descriptor = Descriptor.MessageTypes[3]; - internal__static_unittest_issues_DeprecatedFieldsMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_unittest_issues_DeprecatedFieldsMessage__Descriptor, - new string[] { "PrimitiveValue", "PrimitiveArray", "MessageValue", "MessageArray", "EnumValue", "EnumArray", }); - internal__static_unittest_issues_ItemField__Descriptor = Descriptor.MessageTypes[4]; - internal__static_unittest_issues_ItemField__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_unittest_issues_ItemField__Descriptor, - new string[] { "Item", }); - }; - pbd::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, + descriptor = pbd::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, new pbd::FileDescriptor[] { - }, assigner); + }); + internal__static_unittest_issues_Issue307__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::UnitTest.Issues.TestProtos.Issue307), descriptor.MessageTypes[0], + new string[] { }); + internal__static_unittest_issues_Issue307_NestedOnce__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::UnitTest.Issues.TestProtos.Issue307.Types.NestedOnce), descriptor.MessageTypes[0].NestedTypes[0], + new string[] { }); + internal__static_unittest_issues_Issue307_NestedOnce_NestedTwice__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::UnitTest.Issues.TestProtos.Issue307.Types.NestedOnce.Types.NestedTwice), descriptor.MessageTypes[0].NestedTypes[0].NestedTypes[0], + new string[] { }); + internal__static_unittest_issues_NegativeEnumMessage__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::UnitTest.Issues.TestProtos.NegativeEnumMessage), descriptor.MessageTypes[1], + new string[] { "Value", "Values", "PackedValues", }); + internal__static_unittest_issues_DeprecatedChild__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::UnitTest.Issues.TestProtos.DeprecatedChild), descriptor.MessageTypes[2], + new string[] { }); + internal__static_unittest_issues_DeprecatedFieldsMessage__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::UnitTest.Issues.TestProtos.DeprecatedFieldsMessage), descriptor.MessageTypes[3], + new string[] { "PrimitiveValue", "PrimitiveArray", "MessageValue", "MessageArray", "EnumValue", "EnumArray", }); + internal__static_unittest_issues_ItemField__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::UnitTest.Issues.TestProtos.ItemField), descriptor.MessageTypes[4], + new string[] { "Item", }); } #endregion @@ -116,10 +99,10 @@ namespace UnitTest.Issues.TestProtos { private static readonly string[] _fieldNames = new string[] { }; private static readonly uint[] _fieldTags = new uint[] { }; public static pbd::MessageDescriptor Descriptor { - get { return global::UnitTest.Issues.TestProtos.UnittestIssues.internal__static_unittest_issues_Issue307__Descriptor; } + get { return global::UnitTest.Issues.TestProtos.UnittestIssues.Descriptor.MessageTypes[0]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::UnitTest.Issues.TestProtos.UnittestIssues.internal__static_unittest_issues_Issue307__FieldAccessorTable; } } @@ -201,10 +184,10 @@ namespace UnitTest.Issues.TestProtos { private static readonly string[] _fieldNames = new string[] { }; private static readonly uint[] _fieldTags = new uint[] { }; public static pbd::MessageDescriptor Descriptor { - get { return global::UnitTest.Issues.TestProtos.UnittestIssues.internal__static_unittest_issues_Issue307_NestedOnce__Descriptor; } + get { return global::UnitTest.Issues.TestProtos.Issue307.Descriptor.NestedTypes[0]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::UnitTest.Issues.TestProtos.UnittestIssues.internal__static_unittest_issues_Issue307_NestedOnce__FieldAccessorTable; } } @@ -286,10 +269,10 @@ namespace UnitTest.Issues.TestProtos { private static readonly string[] _fieldNames = new string[] { }; private static readonly uint[] _fieldTags = new uint[] { }; public static pbd::MessageDescriptor Descriptor { - get { return global::UnitTest.Issues.TestProtos.UnittestIssues.internal__static_unittest_issues_Issue307_NestedOnce_NestedTwice__Descriptor; } + get { return global::UnitTest.Issues.TestProtos.Issue307.Types.NestedOnce.Descriptor.NestedTypes[0]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::UnitTest.Issues.TestProtos.UnittestIssues.internal__static_unittest_issues_Issue307_NestedOnce_NestedTwice__FieldAccessorTable; } } @@ -380,10 +363,10 @@ namespace UnitTest.Issues.TestProtos { private static readonly string[] _fieldNames = new string[] { "packed_values", "value", "values" }; private static readonly uint[] _fieldTags = new uint[] { 26, 8, 16 }; public static pbd::MessageDescriptor Descriptor { - get { return global::UnitTest.Issues.TestProtos.UnittestIssues.internal__static_unittest_issues_NegativeEnumMessage__Descriptor; } + get { return global::UnitTest.Issues.TestProtos.UnittestIssues.Descriptor.MessageTypes[1]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::UnitTest.Issues.TestProtos.UnittestIssues.internal__static_unittest_issues_NegativeEnumMessage__FieldAccessorTable; } } @@ -529,10 +512,10 @@ namespace UnitTest.Issues.TestProtos { private static readonly string[] _fieldNames = new string[] { }; private static readonly uint[] _fieldTags = new uint[] { }; public static pbd::MessageDescriptor Descriptor { - get { return global::UnitTest.Issues.TestProtos.UnittestIssues.internal__static_unittest_issues_DeprecatedChild__Descriptor; } + get { return global::UnitTest.Issues.TestProtos.UnittestIssues.Descriptor.MessageTypes[2]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::UnitTest.Issues.TestProtos.UnittestIssues.internal__static_unittest_issues_DeprecatedChild__FieldAccessorTable; } } @@ -613,10 +596,10 @@ namespace UnitTest.Issues.TestProtos { private static readonly string[] _fieldNames = new string[] { "EnumArray", "EnumValue", "MessageArray", "MessageValue", "PrimitiveArray", "PrimitiveValue" }; private static readonly uint[] _fieldTags = new uint[] { 50, 40, 34, 26, 18, 8 }; public static pbd::MessageDescriptor Descriptor { - get { return global::UnitTest.Issues.TestProtos.UnittestIssues.internal__static_unittest_issues_DeprecatedFieldsMessage__Descriptor; } + get { return global::UnitTest.Issues.TestProtos.UnittestIssues.Descriptor.MessageTypes[3]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::UnitTest.Issues.TestProtos.UnittestIssues.internal__static_unittest_issues_DeprecatedFieldsMessage__FieldAccessorTable; } } @@ -849,10 +832,10 @@ namespace UnitTest.Issues.TestProtos { private static readonly string[] _fieldNames = new string[] { "item" }; private static readonly uint[] _fieldTags = new uint[] { 8 }; public static pbd::MessageDescriptor Descriptor { - get { return global::UnitTest.Issues.TestProtos.UnittestIssues.internal__static_unittest_issues_ItemField__Descriptor; } + get { return global::UnitTest.Issues.TestProtos.UnittestIssues.Descriptor.MessageTypes[4]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::UnitTest.Issues.TestProtos.UnittestIssues.internal__static_unittest_issues_ItemField__FieldAccessorTable; } } diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs index ea486fcc..c9aed740 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs @@ -13,76 +13,41 @@ namespace Google.Protobuf.TestProtos { public static partial class UnittestProto3 { #region Static variables - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestAllTypes__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestAllTypes__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestAllTypes_NestedMessage__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestAllTypes_NestedMessage__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_NestedTestAllTypes__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_NestedTestAllTypes__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestDeprecatedFields__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestDeprecatedFields__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_ForeignMessage__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_ForeignMessage__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestReservedFields__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestReservedFields__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestForeignNested__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestForeignNested__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestReallyLargeTagNumber__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestReallyLargeTagNumber__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestRecursiveMessage__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestRecursiveMessage__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestMutualRecursionA__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMutualRecursionA__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestMutualRecursionB__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMutualRecursionB__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestCamelCaseFieldNames__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestCamelCaseFieldNames__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestFieldOrderings__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestFieldOrderings__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestFieldOrderings_NestedMessage__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestFieldOrderings_NestedMessage__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_SparseEnumMessage__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_SparseEnumMessage__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_OneString__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_OneString__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_MoreString__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_MoreString__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_OneBytes__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_OneBytes__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_MoreBytes__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_MoreBytes__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_Int32Message__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_Int32Message__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_Uint32Message__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_Uint32Message__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_Int64Message__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_Int64Message__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_Uint64Message__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_Uint64Message__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_BoolMessage__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_BoolMessage__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestOneof__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestOneof__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestPackedTypes__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestPackedTypes__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestUnpackedTypes__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestUnpackedTypes__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestRepeatedScalarDifferentTagSizes__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestRepeatedScalarDifferentTagSizes__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_TestCommentInjectionMessage__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestCommentInjectionMessage__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_FooRequest__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_FooRequest__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_FooResponse__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_FooResponse__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_FooClientMessage__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_FooClientMessage__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_FooServerMessage__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_FooServerMessage__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_BarRequest__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_BarRequest__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_protobuf_unittest_BarResponse__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_BarResponse__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestAllTypes__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestAllTypes_NestedMessage__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_NestedTestAllTypes__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestDeprecatedFields__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_ForeignMessage__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestReservedFields__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestForeignNested__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestReallyLargeTagNumber__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestRecursiveMessage__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMutualRecursionA__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestMutualRecursionB__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestCamelCaseFieldNames__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestFieldOrderings__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestFieldOrderings_NestedMessage__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_SparseEnumMessage__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_OneString__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_MoreString__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_OneBytes__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_MoreBytes__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_Int32Message__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_Uint32Message__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_Int64Message__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_Uint64Message__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_BoolMessage__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestOneof__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestPackedTypes__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestUnpackedTypes__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestRepeatedScalarDifferentTagSizes__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_TestCommentInjectionMessage__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_FooRequest__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_FooResponse__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_FooClientMessage__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_FooServerMessage__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_BarRequest__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_protobuf_unittest_BarResponse__FieldAccessorTable; #endregion #region Descriptor public static pbd::FileDescriptor Descriptor { @@ -220,153 +185,115 @@ namespace Google.Protobuf.TestProtos { "HS5wcm90b2J1Zl91bml0dGVzdC5CYXJSZXF1ZXN0Gh4ucHJvdG9idWZfdW5p", "dHRlc3QuQmFyUmVzcG9uc2VCOkINVW5pdHRlc3RQcm90b0gBgAEBiAEBkAEB", "+AEBqgIaR29vZ2xlLlByb3RvYnVmLlRlc3RQcm90b3NiBnByb3RvMw==")); - pbd::FileDescriptor.InternalDescriptorAssigner assigner = delegate(pbd::FileDescriptor root) { - descriptor = root; - internal__static_protobuf_unittest_TestAllTypes__Descriptor = Descriptor.MessageTypes[0]; - internal__static_protobuf_unittest_TestAllTypes__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestAllTypes__Descriptor, - new string[] { "SingleInt32", "SingleInt64", "SingleUint32", "SingleUint64", "SingleSint32", "SingleSint64", "SingleFixed32", "SingleFixed64", "SingleSfixed32", "SingleSfixed64", "SingleFloat", "SingleDouble", "SingleBool", "SingleString", "SingleBytes", "SingleNestedMessage", "SingleForeignMessage", "SingleImportMessage", "SingleNestedEnum", "SingleForeignEnum", "SingleImportEnum", "SinglePublicImportMessage", "RepeatedInt32", "RepeatedInt64", "RepeatedUint32", "RepeatedUint64", "RepeatedSint32", "RepeatedSint64", "RepeatedFixed32", "RepeatedFixed64", "RepeatedSfixed32", "RepeatedSfixed64", "RepeatedFloat", "RepeatedDouble", "RepeatedBool", "RepeatedString", "RepeatedBytes", "RepeatedNestedMessage", "RepeatedForeignMessage", "RepeatedImportMessage", "RepeatedNestedEnum", "RepeatedForeignEnum", "RepeatedImportEnum", "RepeatedPublicImportMessage", "OneofUint32", "OneofNestedMessage", "OneofString", "OneofBytes", "OneofField", }); - internal__static_protobuf_unittest_TestAllTypes_NestedMessage__Descriptor = internal__static_protobuf_unittest_TestAllTypes__Descriptor.NestedTypes[0]; - internal__static_protobuf_unittest_TestAllTypes_NestedMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestAllTypes_NestedMessage__Descriptor, - new string[] { "Bb", }); - internal__static_protobuf_unittest_NestedTestAllTypes__Descriptor = Descriptor.MessageTypes[1]; - internal__static_protobuf_unittest_NestedTestAllTypes__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_NestedTestAllTypes__Descriptor, - new string[] { "Child", "Payload", "RepeatedChild", }); - internal__static_protobuf_unittest_TestDeprecatedFields__Descriptor = Descriptor.MessageTypes[2]; - internal__static_protobuf_unittest_TestDeprecatedFields__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestDeprecatedFields__Descriptor, - new string[] { "DeprecatedInt32", }); - internal__static_protobuf_unittest_ForeignMessage__Descriptor = Descriptor.MessageTypes[3]; - internal__static_protobuf_unittest_ForeignMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_ForeignMessage__Descriptor, - new string[] { "C", }); - internal__static_protobuf_unittest_TestReservedFields__Descriptor = Descriptor.MessageTypes[4]; - internal__static_protobuf_unittest_TestReservedFields__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestReservedFields__Descriptor, - new string[] { }); - internal__static_protobuf_unittest_TestForeignNested__Descriptor = Descriptor.MessageTypes[5]; - internal__static_protobuf_unittest_TestForeignNested__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestForeignNested__Descriptor, - new string[] { "ForeignNested", }); - internal__static_protobuf_unittest_TestReallyLargeTagNumber__Descriptor = Descriptor.MessageTypes[6]; - internal__static_protobuf_unittest_TestReallyLargeTagNumber__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestReallyLargeTagNumber__Descriptor, - new string[] { "A", "Bb", }); - internal__static_protobuf_unittest_TestRecursiveMessage__Descriptor = Descriptor.MessageTypes[7]; - internal__static_protobuf_unittest_TestRecursiveMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestRecursiveMessage__Descriptor, - new string[] { "A", "I", }); - internal__static_protobuf_unittest_TestMutualRecursionA__Descriptor = Descriptor.MessageTypes[8]; - internal__static_protobuf_unittest_TestMutualRecursionA__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestMutualRecursionA__Descriptor, - new string[] { "Bb", }); - internal__static_protobuf_unittest_TestMutualRecursionB__Descriptor = Descriptor.MessageTypes[9]; - internal__static_protobuf_unittest_TestMutualRecursionB__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestMutualRecursionB__Descriptor, - new string[] { "A", "OptionalInt32", }); - internal__static_protobuf_unittest_TestCamelCaseFieldNames__Descriptor = Descriptor.MessageTypes[10]; - internal__static_protobuf_unittest_TestCamelCaseFieldNames__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestCamelCaseFieldNames__Descriptor, - new string[] { "PrimitiveField", "StringField", "EnumField", "MessageField", "RepeatedPrimitiveField", "RepeatedStringField", "RepeatedEnumField", "RepeatedMessageField", }); - internal__static_protobuf_unittest_TestFieldOrderings__Descriptor = Descriptor.MessageTypes[11]; - internal__static_protobuf_unittest_TestFieldOrderings__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestFieldOrderings__Descriptor, - new string[] { "MyString", "MyInt", "MyFloat", "SingleNestedMessage", }); - internal__static_protobuf_unittest_TestFieldOrderings_NestedMessage__Descriptor = internal__static_protobuf_unittest_TestFieldOrderings__Descriptor.NestedTypes[0]; - internal__static_protobuf_unittest_TestFieldOrderings_NestedMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestFieldOrderings_NestedMessage__Descriptor, - new string[] { "Oo", "Bb", }); - internal__static_protobuf_unittest_SparseEnumMessage__Descriptor = Descriptor.MessageTypes[12]; - internal__static_protobuf_unittest_SparseEnumMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_SparseEnumMessage__Descriptor, - new string[] { "SparseEnum", }); - internal__static_protobuf_unittest_OneString__Descriptor = Descriptor.MessageTypes[13]; - internal__static_protobuf_unittest_OneString__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_OneString__Descriptor, - new string[] { "Data", }); - internal__static_protobuf_unittest_MoreString__Descriptor = Descriptor.MessageTypes[14]; - internal__static_protobuf_unittest_MoreString__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_MoreString__Descriptor, - new string[] { "Data", }); - internal__static_protobuf_unittest_OneBytes__Descriptor = Descriptor.MessageTypes[15]; - internal__static_protobuf_unittest_OneBytes__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_OneBytes__Descriptor, - new string[] { "Data", }); - internal__static_protobuf_unittest_MoreBytes__Descriptor = Descriptor.MessageTypes[16]; - internal__static_protobuf_unittest_MoreBytes__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_MoreBytes__Descriptor, - new string[] { "Data", }); - internal__static_protobuf_unittest_Int32Message__Descriptor = Descriptor.MessageTypes[17]; - internal__static_protobuf_unittest_Int32Message__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_Int32Message__Descriptor, - new string[] { "Data", }); - internal__static_protobuf_unittest_Uint32Message__Descriptor = Descriptor.MessageTypes[18]; - internal__static_protobuf_unittest_Uint32Message__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_Uint32Message__Descriptor, - new string[] { "Data", }); - internal__static_protobuf_unittest_Int64Message__Descriptor = Descriptor.MessageTypes[19]; - internal__static_protobuf_unittest_Int64Message__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_Int64Message__Descriptor, - new string[] { "Data", }); - internal__static_protobuf_unittest_Uint64Message__Descriptor = Descriptor.MessageTypes[20]; - internal__static_protobuf_unittest_Uint64Message__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_Uint64Message__Descriptor, - new string[] { "Data", }); - internal__static_protobuf_unittest_BoolMessage__Descriptor = Descriptor.MessageTypes[21]; - internal__static_protobuf_unittest_BoolMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_BoolMessage__Descriptor, - new string[] { "Data", }); - internal__static_protobuf_unittest_TestOneof__Descriptor = Descriptor.MessageTypes[22]; - internal__static_protobuf_unittest_TestOneof__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestOneof__Descriptor, - new string[] { "FooInt", "FooString", "FooMessage", "Foo", }); - internal__static_protobuf_unittest_TestPackedTypes__Descriptor = Descriptor.MessageTypes[23]; - internal__static_protobuf_unittest_TestPackedTypes__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestPackedTypes__Descriptor, - new string[] { "PackedInt32", "PackedInt64", "PackedUint32", "PackedUint64", "PackedSint32", "PackedSint64", "PackedFixed32", "PackedFixed64", "PackedSfixed32", "PackedSfixed64", "PackedFloat", "PackedDouble", "PackedBool", "PackedEnum", }); - internal__static_protobuf_unittest_TestUnpackedTypes__Descriptor = Descriptor.MessageTypes[24]; - internal__static_protobuf_unittest_TestUnpackedTypes__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestUnpackedTypes__Descriptor, - new string[] { "UnpackedInt32", "UnpackedInt64", "UnpackedUint32", "UnpackedUint64", "UnpackedSint32", "UnpackedSint64", "UnpackedFixed32", "UnpackedFixed64", "UnpackedSfixed32", "UnpackedSfixed64", "UnpackedFloat", "UnpackedDouble", "UnpackedBool", "UnpackedEnum", }); - internal__static_protobuf_unittest_TestRepeatedScalarDifferentTagSizes__Descriptor = Descriptor.MessageTypes[25]; - internal__static_protobuf_unittest_TestRepeatedScalarDifferentTagSizes__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestRepeatedScalarDifferentTagSizes__Descriptor, - new string[] { "RepeatedFixed32", "RepeatedInt32", "RepeatedFixed64", "RepeatedInt64", "RepeatedFloat", "RepeatedUint64", }); - internal__static_protobuf_unittest_TestCommentInjectionMessage__Descriptor = Descriptor.MessageTypes[26]; - internal__static_protobuf_unittest_TestCommentInjectionMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_TestCommentInjectionMessage__Descriptor, - new string[] { "A", }); - internal__static_protobuf_unittest_FooRequest__Descriptor = Descriptor.MessageTypes[27]; - internal__static_protobuf_unittest_FooRequest__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_FooRequest__Descriptor, - new string[] { }); - internal__static_protobuf_unittest_FooResponse__Descriptor = Descriptor.MessageTypes[28]; - internal__static_protobuf_unittest_FooResponse__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_FooResponse__Descriptor, - new string[] { }); - internal__static_protobuf_unittest_FooClientMessage__Descriptor = Descriptor.MessageTypes[29]; - internal__static_protobuf_unittest_FooClientMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_FooClientMessage__Descriptor, - new string[] { }); - internal__static_protobuf_unittest_FooServerMessage__Descriptor = Descriptor.MessageTypes[30]; - internal__static_protobuf_unittest_FooServerMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_FooServerMessage__Descriptor, - new string[] { }); - internal__static_protobuf_unittest_BarRequest__Descriptor = Descriptor.MessageTypes[31]; - internal__static_protobuf_unittest_BarRequest__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_BarRequest__Descriptor, - new string[] { }); - internal__static_protobuf_unittest_BarResponse__Descriptor = Descriptor.MessageTypes[32]; - internal__static_protobuf_unittest_BarResponse__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_protobuf_unittest_BarResponse__Descriptor, - new string[] { }); - }; - pbd::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, + descriptor = pbd::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, new pbd::FileDescriptor[] { global::Google.Protobuf.TestProtos.UnittestImportProto3.Descriptor, - }, assigner); + }); + internal__static_protobuf_unittest_TestAllTypes__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestAllTypes), descriptor.MessageTypes[0], + new string[] { "SingleInt32", "SingleInt64", "SingleUint32", "SingleUint64", "SingleSint32", "SingleSint64", "SingleFixed32", "SingleFixed64", "SingleSfixed32", "SingleSfixed64", "SingleFloat", "SingleDouble", "SingleBool", "SingleString", "SingleBytes", "SingleNestedMessage", "SingleForeignMessage", "SingleImportMessage", "SingleNestedEnum", "SingleForeignEnum", "SingleImportEnum", "SinglePublicImportMessage", "RepeatedInt32", "RepeatedInt64", "RepeatedUint32", "RepeatedUint64", "RepeatedSint32", "RepeatedSint64", "RepeatedFixed32", "RepeatedFixed64", "RepeatedSfixed32", "RepeatedSfixed64", "RepeatedFloat", "RepeatedDouble", "RepeatedBool", "RepeatedString", "RepeatedBytes", "RepeatedNestedMessage", "RepeatedForeignMessage", "RepeatedImportMessage", "RepeatedNestedEnum", "RepeatedForeignEnum", "RepeatedImportEnum", "RepeatedPublicImportMessage", "OneofUint32", "OneofNestedMessage", "OneofString", "OneofBytes", "OneofField", }); + internal__static_protobuf_unittest_TestAllTypes_NestedMessage__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage), descriptor.MessageTypes[0].NestedTypes[0], + new string[] { "Bb", }); + internal__static_protobuf_unittest_NestedTestAllTypes__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.NestedTestAllTypes), descriptor.MessageTypes[1], + new string[] { "Child", "Payload", "RepeatedChild", }); + internal__static_protobuf_unittest_TestDeprecatedFields__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestDeprecatedFields), descriptor.MessageTypes[2], + new string[] { "DeprecatedInt32", }); + internal__static_protobuf_unittest_ForeignMessage__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.ForeignMessage), descriptor.MessageTypes[3], + new string[] { "C", }); + internal__static_protobuf_unittest_TestReservedFields__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestReservedFields), descriptor.MessageTypes[4], + new string[] { }); + internal__static_protobuf_unittest_TestForeignNested__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestForeignNested), descriptor.MessageTypes[5], + new string[] { "ForeignNested", }); + internal__static_protobuf_unittest_TestReallyLargeTagNumber__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestReallyLargeTagNumber), descriptor.MessageTypes[6], + new string[] { "A", "Bb", }); + internal__static_protobuf_unittest_TestRecursiveMessage__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestRecursiveMessage), descriptor.MessageTypes[7], + new string[] { "A", "I", }); + internal__static_protobuf_unittest_TestMutualRecursionA__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMutualRecursionA), descriptor.MessageTypes[8], + new string[] { "Bb", }); + internal__static_protobuf_unittest_TestMutualRecursionB__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMutualRecursionB), descriptor.MessageTypes[9], + new string[] { "A", "OptionalInt32", }); + internal__static_protobuf_unittest_TestCamelCaseFieldNames__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestCamelCaseFieldNames), descriptor.MessageTypes[10], + new string[] { "PrimitiveField", "StringField", "EnumField", "MessageField", "RepeatedPrimitiveField", "RepeatedStringField", "RepeatedEnumField", "RepeatedMessageField", }); + internal__static_protobuf_unittest_TestFieldOrderings__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestFieldOrderings), descriptor.MessageTypes[11], + new string[] { "MyString", "MyInt", "MyFloat", "SingleNestedMessage", }); + internal__static_protobuf_unittest_TestFieldOrderings_NestedMessage__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestFieldOrderings.Types.NestedMessage), descriptor.MessageTypes[11].NestedTypes[0], + new string[] { "Oo", "Bb", }); + internal__static_protobuf_unittest_SparseEnumMessage__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.SparseEnumMessage), descriptor.MessageTypes[12], + new string[] { "SparseEnum", }); + internal__static_protobuf_unittest_OneString__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.OneString), descriptor.MessageTypes[13], + new string[] { "Data", }); + internal__static_protobuf_unittest_MoreString__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.MoreString), descriptor.MessageTypes[14], + new string[] { "Data", }); + internal__static_protobuf_unittest_OneBytes__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.OneBytes), descriptor.MessageTypes[15], + new string[] { "Data", }); + internal__static_protobuf_unittest_MoreBytes__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.MoreBytes), descriptor.MessageTypes[16], + new string[] { "Data", }); + internal__static_protobuf_unittest_Int32Message__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.Int32Message), descriptor.MessageTypes[17], + new string[] { "Data", }); + internal__static_protobuf_unittest_Uint32Message__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.Uint32Message), descriptor.MessageTypes[18], + new string[] { "Data", }); + internal__static_protobuf_unittest_Int64Message__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.Int64Message), descriptor.MessageTypes[19], + new string[] { "Data", }); + internal__static_protobuf_unittest_Uint64Message__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.Uint64Message), descriptor.MessageTypes[20], + new string[] { "Data", }); + internal__static_protobuf_unittest_BoolMessage__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.BoolMessage), descriptor.MessageTypes[21], + new string[] { "Data", }); + internal__static_protobuf_unittest_TestOneof__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestOneof), descriptor.MessageTypes[22], + new string[] { "FooInt", "FooString", "FooMessage", "Foo", }); + internal__static_protobuf_unittest_TestPackedTypes__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestPackedTypes), descriptor.MessageTypes[23], + new string[] { "PackedInt32", "PackedInt64", "PackedUint32", "PackedUint64", "PackedSint32", "PackedSint64", "PackedFixed32", "PackedFixed64", "PackedSfixed32", "PackedSfixed64", "PackedFloat", "PackedDouble", "PackedBool", "PackedEnum", }); + internal__static_protobuf_unittest_TestUnpackedTypes__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestUnpackedTypes), descriptor.MessageTypes[24], + new string[] { "UnpackedInt32", "UnpackedInt64", "UnpackedUint32", "UnpackedUint64", "UnpackedSint32", "UnpackedSint64", "UnpackedFixed32", "UnpackedFixed64", "UnpackedSfixed32", "UnpackedSfixed64", "UnpackedFloat", "UnpackedDouble", "UnpackedBool", "UnpackedEnum", }); + internal__static_protobuf_unittest_TestRepeatedScalarDifferentTagSizes__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestRepeatedScalarDifferentTagSizes), descriptor.MessageTypes[25], + new string[] { "RepeatedFixed32", "RepeatedInt32", "RepeatedFixed64", "RepeatedInt64", "RepeatedFloat", "RepeatedUint64", }); + internal__static_protobuf_unittest_TestCommentInjectionMessage__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestCommentInjectionMessage), descriptor.MessageTypes[26], + new string[] { "A", }); + internal__static_protobuf_unittest_FooRequest__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.FooRequest), descriptor.MessageTypes[27], + new string[] { }); + internal__static_protobuf_unittest_FooResponse__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.FooResponse), descriptor.MessageTypes[28], + new string[] { }); + internal__static_protobuf_unittest_FooClientMessage__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.FooClientMessage), descriptor.MessageTypes[29], + new string[] { }); + internal__static_protobuf_unittest_FooServerMessage__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.FooServerMessage), descriptor.MessageTypes[30], + new string[] { }); + internal__static_protobuf_unittest_BarRequest__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.BarRequest), descriptor.MessageTypes[31], + new string[] { }); + internal__static_protobuf_unittest_BarResponse__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.BarResponse), descriptor.MessageTypes[32], + new string[] { }); } #endregion @@ -409,10 +336,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "oneof_bytes", "oneof_nested_message", "oneof_string", "oneof_uint32", "repeated_bool", "repeated_bytes", "repeated_double", "repeated_fixed32", "repeated_fixed64", "repeated_float", "repeated_foreign_enum", "repeated_foreign_message", "repeated_import_enum", "repeated_import_message", "repeated_int32", "repeated_int64", "repeated_nested_enum", "repeated_nested_message", "repeated_public_import_message", "repeated_sfixed32", "repeated_sfixed64", "repeated_sint32", "repeated_sint64", "repeated_string", "repeated_uint32", "repeated_uint64", "single_bool", "single_bytes", "single_double", "single_fixed32", "single_fixed64", "single_float", "single_foreign_enum", "single_foreign_message", "single_import_enum", "single_import_message", "single_int32", "single_int64", "single_nested_enum", "single_nested_message", "single_public_import_message", "single_sfixed32", "single_sfixed64", "single_sint32", "single_sint64", "single_string", "single_uint32", "single_uint64" }; private static readonly uint[] _fieldTags = new uint[] { 914, 898, 906, 888, 346, 362, 338, 298, 306, 330, 418, 394, 426, 402, 250, 258, 410, 386, 434, 314, 322, 282, 290, 354, 266, 274, 104, 122, 97, 61, 65, 93, 176, 154, 184, 162, 8, 16, 168, 146, 210, 77, 81, 40, 48, 114, 24, 32 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestAllTypes__Descriptor; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[0]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestAllTypes__FieldAccessorTable; } } @@ -1702,10 +1629,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "bb" }; private static readonly uint[] _fieldTags = new uint[] { 8 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestAllTypes_NestedMessage__Descriptor; } + get { return global::Google.Protobuf.TestProtos.TestAllTypes.Descriptor.NestedTypes[0]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestAllTypes_NestedMessage__FieldAccessorTable; } } @@ -1818,10 +1745,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "child", "payload", "repeated_child" }; private static readonly uint[] _fieldTags = new uint[] { 10, 18, 26 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_NestedTestAllTypes__Descriptor; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[1]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_NestedTestAllTypes__FieldAccessorTable; } } @@ -1989,10 +1916,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "deprecated_int32" }; private static readonly uint[] _fieldTags = new uint[] { 8 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestDeprecatedFields__Descriptor; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[2]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestDeprecatedFields__FieldAccessorTable; } } @@ -2101,10 +2028,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "c" }; private static readonly uint[] _fieldTags = new uint[] { 8 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_ForeignMessage__Descriptor; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[3]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_ForeignMessage__FieldAccessorTable; } } @@ -2212,10 +2139,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { }; private static readonly uint[] _fieldTags = new uint[] { }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestReservedFields__Descriptor; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[4]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestReservedFields__FieldAccessorTable; } } @@ -2296,10 +2223,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "foreign_nested" }; private static readonly uint[] _fieldTags = new uint[] { 10 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestForeignNested__Descriptor; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[5]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestForeignNested__FieldAccessorTable; } } @@ -2414,10 +2341,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "a", "bb" }; private static readonly uint[] _fieldTags = new uint[] { 8, 2147483640 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestReallyLargeTagNumber__Descriptor; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[6]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestReallyLargeTagNumber__FieldAccessorTable; } } @@ -2552,10 +2479,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "a", "i" }; private static readonly uint[] _fieldTags = new uint[] { 10, 16 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestRecursiveMessage__Descriptor; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[7]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestRecursiveMessage__FieldAccessorTable; } } @@ -2697,10 +2624,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "bb" }; private static readonly uint[] _fieldTags = new uint[] { 10 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestMutualRecursionA__Descriptor; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[8]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestMutualRecursionA__FieldAccessorTable; } } @@ -2815,10 +2742,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "a", "optional_int32" }; private static readonly uint[] _fieldTags = new uint[] { 10, 16 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestMutualRecursionB__Descriptor; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[9]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestMutualRecursionB__FieldAccessorTable; } } @@ -2960,10 +2887,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "EnumField", "MessageField", "PrimitiveField", "RepeatedEnumField", "RepeatedMessageField", "RepeatedPrimitiveField", "RepeatedStringField", "StringField" }; private static readonly uint[] _fieldTags = new uint[] { 24, 34, 8, 74, 82, 58, 66, 18 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestCamelCaseFieldNames__Descriptor; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[10]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestCamelCaseFieldNames__FieldAccessorTable; } } @@ -3236,10 +3163,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "my_float", "my_int", "my_string", "single_nested_message" }; private static readonly uint[] _fieldTags = new uint[] { 813, 8, 90, 1602 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestFieldOrderings__Descriptor; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[11]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestFieldOrderings__FieldAccessorTable; } } @@ -3436,10 +3363,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "bb", "oo" }; private static readonly uint[] _fieldTags = new uint[] { 8, 16 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestFieldOrderings_NestedMessage__Descriptor; } + get { return global::Google.Protobuf.TestProtos.TestFieldOrderings.Descriptor.NestedTypes[0]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestFieldOrderings_NestedMessage__FieldAccessorTable; } } @@ -3579,10 +3506,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "sparse_enum" }; private static readonly uint[] _fieldTags = new uint[] { 8 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_SparseEnumMessage__Descriptor; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[12]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_SparseEnumMessage__FieldAccessorTable; } } @@ -3690,10 +3617,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "data" }; private static readonly uint[] _fieldTags = new uint[] { 10 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_OneString__Descriptor; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[13]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_OneString__FieldAccessorTable; } } @@ -3801,10 +3728,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "data" }; private static readonly uint[] _fieldTags = new uint[] { 10 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_MoreString__Descriptor; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[14]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_MoreString__FieldAccessorTable; } } @@ -3904,10 +3831,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "data" }; private static readonly uint[] _fieldTags = new uint[] { 10 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_OneBytes__Descriptor; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[15]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_OneBytes__FieldAccessorTable; } } @@ -4015,10 +3942,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "data" }; private static readonly uint[] _fieldTags = new uint[] { 10 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_MoreBytes__Descriptor; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[16]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_MoreBytes__FieldAccessorTable; } } @@ -4126,10 +4053,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "data" }; private static readonly uint[] _fieldTags = new uint[] { 8 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_Int32Message__Descriptor; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[17]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_Int32Message__FieldAccessorTable; } } @@ -4237,10 +4164,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "data" }; private static readonly uint[] _fieldTags = new uint[] { 8 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_Uint32Message__Descriptor; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[18]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_Uint32Message__FieldAccessorTable; } } @@ -4348,10 +4275,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "data" }; private static readonly uint[] _fieldTags = new uint[] { 8 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_Int64Message__Descriptor; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[19]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_Int64Message__FieldAccessorTable; } } @@ -4459,10 +4386,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "data" }; private static readonly uint[] _fieldTags = new uint[] { 8 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_Uint64Message__Descriptor; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[20]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_Uint64Message__FieldAccessorTable; } } @@ -4570,10 +4497,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "data" }; private static readonly uint[] _fieldTags = new uint[] { 8 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_BoolMessage__Descriptor; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[21]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_BoolMessage__FieldAccessorTable; } } @@ -4681,10 +4608,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "foo_int", "foo_message", "foo_string" }; private static readonly uint[] _fieldTags = new uint[] { 8, 26, 18 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestOneof__Descriptor; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[22]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestOneof__FieldAccessorTable; } } @@ -4882,10 +4809,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "packed_bool", "packed_double", "packed_enum", "packed_fixed32", "packed_fixed64", "packed_float", "packed_int32", "packed_int64", "packed_sfixed32", "packed_sfixed64", "packed_sint32", "packed_sint64", "packed_uint32", "packed_uint64" }; private static readonly uint[] _fieldTags = new uint[] { 818, 810, 826, 770, 778, 802, 722, 730, 786, 794, 754, 762, 738, 746 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestPackedTypes__Descriptor; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[23]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestPackedTypes__FieldAccessorTable; } } @@ -5245,10 +5172,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "unpacked_bool", "unpacked_double", "unpacked_enum", "unpacked_fixed32", "unpacked_fixed64", "unpacked_float", "unpacked_int32", "unpacked_int64", "unpacked_sfixed32", "unpacked_sfixed64", "unpacked_sint32", "unpacked_sint64", "unpacked_uint32", "unpacked_uint64" }; private static readonly uint[] _fieldTags = new uint[] { 816, 809, 824, 773, 777, 805, 720, 728, 789, 793, 752, 760, 736, 744 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestUnpackedTypes__Descriptor; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[24]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestUnpackedTypes__FieldAccessorTable; } } @@ -5608,10 +5535,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "repeated_fixed32", "repeated_fixed64", "repeated_float", "repeated_int32", "repeated_int64", "repeated_uint64" }; private static readonly uint[] _fieldTags = new uint[] { 98, 16370, 2097138, 106, 16378, 2097146 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestRepeatedScalarDifferentTagSizes__Descriptor; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[25]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestRepeatedScalarDifferentTagSizes__FieldAccessorTable; } } @@ -5812,10 +5739,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { "a" }; private static readonly uint[] _fieldTags = new uint[] { 10 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestCommentInjectionMessage__Descriptor; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[26]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestCommentInjectionMessage__FieldAccessorTable; } } @@ -5923,10 +5850,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { }; private static readonly uint[] _fieldTags = new uint[] { }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_FooRequest__Descriptor; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[27]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_FooRequest__FieldAccessorTable; } } @@ -6007,10 +5934,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { }; private static readonly uint[] _fieldTags = new uint[] { }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_FooResponse__Descriptor; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[28]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_FooResponse__FieldAccessorTable; } } @@ -6091,10 +6018,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { }; private static readonly uint[] _fieldTags = new uint[] { }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_FooClientMessage__Descriptor; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[29]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_FooClientMessage__FieldAccessorTable; } } @@ -6175,10 +6102,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { }; private static readonly uint[] _fieldTags = new uint[] { }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_FooServerMessage__Descriptor; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[30]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_FooServerMessage__FieldAccessorTable; } } @@ -6259,10 +6186,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { }; private static readonly uint[] _fieldTags = new uint[] { }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_BarRequest__Descriptor; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[31]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_BarRequest__FieldAccessorTable; } } @@ -6343,10 +6270,10 @@ namespace Google.Protobuf.TestProtos { private static readonly string[] _fieldNames = new string[] { }; private static readonly uint[] _fieldTags = new uint[] { }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_BarResponse__Descriptor; } + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[32]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_BarResponse__FieldAccessorTable; } } diff --git a/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs b/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs index 80166a34..3be7c4a9 100644 --- a/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs +++ b/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs @@ -13,50 +13,28 @@ namespace Google.Protobuf.DescriptorProtos { public static partial class DescriptorProtoFile { #region Static variables - internal static pbd::MessageDescriptor internal__static_google_protobuf_FileDescriptorSet__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_FileDescriptorSet__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_google_protobuf_FileDescriptorProto__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_FileDescriptorProto__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_google_protobuf_DescriptorProto__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_DescriptorProto__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_google_protobuf_DescriptorProto_ExtensionRange__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_DescriptorProto_ExtensionRange__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_google_protobuf_DescriptorProto_ReservedRange__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_DescriptorProto_ReservedRange__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_google_protobuf_FieldDescriptorProto__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_FieldDescriptorProto__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_google_protobuf_OneofDescriptorProto__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_OneofDescriptorProto__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_google_protobuf_EnumDescriptorProto__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_EnumDescriptorProto__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_google_protobuf_EnumValueDescriptorProto__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_EnumValueDescriptorProto__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_google_protobuf_ServiceDescriptorProto__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_ServiceDescriptorProto__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_google_protobuf_MethodDescriptorProto__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_MethodDescriptorProto__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_google_protobuf_FileOptions__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_FileOptions__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_google_protobuf_MessageOptions__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_MessageOptions__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_google_protobuf_FieldOptions__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_FieldOptions__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_google_protobuf_EnumOptions__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_EnumOptions__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_google_protobuf_EnumValueOptions__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_EnumValueOptions__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_google_protobuf_ServiceOptions__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_ServiceOptions__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_google_protobuf_MethodOptions__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_MethodOptions__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_google_protobuf_UninterpretedOption__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_UninterpretedOption__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_google_protobuf_UninterpretedOption_NamePart__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_UninterpretedOption_NamePart__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_google_protobuf_SourceCodeInfo__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_SourceCodeInfo__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_google_protobuf_SourceCodeInfo_Location__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_SourceCodeInfo_Location__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_FileDescriptorSet__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_FileDescriptorProto__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_DescriptorProto__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_DescriptorProto_ExtensionRange__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_DescriptorProto_ReservedRange__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_FieldDescriptorProto__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_OneofDescriptorProto__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_EnumDescriptorProto__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_EnumValueDescriptorProto__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_ServiceDescriptorProto__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_MethodDescriptorProto__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_FileOptions__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_MessageOptions__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_FieldOptions__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_EnumOptions__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_EnumValueOptions__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_ServiceOptions__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_MethodOptions__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_UninterpretedOption__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_UninterpretedOption_NamePart__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_SourceCodeInfo__FieldAccessorTable; + internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_SourceCodeInfo_Location__FieldAccessorTable; #endregion #region Descriptor public static pbd::FileDescriptor Descriptor { @@ -178,100 +156,75 @@ namespace Google.Protobuf.DescriptorProtos { "bWVudHMYBiADKAlCXgoTY29tLmdvb2dsZS5wcm90b2J1ZkIQRGVzY3JpcHRv", "clByb3Rvc0gBWgpkZXNjcmlwdG9yogIDR1BCqgIgR29vZ2xlLlByb3RvYnVm", "LkRlc2NyaXB0b3JQcm90b3M=")); - pbd::FileDescriptor.InternalDescriptorAssigner assigner = delegate(pbd::FileDescriptor root) { - descriptor = root; - internal__static_google_protobuf_FileDescriptorSet__Descriptor = Descriptor.MessageTypes[0]; - internal__static_google_protobuf_FileDescriptorSet__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_google_protobuf_FileDescriptorSet__Descriptor, - new string[] { "File", }); - internal__static_google_protobuf_FileDescriptorProto__Descriptor = Descriptor.MessageTypes[1]; - internal__static_google_protobuf_FileDescriptorProto__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_google_protobuf_FileDescriptorProto__Descriptor, - new string[] { "Name", "Package", "Dependency", "PublicDependency", "WeakDependency", "MessageType", "EnumType", "Service", "Extension", "Options", "SourceCodeInfo", "Syntax", }); - internal__static_google_protobuf_DescriptorProto__Descriptor = Descriptor.MessageTypes[2]; - internal__static_google_protobuf_DescriptorProto__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_google_protobuf_DescriptorProto__Descriptor, - new string[] { "Name", "Field", "Extension", "NestedType", "EnumType", "ExtensionRange", "OneofDecl", "Options", "ReservedRange", "ReservedName", }); - internal__static_google_protobuf_DescriptorProto_ExtensionRange__Descriptor = internal__static_google_protobuf_DescriptorProto__Descriptor.NestedTypes[0]; - internal__static_google_protobuf_DescriptorProto_ExtensionRange__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_google_protobuf_DescriptorProto_ExtensionRange__Descriptor, - new string[] { "Start", "End", }); - internal__static_google_protobuf_DescriptorProto_ReservedRange__Descriptor = internal__static_google_protobuf_DescriptorProto__Descriptor.NestedTypes[1]; - internal__static_google_protobuf_DescriptorProto_ReservedRange__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_google_protobuf_DescriptorProto_ReservedRange__Descriptor, - new string[] { "Start", "End", }); - internal__static_google_protobuf_FieldDescriptorProto__Descriptor = Descriptor.MessageTypes[3]; - internal__static_google_protobuf_FieldDescriptorProto__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_google_protobuf_FieldDescriptorProto__Descriptor, - new string[] { "Name", "Number", "Label", "Type", "TypeName", "Extendee", "DefaultValue", "OneofIndex", "Options", }); - internal__static_google_protobuf_OneofDescriptorProto__Descriptor = Descriptor.MessageTypes[4]; - internal__static_google_protobuf_OneofDescriptorProto__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_google_protobuf_OneofDescriptorProto__Descriptor, - new string[] { "Name", }); - internal__static_google_protobuf_EnumDescriptorProto__Descriptor = Descriptor.MessageTypes[5]; - internal__static_google_protobuf_EnumDescriptorProto__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_google_protobuf_EnumDescriptorProto__Descriptor, - new string[] { "Name", "Value", "Options", }); - internal__static_google_protobuf_EnumValueDescriptorProto__Descriptor = Descriptor.MessageTypes[6]; - internal__static_google_protobuf_EnumValueDescriptorProto__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_google_protobuf_EnumValueDescriptorProto__Descriptor, - new string[] { "Name", "Number", "Options", }); - internal__static_google_protobuf_ServiceDescriptorProto__Descriptor = Descriptor.MessageTypes[7]; - internal__static_google_protobuf_ServiceDescriptorProto__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_google_protobuf_ServiceDescriptorProto__Descriptor, - new string[] { "Name", "Method", "Options", }); - internal__static_google_protobuf_MethodDescriptorProto__Descriptor = Descriptor.MessageTypes[8]; - internal__static_google_protobuf_MethodDescriptorProto__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_google_protobuf_MethodDescriptorProto__Descriptor, - new string[] { "Name", "InputType", "OutputType", "Options", "ClientStreaming", "ServerStreaming", }); - internal__static_google_protobuf_FileOptions__Descriptor = Descriptor.MessageTypes[9]; - internal__static_google_protobuf_FileOptions__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_google_protobuf_FileOptions__Descriptor, - new string[] { "JavaPackage", "JavaOuterClassname", "JavaMultipleFiles", "JavaGenerateEqualsAndHash", "JavaStringCheckUtf8", "OptimizeFor", "GoPackage", "CcGenericServices", "JavaGenericServices", "PyGenericServices", "Deprecated", "CcEnableArenas", "ObjcClassPrefix", "CsharpNamespace", "UninterpretedOption", }); - internal__static_google_protobuf_MessageOptions__Descriptor = Descriptor.MessageTypes[10]; - internal__static_google_protobuf_MessageOptions__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_google_protobuf_MessageOptions__Descriptor, - new string[] { "MessageSetWireFormat", "NoStandardDescriptorAccessor", "Deprecated", "MapEntry", "UninterpretedOption", }); - internal__static_google_protobuf_FieldOptions__Descriptor = Descriptor.MessageTypes[11]; - internal__static_google_protobuf_FieldOptions__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_google_protobuf_FieldOptions__Descriptor, - new string[] { "Ctype", "Packed", "Jstype", "Lazy", "Deprecated", "Weak", "UninterpretedOption", }); - internal__static_google_protobuf_EnumOptions__Descriptor = Descriptor.MessageTypes[12]; - internal__static_google_protobuf_EnumOptions__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_google_protobuf_EnumOptions__Descriptor, - new string[] { "AllowAlias", "Deprecated", "UninterpretedOption", }); - internal__static_google_protobuf_EnumValueOptions__Descriptor = Descriptor.MessageTypes[13]; - internal__static_google_protobuf_EnumValueOptions__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_google_protobuf_EnumValueOptions__Descriptor, - new string[] { "Deprecated", "UninterpretedOption", }); - internal__static_google_protobuf_ServiceOptions__Descriptor = Descriptor.MessageTypes[14]; - internal__static_google_protobuf_ServiceOptions__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_google_protobuf_ServiceOptions__Descriptor, - new string[] { "Deprecated", "UninterpretedOption", }); - internal__static_google_protobuf_MethodOptions__Descriptor = Descriptor.MessageTypes[15]; - internal__static_google_protobuf_MethodOptions__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_google_protobuf_MethodOptions__Descriptor, - new string[] { "Deprecated", "UninterpretedOption", }); - internal__static_google_protobuf_UninterpretedOption__Descriptor = Descriptor.MessageTypes[16]; - internal__static_google_protobuf_UninterpretedOption__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_google_protobuf_UninterpretedOption__Descriptor, - new string[] { "Name", "IdentifierValue", "PositiveIntValue", "NegativeIntValue", "DoubleValue", "StringValue", "AggregateValue", }); - internal__static_google_protobuf_UninterpretedOption_NamePart__Descriptor = internal__static_google_protobuf_UninterpretedOption__Descriptor.NestedTypes[0]; - internal__static_google_protobuf_UninterpretedOption_NamePart__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_google_protobuf_UninterpretedOption_NamePart__Descriptor, - new string[] { "NamePart_", "IsExtension", }); - internal__static_google_protobuf_SourceCodeInfo__Descriptor = Descriptor.MessageTypes[17]; - internal__static_google_protobuf_SourceCodeInfo__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_google_protobuf_SourceCodeInfo__Descriptor, - new string[] { "Location", }); - internal__static_google_protobuf_SourceCodeInfo_Location__Descriptor = internal__static_google_protobuf_SourceCodeInfo__Descriptor.NestedTypes[0]; - internal__static_google_protobuf_SourceCodeInfo_Location__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_google_protobuf_SourceCodeInfo_Location__Descriptor, - new string[] { "Path", "Span", "LeadingComments", "TrailingComments", "LeadingDetachedComments", }); - }; - pbd::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, + descriptor = pbd::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, new pbd::FileDescriptor[] { - }, assigner); + }); + internal__static_google_protobuf_FileDescriptorSet__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.FileDescriptorSet), descriptor.MessageTypes[0], + new string[] { "File", }); + internal__static_google_protobuf_FileDescriptorProto__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.FileDescriptorProto), descriptor.MessageTypes[1], + new string[] { "Name", "Package", "Dependency", "PublicDependency", "WeakDependency", "MessageType", "EnumType", "Service", "Extension", "Options", "SourceCodeInfo", "Syntax", }); + internal__static_google_protobuf_DescriptorProto__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.DescriptorProto), descriptor.MessageTypes[2], + new string[] { "Name", "Field", "Extension", "NestedType", "EnumType", "ExtensionRange", "OneofDecl", "Options", "ReservedRange", "ReservedName", }); + internal__static_google_protobuf_DescriptorProto_ExtensionRange__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ExtensionRange), descriptor.MessageTypes[2].NestedTypes[0], + new string[] { "Start", "End", }); + internal__static_google_protobuf_DescriptorProto_ReservedRange__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ReservedRange), descriptor.MessageTypes[2].NestedTypes[1], + new string[] { "Start", "End", }); + internal__static_google_protobuf_FieldDescriptorProto__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto), descriptor.MessageTypes[3], + new string[] { "Name", "Number", "Label", "Type", "TypeName", "Extendee", "DefaultValue", "OneofIndex", "Options", }); + internal__static_google_protobuf_OneofDescriptorProto__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.OneofDescriptorProto), descriptor.MessageTypes[4], + new string[] { "Name", }); + internal__static_google_protobuf_EnumDescriptorProto__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto), descriptor.MessageTypes[5], + new string[] { "Name", "Value", "Options", }); + internal__static_google_protobuf_EnumValueDescriptorProto__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.EnumValueDescriptorProto), descriptor.MessageTypes[6], + new string[] { "Name", "Number", "Options", }); + internal__static_google_protobuf_ServiceDescriptorProto__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.ServiceDescriptorProto), descriptor.MessageTypes[7], + new string[] { "Name", "Method", "Options", }); + internal__static_google_protobuf_MethodDescriptorProto__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.MethodDescriptorProto), descriptor.MessageTypes[8], + new string[] { "Name", "InputType", "OutputType", "Options", "ClientStreaming", "ServerStreaming", }); + internal__static_google_protobuf_FileOptions__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.FileOptions), descriptor.MessageTypes[9], + new string[] { "JavaPackage", "JavaOuterClassname", "JavaMultipleFiles", "JavaGenerateEqualsAndHash", "JavaStringCheckUtf8", "OptimizeFor", "GoPackage", "CcGenericServices", "JavaGenericServices", "PyGenericServices", "Deprecated", "CcEnableArenas", "ObjcClassPrefix", "CsharpNamespace", "UninterpretedOption", }); + internal__static_google_protobuf_MessageOptions__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.MessageOptions), descriptor.MessageTypes[10], + new string[] { "MessageSetWireFormat", "NoStandardDescriptorAccessor", "Deprecated", "MapEntry", "UninterpretedOption", }); + internal__static_google_protobuf_FieldOptions__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.FieldOptions), descriptor.MessageTypes[11], + new string[] { "Ctype", "Packed", "Jstype", "Lazy", "Deprecated", "Weak", "UninterpretedOption", }); + internal__static_google_protobuf_EnumOptions__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.EnumOptions), descriptor.MessageTypes[12], + new string[] { "AllowAlias", "Deprecated", "UninterpretedOption", }); + internal__static_google_protobuf_EnumValueOptions__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.EnumValueOptions), descriptor.MessageTypes[13], + new string[] { "Deprecated", "UninterpretedOption", }); + internal__static_google_protobuf_ServiceOptions__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.ServiceOptions), descriptor.MessageTypes[14], + new string[] { "Deprecated", "UninterpretedOption", }); + internal__static_google_protobuf_MethodOptions__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.MethodOptions), descriptor.MessageTypes[15], + new string[] { "Deprecated", "UninterpretedOption", }); + internal__static_google_protobuf_UninterpretedOption__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.UninterpretedOption), descriptor.MessageTypes[16], + new string[] { "Name", "IdentifierValue", "PositiveIntValue", "NegativeIntValue", "DoubleValue", "StringValue", "AggregateValue", }); + internal__static_google_protobuf_UninterpretedOption_NamePart__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Types.NamePart), descriptor.MessageTypes[16].NestedTypes[0], + new string[] { "NamePart_", "IsExtension", }); + internal__static_google_protobuf_SourceCodeInfo__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.SourceCodeInfo), descriptor.MessageTypes[17], + new string[] { "Location", }); + internal__static_google_protobuf_SourceCodeInfo_Location__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.SourceCodeInfo.Types.Location), descriptor.MessageTypes[17].NestedTypes[0], + new string[] { "Path", "Span", "LeadingComments", "TrailingComments", "LeadingDetachedComments", }); } #endregion @@ -285,10 +238,10 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly string[] _fieldNames = new string[] { "file" }; private static readonly uint[] _fieldTags = new uint[] { 10 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FileDescriptorSet__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[0]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FileDescriptorSet__FieldAccessorTable; } } @@ -388,10 +341,10 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly string[] _fieldNames = new string[] { "dependency", "enum_type", "extension", "message_type", "name", "options", "package", "public_dependency", "service", "source_code_info", "syntax", "weak_dependency" }; private static readonly uint[] _fieldTags = new uint[] { 26, 42, 58, 34, 10, 66, 18, 80, 50, 74, 98, 88 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FileDescriptorProto__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[1]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FileDescriptorProto__FieldAccessorTable; } } @@ -756,10 +709,10 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly string[] _fieldNames = new string[] { "enum_type", "extension", "extension_range", "field", "name", "nested_type", "oneof_decl", "options", "reserved_name", "reserved_range" }; private static readonly uint[] _fieldTags = new uint[] { 34, 50, 42, 18, 10, 26, 66, 58, 82, 74 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_DescriptorProto__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[2]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_DescriptorProto__FieldAccessorTable; } } @@ -1054,10 +1007,10 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly string[] _fieldNames = new string[] { "end", "start" }; private static readonly uint[] _fieldTags = new uint[] { 16, 8 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_DescriptorProto_ExtensionRange__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProto.Descriptor.NestedTypes[0]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_DescriptorProto_ExtensionRange__FieldAccessorTable; } } @@ -1192,10 +1145,10 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly string[] _fieldNames = new string[] { "end", "start" }; private static readonly uint[] _fieldTags = new uint[] { 16, 8 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_DescriptorProto_ReservedRange__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProto.Descriptor.NestedTypes[1]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_DescriptorProto_ReservedRange__FieldAccessorTable; } } @@ -1335,10 +1288,10 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly string[] _fieldNames = new string[] { "default_value", "extendee", "label", "name", "number", "oneof_index", "options", "type", "type_name" }; private static readonly uint[] _fieldTags = new uint[] { 58, 18, 32, 10, 24, 72, 66, 40, 50 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FieldDescriptorProto__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[3]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FieldDescriptorProto__FieldAccessorTable; } } @@ -1702,10 +1655,10 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly string[] _fieldNames = new string[] { "name" }; private static readonly uint[] _fieldTags = new uint[] { 10 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_OneofDescriptorProto__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[4]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_OneofDescriptorProto__FieldAccessorTable; } } @@ -1813,10 +1766,10 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly string[] _fieldNames = new string[] { "name", "options", "value" }; private static readonly uint[] _fieldTags = new uint[] { 10, 26, 18 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_EnumDescriptorProto__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[5]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_EnumDescriptorProto__FieldAccessorTable; } } @@ -1977,10 +1930,10 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly string[] _fieldNames = new string[] { "name", "number", "options" }; private static readonly uint[] _fieldTags = new uint[] { 10, 16, 26 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_EnumValueDescriptorProto__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[6]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_EnumValueDescriptorProto__FieldAccessorTable; } } @@ -2149,10 +2102,10 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly string[] _fieldNames = new string[] { "method", "name", "options" }; private static readonly uint[] _fieldTags = new uint[] { 18, 10, 26 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_ServiceDescriptorProto__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[7]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_ServiceDescriptorProto__FieldAccessorTable; } } @@ -2313,10 +2266,10 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly string[] _fieldNames = new string[] { "client_streaming", "input_type", "name", "options", "output_type", "server_streaming" }; private static readonly uint[] _fieldTags = new uint[] { 40, 18, 10, 34, 26, 48 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_MethodDescriptorProto__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[8]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_MethodDescriptorProto__FieldAccessorTable; } } @@ -2566,10 +2519,10 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly string[] _fieldNames = new string[] { "cc_enable_arenas", "cc_generic_services", "csharp_namespace", "deprecated", "go_package", "java_generate_equals_and_hash", "java_generic_services", "java_multiple_files", "java_outer_classname", "java_package", "java_string_check_utf8", "objc_class_prefix", "optimize_for", "py_generic_services", "uninterpreted_option" }; private static readonly uint[] _fieldTags = new uint[] { 248, 128, 298, 184, 90, 160, 136, 80, 66, 10, 216, 290, 72, 144, 7994 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FileOptions__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[9]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FileOptions__FieldAccessorTable; } } @@ -3059,10 +3012,10 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly string[] _fieldNames = new string[] { "deprecated", "map_entry", "message_set_wire_format", "no_standard_descriptor_accessor", "uninterpreted_option" }; private static readonly uint[] _fieldTags = new uint[] { 24, 56, 8, 16, 7994 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_MessageOptions__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[10]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_MessageOptions__FieldAccessorTable; } } @@ -3270,10 +3223,10 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly string[] _fieldNames = new string[] { "ctype", "deprecated", "jstype", "lazy", "packed", "uninterpreted_option", "weak" }; private static readonly uint[] _fieldTags = new uint[] { 8, 24, 48, 40, 16, 7994, 80 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FieldOptions__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[11]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_FieldOptions__FieldAccessorTable; } } @@ -3553,10 +3506,10 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly string[] _fieldNames = new string[] { "allow_alias", "deprecated", "uninterpreted_option" }; private static readonly uint[] _fieldTags = new uint[] { 16, 24, 7994 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_EnumOptions__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[12]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_EnumOptions__FieldAccessorTable; } } @@ -3710,10 +3663,10 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly string[] _fieldNames = new string[] { "deprecated", "uninterpreted_option" }; private static readonly uint[] _fieldTags = new uint[] { 8, 7994 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_EnumValueOptions__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[13]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_EnumValueOptions__FieldAccessorTable; } } @@ -3840,10 +3793,10 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly string[] _fieldNames = new string[] { "deprecated", "uninterpreted_option" }; private static readonly uint[] _fieldTags = new uint[] { 264, 7994 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_ServiceOptions__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[14]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_ServiceOptions__FieldAccessorTable; } } @@ -3970,10 +3923,10 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly string[] _fieldNames = new string[] { "deprecated", "uninterpreted_option" }; private static readonly uint[] _fieldTags = new uint[] { 264, 7994 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_MethodOptions__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[15]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_MethodOptions__FieldAccessorTable; } } @@ -4100,10 +4053,10 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly string[] _fieldNames = new string[] { "aggregate_value", "double_value", "identifier_value", "name", "negative_int_value", "positive_int_value", "string_value" }; private static readonly uint[] _fieldTags = new uint[] { 66, 49, 26, 18, 40, 32, 58 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_UninterpretedOption__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[16]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_UninterpretedOption__FieldAccessorTable; } } @@ -4366,10 +4319,10 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly string[] _fieldNames = new string[] { "is_extension", "name_part" }; private static readonly uint[] _fieldTags = new uint[] { 16, 10 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_UninterpretedOption_NamePart__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Descriptor.NestedTypes[0]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_UninterpretedOption_NamePart__FieldAccessorTable; } } @@ -4509,10 +4462,10 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly string[] _fieldNames = new string[] { "location" }; private static readonly uint[] _fieldTags = new uint[] { 10 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_SourceCodeInfo__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.Descriptor.MessageTypes[17]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_SourceCodeInfo__FieldAccessorTable; } } @@ -4613,10 +4566,10 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly string[] _fieldNames = new string[] { "leading_comments", "leading_detached_comments", "path", "span", "trailing_comments" }; private static readonly uint[] _fieldTags = new uint[] { 26, 50, 10, 18, 34 }; public static pbd::MessageDescriptor Descriptor { - get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_SourceCodeInfo_Location__Descriptor; } + get { return global::Google.Protobuf.DescriptorProtos.SourceCodeInfo.Descriptor.NestedTypes[0]; } } - public pb::FieldAccess.FieldAccessorTable Fields { + public pb::FieldAccess.FieldAccessorTable Fields { get { return global::Google.Protobuf.DescriptorProtos.DescriptorProtoFile.internal__static_google_protobuf_SourceCodeInfo_Location__FieldAccessorTable; } } -- cgit v1.2.3 From 493e3db98532e99a53cec914d8f4827a556ee408 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Wed, 1 Jul 2015 17:11:17 +0100 Subject: Codegen changes to support descriptor runtime changes - Add a partial method called by all constructors - Generate internal classes for descriptor.proto (only) - Forbid proto2 descriptors except for descriptor.proto --- src/google/protobuf/compiler/csharp/csharp_field_base.cc | 1 + src/google/protobuf/compiler/csharp/csharp_generator.cc | 6 ++++++ src/google/protobuf/compiler/csharp/csharp_helpers.h | 9 +++++++++ src/google/protobuf/compiler/csharp/csharp_map_field.cc | 2 +- src/google/protobuf/compiler/csharp/csharp_message.cc | 9 ++++++--- src/google/protobuf/compiler/csharp/csharp_message_field.cc | 4 ++-- src/google/protobuf/compiler/csharp/csharp_primitive_field.cc | 4 ++-- .../protobuf/compiler/csharp/csharp_repeated_enum_field.cc | 2 +- .../protobuf/compiler/csharp/csharp_repeated_message_field.cc | 2 +- .../protobuf/compiler/csharp/csharp_repeated_primitive_field.cc | 2 +- .../protobuf/compiler/csharp/csharp_source_generator_base.cc | 2 +- 11 files changed, 31 insertions(+), 12 deletions(-) diff --git a/src/google/protobuf/compiler/csharp/csharp_field_base.cc b/src/google/protobuf/compiler/csharp/csharp_field_base.cc index bfb39a64..ae7336ca 100644 --- a/src/google/protobuf/compiler/csharp/csharp_field_base.cc +++ b/src/google/protobuf/compiler/csharp/csharp_field_base.cc @@ -65,6 +65,7 @@ void FieldGeneratorBase::SetCommonFieldVariables( tag_bytes += ", " + SimpleItoa(tag_array[i]); } + (*variables)["access_level"] = class_access_level(); (*variables)["tag"] = SimpleItoa(tag); (*variables)["tag_size"] = SimpleItoa(tag_size); (*variables)["tag_bytes"] = tag_bytes; diff --git a/src/google/protobuf/compiler/csharp/csharp_generator.cc b/src/google/protobuf/compiler/csharp/csharp_generator.cc index 2a416fac..f06d79d8 100644 --- a/src/google/protobuf/compiler/csharp/csharp_generator.cc +++ b/src/google/protobuf/compiler/csharp/csharp_generator.cc @@ -68,6 +68,12 @@ bool Generator::Generate( vector > options; ParseGeneratorParameter(parameter, &options); + // We only support proto3 - but we make an exception for descriptor.proto. + if (file->syntax() != FileDescriptor::SYNTAX_PROTO3 && !IsDescriptorProto(file)) { + *error = "C# code generation only supports proto3 syntax"; + return false; + } + std::string file_extension = ".cs"; for (int i = 0; i < options.size(); i++) { if (options[i].first == "file_extension") { diff --git a/src/google/protobuf/compiler/csharp/csharp_helpers.h b/src/google/protobuf/compiler/csharp/csharp_helpers.h index a8c1fa18..d9576fbd 100644 --- a/src/google/protobuf/compiler/csharp/csharp_helpers.h +++ b/src/google/protobuf/compiler/csharp/csharp_helpers.h @@ -101,6 +101,15 @@ uint FixedMakeTag(const FieldDescriptor* descriptor); FieldGeneratorBase* CreateFieldGenerator(const FieldDescriptor* descriptor, int fieldOrdinal); +// Determines whether we're generating code for the proto representation of descriptors etc, +// for use in the runtime. This is the only type which is allowed to use proto2 syntax, +// and it generates internal classes. +inline bool IsDescriptorProto(const FileDescriptor* descriptor) { + // TODO: Do this better! (Currently this depends on a hack in generate_protos.sh to rename + // the file...) + return descriptor->name() == "google/protobuf/descriptor_proto_file.proto"; +} + } // namespace csharp } // namespace compiler } // namespace protobuf diff --git a/src/google/protobuf/compiler/csharp/csharp_map_field.cc b/src/google/protobuf/compiler/csharp/csharp_map_field.cc index b8f1592c..cb7ce5f0 100644 --- a/src/google/protobuf/compiler/csharp/csharp_map_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_map_field.cc @@ -78,7 +78,7 @@ void MapFieldGenerator::GenerateMembers(io::Printer* printer) { AddDeprecatedFlag(printer); printer->Print( variables_, - "public pbc::MapField<$key_type_name$, $value_type_name$> $property_name$ {\n" + "$access_level$ pbc::MapField<$key_type_name$, $value_type_name$> $property_name$ {\n" " get { return $name$_; }\n" "}\n"); } diff --git a/src/google/protobuf/compiler/csharp/csharp_message.cc b/src/google/protobuf/compiler/csharp/csharp_message.cc index c7a1e290..13544b26 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message.cc @@ -221,10 +221,13 @@ void MessageGenerator::Generate(io::Printer* printer) { "private bool _frozen = false;\n" "public bool IsFrozen { get { return _frozen; } }\n\n"); - // Parameterless constructor + // Parameterless constructor and partial OnConstruction method. printer->Print( vars, - "public $class_name$() { }\n\n"); + "public $class_name$() {\n" + " OnConstruction();\n" + "}\n\n" + "partial void OnConstruction();\n\n"); GenerateCloningCode(printer); GenerateFreezingCode(printer); @@ -311,7 +314,7 @@ void MessageGenerator::GenerateCloningCode(io::Printer* printer) { vars["class_name"] = class_name(); printer->Print( vars, - "public $class_name$($class_name$ other) {\n"); + "public $class_name$($class_name$ other) : this() {\n"); printer->Indent(); // Clone non-oneof fields first for (int i = 0; i < descriptor_->field_count(); i++) { diff --git a/src/google/protobuf/compiler/csharp/csharp_message_field.cc b/src/google/protobuf/compiler/csharp/csharp_message_field.cc index d8c82271..d2c3a88b 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message_field.cc @@ -64,7 +64,7 @@ void MessageFieldGenerator::GenerateMembers(io::Printer* printer) { AddDeprecatedFlag(printer); printer->Print( variables_, - "public $type_name$ $property_name$ {\n" + "$access_level$ $type_name$ $property_name$ {\n" " get { return $name$_; }\n" " set {\n" " pb::Freezable.CheckMutable(this);\n" @@ -158,7 +158,7 @@ void MessageOneofFieldGenerator::GenerateMembers(io::Printer* printer) { AddDeprecatedFlag(printer); printer->Print( variables_, - "public $type_name$ $property_name$ {\n" + "$access_level$ $type_name$ $property_name$ {\n" " get { return $has_property_check$ ? ($type_name$) $oneof_name$_ : null; }\n" " set {\n" " pb::Freezable.CheckMutable(this);\n" diff --git a/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc b/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc index c40cba13..4454ef02 100644 --- a/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc @@ -71,7 +71,7 @@ void PrimitiveFieldGenerator::GenerateMembers(io::Printer* printer) { AddDeprecatedFlag(printer); printer->Print( variables_, - "public $type_name$ $property_name$ {\n" + "$access_level$ $type_name$ $property_name$ {\n" " get { return $name$_; }\n" " set {\n" " pb::Freezable.CheckMutable(this);\n"); @@ -174,7 +174,7 @@ void PrimitiveOneofFieldGenerator::GenerateMembers(io::Printer* printer) { AddDeprecatedFlag(printer); printer->Print( variables_, - "public $type_name$ $property_name$ {\n" + "$access_level$ $type_name$ $property_name$ {\n" " get { return $has_property_check$ ? ($type_name$) $oneof_name$_ : $default_value$; }\n" " set {\n" " pb::Freezable.CheckMutable(this);\n"); diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc b/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc index 4445c281..d5fc6d98 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc @@ -65,7 +65,7 @@ void RepeatedEnumFieldGenerator::GenerateMembers(io::Printer* printer) { AddDeprecatedFlag(printer); printer->Print( variables_, - "public pbc::RepeatedField<$type_name$> $property_name$ {\n" + "$access_level$ pbc::RepeatedField<$type_name$> $property_name$ {\n" " get { return $name$_; }\n" "}\n"); } diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc b/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc index c74e5d0d..6d4e6984 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc @@ -65,7 +65,7 @@ void RepeatedMessageFieldGenerator::GenerateMembers(io::Printer* printer) { AddDeprecatedFlag(printer); printer->Print( variables_, - "public pbc::RepeatedField<$type_name$> $property_name$ {\n" + "$access_level$ pbc::RepeatedField<$type_name$> $property_name$ {\n" " get { return $name$_; }\n" "}\n"); } diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc b/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc index a3014da8..5b5d9b3d 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc @@ -65,7 +65,7 @@ void RepeatedPrimitiveFieldGenerator::GenerateMembers(io::Printer* printer) { AddDeprecatedFlag(printer); printer->Print( variables_, - "public pbc::RepeatedField<$type_name$> $property_name$ {\n" + "$access_level$ pbc::RepeatedField<$type_name$> $property_name$ {\n" " get { return $name$_; }\n" "}\n"); } diff --git a/src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc b/src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc index c666c820..735d164a 100644 --- a/src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc +++ b/src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc @@ -57,7 +57,7 @@ void SourceGeneratorBase::WriteGeneratedCodeAttributes(io::Printer* printer) { } std::string SourceGeneratorBase::class_access_level() { - return "public"; // public_classes is always on. + return IsDescriptorProto(descriptor_) ? "internal" : "public"; // public_classes is always on. } } // namespace csharp -- cgit v1.2.3 From 5350822b0a923287bc23375a10c2f3cb07cff5fb Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Wed, 1 Jul 2015 17:16:55 +0100 Subject: Regenerated code due to previous commit. Note that now we need a proto3 version of addressbook.proto. This may affect other platforms, and could do with an overhaul to follow proto3 conventions anyway (e.g. repeated field names). Will need to think about that carefully before merging into master. Raised issue #565 for this. --- csharp/src/AddressBook/Addressbook.cs | 52 ++- .../TestProtos/MapUnittestProto3.cs | 352 ++++++++++++----- .../TestProtos/UnittestImportProto3.cs | 8 +- .../TestProtos/UnittestImportPublicProto3.cs | 8 +- .../TestProtos/UnittestIssues.cs | 56 ++- .../TestProtos/UnittestProto3.cs | 280 +++++++++---- .../DescriptorProtos/DescriptorProtoFile.cs | 438 +++++++++++++-------- examples/addressbook.proto | 12 +- 8 files changed, 829 insertions(+), 377 deletions(-) diff --git a/csharp/src/AddressBook/Addressbook.cs b/csharp/src/AddressBook/Addressbook.cs index 0b77ebf1..5f4a5139 100644 --- a/csharp/src/AddressBook/Addressbook.cs +++ b/csharp/src/AddressBook/Addressbook.cs @@ -26,15 +26,15 @@ namespace Google.Protobuf.Examples.AddressBook { static Addressbook() { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( - "ChFhZGRyZXNzYm9vay5wcm90bxIIdHV0b3JpYWwi2gEKBlBlcnNvbhIMCgRu", - "YW1lGAEgAigJEgoKAmlkGAIgAigFEg0KBWVtYWlsGAMgASgJEisKBXBob25l", - "GAQgAygLMhwudHV0b3JpYWwuUGVyc29uLlBob25lTnVtYmVyGk0KC1Bob25l", - "TnVtYmVyEg4KBm51bWJlchgBIAIoCRIuCgR0eXBlGAIgASgOMhoudHV0b3Jp", - "YWwuUGVyc29uLlBob25lVHlwZToESE9NRSIrCglQaG9uZVR5cGUSCgoGTU9C", - "SUxFEAASCAoESE9NRRABEggKBFdPUksQAiIvCgtBZGRyZXNzQm9vaxIgCgZw", - "ZXJzb24YASADKAsyEC50dXRvcmlhbC5QZXJzb25CUAoUY29tLmV4YW1wbGUu", - "dHV0b3JpYWxCEUFkZHJlc3NCb29rUHJvdG9zqgIkR29vZ2xlLlByb3RvYnVm", - "LkV4YW1wbGVzLkFkZHJlc3NCb29r")); + "ChFhZGRyZXNzYm9vay5wcm90bxIIdHV0b3JpYWwi1AEKBlBlcnNvbhIMCgRu", + "YW1lGAEgASgJEgoKAmlkGAIgASgFEg0KBWVtYWlsGAMgASgJEisKBXBob25l", + "GAQgAygLMhwudHV0b3JpYWwuUGVyc29uLlBob25lTnVtYmVyGkcKC1Bob25l", + "TnVtYmVyEg4KBm51bWJlchgBIAEoCRIoCgR0eXBlGAIgASgOMhoudHV0b3Jp", + "YWwuUGVyc29uLlBob25lVHlwZSIrCglQaG9uZVR5cGUSCgoGTU9CSUxFEAAS", + "CAoESE9NRRABEggKBFdPUksQAiIvCgtBZGRyZXNzQm9vaxIgCgZwZXJzb24Y", + "ASADKAsyEC50dXRvcmlhbC5QZXJzb25CUAoUY29tLmV4YW1wbGUudHV0b3Jp", + "YWxCEUFkZHJlc3NCb29rUHJvdG9zqgIkR29vZ2xlLlByb3RvYnVmLkV4YW1w", + "bGVzLkFkZHJlc3NCb29rYgZwcm90bzM=")); descriptor = pbd::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, new pbd::FileDescriptor[] { }); @@ -70,9 +70,13 @@ namespace Google.Protobuf.Examples.AddressBook { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public Person() { } + public Person() { + OnConstruction(); + } + + partial void OnConstruction(); - public Person(Person other) { + public Person(Person other) : this() { name_ = other.name_; id_ = other.id_; email_ = other.email_; @@ -261,9 +265,13 @@ namespace Google.Protobuf.Examples.AddressBook { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public PhoneNumber() { } + public PhoneNumber() { + OnConstruction(); + } + + partial void OnConstruction(); - public PhoneNumber(PhoneNumber other) { + public PhoneNumber(PhoneNumber other) : this() { number_ = other.number_; type_ = other.type_; } @@ -290,7 +298,7 @@ namespace Google.Protobuf.Examples.AddressBook { } public const int TypeFieldNumber = 2; - private global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType type_ = global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType.HOME; + private global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType type_ = global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType.MOBILE; public global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType Type { get { return type_; } set { @@ -318,7 +326,7 @@ namespace Google.Protobuf.Examples.AddressBook { public override int GetHashCode() { int hash = 1; if (Number.Length != 0) hash ^= Number.GetHashCode(); - if (Type != global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType.HOME) hash ^= Type.GetHashCode(); + if (Type != global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType.MOBILE) hash ^= Type.GetHashCode(); return hash; } @@ -327,7 +335,7 @@ namespace Google.Protobuf.Examples.AddressBook { output.WriteRawTag(10); output.WriteString(Number); } - if (Type != global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType.HOME) { + if (Type != global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType.MOBILE) { output.WriteRawTag(16); output.WriteEnum((int) Type); } @@ -338,7 +346,7 @@ namespace Google.Protobuf.Examples.AddressBook { if (Number.Length != 0) { size += 1 + pb::CodedOutputStream.ComputeStringSize(Number); } - if (Type != global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType.HOME) { + if (Type != global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType.MOBILE) { size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Type); } return size; @@ -351,7 +359,7 @@ namespace Google.Protobuf.Examples.AddressBook { if (other.Number.Length != 0) { Number = other.Number; } - if (other.Type != global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType.HOME) { + if (other.Type != global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType.MOBILE) { Type = other.Type; } } @@ -404,9 +412,13 @@ namespace Google.Protobuf.Examples.AddressBook { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public AddressBook() { } + public AddressBook() { + OnConstruction(); + } + + partial void OnConstruction(); - public AddressBook(AddressBook other) { + public AddressBook(AddressBook other) : this() { person_ = other.person_.Clone(); } diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/MapUnittestProto3.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/MapUnittestProto3.cs index 365c03a7..55434c53 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/MapUnittestProto3.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/MapUnittestProto3.cs @@ -359,9 +359,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public TestMap() { } + public TestMap() { + OnConstruction(); + } + + partial void OnConstruction(); - public TestMap(TestMap other) { + public TestMap(TestMap other) : this() { mapInt32Int32_ = other.mapInt32Int32_.Clone(); mapInt64Int64_ = other.mapInt64Int64_.Clone(); mapUint32Uint32_ = other.mapUint32Uint32_.Clone(); @@ -767,9 +771,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public MapInt32Int32Entry() { } + public MapInt32Int32Entry() { + OnConstruction(); + } + + partial void OnConstruction(); - public MapInt32Int32Entry(MapInt32Int32Entry other) { + public MapInt32Int32Entry(MapInt32Int32Entry other) : this() { key_ = other.key_; value_ = other.value_; } @@ -905,9 +913,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public MapInt64Int64Entry() { } + public MapInt64Int64Entry() { + OnConstruction(); + } + + partial void OnConstruction(); - public MapInt64Int64Entry(MapInt64Int64Entry other) { + public MapInt64Int64Entry(MapInt64Int64Entry other) : this() { key_ = other.key_; value_ = other.value_; } @@ -1043,9 +1055,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public MapUint32Uint32Entry() { } + public MapUint32Uint32Entry() { + OnConstruction(); + } + + partial void OnConstruction(); - public MapUint32Uint32Entry(MapUint32Uint32Entry other) { + public MapUint32Uint32Entry(MapUint32Uint32Entry other) : this() { key_ = other.key_; value_ = other.value_; } @@ -1181,9 +1197,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public MapUint64Uint64Entry() { } + public MapUint64Uint64Entry() { + OnConstruction(); + } - public MapUint64Uint64Entry(MapUint64Uint64Entry other) { + partial void OnConstruction(); + + public MapUint64Uint64Entry(MapUint64Uint64Entry other) : this() { key_ = other.key_; value_ = other.value_; } @@ -1319,9 +1339,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public MapSint32Sint32Entry() { } + public MapSint32Sint32Entry() { + OnConstruction(); + } + + partial void OnConstruction(); - public MapSint32Sint32Entry(MapSint32Sint32Entry other) { + public MapSint32Sint32Entry(MapSint32Sint32Entry other) : this() { key_ = other.key_; value_ = other.value_; } @@ -1457,9 +1481,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public MapSint64Sint64Entry() { } + public MapSint64Sint64Entry() { + OnConstruction(); + } + + partial void OnConstruction(); - public MapSint64Sint64Entry(MapSint64Sint64Entry other) { + public MapSint64Sint64Entry(MapSint64Sint64Entry other) : this() { key_ = other.key_; value_ = other.value_; } @@ -1595,9 +1623,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public MapFixed32Fixed32Entry() { } + public MapFixed32Fixed32Entry() { + OnConstruction(); + } + + partial void OnConstruction(); - public MapFixed32Fixed32Entry(MapFixed32Fixed32Entry other) { + public MapFixed32Fixed32Entry(MapFixed32Fixed32Entry other) : this() { key_ = other.key_; value_ = other.value_; } @@ -1733,9 +1765,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public MapFixed64Fixed64Entry() { } + public MapFixed64Fixed64Entry() { + OnConstruction(); + } - public MapFixed64Fixed64Entry(MapFixed64Fixed64Entry other) { + partial void OnConstruction(); + + public MapFixed64Fixed64Entry(MapFixed64Fixed64Entry other) : this() { key_ = other.key_; value_ = other.value_; } @@ -1871,9 +1907,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public MapSfixed32Sfixed32Entry() { } + public MapSfixed32Sfixed32Entry() { + OnConstruction(); + } + + partial void OnConstruction(); - public MapSfixed32Sfixed32Entry(MapSfixed32Sfixed32Entry other) { + public MapSfixed32Sfixed32Entry(MapSfixed32Sfixed32Entry other) : this() { key_ = other.key_; value_ = other.value_; } @@ -2009,9 +2049,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public MapSfixed64Sfixed64Entry() { } + public MapSfixed64Sfixed64Entry() { + OnConstruction(); + } + + partial void OnConstruction(); - public MapSfixed64Sfixed64Entry(MapSfixed64Sfixed64Entry other) { + public MapSfixed64Sfixed64Entry(MapSfixed64Sfixed64Entry other) : this() { key_ = other.key_; value_ = other.value_; } @@ -2147,9 +2191,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public MapInt32FloatEntry() { } + public MapInt32FloatEntry() { + OnConstruction(); + } + + partial void OnConstruction(); - public MapInt32FloatEntry(MapInt32FloatEntry other) { + public MapInt32FloatEntry(MapInt32FloatEntry other) : this() { key_ = other.key_; value_ = other.value_; } @@ -2285,9 +2333,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public MapInt32DoubleEntry() { } + public MapInt32DoubleEntry() { + OnConstruction(); + } + + partial void OnConstruction(); - public MapInt32DoubleEntry(MapInt32DoubleEntry other) { + public MapInt32DoubleEntry(MapInt32DoubleEntry other) : this() { key_ = other.key_; value_ = other.value_; } @@ -2423,9 +2475,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public MapBoolBoolEntry() { } + public MapBoolBoolEntry() { + OnConstruction(); + } + + partial void OnConstruction(); - public MapBoolBoolEntry(MapBoolBoolEntry other) { + public MapBoolBoolEntry(MapBoolBoolEntry other) : this() { key_ = other.key_; value_ = other.value_; } @@ -2561,9 +2617,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public MapStringStringEntry() { } + public MapStringStringEntry() { + OnConstruction(); + } + + partial void OnConstruction(); - public MapStringStringEntry(MapStringStringEntry other) { + public MapStringStringEntry(MapStringStringEntry other) : this() { key_ = other.key_; value_ = other.value_; } @@ -2699,9 +2759,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public MapInt32BytesEntry() { } + public MapInt32BytesEntry() { + OnConstruction(); + } - public MapInt32BytesEntry(MapInt32BytesEntry other) { + partial void OnConstruction(); + + public MapInt32BytesEntry(MapInt32BytesEntry other) : this() { key_ = other.key_; value_ = other.value_; } @@ -2837,9 +2901,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public MapInt32EnumEntry() { } + public MapInt32EnumEntry() { + OnConstruction(); + } + + partial void OnConstruction(); - public MapInt32EnumEntry(MapInt32EnumEntry other) { + public MapInt32EnumEntry(MapInt32EnumEntry other) : this() { key_ = other.key_; value_ = other.value_; } @@ -2975,9 +3043,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public MapInt32ForeignMessageEntry() { } + public MapInt32ForeignMessageEntry() { + OnConstruction(); + } + + partial void OnConstruction(); - public MapInt32ForeignMessageEntry(MapInt32ForeignMessageEntry other) { + public MapInt32ForeignMessageEntry(MapInt32ForeignMessageEntry other) : this() { key_ = other.key_; Value = other.value_ != null ? other.Value.Clone() : null; } @@ -3125,9 +3197,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public TestMapSubmessage() { } + public TestMapSubmessage() { + OnConstruction(); + } + + partial void OnConstruction(); - public TestMapSubmessage(TestMapSubmessage other) { + public TestMapSubmessage(TestMapSubmessage other) : this() { TestMap = other.testMap_ != null ? other.TestMap.Clone() : null; } @@ -3243,9 +3319,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public TestMessageMap() { } + public TestMessageMap() { + OnConstruction(); + } - public TestMessageMap(TestMessageMap other) { + partial void OnConstruction(); + + public TestMessageMap(TestMessageMap other) : this() { mapInt32Message_ = other.mapInt32Message_.Clone(); } @@ -3347,9 +3427,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public MapInt32MessageEntry() { } + public MapInt32MessageEntry() { + OnConstruction(); + } + + partial void OnConstruction(); - public MapInt32MessageEntry(MapInt32MessageEntry other) { + public MapInt32MessageEntry(MapInt32MessageEntry other) : this() { key_ = other.key_; Value = other.value_ != null ? other.Value.Clone() : null; } @@ -3497,9 +3581,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public TestSameTypeMap() { } + public TestSameTypeMap() { + OnConstruction(); + } + + partial void OnConstruction(); - public TestSameTypeMap(TestSameTypeMap other) { + public TestSameTypeMap(TestSameTypeMap other) : this() { map1_ = other.map1_.Clone(); map2_ = other.map2_.Clone(); } @@ -3620,9 +3708,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public Map1Entry() { } + public Map1Entry() { + OnConstruction(); + } + + partial void OnConstruction(); - public Map1Entry(Map1Entry other) { + public Map1Entry(Map1Entry other) : this() { key_ = other.key_; value_ = other.value_; } @@ -3758,9 +3850,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public Map2Entry() { } + public Map2Entry() { + OnConstruction(); + } + + partial void OnConstruction(); - public Map2Entry(Map2Entry other) { + public Map2Entry(Map2Entry other) : this() { key_ = other.key_; value_ = other.value_; } @@ -3901,9 +3997,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public TestArenaMap() { } + public TestArenaMap() { + OnConstruction(); + } + + partial void OnConstruction(); - public TestArenaMap(TestArenaMap other) { + public TestArenaMap(TestArenaMap other) : this() { mapInt32Int32_ = other.mapInt32Int32_.Clone(); mapInt64Int64_ = other.mapInt64Int64_.Clone(); mapUint32Uint32_ = other.mapUint32Uint32_.Clone(); @@ -4271,9 +4371,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public MapInt32Int32Entry() { } + public MapInt32Int32Entry() { + OnConstruction(); + } + + partial void OnConstruction(); - public MapInt32Int32Entry(MapInt32Int32Entry other) { + public MapInt32Int32Entry(MapInt32Int32Entry other) : this() { key_ = other.key_; value_ = other.value_; } @@ -4409,9 +4513,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public MapInt64Int64Entry() { } + public MapInt64Int64Entry() { + OnConstruction(); + } - public MapInt64Int64Entry(MapInt64Int64Entry other) { + partial void OnConstruction(); + + public MapInt64Int64Entry(MapInt64Int64Entry other) : this() { key_ = other.key_; value_ = other.value_; } @@ -4547,9 +4655,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public MapUint32Uint32Entry() { } + public MapUint32Uint32Entry() { + OnConstruction(); + } + + partial void OnConstruction(); - public MapUint32Uint32Entry(MapUint32Uint32Entry other) { + public MapUint32Uint32Entry(MapUint32Uint32Entry other) : this() { key_ = other.key_; value_ = other.value_; } @@ -4685,9 +4797,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public MapUint64Uint64Entry() { } + public MapUint64Uint64Entry() { + OnConstruction(); + } + + partial void OnConstruction(); - public MapUint64Uint64Entry(MapUint64Uint64Entry other) { + public MapUint64Uint64Entry(MapUint64Uint64Entry other) : this() { key_ = other.key_; value_ = other.value_; } @@ -4823,9 +4939,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public MapSint32Sint32Entry() { } + public MapSint32Sint32Entry() { + OnConstruction(); + } + + partial void OnConstruction(); - public MapSint32Sint32Entry(MapSint32Sint32Entry other) { + public MapSint32Sint32Entry(MapSint32Sint32Entry other) : this() { key_ = other.key_; value_ = other.value_; } @@ -4961,9 +5081,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public MapSint64Sint64Entry() { } + public MapSint64Sint64Entry() { + OnConstruction(); + } - public MapSint64Sint64Entry(MapSint64Sint64Entry other) { + partial void OnConstruction(); + + public MapSint64Sint64Entry(MapSint64Sint64Entry other) : this() { key_ = other.key_; value_ = other.value_; } @@ -5099,9 +5223,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public MapFixed32Fixed32Entry() { } + public MapFixed32Fixed32Entry() { + OnConstruction(); + } + + partial void OnConstruction(); - public MapFixed32Fixed32Entry(MapFixed32Fixed32Entry other) { + public MapFixed32Fixed32Entry(MapFixed32Fixed32Entry other) : this() { key_ = other.key_; value_ = other.value_; } @@ -5237,9 +5365,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public MapFixed64Fixed64Entry() { } + public MapFixed64Fixed64Entry() { + OnConstruction(); + } + + partial void OnConstruction(); - public MapFixed64Fixed64Entry(MapFixed64Fixed64Entry other) { + public MapFixed64Fixed64Entry(MapFixed64Fixed64Entry other) : this() { key_ = other.key_; value_ = other.value_; } @@ -5375,9 +5507,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public MapSfixed32Sfixed32Entry() { } + public MapSfixed32Sfixed32Entry() { + OnConstruction(); + } + + partial void OnConstruction(); - public MapSfixed32Sfixed32Entry(MapSfixed32Sfixed32Entry other) { + public MapSfixed32Sfixed32Entry(MapSfixed32Sfixed32Entry other) : this() { key_ = other.key_; value_ = other.value_; } @@ -5513,9 +5649,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public MapSfixed64Sfixed64Entry() { } + public MapSfixed64Sfixed64Entry() { + OnConstruction(); + } + + partial void OnConstruction(); - public MapSfixed64Sfixed64Entry(MapSfixed64Sfixed64Entry other) { + public MapSfixed64Sfixed64Entry(MapSfixed64Sfixed64Entry other) : this() { key_ = other.key_; value_ = other.value_; } @@ -5651,9 +5791,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public MapInt32FloatEntry() { } + public MapInt32FloatEntry() { + OnConstruction(); + } + + partial void OnConstruction(); - public MapInt32FloatEntry(MapInt32FloatEntry other) { + public MapInt32FloatEntry(MapInt32FloatEntry other) : this() { key_ = other.key_; value_ = other.value_; } @@ -5789,9 +5933,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public MapInt32DoubleEntry() { } + public MapInt32DoubleEntry() { + OnConstruction(); + } + + partial void OnConstruction(); - public MapInt32DoubleEntry(MapInt32DoubleEntry other) { + public MapInt32DoubleEntry(MapInt32DoubleEntry other) : this() { key_ = other.key_; value_ = other.value_; } @@ -5927,9 +6075,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public MapBoolBoolEntry() { } + public MapBoolBoolEntry() { + OnConstruction(); + } - public MapBoolBoolEntry(MapBoolBoolEntry other) { + partial void OnConstruction(); + + public MapBoolBoolEntry(MapBoolBoolEntry other) : this() { key_ = other.key_; value_ = other.value_; } @@ -6065,9 +6217,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public MapInt32EnumEntry() { } + public MapInt32EnumEntry() { + OnConstruction(); + } + + partial void OnConstruction(); - public MapInt32EnumEntry(MapInt32EnumEntry other) { + public MapInt32EnumEntry(MapInt32EnumEntry other) : this() { key_ = other.key_; value_ = other.value_; } @@ -6203,9 +6359,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public MapInt32ForeignMessageEntry() { } + public MapInt32ForeignMessageEntry() { + OnConstruction(); + } + + partial void OnConstruction(); - public MapInt32ForeignMessageEntry(MapInt32ForeignMessageEntry other) { + public MapInt32ForeignMessageEntry(MapInt32ForeignMessageEntry other) : this() { key_ = other.key_; Value = other.value_ != null ? other.Value.Clone() : null; } @@ -6353,9 +6513,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public MessageContainingEnumCalledType() { } + public MessageContainingEnumCalledType() { + OnConstruction(); + } + + partial void OnConstruction(); - public MessageContainingEnumCalledType(MessageContainingEnumCalledType other) { + public MessageContainingEnumCalledType(MessageContainingEnumCalledType other) : this() { type_ = other.type_.Clone(); } @@ -6461,9 +6625,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public TypeEntry() { } + public TypeEntry() { + OnConstruction(); + } - public TypeEntry(TypeEntry other) { + partial void OnConstruction(); + + public TypeEntry(TypeEntry other) : this() { key_ = other.key_; Value = other.value_ != null ? other.Value.Clone() : null; } @@ -6611,9 +6779,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public MessageContainingMapCalledEntry() { } + public MessageContainingMapCalledEntry() { + OnConstruction(); + } + + partial void OnConstruction(); - public MessageContainingMapCalledEntry(MessageContainingMapCalledEntry other) { + public MessageContainingMapCalledEntry(MessageContainingMapCalledEntry other) : this() { entry_ = other.entry_.Clone(); } @@ -6715,9 +6887,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public EntryEntry() { } + public EntryEntry() { + OnConstruction(); + } + + partial void OnConstruction(); - public EntryEntry(EntryEntry other) { + public EntryEntry(EntryEntry other) : this() { key_ = other.key_; value_ = other.value_; } diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportProto3.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportProto3.cs index 5afcb4e0..d30f22db 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportProto3.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportProto3.cs @@ -72,9 +72,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public ImportMessage() { } + public ImportMessage() { + OnConstruction(); + } + + partial void OnConstruction(); - public ImportMessage(ImportMessage other) { + public ImportMessage(ImportMessage other) : this() { d_ = other.d_; } diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportPublicProto3.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportPublicProto3.cs index 79c0876e..5aa03a64 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportPublicProto3.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportPublicProto3.cs @@ -57,9 +57,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public PublicImportMessage() { } + public PublicImportMessage() { + OnConstruction(); + } + + partial void OnConstruction(); - public PublicImportMessage(PublicImportMessage other) { + public PublicImportMessage(PublicImportMessage other) : this() { e_ = other.e_; } diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs index 124f2de7..0e409c8b 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs @@ -109,9 +109,13 @@ namespace UnitTest.Issues.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public Issue307() { } + public Issue307() { + OnConstruction(); + } + + partial void OnConstruction(); - public Issue307(Issue307 other) { + public Issue307(Issue307 other) : this() { } public Issue307 Clone() { @@ -194,9 +198,13 @@ namespace UnitTest.Issues.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public NestedOnce() { } + public NestedOnce() { + OnConstruction(); + } + + partial void OnConstruction(); - public NestedOnce(NestedOnce other) { + public NestedOnce(NestedOnce other) : this() { } public NestedOnce Clone() { @@ -279,9 +287,13 @@ namespace UnitTest.Issues.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public NestedTwice() { } + public NestedTwice() { + OnConstruction(); + } + + partial void OnConstruction(); - public NestedTwice(NestedTwice other) { + public NestedTwice(NestedTwice other) : this() { } public NestedTwice Clone() { @@ -373,9 +385,13 @@ namespace UnitTest.Issues.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public NegativeEnumMessage() { } + public NegativeEnumMessage() { + OnConstruction(); + } + + partial void OnConstruction(); - public NegativeEnumMessage(NegativeEnumMessage other) { + public NegativeEnumMessage(NegativeEnumMessage other) : this() { value_ = other.value_; values_ = other.values_.Clone(); packedValues_ = other.packedValues_.Clone(); @@ -522,9 +538,13 @@ namespace UnitTest.Issues.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public DeprecatedChild() { } + public DeprecatedChild() { + OnConstruction(); + } + + partial void OnConstruction(); - public DeprecatedChild(DeprecatedChild other) { + public DeprecatedChild(DeprecatedChild other) : this() { } public DeprecatedChild Clone() { @@ -606,9 +626,13 @@ namespace UnitTest.Issues.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public DeprecatedFieldsMessage() { } + public DeprecatedFieldsMessage() { + OnConstruction(); + } - public DeprecatedFieldsMessage(DeprecatedFieldsMessage other) { + partial void OnConstruction(); + + public DeprecatedFieldsMessage(DeprecatedFieldsMessage other) : this() { primitiveValue_ = other.primitiveValue_; primitiveArray_ = other.primitiveArray_.Clone(); MessageValue = other.messageValue_ != null ? other.MessageValue.Clone() : null; @@ -842,9 +866,13 @@ namespace UnitTest.Issues.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public ItemField() { } + public ItemField() { + OnConstruction(); + } + + partial void OnConstruction(); - public ItemField(ItemField other) { + public ItemField(ItemField other) : this() { item_ = other.item_; } diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs index c9aed740..d2437bf4 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs @@ -346,9 +346,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public TestAllTypes() { } + public TestAllTypes() { + OnConstruction(); + } + + partial void OnConstruction(); - public TestAllTypes(TestAllTypes other) { + public TestAllTypes(TestAllTypes other) : this() { singleInt32_ = other.singleInt32_; singleInt64_ = other.singleInt64_; singleUint32_ = other.singleUint32_; @@ -1639,9 +1643,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public NestedMessage() { } + public NestedMessage() { + OnConstruction(); + } - public NestedMessage(NestedMessage other) { + partial void OnConstruction(); + + public NestedMessage(NestedMessage other) : this() { bb_ = other.bb_; } @@ -1755,9 +1763,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public NestedTestAllTypes() { } + public NestedTestAllTypes() { + OnConstruction(); + } - public NestedTestAllTypes(NestedTestAllTypes other) { + partial void OnConstruction(); + + public NestedTestAllTypes(NestedTestAllTypes other) : this() { Child = other.child_ != null ? other.Child.Clone() : null; Payload = other.payload_ != null ? other.Payload.Clone() : null; repeatedChild_ = other.repeatedChild_.Clone(); @@ -1926,9 +1938,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public TestDeprecatedFields() { } + public TestDeprecatedFields() { + OnConstruction(); + } + + partial void OnConstruction(); - public TestDeprecatedFields(TestDeprecatedFields other) { + public TestDeprecatedFields(TestDeprecatedFields other) : this() { deprecatedInt32_ = other.deprecatedInt32_; } @@ -2038,9 +2054,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public ForeignMessage() { } + public ForeignMessage() { + OnConstruction(); + } + + partial void OnConstruction(); - public ForeignMessage(ForeignMessage other) { + public ForeignMessage(ForeignMessage other) : this() { c_ = other.c_; } @@ -2149,9 +2169,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public TestReservedFields() { } + public TestReservedFields() { + OnConstruction(); + } + + partial void OnConstruction(); - public TestReservedFields(TestReservedFields other) { + public TestReservedFields(TestReservedFields other) : this() { } public TestReservedFields Clone() { @@ -2233,9 +2257,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public TestForeignNested() { } + public TestForeignNested() { + OnConstruction(); + } + + partial void OnConstruction(); - public TestForeignNested(TestForeignNested other) { + public TestForeignNested(TestForeignNested other) : this() { ForeignNested = other.foreignNested_ != null ? other.ForeignNested.Clone() : null; } @@ -2351,9 +2379,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public TestReallyLargeTagNumber() { } + public TestReallyLargeTagNumber() { + OnConstruction(); + } + + partial void OnConstruction(); - public TestReallyLargeTagNumber(TestReallyLargeTagNumber other) { + public TestReallyLargeTagNumber(TestReallyLargeTagNumber other) : this() { a_ = other.a_; bb_ = other.bb_; } @@ -2489,9 +2521,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public TestRecursiveMessage() { } + public TestRecursiveMessage() { + OnConstruction(); + } + + partial void OnConstruction(); - public TestRecursiveMessage(TestRecursiveMessage other) { + public TestRecursiveMessage(TestRecursiveMessage other) : this() { A = other.a_ != null ? other.A.Clone() : null; i_ = other.i_; } @@ -2634,9 +2670,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public TestMutualRecursionA() { } + public TestMutualRecursionA() { + OnConstruction(); + } + + partial void OnConstruction(); - public TestMutualRecursionA(TestMutualRecursionA other) { + public TestMutualRecursionA(TestMutualRecursionA other) : this() { Bb = other.bb_ != null ? other.Bb.Clone() : null; } @@ -2752,9 +2792,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public TestMutualRecursionB() { } + public TestMutualRecursionB() { + OnConstruction(); + } - public TestMutualRecursionB(TestMutualRecursionB other) { + partial void OnConstruction(); + + public TestMutualRecursionB(TestMutualRecursionB other) : this() { A = other.a_ != null ? other.A.Clone() : null; optionalInt32_ = other.optionalInt32_; } @@ -2897,9 +2941,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public TestCamelCaseFieldNames() { } + public TestCamelCaseFieldNames() { + OnConstruction(); + } - public TestCamelCaseFieldNames(TestCamelCaseFieldNames other) { + partial void OnConstruction(); + + public TestCamelCaseFieldNames(TestCamelCaseFieldNames other) : this() { primitiveField_ = other.primitiveField_; stringField_ = other.stringField_; enumField_ = other.enumField_; @@ -3173,9 +3221,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public TestFieldOrderings() { } + public TestFieldOrderings() { + OnConstruction(); + } + + partial void OnConstruction(); - public TestFieldOrderings(TestFieldOrderings other) { + public TestFieldOrderings(TestFieldOrderings other) : this() { myString_ = other.myString_; myInt_ = other.myInt_; myFloat_ = other.myFloat_; @@ -3373,9 +3425,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public NestedMessage() { } + public NestedMessage() { + OnConstruction(); + } - public NestedMessage(NestedMessage other) { + partial void OnConstruction(); + + public NestedMessage(NestedMessage other) : this() { oo_ = other.oo_; bb_ = other.bb_; } @@ -3516,9 +3572,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public SparseEnumMessage() { } + public SparseEnumMessage() { + OnConstruction(); + } + + partial void OnConstruction(); - public SparseEnumMessage(SparseEnumMessage other) { + public SparseEnumMessage(SparseEnumMessage other) : this() { sparseEnum_ = other.sparseEnum_; } @@ -3627,9 +3687,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public OneString() { } + public OneString() { + OnConstruction(); + } + + partial void OnConstruction(); - public OneString(OneString other) { + public OneString(OneString other) : this() { data_ = other.data_; } @@ -3738,9 +3802,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public MoreString() { } + public MoreString() { + OnConstruction(); + } + + partial void OnConstruction(); - public MoreString(MoreString other) { + public MoreString(MoreString other) : this() { data_ = other.data_.Clone(); } @@ -3841,9 +3909,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public OneBytes() { } + public OneBytes() { + OnConstruction(); + } + + partial void OnConstruction(); - public OneBytes(OneBytes other) { + public OneBytes(OneBytes other) : this() { data_ = other.data_; } @@ -3952,9 +4024,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public MoreBytes() { } + public MoreBytes() { + OnConstruction(); + } + + partial void OnConstruction(); - public MoreBytes(MoreBytes other) { + public MoreBytes(MoreBytes other) : this() { data_ = other.data_; } @@ -4063,9 +4139,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public Int32Message() { } + public Int32Message() { + OnConstruction(); + } + + partial void OnConstruction(); - public Int32Message(Int32Message other) { + public Int32Message(Int32Message other) : this() { data_ = other.data_; } @@ -4174,9 +4254,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public Uint32Message() { } + public Uint32Message() { + OnConstruction(); + } + + partial void OnConstruction(); - public Uint32Message(Uint32Message other) { + public Uint32Message(Uint32Message other) : this() { data_ = other.data_; } @@ -4285,9 +4369,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public Int64Message() { } + public Int64Message() { + OnConstruction(); + } + + partial void OnConstruction(); - public Int64Message(Int64Message other) { + public Int64Message(Int64Message other) : this() { data_ = other.data_; } @@ -4396,9 +4484,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public Uint64Message() { } + public Uint64Message() { + OnConstruction(); + } + + partial void OnConstruction(); - public Uint64Message(Uint64Message other) { + public Uint64Message(Uint64Message other) : this() { data_ = other.data_; } @@ -4507,9 +4599,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public BoolMessage() { } + public BoolMessage() { + OnConstruction(); + } - public BoolMessage(BoolMessage other) { + partial void OnConstruction(); + + public BoolMessage(BoolMessage other) : this() { data_ = other.data_; } @@ -4618,9 +4714,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public TestOneof() { } + public TestOneof() { + OnConstruction(); + } - public TestOneof(TestOneof other) { + partial void OnConstruction(); + + public TestOneof(TestOneof other) : this() { switch (other.FooCase) { case FooOneofCase.FooInt: FooInt = other.FooInt; @@ -4819,9 +4919,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public TestPackedTypes() { } + public TestPackedTypes() { + OnConstruction(); + } + + partial void OnConstruction(); - public TestPackedTypes(TestPackedTypes other) { + public TestPackedTypes(TestPackedTypes other) : this() { packedInt32_ = other.packedInt32_.Clone(); packedInt64_ = other.packedInt64_.Clone(); packedUint32_ = other.packedUint32_.Clone(); @@ -5182,9 +5286,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public TestUnpackedTypes() { } + public TestUnpackedTypes() { + OnConstruction(); + } - public TestUnpackedTypes(TestUnpackedTypes other) { + partial void OnConstruction(); + + public TestUnpackedTypes(TestUnpackedTypes other) : this() { unpackedInt32_ = other.unpackedInt32_.Clone(); unpackedInt64_ = other.unpackedInt64_.Clone(); unpackedUint32_ = other.unpackedUint32_.Clone(); @@ -5545,9 +5653,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public TestRepeatedScalarDifferentTagSizes() { } + public TestRepeatedScalarDifferentTagSizes() { + OnConstruction(); + } + + partial void OnConstruction(); - public TestRepeatedScalarDifferentTagSizes(TestRepeatedScalarDifferentTagSizes other) { + public TestRepeatedScalarDifferentTagSizes(TestRepeatedScalarDifferentTagSizes other) : this() { repeatedFixed32_ = other.repeatedFixed32_.Clone(); repeatedInt32_ = other.repeatedInt32_.Clone(); repeatedFixed64_ = other.repeatedFixed64_.Clone(); @@ -5749,9 +5861,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public TestCommentInjectionMessage() { } + public TestCommentInjectionMessage() { + OnConstruction(); + } + + partial void OnConstruction(); - public TestCommentInjectionMessage(TestCommentInjectionMessage other) { + public TestCommentInjectionMessage(TestCommentInjectionMessage other) : this() { a_ = other.a_; } @@ -5860,9 +5976,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public FooRequest() { } + public FooRequest() { + OnConstruction(); + } + + partial void OnConstruction(); - public FooRequest(FooRequest other) { + public FooRequest(FooRequest other) : this() { } public FooRequest Clone() { @@ -5944,9 +6064,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public FooResponse() { } + public FooResponse() { + OnConstruction(); + } + + partial void OnConstruction(); - public FooResponse(FooResponse other) { + public FooResponse(FooResponse other) : this() { } public FooResponse Clone() { @@ -6028,9 +6152,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public FooClientMessage() { } + public FooClientMessage() { + OnConstruction(); + } + + partial void OnConstruction(); - public FooClientMessage(FooClientMessage other) { + public FooClientMessage(FooClientMessage other) : this() { } public FooClientMessage Clone() { @@ -6112,9 +6240,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public FooServerMessage() { } + public FooServerMessage() { + OnConstruction(); + } + + partial void OnConstruction(); - public FooServerMessage(FooServerMessage other) { + public FooServerMessage(FooServerMessage other) : this() { } public FooServerMessage Clone() { @@ -6196,9 +6328,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public BarRequest() { } + public BarRequest() { + OnConstruction(); + } + + partial void OnConstruction(); - public BarRequest(BarRequest other) { + public BarRequest(BarRequest other) : this() { } public BarRequest Clone() { @@ -6280,9 +6416,13 @@ namespace Google.Protobuf.TestProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public BarResponse() { } + public BarResponse() { + OnConstruction(); + } + + partial void OnConstruction(); - public BarResponse(BarResponse other) { + public BarResponse(BarResponse other) : this() { } public BarResponse Clone() { diff --git a/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs b/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs index 3be7c4a9..c87b367a 100644 --- a/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs +++ b/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs @@ -10,7 +10,7 @@ using scg = global::System.Collections.Generic; namespace Google.Protobuf.DescriptorProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class DescriptorProtoFile { + internal static partial class DescriptorProtoFile { #region Static variables internal static pb::FieldAccess.FieldAccessorTable internal__static_google_protobuf_FileDescriptorSet__FieldAccessorTable; @@ -231,7 +231,7 @@ namespace Google.Protobuf.DescriptorProtos { } #region Messages [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class FileDescriptorSet : pb::IMessage { + internal sealed partial class FileDescriptorSet : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FileDescriptorSet()); public static pb::MessageParser Parser { get { return _parser; } } @@ -248,9 +248,13 @@ namespace Google.Protobuf.DescriptorProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public FileDescriptorSet() { } + public FileDescriptorSet() { + OnConstruction(); + } + + partial void OnConstruction(); - public FileDescriptorSet(FileDescriptorSet other) { + public FileDescriptorSet(FileDescriptorSet other) : this() { file_ = other.file_.Clone(); } @@ -270,7 +274,7 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec _repeated_file_codec = pb::FieldCodec.ForMessage(10, global::Google.Protobuf.DescriptorProtos.FileDescriptorProto.Parser); private readonly pbc::RepeatedField file_ = new pbc::RepeatedField(); - public pbc::RepeatedField File { + internal pbc::RepeatedField File { get { return file_; } } @@ -334,7 +338,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class FileDescriptorProto : pb::IMessage { + internal sealed partial class FileDescriptorProto : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FileDescriptorProto()); public static pb::MessageParser Parser { get { return _parser; } } @@ -351,9 +355,13 @@ namespace Google.Protobuf.DescriptorProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public FileDescriptorProto() { } + public FileDescriptorProto() { + OnConstruction(); + } + + partial void OnConstruction(); - public FileDescriptorProto(FileDescriptorProto other) { + public FileDescriptorProto(FileDescriptorProto other) : this() { name_ = other.name_; package_ = other.package_; dependency_ = other.dependency_.Clone(); @@ -390,7 +398,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int NameFieldNumber = 1; private string name_ = ""; - public string Name { + internal string Name { get { return name_; } set { pb::Freezable.CheckMutable(this); @@ -400,7 +408,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int PackageFieldNumber = 2; private string package_ = ""; - public string Package { + internal string Package { get { return package_; } set { pb::Freezable.CheckMutable(this); @@ -412,7 +420,7 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec _repeated_dependency_codec = pb::FieldCodec.ForString(26); private readonly pbc::RepeatedField dependency_ = new pbc::RepeatedField(); - public pbc::RepeatedField Dependency { + internal pbc::RepeatedField Dependency { get { return dependency_; } } @@ -420,7 +428,7 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec _repeated_publicDependency_codec = pb::FieldCodec.ForInt32(80); private readonly pbc::RepeatedField publicDependency_ = new pbc::RepeatedField(); - public pbc::RepeatedField PublicDependency { + internal pbc::RepeatedField PublicDependency { get { return publicDependency_; } } @@ -428,7 +436,7 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec _repeated_weakDependency_codec = pb::FieldCodec.ForInt32(88); private readonly pbc::RepeatedField weakDependency_ = new pbc::RepeatedField(); - public pbc::RepeatedField WeakDependency { + internal pbc::RepeatedField WeakDependency { get { return weakDependency_; } } @@ -436,7 +444,7 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec _repeated_messageType_codec = pb::FieldCodec.ForMessage(34, global::Google.Protobuf.DescriptorProtos.DescriptorProto.Parser); private readonly pbc::RepeatedField messageType_ = new pbc::RepeatedField(); - public pbc::RepeatedField MessageType { + internal pbc::RepeatedField MessageType { get { return messageType_; } } @@ -444,7 +452,7 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec _repeated_enumType_codec = pb::FieldCodec.ForMessage(42, global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto.Parser); private readonly pbc::RepeatedField enumType_ = new pbc::RepeatedField(); - public pbc::RepeatedField EnumType { + internal pbc::RepeatedField EnumType { get { return enumType_; } } @@ -452,7 +460,7 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec _repeated_service_codec = pb::FieldCodec.ForMessage(50, global::Google.Protobuf.DescriptorProtos.ServiceDescriptorProto.Parser); private readonly pbc::RepeatedField service_ = new pbc::RepeatedField(); - public pbc::RepeatedField Service { + internal pbc::RepeatedField Service { get { return service_; } } @@ -460,13 +468,13 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec _repeated_extension_codec = pb::FieldCodec.ForMessage(58, global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Parser); private readonly pbc::RepeatedField extension_ = new pbc::RepeatedField(); - public pbc::RepeatedField Extension { + internal pbc::RepeatedField Extension { get { return extension_; } } public const int OptionsFieldNumber = 8; private global::Google.Protobuf.DescriptorProtos.FileOptions options_; - public global::Google.Protobuf.DescriptorProtos.FileOptions Options { + internal global::Google.Protobuf.DescriptorProtos.FileOptions Options { get { return options_; } set { pb::Freezable.CheckMutable(this); @@ -476,7 +484,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int SourceCodeInfoFieldNumber = 9; private global::Google.Protobuf.DescriptorProtos.SourceCodeInfo sourceCodeInfo_; - public global::Google.Protobuf.DescriptorProtos.SourceCodeInfo SourceCodeInfo { + internal global::Google.Protobuf.DescriptorProtos.SourceCodeInfo SourceCodeInfo { get { return sourceCodeInfo_; } set { pb::Freezable.CheckMutable(this); @@ -486,7 +494,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int SyntaxFieldNumber = 12; private string syntax_ = ""; - public string Syntax { + internal string Syntax { get { return syntax_; } set { pb::Freezable.CheckMutable(this); @@ -702,7 +710,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class DescriptorProto : pb::IMessage { + internal sealed partial class DescriptorProto : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new DescriptorProto()); public static pb::MessageParser Parser { get { return _parser; } } @@ -719,9 +727,13 @@ namespace Google.Protobuf.DescriptorProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public DescriptorProto() { } + public DescriptorProto() { + OnConstruction(); + } + + partial void OnConstruction(); - public DescriptorProto(DescriptorProto other) { + public DescriptorProto(DescriptorProto other) : this() { name_ = other.name_; field_ = other.field_.Clone(); extension_ = other.extension_.Clone(); @@ -756,7 +768,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int NameFieldNumber = 1; private string name_ = ""; - public string Name { + internal string Name { get { return name_; } set { pb::Freezable.CheckMutable(this); @@ -768,7 +780,7 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec _repeated_field_codec = pb::FieldCodec.ForMessage(18, global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Parser); private readonly pbc::RepeatedField field_ = new pbc::RepeatedField(); - public pbc::RepeatedField Field { + internal pbc::RepeatedField Field { get { return field_; } } @@ -776,7 +788,7 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec _repeated_extension_codec = pb::FieldCodec.ForMessage(50, global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Parser); private readonly pbc::RepeatedField extension_ = new pbc::RepeatedField(); - public pbc::RepeatedField Extension { + internal pbc::RepeatedField Extension { get { return extension_; } } @@ -784,7 +796,7 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec _repeated_nestedType_codec = pb::FieldCodec.ForMessage(26, global::Google.Protobuf.DescriptorProtos.DescriptorProto.Parser); private readonly pbc::RepeatedField nestedType_ = new pbc::RepeatedField(); - public pbc::RepeatedField NestedType { + internal pbc::RepeatedField NestedType { get { return nestedType_; } } @@ -792,7 +804,7 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec _repeated_enumType_codec = pb::FieldCodec.ForMessage(34, global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto.Parser); private readonly pbc::RepeatedField enumType_ = new pbc::RepeatedField(); - public pbc::RepeatedField EnumType { + internal pbc::RepeatedField EnumType { get { return enumType_; } } @@ -800,7 +812,7 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec _repeated_extensionRange_codec = pb::FieldCodec.ForMessage(42, global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ExtensionRange.Parser); private readonly pbc::RepeatedField extensionRange_ = new pbc::RepeatedField(); - public pbc::RepeatedField ExtensionRange { + internal pbc::RepeatedField ExtensionRange { get { return extensionRange_; } } @@ -808,13 +820,13 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec _repeated_oneofDecl_codec = pb::FieldCodec.ForMessage(66, global::Google.Protobuf.DescriptorProtos.OneofDescriptorProto.Parser); private readonly pbc::RepeatedField oneofDecl_ = new pbc::RepeatedField(); - public pbc::RepeatedField OneofDecl { + internal pbc::RepeatedField OneofDecl { get { return oneofDecl_; } } public const int OptionsFieldNumber = 7; private global::Google.Protobuf.DescriptorProtos.MessageOptions options_; - public global::Google.Protobuf.DescriptorProtos.MessageOptions Options { + internal global::Google.Protobuf.DescriptorProtos.MessageOptions Options { get { return options_; } set { pb::Freezable.CheckMutable(this); @@ -826,7 +838,7 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec _repeated_reservedRange_codec = pb::FieldCodec.ForMessage(74, global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ReservedRange.Parser); private readonly pbc::RepeatedField reservedRange_ = new pbc::RepeatedField(); - public pbc::RepeatedField ReservedRange { + internal pbc::RepeatedField ReservedRange { get { return reservedRange_; } } @@ -834,7 +846,7 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec _repeated_reservedName_codec = pb::FieldCodec.ForString(82); private readonly pbc::RepeatedField reservedName_ = new pbc::RepeatedField(); - public pbc::RepeatedField ReservedName { + internal pbc::RepeatedField ReservedName { get { return reservedName_; } } @@ -1000,7 +1012,7 @@ namespace Google.Protobuf.DescriptorProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class Types { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class ExtensionRange : pb::IMessage { + internal sealed partial class ExtensionRange : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ExtensionRange()); public static pb::MessageParser Parser { get { return _parser; } } @@ -1017,9 +1029,13 @@ namespace Google.Protobuf.DescriptorProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public ExtensionRange() { } + public ExtensionRange() { + OnConstruction(); + } + + partial void OnConstruction(); - public ExtensionRange(ExtensionRange other) { + public ExtensionRange(ExtensionRange other) : this() { start_ = other.start_; end_ = other.end_; } @@ -1037,7 +1053,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int StartFieldNumber = 1; private int start_; - public int Start { + internal int Start { get { return start_; } set { pb::Freezable.CheckMutable(this); @@ -1047,7 +1063,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int EndFieldNumber = 2; private int end_; - public int End { + internal int End { get { return end_; } set { pb::Freezable.CheckMutable(this); @@ -1138,7 +1154,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class ReservedRange : pb::IMessage { + internal sealed partial class ReservedRange : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ReservedRange()); public static pb::MessageParser Parser { get { return _parser; } } @@ -1155,9 +1171,13 @@ namespace Google.Protobuf.DescriptorProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public ReservedRange() { } + public ReservedRange() { + OnConstruction(); + } - public ReservedRange(ReservedRange other) { + partial void OnConstruction(); + + public ReservedRange(ReservedRange other) : this() { start_ = other.start_; end_ = other.end_; } @@ -1175,7 +1195,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int StartFieldNumber = 1; private int start_; - public int Start { + internal int Start { get { return start_; } set { pb::Freezable.CheckMutable(this); @@ -1185,7 +1205,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int EndFieldNumber = 2; private int end_; - public int End { + internal int End { get { return end_; } set { pb::Freezable.CheckMutable(this); @@ -1281,7 +1301,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class FieldDescriptorProto : pb::IMessage { + internal sealed partial class FieldDescriptorProto : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FieldDescriptorProto()); public static pb::MessageParser Parser { get { return _parser; } } @@ -1298,9 +1318,13 @@ namespace Google.Protobuf.DescriptorProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public FieldDescriptorProto() { } + public FieldDescriptorProto() { + OnConstruction(); + } + + partial void OnConstruction(); - public FieldDescriptorProto(FieldDescriptorProto other) { + public FieldDescriptorProto(FieldDescriptorProto other) : this() { name_ = other.name_; number_ = other.number_; label_ = other.label_; @@ -1326,7 +1350,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int NameFieldNumber = 1; private string name_ = ""; - public string Name { + internal string Name { get { return name_; } set { pb::Freezable.CheckMutable(this); @@ -1336,7 +1360,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int NumberFieldNumber = 3; private int number_; - public int Number { + internal int Number { get { return number_; } set { pb::Freezable.CheckMutable(this); @@ -1346,7 +1370,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int LabelFieldNumber = 4; private global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Label label_ = global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Label.LABEL_OPTIONAL; - public global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Label Label { + internal global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Label Label { get { return label_; } set { pb::Freezable.CheckMutable(this); @@ -1356,7 +1380,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int TypeFieldNumber = 5; private global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Type type_ = global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Type.TYPE_DOUBLE; - public global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Type Type { + internal global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Type Type { get { return type_; } set { pb::Freezable.CheckMutable(this); @@ -1366,7 +1390,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int TypeNameFieldNumber = 6; private string typeName_ = ""; - public string TypeName { + internal string TypeName { get { return typeName_; } set { pb::Freezable.CheckMutable(this); @@ -1376,7 +1400,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int ExtendeeFieldNumber = 2; private string extendee_ = ""; - public string Extendee { + internal string Extendee { get { return extendee_; } set { pb::Freezable.CheckMutable(this); @@ -1386,7 +1410,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int DefaultValueFieldNumber = 7; private string defaultValue_ = ""; - public string DefaultValue { + internal string DefaultValue { get { return defaultValue_; } set { pb::Freezable.CheckMutable(this); @@ -1396,7 +1420,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int OneofIndexFieldNumber = 9; private int oneofIndex_; - public int OneofIndex { + internal int OneofIndex { get { return oneofIndex_; } set { pb::Freezable.CheckMutable(this); @@ -1406,7 +1430,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int OptionsFieldNumber = 8; private global::Google.Protobuf.DescriptorProtos.FieldOptions options_; - public global::Google.Protobuf.DescriptorProtos.FieldOptions Options { + internal global::Google.Protobuf.DescriptorProtos.FieldOptions Options { get { return options_; } set { pb::Freezable.CheckMutable(this); @@ -1615,7 +1639,7 @@ namespace Google.Protobuf.DescriptorProtos { #region Nested types [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class Types { - public enum Type { + internal enum Type { TYPE_DOUBLE = 1, TYPE_FLOAT = 2, TYPE_INT64 = 3, @@ -1636,7 +1660,7 @@ namespace Google.Protobuf.DescriptorProtos { TYPE_SINT64 = 18, } - public enum Label { + internal enum Label { LABEL_OPTIONAL = 1, LABEL_REQUIRED = 2, LABEL_REPEATED = 3, @@ -1648,7 +1672,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class OneofDescriptorProto : pb::IMessage { + internal sealed partial class OneofDescriptorProto : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new OneofDescriptorProto()); public static pb::MessageParser Parser { get { return _parser; } } @@ -1665,9 +1689,13 @@ namespace Google.Protobuf.DescriptorProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public OneofDescriptorProto() { } + public OneofDescriptorProto() { + OnConstruction(); + } + + partial void OnConstruction(); - public OneofDescriptorProto(OneofDescriptorProto other) { + public OneofDescriptorProto(OneofDescriptorProto other) : this() { name_ = other.name_; } @@ -1684,7 +1712,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int NameFieldNumber = 1; private string name_ = ""; - public string Name { + internal string Name { get { return name_; } set { pb::Freezable.CheckMutable(this); @@ -1759,7 +1787,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class EnumDescriptorProto : pb::IMessage { + internal sealed partial class EnumDescriptorProto : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new EnumDescriptorProto()); public static pb::MessageParser Parser { get { return _parser; } } @@ -1776,9 +1804,13 @@ namespace Google.Protobuf.DescriptorProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public EnumDescriptorProto() { } + public EnumDescriptorProto() { + OnConstruction(); + } + + partial void OnConstruction(); - public EnumDescriptorProto(EnumDescriptorProto other) { + public EnumDescriptorProto(EnumDescriptorProto other) : this() { name_ = other.name_; value_ = other.value_.Clone(); Options = other.options_ != null ? other.Options.Clone() : null; @@ -1799,7 +1831,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int NameFieldNumber = 1; private string name_ = ""; - public string Name { + internal string Name { get { return name_; } set { pb::Freezable.CheckMutable(this); @@ -1811,13 +1843,13 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec _repeated_value_codec = pb::FieldCodec.ForMessage(18, global::Google.Protobuf.DescriptorProtos.EnumValueDescriptorProto.Parser); private readonly pbc::RepeatedField value_ = new pbc::RepeatedField(); - public pbc::RepeatedField Value { + internal pbc::RepeatedField Value { get { return value_; } } public const int OptionsFieldNumber = 3; private global::Google.Protobuf.DescriptorProtos.EnumOptions options_; - public global::Google.Protobuf.DescriptorProtos.EnumOptions Options { + internal global::Google.Protobuf.DescriptorProtos.EnumOptions Options { get { return options_; } set { pb::Freezable.CheckMutable(this); @@ -1923,7 +1955,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class EnumValueDescriptorProto : pb::IMessage { + internal sealed partial class EnumValueDescriptorProto : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new EnumValueDescriptorProto()); public static pb::MessageParser Parser { get { return _parser; } } @@ -1940,9 +1972,13 @@ namespace Google.Protobuf.DescriptorProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public EnumValueDescriptorProto() { } + public EnumValueDescriptorProto() { + OnConstruction(); + } - public EnumValueDescriptorProto(EnumValueDescriptorProto other) { + partial void OnConstruction(); + + public EnumValueDescriptorProto(EnumValueDescriptorProto other) : this() { name_ = other.name_; number_ = other.number_; Options = other.options_ != null ? other.Options.Clone() : null; @@ -1962,7 +1998,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int NameFieldNumber = 1; private string name_ = ""; - public string Name { + internal string Name { get { return name_; } set { pb::Freezable.CheckMutable(this); @@ -1972,7 +2008,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int NumberFieldNumber = 2; private int number_; - public int Number { + internal int Number { get { return number_; } set { pb::Freezable.CheckMutable(this); @@ -1982,7 +2018,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int OptionsFieldNumber = 3; private global::Google.Protobuf.DescriptorProtos.EnumValueOptions options_; - public global::Google.Protobuf.DescriptorProtos.EnumValueOptions Options { + internal global::Google.Protobuf.DescriptorProtos.EnumValueOptions Options { get { return options_; } set { pb::Freezable.CheckMutable(this); @@ -2095,7 +2131,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class ServiceDescriptorProto : pb::IMessage { + internal sealed partial class ServiceDescriptorProto : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ServiceDescriptorProto()); public static pb::MessageParser Parser { get { return _parser; } } @@ -2112,9 +2148,13 @@ namespace Google.Protobuf.DescriptorProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public ServiceDescriptorProto() { } + public ServiceDescriptorProto() { + OnConstruction(); + } + + partial void OnConstruction(); - public ServiceDescriptorProto(ServiceDescriptorProto other) { + public ServiceDescriptorProto(ServiceDescriptorProto other) : this() { name_ = other.name_; method_ = other.method_.Clone(); Options = other.options_ != null ? other.Options.Clone() : null; @@ -2135,7 +2175,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int NameFieldNumber = 1; private string name_ = ""; - public string Name { + internal string Name { get { return name_; } set { pb::Freezable.CheckMutable(this); @@ -2147,13 +2187,13 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec _repeated_method_codec = pb::FieldCodec.ForMessage(18, global::Google.Protobuf.DescriptorProtos.MethodDescriptorProto.Parser); private readonly pbc::RepeatedField method_ = new pbc::RepeatedField(); - public pbc::RepeatedField Method { + internal pbc::RepeatedField Method { get { return method_; } } public const int OptionsFieldNumber = 3; private global::Google.Protobuf.DescriptorProtos.ServiceOptions options_; - public global::Google.Protobuf.DescriptorProtos.ServiceOptions Options { + internal global::Google.Protobuf.DescriptorProtos.ServiceOptions Options { get { return options_; } set { pb::Freezable.CheckMutable(this); @@ -2259,7 +2299,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MethodDescriptorProto : pb::IMessage { + internal sealed partial class MethodDescriptorProto : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MethodDescriptorProto()); public static pb::MessageParser Parser { get { return _parser; } } @@ -2276,9 +2316,13 @@ namespace Google.Protobuf.DescriptorProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public MethodDescriptorProto() { } + public MethodDescriptorProto() { + OnConstruction(); + } + + partial void OnConstruction(); - public MethodDescriptorProto(MethodDescriptorProto other) { + public MethodDescriptorProto(MethodDescriptorProto other) : this() { name_ = other.name_; inputType_ = other.inputType_; outputType_ = other.outputType_; @@ -2301,7 +2345,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int NameFieldNumber = 1; private string name_ = ""; - public string Name { + internal string Name { get { return name_; } set { pb::Freezable.CheckMutable(this); @@ -2311,7 +2355,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int InputTypeFieldNumber = 2; private string inputType_ = ""; - public string InputType { + internal string InputType { get { return inputType_; } set { pb::Freezable.CheckMutable(this); @@ -2321,7 +2365,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int OutputTypeFieldNumber = 3; private string outputType_ = ""; - public string OutputType { + internal string OutputType { get { return outputType_; } set { pb::Freezable.CheckMutable(this); @@ -2331,7 +2375,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int OptionsFieldNumber = 4; private global::Google.Protobuf.DescriptorProtos.MethodOptions options_; - public global::Google.Protobuf.DescriptorProtos.MethodOptions Options { + internal global::Google.Protobuf.DescriptorProtos.MethodOptions Options { get { return options_; } set { pb::Freezable.CheckMutable(this); @@ -2341,7 +2385,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int ClientStreamingFieldNumber = 5; private bool clientStreaming_; - public bool ClientStreaming { + internal bool ClientStreaming { get { return clientStreaming_; } set { pb::Freezable.CheckMutable(this); @@ -2351,7 +2395,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int ServerStreamingFieldNumber = 6; private bool serverStreaming_; - public bool ServerStreaming { + internal bool ServerStreaming { get { return serverStreaming_; } set { pb::Freezable.CheckMutable(this); @@ -2512,7 +2556,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class FileOptions : pb::IMessage { + internal sealed partial class FileOptions : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FileOptions()); public static pb::MessageParser Parser { get { return _parser; } } @@ -2529,9 +2573,13 @@ namespace Google.Protobuf.DescriptorProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public FileOptions() { } + public FileOptions() { + OnConstruction(); + } + + partial void OnConstruction(); - public FileOptions(FileOptions other) { + public FileOptions(FileOptions other) : this() { javaPackage_ = other.javaPackage_; javaOuterClassname_ = other.javaOuterClassname_; javaMultipleFiles_ = other.javaMultipleFiles_; @@ -2563,7 +2611,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int JavaPackageFieldNumber = 1; private string javaPackage_ = ""; - public string JavaPackage { + internal string JavaPackage { get { return javaPackage_; } set { pb::Freezable.CheckMutable(this); @@ -2573,7 +2621,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int JavaOuterClassnameFieldNumber = 8; private string javaOuterClassname_ = ""; - public string JavaOuterClassname { + internal string JavaOuterClassname { get { return javaOuterClassname_; } set { pb::Freezable.CheckMutable(this); @@ -2583,7 +2631,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int JavaMultipleFilesFieldNumber = 10; private bool javaMultipleFiles_; - public bool JavaMultipleFiles { + internal bool JavaMultipleFiles { get { return javaMultipleFiles_; } set { pb::Freezable.CheckMutable(this); @@ -2593,7 +2641,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int JavaGenerateEqualsAndHashFieldNumber = 20; private bool javaGenerateEqualsAndHash_; - public bool JavaGenerateEqualsAndHash { + internal bool JavaGenerateEqualsAndHash { get { return javaGenerateEqualsAndHash_; } set { pb::Freezable.CheckMutable(this); @@ -2603,7 +2651,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int JavaStringCheckUtf8FieldNumber = 27; private bool javaStringCheckUtf8_; - public bool JavaStringCheckUtf8 { + internal bool JavaStringCheckUtf8 { get { return javaStringCheckUtf8_; } set { pb::Freezable.CheckMutable(this); @@ -2613,7 +2661,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int OptimizeForFieldNumber = 9; private global::Google.Protobuf.DescriptorProtos.FileOptions.Types.OptimizeMode optimizeFor_ = global::Google.Protobuf.DescriptorProtos.FileOptions.Types.OptimizeMode.SPEED; - public global::Google.Protobuf.DescriptorProtos.FileOptions.Types.OptimizeMode OptimizeFor { + internal global::Google.Protobuf.DescriptorProtos.FileOptions.Types.OptimizeMode OptimizeFor { get { return optimizeFor_; } set { pb::Freezable.CheckMutable(this); @@ -2623,7 +2671,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int GoPackageFieldNumber = 11; private string goPackage_ = ""; - public string GoPackage { + internal string GoPackage { get { return goPackage_; } set { pb::Freezable.CheckMutable(this); @@ -2633,7 +2681,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int CcGenericServicesFieldNumber = 16; private bool ccGenericServices_; - public bool CcGenericServices { + internal bool CcGenericServices { get { return ccGenericServices_; } set { pb::Freezable.CheckMutable(this); @@ -2643,7 +2691,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int JavaGenericServicesFieldNumber = 17; private bool javaGenericServices_; - public bool JavaGenericServices { + internal bool JavaGenericServices { get { return javaGenericServices_; } set { pb::Freezable.CheckMutable(this); @@ -2653,7 +2701,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int PyGenericServicesFieldNumber = 18; private bool pyGenericServices_; - public bool PyGenericServices { + internal bool PyGenericServices { get { return pyGenericServices_; } set { pb::Freezable.CheckMutable(this); @@ -2663,7 +2711,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int DeprecatedFieldNumber = 23; private bool deprecated_; - public bool Deprecated { + internal bool Deprecated { get { return deprecated_; } set { pb::Freezable.CheckMutable(this); @@ -2673,7 +2721,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int CcEnableArenasFieldNumber = 31; private bool ccEnableArenas_; - public bool CcEnableArenas { + internal bool CcEnableArenas { get { return ccEnableArenas_; } set { pb::Freezable.CheckMutable(this); @@ -2683,7 +2731,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int ObjcClassPrefixFieldNumber = 36; private string objcClassPrefix_ = ""; - public string ObjcClassPrefix { + internal string ObjcClassPrefix { get { return objcClassPrefix_; } set { pb::Freezable.CheckMutable(this); @@ -2693,7 +2741,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int CsharpNamespaceFieldNumber = 37; private string csharpNamespace_ = ""; - public string CsharpNamespace { + internal string CsharpNamespace { get { return csharpNamespace_; } set { pb::Freezable.CheckMutable(this); @@ -2705,7 +2753,7 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec _repeated_uninterpretedOption_codec = pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); private readonly pbc::RepeatedField uninterpretedOption_ = new pbc::RepeatedField(); - public pbc::RepeatedField UninterpretedOption { + internal pbc::RepeatedField UninterpretedOption { get { return uninterpretedOption_; } } @@ -2993,7 +3041,7 @@ namespace Google.Protobuf.DescriptorProtos { #region Nested types [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class Types { - public enum OptimizeMode { + internal enum OptimizeMode { SPEED = 1, CODE_SIZE = 2, LITE_RUNTIME = 3, @@ -3005,7 +3053,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MessageOptions : pb::IMessage { + internal sealed partial class MessageOptions : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MessageOptions()); public static pb::MessageParser Parser { get { return _parser; } } @@ -3022,9 +3070,13 @@ namespace Google.Protobuf.DescriptorProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public MessageOptions() { } + public MessageOptions() { + OnConstruction(); + } + + partial void OnConstruction(); - public MessageOptions(MessageOptions other) { + public MessageOptions(MessageOptions other) : this() { messageSetWireFormat_ = other.messageSetWireFormat_; noStandardDescriptorAccessor_ = other.noStandardDescriptorAccessor_; deprecated_ = other.deprecated_; @@ -3046,7 +3098,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int MessageSetWireFormatFieldNumber = 1; private bool messageSetWireFormat_; - public bool MessageSetWireFormat { + internal bool MessageSetWireFormat { get { return messageSetWireFormat_; } set { pb::Freezable.CheckMutable(this); @@ -3056,7 +3108,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int NoStandardDescriptorAccessorFieldNumber = 2; private bool noStandardDescriptorAccessor_; - public bool NoStandardDescriptorAccessor { + internal bool NoStandardDescriptorAccessor { get { return noStandardDescriptorAccessor_; } set { pb::Freezable.CheckMutable(this); @@ -3066,7 +3118,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int DeprecatedFieldNumber = 3; private bool deprecated_; - public bool Deprecated { + internal bool Deprecated { get { return deprecated_; } set { pb::Freezable.CheckMutable(this); @@ -3076,7 +3128,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int MapEntryFieldNumber = 7; private bool mapEntry_; - public bool MapEntry { + internal bool MapEntry { get { return mapEntry_; } set { pb::Freezable.CheckMutable(this); @@ -3088,7 +3140,7 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec _repeated_uninterpretedOption_codec = pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); private readonly pbc::RepeatedField uninterpretedOption_ = new pbc::RepeatedField(); - public pbc::RepeatedField UninterpretedOption { + internal pbc::RepeatedField UninterpretedOption { get { return uninterpretedOption_; } } @@ -3216,7 +3268,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class FieldOptions : pb::IMessage { + internal sealed partial class FieldOptions : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FieldOptions()); public static pb::MessageParser Parser { get { return _parser; } } @@ -3233,9 +3285,13 @@ namespace Google.Protobuf.DescriptorProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public FieldOptions() { } + public FieldOptions() { + OnConstruction(); + } + + partial void OnConstruction(); - public FieldOptions(FieldOptions other) { + public FieldOptions(FieldOptions other) : this() { ctype_ = other.ctype_; packed_ = other.packed_; jstype_ = other.jstype_; @@ -3259,7 +3315,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int CtypeFieldNumber = 1; private global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.CType ctype_ = global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.CType.STRING; - public global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.CType Ctype { + internal global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.CType Ctype { get { return ctype_; } set { pb::Freezable.CheckMutable(this); @@ -3269,7 +3325,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int PackedFieldNumber = 2; private bool packed_; - public bool Packed { + internal bool Packed { get { return packed_; } set { pb::Freezable.CheckMutable(this); @@ -3279,7 +3335,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int JstypeFieldNumber = 6; private global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.JSType jstype_ = global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.JSType.JS_NORMAL; - public global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.JSType Jstype { + internal global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.JSType Jstype { get { return jstype_; } set { pb::Freezable.CheckMutable(this); @@ -3289,7 +3345,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int LazyFieldNumber = 5; private bool lazy_; - public bool Lazy { + internal bool Lazy { get { return lazy_; } set { pb::Freezable.CheckMutable(this); @@ -3299,7 +3355,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int DeprecatedFieldNumber = 3; private bool deprecated_; - public bool Deprecated { + internal bool Deprecated { get { return deprecated_; } set { pb::Freezable.CheckMutable(this); @@ -3309,7 +3365,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int WeakFieldNumber = 10; private bool weak_; - public bool Weak { + internal bool Weak { get { return weak_; } set { pb::Freezable.CheckMutable(this); @@ -3321,7 +3377,7 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec _repeated_uninterpretedOption_codec = pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); private readonly pbc::RepeatedField uninterpretedOption_ = new pbc::RepeatedField(); - public pbc::RepeatedField UninterpretedOption { + internal pbc::RepeatedField UninterpretedOption { get { return uninterpretedOption_; } } @@ -3481,13 +3537,13 @@ namespace Google.Protobuf.DescriptorProtos { #region Nested types [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class Types { - public enum CType { + internal enum CType { STRING = 0, CORD = 1, STRING_PIECE = 2, } - public enum JSType { + internal enum JSType { JS_NORMAL = 0, JS_STRING = 1, JS_NUMBER = 2, @@ -3499,7 +3555,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class EnumOptions : pb::IMessage { + internal sealed partial class EnumOptions : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new EnumOptions()); public static pb::MessageParser Parser { get { return _parser; } } @@ -3516,9 +3572,13 @@ namespace Google.Protobuf.DescriptorProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public EnumOptions() { } + public EnumOptions() { + OnConstruction(); + } + + partial void OnConstruction(); - public EnumOptions(EnumOptions other) { + public EnumOptions(EnumOptions other) : this() { allowAlias_ = other.allowAlias_; deprecated_ = other.deprecated_; uninterpretedOption_ = other.uninterpretedOption_.Clone(); @@ -3538,7 +3598,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int AllowAliasFieldNumber = 2; private bool allowAlias_; - public bool AllowAlias { + internal bool AllowAlias { get { return allowAlias_; } set { pb::Freezable.CheckMutable(this); @@ -3548,7 +3608,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int DeprecatedFieldNumber = 3; private bool deprecated_; - public bool Deprecated { + internal bool Deprecated { get { return deprecated_; } set { pb::Freezable.CheckMutable(this); @@ -3560,7 +3620,7 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec _repeated_uninterpretedOption_codec = pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); private readonly pbc::RepeatedField uninterpretedOption_ = new pbc::RepeatedField(); - public pbc::RepeatedField UninterpretedOption { + internal pbc::RepeatedField UninterpretedOption { get { return uninterpretedOption_; } } @@ -3656,7 +3716,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class EnumValueOptions : pb::IMessage { + internal sealed partial class EnumValueOptions : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new EnumValueOptions()); public static pb::MessageParser Parser { get { return _parser; } } @@ -3673,9 +3733,13 @@ namespace Google.Protobuf.DescriptorProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public EnumValueOptions() { } + public EnumValueOptions() { + OnConstruction(); + } - public EnumValueOptions(EnumValueOptions other) { + partial void OnConstruction(); + + public EnumValueOptions(EnumValueOptions other) : this() { deprecated_ = other.deprecated_; uninterpretedOption_ = other.uninterpretedOption_.Clone(); } @@ -3694,7 +3758,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int DeprecatedFieldNumber = 1; private bool deprecated_; - public bool Deprecated { + internal bool Deprecated { get { return deprecated_; } set { pb::Freezable.CheckMutable(this); @@ -3706,7 +3770,7 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec _repeated_uninterpretedOption_codec = pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); private readonly pbc::RepeatedField uninterpretedOption_ = new pbc::RepeatedField(); - public pbc::RepeatedField UninterpretedOption { + internal pbc::RepeatedField UninterpretedOption { get { return uninterpretedOption_; } } @@ -3786,7 +3850,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class ServiceOptions : pb::IMessage { + internal sealed partial class ServiceOptions : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ServiceOptions()); public static pb::MessageParser Parser { get { return _parser; } } @@ -3803,9 +3867,13 @@ namespace Google.Protobuf.DescriptorProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public ServiceOptions() { } + public ServiceOptions() { + OnConstruction(); + } + + partial void OnConstruction(); - public ServiceOptions(ServiceOptions other) { + public ServiceOptions(ServiceOptions other) : this() { deprecated_ = other.deprecated_; uninterpretedOption_ = other.uninterpretedOption_.Clone(); } @@ -3824,7 +3892,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int DeprecatedFieldNumber = 33; private bool deprecated_; - public bool Deprecated { + internal bool Deprecated { get { return deprecated_; } set { pb::Freezable.CheckMutable(this); @@ -3836,7 +3904,7 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec _repeated_uninterpretedOption_codec = pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); private readonly pbc::RepeatedField uninterpretedOption_ = new pbc::RepeatedField(); - public pbc::RepeatedField UninterpretedOption { + internal pbc::RepeatedField UninterpretedOption { get { return uninterpretedOption_; } } @@ -3916,7 +3984,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class MethodOptions : pb::IMessage { + internal sealed partial class MethodOptions : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MethodOptions()); public static pb::MessageParser Parser { get { return _parser; } } @@ -3933,9 +4001,13 @@ namespace Google.Protobuf.DescriptorProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public MethodOptions() { } + public MethodOptions() { + OnConstruction(); + } + + partial void OnConstruction(); - public MethodOptions(MethodOptions other) { + public MethodOptions(MethodOptions other) : this() { deprecated_ = other.deprecated_; uninterpretedOption_ = other.uninterpretedOption_.Clone(); } @@ -3954,7 +4026,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int DeprecatedFieldNumber = 33; private bool deprecated_; - public bool Deprecated { + internal bool Deprecated { get { return deprecated_; } set { pb::Freezable.CheckMutable(this); @@ -3966,7 +4038,7 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec _repeated_uninterpretedOption_codec = pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Parser); private readonly pbc::RepeatedField uninterpretedOption_ = new pbc::RepeatedField(); - public pbc::RepeatedField UninterpretedOption { + internal pbc::RepeatedField UninterpretedOption { get { return uninterpretedOption_; } } @@ -4046,7 +4118,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class UninterpretedOption : pb::IMessage { + internal sealed partial class UninterpretedOption : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new UninterpretedOption()); public static pb::MessageParser Parser { get { return _parser; } } @@ -4063,9 +4135,13 @@ namespace Google.Protobuf.DescriptorProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public UninterpretedOption() { } + public UninterpretedOption() { + OnConstruction(); + } + + partial void OnConstruction(); - public UninterpretedOption(UninterpretedOption other) { + public UninterpretedOption(UninterpretedOption other) : this() { name_ = other.name_.Clone(); identifierValue_ = other.identifierValue_; positiveIntValue_ = other.positiveIntValue_; @@ -4091,13 +4167,13 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec _repeated_name_codec = pb::FieldCodec.ForMessage(18, global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Types.NamePart.Parser); private readonly pbc::RepeatedField name_ = new pbc::RepeatedField(); - public pbc::RepeatedField Name { + internal pbc::RepeatedField Name { get { return name_; } } public const int IdentifierValueFieldNumber = 3; private string identifierValue_ = ""; - public string IdentifierValue { + internal string IdentifierValue { get { return identifierValue_; } set { pb::Freezable.CheckMutable(this); @@ -4107,7 +4183,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int PositiveIntValueFieldNumber = 4; private ulong positiveIntValue_; - public ulong PositiveIntValue { + internal ulong PositiveIntValue { get { return positiveIntValue_; } set { pb::Freezable.CheckMutable(this); @@ -4117,7 +4193,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int NegativeIntValueFieldNumber = 5; private long negativeIntValue_; - public long NegativeIntValue { + internal long NegativeIntValue { get { return negativeIntValue_; } set { pb::Freezable.CheckMutable(this); @@ -4127,7 +4203,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int DoubleValueFieldNumber = 6; private double doubleValue_; - public double DoubleValue { + internal double DoubleValue { get { return doubleValue_; } set { pb::Freezable.CheckMutable(this); @@ -4137,7 +4213,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int StringValueFieldNumber = 7; private pb::ByteString stringValue_ = pb::ByteString.Empty; - public pb::ByteString StringValue { + internal pb::ByteString StringValue { get { return stringValue_; } set { pb::Freezable.CheckMutable(this); @@ -4147,7 +4223,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int AggregateValueFieldNumber = 8; private string aggregateValue_ = ""; - public string AggregateValue { + internal string AggregateValue { get { return aggregateValue_; } set { pb::Freezable.CheckMutable(this); @@ -4312,7 +4388,7 @@ namespace Google.Protobuf.DescriptorProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class Types { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class NamePart : pb::IMessage { + internal sealed partial class NamePart : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NamePart()); public static pb::MessageParser Parser { get { return _parser; } } @@ -4329,9 +4405,13 @@ namespace Google.Protobuf.DescriptorProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public NamePart() { } + public NamePart() { + OnConstruction(); + } - public NamePart(NamePart other) { + partial void OnConstruction(); + + public NamePart(NamePart other) : this() { namePart_ = other.namePart_; isExtension_ = other.isExtension_; } @@ -4349,7 +4429,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int NamePart_FieldNumber = 1; private string namePart_ = ""; - public string NamePart_ { + internal string NamePart_ { get { return namePart_; } set { pb::Freezable.CheckMutable(this); @@ -4359,7 +4439,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int IsExtensionFieldNumber = 2; private bool isExtension_; - public bool IsExtension { + internal bool IsExtension { get { return isExtension_; } set { pb::Freezable.CheckMutable(this); @@ -4455,7 +4535,7 @@ namespace Google.Protobuf.DescriptorProtos { } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class SourceCodeInfo : pb::IMessage { + internal sealed partial class SourceCodeInfo : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new SourceCodeInfo()); public static pb::MessageParser Parser { get { return _parser; } } @@ -4472,9 +4552,13 @@ namespace Google.Protobuf.DescriptorProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public SourceCodeInfo() { } + public SourceCodeInfo() { + OnConstruction(); + } + + partial void OnConstruction(); - public SourceCodeInfo(SourceCodeInfo other) { + public SourceCodeInfo(SourceCodeInfo other) : this() { location_ = other.location_.Clone(); } @@ -4494,7 +4578,7 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec _repeated_location_codec = pb::FieldCodec.ForMessage(10, global::Google.Protobuf.DescriptorProtos.SourceCodeInfo.Types.Location.Parser); private readonly pbc::RepeatedField location_ = new pbc::RepeatedField(); - public pbc::RepeatedField Location { + internal pbc::RepeatedField Location { get { return location_; } } @@ -4559,7 +4643,7 @@ namespace Google.Protobuf.DescriptorProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class Types { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class Location : pb::IMessage { + internal sealed partial class Location : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Location()); public static pb::MessageParser Parser { get { return _parser; } } @@ -4576,9 +4660,13 @@ namespace Google.Protobuf.DescriptorProtos { private bool _frozen = false; public bool IsFrozen { get { return _frozen; } } - public Location() { } + public Location() { + OnConstruction(); + } + + partial void OnConstruction(); - public Location(Location other) { + public Location(Location other) : this() { path_ = other.path_.Clone(); span_ = other.span_.Clone(); leadingComments_ = other.leadingComments_; @@ -4604,7 +4692,7 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec _repeated_path_codec = pb::FieldCodec.ForInt32(10); private readonly pbc::RepeatedField path_ = new pbc::RepeatedField(); - public pbc::RepeatedField Path { + internal pbc::RepeatedField Path { get { return path_; } } @@ -4612,13 +4700,13 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec _repeated_span_codec = pb::FieldCodec.ForInt32(18); private readonly pbc::RepeatedField span_ = new pbc::RepeatedField(); - public pbc::RepeatedField Span { + internal pbc::RepeatedField Span { get { return span_; } } public const int LeadingCommentsFieldNumber = 3; private string leadingComments_ = ""; - public string LeadingComments { + internal string LeadingComments { get { return leadingComments_; } set { pb::Freezable.CheckMutable(this); @@ -4628,7 +4716,7 @@ namespace Google.Protobuf.DescriptorProtos { public const int TrailingCommentsFieldNumber = 4; private string trailingComments_ = ""; - public string TrailingComments { + internal string TrailingComments { get { return trailingComments_; } set { pb::Freezable.CheckMutable(this); @@ -4640,7 +4728,7 @@ namespace Google.Protobuf.DescriptorProtos { private static readonly pb::FieldCodec _repeated_leadingDetachedComments_codec = pb::FieldCodec.ForString(50); private readonly pbc::RepeatedField leadingDetachedComments_ = new pbc::RepeatedField(); - public pbc::RepeatedField LeadingDetachedComments { + internal pbc::RepeatedField LeadingDetachedComments { get { return leadingDetachedComments_; } } diff --git a/examples/addressbook.proto b/examples/addressbook.proto index 9ab45427..5da5fa39 100644 --- a/examples/addressbook.proto +++ b/examples/addressbook.proto @@ -1,6 +1,6 @@ // See README.txt for information and build instructions. -syntax = "proto2"; +syntax = "proto3"; package tutorial; @@ -9,9 +9,9 @@ option java_outer_classname = "AddressBookProtos"; option csharp_namespace = "Google.Protobuf.Examples.AddressBook"; message Person { - required string name = 1; - required int32 id = 2; // Unique ID number for this person. - optional string email = 3; + string name = 1; + int32 id = 2; // Unique ID number for this person. + string email = 3; enum PhoneType { MOBILE = 0; @@ -20,8 +20,8 @@ message Person { } message PhoneNumber { - required string number = 1; - optional PhoneType type = 2 [default = HOME]; + string number = 1; + PhoneType type = 2; } repeated PhoneNumber phone = 4; -- cgit v1.2.3 From af259b77bf04fcfb68609776cb27f04d289a2c39 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Wed, 1 Jul 2015 17:19:48 +0100 Subject: Fix descriptor reflection in various ways - The protos are no longer publicly exposed at all - Oneof detection now works (as we default to -1, not 0) - OneofDescriptor exposes the fields in the oneof - Removed unnecessary code for replacing protos - remnant of extensions - There's now just the non-generic form of IDescriptor --- csharp/src/ProtocolBuffers.Test/DescriptorsTest.cs | 32 +++++++++-- .../DescriptorProtos/IDescriptorProto.cs | 53 ------------------ .../DescriptorProtos/PartialClasses.cs | 38 ++++--------- .../ProtocolBuffers/Descriptors/DescriptorBase.cs | 63 +++++---------------- .../ProtocolBuffers/Descriptors/DescriptorPool.cs | 2 +- .../ProtocolBuffers/Descriptors/EnumDescriptor.cs | 22 ++++---- .../Descriptors/EnumValueDescriptor.cs | 20 +++---- .../ProtocolBuffers/Descriptors/FieldDescriptor.cs | 30 ++++++---- .../ProtocolBuffers/Descriptors/FileDescriptor.cs | 53 +++++++----------- .../src/ProtocolBuffers/Descriptors/IDescriptor.cs | 15 +---- .../Descriptors/IndexedDescriptorBase.cs | 65 ---------------------- .../Descriptors/MessageDescriptor.cs | 57 +++++-------------- .../Descriptors/MethodDescriptor.cs | 28 +++++----- .../ProtocolBuffers/Descriptors/OneofDescriptor.cs | 45 +++++++-------- .../Descriptors/PackageDescriptor.cs | 7 +-- .../Descriptors/ServiceDescriptor.cs | 24 ++++---- csharp/src/ProtocolBuffers/ProtocolBuffers.csproj | 2 - 17 files changed, 178 insertions(+), 378 deletions(-) delete mode 100644 csharp/src/ProtocolBuffers/DescriptorProtos/IDescriptorProto.cs delete mode 100644 csharp/src/ProtocolBuffers/Descriptors/IndexedDescriptorBase.cs diff --git a/csharp/src/ProtocolBuffers.Test/DescriptorsTest.cs b/csharp/src/ProtocolBuffers.Test/DescriptorsTest.cs index e0fef912..d5c622bc 100644 --- a/csharp/src/ProtocolBuffers.Test/DescriptorsTest.cs +++ b/csharp/src/ProtocolBuffers.Test/DescriptorsTest.cs @@ -30,6 +30,8 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #endregion +using System.Linq; +using Google.Protobuf.DescriptorProtos; using Google.Protobuf.Descriptors; using Google.Protobuf.TestProtos; using NUnit.Framework; @@ -50,7 +52,7 @@ namespace Google.Protobuf Assert.AreEqual("google/protobuf/unittest_proto3.proto", file.Name); Assert.AreEqual("protobuf_unittest", file.Package); - Assert.AreEqual("UnittestProto", file.Options.JavaOuterClassname); + Assert.AreEqual("UnittestProto", file.Proto.Options.JavaOuterClassname); Assert.AreEqual("google/protobuf/unittest_proto3.proto", file.Proto.Name); // unittest.proto doesn't have any public imports, but unittest_import.proto does. @@ -92,7 +94,7 @@ namespace Google.Protobuf Assert.AreEqual("protobuf_unittest.TestAllTypes", messageType.FullName); Assert.AreEqual(UnittestProto3.Descriptor, messageType.File); Assert.IsNull(messageType.ContainingType); - Assert.IsNull(messageType.Options); + Assert.IsNull(messageType.Proto.Options); Assert.AreEqual("TestAllTypes", messageType.Name); @@ -143,7 +145,7 @@ namespace Google.Protobuf Assert.AreEqual(messageType, primitiveField.ContainingType); Assert.AreEqual(UnittestProto3.Descriptor, primitiveField.File); Assert.AreEqual(FieldType.Int32, primitiveField.FieldType); - Assert.IsNull(primitiveField.Options); + Assert.IsNull(primitiveField.Proto.Options); Assert.AreEqual("single_nested_enum", enumField.Name); Assert.AreEqual(FieldType.Enum, enumField.FieldType); @@ -177,7 +179,7 @@ namespace Google.Protobuf Assert.AreEqual("protobuf_unittest.ForeignEnum", enumType.FullName); Assert.AreEqual(UnittestProto3.Descriptor, enumType.File); Assert.Null(enumType.ContainingType); - Assert.Null(enumType.Options); + Assert.Null(enumType.Proto.Options); Assert.AreEqual("NestedEnum", nestedType.Name); Assert.AreEqual("protobuf_unittest.TestAllTypes.NestedEnum", @@ -197,5 +199,27 @@ namespace Google.Protobuf Assert.AreEqual(i, enumType.Values[i].Index); } } + + [Test] + public void OneofDescriptor() + { + OneofDescriptor descriptor = TestAllTypes.Descriptor.FindDescriptor("oneof_field"); + Assert.AreEqual("oneof_field", descriptor.Name); + Assert.AreEqual("protobuf_unittest.TestAllTypes.oneof_field", descriptor.FullName); + + var expectedFields = new[] { + TestAllTypes.OneofBytesFieldNumber, + TestAllTypes.OneofNestedMessageFieldNumber, + TestAllTypes.OneofStringFieldNumber, + TestAllTypes.OneofUint32FieldNumber } + .Select(fieldNumber => TestAllTypes.Descriptor.FindFieldByNumber(fieldNumber)) + .ToList(); + foreach (var field in expectedFields) + { + Assert.AreSame(descriptor, field.ContainingOneof); + } + + CollectionAssert.AreEquivalent(expectedFields, descriptor.Fields); + } } } \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/DescriptorProtos/IDescriptorProto.cs b/csharp/src/ProtocolBuffers/DescriptorProtos/IDescriptorProto.cs deleted file mode 100644 index c0f27427..00000000 --- a/csharp/src/ProtocolBuffers/DescriptorProtos/IDescriptorProto.cs +++ /dev/null @@ -1,53 +0,0 @@ -#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.DescriptorProtos -{ - /// - /// Interface implemented by all DescriptorProtos. The generator doesn't - /// emit the interface implementation claim, so PartialClasses.cs contains - /// partial class declarations for each of them. - /// - /// The associated options protocol buffer type - public interface IDescriptorProto - { - /// - /// The brief name of the descriptor's target. - /// - string Name { get; } - - /// - /// The options for this descriptor. - /// - TOptions Options { get; } - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/DescriptorProtos/PartialClasses.cs b/csharp/src/ProtocolBuffers/DescriptorProtos/PartialClasses.cs index 15f339ba..dc19cdad 100644 --- a/csharp/src/ProtocolBuffers/DescriptorProtos/PartialClasses.cs +++ b/csharp/src/ProtocolBuffers/DescriptorProtos/PartialClasses.cs @@ -30,36 +30,18 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #endregion -// This file just contains partial classes for each of the -// autogenerated classes, so that they implement -// IDescriptorProto +// This file just contains partial classes for any autogenerated classes that need additional support. namespace Google.Protobuf.DescriptorProtos { - public partial class DescriptorProto : IDescriptorProto - { - } - - public partial class EnumDescriptorProto : IDescriptorProto - { - } - - public partial class EnumValueDescriptorProto : IDescriptorProto - { - } - - public partial class FieldDescriptorProto : IDescriptorProto - { - } - - public partial class FileDescriptorProto : IDescriptorProto - { - } - - public partial class MethodDescriptorProto : IDescriptorProto - { - } - - public partial class ServiceDescriptorProto : IDescriptorProto + internal partial class FieldDescriptorProto { + // We can't tell the difference between "explicitly set to 0" and "not set" + // in proto3, but we need to tell the difference for OneofIndex. descriptor.proto + // is really a proto2 file, but the runtime doesn't know about proto2 semantics... + // We fake it by defaulting to -1. + partial void OnConstruction() + { + OneofIndex = -1; + } } } \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/Descriptors/DescriptorBase.cs b/csharp/src/ProtocolBuffers/Descriptors/DescriptorBase.cs index ccde34ab..0eb71215 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/DescriptorBase.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/DescriptorBase.cs @@ -34,61 +34,36 @@ using Google.Protobuf.DescriptorProtos; namespace Google.Protobuf.Descriptors { - // TODO(jonskeet): The descriptor type hierarchy needs changing so that we can hide the descriptor protos. /// /// Base class for nearly all descriptors, providing common functionality. /// - /// Type of the protocol buffer form of this descriptor - /// Type of the options protocol buffer for this descriptor - public abstract class DescriptorBase : IDescriptor - where TProto : IMessage, IDescriptorProto + public abstract class DescriptorBase : IDescriptor { - private TProto proto; private readonly FileDescriptor file; private readonly string fullName; + private readonly int index; - protected DescriptorBase(TProto proto, FileDescriptor file, string fullName) + internal DescriptorBase(FileDescriptor file, string fullName, int index) { - this.proto = proto; this.file = file; this.fullName = fullName; + this.index = index; } - internal virtual void ReplaceProto(TProto newProto) - { - this.proto = newProto; - } - - protected static string ComputeFullName(FileDescriptor file, MessageDescriptor parent, string name) - { - if (parent != null) - { - return parent.FullName + "." + name; - } - if (file.Package.Length > 0) - { - return file.Package + "." + name; - } - return name; - } - - IMessage IDescriptor.Proto - { - get { return proto; } - } - - /// - /// Returns the protocol buffer form of this descriptor. - /// - public TProto Proto + /// + /// The index of this descriptor within its parent descriptor. + /// + /// + /// This returns the index of this descriptor within its parent, for + /// this descriptor's type. (There can be duplicate values for different + /// types, e.g. one enum type with index 0 and one message type with index 0.) + /// + public int Index { - get { return proto; } + get { return index; } } - public TOptions Options - { - get { return proto.Options; } - } + public abstract string Name { get; } /// /// The fully qualified name of the descriptor's target. @@ -98,14 +73,6 @@ namespace Google.Protobuf.Descriptors get { return fullName; } } - /// - /// The brief name of the descriptor's target. - /// - public string Name - { - get { return proto.Name; } - } - /// /// The file this descriptor was declared in. /// diff --git a/csharp/src/ProtocolBuffers/Descriptors/DescriptorPool.cs b/csharp/src/ProtocolBuffers/Descriptors/DescriptorPool.cs index 57c4ba03..b07af060 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/DescriptorPool.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/DescriptorPool.cs @@ -257,7 +257,7 @@ namespace Google.Protobuf.Descriptors /// or unqualified. C++-like name lookup semantics are used to search for the /// matching descriptor. /// - public IDescriptor LookupSymbol(string name, IDescriptor relativeTo) + internal IDescriptor LookupSymbol(string name, IDescriptor relativeTo) { // TODO(jonskeet): This could be optimized in a number of ways. diff --git a/csharp/src/ProtocolBuffers/Descriptors/EnumDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/EnumDescriptor.cs index 9f10990b..a6db5268 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/EnumDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/EnumDescriptor.cs @@ -38,14 +38,16 @@ namespace Google.Protobuf.Descriptors /// /// Descriptor for an enum type in a .proto file. /// - public sealed class EnumDescriptor : IndexedDescriptorBase + public sealed class EnumDescriptor : DescriptorBase { + private readonly EnumDescriptorProto proto; private readonly MessageDescriptor containingType; private readonly IList values; internal EnumDescriptor(EnumDescriptorProto proto, FileDescriptor file, MessageDescriptor parent, int index) - : base(proto, file, ComputeFullName(file, parent, proto.Name), index) + : base(file, file.ComputeFullName(parent, proto.Name), index) { + this.proto = proto; containingType = parent; if (proto.Value.Count == 0) @@ -61,6 +63,13 @@ namespace Google.Protobuf.Descriptors File.DescriptorPool.AddSymbol(this); } + internal EnumDescriptorProto Proto { get { return proto; } } + + /// + /// The brief name of the descriptor's target. + /// + public override string Name { get { return proto.Name; } } + /// /// If this is a nested type, get the outer descriptor, otherwise null. /// @@ -95,14 +104,5 @@ namespace Google.Protobuf.Descriptors { return File.DescriptorPool.FindSymbol(FullName + "." + name); } - - internal override void ReplaceProto(EnumDescriptorProto newProto) - { - base.ReplaceProto(newProto); - for (int i = 0; i < values.Count; i++) - { - values[i].ReplaceProto(newProto.Value[i]); - } - } } } \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/Descriptors/EnumValueDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/EnumValueDescriptor.cs index b553ee55..e609b1f8 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/EnumValueDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/EnumValueDescriptor.cs @@ -37,27 +37,27 @@ namespace Google.Protobuf.Descriptors /// /// Descriptor for a single enum value within an enum in a .proto file. /// - public sealed class EnumValueDescriptor : IndexedDescriptorBase + public sealed class EnumValueDescriptor : DescriptorBase { private readonly EnumDescriptor enumDescriptor; + private readonly EnumValueDescriptorProto proto; internal EnumValueDescriptor(EnumValueDescriptorProto proto, FileDescriptor file, EnumDescriptor parent, int index) - : base(proto, file, parent.FullName + "." + proto.Name, index) + : base(file, parent.FullName + "." + proto.Name, index) { + this.proto = proto; enumDescriptor = parent; file.DescriptorPool.AddSymbol(this); file.DescriptorPool.AddEnumValueByNumber(this); } - public int Number - { - get { return Proto.Number; } - } + internal EnumValueDescriptorProto Proto { get { return proto; } } + + public override string Name { get { return proto.Name; } } - public EnumDescriptor EnumDescriptor - { - get { return enumDescriptor; } - } + public int Number { get { return Proto.Number; } } + + public EnumDescriptor EnumDescriptor { get { return enumDescriptor; } } } } \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs index 3b36a280..7af69bbb 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs @@ -38,21 +38,20 @@ namespace Google.Protobuf.Descriptors /// /// Descriptor for a field or extension within a message in a .proto file. /// - public sealed class FieldDescriptor : IndexedDescriptorBase, - IComparable + public sealed class FieldDescriptor : DescriptorBase, IComparable { + private readonly FieldDescriptorProto proto; private EnumDescriptor enumType; private MessageDescriptor messageType; - private MessageDescriptor containingType; - private OneofDescriptor containingOneof; + private readonly MessageDescriptor containingType; + private readonly OneofDescriptor containingOneof; private FieldType fieldType; - private readonly object optionsLock = new object(); - internal FieldDescriptor(FieldDescriptorProto proto, FileDescriptor file, MessageDescriptor parent, int index) - : base(proto, file, ComputeFullName(file, parent, proto.Name), index) + : base(file, file.ComputeFullName(parent, proto.Name), index) { + this.proto = proto; if (proto.Type != 0) { fieldType = GetFieldTypeFromProtoType(proto.Type); @@ -64,7 +63,8 @@ namespace Google.Protobuf.Descriptors "Field numbers must be positive integers."); } containingType = parent; - if (proto.OneofIndex != 0) + // OneofIndex "defaults" to -1 due to a hack in FieldDescriptor.OnConstruction. + if (proto.OneofIndex != -1) { if (proto.OneofIndex < 0 || proto.OneofIndex >= parent.Proto.OneofDecl.Count) { @@ -72,12 +72,18 @@ namespace Google.Protobuf.Descriptors "FieldDescriptorProto.oneof_index is out of range for type " + parent.Name); } containingOneof = parent.Oneofs[proto.OneofIndex]; - containingOneof.fieldCount ++; } file.DescriptorPool.AddSymbol(this); } + /// + /// The brief name of the descriptor's target. + /// + public override string Name { get { return proto.Name; } } + + internal FieldDescriptorProto Proto { get { return proto; } } + /// /// Maps a field type as included in the .proto file to a FieldType. /// @@ -133,12 +139,12 @@ namespace Google.Protobuf.Descriptors public bool IsMap { - get { return fieldType == FieldType.Message && messageType.Options != null && messageType.Options.MapEntry; } + get { return fieldType == FieldType.Message && messageType.Proto.Options != null && messageType.Proto.Options.MapEntry; } } public bool IsPacked { - get { return Proto.Options.Packed; } + get { return Proto.Options != null && Proto.Options.Packed; } } /// @@ -278,7 +284,7 @@ namespace Google.Protobuf.Descriptors File.DescriptorPool.AddFieldByNumber(this); - if (containingType != null && containingType.Options != null && containingType.Options.MessageSetWireFormat) + if (containingType != null && containingType.Proto.Options != null && containingType.Proto.Options.MessageSetWireFormat) { throw new DescriptorValidationException(this, "MessageSet format is not supported."); } diff --git a/csharp/src/ProtocolBuffers/Descriptors/FileDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/FileDescriptor.cs index a6320a31..9d0bdfd3 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/FileDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/FileDescriptor.cs @@ -43,7 +43,7 @@ namespace Google.Protobuf.Descriptors /// IDescriptor is implemented such that the File property returns this descriptor, /// and the FullName is the same as the Name. /// - public sealed class FileDescriptor : IDescriptor + public sealed class FileDescriptor : IDescriptor { private readonly FileDescriptorProto proto; private readonly IList messageTypes; @@ -87,6 +87,22 @@ namespace Google.Protobuf.Descriptors new ServiceDescriptor(service, this, index)); } + /// + /// Computes the full name of a descriptor within this file, with an optional parent message. + /// + internal string ComputeFullName(MessageDescriptor parent, string name) + { + if (parent != null) + { + return parent.FullName + "." + name; + } + if (Package.Length > 0) + { + return Package + "." + name; + } + return name; + } + /// /// Extracts public dependencies from direct dependencies. This is a static method despite its /// first parameter, as the value we're in the middle of constructing is only used for exceptions. @@ -127,19 +143,11 @@ namespace Google.Protobuf.Descriptors /// /// The descriptor in its protocol message representation. /// - public FileDescriptorProto Proto + internal FileDescriptorProto Proto { get { return proto; } } - /// - /// The defined in descriptor.proto. - /// - public FileOptions Options - { - get { return proto.Options; } - } - /// /// The file name. /// @@ -213,14 +221,6 @@ namespace Google.Protobuf.Descriptors get { return this; } } - /// - /// Protocol buffer describing this descriptor. - /// - IMessage IDescriptor.Proto - { - get { return Proto; } - } - /// /// Pool containing symbol descriptors. /// @@ -255,22 +255,7 @@ namespace Google.Protobuf.Descriptors } return null; } - - /// - /// Builds a FileDescriptor from its protocol buffer representation. - /// - /// The protocol message form of the FileDescriptor. - /// FileDescriptors corresponding to all of the - /// file's dependencies, in the exact order listed in the .proto file. May be null, - /// in which case it is treated as an empty array. - /// If is not - /// a valid descriptor. This can occur for a number of reasons, such as a field - /// having an undefined type or because two messages were defined with the same name. - public static FileDescriptor BuildFrom(FileDescriptorProto proto, FileDescriptor[] dependencies) - { - return BuildFrom(proto, dependencies, false); - } - + /// /// Builds a FileDescriptor from its protocol buffer representation. /// diff --git a/csharp/src/ProtocolBuffers/Descriptors/IDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/IDescriptor.cs index 2c2db127..92c6d463 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/IDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/IDescriptor.cs @@ -33,23 +33,12 @@ namespace Google.Protobuf.Descriptors { /// - /// The non-generic form of the IDescriptor interface. Useful for describing a general - /// descriptor. + /// Interface implemented by all descriptor types. /// public interface IDescriptor { string Name { get; } string FullName { get; } FileDescriptor File { get; } - IMessage Proto { get; } - } - - /// - /// Strongly-typed form of the IDescriptor interface. - /// - /// Protocol buffer type underlying this descriptor type - internal interface IDescriptor : IDescriptor where TProto : IMessage - { - new TProto Proto { get; } - } + } } \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/Descriptors/IndexedDescriptorBase.cs b/csharp/src/ProtocolBuffers/Descriptors/IndexedDescriptorBase.cs deleted file mode 100644 index 6c515726..00000000 --- a/csharp/src/ProtocolBuffers/Descriptors/IndexedDescriptorBase.cs +++ /dev/null @@ -1,65 +0,0 @@ -#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 Google.Protobuf.DescriptorProtos; - -namespace Google.Protobuf.Descriptors -{ - /// - /// Base class for descriptors which are also indexed. This is all of them other than - /// . - /// - public abstract class IndexedDescriptorBase : DescriptorBase - where TProto : IMessage, IDescriptorProto - { - private readonly int index; - - protected IndexedDescriptorBase(TProto proto, FileDescriptor file, string fullName, int index) - : base(proto, file, fullName) - { - this.index = index; - } - - /// - /// The index of this descriptor within its parent descriptor. - /// - /// - /// This returns the index of this descriptor within its parent, for - /// this descriptor's type. (There can be duplicate values for different - /// types, e.g. one enum type with index 0 and one message type with index 0.) - /// - public int Index - { - get { return index; } - } - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/Descriptors/MessageDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/MessageDescriptor.cs index cbf4c0f2..e65e8bb0 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/MessageDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/MessageDescriptor.cs @@ -39,8 +39,9 @@ namespace Google.Protobuf.Descriptors /// /// Describes a message type. /// - public sealed class MessageDescriptor : IndexedDescriptorBase + public sealed class MessageDescriptor : DescriptorBase { + private readonly DescriptorProto proto; private readonly MessageDescriptor containingType; private readonly IList nestedTypes; private readonly IList enumTypes; @@ -48,8 +49,9 @@ namespace Google.Protobuf.Descriptors private readonly IList oneofs; internal MessageDescriptor(DescriptorProto proto, FileDescriptor file, MessageDescriptor parent, int typeIndex) - : base(proto, file, ComputeFullName(file, parent, proto.Name), typeIndex) + : base(file, file.ComputeFullName(parent, proto.Name), typeIndex) { + this.proto = proto; containingType = parent; oneofs = DescriptorUtil.ConvertAndMakeReadOnly(proto.OneofDecl, @@ -68,23 +70,16 @@ namespace Google.Protobuf.Descriptors fields = DescriptorUtil.ConvertAndMakeReadOnly(proto.Field, (field, index) => new FieldDescriptor(field, file, this, index)); - - for (int i = 0; i < proto.OneofDecl.Count; i++) - { - oneofs[i].fields = new FieldDescriptor[oneofs[i].FieldCount]; - oneofs[i].fieldCount = 0; - } - for (int i = 0; i< proto.Field.Count; i++) - { - OneofDescriptor oneofDescriptor = fields[i].ContainingOneof; - if (oneofDescriptor != null) - { - oneofDescriptor.fields[oneofDescriptor.fieldCount++] = fields[i]; - } - } file.DescriptorPool.AddSymbol(this); } + /// + /// The brief name of the descriptor's target. + /// + public override string Name { get { return proto.Name; } } + + internal DescriptorProto Proto { get { return proto; } } + /// /// If this is a nested type, get the outer descriptor, otherwise null. /// @@ -144,7 +139,7 @@ namespace Google.Protobuf.Descriptors /// /// Finds a nested descriptor by name. The is valid for fields, nested - /// message types and enums. + /// message types, oneofs and enums. /// /// The unqualified name of the descriptor, e.g. "Foo" /// The descriptor, or null if not found. @@ -171,32 +166,8 @@ namespace Google.Protobuf.Descriptors foreach (OneofDescriptor oneof in oneofs) { - // TODO(jonskeet): Do we need to do this? - // oneof.C - } - } - - /// - /// See FileDescriptor.ReplaceProto - /// - internal override void ReplaceProto(DescriptorProto newProto) - { - base.ReplaceProto(newProto); - - for (int i = 0; i < nestedTypes.Count; i++) - { - nestedTypes[i].ReplaceProto(newProto.NestedType[i]); - } - - for (int i = 0; i < enumTypes.Count; i++) - { - enumTypes[i].ReplaceProto(newProto.EnumType[i]); - } - - for (int i = 0; i < fields.Count; i++) - { - fields[i].ReplaceProto(newProto.Field[i]); + oneof.CrossLink(); } - } + } } } \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/Descriptors/MethodDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/MethodDescriptor.cs index 6a4ad4ea..7d4a6f4f 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/MethodDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/MethodDescriptor.cs @@ -37,8 +37,9 @@ namespace Google.Protobuf.Descriptors /// /// Describes a single method in a service. /// - public sealed class MethodDescriptor : IndexedDescriptorBase + public sealed class MethodDescriptor : DescriptorBase { + private readonly MethodDescriptorProto proto; private readonly ServiceDescriptor service; private MessageDescriptor inputType; private MessageDescriptor outputType; @@ -46,35 +47,34 @@ namespace Google.Protobuf.Descriptors /// /// The service this method belongs to. /// - public ServiceDescriptor Service - { - get { return service; } - } + public ServiceDescriptor Service { get { return service; } } /// /// The method's input type. /// - public MessageDescriptor InputType - { - get { return inputType; } - } + public MessageDescriptor InputType { get { return inputType; } } /// /// The method's input type. /// - public MessageDescriptor OutputType - { - get { return outputType; } - } + public MessageDescriptor OutputType { get { return outputType; } } internal MethodDescriptor(MethodDescriptorProto proto, FileDescriptor file, ServiceDescriptor parent, int index) - : base(proto, file, parent.FullName + "." + proto.Name, index) + : base(file, parent.FullName + "." + proto.Name, index) { + this.proto = proto; service = parent; file.DescriptorPool.AddSymbol(this); } + internal MethodDescriptorProto Proto { get { return proto; } } + + /// + /// The brief name of the descriptor's target. + /// + public override string Name { get { return proto.Name; } } + internal void CrossLink() { IDescriptor lookup = File.DescriptorPool.LookupSymbol(Proto.InputType, this); diff --git a/csharp/src/ProtocolBuffers/Descriptors/OneofDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/OneofDescriptor.cs index ab3b76ec..8418948f 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/OneofDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/OneofDescriptor.cs @@ -31,48 +31,49 @@ #endregion using System.Collections.Generic; +using System.Collections.ObjectModel; using Google.Protobuf.DescriptorProtos; namespace Google.Protobuf.Descriptors { - public sealed class OneofDescriptor + public sealed class OneofDescriptor : DescriptorBase { - private int index; - private OneofDescriptorProto proto; - private FileDescriptor file; + private readonly OneofDescriptorProto proto; private MessageDescriptor containingType; - internal int fieldCount; - internal IList fields; + private IList fields; - internal OneofDescriptor(OneofDescriptorProto proto, FileDescriptor file, - MessageDescriptor parent, int index) + internal OneofDescriptor(OneofDescriptorProto proto, FileDescriptor file, MessageDescriptor parent, int index) + : base(file, file.ComputeFullName(parent, proto.Name), index) { this.proto = proto; - this.file = file; - this.index = index; - containingType = parent; - fieldCount = 0; - } - public int Index - { - get { return index; } + file.DescriptorPool.AddSymbol(this); } + /// + /// The brief name of the descriptor's target. + /// + public override string Name { get { return proto.Name; } } + public MessageDescriptor ContainingType { get { return containingType; } } - public int FieldCount - { - get { return fieldCount; } - } + public IList Fields { get { return fields; } } - public FieldDescriptor Field(int index) + internal void CrossLink() { - return fields[index]; + List fieldCollection = new List(); + foreach (var field in ContainingType.Fields) + { + if (field.ContainingOneof == this) + { + fieldCollection.Add(field); + } + } + fields = new ReadOnlyCollection(fieldCollection); } } } diff --git a/csharp/src/ProtocolBuffers/Descriptors/PackageDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/PackageDescriptor.cs index 9af677d7..18adc9e3 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/PackageDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/PackageDescriptor.cs @@ -37,7 +37,7 @@ namespace Google.Protobuf.Descriptors /// just as placeholders so that someone cannot define, say, a message type /// that has the same name as an existing package. /// - internal sealed class PackageDescriptor : IDescriptor + internal sealed class PackageDescriptor : IDescriptor { private readonly string name; private readonly string fullName; @@ -50,11 +50,6 @@ namespace Google.Protobuf.Descriptors this.name = name; } - public IMessage Proto - { - get { return file.Proto; } - } - public string Name { get { return name; } diff --git a/csharp/src/ProtocolBuffers/Descriptors/ServiceDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/ServiceDescriptor.cs index ef712b46..2556e272 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/ServiceDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/ServiceDescriptor.cs @@ -39,19 +39,28 @@ namespace Google.Protobuf.Descriptors /// /// Describes a service type. /// - public sealed class ServiceDescriptor : IndexedDescriptorBase + public sealed class ServiceDescriptor : DescriptorBase { + private readonly ServiceDescriptorProto proto; private readonly IList methods; - public ServiceDescriptor(ServiceDescriptorProto proto, FileDescriptor file, int index) - : base(proto, file, ComputeFullName(file, null, proto.Name), index) + internal ServiceDescriptor(ServiceDescriptorProto proto, FileDescriptor file, int index) + : base(file, file.ComputeFullName(null, proto.Name), index) { + this.proto = proto; methods = DescriptorUtil.ConvertAndMakeReadOnly(proto.Method, (method, i) => new MethodDescriptor(method, file, this, i)); file.DescriptorPool.AddSymbol(this); } + /// + /// The brief name of the descriptor's target. + /// + public override string Name { get { return proto.Name; } } + + internal ServiceDescriptorProto Proto { get { return proto; } } + /// /// An unmodifiable list of methods in this service. /// @@ -77,14 +86,5 @@ namespace Google.Protobuf.Descriptors method.CrossLink(); } } - - internal override void ReplaceProto(ServiceDescriptorProto newProto) - { - base.ReplaceProto(newProto); - for (int i = 0; i < methods.Count; i++) - { - methods[i].ReplaceProto(newProto.Method[i]); - } - } } } \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj b/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj index 4078589e..aa4adcc0 100644 --- a/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj +++ b/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj @@ -61,7 +61,6 @@ - @@ -74,7 +73,6 @@ - -- cgit v1.2.3 From 14f2222a50a18ff0d8772095587b9cdad455a7bb Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Fri, 3 Jul 2015 11:41:37 +0100 Subject: Lots more tests for FieldCodec, MapField, RepeatedField ... and some implementation changes to go with them. --- .../Collections/MapFieldTest.cs | 184 +++++++++++++- .../Collections/RepeatedFieldTest.cs | 263 +++++++++++++++++++++ csharp/src/ProtocolBuffers.Test/EqualityTester.cs | 7 +- csharp/src/ProtocolBuffers.Test/FieldCodecTest.cs | 15 ++ csharp/src/ProtocolBuffers/Collections/MapField.cs | 45 +++- .../ProtocolBuffers/Collections/RepeatedField.cs | 12 +- csharp/src/ProtocolBuffers/FieldCodec.cs | 8 +- 7 files changed, 516 insertions(+), 18 deletions(-) diff --git a/csharp/src/ProtocolBuffers.Test/Collections/MapFieldTest.cs b/csharp/src/ProtocolBuffers.Test/Collections/MapFieldTest.cs index 75f8ff2a..d43bed3e 100644 --- a/csharp/src/ProtocolBuffers.Test/Collections/MapFieldTest.cs +++ b/csharp/src/ProtocolBuffers.Test/Collections/MapFieldTest.cs @@ -34,6 +34,8 @@ using System; using System.Collections.Generic; using Google.Protobuf.TestProtos; using NUnit.Framework; +using System.Collections; +using System.Linq; namespace Google.Protobuf.Collections { @@ -53,6 +55,18 @@ namespace Google.Protobuf.Collections Assert.IsTrue(message.IsFrozen); } + [Test] + public void Freeze_Idempotent() + { + var message = new ForeignMessage { C = 20 }; + var map = new MapField { { "x", message } }; + Assert.IsFalse(map.IsFrozen); + map.Freeze(); + Assert.IsTrue(message.IsFrozen); + map.Freeze(); + Assert.IsTrue(message.IsFrozen); + } + [Test] public void Freeze_PreventsMutation() { @@ -187,6 +201,15 @@ namespace Google.Protobuf.Collections EqualityTester.AssertInequality(map1, map2); } + [Test] + public void Equality_Simple() + { + var map = new MapField(); + EqualityTester.AssertEquality(map, map); + EqualityTester.AssertInequality(map, null); + Assert.IsFalse(map.Equals(new object())); + } + [Test] public void EqualityIsValueSensitive() { @@ -287,7 +310,8 @@ namespace Google.Protobuf.Collections Assert.IsFalse(map.Remove("missing")); Assert.AreEqual(1, map.Count); Assert.IsTrue(map.Remove("foo")); - Assert.AreEqual(0, map.Count); + Assert.AreEqual(0, map.Count); + Assert.Throws(() => map.Remove(null)); } [Test] @@ -346,6 +370,164 @@ namespace Google.Protobuf.Collections Assert.AreEqual("z", map["x"]); } + [Test] + public void GetEnumerator_NonGeneric() + { + IEnumerable map = new MapField { { "x", "y" } }; + CollectionAssert.AreEqual(new[] { new KeyValuePair("x", "y") }, + map.Cast().ToList()); + } + + // Test for the explicitly-implemented non-generic IDictionary interface + [Test] + public void IDictionary_GetEnumerator() + { + IDictionary map = new MapField { { "x", "y" } }; + var enumerator = map.GetEnumerator(); + + // Commented assertions show an ideal situation - it looks like + // the LinkedList enumerator doesn't throw when you ask for the current entry + // at an inappropriate time; fixing this would be more work than it's worth. + // Assert.Throws(() => enumerator.Current.GetHashCode()); + Assert.IsTrue(enumerator.MoveNext()); + Assert.AreEqual("x", enumerator.Key); + Assert.AreEqual("y", enumerator.Value); + Assert.AreEqual(new DictionaryEntry("x", "y"), enumerator.Current); + Assert.AreEqual(new DictionaryEntry("x", "y"), enumerator.Entry); + Assert.IsFalse(enumerator.MoveNext()); + // Assert.Throws(() => enumerator.Current.GetHashCode()); + enumerator.Reset(); + // Assert.Throws(() => enumerator.Current.GetHashCode()); + Assert.IsTrue(enumerator.MoveNext()); + Assert.AreEqual("x", enumerator.Key); // Assume the rest are okay + } + + [Test] + public void IDictionary_Add() + { + var map = new MapField { { "x", "y" } }; + IDictionary dictionary = map; + dictionary.Add("a", "b"); + Assert.AreEqual("b", map["a"]); + Assert.Throws(() => dictionary.Add("a", "duplicate")); + Assert.Throws(() => dictionary.Add(new object(), "key is bad")); + Assert.Throws(() => dictionary.Add("value is bad", new object())); + } + + [Test] + public void IDictionary_Contains() + { + var map = new MapField { { "x", "y" } }; + IDictionary dictionary = map; + + Assert.IsFalse(dictionary.Contains("a")); + Assert.IsFalse(dictionary.Contains(5)); + // Surprising, but IDictionary.Contains is only about keys. + Assert.IsFalse(dictionary.Contains(new DictionaryEntry("x", "y"))); + Assert.IsTrue(dictionary.Contains("x")); + } + + [Test] + public void IDictionary_Remove() + { + var map = new MapField { { "x", "y" } }; + IDictionary dictionary = map; + dictionary.Remove("a"); + Assert.AreEqual(1, dictionary.Count); + dictionary.Remove(5); + Assert.AreEqual(1, dictionary.Count); + dictionary.Remove(new DictionaryEntry("x", "y")); + Assert.AreEqual(1, dictionary.Count); + dictionary.Remove("x"); + Assert.AreEqual(0, dictionary.Count); + Assert.Throws(() => dictionary.Remove(null)); + + map.Freeze(); + // Call should fail even though it clearly doesn't contain 5 as a key. + Assert.Throws(() => dictionary.Remove(5)); + } + + [Test] + public void IDictionary_CopyTo() + { + var map = new MapField { { "x", "y" } }; + IDictionary dictionary = map; + var array = new DictionaryEntry[3]; + dictionary.CopyTo(array, 1); + CollectionAssert.AreEqual(new[] { default(DictionaryEntry), new DictionaryEntry("x", "y"), default(DictionaryEntry) }, + array); + var objectArray = new object[3]; + dictionary.CopyTo(objectArray, 1); + CollectionAssert.AreEqual(new object[] { null, new DictionaryEntry("x", "y"), null }, + objectArray); + } + + [Test] + public void IDictionary_IsFixedSize() + { + var map = new MapField { { "x", "y" } }; + IDictionary dictionary = map; + Assert.IsFalse(dictionary.IsFixedSize); + map.Freeze(); + Assert.IsTrue(dictionary.IsFixedSize); + } + + [Test] + public void IDictionary_Keys() + { + IDictionary dictionary = new MapField { { "x", "y" } }; + CollectionAssert.AreEqual(new[] { "x" }, dictionary.Keys); + } + + [Test] + public void IDictionary_Values() + { + IDictionary dictionary = new MapField { { "x", "y" } }; + CollectionAssert.AreEqual(new[] { "y" }, dictionary.Values); + } + + [Test] + public void IDictionary_IsSynchronized() + { + IDictionary dictionary = new MapField { { "x", "y" } }; + Assert.IsFalse(dictionary.IsSynchronized); + } + + [Test] + public void IDictionary_SyncRoot() + { + IDictionary dictionary = new MapField { { "x", "y" } }; + Assert.AreSame(dictionary, dictionary.SyncRoot); + } + + [Test] + public void IDictionary_Indexer_Get() + { + IDictionary dictionary = new MapField { { "x", "y" } }; + Assert.AreEqual("y", dictionary["x"]); + Assert.IsNull(dictionary["a"]); + Assert.IsNull(dictionary[5]); + Assert.Throws(() => dictionary[null].GetHashCode()); + } + + [Test] + public void IDictionary_Indexer_Set() + { + var map = new MapField { { "x", "y" } }; + IDictionary dictionary = map; + map["a"] = "b"; + Assert.AreEqual("b", map["a"]); + map["a"] = "c"; + Assert.AreEqual("c", map["a"]); + Assert.Throws(() => dictionary[5] = "x"); + Assert.Throws(() => dictionary["x"] = 5); + Assert.Throws(() => dictionary[null] = "z"); + Assert.Throws(() => dictionary["x"] = null); + map.Freeze(); + // Note: Not InvalidOperationException. + Assert.Throws(() => dictionary["a"] = "c"); + } + private static KeyValuePair NewKeyValuePair(TKey key, TValue value) { return new KeyValuePair(key, value); diff --git a/csharp/src/ProtocolBuffers.Test/Collections/RepeatedFieldTest.cs b/csharp/src/ProtocolBuffers.Test/Collections/RepeatedFieldTest.cs index 988801b7..6eff8683 100644 --- a/csharp/src/ProtocolBuffers.Test/Collections/RepeatedFieldTest.cs +++ b/csharp/src/ProtocolBuffers.Test/Collections/RepeatedFieldTest.cs @@ -31,9 +31,11 @@ #endregion using System; +using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; +using System.Text; using Google.Protobuf.TestProtos; using NUnit.Framework; @@ -82,6 +84,115 @@ namespace Google.Protobuf.Collections Assert.AreEqual("bar", list[2]); } + [Test] + public void RemoveAt_Valid() + { + var list = new RepeatedField { "first", "second", "third" }; + list.RemoveAt(1); + CollectionAssert.AreEqual(new[] { "first", "third" }, list); + // Just check that these don't throw... + list.RemoveAt(list.Count - 1); // Now the count will be 1... + list.RemoveAt(0); + Assert.AreEqual(0, list.Count); + } + + [Test] + public void RemoveAt_Invalid() + { + var list = new RepeatedField { "first", "second", "third" }; + Assert.Throws(() => list.RemoveAt(-1)); + Assert.Throws(() => list.RemoveAt(3)); + } + + [Test] + public void Insert_Valid() + { + var list = new RepeatedField { "first", "second" }; + list.Insert(1, "middle"); + CollectionAssert.AreEqual(new[] { "first", "middle", "second" }, list); + list.Insert(3, "end"); + CollectionAssert.AreEqual(new[] { "first", "middle", "second", "end" }, list); + list.Insert(0, "start"); + CollectionAssert.AreEqual(new[] { "start", "first", "middle", "second", "end" }, list); + } + + [Test] + public void Insert_Invalid() + { + var list = new RepeatedField { "first", "second" }; + Assert.Throws(() => list.Insert(-1, "foo")); + Assert.Throws(() => list.Insert(3, "foo")); + Assert.Throws(() => list.Insert(0, null)); + } + + [Test] + public void Equals_RepeatedField() + { + var list = new RepeatedField { "first", "second" }; + Assert.IsFalse(list.Equals((RepeatedField) null)); + Assert.IsTrue(list.Equals(list)); + Assert.IsFalse(list.Equals(new RepeatedField { "first", "third" })); + Assert.IsFalse(list.Equals(new RepeatedField { "first" })); + Assert.IsTrue(list.Equals(new RepeatedField { "first", "second" })); + } + + [Test] + public void Equals_Object() + { + var list = new RepeatedField { "first", "second" }; + Assert.IsFalse(list.Equals((object) null)); + Assert.IsTrue(list.Equals((object) list)); + Assert.IsFalse(list.Equals((object) new RepeatedField { "first", "third" })); + Assert.IsFalse(list.Equals((object) new RepeatedField { "first" })); + Assert.IsTrue(list.Equals((object) new RepeatedField { "first", "second" })); + Assert.IsFalse(list.Equals(new object())); + } + + [Test] + public void GetEnumerator_GenericInterface() + { + IEnumerable list = new RepeatedField { "first", "second" }; + // Select gets rid of the optimizations in ToList... + CollectionAssert.AreEqual(new[] { "first", "second" }, list.Select(x => x).ToList()); + } + + [Test] + public void GetEnumerator_NonGenericInterface() + { + IEnumerable list = new RepeatedField { "first", "second" }; + CollectionAssert.AreEqual(new[] { "first", "second" }, list.Cast().ToList()); + } + + [Test] + public void CopyTo() + { + var list = new RepeatedField { "first", "second" }; + string[] stringArray = new string[4]; + list.CopyTo(stringArray, 1); + CollectionAssert.AreEqual(new[] { null, "first", "second", null }, stringArray); + } + + [Test] + public void Indexer_Get() + { + var list = new RepeatedField { "first", "second" }; + Assert.AreEqual("first", list[0]); + Assert.AreEqual("second", list[1]); + Assert.Throws(() => list[-1].GetHashCode()); + Assert.Throws(() => list[2].GetHashCode()); + } + + [Test] + public void Indexer_Set() + { + var list = new RepeatedField { "first", "second" }; + list[0] = "changed"; + Assert.AreEqual("changed", list[0]); + Assert.Throws(() => list[0] = null); + Assert.Throws(() => list[-1] = "bad"); + Assert.Throws(() => list[2] = "bad"); + } + [Test] public void Freeze_FreezesElements() { @@ -124,6 +235,27 @@ namespace Google.Protobuf.Collections clone[0] = 1; } + [Test] + public void Enumerator() + { + var list = new RepeatedField { "first", "second" }; + using (var enumerator = list.GetEnumerator()) + { + Assert.Throws(() => enumerator.Current.GetHashCode()); + Assert.IsTrue(enumerator.MoveNext()); + Assert.AreEqual("first", enumerator.Current); + Assert.IsTrue(enumerator.MoveNext()); + Assert.AreEqual("second", enumerator.Current); + Assert.IsFalse(enumerator.MoveNext()); + Assert.Throws(() => enumerator.Current.GetHashCode()); + Assert.IsFalse(enumerator.MoveNext()); + enumerator.Reset(); + Assert.Throws(() => enumerator.Current.GetHashCode()); + Assert.IsTrue(enumerator.MoveNext()); + Assert.AreEqual("first", enumerator.Current); + } + } + [Test] public void AddEntriesFrom_PackedInt32() { @@ -309,6 +441,42 @@ namespace Google.Protobuf.Collections Assert.IsTrue(input.IsAtEnd); } + [Test] + public void CalculateSize_VariableSizeNonPacked() + { + var list = new RepeatedField { 1, 500, 1 }; + var tag = WireFormat.MakeTag(1, WireFormat.WireType.Varint); + // 2 bytes for the first entry, 3 bytes for the second, 2 bytes for the third + Assert.AreEqual(7, list.CalculateSize(FieldCodec.ForInt32(tag))); + } + + [Test] + public void CalculateSize_FixedSizeNonPacked() + { + var list = new RepeatedField { 1, 500, 1 }; + var tag = WireFormat.MakeTag(1, WireFormat.WireType.Fixed32); + // 5 bytes for the each entry + Assert.AreEqual(15, list.CalculateSize(FieldCodec.ForSFixed32(tag))); + } + + [Test] + public void CalculateSize_VariableSizePacked() + { + var list = new RepeatedField { 1, 500, 1}; + var tag = WireFormat.MakeTag(1, WireFormat.WireType.LengthDelimited); + // 1 byte for the tag, 1 byte for the length, + // 1 byte for the first entry, 2 bytes for the second, 1 byte for the third + Assert.AreEqual(6, list.CalculateSize(FieldCodec.ForInt32(tag))); + } + + [Test] + public void CalculateSize_FixedSizePacked() + { + var list = new RepeatedField { 1, 500, 1 }; + var tag = WireFormat.MakeTag(1, WireFormat.WireType.LengthDelimited); + // 1 byte for the tag, 1 byte for the length, 4 bytes per entry + Assert.AreEqual(14, list.CalculateSize(FieldCodec.ForSFixed32(tag))); + } [Test] public void TestNegativeEnumArray() @@ -378,5 +546,100 @@ namespace Google.Protobuf.Collections Assert.AreEqual(((SampleEnum)(-4)), values[4]); Assert.AreEqual(((SampleEnum)(-5)), values[5]); } + + // Fairly perfunctory tests for the non-generic IList implementation + [Test] + public void IList_Indexer() + { + var field = new RepeatedField { "first", "second" }; + IList list = field; + Assert.AreEqual("first", list[0]); + list[1] = "changed"; + Assert.AreEqual("changed", field[1]); + } + + [Test] + public void IList_Contains() + { + IList list = new RepeatedField { "first", "second" }; + Assert.IsTrue(list.Contains("second")); + Assert.IsFalse(list.Contains("third")); + Assert.IsFalse(list.Contains(new object())); + } + + [Test] + public void IList_Add() + { + IList list = new RepeatedField { "first", "second" }; + list.Add("third"); + CollectionAssert.AreEqual(new[] { "first", "second", "third" }, list); + } + + [Test] + public void IList_Remove() + { + IList list = new RepeatedField { "first", "second" }; + list.Remove("third"); // No-op, no exception + list.Remove(new object()); // No-op, no exception + list.Remove("first"); + CollectionAssert.AreEqual(new[] { "second" }, list); + } + + [Test] + public void IList_IsFixedSize() + { + var field = new RepeatedField { "first", "second" }; + IList list = field; + Assert.IsFalse(list.IsFixedSize); + field.Freeze(); + Assert.IsTrue(list.IsFixedSize); + } + + [Test] + public void IList_IndexOf() + { + IList list = new RepeatedField { "first", "second" }; + Assert.AreEqual(1, list.IndexOf("second")); + Assert.AreEqual(-1, list.IndexOf("third")); + Assert.AreEqual(-1, list.IndexOf(new object())); + } + + [Test] + public void IList_SyncRoot() + { + IList list = new RepeatedField { "first", "second" }; + Assert.AreSame(list, list.SyncRoot); + } + + [Test] + public void IList_CopyTo() + { + IList list = new RepeatedField { "first", "second" }; + string[] stringArray = new string[4]; + list.CopyTo(stringArray, 1); + CollectionAssert.AreEqual(new[] { null, "first", "second", null }, stringArray); + + object[] objectArray = new object[4]; + list.CopyTo(objectArray, 1); + CollectionAssert.AreEqual(new[] { null, "first", "second", null }, objectArray); + + Assert.Throws(() => list.CopyTo(new StringBuilder[4], 1)); + Assert.Throws(() => list.CopyTo(new int[4], 1)); + } + + [Test] + public void IList_IsSynchronized() + { + IList list = new RepeatedField { "first", "second" }; + Assert.IsFalse(list.IsSynchronized); + } + + [Test] + public void IList_Insert() + { + IList list = new RepeatedField { "first", "second" }; + list.Insert(1, "middle"); + CollectionAssert.AreEqual(new[] { "first", "middle", "second" }, list); + } } } diff --git a/csharp/src/ProtocolBuffers.Test/EqualityTester.cs b/csharp/src/ProtocolBuffers.Test/EqualityTester.cs index b372443b..a669baba 100644 --- a/csharp/src/ProtocolBuffers.Test/EqualityTester.cs +++ b/csharp/src/ProtocolBuffers.Test/EqualityTester.cs @@ -45,15 +45,20 @@ namespace Google.Protobuf public static void AssertEquality(T first, T second) where T : IEquatable { Assert.IsTrue(first.Equals(second)); + Assert.IsTrue(first.Equals((object) second)); Assert.AreEqual(first.GetHashCode(), second.GetHashCode()); } public static void AssertInequality(T first, T second) where T : IEquatable { Assert.IsFalse(first.Equals(second)); + Assert.IsFalse(first.Equals((object) second)); // While this isn't a requirement, the chances of this test failing due to // coincidence rather than a bug are very small. - Assert.AreNotEqual(first.GetHashCode(), second.GetHashCode()); + if (first != null && second != null) + { + Assert.AreNotEqual(first.GetHashCode(), second.GetHashCode()); + } } } } diff --git a/csharp/src/ProtocolBuffers.Test/FieldCodecTest.cs b/csharp/src/ProtocolBuffers.Test/FieldCodecTest.cs index a14040d1..c6ed2a21 100644 --- a/csharp/src/ProtocolBuffers.Test/FieldCodecTest.cs +++ b/csharp/src/ProtocolBuffers.Test/FieldCodecTest.cs @@ -86,12 +86,22 @@ namespace Google.Protobuf codec.TestDefaultValue(); } + [Test, TestCaseSource("Codecs")] + public void FixedSize(ICodecTestData codec) + { + codec.TestFixedSize(); + } + + // This is ugly, but it means we can have a non-generic interface. + // It feels like NUnit should support this better, but I don't know + // of any better ways right now. public interface ICodecTestData { void TestRoundTripRaw(); void TestRoundTripWithTag(); void TestCalculateSizeWithTag(); void TestDefaultValue(); + void TestFixedSize(); } public class FieldCodecTestData : ICodecTestData @@ -169,6 +179,11 @@ namespace Google.Protobuf } } + public void TestFixedSize() + { + Assert.AreEqual(name.Contains("Fixed"), codec.FixedSize != 0); + } + public override string ToString() { return name; diff --git a/csharp/src/ProtocolBuffers/Collections/MapField.cs b/csharp/src/ProtocolBuffers/Collections/MapField.cs index 779ff061..0f379eaa 100644 --- a/csharp/src/ProtocolBuffers/Collections/MapField.cs +++ b/csharp/src/ProtocolBuffers/Collections/MapField.cs @@ -367,11 +367,13 @@ namespace Google.Protobuf.Collections IDictionaryEnumerator IDictionary.GetEnumerator() { - throw new NotImplementedException(); + return new DictionaryEnumerator(GetEnumerator()); } void IDictionary.Remove(object key) { + ThrowHelper.ThrowIfNull(key, "key"); + this.CheckMutable(); if (!(key is TKey)) { return; @@ -381,7 +383,9 @@ namespace Google.Protobuf.Collections void ICollection.CopyTo(Array array, int index) { - throw new NotImplementedException(); + // This is ugly and slow as heck, but with any luck it will never be used anyway. + ICollection temp = this.Select(pair => new DictionaryEntry(pair.Key, pair.Value)).ToList(); + temp.CopyTo(array, index); } bool IDictionary.IsFixedSize { get { return IsFrozen; } } @@ -392,12 +396,13 @@ namespace Google.Protobuf.Collections bool ICollection.IsSynchronized { get { return false; } } - object ICollection.SyncRoot { get { return null; } } + object ICollection.SyncRoot { get { return this; } } object IDictionary.this[object key] { get { + ThrowHelper.ThrowIfNull(key, "key"); if (!(key is TKey)) { return null; @@ -407,10 +412,42 @@ namespace Google.Protobuf.Collections return value; } - set { this[(TKey)key] = (TValue)value; } + set + { + if (frozen) + { + throw new NotSupportedException("Dictionary is frozen"); + } + this[(TKey)key] = (TValue)value; + } } #endregion + private class DictionaryEnumerator : IDictionaryEnumerator + { + private readonly IEnumerator> enumerator; + + internal DictionaryEnumerator(IEnumerator> enumerator) + { + this.enumerator = enumerator; + } + + public bool MoveNext() + { + return enumerator.MoveNext(); + } + + public void Reset() + { + enumerator.Reset(); + } + + public object Current { get { return Entry; } } + public DictionaryEntry Entry { get { return new DictionaryEntry(Key, Value); } } + public object Key { get { return enumerator.Current.Key; } } + public object Value { get { return enumerator.Current.Value; } } + } + /// /// A codec for a specific map field. This contains all the information required to encoded and /// decode the nested messages. diff --git a/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs b/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs index ebc711de..b6b52cb9 100644 --- a/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs +++ b/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs @@ -376,6 +376,7 @@ namespace Google.Protobuf.Collections this.CheckMutable(); EnsureSize(count + 1); Array.Copy(array, index, array, index + 1, count - index); + array[index] = item; count++; } @@ -421,18 +422,12 @@ namespace Google.Protobuf.Collections void ICollection.CopyTo(Array array, int index) { - ThrowHelper.ThrowIfNull(array, "array"); - T[] strongArray = array as T[]; - if (strongArray == null) - { - throw new ArgumentException("Array is of incorrect type", "array"); - } - CopyTo(strongArray, index); + Array.Copy(this.array, 0, array, index, count); } bool ICollection.IsSynchronized { get { return false; } } - object ICollection.SyncRoot { get { return null; } } + object ICollection.SyncRoot { get { return this; } } object IList.this[int index] { @@ -490,6 +485,7 @@ namespace Google.Protobuf.Collections { if (index + 1 >= field.Count) { + index = field.Count; return false; } index++; diff --git a/csharp/src/ProtocolBuffers/FieldCodec.cs b/csharp/src/ProtocolBuffers/FieldCodec.cs index 2cebc1bb..c72a3e7b 100644 --- a/csharp/src/ProtocolBuffers/FieldCodec.cs +++ b/csharp/src/ProtocolBuffers/FieldCodec.cs @@ -68,12 +68,12 @@ namespace Google.Protobuf public static FieldCodec ForFixed32(uint tag) { - return new FieldCodec(input => input.ReadFixed32(), (output, value) => output.WriteFixed32(value), CodedOutputStream.ComputeFixed32Size, tag); + return new FieldCodec(input => input.ReadFixed32(), (output, value) => output.WriteFixed32(value), 4, tag); } public static FieldCodec ForSFixed32(uint tag) { - return new FieldCodec(input => input.ReadSFixed32(), (output, value) => output.WriteSFixed32(value), CodedOutputStream.ComputeSFixed32Size, tag); + return new FieldCodec(input => input.ReadSFixed32(), (output, value) => output.WriteSFixed32(value), 4, tag); } public static FieldCodec ForUInt32(uint tag) @@ -93,12 +93,12 @@ namespace Google.Protobuf public static FieldCodec ForFixed64(uint tag) { - return new FieldCodec(input => input.ReadFixed64(), (output, value) => output.WriteFixed64(value), CodedOutputStream.ComputeFixed64Size, tag); + return new FieldCodec(input => input.ReadFixed64(), (output, value) => output.WriteFixed64(value), 8, tag); } public static FieldCodec ForSFixed64(uint tag) { - return new FieldCodec(input => input.ReadSFixed64(), (output, value) => output.WriteSFixed64(value), CodedOutputStream.ComputeSFixed64Size, tag); + return new FieldCodec(input => input.ReadSFixed64(), (output, value) => output.WriteSFixed64(value), 8, tag); } public static FieldCodec ForUInt64(uint tag) -- cgit v1.2.3 From 0da4a89c971b51f814f9dbe76a1dca47f5b440b4 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Thu, 9 Jul 2015 08:16:21 +0100 Subject: Knock-on effects of moving GetSampleMessage. --- csharp/src/ProtocolBuffers.Test/GeneratedMessageTest.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/csharp/src/ProtocolBuffers.Test/GeneratedMessageTest.cs b/csharp/src/ProtocolBuffers.Test/GeneratedMessageTest.cs index 8c9e0514..8cee9820 100644 --- a/csharp/src/ProtocolBuffers.Test/GeneratedMessageTest.cs +++ b/csharp/src/ProtocolBuffers.Test/GeneratedMessageTest.cs @@ -603,7 +603,7 @@ namespace Google.Protobuf [Test] public void Reflection_GetValue() { - var message = GetSampleMessage(); + var message = SampleMessages.CreateFullTestAllTypes(); var fields = message.Fields; Assert.AreEqual(message.SingleBool, fields[TestAllTypes.SingleBoolFieldNumber].GetValue(message)); Assert.AreEqual(message.SingleBytes, fields[TestAllTypes.SingleBytesFieldNumber].GetValue(message)); @@ -647,7 +647,7 @@ namespace Google.Protobuf [Test] public void Reflection_Clear() { - var message = GetSampleMessage(); + var message = SampleMessages.CreateFullTestAllTypes(); var fields = message.Fields; fields[TestAllTypes.SingleBoolFieldNumber].Clear(message); fields[TestAllTypes.SingleInt32FieldNumber].Clear(message); @@ -657,7 +657,7 @@ namespace Google.Protobuf fields[TestAllTypes.SingleForeignMessageFieldNumber].Clear(message); fields[TestAllTypes.RepeatedDoubleFieldNumber].Clear(message); - var expected = new TestAllTypes(GetSampleMessage()) + var expected = new TestAllTypes(SampleMessages.CreateFullTestAllTypes()) { SingleBool = false, SingleInt32 = 0, @@ -680,7 +680,7 @@ namespace Google.Protobuf public void Reflection_SetValue_SingleFields() { // Just a sample (primitives, messages, enums, strings, byte strings) - var message = GetSampleMessage(); + var message = SampleMessages.CreateFullTestAllTypes(); var fields = message.Fields; fields[TestAllTypes.SingleBoolFieldNumber].SetValue(message, false); fields[TestAllTypes.SingleInt32FieldNumber].SetValue(message, 500); @@ -690,7 +690,7 @@ namespace Google.Protobuf fields[TestAllTypes.SingleForeignMessageFieldNumber].SetValue(message, new ForeignMessage { C = 12345 }); fields[TestAllTypes.SingleDoubleFieldNumber].SetValue(message, 20150701.5); - var expected = new TestAllTypes(GetSampleMessage()) + var expected = new TestAllTypes(SampleMessages.CreateFullTestAllTypes()) { SingleBool = false, SingleInt32 = 500, @@ -707,7 +707,7 @@ namespace Google.Protobuf [Test] public void Reflection_SetValue_SingleFields_WrongType() { - var message = GetSampleMessage(); + var message = SampleMessages.CreateFullTestAllTypes(); var fields = message.Fields; Assert.Throws(() => fields[TestAllTypes.SingleBoolFieldNumber].SetValue(message, "This isn't a bool")); } @@ -723,7 +723,7 @@ namespace Google.Protobuf [Test] public void Reflection_SetValue_RepeatedFields() { - var message = GetSampleMessage(); + var message = SampleMessages.CreateFullTestAllTypes(); var fields = message.Fields; Assert.Throws(() => fields[TestAllTypes.RepeatedDoubleFieldNumber].SetValue(message, new double[10])); } @@ -731,7 +731,7 @@ namespace Google.Protobuf [Test] public void Reflection_GetValue_IncorrectType() { - var message = GetSampleMessage(); + var message = SampleMessages.CreateFullTestAllTypes(); Assert.Throws(() => message.Fields[TestAllTypes.SingleBoolFieldNumber].GetValue(new TestMap())); } } -- cgit v1.2.3 From f8c151f21e821371c55d1cd02b89ac1b8f50460f Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Fri, 3 Jul 2015 11:56:29 +0100 Subject: Initial implementation of JSON formatting - No parsing - Reflection based, so not hugely efficient - No line breaks or indentation --- .../src/ProtocolBuffers.Test/JsonFormatterTest.cs | 217 +++++++++ .../ProtocolBuffers.Test.csproj | 1 + .../ProtocolBuffers/Descriptors/EnumDescriptor.cs | 1 + .../ProtocolBuffers/FieldAccess/IFieldAccessor.cs | 2 + csharp/src/ProtocolBuffers/IMessage.cs | 6 +- csharp/src/ProtocolBuffers/JsonFormatter.cs | 521 +++++++++++++++++++++ csharp/src/ProtocolBuffers/ProtocolBuffers.csproj | 1 + 7 files changed, 746 insertions(+), 3 deletions(-) create mode 100644 csharp/src/ProtocolBuffers.Test/JsonFormatterTest.cs create mode 100644 csharp/src/ProtocolBuffers/JsonFormatter.cs diff --git a/csharp/src/ProtocolBuffers.Test/JsonFormatterTest.cs b/csharp/src/ProtocolBuffers.Test/JsonFormatterTest.cs new file mode 100644 index 00000000..5f80a499 --- /dev/null +++ b/csharp/src/ProtocolBuffers.Test/JsonFormatterTest.cs @@ -0,0 +1,217 @@ +#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; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Google.Protobuf.TestProtos; +using NUnit.Framework; + +namespace Google.Protobuf +{ + public class JsonFormatterTest + { + [Test] + public void DefaultValues_WhenOmitted() + { + var formatter = new JsonFormatter(new JsonFormatter.Settings(formatDefaultValues: false)); + + Assert.AreEqual("{ }", formatter.Format(new ForeignMessage())); + Assert.AreEqual("{ }", formatter.Format(new TestAllTypes())); + Assert.AreEqual("{ }", formatter.Format(new TestMap())); + } + + [Test] + public void DefaultValues_WhenIncluded() + { + var formatter = new JsonFormatter(new JsonFormatter.Settings(formatDefaultValues: true)); + Assert.AreEqual("{ \"c\": 0 }", formatter.Format(new ForeignMessage())); + } + + [Test] + public void AllSingleFields() + { + var message = new TestAllTypes + { + SingleBool = true, + SingleBytes = ByteString.CopyFrom(1, 2, 3, 4), + SingleDouble = 23.5, + SingleFixed32 = 23, + SingleFixed64 = 1234567890123, + SingleFloat = 12.25f, + SingleForeignEnum = ForeignEnum.FOREIGN_BAR, + SingleForeignMessage = new ForeignMessage { C = 10 }, + SingleImportEnum = ImportEnum.IMPORT_BAZ, + SingleImportMessage = new ImportMessage { D = 20 }, + SingleInt32 = 100, + SingleInt64 = 3210987654321, + SingleNestedEnum = TestAllTypes.Types.NestedEnum.FOO, + SingleNestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 35 }, + SinglePublicImportMessage = new PublicImportMessage { E = 54 }, + SingleSfixed32 = -123, + SingleSfixed64 = -12345678901234, + SingleSint32 = -456, + SingleSint64 = -12345678901235, + SingleString = "test\twith\ttabs", + SingleUint32 = uint.MaxValue, + SingleUint64 = ulong.MaxValue, + }; + var actualText = JsonFormatter.Default.Format(message); + + // Fields in declaration order, which matches numeric order. + var expectedText = "{ " + + "\"singleInt32\": 100, " + + "\"singleInt64\": \"3210987654321\", " + + "\"singleUint32\": 4294967295, " + + "\"singleUint64\": \"18446744073709551615\", " + + "\"singleSint32\": -456, " + + "\"singleSint64\": \"-12345678901235\", " + + "\"singleFixed32\": 23, " + + "\"singleFixed64\": \"1234567890123\", " + + "\"singleSfixed32\": -123, " + + "\"singleSfixed64\": \"-12345678901234\", " + + "\"singleFloat\": 12.25, " + + "\"singleDouble\": 23.5, " + + "\"singleBool\": true, " + + "\"singleString\": \"test\\twith\\ttabs\", " + + "\"singleBytes\": \"AQIDBA==\", " + + "\"singleNestedMessage\": { \"bb\": 35 }, " + + "\"singleForeignMessage\": { \"c\": 10 }, " + + "\"singleImportMessage\": { \"d\": 20 }, " + + "\"singleNestedEnum\": \"FOO\", " + + "\"singleForeignEnum\": \"FOREIGN_BAR\", " + + "\"singleImportEnum\": \"IMPORT_BAZ\", " + + "\"singlePublicImportMessage\": { \"e\": 54 }" + + " }"; + Assert.AreEqual(expectedText, actualText); + } + + [Test] + public void RepeatedField() + { + Assert.AreEqual("{ \"repeatedInt32\": [ 1, 2, 3, 4, 5 ] }", + JsonFormatter.Default.Format(new TestAllTypes { RepeatedInt32 = { 1, 2, 3, 4, 5 } })); + } + + [Test] + public void MapField_StringString() + { + Assert.AreEqual("{ \"mapStringString\": { \"with spaces\": \"bar\", \"a\": \"b\" } }", + JsonFormatter.Default.Format(new TestMap { MapStringString = { { "with spaces", "bar" }, { "a", "b" } } })); + } + + [Test] + public void MapField_Int32Int32() + { + // The keys are quoted, but the values aren't. + Assert.AreEqual("{ \"mapInt32Int32\": { \"0\": 1, \"2\": 3 } }", + JsonFormatter.Default.Format(new TestMap { MapInt32Int32 = { { 0, 1 }, { 2, 3 } } })); + } + + [Test] + public void MapField_BoolBool() + { + // The keys are quoted, but the values aren't. + Assert.AreEqual("{ \"mapBoolBool\": { \"false\": true, \"true\": false } }", + JsonFormatter.Default.Format(new TestMap { MapBoolBool = { { false, true }, { true, false } } })); + } + + [TestCase(1.0, "1")] + [TestCase(double.NaN, "\"NaN\"")] + [TestCase(double.PositiveInfinity, "\"Infinity\"")] + [TestCase(double.NegativeInfinity, "\"-Infinity\"")] + public void DoubleRepresentations(double value, string expectedValueText) + { + var message = new TestAllTypes { SingleDouble = value }; + string actualText = JsonFormatter.Default.Format(message); + string expectedText = "{ \"singleDouble\": " + expectedValueText + " }"; + Assert.AreEqual(expectedText, actualText); + } + + [Test] + public void UnknownEnumValue() + { + var message = new TestAllTypes { SingleForeignEnum = (ForeignEnum) 100 }; + Assert.AreEqual("{ \"singleForeignEnum\": 100 }", JsonFormatter.Default.Format(message)); + } + + [Test] + public void NullValueForMessage() + { + var message = new TestMap { MapInt32ForeignMessage = { { 10, null } } }; + Assert.AreEqual("{ \"mapInt32ForeignMessage\": { \"10\": null } }", JsonFormatter.Default.Format(message)); + } + + [Test] + [TestCase("a\u17b4b", "a\\u17b4b")] // Explicit + [TestCase("a\u0601b", "a\\u0601b")] // Ranged + [TestCase("a\u0605b", "a\u0605b")] // Passthrough (note lack of double backslash...) + public void SimpleNonAscii(string text, string encoded) + { + var message = new TestAllTypes { SingleString = text }; + Assert.AreEqual("{ \"singleString\": \"" + encoded + "\" }", JsonFormatter.Default.Format(message)); + } + + [Test] + public void SurrogatePairEscaping() + { + var message = new TestAllTypes { SingleString = "a\uD801\uDC01b" }; + Assert.AreEqual("{ \"singleString\": \"a\\ud801\\udc01b\" }", JsonFormatter.Default.Format(message)); + } + + [Test] + public void InvalidSurrogatePairsFail() + { + // Note: don't use TestCase for these, as the strings can't be reliably represented + // See http://codeblog.jonskeet.uk/2014/11/07/when-is-a-string-not-a-string/ + + // Lone low surrogate + var message = new TestAllTypes { SingleString = "a\uDC01b" }; + Assert.Throws(() => JsonFormatter.Default.Format(message)); + + // Lone high surrogate + message = new TestAllTypes { SingleString = "a\uD801b" }; + Assert.Throws(() => JsonFormatter.Default.Format(message)); + } + + [Test] + [TestCase("foo_bar", "fooBar")] + [TestCase("bananaBanana", "bananaBanana")] + [TestCase("BANANABanana", "bananaBanana")] + public void ToCamelCase(string original, string expected) + { + Assert.AreEqual(expected, JsonFormatter.ToCamelCase(original)); + } + } +} diff --git a/csharp/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj b/csharp/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj index b02abe70..269961c7 100644 --- a/csharp/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj +++ b/csharp/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj @@ -80,6 +80,7 @@ + diff --git a/csharp/src/ProtocolBuffers/Descriptors/EnumDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/EnumDescriptor.cs index a6db5268..57860e61 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/EnumDescriptor.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/EnumDescriptor.cs @@ -89,6 +89,7 @@ namespace Google.Protobuf.Descriptors /// /// Finds an enum value by number. If multiple enum values have the /// same number, this returns the first defined value with that number. + /// If there is no value for the given number, this returns null. /// public EnumValueDescriptor FindValueByNumber(int number) { diff --git a/csharp/src/ProtocolBuffers/FieldAccess/IFieldAccessor.cs b/csharp/src/ProtocolBuffers/FieldAccess/IFieldAccessor.cs index 77e7146d..d1727cb4 100644 --- a/csharp/src/ProtocolBuffers/FieldAccess/IFieldAccessor.cs +++ b/csharp/src/ProtocolBuffers/FieldAccess/IFieldAccessor.cs @@ -44,6 +44,8 @@ namespace Google.Protobuf.FieldAccess /// FieldDescriptor Descriptor { get; } + // TODO: Should the argument type for these messages by IReflectedMessage? + /// /// Clears the field in the specified message. (For repeated fields, /// this clears the list.) diff --git a/csharp/src/ProtocolBuffers/IMessage.cs b/csharp/src/ProtocolBuffers/IMessage.cs index ad44668c..3324e9ae 100644 --- a/csharp/src/ProtocolBuffers/IMessage.cs +++ b/csharp/src/ProtocolBuffers/IMessage.cs @@ -40,9 +40,9 @@ namespace Google.Protobuf // TODO(jonskeet): Split these interfaces into separate files when we're happy with them. /// - /// Reflection support for a specific message type. + /// Reflection support for accessing field values. /// - public interface IReflectedMessage + public interface IReflectedMessage : IMessage { FieldAccessorTable Fields { get; } // TODO(jonskeet): Descriptor? Or a single property which has "all you need for reflection"? @@ -81,7 +81,7 @@ namespace Google.Protobuf /// the implementation class. /// /// The message type. - public interface IMessage : IMessage, IEquatable, IDeepCloneable, IFreezable where T : IMessage + public interface IMessage : IReflectedMessage, IEquatable, IDeepCloneable, IFreezable where T : IMessage { /// /// Merges the given message into this one. diff --git a/csharp/src/ProtocolBuffers/JsonFormatter.cs b/csharp/src/ProtocolBuffers/JsonFormatter.cs new file mode 100644 index 00000000..a6aa552f --- /dev/null +++ b/csharp/src/ProtocolBuffers/JsonFormatter.cs @@ -0,0 +1,521 @@ +#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 System; +using System.Collections; +using System.Globalization; +using System.Text; +using Google.Protobuf.Descriptors; +using Google.Protobuf.FieldAccess; + +namespace Google.Protobuf +{ + /// + /// Reflection-based converter from messages to JSON. + /// + /// + /// + /// Instances of this class are thread-safe, with no mutable state. + /// + /// + /// This is a simple start to get JSON formatting working. As it's reflection-based, + /// it's not as quick as baking calls into generated messages - but is a simpler implementation. + /// (This code is generally not heavily optimized.) + /// + /// + public sealed class JsonFormatter + { + private static JsonFormatter defaultInstance = new JsonFormatter(Settings.Default); + + /// + /// Returns a formatter using the default settings. + /// + public static JsonFormatter Default { get { return defaultInstance; } } + + /// + /// The JSON representation of the first 160 characters of Unicode. + /// Empty strings are replaced by the static constructor. + /// + private static readonly string[] CommonRepresentations = { + // C0 (ASCII and derivatives) control characters + "\\u0000", "\\u0001", "\\u0002", "\\u0003", // 0x00 + "\\u0004", "\\u0005", "\\u0006", "\\u0007", + "\\b", "\\t", "\\n", "\\u000b", + "\\f", "\\r", "\\u000e", "\\u000f", + "\\u0010", "\\u0011", "\\u0012", "\\u0013", // 0x10 + "\\u0014", "\\u0015", "\\u0016", "\\u0017", + "\\u0018", "\\u0019", "\\u001a", "\\u001b", + "\\u001c", "\\u001d", "\\u001e", "\\u001f", + // Escaping of " and \ are required by www.json.org string definition. + // Escaping of < and > are required for HTML security. + "", "", "\\\"", "", "", "", "", "", // 0x20 + "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", // 0x30 + "", "", "", "", "\\u003c", "", "\\u003e", "", + "", "", "", "", "", "", "", "", // 0x40 + "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", // 0x50 + "", "", "", "", "\\\\", "", "", "", + "", "", "", "", "", "", "", "", // 0x60 + "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", // 0x70 + "", "", "", "", "", "", "", "\\u007f", + // C1 (ISO 8859 and Unicode) extended control characters + "\\u0080", "\\u0081", "\\u0082", "\\u0083", // 0x80 + "\\u0084", "\\u0085", "\\u0086", "\\u0087", + "\\u0088", "\\u0089", "\\u008a", "\\u008b", + "\\u008c", "\\u008d", "\\u008e", "\\u008f", + "\\u0090", "\\u0091", "\\u0092", "\\u0093", // 0x90 + "\\u0094", "\\u0095", "\\u0096", "\\u0097", + "\\u0098", "\\u0099", "\\u009a", "\\u009b", + "\\u009c", "\\u009d", "\\u009e", "\\u009f" + }; + + static JsonFormatter() + { + for (int i = 0; i < CommonRepresentations.Length; i++) + { + if (CommonRepresentations[i] == "") + { + CommonRepresentations[i] = ((char) i).ToString(); + } + } + } + + private readonly Settings settings; + + public JsonFormatter(Settings settings) + { + this.settings = settings; + } + + public string Format(IReflectedMessage message) + { + ThrowHelper.ThrowIfNull(message, "message"); + StringBuilder builder = new StringBuilder(); + WriteMessage(builder, message); + return builder.ToString(); + } + + private void WriteMessage(StringBuilder builder, IReflectedMessage message) + { + if (message == null) + { + WriteNull(builder); + return; + } + builder.Append("{ "); + var fields = message.Fields; + bool first = true; + foreach (var accessor in fields.Accessors) + { + object value = accessor.GetValue(message); + if (!settings.FormatDefaultValues && IsDefaultValue(accessor, value)) + { + continue; + } + if (!first) + { + builder.Append(", "); + } + WriteString(builder, ToCamelCase(accessor.Descriptor.Name)); + builder.Append(": "); + WriteValue(builder, accessor, value); + first = false; + } + builder.Append(first ? "}" : " }"); + } + + // Converted from src/google/protobuf/util/internal/utility.cc ToCamelCase + internal static string ToCamelCase(string input) + { + bool capitalizeNext = false; + bool wasCap = true; + bool isCap = false; + bool firstWord = true; + StringBuilder result = new StringBuilder(input.Length); + + for (int i = 0; i < input.Length; i++, wasCap = isCap) + { + isCap = char.IsUpper(input[i]); + if (input[i] == '_') + { + capitalizeNext = true; + if (result.Length != 0) + { + firstWord = false; + } + continue; + } + else if (firstWord) + { + // Consider when the current character B is capitalized, + // first word ends when: + // 1) following a lowercase: "...aB..." + // 2) followed by a lowercase: "...ABc..." + if (result.Length != 0 && isCap && + (!wasCap || (i + 1 < input.Length && char.IsLower(input[i + 1])))) + { + firstWord = false; + } + else + { + result.Append(char.ToLowerInvariant(input[i])); + continue; + } + } + else if (capitalizeNext) + { + capitalizeNext = false; + if (char.IsLower(input[i])) + { + result.Append(char.ToUpperInvariant(input[i])); + continue; + } + } + result.Append(input[i]); + } + return result.ToString(); + } + + private static void WriteNull(StringBuilder builder) + { + builder.Append("null"); + } + + private static bool IsDefaultValue(IFieldAccessor accessor, object value) + { + if (accessor.Descriptor.IsMap) + { + IDictionary dictionary = (IDictionary) value; + return dictionary.Count == 0; + } + if (accessor.Descriptor.IsRepeated) + { + IList list = (IList) value; + return list.Count == 0; + } + switch (accessor.Descriptor.FieldType) + { + case FieldType.Bool: + return (bool) value == false; + case FieldType.Bytes: + return (ByteString) value == ByteString.Empty; + case FieldType.String: + return (string) value == ""; + case FieldType.Double: + return (double) value == 0.0; + case FieldType.SInt32: + case FieldType.Int32: + case FieldType.SFixed32: + case FieldType.Enum: + return (int) value == 0; + case FieldType.Fixed32: + case FieldType.UInt32: + return (uint) value == 0; + case FieldType.Fixed64: + case FieldType.UInt64: + return (ulong) value == 0; + case FieldType.SFixed64: + case FieldType.Int64: + case FieldType.SInt64: + return (long) value == 0; + case FieldType.Float: + return (float) value == 0f; + case FieldType.Message: + case FieldType.Group: // Never expect to get this, but... + return value == null; + default: + throw new ArgumentException("Invalid field type"); + } + } + + private void WriteValue(StringBuilder builder, IFieldAccessor accessor, object value) + { + if (accessor.Descriptor.IsMap) + { + WriteDictionary(builder, accessor, (IDictionary) value); + } + else if (accessor.Descriptor.IsRepeated) + { + WriteList(builder, accessor, (IList) value); + } + else + { + WriteSingleValue(builder, accessor.Descriptor, value); + } + } + + private void WriteSingleValue(StringBuilder builder, FieldDescriptor descriptor, object value) + { + switch (descriptor.FieldType) + { + case FieldType.Bool: + builder.Append((bool) value ? "true" : "false"); + break; + case FieldType.Bytes: + // Nothing in Base64 needs escaping + builder.Append('"'); + builder.Append(((ByteString) value).ToBase64()); + builder.Append('"'); + break; + case FieldType.String: + WriteString(builder, (string) value); + break; + case FieldType.Fixed32: + case FieldType.UInt32: + case FieldType.SInt32: + case FieldType.Int32: + case FieldType.SFixed32: + { + IFormattable formattable = (IFormattable) value; + builder.Append(formattable.ToString("d", CultureInfo.InvariantCulture)); + break; + } + case FieldType.Enum: + EnumValueDescriptor enumValue = descriptor.EnumType.FindValueByNumber((int) value); + if (enumValue != null) + { + WriteString(builder, enumValue.Name); + } + else + { + // ??? Need more documentation + builder.Append(((int) value).ToString("d", CultureInfo.InvariantCulture)); + } + break; + case FieldType.Fixed64: + case FieldType.UInt64: + case FieldType.SFixed64: + case FieldType.Int64: + case FieldType.SInt64: + { + builder.Append('"'); + IFormattable formattable = (IFormattable) value; + builder.Append(formattable.ToString("d", CultureInfo.InvariantCulture)); + builder.Append('"'); + break; + } + case FieldType.Double: + case FieldType.Float: + string text = ((IFormattable) value).ToString("r", CultureInfo.InvariantCulture); + if (text == "NaN" || text == "Infinity" || text == "-Infinity") + { + builder.Append('"'); + builder.Append(text); + builder.Append('"'); + } + else + { + builder.Append(text); + } + break; + case FieldType.Message: + case FieldType.Group: // Never expect to get this, but... + WriteMessage(builder, (IReflectedMessage) value); + break; + default: + throw new ArgumentException("Invalid field type: " + descriptor.FieldType); + } + } + + private void WriteList(StringBuilder builder, IFieldAccessor accessor, IList list) + { + builder.Append("[ "); + bool first = true; + foreach (var value in list) + { + if (!first) + { + builder.Append(", "); + } + WriteSingleValue(builder, accessor.Descriptor, value); + first = false; + } + builder.Append(first ? "]" : " ]"); + } + + private void WriteDictionary(StringBuilder builder, IFieldAccessor accessor, IDictionary dictionary) + { + builder.Append("{ "); + bool first = true; + FieldDescriptor keyType = accessor.Descriptor.MessageType.FindFieldByNumber(1); + FieldDescriptor valueType = accessor.Descriptor.MessageType.FindFieldByNumber(2); + // This will box each pair. Could use IDictionaryEnumerator, but that's ugly in terms of disposal. + foreach (DictionaryEntry pair in dictionary) + { + if (!first) + { + builder.Append(", "); + } + string keyText; + switch (keyType.FieldType) + { + case FieldType.String: + keyText = (string) pair.Key; + break; + case FieldType.Bool: + keyText = (bool) pair.Key ? "true" : "false"; + break; + case FieldType.Fixed32: + case FieldType.Fixed64: + case FieldType.SFixed32: + case FieldType.SFixed64: + case FieldType.Int32: + case FieldType.Int64: + case FieldType.SInt32: + case FieldType.SInt64: + case FieldType.UInt32: + case FieldType.UInt64: + keyText = ((IFormattable) pair.Key).ToString("d", CultureInfo.InvariantCulture); + break; + default: + throw new ArgumentException("Invalid key type: " + keyType.FieldType); + } + WriteString(builder, keyText); + builder.Append(": "); + WriteSingleValue(builder, valueType, pair.Value); + first = false; + } + builder.Append(first ? "}" : " }"); + } + + /// + /// Writes a string (including leading and trailing double quotes) to a builder, escaping as required. + /// + /// + /// Other than surrogate pair handling, this code is mostly taken from src/google/protobuf/util/internal/json_escaping.cc. + /// + private void WriteString(StringBuilder builder, string text) + { + builder.Append('"'); + for (int i = 0; i < text.Length; i++) + { + char c = text[i]; + if (c < 0xa0) + { + builder.Append(CommonRepresentations[c]); + continue; + } + if (char.IsHighSurrogate(c)) + { + // Encountered first part of a surrogate pair. + // Check that we have the whole pair, and encode both parts as hex. + i++; + if (i == text.Length || !char.IsLowSurrogate(text[i])) + { + throw new ArgumentException("String contains low surrogate not followed by high surrogate"); + } + HexEncodeUtf16CodeUnit(builder, c); + HexEncodeUtf16CodeUnit(builder, text[i]); + continue; + } + else if (char.IsLowSurrogate(c)) + { + throw new ArgumentException("String contains high surrogate not preceded by low surrogate"); + } + switch ((uint) c) + { + // These are not required by json spec + // but used to prevent security bugs in javascript. + case 0xfeff: // Zero width no-break space + case 0xfff9: // Interlinear annotation anchor + case 0xfffa: // Interlinear annotation separator + case 0xfffb: // Interlinear annotation terminator + + case 0x00ad: // Soft-hyphen + case 0x06dd: // Arabic end of ayah + case 0x070f: // Syriac abbreviation mark + case 0x17b4: // Khmer vowel inherent Aq + case 0x17b5: // Khmer vowel inherent Aa + HexEncodeUtf16CodeUnit(builder, c); + break; + + default: + if ((c >= 0x0600 && c <= 0x0603) || // Arabic signs + (c >= 0x200b && c <= 0x200f) || // Zero width etc. + (c >= 0x2028 && c <= 0x202e) || // Separators etc. + (c >= 0x2060 && c <= 0x2064) || // Invisible etc. + (c >= 0x206a && c <= 0x206f)) + { + HexEncodeUtf16CodeUnit(builder, c); + } + else + { + // No handling of surrogates here - that's done earlier + builder.Append(c); + } + break; + } + } + builder.Append('"'); + } + + private const string Hex = "0123456789abcdef"; + private static void HexEncodeUtf16CodeUnit(StringBuilder builder, char c) + { + uint utf16 = c; + builder.Append("\\u"); + builder.Append(Hex[(c >> 12) & 0xf]); + builder.Append(Hex[(c >> 8) & 0xf]); + builder.Append(Hex[(c >> 4) & 0xf]); + builder.Append(Hex[(c >> 0) & 0xf]); + } + + /// + /// Settings controlling JSON formatting. + /// + public sealed class Settings + { + private static readonly Settings defaultInstance = new Settings(false); + + /// + /// Default settings, as used by + /// + public static Settings Default { get { return defaultInstance; } } + + private readonly bool formatDefaultValues; + + + /// + /// Whether fields whose values are the default for the field type (e.g. 0 for integers) + /// should be formatted (true) or omitted (false). + /// + public bool FormatDefaultValues { get { return formatDefaultValues; } } + + public Settings(bool formatDefaultValues) + { + this.formatDefaultValues = formatDefaultValues; + } + } + } +} diff --git a/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj b/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj index aa4adcc0..17532de8 100644 --- a/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj +++ b/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj @@ -81,6 +81,7 @@ + -- cgit v1.2.3 From 5b9288e47d7add219717d472aa95a5cfe1141ac9 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Fri, 3 Jul 2015 12:45:36 +0100 Subject: Use the new JsonFormatter to implement ToString on generated messages. --- csharp/src/AddressBook/Addressbook.cs | 12 ++ .../TestProtos/MapUnittestProto3.cs | 176 +++++++++++++++++++++ .../TestProtos/UnittestImportProto3.cs | 4 + .../TestProtos/UnittestImportPublicProto3.cs | 4 + .../TestProtos/UnittestIssues.cs | 28 ++++ .../TestProtos/UnittestProto3.cs | 140 ++++++++++++++++ .../DescriptorProtos/DescriptorProtoFile.cs | 88 +++++++++++ .../protobuf/compiler/csharp/csharp_field_base.h | 1 + .../protobuf/compiler/csharp/csharp_map_field.cc | 7 +- .../protobuf/compiler/csharp/csharp_message.cc | 5 +- 10 files changed, 459 insertions(+), 6 deletions(-) diff --git a/csharp/src/AddressBook/Addressbook.cs b/csharp/src/AddressBook/Addressbook.cs index 5f4a5139..b7a08ef0 100644 --- a/csharp/src/AddressBook/Addressbook.cs +++ b/csharp/src/AddressBook/Addressbook.cs @@ -160,6 +160,10 @@ namespace Google.Protobuf.Examples.AddressBook { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Name.Length != 0) { output.WriteRawTag(10); @@ -330,6 +334,10 @@ namespace Google.Protobuf.Examples.AddressBook { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Number.Length != 0) { output.WriteRawTag(10); @@ -463,6 +471,10 @@ namespace Google.Protobuf.Examples.AddressBook { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { person_.WriteTo(output, _repeated_person_codec); } diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/MapUnittestProto3.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/MapUnittestProto3.cs index 55434c53..0e261e1b 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/MapUnittestProto3.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/MapUnittestProto3.cs @@ -602,6 +602,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { mapInt32Int32_.WriteTo(output, _map_mapInt32Int32_codec); mapInt64Int64_.WriteTo(output, _map_mapInt64Int64_codec); @@ -836,6 +840,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Key != 0) { output.WriteRawTag(8); @@ -978,6 +986,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Key != 0L) { output.WriteRawTag(8); @@ -1120,6 +1132,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Key != 0) { output.WriteRawTag(8); @@ -1262,6 +1278,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Key != 0UL) { output.WriteRawTag(8); @@ -1404,6 +1424,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Key != 0) { output.WriteRawTag(8); @@ -1546,6 +1570,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Key != 0L) { output.WriteRawTag(8); @@ -1688,6 +1716,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Key != 0) { output.WriteRawTag(13); @@ -1830,6 +1862,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Key != 0UL) { output.WriteRawTag(9); @@ -1972,6 +2008,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Key != 0) { output.WriteRawTag(13); @@ -2114,6 +2154,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Key != 0L) { output.WriteRawTag(9); @@ -2256,6 +2300,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Key != 0) { output.WriteRawTag(8); @@ -2398,6 +2446,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Key != 0) { output.WriteRawTag(8); @@ -2540,6 +2592,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Key != false) { output.WriteRawTag(8); @@ -2682,6 +2738,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Key.Length != 0) { output.WriteRawTag(10); @@ -2824,6 +2884,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Key != 0) { output.WriteRawTag(8); @@ -2966,6 +3030,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Key != 0) { output.WriteRawTag(8); @@ -3109,6 +3177,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Key != 0) { output.WriteRawTag(8); @@ -3250,6 +3322,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (testMap_ != null) { output.WriteRawTag(10); @@ -3370,6 +3446,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { mapInt32Message_.WriteTo(output, _map_mapInt32Message_codec); } @@ -3493,6 +3573,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Key != 0) { output.WriteRawTag(8); @@ -3644,6 +3728,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { map1_.WriteTo(output, _map_map1_codec); map2_.WriteTo(output, _map_map2_codec); @@ -3773,6 +3861,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Key != 0) { output.WriteRawTag(8); @@ -3915,6 +4007,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Key != 0) { output.WriteRawTag(8); @@ -4216,6 +4312,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { mapInt32Int32_.WriteTo(output, _map_mapInt32Int32_codec); mapInt64Int64_.WriteTo(output, _map_mapInt64Int64_codec); @@ -4436,6 +4536,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Key != 0) { output.WriteRawTag(8); @@ -4578,6 +4682,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Key != 0L) { output.WriteRawTag(8); @@ -4720,6 +4828,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Key != 0) { output.WriteRawTag(8); @@ -4862,6 +4974,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Key != 0UL) { output.WriteRawTag(8); @@ -5004,6 +5120,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Key != 0) { output.WriteRawTag(8); @@ -5146,6 +5266,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Key != 0L) { output.WriteRawTag(8); @@ -5288,6 +5412,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Key != 0) { output.WriteRawTag(13); @@ -5430,6 +5558,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Key != 0UL) { output.WriteRawTag(9); @@ -5572,6 +5704,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Key != 0) { output.WriteRawTag(13); @@ -5714,6 +5850,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Key != 0L) { output.WriteRawTag(9); @@ -5856,6 +5996,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Key != 0) { output.WriteRawTag(8); @@ -5998,6 +6142,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Key != 0) { output.WriteRawTag(8); @@ -6140,6 +6288,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Key != false) { output.WriteRawTag(8); @@ -6282,6 +6434,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Key != 0) { output.WriteRawTag(8); @@ -6425,6 +6581,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Key != 0) { output.WriteRawTag(8); @@ -6564,6 +6724,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { type_.WriteTo(output, _map_type_codec); } @@ -6691,6 +6855,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Key != 0) { output.WriteRawTag(8); @@ -6830,6 +6998,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { entry_.WriteTo(output, _map_entry_codec); } @@ -6952,6 +7124,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Key != 0) { output.WriteRawTag(8); diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportProto3.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportProto3.cs index d30f22db..14c844fe 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportProto3.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportProto3.cs @@ -124,6 +124,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (D != 0) { output.WriteRawTag(8); diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportPublicProto3.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportPublicProto3.cs index 5aa03a64..b8c62bc9 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportPublicProto3.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportPublicProto3.cs @@ -109,6 +109,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (E != 0) { output.WriteRawTag(8); diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs index 0e409c8b..59c551dc 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs @@ -148,6 +148,10 @@ namespace UnitTest.Issues.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { } @@ -237,6 +241,10 @@ namespace UnitTest.Issues.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { } @@ -326,6 +334,10 @@ namespace UnitTest.Issues.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { } @@ -459,6 +471,10 @@ namespace UnitTest.Issues.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Value != global::UnitTest.Issues.TestProtos.NegativeEnum.NEGATIVE_ENUM_ZERO) { output.WriteRawTag(8); @@ -577,6 +593,10 @@ namespace UnitTest.Issues.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { } @@ -746,6 +766,10 @@ namespace UnitTest.Issues.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (PrimitiveValue != 0) { output.WriteRawTag(8); @@ -918,6 +942,10 @@ namespace UnitTest.Issues.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Item != 0) { output.WriteRawTag(8); diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs index d2437bf4..0e63e1d6 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs @@ -1019,6 +1019,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (SingleInt32 != 0) { output.WriteRawTag(8); @@ -1695,6 +1699,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Bb != 0) { output.WriteRawTag(8); @@ -1842,6 +1850,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (child_ != null) { output.WriteRawTag(10); @@ -1991,6 +2003,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (DeprecatedInt32 != 0) { output.WriteRawTag(8); @@ -2106,6 +2122,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (C != 0) { output.WriteRawTag(8); @@ -2208,6 +2228,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { } @@ -2310,6 +2334,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (foreignNested_ != null) { output.WriteRawTag(10); @@ -2444,6 +2472,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (A != 0) { output.WriteRawTag(8); @@ -2587,6 +2619,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (a_ != null) { output.WriteRawTag(10); @@ -2723,6 +2759,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (bb_ != null) { output.WriteRawTag(10); @@ -2858,6 +2898,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (a_ != null) { output.WriteRawTag(10); @@ -3080,6 +3124,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (PrimitiveField != 0) { output.WriteRawTag(8); @@ -3313,6 +3361,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (MyInt != 0L) { output.WriteRawTag(8); @@ -3490,6 +3542,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Bb != 0) { output.WriteRawTag(8); @@ -3624,6 +3680,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (SparseEnum != global::Google.Protobuf.TestProtos.TestSparseEnum.TEST_SPARSE_ENUM_UNSPECIFIED) { output.WriteRawTag(8); @@ -3739,6 +3799,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Data.Length != 0) { output.WriteRawTag(10); @@ -3853,6 +3917,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { data_.WriteTo(output, _repeated_data_codec); } @@ -3961,6 +4029,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Data.Length != 0) { output.WriteRawTag(10); @@ -4076,6 +4148,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Data.Length != 0) { output.WriteRawTag(10); @@ -4191,6 +4267,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Data != 0) { output.WriteRawTag(8); @@ -4306,6 +4386,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Data != 0) { output.WriteRawTag(8); @@ -4421,6 +4505,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Data != 0L) { output.WriteRawTag(8); @@ -4536,6 +4624,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Data != 0UL) { output.WriteRawTag(8); @@ -4651,6 +4743,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Data != false) { output.WriteRawTag(8); @@ -4820,6 +4916,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (fooCase_ == FooOneofCase.FooInt) { output.WriteRawTag(8); @@ -5125,6 +5225,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { packedInt32_.WriteTo(output, _repeated_packedInt32_codec); packedInt64_.WriteTo(output, _repeated_packedInt64_codec); @@ -5492,6 +5596,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { unpackedInt32_.WriteTo(output, _repeated_unpackedInt32_codec); unpackedInt64_.WriteTo(output, _repeated_unpackedInt64_codec); @@ -5764,6 +5872,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { repeatedFixed32_.WriteTo(output, _repeated_repeatedFixed32_codec); repeatedInt32_.WriteTo(output, _repeated_repeatedInt32_codec); @@ -5913,6 +6025,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (A.Length != 0) { output.WriteRawTag(10); @@ -6015,6 +6131,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { } @@ -6103,6 +6223,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { } @@ -6191,6 +6315,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { } @@ -6279,6 +6407,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { } @@ -6367,6 +6499,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { } @@ -6455,6 +6591,10 @@ namespace Google.Protobuf.TestProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { } diff --git a/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs b/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs index c87b367a..a7d1d726 100644 --- a/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs +++ b/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs @@ -299,6 +299,10 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { file_.WriteTo(output, _repeated_file_codec); } @@ -545,6 +549,10 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Name.Length != 0) { output.WriteRawTag(10); @@ -889,6 +897,10 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Name.Length != 0) { output.WriteRawTag(10); @@ -1094,6 +1106,10 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Start != 0) { output.WriteRawTag(8); @@ -1236,6 +1252,10 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Start != 0) { output.WriteRawTag(8); @@ -1475,6 +1495,10 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Name.Length != 0) { output.WriteRawTag(10); @@ -1741,6 +1765,10 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Name.Length != 0) { output.WriteRawTag(10); @@ -1882,6 +1910,10 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Name.Length != 0) { output.WriteRawTag(10); @@ -2051,6 +2083,10 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Name.Length != 0) { output.WriteRawTag(10); @@ -2226,6 +2262,10 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Name.Length != 0) { output.WriteRawTag(10); @@ -2434,6 +2474,10 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Name.Length != 0) { output.WriteRawTag(10); @@ -2806,6 +2850,10 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (JavaPackage.Length != 0) { output.WriteRawTag(10); @@ -3173,6 +3221,10 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (MessageSetWireFormat != false) { output.WriteRawTag(8); @@ -3414,6 +3466,10 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Ctype != global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.CType.STRING) { output.WriteRawTag(8); @@ -3649,6 +3705,10 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (AllowAlias != false) { output.WriteRawTag(16); @@ -3797,6 +3857,10 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Deprecated != false) { output.WriteRawTag(8); @@ -3931,6 +3995,10 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Deprecated != false) { output.WriteRawTag(136, 2); @@ -4065,6 +4133,10 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (Deprecated != false) { output.WriteRawTag(136, 2); @@ -4264,6 +4336,10 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { name_.WriteTo(output, _repeated_name_codec); if (IdentifierValue.Length != 0) { @@ -4470,6 +4546,10 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { if (NamePart_.Length != 0) { output.WriteRawTag(10); @@ -4603,6 +4683,10 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { location_.WriteTo(output, _repeated_location_codec); } @@ -4761,6 +4845,10 @@ namespace Google.Protobuf.DescriptorProtos { return hash; } + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + public void WriteTo(pb::CodedOutputStream output) { path_.WriteTo(output, _repeated_path_codec); span_.WriteTo(output, _repeated_span_codec); diff --git a/src/google/protobuf/compiler/csharp/csharp_field_base.h b/src/google/protobuf/compiler/csharp/csharp_field_base.h index 349d835b..bffa2062 100644 --- a/src/google/protobuf/compiler/csharp/csharp_field_base.h +++ b/src/google/protobuf/compiler/csharp/csharp_field_base.h @@ -58,6 +58,7 @@ class FieldGeneratorBase : public SourceGeneratorBase { virtual void WriteHash(io::Printer* printer) = 0; virtual void WriteEquals(io::Printer* printer) = 0; + // Currently unused, as we use reflection to generate JSON virtual void WriteToString(io::Printer* printer) = 0; protected: diff --git a/src/google/protobuf/compiler/csharp/csharp_map_field.cc b/src/google/protobuf/compiler/csharp/csharp_map_field.cc index cb7ce5f0..32c05232 100644 --- a/src/google/protobuf/compiler/csharp/csharp_map_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_map_field.cc @@ -117,12 +117,9 @@ void MapFieldGenerator::WriteEquals(io::Printer* printer) { variables_, "if (!$property_name$.Equals(other.$property_name$)) return false;\n"); } + void MapFieldGenerator::WriteToString(io::Printer* printer) { - /* - variables_["field_name"] = GetFieldName(descriptor_); - printer->Print( - variables_, - "PrintField(\"$field_name$\", has$property_name$, $name$_, writer);\n");*/ + // TODO: If we ever actually use ToString, we'll need to impleme this... } void MapFieldGenerator::GenerateCloningCode(io::Printer* printer) { diff --git a/src/google/protobuf/compiler/csharp/csharp_message.cc b/src/google/protobuf/compiler/csharp/csharp_message.cc index 13544b26..ac135951 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message.cc @@ -429,7 +429,10 @@ void MessageGenerator::GenerateFrameworkMethods(io::Printer* printer) { printer->Outdent(); printer->Print("}\n\n"); - // TODO(jonskeet): ToString. + printer->Print( + "public override string ToString() {\n" + " return pb::JsonFormatter.Default.Format(this);\n" + "}\n\n"); } void MessageGenerator::GenerateMessageSerializationMethods(io::Printer* printer) { -- cgit v1.2.3 From ef3464dff648362683a75ddf593c9d47ec3c33ce Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Fri, 10 Jul 2015 14:04:53 +0100 Subject: Oneof reflection support. (Generated code changes in next commit.) --- .../ProtocolBuffers.Test/GeneratedMessageTest.cs | 20 ++++++++ .../FieldAccess/FieldAccessorTable.cs | 29 +++++++++-- .../ProtocolBuffers/FieldAccess/OneofAccessor.cs | 57 ++++++++++------------ .../ProtocolBuffers/FieldAccess/ReflectionUtil.cs | 15 +++++- .../protobuf/compiler/csharp/csharp_message.cc | 1 + 5 files changed, 87 insertions(+), 35 deletions(-) diff --git a/csharp/src/ProtocolBuffers.Test/GeneratedMessageTest.cs b/csharp/src/ProtocolBuffers.Test/GeneratedMessageTest.cs index 8cee9820..28c2195f 100644 --- a/csharp/src/ProtocolBuffers.Test/GeneratedMessageTest.cs +++ b/csharp/src/ProtocolBuffers.Test/GeneratedMessageTest.cs @@ -734,5 +734,25 @@ namespace Google.Protobuf var message = SampleMessages.CreateFullTestAllTypes(); Assert.Throws(() => message.Fields[TestAllTypes.SingleBoolFieldNumber].GetValue(new TestMap())); } + + [Test] + public void Reflection_Oneof() + { + var message = new TestAllTypes(); + var fields = message.Fields; + Assert.AreEqual(1, fields.Oneofs.Count); + var oneof = fields.Oneofs[0]; + Assert.AreEqual("oneof_field", oneof.Descriptor.Name); + Assert.IsNull(oneof.GetCaseFieldDescriptor(message)); + + message.OneofString = "foo"; + Assert.AreSame(fields[TestAllTypes.OneofStringFieldNumber].Descriptor, oneof.GetCaseFieldDescriptor(message)); + + message.OneofUint32 = 10; + Assert.AreSame(fields[TestAllTypes.OneofUint32FieldNumber].Descriptor, oneof.GetCaseFieldDescriptor(message)); + + oneof.Clear(message); + Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.None, message.OneofFieldCase); + } } } diff --git a/csharp/src/ProtocolBuffers/FieldAccess/FieldAccessorTable.cs b/csharp/src/ProtocolBuffers/FieldAccess/FieldAccessorTable.cs index 57ea9c87..c69612fb 100644 --- a/csharp/src/ProtocolBuffers/FieldAccess/FieldAccessorTable.cs +++ b/csharp/src/ProtocolBuffers/FieldAccess/FieldAccessorTable.cs @@ -42,6 +42,7 @@ namespace Google.Protobuf.FieldAccess public sealed class FieldAccessorTable { private readonly ReadOnlyCollection accessors; + private readonly ReadOnlyCollection oneofs; private readonly MessageDescriptor descriptor; /// @@ -51,7 +52,7 @@ namespace Google.Protobuf.FieldAccess /// The CLR type for the message. /// The type's descriptor /// The Pascal-case names of all the field-based properties in the message. - public FieldAccessorTable(Type type, MessageDescriptor descriptor, string[] propertyNames) + public FieldAccessorTable(Type type, MessageDescriptor descriptor, string[] propertyNames, string[] oneofPropertyNames) { this.descriptor = descriptor; var accessorsArray = new IFieldAccessor[descriptor.Fields.Count]; @@ -65,7 +66,13 @@ namespace Google.Protobuf.FieldAccess : (IFieldAccessor) new SingleFieldAccessor(type, name, field); } accessors = new ReadOnlyCollection(accessorsArray); - // TODO(jonskeet): Oneof support + var oneofsArray = new OneofAccessor[descriptor.Oneofs.Count]; + for (int i = 0; i < oneofsArray.Length; i++) + { + var oneof = descriptor.Oneofs[i]; + oneofsArray[i] = new OneofAccessor(type, oneofPropertyNames[i], oneof); + } + oneofs = new ReadOnlyCollection(oneofsArray); } // TODO: Validate the name here... should possibly make this type a more "general reflection access" type, @@ -75,6 +82,10 @@ namespace Google.Protobuf.FieldAccess /// public ReadOnlyCollection Accessors { get { return accessors; } } + public ReadOnlyCollection Oneofs { get { return oneofs; } } + + // TODO: Review the API for the indexers. Now that we have fields and oneofs, it's not as clear... + public IFieldAccessor this[int fieldNumber] { get @@ -84,7 +95,7 @@ namespace Google.Protobuf.FieldAccess } } - internal IFieldAccessor this[FieldDescriptor field] + public IFieldAccessor this[FieldDescriptor field] { get { @@ -95,5 +106,17 @@ namespace Google.Protobuf.FieldAccess return accessors[field.Index]; } } + + public OneofAccessor this[OneofDescriptor oneof] + { + get + { + if (oneof.ContainingType != descriptor) + { + throw new ArgumentException("OneofDescriptor does not match message type."); + } + return oneofs[oneof.Index]; + } + } } } \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/FieldAccess/OneofAccessor.cs b/csharp/src/ProtocolBuffers/FieldAccess/OneofAccessor.cs index feaa6232..590b6309 100644 --- a/csharp/src/ProtocolBuffers/FieldAccess/OneofAccessor.cs +++ b/csharp/src/ProtocolBuffers/FieldAccess/OneofAccessor.cs @@ -30,62 +30,57 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #endregion +using Google.Protobuf.Descriptors; +using System; +using System.Reflection; + namespace Google.Protobuf.FieldAccess { - // TODO(jonskeet): Add "new" oneof API support - /// - /// Access for an oneof + /// Reflection access for a oneof, allowing clear and "get case" actions. /// - internal class OneofAccessor where TMessage : IMessage + public sealed class OneofAccessor { - /* - private readonly Func caseDelegate; - private readonly Func clearDelegate; - private MessageDescriptor descriptor; + private readonly Func caseDelegate; + private readonly Action clearDelegate; + private OneofDescriptor descriptor; - internal OneofAccessor(MessageDescriptor descriptor, string name) + internal OneofAccessor(Type type, string propertyName, OneofDescriptor descriptor) { - this.descriptor = descriptor; - MethodInfo clearMethod = typeof(TBuilder).GetMethod("Clear" + name); - PropertyInfo caseProperty = typeof(TMessage).GetProperty(name + "Case"); - if (clearMethod == null || caseProperty == null) + PropertyInfo property = type.GetProperty(propertyName + "Case"); + if (property == null || !property.CanRead) { - throw new ArgumentException("Not all required properties/methods available for oneof"); + throw new ArgumentException("Not all required properties/methods available"); } - + this.descriptor = descriptor; + caseDelegate = ReflectionUtil.CreateFuncObjectT(property.GetGetMethod()); - clearDelegate = ReflectionUtil.CreateDelegateFunc(clearMethod); - caseDelegate = ReflectionUtil.CreateUpcastDelegate(caseProperty.GetGetMethod()); + this.descriptor = descriptor; + MethodInfo clearMethod = type.GetMethod("Clear" + propertyName); + clearDelegate = ReflectionUtil.CreateActionObject(clearMethod); } - /// - /// Indicates whether the specified message has set any field in the oneof. - /// - public bool Has(TMessage message) - { - return ((int) caseDelegate(message) != 0); - } + public OneofDescriptor Descriptor { get { return descriptor; } } /// - /// Clears the oneof in the specified builder. + /// Clears the oneof in the specified message. /// - public void Clear(TBuilder builder) + public void Clear(object message) { - clearDelegate(builder); + clearDelegate(message); } /// /// Indicates which field in the oneof is set for specified message /// - public virtual FieldDescriptor GetOneofFieldDescriptor(TMessage message) + public FieldDescriptor GetCaseFieldDescriptor(object message) { - int fieldNumber = (int) caseDelegate(message); + int fieldNumber = caseDelegate(message); if (fieldNumber > 0) { - return descriptor.FindFieldByNumber(fieldNumber); + return descriptor.ContainingType.FindFieldByNumber(fieldNumber); } return null; - }*/ + } } } diff --git a/csharp/src/ProtocolBuffers/FieldAccess/ReflectionUtil.cs b/csharp/src/ProtocolBuffers/FieldAccess/ReflectionUtil.cs index d3053920..08ef6c0c 100644 --- a/csharp/src/ProtocolBuffers/FieldAccess/ReflectionUtil.cs +++ b/csharp/src/ProtocolBuffers/FieldAccess/ReflectionUtil.cs @@ -63,7 +63,20 @@ namespace Google.Protobuf.FieldAccess Expression upcast = Expression.Convert(call, typeof(object)); return Expression.Lambda>(upcast, parameter).Compile(); } - + + /// + /// Creates a delegate which will cast the argument to the appropriate method target type, + /// call the method on it, then convert the result to the specified type. + /// + internal static Func CreateFuncObjectT(MethodInfo method) + { + ParameterExpression parameter = Expression.Parameter(typeof(object), "p"); + Expression downcast = Expression.Convert(parameter, method.DeclaringType); + Expression call = Expression.Call(downcast, method); + Expression upcast = Expression.Convert(call, typeof(T)); + return Expression.Lambda>(upcast, parameter).Compile(); + } + /// /// Creates a delegate which will execute the given method after casting the first argument to /// the target type of the method, and the second argument to the first parameter type of the method. diff --git a/src/google/protobuf/compiler/csharp/csharp_message.cc b/src/google/protobuf/compiler/csharp/csharp_message.cc index ac135951..3fbec2b5 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message.cc @@ -151,6 +151,7 @@ void MessageGenerator::GenerateStaticVariableInitializers(io::Printer* printer) printer->Print("\"$property_name$\", ", "property_name", GetPropertyName(descriptor_->field(i))); } + printer->Print("}, new string[] { "); for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { printer->Print("\"$oneof_name$\", ", "oneof_name", -- cgit v1.2.3 From 68fc689e523a4e27a689b93f2fa4a054529708d0 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Fri, 10 Jul 2015 14:05:17 +0100 Subject: Generated code changes for previous submit --- csharp/src/AddressBook/Addressbook.cs | 6 +- .../TestProtos/MapUnittestProto3.cs | 88 +++++++++++----------- .../TestProtos/UnittestImportProto3.cs | 2 +- .../TestProtos/UnittestImportPublicProto3.cs | 2 +- .../TestProtos/UnittestIssues.cs | 14 ++-- .../TestProtos/UnittestProto3.cs | 70 ++++++++--------- .../DescriptorProtos/DescriptorProtoFile.cs | 44 +++++------ 7 files changed, 113 insertions(+), 113 deletions(-) diff --git a/csharp/src/AddressBook/Addressbook.cs b/csharp/src/AddressBook/Addressbook.cs index b7a08ef0..afdb1728 100644 --- a/csharp/src/AddressBook/Addressbook.cs +++ b/csharp/src/AddressBook/Addressbook.cs @@ -40,13 +40,13 @@ namespace Google.Protobuf.Examples.AddressBook { }); internal__static_tutorial_Person__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.Examples.AddressBook.Person), descriptor.MessageTypes[0], - new string[] { "Name", "Id", "Email", "Phone", }); + new string[] { "Name", "Id", "Email", "Phone", }, new string[] { }); internal__static_tutorial_Person_PhoneNumber__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneNumber), descriptor.MessageTypes[0].NestedTypes[0], - new string[] { "Number", "Type", }); + new string[] { "Number", "Type", }, new string[] { }); internal__static_tutorial_AddressBook__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.Examples.AddressBook.AddressBook), descriptor.MessageTypes[1], - new string[] { "Person", }); + new string[] { "Person", }, new string[] { }); } #endregion diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/MapUnittestProto3.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/MapUnittestProto3.cs index 0e261e1b..05fe7fc4 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/MapUnittestProto3.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/MapUnittestProto3.cs @@ -197,136 +197,136 @@ namespace Google.Protobuf.TestProtos { }); internal__static_protobuf_unittest_TestMap__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap), descriptor.MessageTypes[0], - new string[] { "MapInt32Int32", "MapInt64Int64", "MapUint32Uint32", "MapUint64Uint64", "MapSint32Sint32", "MapSint64Sint64", "MapFixed32Fixed32", "MapFixed64Fixed64", "MapSfixed32Sfixed32", "MapSfixed64Sfixed64", "MapInt32Float", "MapInt32Double", "MapBoolBool", "MapStringString", "MapInt32Bytes", "MapInt32Enum", "MapInt32ForeignMessage", }); + new string[] { "MapInt32Int32", "MapInt64Int64", "MapUint32Uint32", "MapUint64Uint64", "MapSint32Sint32", "MapSint64Sint64", "MapFixed32Fixed32", "MapFixed64Fixed64", "MapSfixed32Sfixed32", "MapSfixed64Sfixed64", "MapInt32Float", "MapInt32Double", "MapBoolBool", "MapStringString", "MapInt32Bytes", "MapInt32Enum", "MapInt32ForeignMessage", }, new string[] { }); internal__static_protobuf_unittest_TestMap_MapInt32Int32Entry__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap.Types.MapInt32Int32Entry), descriptor.MessageTypes[0].NestedTypes[0], - new string[] { "Key", "Value", }); + new string[] { "Key", "Value", }, new string[] { }); internal__static_protobuf_unittest_TestMap_MapInt64Int64Entry__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap.Types.MapInt64Int64Entry), descriptor.MessageTypes[0].NestedTypes[1], - new string[] { "Key", "Value", }); + new string[] { "Key", "Value", }, new string[] { }); internal__static_protobuf_unittest_TestMap_MapUint32Uint32Entry__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap.Types.MapUint32Uint32Entry), descriptor.MessageTypes[0].NestedTypes[2], - new string[] { "Key", "Value", }); + new string[] { "Key", "Value", }, new string[] { }); internal__static_protobuf_unittest_TestMap_MapUint64Uint64Entry__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap.Types.MapUint64Uint64Entry), descriptor.MessageTypes[0].NestedTypes[3], - new string[] { "Key", "Value", }); + new string[] { "Key", "Value", }, new string[] { }); internal__static_protobuf_unittest_TestMap_MapSint32Sint32Entry__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap.Types.MapSint32Sint32Entry), descriptor.MessageTypes[0].NestedTypes[4], - new string[] { "Key", "Value", }); + new string[] { "Key", "Value", }, new string[] { }); internal__static_protobuf_unittest_TestMap_MapSint64Sint64Entry__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap.Types.MapSint64Sint64Entry), descriptor.MessageTypes[0].NestedTypes[5], - new string[] { "Key", "Value", }); + new string[] { "Key", "Value", }, new string[] { }); internal__static_protobuf_unittest_TestMap_MapFixed32Fixed32Entry__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap.Types.MapFixed32Fixed32Entry), descriptor.MessageTypes[0].NestedTypes[6], - new string[] { "Key", "Value", }); + new string[] { "Key", "Value", }, new string[] { }); internal__static_protobuf_unittest_TestMap_MapFixed64Fixed64Entry__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap.Types.MapFixed64Fixed64Entry), descriptor.MessageTypes[0].NestedTypes[7], - new string[] { "Key", "Value", }); + new string[] { "Key", "Value", }, new string[] { }); internal__static_protobuf_unittest_TestMap_MapSfixed32Sfixed32Entry__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap.Types.MapSfixed32Sfixed32Entry), descriptor.MessageTypes[0].NestedTypes[8], - new string[] { "Key", "Value", }); + new string[] { "Key", "Value", }, new string[] { }); internal__static_protobuf_unittest_TestMap_MapSfixed64Sfixed64Entry__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap.Types.MapSfixed64Sfixed64Entry), descriptor.MessageTypes[0].NestedTypes[9], - new string[] { "Key", "Value", }); + new string[] { "Key", "Value", }, new string[] { }); internal__static_protobuf_unittest_TestMap_MapInt32FloatEntry__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap.Types.MapInt32FloatEntry), descriptor.MessageTypes[0].NestedTypes[10], - new string[] { "Key", "Value", }); + new string[] { "Key", "Value", }, new string[] { }); internal__static_protobuf_unittest_TestMap_MapInt32DoubleEntry__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap.Types.MapInt32DoubleEntry), descriptor.MessageTypes[0].NestedTypes[11], - new string[] { "Key", "Value", }); + new string[] { "Key", "Value", }, new string[] { }); internal__static_protobuf_unittest_TestMap_MapBoolBoolEntry__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap.Types.MapBoolBoolEntry), descriptor.MessageTypes[0].NestedTypes[12], - new string[] { "Key", "Value", }); + new string[] { "Key", "Value", }, new string[] { }); internal__static_protobuf_unittest_TestMap_MapStringStringEntry__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap.Types.MapStringStringEntry), descriptor.MessageTypes[0].NestedTypes[13], - new string[] { "Key", "Value", }); + new string[] { "Key", "Value", }, new string[] { }); internal__static_protobuf_unittest_TestMap_MapInt32BytesEntry__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap.Types.MapInt32BytesEntry), descriptor.MessageTypes[0].NestedTypes[14], - new string[] { "Key", "Value", }); + new string[] { "Key", "Value", }, new string[] { }); internal__static_protobuf_unittest_TestMap_MapInt32EnumEntry__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap.Types.MapInt32EnumEntry), descriptor.MessageTypes[0].NestedTypes[15], - new string[] { "Key", "Value", }); + new string[] { "Key", "Value", }, new string[] { }); internal__static_protobuf_unittest_TestMap_MapInt32ForeignMessageEntry__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap.Types.MapInt32ForeignMessageEntry), descriptor.MessageTypes[0].NestedTypes[16], - new string[] { "Key", "Value", }); + new string[] { "Key", "Value", }, new string[] { }); internal__static_protobuf_unittest_TestMapSubmessage__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMapSubmessage), descriptor.MessageTypes[1], - new string[] { "TestMap", }); + new string[] { "TestMap", }, new string[] { }); internal__static_protobuf_unittest_TestMessageMap__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMessageMap), descriptor.MessageTypes[2], - new string[] { "MapInt32Message", }); + new string[] { "MapInt32Message", }, new string[] { }); internal__static_protobuf_unittest_TestMessageMap_MapInt32MessageEntry__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMessageMap.Types.MapInt32MessageEntry), descriptor.MessageTypes[2].NestedTypes[0], - new string[] { "Key", "Value", }); + new string[] { "Key", "Value", }, new string[] { }); internal__static_protobuf_unittest_TestSameTypeMap__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestSameTypeMap), descriptor.MessageTypes[3], - new string[] { "Map1", "Map2", }); + new string[] { "Map1", "Map2", }, new string[] { }); internal__static_protobuf_unittest_TestSameTypeMap_Map1Entry__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestSameTypeMap.Types.Map1Entry), descriptor.MessageTypes[3].NestedTypes[0], - new string[] { "Key", "Value", }); + new string[] { "Key", "Value", }, new string[] { }); internal__static_protobuf_unittest_TestSameTypeMap_Map2Entry__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestSameTypeMap.Types.Map2Entry), descriptor.MessageTypes[3].NestedTypes[1], - new string[] { "Key", "Value", }); + new string[] { "Key", "Value", }, new string[] { }); internal__static_protobuf_unittest_TestArenaMap__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestArenaMap), descriptor.MessageTypes[4], - new string[] { "MapInt32Int32", "MapInt64Int64", "MapUint32Uint32", "MapUint64Uint64", "MapSint32Sint32", "MapSint64Sint64", "MapFixed32Fixed32", "MapFixed64Fixed64", "MapSfixed32Sfixed32", "MapSfixed64Sfixed64", "MapInt32Float", "MapInt32Double", "MapBoolBool", "MapInt32Enum", "MapInt32ForeignMessage", }); + new string[] { "MapInt32Int32", "MapInt64Int64", "MapUint32Uint32", "MapUint64Uint64", "MapSint32Sint32", "MapSint64Sint64", "MapFixed32Fixed32", "MapFixed64Fixed64", "MapSfixed32Sfixed32", "MapSfixed64Sfixed64", "MapInt32Float", "MapInt32Double", "MapBoolBool", "MapInt32Enum", "MapInt32ForeignMessage", }, new string[] { }); internal__static_protobuf_unittest_TestArenaMap_MapInt32Int32Entry__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestArenaMap.Types.MapInt32Int32Entry), descriptor.MessageTypes[4].NestedTypes[0], - new string[] { "Key", "Value", }); + new string[] { "Key", "Value", }, new string[] { }); internal__static_protobuf_unittest_TestArenaMap_MapInt64Int64Entry__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestArenaMap.Types.MapInt64Int64Entry), descriptor.MessageTypes[4].NestedTypes[1], - new string[] { "Key", "Value", }); + new string[] { "Key", "Value", }, new string[] { }); internal__static_protobuf_unittest_TestArenaMap_MapUint32Uint32Entry__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestArenaMap.Types.MapUint32Uint32Entry), descriptor.MessageTypes[4].NestedTypes[2], - new string[] { "Key", "Value", }); + new string[] { "Key", "Value", }, new string[] { }); internal__static_protobuf_unittest_TestArenaMap_MapUint64Uint64Entry__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestArenaMap.Types.MapUint64Uint64Entry), descriptor.MessageTypes[4].NestedTypes[3], - new string[] { "Key", "Value", }); + new string[] { "Key", "Value", }, new string[] { }); internal__static_protobuf_unittest_TestArenaMap_MapSint32Sint32Entry__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestArenaMap.Types.MapSint32Sint32Entry), descriptor.MessageTypes[4].NestedTypes[4], - new string[] { "Key", "Value", }); + new string[] { "Key", "Value", }, new string[] { }); internal__static_protobuf_unittest_TestArenaMap_MapSint64Sint64Entry__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestArenaMap.Types.MapSint64Sint64Entry), descriptor.MessageTypes[4].NestedTypes[5], - new string[] { "Key", "Value", }); + new string[] { "Key", "Value", }, new string[] { }); internal__static_protobuf_unittest_TestArenaMap_MapFixed32Fixed32Entry__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestArenaMap.Types.MapFixed32Fixed32Entry), descriptor.MessageTypes[4].NestedTypes[6], - new string[] { "Key", "Value", }); + new string[] { "Key", "Value", }, new string[] { }); internal__static_protobuf_unittest_TestArenaMap_MapFixed64Fixed64Entry__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestArenaMap.Types.MapFixed64Fixed64Entry), descriptor.MessageTypes[4].NestedTypes[7], - new string[] { "Key", "Value", }); + new string[] { "Key", "Value", }, new string[] { }); internal__static_protobuf_unittest_TestArenaMap_MapSfixed32Sfixed32Entry__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestArenaMap.Types.MapSfixed32Sfixed32Entry), descriptor.MessageTypes[4].NestedTypes[8], - new string[] { "Key", "Value", }); + new string[] { "Key", "Value", }, new string[] { }); internal__static_protobuf_unittest_TestArenaMap_MapSfixed64Sfixed64Entry__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestArenaMap.Types.MapSfixed64Sfixed64Entry), descriptor.MessageTypes[4].NestedTypes[9], - new string[] { "Key", "Value", }); + new string[] { "Key", "Value", }, new string[] { }); internal__static_protobuf_unittest_TestArenaMap_MapInt32FloatEntry__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestArenaMap.Types.MapInt32FloatEntry), descriptor.MessageTypes[4].NestedTypes[10], - new string[] { "Key", "Value", }); + new string[] { "Key", "Value", }, new string[] { }); internal__static_protobuf_unittest_TestArenaMap_MapInt32DoubleEntry__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestArenaMap.Types.MapInt32DoubleEntry), descriptor.MessageTypes[4].NestedTypes[11], - new string[] { "Key", "Value", }); + new string[] { "Key", "Value", }, new string[] { }); internal__static_protobuf_unittest_TestArenaMap_MapBoolBoolEntry__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestArenaMap.Types.MapBoolBoolEntry), descriptor.MessageTypes[4].NestedTypes[12], - new string[] { "Key", "Value", }); + new string[] { "Key", "Value", }, new string[] { }); internal__static_protobuf_unittest_TestArenaMap_MapInt32EnumEntry__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestArenaMap.Types.MapInt32EnumEntry), descriptor.MessageTypes[4].NestedTypes[13], - new string[] { "Key", "Value", }); + new string[] { "Key", "Value", }, new string[] { }); internal__static_protobuf_unittest_TestArenaMap_MapInt32ForeignMessageEntry__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestArenaMap.Types.MapInt32ForeignMessageEntry), descriptor.MessageTypes[4].NestedTypes[14], - new string[] { "Key", "Value", }); + new string[] { "Key", "Value", }, new string[] { }); internal__static_protobuf_unittest_MessageContainingEnumCalledType__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.MessageContainingEnumCalledType), descriptor.MessageTypes[5], - new string[] { "Type", }); + new string[] { "Type", }, new string[] { }); internal__static_protobuf_unittest_MessageContainingEnumCalledType_TypeEntry__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.MessageContainingEnumCalledType.Types.TypeEntry), descriptor.MessageTypes[5].NestedTypes[0], - new string[] { "Key", "Value", }); + new string[] { "Key", "Value", }, new string[] { }); internal__static_protobuf_unittest_MessageContainingMapCalledEntry__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.MessageContainingMapCalledEntry), descriptor.MessageTypes[6], - new string[] { "Entry", }); + new string[] { "Entry", }, new string[] { }); internal__static_protobuf_unittest_MessageContainingMapCalledEntry_EntryEntry__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.MessageContainingMapCalledEntry.Types.EntryEntry), descriptor.MessageTypes[6].NestedTypes[0], - new string[] { "Key", "Value", }); + new string[] { "Key", "Value", }, new string[] { }); } #endregion diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportProto3.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportProto3.cs index 14c844fe..3cc5949b 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportProto3.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportProto3.cs @@ -38,7 +38,7 @@ namespace Google.Protobuf.TestProtos { }); internal__static_protobuf_unittest_import_ImportMessage__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.ImportMessage), descriptor.MessageTypes[0], - new string[] { "D", }); + new string[] { "D", }, new string[] { }); } #endregion diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportPublicProto3.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportPublicProto3.cs index b8c62bc9..d3abe5d5 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportPublicProto3.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestImportPublicProto3.cs @@ -33,7 +33,7 @@ namespace Google.Protobuf.TestProtos { }); internal__static_protobuf_unittest_import_PublicImportMessage__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.PublicImportMessage), descriptor.MessageTypes[0], - new string[] { "E", }); + new string[] { "E", }, new string[] { }); } #endregion diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs index 59c551dc..c296cd24 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestIssues.cs @@ -53,25 +53,25 @@ namespace UnitTest.Issues.TestProtos { }); internal__static_unittest_issues_Issue307__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::UnitTest.Issues.TestProtos.Issue307), descriptor.MessageTypes[0], - new string[] { }); + new string[] { }, new string[] { }); internal__static_unittest_issues_Issue307_NestedOnce__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::UnitTest.Issues.TestProtos.Issue307.Types.NestedOnce), descriptor.MessageTypes[0].NestedTypes[0], - new string[] { }); + new string[] { }, new string[] { }); internal__static_unittest_issues_Issue307_NestedOnce_NestedTwice__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::UnitTest.Issues.TestProtos.Issue307.Types.NestedOnce.Types.NestedTwice), descriptor.MessageTypes[0].NestedTypes[0].NestedTypes[0], - new string[] { }); + new string[] { }, new string[] { }); internal__static_unittest_issues_NegativeEnumMessage__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::UnitTest.Issues.TestProtos.NegativeEnumMessage), descriptor.MessageTypes[1], - new string[] { "Value", "Values", "PackedValues", }); + new string[] { "Value", "Values", "PackedValues", }, new string[] { }); internal__static_unittest_issues_DeprecatedChild__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::UnitTest.Issues.TestProtos.DeprecatedChild), descriptor.MessageTypes[2], - new string[] { }); + new string[] { }, new string[] { }); internal__static_unittest_issues_DeprecatedFieldsMessage__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::UnitTest.Issues.TestProtos.DeprecatedFieldsMessage), descriptor.MessageTypes[3], - new string[] { "PrimitiveValue", "PrimitiveArray", "MessageValue", "MessageArray", "EnumValue", "EnumArray", }); + new string[] { "PrimitiveValue", "PrimitiveArray", "MessageValue", "MessageArray", "EnumValue", "EnumArray", }, new string[] { }); internal__static_unittest_issues_ItemField__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::UnitTest.Issues.TestProtos.ItemField), descriptor.MessageTypes[4], - new string[] { "Item", }); + new string[] { "Item", }, new string[] { }); } #endregion diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs index 0e63e1d6..a5e37bd6 100644 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestProto3.cs @@ -191,109 +191,109 @@ namespace Google.Protobuf.TestProtos { }); internal__static_protobuf_unittest_TestAllTypes__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestAllTypes), descriptor.MessageTypes[0], - new string[] { "SingleInt32", "SingleInt64", "SingleUint32", "SingleUint64", "SingleSint32", "SingleSint64", "SingleFixed32", "SingleFixed64", "SingleSfixed32", "SingleSfixed64", "SingleFloat", "SingleDouble", "SingleBool", "SingleString", "SingleBytes", "SingleNestedMessage", "SingleForeignMessage", "SingleImportMessage", "SingleNestedEnum", "SingleForeignEnum", "SingleImportEnum", "SinglePublicImportMessage", "RepeatedInt32", "RepeatedInt64", "RepeatedUint32", "RepeatedUint64", "RepeatedSint32", "RepeatedSint64", "RepeatedFixed32", "RepeatedFixed64", "RepeatedSfixed32", "RepeatedSfixed64", "RepeatedFloat", "RepeatedDouble", "RepeatedBool", "RepeatedString", "RepeatedBytes", "RepeatedNestedMessage", "RepeatedForeignMessage", "RepeatedImportMessage", "RepeatedNestedEnum", "RepeatedForeignEnum", "RepeatedImportEnum", "RepeatedPublicImportMessage", "OneofUint32", "OneofNestedMessage", "OneofString", "OneofBytes", "OneofField", }); + new string[] { "SingleInt32", "SingleInt64", "SingleUint32", "SingleUint64", "SingleSint32", "SingleSint64", "SingleFixed32", "SingleFixed64", "SingleSfixed32", "SingleSfixed64", "SingleFloat", "SingleDouble", "SingleBool", "SingleString", "SingleBytes", "SingleNestedMessage", "SingleForeignMessage", "SingleImportMessage", "SingleNestedEnum", "SingleForeignEnum", "SingleImportEnum", "SinglePublicImportMessage", "RepeatedInt32", "RepeatedInt64", "RepeatedUint32", "RepeatedUint64", "RepeatedSint32", "RepeatedSint64", "RepeatedFixed32", "RepeatedFixed64", "RepeatedSfixed32", "RepeatedSfixed64", "RepeatedFloat", "RepeatedDouble", "RepeatedBool", "RepeatedString", "RepeatedBytes", "RepeatedNestedMessage", "RepeatedForeignMessage", "RepeatedImportMessage", "RepeatedNestedEnum", "RepeatedForeignEnum", "RepeatedImportEnum", "RepeatedPublicImportMessage", "OneofUint32", "OneofNestedMessage", "OneofString", "OneofBytes", }, new string[] { "OneofField", }); internal__static_protobuf_unittest_TestAllTypes_NestedMessage__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage), descriptor.MessageTypes[0].NestedTypes[0], - new string[] { "Bb", }); + new string[] { "Bb", }, new string[] { }); internal__static_protobuf_unittest_NestedTestAllTypes__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.NestedTestAllTypes), descriptor.MessageTypes[1], - new string[] { "Child", "Payload", "RepeatedChild", }); + new string[] { "Child", "Payload", "RepeatedChild", }, new string[] { }); internal__static_protobuf_unittest_TestDeprecatedFields__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestDeprecatedFields), descriptor.MessageTypes[2], - new string[] { "DeprecatedInt32", }); + new string[] { "DeprecatedInt32", }, new string[] { }); internal__static_protobuf_unittest_ForeignMessage__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.ForeignMessage), descriptor.MessageTypes[3], - new string[] { "C", }); + new string[] { "C", }, new string[] { }); internal__static_protobuf_unittest_TestReservedFields__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestReservedFields), descriptor.MessageTypes[4], - new string[] { }); + new string[] { }, new string[] { }); internal__static_protobuf_unittest_TestForeignNested__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestForeignNested), descriptor.MessageTypes[5], - new string[] { "ForeignNested", }); + new string[] { "ForeignNested", }, new string[] { }); internal__static_protobuf_unittest_TestReallyLargeTagNumber__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestReallyLargeTagNumber), descriptor.MessageTypes[6], - new string[] { "A", "Bb", }); + new string[] { "A", "Bb", }, new string[] { }); internal__static_protobuf_unittest_TestRecursiveMessage__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestRecursiveMessage), descriptor.MessageTypes[7], - new string[] { "A", "I", }); + new string[] { "A", "I", }, new string[] { }); internal__static_protobuf_unittest_TestMutualRecursionA__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMutualRecursionA), descriptor.MessageTypes[8], - new string[] { "Bb", }); + new string[] { "Bb", }, new string[] { }); internal__static_protobuf_unittest_TestMutualRecursionB__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMutualRecursionB), descriptor.MessageTypes[9], - new string[] { "A", "OptionalInt32", }); + new string[] { "A", "OptionalInt32", }, new string[] { }); internal__static_protobuf_unittest_TestCamelCaseFieldNames__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestCamelCaseFieldNames), descriptor.MessageTypes[10], - new string[] { "PrimitiveField", "StringField", "EnumField", "MessageField", "RepeatedPrimitiveField", "RepeatedStringField", "RepeatedEnumField", "RepeatedMessageField", }); + new string[] { "PrimitiveField", "StringField", "EnumField", "MessageField", "RepeatedPrimitiveField", "RepeatedStringField", "RepeatedEnumField", "RepeatedMessageField", }, new string[] { }); internal__static_protobuf_unittest_TestFieldOrderings__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestFieldOrderings), descriptor.MessageTypes[11], - new string[] { "MyString", "MyInt", "MyFloat", "SingleNestedMessage", }); + new string[] { "MyString", "MyInt", "MyFloat", "SingleNestedMessage", }, new string[] { }); internal__static_protobuf_unittest_TestFieldOrderings_NestedMessage__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestFieldOrderings.Types.NestedMessage), descriptor.MessageTypes[11].NestedTypes[0], - new string[] { "Oo", "Bb", }); + new string[] { "Oo", "Bb", }, new string[] { }); internal__static_protobuf_unittest_SparseEnumMessage__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.SparseEnumMessage), descriptor.MessageTypes[12], - new string[] { "SparseEnum", }); + new string[] { "SparseEnum", }, new string[] { }); internal__static_protobuf_unittest_OneString__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.OneString), descriptor.MessageTypes[13], - new string[] { "Data", }); + new string[] { "Data", }, new string[] { }); internal__static_protobuf_unittest_MoreString__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.MoreString), descriptor.MessageTypes[14], - new string[] { "Data", }); + new string[] { "Data", }, new string[] { }); internal__static_protobuf_unittest_OneBytes__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.OneBytes), descriptor.MessageTypes[15], - new string[] { "Data", }); + new string[] { "Data", }, new string[] { }); internal__static_protobuf_unittest_MoreBytes__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.MoreBytes), descriptor.MessageTypes[16], - new string[] { "Data", }); + new string[] { "Data", }, new string[] { }); internal__static_protobuf_unittest_Int32Message__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.Int32Message), descriptor.MessageTypes[17], - new string[] { "Data", }); + new string[] { "Data", }, new string[] { }); internal__static_protobuf_unittest_Uint32Message__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.Uint32Message), descriptor.MessageTypes[18], - new string[] { "Data", }); + new string[] { "Data", }, new string[] { }); internal__static_protobuf_unittest_Int64Message__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.Int64Message), descriptor.MessageTypes[19], - new string[] { "Data", }); + new string[] { "Data", }, new string[] { }); internal__static_protobuf_unittest_Uint64Message__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.Uint64Message), descriptor.MessageTypes[20], - new string[] { "Data", }); + new string[] { "Data", }, new string[] { }); internal__static_protobuf_unittest_BoolMessage__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.BoolMessage), descriptor.MessageTypes[21], - new string[] { "Data", }); + new string[] { "Data", }, new string[] { }); internal__static_protobuf_unittest_TestOneof__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestOneof), descriptor.MessageTypes[22], - new string[] { "FooInt", "FooString", "FooMessage", "Foo", }); + new string[] { "FooInt", "FooString", "FooMessage", }, new string[] { "Foo", }); internal__static_protobuf_unittest_TestPackedTypes__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestPackedTypes), descriptor.MessageTypes[23], - new string[] { "PackedInt32", "PackedInt64", "PackedUint32", "PackedUint64", "PackedSint32", "PackedSint64", "PackedFixed32", "PackedFixed64", "PackedSfixed32", "PackedSfixed64", "PackedFloat", "PackedDouble", "PackedBool", "PackedEnum", }); + new string[] { "PackedInt32", "PackedInt64", "PackedUint32", "PackedUint64", "PackedSint32", "PackedSint64", "PackedFixed32", "PackedFixed64", "PackedSfixed32", "PackedSfixed64", "PackedFloat", "PackedDouble", "PackedBool", "PackedEnum", }, new string[] { }); internal__static_protobuf_unittest_TestUnpackedTypes__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestUnpackedTypes), descriptor.MessageTypes[24], - new string[] { "UnpackedInt32", "UnpackedInt64", "UnpackedUint32", "UnpackedUint64", "UnpackedSint32", "UnpackedSint64", "UnpackedFixed32", "UnpackedFixed64", "UnpackedSfixed32", "UnpackedSfixed64", "UnpackedFloat", "UnpackedDouble", "UnpackedBool", "UnpackedEnum", }); + new string[] { "UnpackedInt32", "UnpackedInt64", "UnpackedUint32", "UnpackedUint64", "UnpackedSint32", "UnpackedSint64", "UnpackedFixed32", "UnpackedFixed64", "UnpackedSfixed32", "UnpackedSfixed64", "UnpackedFloat", "UnpackedDouble", "UnpackedBool", "UnpackedEnum", }, new string[] { }); internal__static_protobuf_unittest_TestRepeatedScalarDifferentTagSizes__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestRepeatedScalarDifferentTagSizes), descriptor.MessageTypes[25], - new string[] { "RepeatedFixed32", "RepeatedInt32", "RepeatedFixed64", "RepeatedInt64", "RepeatedFloat", "RepeatedUint64", }); + new string[] { "RepeatedFixed32", "RepeatedInt32", "RepeatedFixed64", "RepeatedInt64", "RepeatedFloat", "RepeatedUint64", }, new string[] { }); internal__static_protobuf_unittest_TestCommentInjectionMessage__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestCommentInjectionMessage), descriptor.MessageTypes[26], - new string[] { "A", }); + new string[] { "A", }, new string[] { }); internal__static_protobuf_unittest_FooRequest__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.FooRequest), descriptor.MessageTypes[27], - new string[] { }); + new string[] { }, new string[] { }); internal__static_protobuf_unittest_FooResponse__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.FooResponse), descriptor.MessageTypes[28], - new string[] { }); + new string[] { }, new string[] { }); internal__static_protobuf_unittest_FooClientMessage__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.FooClientMessage), descriptor.MessageTypes[29], - new string[] { }); + new string[] { }, new string[] { }); internal__static_protobuf_unittest_FooServerMessage__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.FooServerMessage), descriptor.MessageTypes[30], - new string[] { }); + new string[] { }, new string[] { }); internal__static_protobuf_unittest_BarRequest__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.BarRequest), descriptor.MessageTypes[31], - new string[] { }); + new string[] { }, new string[] { }); internal__static_protobuf_unittest_BarResponse__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.BarResponse), descriptor.MessageTypes[32], - new string[] { }); + new string[] { }, new string[] { }); } #endregion diff --git a/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs b/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs index a7d1d726..52f0c4b2 100644 --- a/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs +++ b/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs @@ -161,70 +161,70 @@ namespace Google.Protobuf.DescriptorProtos { }); internal__static_google_protobuf_FileDescriptorSet__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.FileDescriptorSet), descriptor.MessageTypes[0], - new string[] { "File", }); + new string[] { "File", }, new string[] { }); internal__static_google_protobuf_FileDescriptorProto__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.FileDescriptorProto), descriptor.MessageTypes[1], - new string[] { "Name", "Package", "Dependency", "PublicDependency", "WeakDependency", "MessageType", "EnumType", "Service", "Extension", "Options", "SourceCodeInfo", "Syntax", }); + new string[] { "Name", "Package", "Dependency", "PublicDependency", "WeakDependency", "MessageType", "EnumType", "Service", "Extension", "Options", "SourceCodeInfo", "Syntax", }, new string[] { }); internal__static_google_protobuf_DescriptorProto__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.DescriptorProto), descriptor.MessageTypes[2], - new string[] { "Name", "Field", "Extension", "NestedType", "EnumType", "ExtensionRange", "OneofDecl", "Options", "ReservedRange", "ReservedName", }); + new string[] { "Name", "Field", "Extension", "NestedType", "EnumType", "ExtensionRange", "OneofDecl", "Options", "ReservedRange", "ReservedName", }, new string[] { }); internal__static_google_protobuf_DescriptorProto_ExtensionRange__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ExtensionRange), descriptor.MessageTypes[2].NestedTypes[0], - new string[] { "Start", "End", }); + new string[] { "Start", "End", }, new string[] { }); internal__static_google_protobuf_DescriptorProto_ReservedRange__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ReservedRange), descriptor.MessageTypes[2].NestedTypes[1], - new string[] { "Start", "End", }); + new string[] { "Start", "End", }, new string[] { }); internal__static_google_protobuf_FieldDescriptorProto__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto), descriptor.MessageTypes[3], - new string[] { "Name", "Number", "Label", "Type", "TypeName", "Extendee", "DefaultValue", "OneofIndex", "Options", }); + new string[] { "Name", "Number", "Label", "Type", "TypeName", "Extendee", "DefaultValue", "OneofIndex", "Options", }, new string[] { }); internal__static_google_protobuf_OneofDescriptorProto__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.OneofDescriptorProto), descriptor.MessageTypes[4], - new string[] { "Name", }); + new string[] { "Name", }, new string[] { }); internal__static_google_protobuf_EnumDescriptorProto__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto), descriptor.MessageTypes[5], - new string[] { "Name", "Value", "Options", }); + new string[] { "Name", "Value", "Options", }, new string[] { }); internal__static_google_protobuf_EnumValueDescriptorProto__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.EnumValueDescriptorProto), descriptor.MessageTypes[6], - new string[] { "Name", "Number", "Options", }); + new string[] { "Name", "Number", "Options", }, new string[] { }); internal__static_google_protobuf_ServiceDescriptorProto__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.ServiceDescriptorProto), descriptor.MessageTypes[7], - new string[] { "Name", "Method", "Options", }); + new string[] { "Name", "Method", "Options", }, new string[] { }); internal__static_google_protobuf_MethodDescriptorProto__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.MethodDescriptorProto), descriptor.MessageTypes[8], - new string[] { "Name", "InputType", "OutputType", "Options", "ClientStreaming", "ServerStreaming", }); + new string[] { "Name", "InputType", "OutputType", "Options", "ClientStreaming", "ServerStreaming", }, new string[] { }); internal__static_google_protobuf_FileOptions__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.FileOptions), descriptor.MessageTypes[9], - new string[] { "JavaPackage", "JavaOuterClassname", "JavaMultipleFiles", "JavaGenerateEqualsAndHash", "JavaStringCheckUtf8", "OptimizeFor", "GoPackage", "CcGenericServices", "JavaGenericServices", "PyGenericServices", "Deprecated", "CcEnableArenas", "ObjcClassPrefix", "CsharpNamespace", "UninterpretedOption", }); + new string[] { "JavaPackage", "JavaOuterClassname", "JavaMultipleFiles", "JavaGenerateEqualsAndHash", "JavaStringCheckUtf8", "OptimizeFor", "GoPackage", "CcGenericServices", "JavaGenericServices", "PyGenericServices", "Deprecated", "CcEnableArenas", "ObjcClassPrefix", "CsharpNamespace", "UninterpretedOption", }, new string[] { }); internal__static_google_protobuf_MessageOptions__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.MessageOptions), descriptor.MessageTypes[10], - new string[] { "MessageSetWireFormat", "NoStandardDescriptorAccessor", "Deprecated", "MapEntry", "UninterpretedOption", }); + new string[] { "MessageSetWireFormat", "NoStandardDescriptorAccessor", "Deprecated", "MapEntry", "UninterpretedOption", }, new string[] { }); internal__static_google_protobuf_FieldOptions__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.FieldOptions), descriptor.MessageTypes[11], - new string[] { "Ctype", "Packed", "Jstype", "Lazy", "Deprecated", "Weak", "UninterpretedOption", }); + new string[] { "Ctype", "Packed", "Jstype", "Lazy", "Deprecated", "Weak", "UninterpretedOption", }, new string[] { }); internal__static_google_protobuf_EnumOptions__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.EnumOptions), descriptor.MessageTypes[12], - new string[] { "AllowAlias", "Deprecated", "UninterpretedOption", }); + new string[] { "AllowAlias", "Deprecated", "UninterpretedOption", }, new string[] { }); internal__static_google_protobuf_EnumValueOptions__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.EnumValueOptions), descriptor.MessageTypes[13], - new string[] { "Deprecated", "UninterpretedOption", }); + new string[] { "Deprecated", "UninterpretedOption", }, new string[] { }); internal__static_google_protobuf_ServiceOptions__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.ServiceOptions), descriptor.MessageTypes[14], - new string[] { "Deprecated", "UninterpretedOption", }); + new string[] { "Deprecated", "UninterpretedOption", }, new string[] { }); internal__static_google_protobuf_MethodOptions__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.MethodOptions), descriptor.MessageTypes[15], - new string[] { "Deprecated", "UninterpretedOption", }); + new string[] { "Deprecated", "UninterpretedOption", }, new string[] { }); internal__static_google_protobuf_UninterpretedOption__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.UninterpretedOption), descriptor.MessageTypes[16], - new string[] { "Name", "IdentifierValue", "PositiveIntValue", "NegativeIntValue", "DoubleValue", "StringValue", "AggregateValue", }); + new string[] { "Name", "IdentifierValue", "PositiveIntValue", "NegativeIntValue", "DoubleValue", "StringValue", "AggregateValue", }, new string[] { }); internal__static_google_protobuf_UninterpretedOption_NamePart__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Types.NamePart), descriptor.MessageTypes[16].NestedTypes[0], - new string[] { "NamePart_", "IsExtension", }); + new string[] { "NamePart_", "IsExtension", }, new string[] { }); internal__static_google_protobuf_SourceCodeInfo__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.SourceCodeInfo), descriptor.MessageTypes[17], - new string[] { "Location", }); + new string[] { "Location", }, new string[] { }); internal__static_google_protobuf_SourceCodeInfo_Location__FieldAccessorTable = new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.DescriptorProtos.SourceCodeInfo.Types.Location), descriptor.MessageTypes[17].NestedTypes[0], - new string[] { "Path", "Span", "LeadingComments", "TrailingComments", "LeadingDetachedComments", }); + new string[] { "Path", "Span", "LeadingComments", "TrailingComments", "LeadingDetachedComments", }, new string[] { }); } #endregion -- cgit v1.2.3 From 6ea9bc7aa3af5c392fcd8f4eeebf71342c1ce961 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Fri, 10 Jul 2015 14:05:52 +0100 Subject: Fixes to JsonFormatter - Handle oneof properly - Omit unknown enum values --- .../src/ProtocolBuffers.Test/JsonFormatterTest.cs | 48 +++++++++++++- csharp/src/ProtocolBuffers/JsonFormatter.cs | 75 +++++++++++++++++++--- 2 files changed, 112 insertions(+), 11 deletions(-) diff --git a/csharp/src/ProtocolBuffers.Test/JsonFormatterTest.cs b/csharp/src/ProtocolBuffers.Test/JsonFormatterTest.cs index 5f80a499..5441bf47 100644 --- a/csharp/src/ProtocolBuffers.Test/JsonFormatterTest.cs +++ b/csharp/src/ProtocolBuffers.Test/JsonFormatterTest.cs @@ -160,10 +160,34 @@ namespace Google.Protobuf } [Test] - public void UnknownEnumValue() + public void UnknownEnumValueOmitted_SingleField() { var message = new TestAllTypes { SingleForeignEnum = (ForeignEnum) 100 }; - Assert.AreEqual("{ \"singleForeignEnum\": 100 }", JsonFormatter.Default.Format(message)); + Assert.AreEqual("{ }", JsonFormatter.Default.Format(message)); + } + + [Test] + public void UnknownEnumValueOmitted_RepeatedField() + { + var message = new TestAllTypes { RepeatedForeignEnum = { ForeignEnum.FOREIGN_BAZ, (ForeignEnum) 100, ForeignEnum.FOREIGN_FOO } }; + Assert.AreEqual("{ \"repeatedForeignEnum\": [ \"FOREIGN_BAZ\", \"FOREIGN_FOO\" ] }", JsonFormatter.Default.Format(message)); + } + + [Test] + public void UnknownEnumValueOmitted_MapField() + { + // This matches the C++ behaviour. + var message = new TestMap { MapInt32Enum = { { 1, MapEnum.MAP_ENUM_FOO }, { 2, (MapEnum) 100 }, { 3, MapEnum.MAP_ENUM_BAR } } }; + Assert.AreEqual("{ \"mapInt32Enum\": { \"1\": \"MAP_ENUM_FOO\", \"3\": \"MAP_ENUM_BAR\" } }", JsonFormatter.Default.Format(message)); + } + + [Test] + public void UnknownEnumValueOmitted_RepeatedField_AllEntriesUnknown() + { + // *Maybe* we should hold off on writing the "[" until we find that we've got at least one value to write... + // but this is what happens at the moment, and it doesn't seem too awful. + var message = new TestAllTypes { RepeatedForeignEnum = { (ForeignEnum) 200, (ForeignEnum) 100 } }; + Assert.AreEqual("{ \"repeatedForeignEnum\": [ ] }", JsonFormatter.Default.Format(message)); } [Test] @@ -213,5 +237,25 @@ namespace Google.Protobuf { Assert.AreEqual(expected, JsonFormatter.ToCamelCase(original)); } + + [Test] + [TestCase(null, "{ }")] + [TestCase("x", "{ \"fooString\": \"x\" }")] + [TestCase("", "{ \"fooString\": \"\" }")] + [TestCase(null, "{ }")] + public void Oneof(string fooStringValue, string expectedJson) + { + var message = new TestOneof(); + if (fooStringValue != null) + { + message.FooString = fooStringValue; + } + + // We should get the same result both with and without "format default values". + var formatter = new JsonFormatter(new JsonFormatter.Settings(false)); + Assert.AreEqual(expectedJson, formatter.Format(message)); + formatter = new JsonFormatter(new JsonFormatter.Settings(true)); + Assert.AreEqual(expectedJson, formatter.Format(message)); + } } } diff --git a/csharp/src/ProtocolBuffers/JsonFormatter.cs b/csharp/src/ProtocolBuffers/JsonFormatter.cs index a6aa552f..3e2244d6 100644 --- a/csharp/src/ProtocolBuffers/JsonFormatter.cs +++ b/csharp/src/ProtocolBuffers/JsonFormatter.cs @@ -136,13 +136,28 @@ namespace Google.Protobuf builder.Append("{ "); var fields = message.Fields; bool first = true; + // First non-oneof fields foreach (var accessor in fields.Accessors) { + var descriptor = accessor.Descriptor; + // Oneofs are written later + if (descriptor.ContainingOneof != null) + { + continue; + } + // Omit default values unless we're asked to format them object value = accessor.GetValue(message); if (!settings.FormatDefaultValues && IsDefaultValue(accessor, value)) { continue; } + // Omit awkward (single) values such as unknown enum values + if (!descriptor.IsRepeated && !descriptor.IsMap && !CanWriteSingleValue(accessor.Descriptor, value)) + { + continue; + } + + // Okay, all tests complete: let's write the field value... if (!first) { builder.Append(", "); @@ -152,6 +167,32 @@ namespace Google.Protobuf WriteValue(builder, accessor, value); first = false; } + + // Now oneofs + foreach (var accessor in fields.Oneofs) + { + var fieldDescriptor = accessor.GetCaseFieldDescriptor(message); + if (fieldDescriptor == null) + { + continue; + } + var fieldAccessor = fields[fieldDescriptor]; + object value = fieldAccessor.GetValue(message); + // Omit awkward (single) values such as unknown enum values + if (!fieldDescriptor.IsRepeated && !fieldDescriptor.IsMap && !CanWriteSingleValue(fieldDescriptor, value)) + { + continue; + } + + if (!first) + { + builder.Append(", "); + } + WriteString(builder, ToCamelCase(fieldDescriptor.Name)); + builder.Append(": "); + WriteValue(builder, fieldAccessor, value); + first = false; + } builder.Append(first ? "}" : " }"); } @@ -303,15 +344,8 @@ namespace Google.Protobuf } case FieldType.Enum: EnumValueDescriptor enumValue = descriptor.EnumType.FindValueByNumber((int) value); - if (enumValue != null) - { - WriteString(builder, enumValue.Name); - } - else - { - // ??? Need more documentation - builder.Append(((int) value).ToString("d", CultureInfo.InvariantCulture)); - } + // We will already have validated that this is a known value. + WriteString(builder, enumValue.Name); break; case FieldType.Fixed64: case FieldType.UInt64: @@ -354,6 +388,10 @@ namespace Google.Protobuf bool first = true; foreach (var value in list) { + if (!CanWriteSingleValue(accessor.Descriptor, value)) + { + continue; + } if (!first) { builder.Append(", "); @@ -373,6 +411,10 @@ namespace Google.Protobuf // This will box each pair. Could use IDictionaryEnumerator, but that's ugly in terms of disposal. foreach (DictionaryEntry pair in dictionary) { + if (!CanWriteSingleValue(valueType, pair.Value)) + { + continue; + } if (!first) { builder.Append(", "); @@ -409,6 +451,21 @@ namespace Google.Protobuf builder.Append(first ? "}" : " }"); } + /// + /// Returns whether or not a singular value can be represented in JSON. + /// Currently only relevant for enums, where unknown values can't be represented. + /// For repeated/map fields, this always returns true. + /// + private bool CanWriteSingleValue(FieldDescriptor descriptor, object value) + { + if (descriptor.FieldType == FieldType.Enum) + { + EnumValueDescriptor enumValue = descriptor.EnumType.FindValueByNumber((int) value); + return enumValue != null; + } + return true; + } + /// /// Writes a string (including leading and trailing double quotes) to a builder, escaping as required. /// -- cgit v1.2.3 From a1daeaba80570a673913f8184855219607a6f556 Mon Sep 17 00:00:00 2001 From: Josh Haberman Date: Fri, 10 Jul 2015 11:56:06 -0700 Subject: Conform to C89/C90 variable declaration rules. While we are C99 in general, the Ruby build system for building C extensions enables several flags that throw warnings for C89/C90 variable ordering rules. To avoid spewing a million warnings (or trying to specifically override these warnings with command-line flags, which would be tricky and possibly fragile) we conform to Ruby's world of C89/C90. Change-Id: I0e03e62d95068dfdfde112df0fb16a248a2f32a0 --- ruby/ext/google/protobuf_c/defs.c | 156 ++++++++++++---------- ruby/ext/google/protobuf_c/encode_decode.c | 193 ++++++++++++++++------------ ruby/ext/google/protobuf_c/map.c | 24 ++-- ruby/ext/google/protobuf_c/message.c | 97 +++++++++----- ruby/ext/google/protobuf_c/protobuf.c | 3 +- ruby/ext/google/protobuf_c/repeated_field.c | 80 +++++++----- ruby/ext/google/protobuf_c/storage.c | 48 ++++--- 7 files changed, 354 insertions(+), 247 deletions(-) diff --git a/ruby/ext/google/protobuf_c/defs.c b/ruby/ext/google/protobuf_c/defs.c index 8f9f33e2..a5ca1ba7 100644 --- a/ruby/ext/google/protobuf_c/defs.c +++ b/ruby/ext/google/protobuf_c/defs.c @@ -88,7 +88,7 @@ static upb_enumdef* check_enum_notfrozen(const upb_enumdef* def) { } \ #define DEFINE_SELF(type, var, rb_var) \ - type* var = ruby_to_ ## type(rb_var); + type* var = ruby_to_ ## type(rb_var) // Global singleton DescriptorPool. The user is free to create others, but this // is used by generated code. @@ -656,13 +656,13 @@ VALUE FieldDescriptor_label(VALUE _self) { VALUE FieldDescriptor_label_set(VALUE _self, VALUE label) { DEFINE_SELF(FieldDescriptor, self, _self); upb_fielddef* mut_def = check_field_notfrozen(self->fielddef); + upb_label_t upb_label = -1; + bool converted = false; + if (TYPE(label) != T_SYMBOL) { rb_raise(rb_eArgError, "Expected symbol for field label."); } - upb_label_t upb_label = -1; - bool converted = false; - #define CONVERT(upb, ruby) \ if (SYM2ID(label) == rb_intern( # ruby )) { \ upb_label = UPB_LABEL_ ## upb; \ @@ -740,10 +740,10 @@ VALUE FieldDescriptor_submsg_name(VALUE _self) { VALUE FieldDescriptor_submsg_name_set(VALUE _self, VALUE value) { DEFINE_SELF(FieldDescriptor, self, _self); upb_fielddef* mut_def = check_field_notfrozen(self->fielddef); + const char* str = get_str(value); if (!upb_fielddef_hassubdef(self->fielddef)) { rb_raise(rb_eTypeError, "FieldDescriptor does not have subdef."); } - const char* str = get_str(value); CHECK_UPB(upb_fielddef_setsubdefname(mut_def, str, &status), "Error setting submessage name"); return Qnil; @@ -760,10 +760,12 @@ VALUE FieldDescriptor_submsg_name_set(VALUE _self, VALUE value) { */ VALUE FieldDescriptor_subtype(VALUE _self) { DEFINE_SELF(FieldDescriptor, self, _self); + const upb_def* def; + if (!upb_fielddef_hassubdef(self->fielddef)) { return Qnil; } - const upb_def* def = upb_fielddef_subdef(self->fielddef); + def = upb_fielddef_subdef(self->fielddef); if (def == NULL) { return Qnil; } @@ -1187,14 +1189,15 @@ static VALUE msgdef_add_field(VALUE msgdef, */ VALUE MessageBuilderContext_optional(int argc, VALUE* argv, VALUE _self) { DEFINE_SELF(MessageBuilderContext, self, _self); + VALUE name, type, number, type_class; if (argc < 3) { rb_raise(rb_eArgError, "Expected at least 3 arguments."); } - VALUE name = argv[0]; - VALUE type = argv[1]; - VALUE number = argv[2]; - VALUE type_class = (argc > 3) ? argv[3] : Qnil; + name = argv[0]; + type = argv[1]; + number = argv[2]; + type_class = (argc > 3) ? argv[3] : Qnil; return msgdef_add_field(self->descriptor, "optional", name, type, number, type_class); @@ -1215,14 +1218,15 @@ VALUE MessageBuilderContext_optional(int argc, VALUE* argv, VALUE _self) { */ VALUE MessageBuilderContext_required(int argc, VALUE* argv, VALUE _self) { DEFINE_SELF(MessageBuilderContext, self, _self); + VALUE name, type, number, type_class; if (argc < 3) { rb_raise(rb_eArgError, "Expected at least 3 arguments."); } - VALUE name = argv[0]; - VALUE type = argv[1]; - VALUE number = argv[2]; - VALUE type_class = (argc > 3) ? argv[3] : Qnil; + name = argv[0]; + type = argv[1]; + number = argv[2]; + type_class = (argc > 3) ? argv[3] : Qnil; return msgdef_add_field(self->descriptor, "required", name, type, number, type_class); @@ -1239,14 +1243,15 @@ VALUE MessageBuilderContext_required(int argc, VALUE* argv, VALUE _self) { */ VALUE MessageBuilderContext_repeated(int argc, VALUE* argv, VALUE _self) { DEFINE_SELF(MessageBuilderContext, self, _self); + VALUE name, type, number, type_class; if (argc < 3) { rb_raise(rb_eArgError, "Expected at least 3 arguments."); } - VALUE name = argv[0]; - VALUE type = argv[1]; - VALUE number = argv[2]; - VALUE type_class = (argc > 3) ? argv[3] : Qnil; + name = argv[0]; + type = argv[1]; + number = argv[2]; + type_class = (argc > 3) ? argv[3] : Qnil; return msgdef_add_field(self->descriptor, "repeated", name, type, number, type_class); @@ -1266,15 +1271,17 @@ VALUE MessageBuilderContext_repeated(int argc, VALUE* argv, VALUE _self) { */ VALUE MessageBuilderContext_map(int argc, VALUE* argv, VALUE _self) { DEFINE_SELF(MessageBuilderContext, self, _self); + VALUE name, key_type, value_type, number, type_class; + VALUE mapentry_desc, mapentry_desc_name; if (argc < 4) { rb_raise(rb_eArgError, "Expected at least 4 arguments."); } - VALUE name = argv[0]; - VALUE key_type = argv[1]; - VALUE value_type = argv[2]; - VALUE number = argv[3]; - VALUE type_class = (argc > 4) ? argv[4] : Qnil; + name = argv[0]; + key_type = argv[1]; + value_type = argv[2]; + number = argv[3]; + type_class = (argc > 4) ? argv[4] : Qnil; // Validate the key type. We can't accept enums, messages, or floats/doubles // as map keys. (We exclude these explicitly, and the field-descriptor setter @@ -1290,55 +1297,67 @@ VALUE MessageBuilderContext_map(int argc, VALUE* argv, VALUE _self) { // Create a new message descriptor for the map entry message, and create a // repeated submessage field here with that type. - VALUE mapentry_desc = rb_class_new_instance(0, NULL, cDescriptor); - VALUE mapentry_desc_name = rb_funcall(self->descriptor, rb_intern("name"), 0); + mapentry_desc = rb_class_new_instance(0, NULL, cDescriptor); + mapentry_desc_name = rb_funcall(self->descriptor, rb_intern("name"), 0); mapentry_desc_name = rb_str_cat2(mapentry_desc_name, "_MapEntry_"); mapentry_desc_name = rb_str_cat2(mapentry_desc_name, rb_id2name(SYM2ID(name))); Descriptor_name_set(mapentry_desc, mapentry_desc_name); - // The 'mapentry' attribute has no Ruby setter because we do not want the user - // attempting to DIY the setup below; we want to ensure that the fields are - // correct. So we reach into the msgdef here to set the bit manually. - Descriptor* mapentry_desc_self = ruby_to_Descriptor(mapentry_desc); - upb_msgdef_setmapentry((upb_msgdef*)mapentry_desc_self->msgdef, true); - - // optional key = 1; - VALUE key_field = rb_class_new_instance(0, NULL, cFieldDescriptor); - FieldDescriptor_name_set(key_field, rb_str_new2("key")); - FieldDescriptor_label_set(key_field, ID2SYM(rb_intern("optional"))); - FieldDescriptor_number_set(key_field, INT2NUM(1)); - FieldDescriptor_type_set(key_field, key_type); - Descriptor_add_field(mapentry_desc, key_field); - - // optional value = 2; - VALUE value_field = rb_class_new_instance(0, NULL, cFieldDescriptor); - FieldDescriptor_name_set(value_field, rb_str_new2("value")); - FieldDescriptor_label_set(value_field, ID2SYM(rb_intern("optional"))); - FieldDescriptor_number_set(value_field, INT2NUM(2)); - FieldDescriptor_type_set(value_field, value_type); - if (type_class != Qnil) { - VALUE submsg_name = rb_str_new2("."); // prepend '.' to make name absolute. - submsg_name = rb_str_append(submsg_name, type_class); - FieldDescriptor_submsg_name_set(value_field, submsg_name); + { + // The 'mapentry' attribute has no Ruby setter because we do not want the + // user attempting to DIY the setup below; we want to ensure that the fields + // are correct. So we reach into the msgdef here to set the bit manually. + Descriptor* mapentry_desc_self = ruby_to_Descriptor(mapentry_desc); + upb_msgdef_setmapentry((upb_msgdef*)mapentry_desc_self->msgdef, true); } - Descriptor_add_field(mapentry_desc, value_field); - // Add the map-entry message type to the current builder, and use the type to - // create the map field itself. - Builder* builder_self = ruby_to_Builder(self->builder); - rb_ary_push(builder_self->pending_list, mapentry_desc); + { + // optional key = 1; + VALUE key_field = rb_class_new_instance(0, NULL, cFieldDescriptor); + FieldDescriptor_name_set(key_field, rb_str_new2("key")); + FieldDescriptor_label_set(key_field, ID2SYM(rb_intern("optional"))); + FieldDescriptor_number_set(key_field, INT2NUM(1)); + FieldDescriptor_type_set(key_field, key_type); + Descriptor_add_field(mapentry_desc, key_field); + } - VALUE map_field = rb_class_new_instance(0, NULL, cFieldDescriptor); - VALUE name_str = rb_str_new2(rb_id2name(SYM2ID(name))); - FieldDescriptor_name_set(map_field, name_str); - FieldDescriptor_number_set(map_field, number); - FieldDescriptor_label_set(map_field, ID2SYM(rb_intern("repeated"))); - FieldDescriptor_type_set(map_field, ID2SYM(rb_intern("message"))); - VALUE submsg_name = rb_str_new2("."); // prepend '.' to make name absolute. - submsg_name = rb_str_append(submsg_name, mapentry_desc_name); - FieldDescriptor_submsg_name_set(map_field, submsg_name); - Descriptor_add_field(self->descriptor, map_field); + { + // optional value = 2; + VALUE value_field = rb_class_new_instance(0, NULL, cFieldDescriptor); + FieldDescriptor_name_set(value_field, rb_str_new2("value")); + FieldDescriptor_label_set(value_field, ID2SYM(rb_intern("optional"))); + FieldDescriptor_number_set(value_field, INT2NUM(2)); + FieldDescriptor_type_set(value_field, value_type); + if (type_class != Qnil) { + VALUE submsg_name = rb_str_new2("."); // prepend '.' to make absolute. + submsg_name = rb_str_append(submsg_name, type_class); + FieldDescriptor_submsg_name_set(value_field, submsg_name); + } + Descriptor_add_field(mapentry_desc, value_field); + } + + { + // Add the map-entry message type to the current builder, and use the type + // to create the map field itself. + Builder* builder_self = ruby_to_Builder(self->builder); + rb_ary_push(builder_self->pending_list, mapentry_desc); + } + + { + VALUE map_field = rb_class_new_instance(0, NULL, cFieldDescriptor); + VALUE name_str = rb_str_new2(rb_id2name(SYM2ID(name))); + VALUE submsg_name; + + FieldDescriptor_name_set(map_field, name_str); + FieldDescriptor_number_set(map_field, number); + FieldDescriptor_label_set(map_field, ID2SYM(rb_intern("repeated"))); + FieldDescriptor_type_set(map_field, ID2SYM(rb_intern("message"))); + submsg_name = rb_str_new2("."); // prepend '.' to make name absolute. + submsg_name = rb_str_append(submsg_name, mapentry_desc_name); + FieldDescriptor_submsg_name_set(map_field, submsg_name); + Descriptor_add_field(self->descriptor, map_field); + } return Qnil; } @@ -1434,14 +1453,15 @@ VALUE OneofBuilderContext_initialize(VALUE _self, */ VALUE OneofBuilderContext_optional(int argc, VALUE* argv, VALUE _self) { DEFINE_SELF(OneofBuilderContext, self, _self); + VALUE name, type, number, type_class; if (argc < 3) { rb_raise(rb_eArgError, "Expected at least 3 arguments."); } - VALUE name = argv[0]; - VALUE type = argv[1]; - VALUE number = argv[2]; - VALUE type_class = (argc > 3) ? argv[3] : Qnil; + name = argv[0]; + type = argv[1]; + number = argv[2]; + type_class = (argc > 3) ? argv[3] : Qnil; return msgdef_add_field(self->descriptor, "optional", name, type, number, type_class); diff --git a/ruby/ext/google/protobuf_c/encode_decode.c b/ruby/ext/google/protobuf_c/encode_decode.c index fe249d45..68f3b75d 100644 --- a/ruby/ext/google/protobuf_c/encode_decode.c +++ b/ruby/ext/google/protobuf_c/encode_decode.c @@ -175,11 +175,11 @@ static void *appendsubmsg_handler(void *closure, const void *hd) { VALUE subdesc = get_def_obj((void*)submsgdata->md); VALUE subklass = Descriptor_msgclass(subdesc); + MessageHeader* submsg; VALUE submsg_rb = rb_class_new_instance(0, NULL, subklass); RepeatedField_push(ary, submsg_rb); - MessageHeader* submsg; TypedData_Get_Struct(submsg_rb, MessageHeader, &Message_type, submsg); return submsg; } @@ -191,14 +191,15 @@ static void *submsg_handler(void *closure, const void *hd) { VALUE subdesc = get_def_obj((void*)submsgdata->md); VALUE subklass = Descriptor_msgclass(subdesc); + VALUE submsg_rb; + MessageHeader* submsg; if (DEREF(msg, submsgdata->ofs, VALUE) == Qnil) { DEREF(msg, submsgdata->ofs, VALUE) = rb_class_new_instance(0, NULL, subklass); } - VALUE submsg_rb = DEREF(msg, submsgdata->ofs, VALUE); - MessageHeader* submsg; + submsg_rb = DEREF(msg, submsgdata->ofs, VALUE); TypedData_Get_Struct(submsg_rb, MessageHeader, &Message_type, submsg); return submsg; } @@ -254,12 +255,14 @@ static bool endmap_handler(void *closure, const void *hd, upb_status* s) { &frame->key_storage); VALUE value_field_typeclass = Qnil; + VALUE value; + if (mapdata->value_field_type == UPB_TYPE_MESSAGE || mapdata->value_field_type == UPB_TYPE_ENUM) { value_field_typeclass = get_def_obj(mapdata->value_field_subdef); } - VALUE value = native_slot_get( + value = native_slot_get( mapdata->value_field_type, value_field_typeclass, &frame->value_storage); @@ -280,15 +283,14 @@ static map_handlerdata_t* new_map_handlerdata( size_t ofs, const upb_msgdef* mapentry_def, Descriptor* desc) { - + const upb_fielddef* key_field; + const upb_fielddef* value_field; map_handlerdata_t* hd = ALLOC(map_handlerdata_t); hd->ofs = ofs; - const upb_fielddef* key_field = upb_msgdef_itof(mapentry_def, - MAP_KEY_FIELD); + key_field = upb_msgdef_itof(mapentry_def, MAP_KEY_FIELD); assert(key_field != NULL); hd->key_field_type = upb_fielddef_type(key_field); - const upb_fielddef* value_field = upb_msgdef_itof(mapentry_def, - MAP_VALUE_FIELD); + value_field = upb_msgdef_itof(mapentry_def, MAP_VALUE_FIELD); assert(value_field != NULL); hd->value_field_type = upb_fielddef_type(value_field); hd->value_field_subdef = upb_fielddef_subdef(value_field); @@ -354,6 +356,8 @@ static void *oneofsubmsg_handler(void *closure, VALUE subdesc = get_def_obj((void*)oneofdata->md); VALUE subklass = Descriptor_msgclass(subdesc); + VALUE submsg_rb; + MessageHeader* submsg; if (oldcase != oneofdata->oneof_case_num || DEREF(msg, oneofdata->ofs, VALUE) == Qnil) { @@ -369,8 +373,7 @@ static void *oneofsubmsg_handler(void *closure, DEREF(msg, oneofdata->case_ofs, uint32_t) = oneofdata->oneof_case_num; - VALUE submsg_rb = DEREF(msg, oneofdata->ofs, VALUE); - MessageHeader* submsg; + submsg_rb = DEREF(msg, oneofdata->ofs, VALUE); TypedData_Get_Struct(submsg_rb, MessageHeader, &Message_type, submsg); return submsg; } @@ -465,8 +468,9 @@ static void add_handlers_for_mapfield(upb_handlers* h, Descriptor* desc) { const upb_msgdef* map_msgdef = upb_fielddef_msgsubdef(fielddef); map_handlerdata_t* hd = new_map_handlerdata(offset, map_msgdef, desc); - upb_handlers_addcleanup(h, hd, free); upb_handlerattr attr = UPB_HANDLERATTR_INITIALIZER; + + upb_handlers_addcleanup(h, hd, free); upb_handlerattr_sethandlerdata(&attr, hd); upb_handlers_setstartsubmsg(h, fielddef, startmapentry_handler, &attr); upb_handlerattr_uninit(&attr); @@ -479,8 +483,9 @@ static void add_handlers_for_mapentry(const upb_msgdef* msgdef, const upb_fielddef* key_field = map_entry_key(msgdef); const upb_fielddef* value_field = map_entry_value(msgdef); map_handlerdata_t* hd = new_map_handlerdata(0, msgdef, desc); - upb_handlers_addcleanup(h, hd, free); upb_handlerattr attr = UPB_HANDLERATTR_INITIALIZER; + + upb_handlers_addcleanup(h, hd, free); upb_handlerattr_sethandlerdata(&attr, hd); upb_handlers_setendmsg(h, endmap_handler, &attr); @@ -542,6 +547,7 @@ static void add_handlers_for_oneof_field(upb_handlers *h, static void add_handlers_for_message(const void *closure, upb_handlers *h) { const upb_msgdef* msgdef = upb_handlers_msgdef(h); Descriptor* desc = ruby_to_Descriptor(get_def_obj((void*)msgdef)); + upb_msg_field_iter i; // If this is a mapentry message type, set up a special set of handlers and // bail out of the normal (user-defined) message type handling. @@ -558,7 +564,6 @@ static void add_handlers_for_message(const void *closure, upb_handlers *h) { desc->layout = create_layout(desc->msgdef); } - upb_msg_field_iter i; for (upb_msg_field_begin(&i, desc->msgdef); !upb_msg_field_done(&i); upb_msg_field_next(&i)) { @@ -610,8 +615,7 @@ const upb_pbdecodermethod *new_fillmsg_decodermethod(Descriptor* desc, upb_pbdecodermethodopts opts; upb_pbdecodermethodopts_init(&opts, handlers); - const upb_pbdecodermethod *ret = upb_pbdecodermethod_new(&opts, owner); - return ret; + return upb_pbdecodermethod_new(&opts, owner); } static const upb_pbdecodermethod *msgdef_decodermethod(Descriptor* desc) { @@ -677,28 +681,31 @@ VALUE Message_decode(VALUE klass, VALUE data) { VALUE descriptor = rb_ivar_get(klass, descriptor_instancevar_interned); Descriptor* desc = ruby_to_Descriptor(descriptor); VALUE msgklass = Descriptor_msgclass(descriptor); + VALUE msg_rb; + MessageHeader* msg; if (TYPE(data) != T_STRING) { rb_raise(rb_eArgError, "Expected string for binary protobuf data."); } - VALUE msg_rb = rb_class_new_instance(0, NULL, msgklass); - MessageHeader* msg; + msg_rb = rb_class_new_instance(0, NULL, msgklass); TypedData_Get_Struct(msg_rb, MessageHeader, &Message_type, msg); - const upb_pbdecodermethod* method = msgdef_decodermethod(desc); - const upb_handlers* h = upb_pbdecodermethod_desthandlers(method); - stackenv se; - stackenv_init(&se, "Error occurred during parsing: %s"); + { + const upb_pbdecodermethod* method = msgdef_decodermethod(desc); + const upb_handlers* h = upb_pbdecodermethod_desthandlers(method); + stackenv se; + upb_sink sink; + upb_pbdecoder* decoder; + stackenv_init(&se, "Error occurred during parsing: %s"); - upb_sink sink; - upb_sink_reset(&sink, h, msg); - upb_pbdecoder* decoder = - upb_pbdecoder_create(&se.env, method, &sink); - upb_bufsrc_putbuf(RSTRING_PTR(data), RSTRING_LEN(data), - upb_pbdecoder_input(decoder)); + upb_sink_reset(&sink, h, msg); + decoder = upb_pbdecoder_create(&se.env, method, &sink); + upb_bufsrc_putbuf(RSTRING_PTR(data), RSTRING_LEN(data), + upb_pbdecoder_input(decoder)); - stackenv_uninit(&se); + stackenv_uninit(&se); + } return msg_rb; } @@ -715,6 +722,8 @@ VALUE Message_decode_json(VALUE klass, VALUE data) { VALUE descriptor = rb_ivar_get(klass, descriptor_instancevar_interned); Descriptor* desc = ruby_to_Descriptor(descriptor); VALUE msgklass = Descriptor_msgclass(descriptor); + VALUE msg_rb; + MessageHeader* msg; if (TYPE(data) != T_STRING) { rb_raise(rb_eArgError, "Expected string for JSON data."); @@ -723,20 +732,22 @@ VALUE Message_decode_json(VALUE klass, VALUE data) { // convert, because string handlers pass data directly to message string // fields. - VALUE msg_rb = rb_class_new_instance(0, NULL, msgklass); - MessageHeader* msg; + msg_rb = rb_class_new_instance(0, NULL, msgklass); TypedData_Get_Struct(msg_rb, MessageHeader, &Message_type, msg); - stackenv se; - stackenv_init(&se, "Error occurred during parsing: %s"); + { + stackenv se; + upb_sink sink; + upb_json_parser* parser; + stackenv_init(&se, "Error occurred during parsing: %s"); - upb_sink sink; - upb_sink_reset(&sink, get_fill_handlers(desc), msg); - upb_json_parser* parser = upb_json_parser_create(&se.env, &sink); - upb_bufsrc_putbuf(RSTRING_PTR(data), RSTRING_LEN(data), - upb_json_parser_input(parser)); + upb_sink_reset(&sink, get_fill_handlers(desc), msg); + parser = upb_json_parser_create(&se.env, &sink); + upb_bufsrc_putbuf(RSTRING_PTR(data), RSTRING_LEN(data), + upb_json_parser_input(parser)); - stackenv_uninit(&se); + stackenv_uninit(&se); + } return msg_rb; } @@ -767,12 +778,12 @@ static void *stringsink_start(void *_sink, const void *hd, size_t size_hint) { static size_t stringsink_string(void *_sink, const void *hd, const char *ptr, size_t len, const upb_bufhandle *handle) { - UPB_UNUSED(hd); - UPB_UNUSED(handle); - stringsink *sink = _sink; size_t new_size = sink->size; + UPB_UNUSED(hd); + UPB_UNUSED(handle); + while (sink->len + len > new_size) { new_size *= 2; } @@ -826,10 +837,11 @@ static upb_selector_t getsel(const upb_fielddef *f, upb_handlertype_t type) { } static void putstr(VALUE str, const upb_fielddef *f, upb_sink *sink) { + upb_sink subsink; + if (str == Qnil) return; assert(BUILTIN_TYPE(str) == RUBY_T_STRING); - upb_sink subsink; // Ensure that the string has the correct encoding. We also check at field-set // time, but the user may have mutated the string object since then. @@ -844,11 +856,14 @@ static void putstr(VALUE str, const upb_fielddef *f, upb_sink *sink) { static void putsubmsg(VALUE submsg, const upb_fielddef *f, upb_sink *sink, int depth) { + upb_sink subsink; + VALUE descriptor; + Descriptor* subdesc; + if (submsg == Qnil) return; - upb_sink subsink; - VALUE descriptor = rb_ivar_get(submsg, descriptor_instancevar_interned); - Descriptor* subdesc = ruby_to_Descriptor(descriptor); + descriptor = rb_ivar_get(submsg, descriptor_instancevar_interned); + subdesc = ruby_to_Descriptor(descriptor); upb_sink_startsubmsg(sink, getsel(f, UPB_HANDLER_STARTSUBMSG), &subsink); putmsg(submsg, subdesc, &subsink, depth + 1); @@ -857,19 +872,20 @@ static void putsubmsg(VALUE submsg, const upb_fielddef *f, upb_sink *sink, static void putary(VALUE ary, const upb_fielddef *f, upb_sink *sink, int depth) { - if (ary == Qnil) return; - upb_sink subsink; + upb_fieldtype_t type = upb_fielddef_type(f); + upb_selector_t sel = 0; + int size; + + if (ary == Qnil) return; upb_sink_startseq(sink, getsel(f, UPB_HANDLER_STARTSEQ), &subsink); - upb_fieldtype_t type = upb_fielddef_type(f); - upb_selector_t sel = 0; if (upb_fielddef_isprimitive(f)) { sel = getsel(f, upb_handlers_getprimitivehandlertype(f)); } - int size = NUM2INT(RepeatedField_length(ary)); + size = NUM2INT(RepeatedField_length(ary)); for (int i = 0; i < size; i++) { void* memory = RepeatedField_index_native(ary, i); switch (type) { @@ -952,21 +968,25 @@ static void put_ruby_value(VALUE value, static void putmap(VALUE map, const upb_fielddef *f, upb_sink *sink, int depth) { - if (map == Qnil) return; - Map* self = ruby_to_Map(map); - + Map* self; upb_sink subsink; + const upb_fielddef* key_field; + const upb_fielddef* value_field; + Map_iter it; + + if (map == Qnil) return; + self = ruby_to_Map(map); upb_sink_startseq(sink, getsel(f, UPB_HANDLER_STARTSEQ), &subsink); assert(upb_fielddef_type(f) == UPB_TYPE_MESSAGE); - const upb_fielddef* key_field = map_field_key(f); - const upb_fielddef* value_field = map_field_value(f); + key_field = map_field_key(f); + value_field = map_field_value(f); - Map_iter it; for (Map_begin(map, &it); !Map_done(&it); Map_next(&it)) { VALUE key = Map_iter_key(&it); VALUE value = Map_iter_value(&it); + upb_status status; upb_sink entry_sink; upb_sink_startsubmsg(&subsink, getsel(f, UPB_HANDLER_STARTSUBMSG), @@ -977,7 +997,6 @@ static void putmap(VALUE map, const upb_fielddef *f, upb_sink *sink, put_ruby_value(value, value_field, self->value_type_class, depth + 1, &entry_sink); - upb_status status; upb_sink_endmsg(&entry_sink, &status); upb_sink_endsubmsg(&subsink, getsel(f, UPB_HANDLER_ENDSUBMSG)); } @@ -987,6 +1006,10 @@ static void putmap(VALUE map, const upb_fielddef *f, upb_sink *sink, static void putmsg(VALUE msg_rb, const Descriptor* desc, upb_sink *sink, int depth) { + MessageHeader* msg; + upb_msg_field_iter i; + upb_status status; + upb_sink_startmsg(sink); // Protect against cycles (possible because users may freely reassign message @@ -996,10 +1019,8 @@ static void putmsg(VALUE msg_rb, const Descriptor* desc, "Maximum recursion depth exceeded during encoding."); } - MessageHeader* msg; TypedData_Get_Struct(msg_rb, MessageHeader, &Message_type, msg); - upb_msg_field_iter i; for (upb_msg_field_begin(&i, desc->msgdef); !upb_msg_field_done(&i); upb_msg_field_next(&i)) { @@ -1071,7 +1092,6 @@ static void putmsg(VALUE msg_rb, const Descriptor* desc, } } - upb_status status; upb_sink_endmsg(sink, &status); } @@ -1106,22 +1126,26 @@ VALUE Message_encode(VALUE klass, VALUE msg_rb) { stringsink sink; stringsink_init(&sink); - const upb_handlers* serialize_handlers = - msgdef_pb_serialize_handlers(desc); + { + const upb_handlers* serialize_handlers = + msgdef_pb_serialize_handlers(desc); - stackenv se; - stackenv_init(&se, "Error occurred during encoding: %s"); - upb_pb_encoder* encoder = - upb_pb_encoder_create(&se.env, serialize_handlers, &sink.sink); + stackenv se; + upb_pb_encoder* encoder; + VALUE ret; - putmsg(msg_rb, desc, upb_pb_encoder_input(encoder), 0); + stackenv_init(&se, "Error occurred during encoding: %s"); + encoder = upb_pb_encoder_create(&se.env, serialize_handlers, &sink.sink); - VALUE ret = rb_str_new(sink.ptr, sink.len); + putmsg(msg_rb, desc, upb_pb_encoder_input(encoder), 0); - stackenv_uninit(&se); - stringsink_uninit(&sink); + ret = rb_str_new(sink.ptr, sink.len); - return ret; + stackenv_uninit(&se); + stringsink_uninit(&sink); + + return ret; + } } /* @@ -1137,21 +1161,24 @@ VALUE Message_encode_json(VALUE klass, VALUE msg_rb) { stringsink sink; stringsink_init(&sink); - const upb_handlers* serialize_handlers = - msgdef_json_serialize_handlers(desc); + { + const upb_handlers* serialize_handlers = + msgdef_json_serialize_handlers(desc); + upb_json_printer* printer; + stackenv se; + VALUE ret; - stackenv se; - stackenv_init(&se, "Error occurred during encoding: %s"); - upb_json_printer* printer = - upb_json_printer_create(&se.env, serialize_handlers, &sink.sink); + stackenv_init(&se, "Error occurred during encoding: %s"); + printer = upb_json_printer_create(&se.env, serialize_handlers, &sink.sink); - putmsg(msg_rb, desc, upb_json_printer_input(printer), 0); + putmsg(msg_rb, desc, upb_json_printer_input(printer), 0); - VALUE ret = rb_str_new(sink.ptr, sink.len); + ret = rb_str_new(sink.ptr, sink.len); - stackenv_uninit(&se); - stringsink_uninit(&sink); + stackenv_uninit(&se); + stringsink_uninit(&sink); - return ret; + return ret; + } } diff --git a/ruby/ext/google/protobuf_c/map.c b/ruby/ext/google/protobuf_c/map.c index 3436e09a..5043f395 100644 --- a/ruby/ext/google/protobuf_c/map.c +++ b/ruby/ext/google/protobuf_c/map.c @@ -167,9 +167,9 @@ void Map_free(void* _self) { VALUE Map_alloc(VALUE klass) { Map* self = ALLOC(Map); + VALUE ret = TypedData_Wrap_Struct(klass, &Map_type, self); memset(self, 0, sizeof(Map)); self->value_type_class = Qnil; - VALUE ret = TypedData_Wrap_Struct(klass, &Map_type, self); return ret; } @@ -215,6 +215,7 @@ static bool needs_typeclass(upb_fieldtype_t type) { */ VALUE Map_init(int argc, VALUE* argv, VALUE _self) { Map* self = ruby_to_Map(_self); + int init_value_arg; // We take either two args (:key_type, :value_type), three args (:key_type, // :value_type, "ValueMessageType"), or four args (the above plus an initial @@ -241,7 +242,7 @@ VALUE Map_init(int argc, VALUE* argv, VALUE _self) { rb_raise(rb_eArgError, "Invalid key type for map."); } - int init_value_arg = 2; + init_value_arg = 2; if (needs_typeclass(self->value_type) && argc > 2) { self->value_type_class = argv[2]; validate_type_class(self->value_type, self->value_type_class); @@ -356,9 +357,9 @@ VALUE Map_index(VALUE _self, VALUE key) { char keybuf[TABLE_KEY_BUF_LENGTH]; const char* keyval = NULL; size_t length = 0; + upb_value v; table_key(self, key, keybuf, &keyval, &length); - upb_value v; if (upb_strtable_lookup2(&self->table, keyval, length, &v)) { void* mem = value_memory(&v); return native_slot_get(self->value_type, self->value_type_class, mem); @@ -381,10 +382,11 @@ VALUE Map_index_set(VALUE _self, VALUE key, VALUE value) { char keybuf[TABLE_KEY_BUF_LENGTH]; const char* keyval = NULL; size_t length = 0; + upb_value v; + void* mem; table_key(self, key, keybuf, &keyval, &length); - upb_value v; - void* mem = value_memory(&v); + mem = value_memory(&v); native_slot_set(self->value_type, self->value_type_class, mem, value); // Replace any existing value by issuing a 'remove' operation first. @@ -432,9 +434,9 @@ VALUE Map_delete(VALUE _self, VALUE key) { char keybuf[TABLE_KEY_BUF_LENGTH]; const char* keyval = NULL; size_t length = 0; + upb_value v; table_key(self, key, keybuf, &keyval, &length); - upb_value v; if (upb_strtable_remove2(&self->table, keyval, length, &v)) { void* mem = value_memory(&v); return native_slot_get(self->value_type, self->value_type_class, mem); @@ -564,6 +566,8 @@ VALUE Map_deep_copy(VALUE _self) { */ VALUE Map_eq(VALUE _self, VALUE _other) { Map* self = ruby_to_Map(_self); + Map* other; + upb_strtable_iter it; // Allow comparisons to Ruby hashmaps by converting to a temporary Map // instance. Slow, but workable. @@ -573,7 +577,7 @@ VALUE Map_eq(VALUE _self, VALUE _other) { _other = other_map; } - Map* other = ruby_to_Map(_other); + other = ruby_to_Map(_other); if (self == other) { return Qtrue; @@ -589,7 +593,6 @@ VALUE Map_eq(VALUE _self, VALUE _other) { // For each member of self, check that an equal member exists at the same key // in other. - upb_strtable_iter it; for (upb_strtable_begin(&it, &self->table); !upb_strtable_done(&it); upb_strtable_next(&it)) { @@ -719,6 +722,7 @@ VALUE Map_merge_into_self(VALUE _self, VALUE hashmap) { Map* self = ruby_to_Map(_self); Map* other = ruby_to_Map(hashmap); + upb_strtable_iter it; if (self->key_type != other->key_type || self->value_type != other->value_type || @@ -726,19 +730,19 @@ VALUE Map_merge_into_self(VALUE _self, VALUE hashmap) { rb_raise(rb_eArgError, "Attempt to merge Map with mismatching types"); } - upb_strtable_iter it; for (upb_strtable_begin(&it, &other->table); !upb_strtable_done(&it); upb_strtable_next(&it)) { // Replace any existing value by issuing a 'remove' operation first. + upb_value v; upb_value oldv; upb_strtable_remove2(&self->table, upb_strtable_iter_key(&it), upb_strtable_iter_keylength(&it), &oldv); - upb_value v = upb_strtable_iter_value(&it); + v = upb_strtable_iter_value(&it); upb_strtable_insert2(&self->table, upb_strtable_iter_key(&it), upb_strtable_iter_keylength(&it), diff --git a/ruby/ext/google/protobuf_c/message.c b/ruby/ext/google/protobuf_c/message.c index 4be1c8c8..ebe2f1ab 100644 --- a/ruby/ext/google/protobuf_c/message.c +++ b/ruby/ext/google/protobuf_c/message.c @@ -57,11 +57,13 @@ VALUE Message_alloc(VALUE klass) { Descriptor* desc = ruby_to_Descriptor(descriptor); MessageHeader* msg = (MessageHeader*)ALLOC_N( uint8_t, sizeof(MessageHeader) + desc->layout->size); + VALUE ret; + memset(Message_data(msg), 0, desc->layout->size); // We wrap first so that everything in the message object is GC-rooted in case // a collection happens during object creation in layout_init(). - VALUE ret = TypedData_Wrap_Struct(klass, &Message_type, msg); + ret = TypedData_Wrap_Struct(klass, &Message_type, msg); msg->descriptor = desc; rb_ivar_set(ret, descriptor_instancevar_interned, descriptor); @@ -71,29 +73,34 @@ VALUE Message_alloc(VALUE klass) { } static VALUE which_oneof_field(MessageHeader* self, const upb_oneofdef* o) { + upb_oneof_iter it; + size_t case_ofs; + uint32_t oneof_case; + const upb_fielddef* first_field; + const upb_fielddef* f; + // If no fields in the oneof, always nil. if (upb_oneofdef_numfields(o) == 0) { return Qnil; } // Grab the first field in the oneof so we can get its layout info to find the // oneof_case field. - upb_oneof_iter it; upb_oneof_begin(&it, o); assert(!upb_oneof_done(&it)); - const upb_fielddef* first_field = upb_oneof_iter_field(&it); + first_field = upb_oneof_iter_field(&it); assert(upb_fielddef_containingoneof(first_field) != NULL); - size_t case_ofs = + case_ofs = self->descriptor->layout-> fields[upb_fielddef_index(first_field)].case_offset; - uint32_t oneof_case = *((uint32_t*)((char*)Message_data(self) + case_ofs)); + oneof_case = *((uint32_t*)((char*)Message_data(self) + case_ofs)); if (oneof_case == ONEOF_CASE_NONE) { return Qnil; } // oneof_case is a field index, so find that field. - const upb_fielddef* f = upb_oneofdef_itof(o, oneof_case); + f = upb_oneofdef_itof(o, oneof_case); assert(f != NULL); return ID2SYM(rb_intern(upb_fielddef_name(f))); @@ -118,18 +125,25 @@ static VALUE which_oneof_field(MessageHeader* self, const upb_oneofdef* o) { */ VALUE Message_method_missing(int argc, VALUE* argv, VALUE _self) { MessageHeader* self; + VALUE method_name, method_str; + char* name; + size_t name_len; + bool setter; + const upb_oneofdef* o; + const upb_fielddef* f; + TypedData_Get_Struct(_self, MessageHeader, &Message_type, self); if (argc < 1) { rb_raise(rb_eArgError, "Expected method name as first argument."); } - VALUE method_name = argv[0]; + method_name = argv[0]; if (!SYMBOL_P(method_name)) { rb_raise(rb_eArgError, "Expected symbol as method name."); } - VALUE method_str = rb_id2str(SYM2ID(method_name)); - char* name = RSTRING_PTR(method_str); - size_t name_len = RSTRING_LEN(method_str); - bool setter = false; + method_str = rb_id2str(SYM2ID(method_name)); + name = RSTRING_PTR(method_str); + name_len = RSTRING_LEN(method_str); + setter = false; // Setters have names that end in '='. if (name[name_len - 1] == '=') { @@ -138,7 +152,7 @@ VALUE Message_method_missing(int argc, VALUE* argv, VALUE _self) { } // Check for a oneof name first. - const upb_oneofdef* o = upb_msgdef_ntoo(self->descriptor->msgdef, + o = upb_msgdef_ntoo(self->descriptor->msgdef, name, name_len); if (o != NULL) { if (setter) { @@ -148,7 +162,7 @@ VALUE Message_method_missing(int argc, VALUE* argv, VALUE _self) { } // Otherwise, check for a field with that name. - const upb_fielddef* f = upb_msgdef_ntof(self->descriptor->msgdef, + f = upb_msgdef_ntof(self->descriptor->msgdef, name, name_len); if (f == NULL) { @@ -168,6 +182,9 @@ VALUE Message_method_missing(int argc, VALUE* argv, VALUE _self) { int Message_initialize_kwarg(VALUE key, VALUE val, VALUE _self) { MessageHeader* self; + VALUE method_str; + char* name; + const upb_fielddef* f; TypedData_Get_Struct(_self, MessageHeader, &Message_type, self); if (!SYMBOL_P(key)) { @@ -175,27 +192,31 @@ int Message_initialize_kwarg(VALUE key, VALUE val, VALUE _self) { "Expected symbols as hash keys in initialization map."); } - VALUE method_str = rb_id2str(SYM2ID(key)); - char* name = RSTRING_PTR(method_str); - const upb_fielddef* f = upb_msgdef_ntofz(self->descriptor->msgdef, name); + method_str = rb_id2str(SYM2ID(key)); + name = RSTRING_PTR(method_str); + f = upb_msgdef_ntofz(self->descriptor->msgdef, name); if (f == NULL) { rb_raise(rb_eArgError, "Unknown field name in initialization map entry."); } if (is_map_field(f)) { + VALUE map; + if (TYPE(val) != T_HASH) { rb_raise(rb_eArgError, "Expected Hash object as initializer value for map field."); } - VALUE map = layout_get(self->descriptor->layout, Message_data(self), f); + map = layout_get(self->descriptor->layout, Message_data(self), f); Map_merge_into_self(map, val); } else if (upb_fielddef_label(f) == UPB_LABEL_REPEATED) { + VALUE ary; + if (TYPE(val) != T_ARRAY) { rb_raise(rb_eArgError, "Expected array as initializer value for repeated field."); } - VALUE ary = layout_get(self->descriptor->layout, Message_data(self), f); + ary = layout_get(self->descriptor->layout, Message_data(self), f); for (int i = 0; i < RARRAY_LEN(val); i++) { RepeatedField_push(ary, rb_ary_entry(val, i)); } @@ -218,13 +239,15 @@ int Message_initialize_kwarg(VALUE key, VALUE val, VALUE _self) { * Message class are provided on each concrete message class. */ VALUE Message_initialize(int argc, VALUE* argv, VALUE _self) { + VALUE hash_args; + if (argc == 0) { return Qnil; } if (argc != 1) { rb_raise(rb_eArgError, "Expected 0 or 1 arguments."); } - VALUE hash_args = argv[0]; + hash_args = argv[0]; if (TYPE(hash_args) != T_HASH) { rb_raise(rb_eArgError, "Expected hash arguments."); } @@ -241,10 +264,11 @@ VALUE Message_initialize(int argc, VALUE* argv, VALUE _self) { */ VALUE Message_dup(VALUE _self) { MessageHeader* self; + VALUE new_msg; + MessageHeader* new_msg_self; TypedData_Get_Struct(_self, MessageHeader, &Message_type, self); - VALUE new_msg = rb_class_new_instance(0, NULL, CLASS_OF(_self)); - MessageHeader* new_msg_self; + new_msg = rb_class_new_instance(0, NULL, CLASS_OF(_self)); TypedData_Get_Struct(new_msg, MessageHeader, &Message_type, new_msg_self); layout_dup(self->descriptor->layout, @@ -257,10 +281,11 @@ VALUE Message_dup(VALUE _self) { // Internal only; used by Google::Protobuf.deep_copy. VALUE Message_deep_copy(VALUE _self) { MessageHeader* self; + MessageHeader* new_msg_self; + VALUE new_msg; TypedData_Get_Struct(_self, MessageHeader, &Message_type, self); - VALUE new_msg = rb_class_new_instance(0, NULL, CLASS_OF(_self)); - MessageHeader* new_msg_self; + new_msg = rb_class_new_instance(0, NULL, CLASS_OF(_self)); TypedData_Get_Struct(new_msg, MessageHeader, &Message_type, new_msg_self); layout_deep_copy(self->descriptor->layout, @@ -281,9 +306,8 @@ VALUE Message_deep_copy(VALUE _self) { */ VALUE Message_eq(VALUE _self, VALUE _other) { MessageHeader* self; - TypedData_Get_Struct(_self, MessageHeader, &Message_type, self); - MessageHeader* other; + TypedData_Get_Struct(_self, MessageHeader, &Message_type, self); TypedData_Get_Struct(_other, MessageHeader, &Message_type, other); if (self->descriptor != other->descriptor) { @@ -318,9 +342,10 @@ VALUE Message_hash(VALUE _self) { */ VALUE Message_inspect(VALUE _self) { MessageHeader* self; + VALUE str; TypedData_Get_Struct(_self, MessageHeader, &Message_type, self); - VALUE str = rb_str_new2("<"); + str = rb_str_new2("<"); str = rb_str_append(str, rb_str_new2(rb_class2name(CLASS_OF(_self)))); str = rb_str_cat2(str, ": "); str = rb_str_append(str, layout_inspect( @@ -332,11 +357,12 @@ VALUE Message_inspect(VALUE _self) { VALUE Message_to_h(VALUE _self) { MessageHeader* self; + VALUE hash; + upb_msg_field_iter it; TypedData_Get_Struct(_self, MessageHeader, &Message_type, self); - VALUE hash = rb_hash_new(); + hash = rb_hash_new(); - upb_msg_field_iter it; for (upb_msg_field_begin(&it, self->descriptor->msgdef); !upb_msg_field_done(&it); upb_msg_field_next(&it)) { @@ -363,10 +389,10 @@ VALUE Message_to_h(VALUE _self) { */ VALUE Message_index(VALUE _self, VALUE field_name) { MessageHeader* self; + const upb_fielddef* field; TypedData_Get_Struct(_self, MessageHeader, &Message_type, self); Check_Type(field_name, T_STRING); - const upb_fielddef* field = - upb_msgdef_ntofz(self->descriptor->msgdef, RSTRING_PTR(field_name)); + field = upb_msgdef_ntofz(self->descriptor->msgdef, RSTRING_PTR(field_name)); if (field == NULL) { return Qnil; } @@ -382,10 +408,10 @@ VALUE Message_index(VALUE _self, VALUE field_name) { */ VALUE Message_index_set(VALUE _self, VALUE field_name, VALUE value) { MessageHeader* self; + const upb_fielddef* field; TypedData_Get_Struct(_self, MessageHeader, &Message_type, self); Check_Type(field_name, T_STRING); - const upb_fielddef* field = - upb_msgdef_ntofz(self->descriptor->msgdef, RSTRING_PTR(field_name)); + field = upb_msgdef_ntofz(self->descriptor->msgdef, RSTRING_PTR(field_name)); if (field == NULL) { rb_raise(rb_eArgError, "Unknown field: %s", RSTRING_PTR(field_name)); } @@ -405,6 +431,9 @@ VALUE Message_descriptor(VALUE klass) { } VALUE build_class_from_descriptor(Descriptor* desc) { + const char *name; + VALUE klass; + if (desc->layout == NULL) { desc->layout = create_layout(desc->msgdef); } @@ -412,12 +441,12 @@ VALUE build_class_from_descriptor(Descriptor* desc) { desc->fill_method = new_fillmsg_decodermethod(desc, &desc->fill_method); } - const char* name = upb_msgdef_fullname(desc->msgdef); + name = upb_msgdef_fullname(desc->msgdef); if (name == NULL) { rb_raise(rb_eRuntimeError, "Descriptor does not have assigned name."); } - VALUE klass = rb_define_class_id( + klass = rb_define_class_id( // Docs say this parameter is ignored. User will assign return value to // their own toplevel constant class name. rb_intern("Message"), diff --git a/ruby/ext/google/protobuf_c/protobuf.c b/ruby/ext/google/protobuf_c/protobuf.c index d0625a10..32e3aea3 100644 --- a/ruby/ext/google/protobuf_c/protobuf.c +++ b/ruby/ext/google/protobuf_c/protobuf.c @@ -80,10 +80,11 @@ ID descriptor_instancevar_interned; // This must be named "Init_protobuf_c" because the Ruby module is named // "protobuf_c" -- the VM looks for this symbol in our .so. void Init_protobuf_c() { - descriptor_instancevar_interned = rb_intern(kDescriptorInstanceVar); VALUE google = rb_define_module("Google"); VALUE protobuf = rb_define_module_under(google, "Protobuf"); VALUE internal = rb_define_module_under(protobuf, "Internal"); + + descriptor_instancevar_interned = rb_intern(kDescriptorInstanceVar); DescriptorPool_register(protobuf); Descriptor_register(protobuf); FieldDescriptor_register(protobuf); diff --git a/ruby/ext/google/protobuf_c/repeated_field.c b/ruby/ext/google/protobuf_c/repeated_field.c index ffa60c15..72687f27 100644 --- a/ruby/ext/google/protobuf_c/repeated_field.c +++ b/ruby/ext/google/protobuf_c/repeated_field.c @@ -47,6 +47,10 @@ RepeatedField* ruby_to_RepeatedField(VALUE _self) { return self; } +void* RepeatedField_memoryat(RepeatedField* self, int index, int element_size) { + return ((uint8_t *)self->elements) + index * element_size; +} + static int index_position(VALUE _index, RepeatedField* repeated_field) { int index = NUM2INT(_index); if (index < 0 && repeated_field->size > 0) { @@ -113,16 +117,15 @@ VALUE RepeatedField_index(int argc, VALUE* argv, VALUE _self) { if (argc == 1){ if (FIXNUM_P(arg)) { /* standard case */ + void* memory; int index = index_position(argv[0], self); if (index < 0 || index >= self->size) { return Qnil; } - void* memory = (void *) (((uint8_t *)self->elements) + - index * element_size); + memory = RepeatedField_memoryat(self, index, element_size); return native_slot_get(field_type, field_type_class, memory); }else{ /* check if idx is Range */ - size_t off; switch (rb_range_beg_len(arg, &beg, &len, self->size, 0)) { case Qfalse: break; @@ -157,23 +160,24 @@ VALUE RepeatedField_index_set(VALUE _self, VALUE _index, VALUE val) { upb_fieldtype_t field_type = self->field_type; VALUE field_type_class = self->field_type_class; int element_size = native_slot_size(field_type); + void* memory; int index = index_position(_index, self); if (index < 0 || index >= (INT_MAX - 1)) { return Qnil; } if (index >= self->size) { - RepeatedField_reserve(self, index + 1); upb_fieldtype_t field_type = self->field_type; int element_size = native_slot_size(field_type); + RepeatedField_reserve(self, index + 1); for (int i = self->size; i <= index; i++) { - void* elem = (void *)(((uint8_t *)self->elements) + i * element_size); + void* elem = RepeatedField_memoryat(self, i, element_size); native_slot_init(field_type, elem); } self->size = index + 1; } - void* memory = (void *) (((uint8_t *)self->elements) + index * element_size); + memory = RepeatedField_memoryat(self, index, element_size); native_slot_set(field_type, field_type_class, memory, val); return Qnil; } @@ -181,6 +185,8 @@ VALUE RepeatedField_index_set(VALUE _self, VALUE _index, VALUE val) { static int kInitialSize = 8; void RepeatedField_reserve(RepeatedField* self, int new_size) { + void* old_elems = self->elements; + int elem_size = native_slot_size(self->field_type); if (new_size <= self->capacity) { return; } @@ -190,8 +196,6 @@ void RepeatedField_reserve(RepeatedField* self, int new_size) { while (self->capacity < new_size) { self->capacity *= 2; } - void* old_elems = self->elements; - int elem_size = native_slot_size(self->field_type); self->elements = ALLOC_N(uint8_t, elem_size * self->capacity); if (old_elems != NULL) { memcpy(self->elements, old_elems, self->size * elem_size); @@ -209,11 +213,12 @@ VALUE RepeatedField_push(VALUE _self, VALUE val) { RepeatedField* self = ruby_to_RepeatedField(_self); upb_fieldtype_t field_type = self->field_type; int element_size = native_slot_size(field_type); + void* memory; + RepeatedField_reserve(self, self->size + 1); - int index = self->size; - void* memory = (void *) (((uint8_t *)self->elements) + index * element_size); + memory = (void *) (((uint8_t *)self->elements) + self->size * element_size); native_slot_set(field_type, self->field_type_class, memory, val); - // native_slot_set may raise an error; bump index only after set. + // native_slot_set may raise an error; bump size only after set. self->size++; return _self; } @@ -224,9 +229,10 @@ void RepeatedField_push_native(VALUE _self, void* data) { RepeatedField* self = ruby_to_RepeatedField(_self); upb_fieldtype_t field_type = self->field_type; int element_size = native_slot_size(field_type); + void* memory; + RepeatedField_reserve(self, self->size + 1); - int index = self->size; - void* memory = (void *) (((uint8_t *)self->elements) + index * element_size); + memory = (void *) (((uint8_t *)self->elements) + self->size * element_size); memcpy(memory, data, element_size); self->size++; } @@ -235,7 +241,7 @@ void* RepeatedField_index_native(VALUE _self, int index) { RepeatedField* self = ruby_to_RepeatedField(_self); upb_fieldtype_t field_type = self->field_type; int element_size = native_slot_size(field_type); - return ((uint8_t *)self->elements) + index * element_size; + return RepeatedField_memoryat(self, index, element_size); } /* @@ -246,12 +252,16 @@ VALUE RepeatedField_pop_one(VALUE _self) { upb_fieldtype_t field_type = self->field_type; VALUE field_type_class = self->field_type_class; int element_size = native_slot_size(field_type); + int index; + void* memory; + VALUE ret; + if (self->size == 0) { return Qnil; } - int index = self->size - 1; - void* memory = (void *) (((uint8_t *)self->elements) + index * element_size); - VALUE ret = native_slot_get(field_type, field_type_class, memory); + index = self->size - 1; + memory = RepeatedField_memoryat(self, index, element_size); + ret = native_slot_get(field_type, field_type_class, memory); self->size--; return ret; } @@ -320,10 +330,10 @@ VALUE RepeatedField_dup(VALUE _self) { RepeatedField* self = ruby_to_RepeatedField(_self); VALUE new_rptfield = RepeatedField_new_this_type(_self); RepeatedField* new_rptfield_self = ruby_to_RepeatedField(new_rptfield); - RepeatedField_reserve(new_rptfield_self, self->size); upb_fieldtype_t field_type = self->field_type; size_t elem_size = native_slot_size(field_type); size_t off = 0; + RepeatedField_reserve(new_rptfield_self, self->size); for (int i = 0; i < self->size; i++, off += elem_size) { void* to_mem = (uint8_t *)new_rptfield_self->elements + off; void* from_mem = (uint8_t *)self->elements + off; @@ -339,10 +349,10 @@ VALUE RepeatedField_deep_copy(VALUE _self) { RepeatedField* self = ruby_to_RepeatedField(_self); VALUE new_rptfield = RepeatedField_new_this_type(_self); RepeatedField* new_rptfield_self = ruby_to_RepeatedField(new_rptfield); - RepeatedField_reserve(new_rptfield_self, self->size); upb_fieldtype_t field_type = self->field_type; size_t elem_size = native_slot_size(field_type); size_t off = 0; + RepeatedField_reserve(new_rptfield_self, self->size); for (int i = 0; i < self->size; i++, off += elem_size) { void* to_mem = (uint8_t *)new_rptfield_self->elements + off; void* from_mem = (uint8_t *)self->elements + off; @@ -389,34 +399,39 @@ VALUE RepeatedField_to_ary(VALUE _self) { * indicated that every element has equal value. */ VALUE RepeatedField_eq(VALUE _self, VALUE _other) { + RepeatedField* self; + RepeatedField* other; + if (_self == _other) { return Qtrue; } - RepeatedField* self = ruby_to_RepeatedField(_self); if (TYPE(_other) == T_ARRAY) { VALUE self_ary = RepeatedField_to_ary(_self); return rb_equal(self_ary, _other); } - RepeatedField* other = ruby_to_RepeatedField(_other); + self = ruby_to_RepeatedField(_self); + other = ruby_to_RepeatedField(_other); if (self->field_type != other->field_type || self->field_type_class != other->field_type_class || self->size != other->size) { return Qfalse; } - upb_fieldtype_t field_type = self->field_type; - size_t elem_size = native_slot_size(field_type); - size_t off = 0; - for (int i = 0; i < self->size; i++, off += elem_size) { - void* self_mem = ((uint8_t *)self->elements) + off; - void* other_mem = ((uint8_t *)other->elements) + off; - if (!native_slot_eq(field_type, self_mem, other_mem)) { - return Qfalse; + { + upb_fieldtype_t field_type = self->field_type; + size_t elem_size = native_slot_size(field_type); + size_t off = 0; + for (int i = 0; i < self->size; i++, off += elem_size) { + void* self_mem = ((uint8_t *)self->elements) + off; + void* other_mem = ((uint8_t *)other->elements) + off; + if (!native_slot_eq(field_type, self_mem, other_mem)) { + return Qfalse; + } } + return Qtrue; } - return Qtrue; } /* @@ -488,7 +503,6 @@ VALUE RepeatedField_plus(VALUE _self, VALUE list) { * concats the passed in array to self. Returns a Ruby array. */ VALUE RepeatedField_concat(VALUE _self, VALUE list) { - RepeatedField* self = ruby_to_RepeatedField(_self); Check_Type(list, T_ARRAY); for (int i = 0; i < RARRAY_LEN(list); i++) { RepeatedField_push(_self, rb_ary_entry(list, i)); @@ -564,9 +578,9 @@ void RepeatedField_init_args(int argc, VALUE* argv, void RepeatedField_mark(void* _self) { RepeatedField* self = (RepeatedField*)_self; - rb_gc_mark(self->field_type_class); upb_fieldtype_t field_type = self->field_type; int element_size = native_slot_size(field_type); + rb_gc_mark(self->field_type_class); for (int i = 0; i < self->size; i++) { void* memory = (((uint8_t *)self->elements) + i * element_size); native_slot_mark(self->field_type, memory); @@ -592,12 +606,12 @@ void RepeatedField_free(void* _self) { */ VALUE RepeatedField_alloc(VALUE klass) { RepeatedField* self = ALLOC(RepeatedField); + VALUE ret = TypedData_Wrap_Struct(klass, &RepeatedField_type, self); self->elements = NULL; self->size = 0; self->capacity = 0; self->field_type = -1; self->field_type_class = Qnil; - VALUE ret = TypedData_Wrap_Struct(klass, &RepeatedField_type, self); return ret; } diff --git a/ruby/ext/google/protobuf_c/storage.c b/ruby/ext/google/protobuf_c/storage.c index c4cdc9cc..b1f65f41 100644 --- a/ruby/ext/google/protobuf_c/storage.c +++ b/ruby/ext/google/protobuf_c/storage.c @@ -166,11 +166,11 @@ void native_slot_set_value_and_case(upb_fieldtype_t type, VALUE type_class, break; } case UPB_TYPE_ENUM: { + int32_t int_val = 0; if (!is_ruby_num(value) && TYPE(value) != T_SYMBOL) { rb_raise(rb_eTypeError, "Expected number or symbol type for enum field."); } - int32_t int_val = 0; if (TYPE(value) == T_SYMBOL) { // Ensure that the given symbol exists in the enum module. VALUE lookup = rb_funcall(type_class, rb_intern("resolve"), 1, value); @@ -346,24 +346,33 @@ bool native_slot_eq(upb_fieldtype_t type, void* mem1, void* mem2) { // Map field utilities. // ----------------------------------------------------------------------------- -bool is_map_field(const upb_fielddef* field) { +const upb_msgdef* tryget_map_entry_msgdef(const upb_fielddef* field) { + const upb_msgdef* subdef; if (upb_fielddef_label(field) != UPB_LABEL_REPEATED || upb_fielddef_type(field) != UPB_TYPE_MESSAGE) { - return false; + return NULL; } - const upb_msgdef* subdef = upb_fielddef_msgsubdef(field); - return upb_msgdef_mapentry(subdef); + subdef = upb_fielddef_msgsubdef(field); + return upb_msgdef_mapentry(subdef) ? subdef : NULL; +} + +const upb_msgdef *map_entry_msgdef(const upb_fielddef* field) { + const upb_msgdef* subdef = tryget_map_entry_msgdef(field); + assert(subdef); + return subdef; +} + +bool is_map_field(const upb_fielddef *field) { + return tryget_map_entry_msgdef(field) != NULL; } const upb_fielddef* map_field_key(const upb_fielddef* field) { - assert(is_map_field(field)); - const upb_msgdef* subdef = upb_fielddef_msgsubdef(field); + const upb_msgdef* subdef = map_entry_msgdef(field); return map_entry_key(subdef); } const upb_fielddef* map_field_value(const upb_fielddef* field) { - assert(is_map_field(field)); - const upb_msgdef* subdef = upb_fielddef_msgsubdef(field); + const upb_msgdef* subdef = map_entry_msgdef(field); return map_entry_value(subdef); } @@ -391,14 +400,17 @@ static size_t align_up_to(size_t offset, size_t granularity) { MessageLayout* create_layout(const upb_msgdef* msgdef) { MessageLayout* layout = ALLOC(MessageLayout); int nfields = upb_msgdef_numfields(msgdef); - layout->fields = ALLOC_N(MessageField, nfields); - upb_msg_field_iter it; + upb_msg_oneof_iter oit; size_t off = 0; + + layout->fields = ALLOC_N(MessageField, nfields); + for (upb_msg_field_begin(&it, msgdef); !upb_msg_field_done(&it); upb_msg_field_next(&it)) { const upb_fielddef* field = upb_msg_iter_field(&it); + size_t field_size; if (upb_fielddef_containingoneof(field)) { // Oneofs are handled separately below. @@ -406,7 +418,7 @@ MessageLayout* create_layout(const upb_msgdef* msgdef) { } // Allocate |field_size| bytes for this field in the layout. - size_t field_size = 0; + field_size = 0; if (upb_fielddef_label(field) == UPB_LABEL_REPEATED) { field_size = sizeof(VALUE); } else { @@ -433,11 +445,11 @@ MessageLayout* create_layout(const upb_msgdef* msgdef) { // members (8 or 16 bits respectively), so conceivably we could assign // consecutive case numbers and then pick a smaller oneof case slot size, but // the complexity to implement this indirection is probably not worthwhile. - upb_msg_oneof_iter oit; for (upb_msg_oneof_begin(&oit, msgdef); !upb_msg_oneof_done(&oit); upb_msg_oneof_next(&oit)) { const upb_oneofdef* oneof = upb_msg_iter_oneof(&oit); + upb_oneof_iter fit; // Always allocate NATIVE_SLOT_MAX_SIZE bytes, but share the slot between // all fields. @@ -445,7 +457,6 @@ MessageLayout* create_layout(const upb_msgdef* msgdef) { // Align the offset. off = align_up_to(off, field_size); // Assign all fields in the oneof this same offset. - upb_oneof_iter fit; for (upb_oneof_begin(&fit, oneof); !upb_oneof_done(&fit); upb_oneof_next(&fit)) { @@ -460,12 +471,12 @@ MessageLayout* create_layout(const upb_msgdef* msgdef) { !upb_msg_oneof_done(&oit); upb_msg_oneof_next(&oit)) { const upb_oneofdef* oneof = upb_msg_iter_oneof(&oit); + upb_oneof_iter fit; size_t field_size = sizeof(uint32_t); // Align the offset. off = (off + field_size - 1) & ~(field_size - 1); // Assign all fields in the oneof this same offset. - upb_oneof_iter fit; for (upb_oneof_begin(&fit, oneof); !upb_oneof_done(&fit); upb_oneof_next(&fit)) { @@ -541,6 +552,7 @@ VALUE layout_get(MessageLayout* layout, } static void check_repeated_field_type(VALUE val, const upb_fielddef* field) { + RepeatedField* self; assert(upb_fielddef_label(field) == UPB_LABEL_REPEATED); if (!RB_TYPE_P(val, T_DATA) || !RTYPEDDATA_P(val) || @@ -548,7 +560,7 @@ static void check_repeated_field_type(VALUE val, const upb_fielddef* field) { rb_raise(rb_eTypeError, "Expected repeated field array"); } - RepeatedField* self = ruby_to_RepeatedField(val); + self = ruby_to_RepeatedField(val); if (self->field_type != upb_fielddef_type(field)) { rb_raise(rb_eTypeError, "Repeated field array has wrong element type"); } @@ -564,16 +576,16 @@ static void check_repeated_field_type(VALUE val, const upb_fielddef* field) { } static void check_map_field_type(VALUE val, const upb_fielddef* field) { - assert(is_map_field(field)); const upb_fielddef* key_field = map_field_key(field); const upb_fielddef* value_field = map_field_value(field); + Map* self; if (!RB_TYPE_P(val, T_DATA) || !RTYPEDDATA_P(val) || RTYPEDDATA_TYPE(val) != &Map_type) { rb_raise(rb_eTypeError, "Expected Map instance"); } - Map* self = ruby_to_Map(val); + self = ruby_to_Map(val); if (self->key_type != upb_fielddef_type(key_field)) { rb_raise(rb_eTypeError, "Map key type does not match field's key type"); } -- cgit v1.2.3 From cacbedf04ef0ca9727e5b990a62f4146e2027f21 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 10 Jul 2015 13:40:34 -0700 Subject: export c# naming routines publicly --- cmake/extract_includes.bat.in | 1 + src/Makefile.am | 1 + .../protobuf/compiler/csharp/csharp_field_base.cc | 1 + .../protobuf/compiler/csharp/csharp_helpers.h | 3 +- .../protobuf/compiler/csharp/csharp_message.cc | 5 +- src/google/protobuf/compiler/csharp/csharp_names.h | 74 ++++++++++++++++++++++ .../compiler/csharp/csharp_umbrella_class.cc | 4 +- 7 files changed, 84 insertions(+), 5 deletions(-) create mode 100644 src/google/protobuf/compiler/csharp/csharp_names.h diff --git a/cmake/extract_includes.bat.in b/cmake/extract_includes.bat.in index 4e34d81a..500975bb 100644 --- a/cmake/extract_includes.bat.in +++ b/cmake/extract_includes.bat.in @@ -21,6 +21,7 @@ copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\code_generato copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\command_line_interface.h include\google\protobuf\compiler\command_line_interface.h copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\cpp\cpp_generator.h include\google\protobuf\compiler\cpp\cpp_generator.h copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\csharp\csharp_generator.h include\google\protobuf\compiler\csharp\csharp_generator.h +copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\csharp\csharp_names.h include\google\protobuf\compiler\csharp\csharp_names.h copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\importer.h include\google\protobuf\compiler\importer.h copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\java\java_generator.h include\google\protobuf\compiler\java\java_generator.h copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\java\java_names.h include\google\protobuf\compiler\java\java_names.h diff --git a/src/Makefile.am b/src/Makefile.am index cea3089e..c0ab2bea 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -148,6 +148,7 @@ nobase_include_HEADERS = \ google/protobuf/compiler/python/python_generator.h \ google/protobuf/compiler/ruby/ruby_generator.h \ google/protobuf/compiler/csharp/csharp_generator.h \ + google/protobuf/compiler/csharp/csharp_names.h \ google/protobuf/util/type_resolver.h \ google/protobuf/util/type_resolver_util.h \ google/protobuf/util/json_util.h \ diff --git a/src/google/protobuf/compiler/csharp/csharp_field_base.cc b/src/google/protobuf/compiler/csharp/csharp_field_base.cc index ae7336ca..c5662bcb 100644 --- a/src/google/protobuf/compiler/csharp/csharp_field_base.cc +++ b/src/google/protobuf/compiler/csharp/csharp_field_base.cc @@ -43,6 +43,7 @@ #include #include +#include using google::protobuf::internal::scoped_ptr; diff --git a/src/google/protobuf/compiler/csharp/csharp_helpers.h b/src/google/protobuf/compiler/csharp/csharp_helpers.h index d9576fbd..4227f980 100644 --- a/src/google/protobuf/compiler/csharp/csharp_helpers.h +++ b/src/google/protobuf/compiler/csharp/csharp_helpers.h @@ -69,15 +69,14 @@ CSharpType GetCSharpType(FieldDescriptor::Type type); std::string StripDotProto(const std::string& proto_file); -std::string GetFileNamespace(const FileDescriptor* descriptor); std::string GetFileUmbrellaClassname(const FileDescriptor* descriptor); + std::string GetFileUmbrellaNamespace(const FileDescriptor* descriptor); std::string GetFullUmbrellaClassName(const FileDescriptor* descriptor); std::string GetQualifiedUmbrellaClassName(const FileDescriptor* descriptor); -std::string GetClassName(const Descriptor* descriptor); std::string GetClassName(const EnumDescriptor* descriptor); std::string GetFieldName(const FieldDescriptor* descriptor); diff --git a/src/google/protobuf/compiler/csharp/csharp_message.cc b/src/google/protobuf/compiler/csharp/csharp_message.cc index 13544b26..ac61c2c9 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message.cc @@ -43,9 +43,10 @@ #include #include -#include -#include #include +#include +#include +#include using google::protobuf::internal::scoped_ptr; diff --git a/src/google/protobuf/compiler/csharp/csharp_names.h b/src/google/protobuf/compiler/csharp/csharp_names.h new file mode 100644 index 00000000..74466cd3 --- /dev/null +++ b/src/google/protobuf/compiler/csharp/csharp_names.h @@ -0,0 +1,74 @@ +// 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. + +// Author: kenton@google.com (Kenton Varda) +// Based on original Protocol Buffers design by +// Sanjay Ghemawat, Jeff Dean, and others. +// +// Provides a mechanism for mapping a descriptor to the +// fully-qualified name of the corresponding C# class. + +#ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_NAMES_H__ +#define GOOGLE_PROTOBUF_COMPILER_CSHARP_NAMES_H__ + +#include + +namespace google { +namespace protobuf { + +class Descriptor; +class EnumDescriptor; +class FileDescriptor; +class ServiceDescriptor; + +namespace compiler { +namespace csharp { + +// Requires: +// descriptor != NULL +// +// Returns: +// The namespace to use for given file descriptor. +string GetFileNamespace(const FileDescriptor* descriptor); + +// Requires: +// descriptor != NULL +// +// Returns: +// The fully-qualified C# class name. +string GetClassName(const Descriptor* descriptor); + + +} // namespace csharp +} // namespace compiler +} // namespace protobuf +} // namespace google + +#endif // GOOGLE_PROTOBUF_COMPILER_CSHARP_NAMES_H__ diff --git a/src/google/protobuf/compiler/csharp/csharp_umbrella_class.cc b/src/google/protobuf/compiler/csharp/csharp_umbrella_class.cc index 8fbd3e9a..c31aaaa2 100644 --- a/src/google/protobuf/compiler/csharp/csharp_umbrella_class.cc +++ b/src/google/protobuf/compiler/csharp/csharp_umbrella_class.cc @@ -37,10 +37,12 @@ #include #include -#include + #include #include #include +#include +#include namespace google { namespace protobuf { -- cgit v1.2.3 From 46feed023d215c0f95030265b3e0b800d2aa6ffc Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 10 Jul 2015 15:23:28 -0700 Subject: enable building nuget package --- csharp/.gitignore | 14 +------------ csharp/build_packages.bat | 13 ++++++++++++ csharp/src/ProtocolBuffers/Google.Protobuf.nuspec | 24 +++++++++++++++++++++++ csharp/src/ProtocolBuffers/ProtocolBuffers.csproj | 3 +++ 4 files changed, 41 insertions(+), 13 deletions(-) create mode 100644 csharp/build_packages.bat create mode 100644 csharp/src/ProtocolBuffers/Google.Protobuf.nuspec diff --git a/csharp/.gitignore b/csharp/.gitignore index d7dcef59..91baa54e 100644 --- a/csharp/.gitignore +++ b/csharp/.gitignore @@ -5,23 +5,10 @@ src/AddressBook/bin src/AddressBook/obj src/ProtocolBuffers/bin/ src/ProtocolBuffers/obj/ -src/ProtocolBuffers/objCF -src/ProtocolBuffers.Serialization/bin/ -src/ProtocolBuffers.Serialization/obj/ src/ProtocolBuffers.Test/bin/ src/ProtocolBuffers.Test/obj/ -src/ProtocolBuffersLite.Test/bin/ -src/ProtocolBuffersLite.Test/obj/ -src/ProtoBench/bin/ -src/ProtoBench/obj/ src/ProtoDump/bin/ src/ProtoDump/obj/ -src/ProtoGen/bin/ -src/ProtoGen/obj/ -src/ProtoGen.Test/bin/ -src/ProtoGen.Test/obj/ -src/ProtoMunge/bin/ -src/ProtoMunge/obj/ mono/bin mono/tmp mono/protoc @@ -36,6 +23,7 @@ lib/NUnit # *.user *.suo +*.nupkg _ReSharper.* *.sln.cache mono/TestResult.xml diff --git a/csharp/build_packages.bat b/csharp/build_packages.bat new file mode 100644 index 00000000..315c1501 --- /dev/null +++ b/csharp/build_packages.bat @@ -0,0 +1,13 @@ +@rem Builds Google.Protobuf NuGet packages + +@rem Adjust the location of nuget.exe +set NUGET=C:\nuget\nuget.exe + +@rem Build src/ProtocolBuffers.sln solution in Release configuration first. +%NUGET% pack src\ProtocolBuffers\Google.Protobuf.nuspec -Symbols || goto :error + +goto :EOF + +:error +echo Failed! +exit /b %errorlevel% diff --git a/csharp/src/ProtocolBuffers/Google.Protobuf.nuspec b/csharp/src/ProtocolBuffers/Google.Protobuf.nuspec new file mode 100644 index 00000000..49704993 --- /dev/null +++ b/csharp/src/ProtocolBuffers/Google.Protobuf.nuspec @@ -0,0 +1,24 @@ + + + + Google.Protobuf + Google Protocol Buffers C# + C# runtime library for Protocol Buffers - Google's data interchange format. + See project site for more info. + 3.0.0-experimental + Google Inc. + protobuf-packages + https://github.com/google/protobuf/blob/master/LICENSE + https://github.com/google/protobuf + false + Experimental version of C# Protocol Buffers + Copyright 2015, Google Inc. + Protocol Buffers Binary Serialization Format Google proto proto3 + + + + + + + + diff --git a/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj b/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj index aa4adcc0..acfade59 100644 --- a/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj +++ b/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj @@ -97,6 +97,9 @@ + + + + \ No newline at end of file diff --git a/csharp/src/Google.Protobuf.JsonDump/Program.cs b/csharp/src/Google.Protobuf.JsonDump/Program.cs new file mode 100644 index 00000000..99e60e90 --- /dev/null +++ b/csharp/src/Google.Protobuf.JsonDump/Program.cs @@ -0,0 +1,72 @@ +#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; +using System.IO; + +namespace Google.Protobuf.ProtoDump +{ + /// + /// Small utility to load a binary message and dump it in JSON format. + /// + internal class Program + { + private static int Main(string[] args) + { + if (args.Length != 2) + { + Console.Error.WriteLine("Usage: Google.Protobuf.JsonDump "); + Console.Error.WriteLine("The descriptor type name is the fully-qualified message name,"); + Console.Error.WriteLine("including assembly e.g. ProjectNamespace.Message,Company.Project"); + return 1; + } + Type type = Type.GetType(args[0]); + if (type == null) + { + Console.Error.WriteLine("Unable to load type {0}.", args[0]); + return 1; + } + if (!typeof(IMessage).IsAssignableFrom(type)) + { + Console.Error.WriteLine("Type {0} doesn't implement IMessage.", args[0]); + return 1; + } + IMessage message = (IMessage) Activator.CreateInstance(type); + using (var input = File.OpenRead(args[1])) + { + message.MergeFrom(input); + } + Console.WriteLine(message); + return 0; + } + } +} \ No newline at end of file diff --git a/csharp/src/Google.Protobuf.JsonDump/Properties/AssemblyInfo.cs b/csharp/src/Google.Protobuf.JsonDump/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..a8ce8eae --- /dev/null +++ b/csharp/src/Google.Protobuf.JsonDump/Properties/AssemblyInfo.cs @@ -0,0 +1,30 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. + +[assembly: AssemblyTitle("ProtoDump")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ProtoDump")] +[assembly: AssemblyCopyright("Copyright © 2009")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("2.4.1.555")] + +[assembly: AssemblyVersion("2.4.1.555")] +[assembly: AssemblyFileVersion("2.4.1.555")] \ No newline at end of file diff --git a/csharp/src/Google.Protobuf.JsonDump/app.config b/csharp/src/Google.Protobuf.JsonDump/app.config new file mode 100644 index 00000000..e2a5a187 --- /dev/null +++ b/csharp/src/Google.Protobuf.JsonDump/app.config @@ -0,0 +1,3 @@ + + + diff --git a/csharp/src/Google.Protobuf.Test/ByteStringTest.cs b/csharp/src/Google.Protobuf.Test/ByteStringTest.cs new file mode 100644 index 00000000..685e130a --- /dev/null +++ b/csharp/src/Google.Protobuf.Test/ByteStringTest.cs @@ -0,0 +1,171 @@ +#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; +using System.Text; +using NUnit.Framework; + +namespace Google.Protobuf +{ + public class ByteStringTest + { + [Test] + public void Equality() + { + ByteString b1 = ByteString.CopyFrom(1, 2, 3); + ByteString b2 = ByteString.CopyFrom(1, 2, 3); + ByteString b3 = ByteString.CopyFrom(1, 2, 4); + ByteString b4 = ByteString.CopyFrom(1, 2, 3, 4); + EqualityTester.AssertEquality(b1, b1); + EqualityTester.AssertEquality(b1, b2); + EqualityTester.AssertInequality(b1, b3); + EqualityTester.AssertInequality(b1, b4); + EqualityTester.AssertInequality(b1, null); +#pragma warning disable 1718 // Deliberately calling ==(b1, b1) and !=(b1, b1) + Assert.IsTrue(b1 == b1); + Assert.IsTrue(b1 == b2); + Assert.IsFalse(b1 == b3); + Assert.IsFalse(b1 == b4); + Assert.IsFalse(b1 == null); + Assert.IsTrue((ByteString) null == null); + Assert.IsFalse(b1 != b1); + Assert.IsFalse(b1 != b2); +#pragma warning disable 1718 + Assert.IsTrue(b1 != b3); + Assert.IsTrue(b1 != b4); + Assert.IsTrue(b1 != null); + Assert.IsFalse((ByteString) null != null); + } + + [Test] + public void EmptyByteStringHasZeroSize() + { + Assert.AreEqual(0, ByteString.Empty.Length); + } + + [Test] + public void CopyFromStringWithExplicitEncoding() + { + ByteString bs = ByteString.CopyFrom("AB", Encoding.Unicode); + Assert.AreEqual(4, bs.Length); + Assert.AreEqual(65, bs[0]); + Assert.AreEqual(0, bs[1]); + Assert.AreEqual(66, bs[2]); + Assert.AreEqual(0, bs[3]); + } + + [Test] + public void IsEmptyWhenEmpty() + { + Assert.IsTrue(ByteString.CopyFromUtf8("").IsEmpty); + } + + [Test] + public void IsEmptyWhenNotEmpty() + { + Assert.IsFalse(ByteString.CopyFromUtf8("X").IsEmpty); + } + + [Test] + public void CopyFromByteArrayCopiesContents() + { + byte[] data = new byte[1]; + data[0] = 10; + ByteString bs = ByteString.CopyFrom(data); + Assert.AreEqual(10, bs[0]); + data[0] = 5; + Assert.AreEqual(10, bs[0]); + } + + [Test] + public void ToByteArrayCopiesContents() + { + ByteString bs = ByteString.CopyFromUtf8("Hello"); + byte[] data = bs.ToByteArray(); + Assert.AreEqual((byte)'H', data[0]); + Assert.AreEqual((byte)'H', bs[0]); + data[0] = 0; + Assert.AreEqual(0, data[0]); + Assert.AreEqual((byte)'H', bs[0]); + } + + [Test] + public void CopyFromUtf8UsesUtf8() + { + ByteString bs = ByteString.CopyFromUtf8("\u20ac"); + Assert.AreEqual(3, bs.Length); + Assert.AreEqual(0xe2, bs[0]); + Assert.AreEqual(0x82, bs[1]); + Assert.AreEqual(0xac, bs[2]); + } + + [Test] + public void CopyFromPortion() + { + byte[] data = new byte[] {0, 1, 2, 3, 4, 5, 6}; + ByteString bs = ByteString.CopyFrom(data, 2, 3); + Assert.AreEqual(3, bs.Length); + Assert.AreEqual(2, bs[0]); + Assert.AreEqual(3, bs[1]); + } + + [Test] + public void ToStringUtf8() + { + ByteString bs = ByteString.CopyFromUtf8("\u20ac"); + Assert.AreEqual("\u20ac", bs.ToStringUtf8()); + } + + [Test] + public void ToStringWithExplicitEncoding() + { + ByteString bs = ByteString.CopyFrom("\u20ac", Encoding.Unicode); + Assert.AreEqual("\u20ac", bs.ToString(Encoding.Unicode)); + } + + [Test] + public void FromBase64_WithText() + { + byte[] data = new byte[] {0, 1, 2, 3, 4, 5, 6}; + string base64 = Convert.ToBase64String(data); + ByteString bs = ByteString.FromBase64(base64); + Assert.AreEqual(data, bs.ToByteArray()); + } + + [Test] + public void FromBase64_Empty() + { + // Optimization which also fixes issue 61. + Assert.AreSame(ByteString.Empty, ByteString.FromBase64("")); + } + } +} \ No newline at end of file diff --git a/csharp/src/Google.Protobuf.Test/CodedInputStreamExtensions.cs b/csharp/src/Google.Protobuf.Test/CodedInputStreamExtensions.cs new file mode 100644 index 00000000..408c7cb9 --- /dev/null +++ b/csharp/src/Google.Protobuf.Test/CodedInputStreamExtensions.cs @@ -0,0 +1,54 @@ +#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; + +namespace Google.Protobuf +{ + internal static class CodedInputStreamExtensions + { + public static void AssertNextTag(this CodedInputStream input, uint expectedTag) + { + uint tag; + Assert.IsTrue(input.ReadTag(out tag)); + Assert.AreEqual(expectedTag, tag); + } + + public static T ReadMessage(this CodedInputStream stream, MessageParser parser) + where T : IMessage + { + var message = parser.CreateTemplate(); + stream.ReadMessage(message); + return message; + } + } +} diff --git a/csharp/src/Google.Protobuf.Test/CodedInputStreamTest.cs b/csharp/src/Google.Protobuf.Test/CodedInputStreamTest.cs new file mode 100644 index 00000000..fa88d407 --- /dev/null +++ b/csharp/src/Google.Protobuf.Test/CodedInputStreamTest.cs @@ -0,0 +1,444 @@ +#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; +using System.IO; +using Google.Protobuf.TestProtos; +using NUnit.Framework; + +namespace Google.Protobuf +{ + public class CodedInputStreamTest + { + /// + /// 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 = CodedInputStream.CreateInstance(data); + Assert.AreEqual((uint) value, input.ReadRawVarint32()); + + input = CodedInputStream.CreateInstance(data); + Assert.AreEqual(value, input.ReadRawVarint64()); + Assert.IsTrue(input.IsAtEnd); + + // Try different block sizes. + for (int bufferSize = 1; bufferSize <= 16; bufferSize *= 2) + { + input = CodedInputStream.CreateInstance(new SmallBlockInputStream(data, bufferSize)); + Assert.AreEqual((uint) value, input.ReadRawVarint32()); + + input = CodedInputStream.CreateInstance(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 = CodedInputStream.CreateInstance(data); + var exception = Assert.Throws(() => input.ReadRawVarint32()); + Assert.AreEqual(expected.Message, exception.Message); + + input = CodedInputStream.CreateInstance(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 = CodedInputStream.CreateInstance(data); + Assert.AreEqual(value, input.ReadRawLittleEndian32()); + Assert.IsTrue(input.IsAtEnd); + + // Try different block sizes. + for (int blockSize = 1; blockSize <= 16; blockSize *= 2) + { + input = CodedInputStream.CreateInstance( + 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 = CodedInputStream.CreateInstance(data); + Assert.AreEqual(value, input.ReadRawLittleEndian64()); + Assert.IsTrue(input.IsAtEnd); + + // Try different block sizes. + for (int blockSize = 1; blockSize <= 16; blockSize *= 2) + { + input = CodedInputStream.CreateInstance( + 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() + { + TestAllTypes message = SampleMessages.CreateFullTestAllTypes(); + + byte[] rawBytes = message.ToByteArray(); + Assert.AreEqual(rawBytes.Length, message.CalculateSize()); + TestAllTypes message2 = TestAllTypes.Parser.ParseFrom(rawBytes); + Assert.AreEqual(message, message2); + + // Try different block sizes. + for (int blockSize = 1; blockSize < 256; blockSize *= 2) + { + message2 = TestAllTypes.Parser.ParseFrom(new SmallBlockInputStream(rawBytes, blockSize)); + 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 = CodedOutputStream.CreateInstance(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 = CodedInputStream.CreateInstance(ms); + uint testtag; + Assert.IsTrue(input.ReadTag(out testtag)); + Assert.AreEqual(tag, testtag); + + // TODO(jonskeet): Should this be ArgumentNullException instead? + Assert.Throws(() => input.ReadBytes()); + } + + private static TestRecursiveMessage MakeRecursiveMessage(int depth) + { + if (depth == 0) + { + return new TestRecursiveMessage { I = 5 }; + } + else + { + return new TestRecursiveMessage { A = MakeRecursiveMessage(depth - 1) }; + } + } + + private 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 data64 = MakeRecursiveMessage(64).ToByteString(); + ByteString data65 = MakeRecursiveMessage(65).ToByteString(); + + AssertMessageDepth(TestRecursiveMessage.Parser.ParseFrom(data64), 64); + + Assert.Throws(() => TestRecursiveMessage.Parser.ParseFrom(data65)); + + CodedInputStream input = data64.CreateCodedInput(); + input.SetRecursionLimit(8); + 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(TestUtil.GetAllSet().ToByteString().ToByteArray()); + CodedInputStream input = CodedInputStream.CreateInstance(ms); + input.SetSizeLimit(16); + + Assert.Throws(() => TestAllTypes.ParseFrom(input)); + }*/ + + [Test] + public void ResetSizeCounter() + { + CodedInputStream input = CodedInputStream.CreateInstance( + new SmallBlockInputStream(new byte[256], 8)); + input.SetSizeLimit(16); + input.ReadRawBytes(16); + + Assert.Throws(() => input.ReadRawByte()); + + input.ResetSizeCounter(); + input.ReadRawByte(); // No exception thrown. + + Assert.Throws(() => input.ReadRawBytes(16)); + } + + /// + /// 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 = CodedOutputStream.CreateInstance(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; + + CodedInputStream input = CodedInputStream.CreateInstance(ms); + + uint actualTag; + Assert.IsTrue(input.ReadTag(out actualTag)); + Assert.AreEqual(tag, actualTag); + string text = input.ReadString(); + Assert.AreEqual('\ufffd', text[0]); + } + + /// + /// A stream which limits the number of bytes it reads at a time. + /// We use this to make sure that CodedInputStream doesn't screw up when + /// reading in small blocks. + /// + private sealed class SmallBlockInputStream : MemoryStream + { + private readonly int blockSize; + + public SmallBlockInputStream(byte[] data, int blockSize) + : base(data) + { + this.blockSize = blockSize; + } + + public override int Read(byte[] buffer, int offset, int count) + { + return base.Read(buffer, offset, Math.Min(count, blockSize)); + } + } + + [Test] + public void TestNegativeEnum() + { + byte[] bytes = { 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01 }; + CodedInputStream input = CodedInputStream.CreateInstance(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() + { + using (var ms = new MemoryStream()) + { + CodedOutputStream output = CodedOutputStream.CreateInstance(ms); + output.WriteTag(1, WireFormat.WireType.LengthDelimited); + output.WriteBytes(ByteString.CopyFrom(new byte[100])); + output.WriteTag(2, WireFormat.WireType.LengthDelimited); + output.WriteBytes(ByteString.CopyFrom(new byte[100])); + output.Flush(); + + ms.Position = 0; + CodedInputStream input = CodedInputStream.CreateInstance(ms, new byte[ms.Length / 2]); + + uint tag; + Assert.IsTrue(input.ReadTag(out tag)); + Assert.AreEqual(1, WireFormat.GetTagFieldNumber(tag)); + Assert.AreEqual(100, input.ReadBytes().Length); + + Assert.IsTrue(input.ReadTag(out tag)); + Assert.AreEqual(2, WireFormat.GetTagFieldNumber(tag)); + Assert.AreEqual(100, input.ReadBytes().Length); + } + } + } +} \ No newline at end of file diff --git a/csharp/src/Google.Protobuf.Test/CodedOutputStreamTest.cs b/csharp/src/Google.Protobuf.Test/CodedOutputStreamTest.cs new file mode 100644 index 00000000..c3d92a66 --- /dev/null +++ b/csharp/src/Google.Protobuf.Test/CodedOutputStreamTest.cs @@ -0,0 +1,386 @@ +#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; +using System.IO; +using Google.Protobuf.TestProtos; +using NUnit.Framework; + +namespace Google.Protobuf +{ + public class CodedOutputStreamTest + { + /// + /// 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 = CodedOutputStream.CreateInstance(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 = CodedOutputStream.CreateInstance(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 = + CodedOutputStream.CreateInstance(rawOutput, bufferSize); + output.WriteRawVarint32((uint) value); + output.Flush(); + Assert.AreEqual(data, rawOutput.ToArray()); + } + + { + MemoryStream rawOutput = new MemoryStream(); + CodedOutputStream output = CodedOutputStream.CreateInstance(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 = CodedOutputStream.CreateInstance(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 = CodedOutputStream.CreateInstance(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 = CodedOutputStream.CreateInstance(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 = CodedOutputStream.CreateInstance(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() + { + TestAllTypes message = SampleMessages.CreateFullTestAllTypes(); + + byte[] rawBytes = message.ToByteArray(); + + // Try different block sizes. + for (int blockSize = 1; blockSize < 256; blockSize *= 2) + { + MemoryStream rawOutput = new MemoryStream(); + CodedOutputStream output = CodedOutputStream.CreateInstance(rawOutput, blockSize); + message.WriteTo(output); + output.Flush(); + 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 = CodedOutputStream.CreateInstance(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() + { + byte[] content = new byte[110]; + for (int i = 0; i < content.Length; i++) + content[i] = (byte)i; + + byte[] child = new byte[120]; + { + MemoryStream ms = new MemoryStream(child); + CodedOutputStream cout = CodedOutputStream.CreateInstance(ms, 20); + // Field 11: numeric value: 500 + cout.WriteTag(11, WireFormat.WireType.Varint); + Assert.AreEqual(1, cout.Position); + cout.WriteInt32(500); + Assert.AreEqual(3, cout.Position); + //Field 12: length delimited 120 bytes + cout.WriteTag(12, WireFormat.WireType.LengthDelimited); + Assert.AreEqual(4, cout.Position); + cout.WriteBytes(ByteString.CopyFrom(content)); + Assert.AreEqual(115, cout.Position); + // Field 13: fixed numeric value: 501 + cout.WriteTag(13, WireFormat.WireType.Fixed32); + Assert.AreEqual(116, cout.Position); + cout.WriteSFixed32(501); + Assert.AreEqual(120, cout.Position); + cout.Flush(); + } + + byte[] bytes = new byte[130]; + { + CodedOutputStream cout = CodedOutputStream.CreateInstance(bytes); + // Field 1: numeric value: 500 + cout.WriteTag(1, WireFormat.WireType.Varint); + Assert.AreEqual(1, cout.Position); + cout.WriteInt32(500); + Assert.AreEqual(3, cout.Position); + //Field 2: length delimited 120 bytes + cout.WriteTag(2, WireFormat.WireType.LengthDelimited); + Assert.AreEqual(4, cout.Position); + cout.WriteBytes(ByteString.CopyFrom(child)); + Assert.AreEqual(125, cout.Position); + // Field 3: fixed numeric value: 500 + cout.WriteTag(3, WireFormat.WireType.Fixed32); + Assert.AreEqual(126, cout.Position); + cout.WriteSFixed32(501); + Assert.AreEqual(130, cout.Position); + cout.Flush(); + } + // Now test Input stream: + { + CodedInputStream cin = CodedInputStream.CreateInstance(new MemoryStream(bytes), new byte[50]); + uint tag; + Assert.AreEqual(0, cin.Position); + // Field 1: + Assert.IsTrue(cin.ReadTag(out tag) && tag >> 3 == 1); + Assert.AreEqual(1, cin.Position); + Assert.AreEqual(500, cin.ReadInt32()); + Assert.AreEqual(3, cin.Position); + //Field 2: + Assert.IsTrue(cin.ReadTag(out tag) && tag >> 3 == 2); + Assert.AreEqual(4, cin.Position); + int childlen = cin.ReadLength(); + Assert.AreEqual(120, childlen); + Assert.AreEqual(5, cin.Position); + int oldlimit = cin.PushLimit((int)childlen); + Assert.AreEqual(5, cin.Position); + // Now we are reading child message + { + // Field 11: numeric value: 500 + Assert.IsTrue(cin.ReadTag(out tag) && tag >> 3 == 11); + Assert.AreEqual(6, cin.Position); + Assert.AreEqual(500, cin.ReadInt32()); + Assert.AreEqual(8, cin.Position); + //Field 12: length delimited 120 bytes + Assert.IsTrue(cin.ReadTag(out tag) && tag >> 3 == 12); + 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 + Assert.IsTrue(cin.ReadTag(out tag) && tag >> 3 == 13); + // 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.IsTrue(cin.IsAtEnd); + } + cin.PopLimit(oldlimit); + Assert.AreEqual(125, cin.Position); + // Field 3: fixed numeric value: 501 + Assert.IsTrue(cin.ReadTag(out tag) && tag >> 3 == 3); + Assert.AreEqual(126, cin.Position); + Assert.AreEqual(501, cin.ReadSFixed32()); + Assert.AreEqual(130, cin.Position); + Assert.IsTrue(cin.IsAtEnd); + } + } + } +} \ No newline at end of file diff --git a/csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs b/csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs new file mode 100644 index 00000000..46d3bd9a --- /dev/null +++ b/csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs @@ -0,0 +1,541 @@ +#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 System; +using System.Collections.Generic; +using Google.Protobuf.TestProtos; +using NUnit.Framework; +using System.Collections; +using System.Linq; + +namespace Google.Protobuf.Collections +{ + /// + /// Tests for MapField which aren't reliant on the encoded format - + /// tests for serialization/deserialization are part of GeneratedMessageTest. + /// + public class MapFieldTest + { + // Protobuf-specific tests + [Test] + public void Freeze_FreezesMessages() + { + var message = new ForeignMessage { C = 20 }; + var map = new MapField { { "x", message } }; + map.Freeze(); + Assert.IsTrue(message.IsFrozen); + } + + [Test] + public void Freeze_Idempotent() + { + var message = new ForeignMessage { C = 20 }; + var map = new MapField { { "x", message } }; + Assert.IsFalse(map.IsFrozen); + map.Freeze(); + Assert.IsTrue(message.IsFrozen); + map.Freeze(); + Assert.IsTrue(message.IsFrozen); + } + + [Test] + public void Freeze_PreventsMutation() + { + var map = new MapField(); + map.Freeze(); + Assert.IsTrue(map.IsFrozen); + Assert.IsTrue(map.IsReadOnly); + ICollection> collection = map; + Assert.Throws(() => map["x"] = "y"); + Assert.Throws(() => map.Add("x", "y")); + Assert.Throws(() => map.Remove("x")); + Assert.Throws(() => map.Clear()); + Assert.Throws(() => collection.Add(NewKeyValuePair("x", "y"))); + Assert.Throws(() => collection.Remove(NewKeyValuePair("x", "y"))); + } + + [Test] + public void Clone_ReturnsNonFrozen() + { + var map = new MapField(); + map.Freeze(); + var clone = map.Clone(); + clone.Add("x", "y"); + } + + [Test] + public void Clone_ClonesMessages() + { + var message = new ForeignMessage { C = 20 }; + var map = new MapField { { "x", message } }; + var clone = map.Clone(); + map["x"].C = 30; + Assert.AreEqual(20, clone["x"].C); + } + + [Test] + public void NullValues() + { + TestNullValues(0); + TestNullValues(""); + TestNullValues(new TestAllTypes()); + } + + private void TestNullValues(T nonNullValue) + { + var map = new MapField(false); + var nullValue = (T) (object) null; + Assert.Throws(() => map.Add(0, nullValue)); + Assert.Throws(() => map[0] = nullValue); + map.Add(1, nonNullValue); + map[1] = nonNullValue; + + // Doesn't throw... + map = new MapField(true); + map.Add(0, nullValue); + map[0] = nullValue; + map.Add(1, nonNullValue); + map[1] = nonNullValue; + } + + [Test] + public void Add_ForbidsNullKeys() + { + var map = new MapField(); + Assert.Throws(() => map.Add(null, new ForeignMessage())); + } + + [Test] + public void Indexer_ForbidsNullKeys() + { + var map = new MapField(); + Assert.Throws(() => map[null] = new ForeignMessage()); + } + + [Test] + public void AddPreservesInsertionOrder() + { + var map = new MapField(); + map.Add("a", "v1"); + map.Add("b", "v2"); + map.Add("c", "v3"); + map.Remove("b"); + map.Add("d", "v4"); + CollectionAssert.AreEqual(new[] { "a", "c", "d" }, map.Keys); + CollectionAssert.AreEqual(new[] { "v1", "v3", "v4" }, map.Values); + } + + [Test] + public void EqualityIsOrderInsensitive() + { + var map1 = new MapField(); + map1.Add("a", "v1"); + map1.Add("b", "v2"); + + var map2 = new MapField(); + map2.Add("b", "v2"); + map2.Add("a", "v1"); + + EqualityTester.AssertEquality(map1, map2); + } + + [Test] + public void EqualityIsKeySensitive() + { + var map1 = new MapField(); + map1.Add("first key", "v1"); + map1.Add("second key", "v2"); + + var map2 = new MapField(); + map2.Add("third key", "v1"); + map2.Add("fourth key", "v2"); + + EqualityTester.AssertInequality(map1, map2); + } + + [Test] + public void Equality_Simple() + { + var map = new MapField(); + EqualityTester.AssertEquality(map, map); + EqualityTester.AssertInequality(map, null); + Assert.IsFalse(map.Equals(new object())); + } + + [Test] + public void EqualityIsValueSensitive() + { + // Note: Without some care, it's a little easier than one might + // hope to see hash collisions, but only in some environments... + var map1 = new MapField(); + map1.Add("a", "first value"); + map1.Add("b", "second value"); + + var map2 = new MapField(); + map2.Add("a", "third value"); + map2.Add("b", "fourth value"); + + EqualityTester.AssertInequality(map1, map2); + } + + [Test] + public void EqualityHandlesNullValues() + { + var map1 = new MapField(); + map1.Add("a", new ForeignMessage { C = 10 }); + map1.Add("b", null); + + var map2 = new MapField(); + map2.Add("a", new ForeignMessage { C = 10 }); + map2.Add("b", null); + + EqualityTester.AssertEquality(map1, map2); + // Check the null value isn't ignored entirely... + Assert.IsTrue(map1.Remove("b")); + EqualityTester.AssertInequality(map1, map2); + map1.Add("b", new ForeignMessage()); + EqualityTester.AssertInequality(map1, map2); + map1["b"] = null; + EqualityTester.AssertEquality(map1, map2); + } + + [Test] + public void Add_Dictionary() + { + var map1 = new MapField + { + { "x", "y" }, + { "a", "b" } + }; + var map2 = new MapField + { + { "before", "" }, + map1, + { "after", "" } + }; + var expected = new MapField + { + { "before", "" }, + { "x", "y" }, + { "a", "b" }, + { "after", "" } + }; + Assert.AreEqual(expected, map2); + CollectionAssert.AreEqual(new[] { "before", "x", "a", "after" }, map2.Keys); + } + + // General IDictionary behavior tests + [Test] + public void Add_KeyAlreadyExists() + { + var map = new MapField(); + map.Add("foo", "bar"); + Assert.Throws(() => map.Add("foo", "baz")); + } + + [Test] + public void Add_Pair() + { + var map = new MapField(); + ICollection> collection = map; + collection.Add(NewKeyValuePair("x", "y")); + Assert.AreEqual("y", map["x"]); + Assert.Throws(() => collection.Add(NewKeyValuePair("x", "z"))); + } + + [Test] + public void Contains_Pair() + { + var map = new MapField { { "x", "y" } }; + ICollection> collection = map; + Assert.IsTrue(collection.Contains(NewKeyValuePair("x", "y"))); + Assert.IsFalse(collection.Contains(NewKeyValuePair("x", "z"))); + Assert.IsFalse(collection.Contains(NewKeyValuePair("z", "y"))); + } + + [Test] + public void Remove_Key() + { + var map = new MapField(); + map.Add("foo", "bar"); + Assert.AreEqual(1, map.Count); + Assert.IsFalse(map.Remove("missing")); + Assert.AreEqual(1, map.Count); + Assert.IsTrue(map.Remove("foo")); + Assert.AreEqual(0, map.Count); + Assert.Throws(() => map.Remove(null)); + } + + [Test] + public void Remove_Pair() + { + var map = new MapField(); + map.Add("foo", "bar"); + ICollection> collection = map; + Assert.AreEqual(1, map.Count); + Assert.IsFalse(collection.Remove(NewKeyValuePair("wrong key", "bar"))); + Assert.AreEqual(1, map.Count); + Assert.IsFalse(collection.Remove(NewKeyValuePair("foo", "wrong value"))); + Assert.AreEqual(1, map.Count); + Assert.IsTrue(collection.Remove(NewKeyValuePair("foo", "bar"))); + Assert.AreEqual(0, map.Count); + Assert.Throws(() => collection.Remove(new KeyValuePair(null, ""))); + } + + [Test] + public void CopyTo_Pair() + { + var map = new MapField(); + map.Add("foo", "bar"); + ICollection> collection = map; + KeyValuePair[] array = new KeyValuePair[3]; + collection.CopyTo(array, 1); + Assert.AreEqual(NewKeyValuePair("foo", "bar"), array[1]); + } + + [Test] + public void Clear() + { + var map = new MapField { { "x", "y" } }; + Assert.AreEqual(1, map.Count); + map.Clear(); + Assert.AreEqual(0, map.Count); + map.Add("x", "y"); + Assert.AreEqual(1, map.Count); + } + + [Test] + public void Indexer_Get() + { + var map = new MapField { { "x", "y" } }; + Assert.AreEqual("y", map["x"]); + Assert.Throws(() => { var ignored = map["z"]; }); + } + + [Test] + public void Indexer_Set() + { + var map = new MapField(); + map["x"] = "y"; + Assert.AreEqual("y", map["x"]); + map["x"] = "z"; // This won't throw, unlike Add. + Assert.AreEqual("z", map["x"]); + } + + [Test] + public void GetEnumerator_NonGeneric() + { + IEnumerable map = new MapField { { "x", "y" } }; + CollectionAssert.AreEqual(new[] { new KeyValuePair("x", "y") }, + map.Cast().ToList()); + } + + // Test for the explicitly-implemented non-generic IDictionary interface + [Test] + public void IDictionary_GetEnumerator() + { + IDictionary map = new MapField { { "x", "y" } }; + var enumerator = map.GetEnumerator(); + + // Commented assertions show an ideal situation - it looks like + // the LinkedList enumerator doesn't throw when you ask for the current entry + // at an inappropriate time; fixing this would be more work than it's worth. + // Assert.Throws(() => enumerator.Current.GetHashCode()); + Assert.IsTrue(enumerator.MoveNext()); + Assert.AreEqual("x", enumerator.Key); + Assert.AreEqual("y", enumerator.Value); + Assert.AreEqual(new DictionaryEntry("x", "y"), enumerator.Current); + Assert.AreEqual(new DictionaryEntry("x", "y"), enumerator.Entry); + Assert.IsFalse(enumerator.MoveNext()); + // Assert.Throws(() => enumerator.Current.GetHashCode()); + enumerator.Reset(); + // Assert.Throws(() => enumerator.Current.GetHashCode()); + Assert.IsTrue(enumerator.MoveNext()); + Assert.AreEqual("x", enumerator.Key); // Assume the rest are okay + } + + [Test] + public void IDictionary_Add() + { + var map = new MapField { { "x", "y" } }; + IDictionary dictionary = map; + dictionary.Add("a", "b"); + Assert.AreEqual("b", map["a"]); + Assert.Throws(() => dictionary.Add("a", "duplicate")); + Assert.Throws(() => dictionary.Add(new object(), "key is bad")); + Assert.Throws(() => dictionary.Add("value is bad", new object())); + } + + [Test] + public void IDictionary_Contains() + { + var map = new MapField { { "x", "y" } }; + IDictionary dictionary = map; + + Assert.IsFalse(dictionary.Contains("a")); + Assert.IsFalse(dictionary.Contains(5)); + // Surprising, but IDictionary.Contains is only about keys. + Assert.IsFalse(dictionary.Contains(new DictionaryEntry("x", "y"))); + Assert.IsTrue(dictionary.Contains("x")); + } + + [Test] + public void IDictionary_Remove() + { + var map = new MapField { { "x", "y" } }; + IDictionary dictionary = map; + dictionary.Remove("a"); + Assert.AreEqual(1, dictionary.Count); + dictionary.Remove(5); + Assert.AreEqual(1, dictionary.Count); + dictionary.Remove(new DictionaryEntry("x", "y")); + Assert.AreEqual(1, dictionary.Count); + dictionary.Remove("x"); + Assert.AreEqual(0, dictionary.Count); + Assert.Throws(() => dictionary.Remove(null)); + + map.Freeze(); + // Call should fail even though it clearly doesn't contain 5 as a key. + Assert.Throws(() => dictionary.Remove(5)); + } + + [Test] + public void IDictionary_CopyTo() + { + var map = new MapField { { "x", "y" } }; + IDictionary dictionary = map; + var array = new DictionaryEntry[3]; + dictionary.CopyTo(array, 1); + CollectionAssert.AreEqual(new[] { default(DictionaryEntry), new DictionaryEntry("x", "y"), default(DictionaryEntry) }, + array); + var objectArray = new object[3]; + dictionary.CopyTo(objectArray, 1); + CollectionAssert.AreEqual(new object[] { null, new DictionaryEntry("x", "y"), null }, + objectArray); + } + + [Test] + public void IDictionary_IsFixedSize() + { + var map = new MapField { { "x", "y" } }; + IDictionary dictionary = map; + Assert.IsFalse(dictionary.IsFixedSize); + map.Freeze(); + Assert.IsTrue(dictionary.IsFixedSize); + } + + [Test] + public void IDictionary_Keys() + { + IDictionary dictionary = new MapField { { "x", "y" } }; + CollectionAssert.AreEqual(new[] { "x" }, dictionary.Keys); + } + + [Test] + public void IDictionary_Values() + { + IDictionary dictionary = new MapField { { "x", "y" } }; + CollectionAssert.AreEqual(new[] { "y" }, dictionary.Values); + } + + [Test] + public void IDictionary_IsSynchronized() + { + IDictionary dictionary = new MapField { { "x", "y" } }; + Assert.IsFalse(dictionary.IsSynchronized); + } + + [Test] + public void IDictionary_SyncRoot() + { + IDictionary dictionary = new MapField { { "x", "y" } }; + Assert.AreSame(dictionary, dictionary.SyncRoot); + } + + [Test] + public void IDictionary_Indexer_Get() + { + IDictionary dictionary = new MapField { { "x", "y" } }; + Assert.AreEqual("y", dictionary["x"]); + Assert.IsNull(dictionary["a"]); + Assert.IsNull(dictionary[5]); + Assert.Throws(() => dictionary[null].GetHashCode()); + } + + [Test] + public void IDictionary_Indexer_Set() + { + var map = new MapField { { "x", "y" } }; + IDictionary dictionary = map; + map["a"] = "b"; + Assert.AreEqual("b", map["a"]); + map["a"] = "c"; + Assert.AreEqual("c", map["a"]); + Assert.Throws(() => dictionary[5] = "x"); + Assert.Throws(() => dictionary["x"] = 5); + Assert.Throws(() => dictionary[null] = "z"); + Assert.Throws(() => dictionary["x"] = null); + map.Freeze(); + // Note: Not InvalidOperationException. + Assert.Throws(() => dictionary["a"] = "c"); + } + + [Test] + public void AllowNullValues_Property() + { + // Non-message reference type values are non-nullable by default, but can be overridden + Assert.IsFalse(new MapField().AllowsNullValues); + Assert.IsFalse(new MapField(false).AllowsNullValues); + Assert.IsTrue(new MapField(true).AllowsNullValues); + + // Non-nullable value type values are never nullable + Assert.IsFalse(new MapField().AllowsNullValues); + Assert.IsFalse(new MapField(false).AllowsNullValues); + Assert.Throws(() => new MapField(true)); + + // Message type values are nullable by default, but can be overridden + Assert.IsTrue(new MapField().AllowsNullValues); + Assert.IsFalse(new MapField(false).AllowsNullValues); + Assert.IsTrue(new MapField(true).AllowsNullValues); + + // Nullable value type values are nullable by default, but can be overridden + Assert.IsTrue(new MapField().AllowsNullValues); + Assert.IsFalse(new MapField(false).AllowsNullValues); + Assert.IsTrue(new MapField(true).AllowsNullValues); + } + + private static KeyValuePair NewKeyValuePair(TKey key, TValue value) + { + return new KeyValuePair(key, value); + } + } +} diff --git a/csharp/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs b/csharp/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs new file mode 100644 index 00000000..25be7731 --- /dev/null +++ b/csharp/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs @@ -0,0 +1,639 @@ +#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 System; +using System.Collections; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using Google.Protobuf.TestProtos; +using NUnit.Framework; + +namespace Google.Protobuf.Collections +{ + public class RepeatedFieldTest + { + [Test] + public void NullValuesRejected() + { + var list = new RepeatedField(); + Assert.Throws(() => list.Add((string)null)); + Assert.Throws(() => list.Add((IEnumerable)null)); + Assert.Throws(() => list.Add((RepeatedField)null)); + Assert.Throws(() => list.Contains(null)); + Assert.Throws(() => list.IndexOf(null)); + } + + [Test] + public void Add_SingleItem() + { + var list = new RepeatedField(); + list.Add("foo"); + Assert.AreEqual(1, list.Count); + Assert.AreEqual("foo", list[0]); + } + + [Test] + public void Add_Sequence() + { + var list = new RepeatedField(); + list.Add(new[] { "foo", "bar" }); + Assert.AreEqual(2, list.Count); + Assert.AreEqual("foo", list[0]); + Assert.AreEqual("bar", list[1]); + } + + [Test] + public void Add_RepeatedField() + { + var list = new RepeatedField { "original" }; + list.Add(new RepeatedField { "foo", "bar" }); + Assert.AreEqual(3, list.Count); + Assert.AreEqual("original", list[0]); + Assert.AreEqual("foo", list[1]); + Assert.AreEqual("bar", list[2]); + } + + [Test] + public void RemoveAt_Valid() + { + var list = new RepeatedField { "first", "second", "third" }; + list.RemoveAt(1); + CollectionAssert.AreEqual(new[] { "first", "third" }, list); + // Just check that these don't throw... + list.RemoveAt(list.Count - 1); // Now the count will be 1... + list.RemoveAt(0); + Assert.AreEqual(0, list.Count); + } + + [Test] + public void RemoveAt_Invalid() + { + var list = new RepeatedField { "first", "second", "third" }; + Assert.Throws(() => list.RemoveAt(-1)); + Assert.Throws(() => list.RemoveAt(3)); + } + + [Test] + public void Insert_Valid() + { + var list = new RepeatedField { "first", "second" }; + list.Insert(1, "middle"); + CollectionAssert.AreEqual(new[] { "first", "middle", "second" }, list); + list.Insert(3, "end"); + CollectionAssert.AreEqual(new[] { "first", "middle", "second", "end" }, list); + list.Insert(0, "start"); + CollectionAssert.AreEqual(new[] { "start", "first", "middle", "second", "end" }, list); + } + + [Test] + public void Insert_Invalid() + { + var list = new RepeatedField { "first", "second" }; + Assert.Throws(() => list.Insert(-1, "foo")); + Assert.Throws(() => list.Insert(3, "foo")); + Assert.Throws(() => list.Insert(0, null)); + } + + [Test] + public void Equals_RepeatedField() + { + var list = new RepeatedField { "first", "second" }; + Assert.IsFalse(list.Equals((RepeatedField) null)); + Assert.IsTrue(list.Equals(list)); + Assert.IsFalse(list.Equals(new RepeatedField { "first", "third" })); + Assert.IsFalse(list.Equals(new RepeatedField { "first" })); + Assert.IsTrue(list.Equals(new RepeatedField { "first", "second" })); + } + + [Test] + public void Equals_Object() + { + var list = new RepeatedField { "first", "second" }; + Assert.IsFalse(list.Equals((object) null)); + Assert.IsTrue(list.Equals((object) list)); + Assert.IsFalse(list.Equals((object) new RepeatedField { "first", "third" })); + Assert.IsFalse(list.Equals((object) new RepeatedField { "first" })); + Assert.IsTrue(list.Equals((object) new RepeatedField { "first", "second" })); + Assert.IsFalse(list.Equals(new object())); + } + + [Test] + public void GetEnumerator_GenericInterface() + { + IEnumerable list = new RepeatedField { "first", "second" }; + // Select gets rid of the optimizations in ToList... + CollectionAssert.AreEqual(new[] { "first", "second" }, list.Select(x => x).ToList()); + } + + [Test] + public void GetEnumerator_NonGenericInterface() + { + IEnumerable list = new RepeatedField { "first", "second" }; + CollectionAssert.AreEqual(new[] { "first", "second" }, list.Cast().ToList()); + } + + [Test] + public void CopyTo() + { + var list = new RepeatedField { "first", "second" }; + string[] stringArray = new string[4]; + list.CopyTo(stringArray, 1); + CollectionAssert.AreEqual(new[] { null, "first", "second", null }, stringArray); + } + + [Test] + public void Indexer_Get() + { + var list = new RepeatedField { "first", "second" }; + Assert.AreEqual("first", list[0]); + Assert.AreEqual("second", list[1]); + Assert.Throws(() => list[-1].GetHashCode()); + Assert.Throws(() => list[2].GetHashCode()); + } + + [Test] + public void Indexer_Set() + { + var list = new RepeatedField { "first", "second" }; + list[0] = "changed"; + Assert.AreEqual("changed", list[0]); + Assert.Throws(() => list[0] = null); + Assert.Throws(() => list[-1] = "bad"); + Assert.Throws(() => list[2] = "bad"); + } + + [Test] + public void Freeze_FreezesElements() + { + var list = new RepeatedField { new TestAllTypes() }; + Assert.IsFalse(list[0].IsFrozen); + list.Freeze(); + Assert.IsTrue(list[0].IsFrozen); + } + + [Test] + public void Freeze_PreventsMutations() + { + var list = new RepeatedField { 0 }; + list.Freeze(); + Assert.Throws(() => list.Add(1)); + Assert.Throws(() => list[0] = 1); + Assert.Throws(() => list.Clear()); + Assert.Throws(() => list.RemoveAt(0)); + Assert.Throws(() => list.Remove(0)); + Assert.Throws(() => list.Insert(0, 0)); + } + + [Test] + public void Freeze_ReportsFrozen() + { + var list = new RepeatedField { 0 }; + Assert.IsFalse(list.IsFrozen); + Assert.IsFalse(list.IsReadOnly); + list.Freeze(); + Assert.IsTrue(list.IsFrozen); + Assert.IsTrue(list.IsReadOnly); + } + + [Test] + public void Clone_ReturnsMutable() + { + var list = new RepeatedField { 0 }; + list.Freeze(); + var clone = list.Clone(); + clone[0] = 1; + } + + [Test] + public void Enumerator() + { + var list = new RepeatedField { "first", "second" }; + using (var enumerator = list.GetEnumerator()) + { + Assert.IsTrue(enumerator.MoveNext()); + Assert.AreEqual("first", enumerator.Current); + Assert.IsTrue(enumerator.MoveNext()); + Assert.AreEqual("second", enumerator.Current); + Assert.IsFalse(enumerator.MoveNext()); + Assert.IsFalse(enumerator.MoveNext()); + } + } + + [Test] + public void AddEntriesFrom_PackedInt32() + { + uint packedTag = WireFormat.MakeTag(10, WireFormat.WireType.LengthDelimited); + var stream = new MemoryStream(); + var output = CodedOutputStream.CreateInstance(stream); + var length = CodedOutputStream.ComputeInt32Size(10) + + CodedOutputStream.ComputeInt32Size(999) + + CodedOutputStream.ComputeInt32Size(-1000); + output.WriteTag(packedTag); + output.WriteRawVarint32((uint) length); + output.WriteInt32(10); + output.WriteInt32(999); + output.WriteInt32(-1000); + output.Flush(); + stream.Position = 0; + + // Deliberately "expecting" a non-packed tag, but we detect that the data is + // actually packed. + uint nonPackedTag = WireFormat.MakeTag(10, WireFormat.WireType.LengthDelimited); + var field = new RepeatedField(); + var input = CodedInputStream.CreateInstance(stream); + input.AssertNextTag(packedTag); + field.AddEntriesFrom(input, FieldCodec.ForInt32(nonPackedTag)); + CollectionAssert.AreEqual(new[] { 10, 999, -1000 }, field); + Assert.IsTrue(input.IsAtEnd); + } + + [Test] + public void AddEntriesFrom_NonPackedInt32() + { + uint nonPackedTag = WireFormat.MakeTag(10, WireFormat.WireType.Varint); + var stream = new MemoryStream(); + var output = CodedOutputStream.CreateInstance(stream); + output.WriteTag(nonPackedTag); + output.WriteInt32(10); + output.WriteTag(nonPackedTag); + output.WriteInt32(999); + output.WriteTag(nonPackedTag); + output.WriteInt32(-1000); // Just for variety... + output.Flush(); + stream.Position = 0; + + // Deliberately "expecting" a packed tag, but we detect that the data is + // actually not packed. + uint packedTag = WireFormat.MakeTag(10, WireFormat.WireType.LengthDelimited); + var field = new RepeatedField(); + var input = CodedInputStream.CreateInstance(stream); + input.AssertNextTag(nonPackedTag); + field.AddEntriesFrom(input, FieldCodec.ForInt32(packedTag)); + CollectionAssert.AreEqual(new[] { 10, 999, -1000 }, field); + Assert.IsTrue(input.IsAtEnd); + } + + [Test] + public void AddEntriesFrom_String() + { + uint tag = WireFormat.MakeTag(10, WireFormat.WireType.LengthDelimited); + var stream = new MemoryStream(); + var output = CodedOutputStream.CreateInstance(stream); + output.WriteTag(tag); + output.WriteString("Foo"); + output.WriteTag(tag); + output.WriteString(""); + output.WriteTag(tag); + output.WriteString("Bar"); + output.Flush(); + stream.Position = 0; + + var field = new RepeatedField(); + var input = CodedInputStream.CreateInstance(stream); + input.AssertNextTag(tag); + field.AddEntriesFrom(input, FieldCodec.ForString(tag)); + CollectionAssert.AreEqual(new[] { "Foo", "", "Bar" }, field); + Assert.IsTrue(input.IsAtEnd); + } + + [Test] + public void AddEntriesFrom_Message() + { + var message1 = new ForeignMessage { C = 2000 }; + var message2 = new ForeignMessage { C = -250 }; + + uint tag = WireFormat.MakeTag(10, WireFormat.WireType.LengthDelimited); + var stream = new MemoryStream(); + var output = CodedOutputStream.CreateInstance(stream); + output.WriteTag(tag); + output.WriteMessage(message1); + output.WriteTag(tag); + output.WriteMessage(message2); + output.Flush(); + stream.Position = 0; + + var field = new RepeatedField(); + var input = CodedInputStream.CreateInstance(stream); + input.AssertNextTag(tag); + field.AddEntriesFrom(input, FieldCodec.ForMessage(tag, ForeignMessage.Parser)); + CollectionAssert.AreEqual(new[] { message1, message2}, field); + Assert.IsTrue(input.IsAtEnd); + } + + [Test] + public void WriteTo_PackedInt32() + { + uint tag = WireFormat.MakeTag(10, WireFormat.WireType.LengthDelimited); + var field = new RepeatedField { 10, 1000, 1000000 }; + var stream = new MemoryStream(); + var output = CodedOutputStream.CreateInstance(stream); + field.WriteTo(output, FieldCodec.ForInt32(tag)); + output.Flush(); + stream.Position = 0; + + var input = CodedInputStream.CreateInstance(stream); + input.AssertNextTag(tag); + var length = input.ReadLength(); + Assert.AreEqual(10, input.ReadInt32()); + Assert.AreEqual(1000, input.ReadInt32()); + Assert.AreEqual(1000000, input.ReadInt32()); + Assert.IsTrue(input.IsAtEnd); + Assert.AreEqual(1 + CodedOutputStream.ComputeLengthSize(length) + length, stream.Length); + } + + [Test] + public void WriteTo_NonPackedInt32() + { + uint tag = WireFormat.MakeTag(10, WireFormat.WireType.Varint); + var field = new RepeatedField { 10, 1000, 1000000}; + var stream = new MemoryStream(); + var output = CodedOutputStream.CreateInstance(stream); + field.WriteTo(output, FieldCodec.ForInt32(tag)); + output.Flush(); + stream.Position = 0; + + var input = CodedInputStream.CreateInstance(stream); + input.AssertNextTag(tag); + Assert.AreEqual(10, input.ReadInt32()); + input.AssertNextTag(tag); + Assert.AreEqual(1000, input.ReadInt32()); + input.AssertNextTag(tag); + Assert.AreEqual(1000000, input.ReadInt32()); + Assert.IsTrue(input.IsAtEnd); + } + + [Test] + public void WriteTo_String() + { + uint tag = WireFormat.MakeTag(10, WireFormat.WireType.LengthDelimited); + var field = new RepeatedField { "Foo", "", "Bar" }; + var stream = new MemoryStream(); + var output = CodedOutputStream.CreateInstance(stream); + field.WriteTo(output, FieldCodec.ForString(tag)); + output.Flush(); + stream.Position = 0; + + var input = CodedInputStream.CreateInstance(stream); + input.AssertNextTag(tag); + Assert.AreEqual("Foo", input.ReadString()); + input.AssertNextTag(tag); + Assert.AreEqual("", input.ReadString()); + input.AssertNextTag(tag); + Assert.AreEqual("Bar", input.ReadString()); + Assert.IsTrue(input.IsAtEnd); + } + + [Test] + public void WriteTo_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 stream = new MemoryStream(); + var output = CodedOutputStream.CreateInstance(stream); + field.WriteTo(output, FieldCodec.ForMessage(tag, ForeignMessage.Parser)); + output.Flush(); + stream.Position = 0; + + var input = CodedInputStream.CreateInstance(stream); + input.AssertNextTag(tag); + Assert.AreEqual(message1, input.ReadMessage(ForeignMessage.Parser)); + input.AssertNextTag(tag); + Assert.AreEqual(message2, input.ReadMessage(ForeignMessage.Parser)); + Assert.IsTrue(input.IsAtEnd); + } + + [Test] + public void CalculateSize_VariableSizeNonPacked() + { + var list = new RepeatedField { 1, 500, 1 }; + var tag = WireFormat.MakeTag(1, WireFormat.WireType.Varint); + // 2 bytes for the first entry, 3 bytes for the second, 2 bytes for the third + Assert.AreEqual(7, list.CalculateSize(FieldCodec.ForInt32(tag))); + } + + [Test] + public void CalculateSize_FixedSizeNonPacked() + { + var list = new RepeatedField { 1, 500, 1 }; + var tag = WireFormat.MakeTag(1, WireFormat.WireType.Fixed32); + // 5 bytes for the each entry + Assert.AreEqual(15, list.CalculateSize(FieldCodec.ForSFixed32(tag))); + } + + [Test] + public void CalculateSize_VariableSizePacked() + { + var list = new RepeatedField { 1, 500, 1}; + var tag = WireFormat.MakeTag(1, WireFormat.WireType.LengthDelimited); + // 1 byte for the tag, 1 byte for the length, + // 1 byte for the first entry, 2 bytes for the second, 1 byte for the third + Assert.AreEqual(6, list.CalculateSize(FieldCodec.ForInt32(tag))); + } + + [Test] + public void CalculateSize_FixedSizePacked() + { + var list = new RepeatedField { 1, 500, 1 }; + var tag = WireFormat.MakeTag(1, WireFormat.WireType.LengthDelimited); + // 1 byte for the tag, 1 byte for the length, 4 bytes per entry + Assert.AreEqual(14, list.CalculateSize(FieldCodec.ForSFixed32(tag))); + } + + [Test] + public void TestNegativeEnumArray() + { + int arraySize = 1 + 1 + (11 * 5); + int msgSize = arraySize; + byte[] bytes = new byte[msgSize]; + CodedOutputStream output = CodedOutputStream.CreateInstance(bytes); + uint tag = WireFormat.MakeTag(8, WireFormat.WireType.Varint); + for (int i = 0; i >= -5; i--) + { + output.WriteTag(tag); + output.WriteEnum(i); + } + + Assert.AreEqual(0, output.SpaceLeft); + + CodedInputStream input = CodedInputStream.CreateInstance(bytes); + Assert.IsTrue(input.ReadTag(out tag)); + + RepeatedField values = new RepeatedField(); + values.AddEntriesFrom(input, FieldCodec.ForEnum(tag, x => (int)x, x => (SampleEnum)x)); + + Assert.AreEqual(6, values.Count); + Assert.AreEqual(SampleEnum.None, values[0]); + Assert.AreEqual(((SampleEnum)(-1)), values[1]); + Assert.AreEqual(SampleEnum.NegativeValue, values[2]); + Assert.AreEqual(((SampleEnum)(-3)), values[3]); + Assert.AreEqual(((SampleEnum)(-4)), values[4]); + Assert.AreEqual(((SampleEnum)(-5)), values[5]); + } + + + [Test] + public void TestNegativeEnumPackedArray() + { + int arraySize = 1 + (10 * 5); + int msgSize = 1 + 1 + arraySize; + byte[] bytes = new byte[msgSize]; + CodedOutputStream output = CodedOutputStream.CreateInstance(bytes); + // Length-delimited to show we want the packed representation + uint tag = WireFormat.MakeTag(8, WireFormat.WireType.LengthDelimited); + output.WriteTag(tag); + int size = 0; + for (int i = 0; i >= -5; i--) + { + size += CodedOutputStream.ComputeEnumSize(i); + } + output.WriteRawVarint32((uint)size); + for (int i = 0; i >= -5; i--) + { + output.WriteEnum(i); + } + Assert.AreEqual(0, output.SpaceLeft); + + CodedInputStream input = CodedInputStream.CreateInstance(bytes); + Assert.IsTrue(input.ReadTag(out tag)); + + RepeatedField values = new RepeatedField(); + values.AddEntriesFrom(input, FieldCodec.ForEnum(tag, x => (int)x, x => (SampleEnum)x)); + + Assert.AreEqual(6, values.Count); + Assert.AreEqual(SampleEnum.None, values[0]); + Assert.AreEqual(((SampleEnum)(-1)), values[1]); + Assert.AreEqual(SampleEnum.NegativeValue, values[2]); + Assert.AreEqual(((SampleEnum)(-3)), values[3]); + Assert.AreEqual(((SampleEnum)(-4)), values[4]); + Assert.AreEqual(((SampleEnum)(-5)), values[5]); + } + + // Fairly perfunctory tests for the non-generic IList implementation + [Test] + public void IList_Indexer() + { + var field = new RepeatedField { "first", "second" }; + IList list = field; + Assert.AreEqual("first", list[0]); + list[1] = "changed"; + Assert.AreEqual("changed", field[1]); + } + + [Test] + public void IList_Contains() + { + IList list = new RepeatedField { "first", "second" }; + Assert.IsTrue(list.Contains("second")); + Assert.IsFalse(list.Contains("third")); + Assert.IsFalse(list.Contains(new object())); + } + + [Test] + public void IList_Add() + { + IList list = new RepeatedField { "first", "second" }; + list.Add("third"); + CollectionAssert.AreEqual(new[] { "first", "second", "third" }, list); + } + + [Test] + public void IList_Remove() + { + IList list = new RepeatedField { "first", "second" }; + list.Remove("third"); // No-op, no exception + list.Remove(new object()); // No-op, no exception + list.Remove("first"); + CollectionAssert.AreEqual(new[] { "second" }, list); + } + + [Test] + public void IList_IsFixedSize() + { + var field = new RepeatedField { "first", "second" }; + IList list = field; + Assert.IsFalse(list.IsFixedSize); + field.Freeze(); + Assert.IsTrue(list.IsFixedSize); + } + + [Test] + public void IList_IndexOf() + { + IList list = new RepeatedField { "first", "second" }; + Assert.AreEqual(1, list.IndexOf("second")); + Assert.AreEqual(-1, list.IndexOf("third")); + Assert.AreEqual(-1, list.IndexOf(new object())); + } + + [Test] + public void IList_SyncRoot() + { + IList list = new RepeatedField { "first", "second" }; + Assert.AreSame(list, list.SyncRoot); + } + + [Test] + public void IList_CopyTo() + { + IList list = new RepeatedField { "first", "second" }; + string[] stringArray = new string[4]; + list.CopyTo(stringArray, 1); + CollectionAssert.AreEqual(new[] { null, "first", "second", null }, stringArray); + + object[] objectArray = new object[4]; + list.CopyTo(objectArray, 1); + CollectionAssert.AreEqual(new[] { null, "first", "second", null }, objectArray); + + Assert.Throws(() => list.CopyTo(new StringBuilder[4], 1)); + Assert.Throws(() => list.CopyTo(new int[4], 1)); + } + + [Test] + public void IList_IsSynchronized() + { + IList list = new RepeatedField { "first", "second" }; + Assert.IsFalse(list.IsSynchronized); + } + + [Test] + public void IList_Insert() + { + IList list = new RepeatedField { "first", "second" }; + list.Insert(1, "middle"); + CollectionAssert.AreEqual(new[] { "first", "middle", "second" }, list); + } + } +} diff --git a/csharp/src/Google.Protobuf.Test/DeprecatedMemberTest.cs b/csharp/src/Google.Protobuf.Test/DeprecatedMemberTest.cs new file mode 100644 index 00000000..34d5b9f9 --- /dev/null +++ b/csharp/src/Google.Protobuf.Test/DeprecatedMemberTest.cs @@ -0,0 +1,55 @@ +#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 System; +using System.Reflection; +using Google.Protobuf.TestProtos; +using NUnit.Framework; + +namespace Google.Protobuf +{ + public class DeprecatedMemberTest + { + private static void AssertIsDeprecated(MemberInfo member) + { + Assert.NotNull(member); + Assert.IsTrue(member.IsDefined(typeof(ObsoleteAttribute), false), "Member not obsolete: " + member); + } + + [Test] + public void TestDepreatedPrimitiveValue() + { + AssertIsDeprecated(typeof(TestDeprecatedFields).GetProperty("DeprecatedInt32")); + } + + } +} diff --git a/csharp/src/Google.Protobuf.Test/EqualityTester.cs b/csharp/src/Google.Protobuf.Test/EqualityTester.cs new file mode 100644 index 00000000..a669baba --- /dev/null +++ b/csharp/src/Google.Protobuf.Test/EqualityTester.cs @@ -0,0 +1,64 @@ +#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 System; +using NUnit.Framework; + +namespace Google.Protobuf +{ + /// + /// Helper methods when testing equality. NUnit's Assert.AreEqual and + /// Assert.AreNotEqual methods try to be clever with collections, which can + /// be annoying... + /// + internal static class EqualityTester + { + public static void AssertEquality(T first, T second) where T : IEquatable + { + Assert.IsTrue(first.Equals(second)); + Assert.IsTrue(first.Equals((object) second)); + Assert.AreEqual(first.GetHashCode(), second.GetHashCode()); + } + + public static void AssertInequality(T first, T second) where T : IEquatable + { + Assert.IsFalse(first.Equals(second)); + Assert.IsFalse(first.Equals((object) second)); + // While this isn't a requirement, the chances of this test failing due to + // coincidence rather than a bug are very small. + if (first != null && second != null) + { + Assert.AreNotEqual(first.GetHashCode(), second.GetHashCode()); + } + } + } +} diff --git a/csharp/src/Google.Protobuf.Test/FieldCodecTest.cs b/csharp/src/Google.Protobuf.Test/FieldCodecTest.cs new file mode 100644 index 00000000..c6ed2a21 --- /dev/null +++ b/csharp/src/Google.Protobuf.Test/FieldCodecTest.cs @@ -0,0 +1,193 @@ +#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 System.Collections.Generic; +using System.IO; +using Google.Protobuf.TestProtos; +using NUnit.Framework; + +namespace Google.Protobuf +{ + public class FieldCodecTest + { + private static readonly List Codecs = new List + { + new FieldCodecTestData(FieldCodec.ForBool(100), true, "Bool"), + new FieldCodecTestData(FieldCodec.ForString(100), "sample", "String"), + new FieldCodecTestData(FieldCodec.ForBytes(100), ByteString.CopyFrom(1, 2, 3), "Bytes"), + new FieldCodecTestData(FieldCodec.ForInt32(100), -1000, "Int32"), + new FieldCodecTestData(FieldCodec.ForSInt32(100), -1000, "SInt32"), + new FieldCodecTestData(FieldCodec.ForSFixed32(100), -1000, "SFixed32"), + new FieldCodecTestData(FieldCodec.ForUInt32(100), 1234, "UInt32"), + new FieldCodecTestData(FieldCodec.ForFixed32(100), 1234, "Fixed32"), + new FieldCodecTestData(FieldCodec.ForInt64(100), -1000, "Int64"), + new FieldCodecTestData(FieldCodec.ForSInt64(100), -1000, "SInt64"), + new FieldCodecTestData(FieldCodec.ForSFixed64(100), -1000, "SFixed64"), + new FieldCodecTestData(FieldCodec.ForUInt64(100), 1234, "UInt64"), + new FieldCodecTestData(FieldCodec.ForFixed64(100), 1234, "Fixed64"), + new FieldCodecTestData(FieldCodec.ForFloat(100), 1234.5f, "Float"), + new FieldCodecTestData(FieldCodec.ForDouble(100), 1234567890.5d, "Double"), + new FieldCodecTestData( + FieldCodec.ForEnum(100, t => (int) t, t => (ForeignEnum) t), ForeignEnum.FOREIGN_BAZ, "Enum"), + new FieldCodecTestData( + FieldCodec.ForMessage(100, ForeignMessage.Parser), new ForeignMessage { C = 10 }, "Message"), + }; + + [Test, TestCaseSource("Codecs")] + public void RoundTripWithTag(ICodecTestData codec) + { + codec.TestRoundTripWithTag(); + } + + [Test, TestCaseSource("Codecs")] + public void RoundTripRaw(ICodecTestData codec) + { + codec.TestRoundTripRaw(); + } + + [Test, TestCaseSource("Codecs")] + public void CalculateSize(ICodecTestData codec) + { + codec.TestCalculateSizeWithTag(); + } + + [Test, TestCaseSource("Codecs")] + public void DefaultValue(ICodecTestData codec) + { + codec.TestDefaultValue(); + } + + [Test, TestCaseSource("Codecs")] + public void FixedSize(ICodecTestData codec) + { + codec.TestFixedSize(); + } + + // This is ugly, but it means we can have a non-generic interface. + // It feels like NUnit should support this better, but I don't know + // of any better ways right now. + public interface ICodecTestData + { + void TestRoundTripRaw(); + void TestRoundTripWithTag(); + void TestCalculateSizeWithTag(); + void TestDefaultValue(); + void TestFixedSize(); + } + + public class FieldCodecTestData : ICodecTestData + { + private readonly FieldCodec codec; + private readonly T sampleValue; + private readonly string name; + + public FieldCodecTestData(FieldCodec codec, T sampleValue, string name) + { + this.codec = codec; + this.sampleValue = sampleValue; + this.name = name; + } + + public void TestRoundTripRaw() + { + var stream = new MemoryStream(); + var codedOutput = CodedOutputStream.CreateInstance(stream); + codec.ValueWriter(codedOutput, sampleValue); + codedOutput.Flush(); + stream.Position = 0; + var codedInput = CodedInputStream.CreateInstance(stream); + Assert.AreEqual(sampleValue, codec.ValueReader(codedInput)); + Assert.IsTrue(codedInput.IsAtEnd); + } + + public void TestRoundTripWithTag() + { + var stream = new MemoryStream(); + var codedOutput = CodedOutputStream.CreateInstance(stream); + codec.WriteTagAndValue(codedOutput, sampleValue); + codedOutput.Flush(); + stream.Position = 0; + var codedInput = CodedInputStream.CreateInstance(stream); + codedInput.AssertNextTag(codec.Tag); + Assert.AreEqual(sampleValue, codec.Read(codedInput)); + Assert.IsTrue(codedInput.IsAtEnd); + } + + public void TestCalculateSizeWithTag() + { + var stream = new MemoryStream(); + var codedOutput = CodedOutputStream.CreateInstance(stream); + codec.WriteTagAndValue(codedOutput, sampleValue); + codedOutput.Flush(); + Assert.AreEqual(stream.Position, codec.CalculateSizeWithTag(sampleValue)); + } + + public void TestDefaultValue() + { + // WriteTagAndValue ignores default values + var stream = new MemoryStream(); + var codedOutput = CodedOutputStream.CreateInstance(stream); + codec.WriteTagAndValue(codedOutput, codec.DefaultValue); + codedOutput.Flush(); + Assert.AreEqual(0, stream.Position); + Assert.AreEqual(0, codec.CalculateSizeWithTag(codec.DefaultValue)); + if (typeof(T).IsValueType) + { + Assert.AreEqual(default(T), codec.DefaultValue); + } + + // The plain ValueWriter/ValueReader delegates don't. + if (codec.DefaultValue != null) // This part isn't appropriate for message types. + { + codedOutput = CodedOutputStream.CreateInstance(stream); + codec.ValueWriter(codedOutput, codec.DefaultValue); + codedOutput.Flush(); + Assert.AreNotEqual(0, stream.Position); + Assert.AreEqual(stream.Position, codec.ValueSizeCalculator(codec.DefaultValue)); + stream.Position = 0; + var codedInput = CodedInputStream.CreateInstance(stream); + Assert.AreEqual(codec.DefaultValue, codec.ValueReader(codedInput)); + } + } + + public void TestFixedSize() + { + Assert.AreEqual(name.Contains("Fixed"), codec.FixedSize != 0); + } + + public override string ToString() + { + return name; + } + } + } +} diff --git a/csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs b/csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs new file mode 100644 index 00000000..acb20b15 --- /dev/null +++ b/csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs @@ -0,0 +1,760 @@ +#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 System; +using System.IO; +using Google.Protobuf.TestProtos; +using NUnit.Framework; +using System.Collections; +using System.Collections.Generic; + +namespace Google.Protobuf +{ + /// + /// Tests around the generated TestAllTypes message. + /// + public class GeneratedMessageTest + { + [Test] + public void EmptyMessageFieldDistinctFromMissingMessageField() + { + // This demonstrates what we're really interested in... + var message1 = new TestAllTypes { SingleForeignMessage = new ForeignMessage() }; + var message2 = new TestAllTypes(); // SingleForeignMessage is null + EqualityTester.AssertInequality(message1, message2); + } + + [Test] + public void DefaultValues() + { + // Single fields + var message = new TestAllTypes(); + Assert.AreEqual(false, message.SingleBool); + Assert.AreEqual(ByteString.Empty, message.SingleBytes); + Assert.AreEqual(0.0, message.SingleDouble); + Assert.AreEqual(0, message.SingleFixed32); + Assert.AreEqual(0L, message.SingleFixed64); + Assert.AreEqual(0.0f, message.SingleFloat); + Assert.AreEqual(ForeignEnum.FOREIGN_UNSPECIFIED, message.SingleForeignEnum); + Assert.IsNull(message.SingleForeignMessage); + Assert.AreEqual(ImportEnum.IMPORT_ENUM_UNSPECIFIED, message.SingleImportEnum); + Assert.IsNull(message.SingleImportMessage); + Assert.AreEqual(0, message.SingleInt32); + Assert.AreEqual(0L, message.SingleInt64); + Assert.AreEqual(TestAllTypes.Types.NestedEnum.NESTED_ENUM_UNSPECIFIED, message.SingleNestedEnum); + Assert.IsNull(message.SingleNestedMessage); + Assert.IsNull(message.SinglePublicImportMessage); + Assert.AreEqual(0, message.SingleSfixed32); + Assert.AreEqual(0L, message.SingleSfixed64); + Assert.AreEqual(0, message.SingleSint32); + Assert.AreEqual(0L, message.SingleSint64); + Assert.AreEqual("", message.SingleString); + Assert.AreEqual(0U, message.SingleUint32); + Assert.AreEqual(0UL, message.SingleUint64); + + // Repeated fields + Assert.AreEqual(0, message.RepeatedBool.Count); + Assert.AreEqual(0, message.RepeatedBytes.Count); + Assert.AreEqual(0, message.RepeatedDouble.Count); + Assert.AreEqual(0, message.RepeatedFixed32.Count); + Assert.AreEqual(0, message.RepeatedFixed64.Count); + Assert.AreEqual(0, message.RepeatedFloat.Count); + Assert.AreEqual(0, message.RepeatedForeignEnum.Count); + Assert.AreEqual(0, message.RepeatedForeignMessage.Count); + Assert.AreEqual(0, message.RepeatedImportEnum.Count); + Assert.AreEqual(0, message.RepeatedImportMessage.Count); + Assert.AreEqual(0, message.RepeatedNestedEnum.Count); + Assert.AreEqual(0, message.RepeatedNestedMessage.Count); + Assert.AreEqual(0, message.RepeatedPublicImportMessage.Count); + Assert.AreEqual(0, message.RepeatedSfixed32.Count); + Assert.AreEqual(0, message.RepeatedSfixed64.Count); + Assert.AreEqual(0, message.RepeatedSint32.Count); + Assert.AreEqual(0, message.RepeatedSint64.Count); + Assert.AreEqual(0, message.RepeatedString.Count); + Assert.AreEqual(0, message.RepeatedUint32.Count); + Assert.AreEqual(0, message.RepeatedUint64.Count); + + // Oneof fields + Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.None, message.OneofFieldCase); + Assert.AreEqual(0, message.OneofUint32); + Assert.AreEqual("", message.OneofString); + Assert.AreEqual(ByteString.Empty, message.OneofBytes); + Assert.IsNull(message.OneofNestedMessage); + } + + [Test] + public void RoundTrip_Empty() + { + var message = new TestAllTypes(); + // 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); + } + + [Test] + public void RoundTrip_SingleValues() + { + var message = new TestAllTypes + { + SingleBool = true, + SingleBytes = ByteString.CopyFrom(1, 2, 3, 4), + SingleDouble = 23.5, + SingleFixed32 = 23, + SingleFixed64 = 1234567890123, + SingleFloat = 12.25f, + SingleForeignEnum = ForeignEnum.FOREIGN_BAR, + SingleForeignMessage = new ForeignMessage { C = 10 }, + SingleImportEnum = ImportEnum.IMPORT_BAZ, + SingleImportMessage = new ImportMessage { D = 20 }, + SingleInt32 = 100, + SingleInt64 = 3210987654321, + SingleNestedEnum = TestAllTypes.Types.NestedEnum.FOO, + SingleNestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 35 }, + SinglePublicImportMessage = new PublicImportMessage { E = 54 }, + SingleSfixed32 = -123, + SingleSfixed64 = -12345678901234, + SingleSint32 = -456, + SingleSint64 = -12345678901235, + SingleString = "test", + SingleUint32 = uint.MaxValue, + SingleUint64 = ulong.MaxValue + }; + + byte[] bytes = message.ToByteArray(); + TestAllTypes parsed = TestAllTypes.Parser.ParseFrom(bytes); + Assert.AreEqual(message, parsed); + } + + [Test] + public void RoundTrip_RepeatedValues() + { + var message = new TestAllTypes + { + RepeatedBool = { true, false }, + RepeatedBytes = { ByteString.CopyFrom(1, 2, 3, 4), ByteString.CopyFrom(5, 6) }, + RepeatedDouble = { -12.25, 23.5 }, + RepeatedFixed32 = { uint.MaxValue, 23 }, + RepeatedFixed64 = { ulong.MaxValue, 1234567890123 }, + RepeatedFloat = { 100f, 12.25f }, + RepeatedForeignEnum = { ForeignEnum.FOREIGN_FOO, ForeignEnum.FOREIGN_BAR }, + RepeatedForeignMessage = { new ForeignMessage(), new ForeignMessage { C = 10 } }, + RepeatedImportEnum = { ImportEnum.IMPORT_BAZ, ImportEnum.IMPORT_ENUM_UNSPECIFIED }, + RepeatedImportMessage = { new ImportMessage { D = 20 }, new ImportMessage { D = 25 } }, + RepeatedInt32 = { 100, 200 }, + RepeatedInt64 = { 3210987654321, long.MaxValue }, + RepeatedNestedEnum = { TestAllTypes.Types.NestedEnum.FOO, TestAllTypes.Types.NestedEnum.NEG }, + RepeatedNestedMessage = { new TestAllTypes.Types.NestedMessage { Bb = 35 }, new TestAllTypes.Types.NestedMessage { Bb = 10 } }, + RepeatedPublicImportMessage = { new PublicImportMessage { E = 54 }, new PublicImportMessage { E = -1 } }, + RepeatedSfixed32 = { -123, 123 }, + RepeatedSfixed64 = { -12345678901234, 12345678901234 }, + RepeatedSint32 = { -456, 100 }, + RepeatedSint64 = { -12345678901235, 123 }, + RepeatedString = { "foo", "bar" }, + RepeatedUint32 = { uint.MaxValue, uint.MinValue }, + RepeatedUint64 = { ulong.MaxValue, uint.MinValue } + }; + + byte[] bytes = message.ToByteArray(); + TestAllTypes parsed = TestAllTypes.Parser.ParseFrom(bytes); + Assert.AreEqual(message, parsed); + } + + // Note that not every map within map_unittest_proto3 is used. They all go through very + // similar code paths. The fact that all maps are present is validation that we have codecs + // for every type. + [Test] + public void RoundTrip_Maps() + { + var message = new TestMap + { + MapBoolBool = { + { false, true }, + { true, false } + }, + MapInt32Bytes = { + { 5, ByteString.CopyFrom(6, 7, 8) }, + { 25, ByteString.CopyFrom(1, 2, 3, 4, 5) }, + { 10, ByteString.Empty } + }, + MapInt32ForeignMessage = { + { 0, new ForeignMessage { C = 10 } }, + { 5, null }, + }, + MapInt32Enum = { + { 1, MapEnum.MAP_ENUM_BAR }, + { 2000, MapEnum.MAP_ENUM_FOO } + } + }; + + byte[] bytes = message.ToByteArray(); + TestMap parsed = TestMap.Parser.ParseFrom(bytes); + Assert.AreEqual(message, parsed); + } + + [Test] + public void MapWithEmptyEntry() + { + var message = new TestMap + { + MapInt32Bytes = { { 0, ByteString.Empty } } + }; + + 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]); + } + + [Test] + public void MapWithOnlyValue() + { + // Hand-craft the stream to contain a single entry with just a value. + var memoryStream = new MemoryStream(); + var output = CodedOutputStream.CreateInstance(memoryStream); + output.WriteTag(TestMap.MapInt32ForeignMessageFieldNumber, WireFormat.WireType.LengthDelimited); + var nestedMessage = new ForeignMessage { C = 20 }; + // Size of the entry (tag, size written by WriteMessage, data written by WriteMessage) + output.WriteRawVarint32((uint)(nestedMessage.CalculateSize() + 3)); + output.WriteTag(2, WireFormat.WireType.LengthDelimited); + output.WriteMessage(nestedMessage); + output.Flush(); + + var parsed = TestMap.Parser.ParseFrom(memoryStream.ToArray()); + Assert.AreEqual(nestedMessage, parsed.MapInt32ForeignMessage[0]); + } + + [Test] + public void MapIgnoresExtraFieldsWithinEntryMessages() + { + // Hand-craft the stream to contain a single entry with three fields + var memoryStream = new MemoryStream(); + var output = CodedOutputStream.CreateInstance(memoryStream); + + output.WriteTag(TestMap.MapInt32Int32FieldNumber, WireFormat.WireType.LengthDelimited); + + var key = 10; // Field 1 + var value = 20; // Field 2 + var extra = 30; // Field 3 + + // Each field can be represented in a single byte, with a single byte tag. + // Total message size: 6 bytes. + output.WriteRawVarint32(6); + output.WriteTag(1, WireFormat.WireType.Varint); + output.WriteInt32(key); + output.WriteTag(2, WireFormat.WireType.Varint); + output.WriteInt32(value); + output.WriteTag(3, WireFormat.WireType.Varint); + output.WriteInt32(extra); + output.Flush(); + + var parsed = TestMap.Parser.ParseFrom(memoryStream.ToArray()); + Assert.AreEqual(value, parsed.MapInt32Int32[key]); + } + + [Test] + public void MapFieldOrderIsIrrelevant() + { + var memoryStream = new MemoryStream(); + var output = CodedOutputStream.CreateInstance(memoryStream); + + output.WriteTag(TestMap.MapInt32Int32FieldNumber, WireFormat.WireType.LengthDelimited); + + var key = 10; + var value = 20; + + // Each field can be represented in a single byte, with a single byte tag. + // Total message size: 4 bytes. + output.WriteRawVarint32(4); + output.WriteTag(2, WireFormat.WireType.Varint); + output.WriteInt32(value); + output.WriteTag(1, WireFormat.WireType.Varint); + output.WriteInt32(key); + output.Flush(); + + var parsed = TestMap.Parser.ParseFrom(memoryStream.ToArray()); + Assert.AreEqual(value, parsed.MapInt32Int32[key]); + } + + [Test] + public void MapNonContiguousEntries() + { + var memoryStream = new MemoryStream(); + var output = CodedOutputStream.CreateInstance(memoryStream); + + // Message structure: + // Entry for MapInt32Int32 + // Entry for MapStringString + // Entry for MapInt32Int32 + + // First entry + var key1 = 10; + var value1 = 20; + output.WriteTag(TestMap.MapInt32Int32FieldNumber, WireFormat.WireType.LengthDelimited); + output.WriteRawVarint32(4); + output.WriteTag(1, WireFormat.WireType.Varint); + output.WriteInt32(key1); + output.WriteTag(2, WireFormat.WireType.Varint); + output.WriteInt32(value1); + + // Second entry + var key2 = "a"; + var value2 = "b"; + output.WriteTag(TestMap.MapStringStringFieldNumber, WireFormat.WireType.LengthDelimited); + output.WriteRawVarint32(6); // 3 bytes per entry: tag, size, character + output.WriteTag(1, WireFormat.WireType.LengthDelimited); + output.WriteString(key2); + output.WriteTag(2, WireFormat.WireType.LengthDelimited); + output.WriteString(value2); + + // Third entry + var key3 = 15; + var value3 = 25; + output.WriteTag(TestMap.MapInt32Int32FieldNumber, WireFormat.WireType.LengthDelimited); + output.WriteRawVarint32(4); + output.WriteTag(1, WireFormat.WireType.Varint); + output.WriteInt32(key3); + output.WriteTag(2, WireFormat.WireType.Varint); + 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); + } + + [Test] + public void DuplicateKeys_LastEntryWins() + { + var memoryStream = new MemoryStream(); + var output = CodedOutputStream.CreateInstance(memoryStream); + + var key = 10; + var value1 = 20; + var value2 = 30; + + // First entry + output.WriteTag(TestMap.MapInt32Int32FieldNumber, WireFormat.WireType.LengthDelimited); + output.WriteRawVarint32(4); + output.WriteTag(1, WireFormat.WireType.Varint); + output.WriteInt32(key); + output.WriteTag(2, WireFormat.WireType.Varint); + output.WriteInt32(value1); + + // Second entry - same key, different value + output.WriteTag(TestMap.MapInt32Int32FieldNumber, WireFormat.WireType.LengthDelimited); + output.WriteRawVarint32(4); + output.WriteTag(1, WireFormat.WireType.Varint); + output.WriteInt32(key); + output.WriteTag(2, WireFormat.WireType.Varint); + output.WriteInt32(value2); + output.Flush(); + + var parsed = TestMap.Parser.ParseFrom(memoryStream.ToArray()); + Assert.AreEqual(value2, parsed.MapInt32Int32[key]); + } + + [Test] + public void CloneSingleNonMessageValues() + { + var original = new TestAllTypes + { + SingleBool = true, + SingleBytes = ByteString.CopyFrom(1, 2, 3, 4), + SingleDouble = 23.5, + SingleFixed32 = 23, + SingleFixed64 = 1234567890123, + SingleFloat = 12.25f, + SingleInt32 = 100, + SingleInt64 = 3210987654321, + SingleNestedEnum = TestAllTypes.Types.NestedEnum.FOO, + SingleSfixed32 = -123, + SingleSfixed64 = -12345678901234, + SingleSint32 = -456, + SingleSint64 = -12345678901235, + SingleString = "test", + SingleUint32 = uint.MaxValue, + SingleUint64 = ulong.MaxValue + }; + var clone = original.Clone(); + Assert.AreNotSame(original, clone); + Assert.AreEqual(original, clone); + // Just as a single example + clone.SingleInt32 = 150; + Assert.AreNotEqual(original, clone); + } + + [Test] + public void CloneRepeatedNonMessageValues() + { + var original = new TestAllTypes + { + RepeatedBool = { true, false }, + RepeatedBytes = { ByteString.CopyFrom(1, 2, 3, 4), ByteString.CopyFrom(5, 6) }, + RepeatedDouble = { -12.25, 23.5 }, + RepeatedFixed32 = { uint.MaxValue, 23 }, + RepeatedFixed64 = { ulong.MaxValue, 1234567890123 }, + RepeatedFloat = { 100f, 12.25f }, + RepeatedInt32 = { 100, 200 }, + RepeatedInt64 = { 3210987654321, long.MaxValue }, + RepeatedNestedEnum = { TestAllTypes.Types.NestedEnum.FOO, TestAllTypes.Types.NestedEnum.NEG }, + RepeatedSfixed32 = { -123, 123 }, + RepeatedSfixed64 = { -12345678901234, 12345678901234 }, + RepeatedSint32 = { -456, 100 }, + RepeatedSint64 = { -12345678901235, 123 }, + RepeatedString = { "foo", "bar" }, + RepeatedUint32 = { uint.MaxValue, uint.MinValue }, + RepeatedUint64 = { ulong.MaxValue, uint.MinValue } + }; + + var clone = original.Clone(); + Assert.AreNotSame(original, clone); + Assert.AreEqual(original, clone); + // Just as a single example + clone.RepeatedDouble.Add(25.5); + Assert.AreNotEqual(original, clone); + } + + [Test] + public void CloneSingleMessageField() + { + var original = new TestAllTypes + { + SingleNestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 20 } + }; + + var clone = original.Clone(); + Assert.AreNotSame(original, clone); + Assert.AreNotSame(original.SingleNestedMessage, clone.SingleNestedMessage); + Assert.AreEqual(original, clone); + + clone.SingleNestedMessage.Bb = 30; + Assert.AreNotEqual(original, clone); + } + + [Test] + public void CloneRepeatedMessageField() + { + var original = new TestAllTypes + { + RepeatedNestedMessage = { new TestAllTypes.Types.NestedMessage { Bb = 20 } } + }; + + var clone = original.Clone(); + Assert.AreNotSame(original, clone); + Assert.AreNotSame(original.RepeatedNestedMessage, clone.RepeatedNestedMessage); + Assert.AreNotSame(original.RepeatedNestedMessage[0], clone.RepeatedNestedMessage[0]); + Assert.AreEqual(original, clone); + + clone.RepeatedNestedMessage[0].Bb = 30; + Assert.AreNotEqual(original, clone); + } + + [Test] + public void CloneOneofField() + { + var original = new TestAllTypes + { + OneofNestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 20 } + }; + + var clone = original.Clone(); + Assert.AreNotSame(original, clone); + Assert.AreEqual(original, clone); + + // We should have cloned the message + original.OneofNestedMessage.Bb = 30; + Assert.AreNotEqual(original, clone); + } + + [Test] + public void Freeze() + { + var frozen = new TestAllTypes(); + frozen.Freeze(); + Assert.IsTrue(frozen.IsFrozen); + + Assert.Throws(() => frozen.ClearOneofField()); + Assert.Throws(() => frozen.SingleInt32 = 0); + Assert.Throws(() => frozen.SingleNestedMessage = null); + Assert.Throws(() => frozen.SingleNestedEnum = 0); + Assert.Throws(() => frozen.OneofString = null); + Assert.Throws(() => frozen.OneofUint32 = 0U); + Assert.Throws(() => frozen.RepeatedDouble.Add(0.0)); + Assert.Throws(() => frozen.RepeatedNestedMessage.Add(new TestAllTypes.Types.NestedMessage())); + } + + [Test] + public void OneofProperties() + { + // Switch the oneof case between each of the different options, and check everything behaves + // as expected in each case. + var message = new TestAllTypes(); + Assert.AreEqual("", message.OneofString); + Assert.AreEqual(0, message.OneofUint32); + Assert.AreEqual(ByteString.Empty, message.OneofBytes); + Assert.IsNull(message.OneofNestedMessage); + Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.None, message.OneofFieldCase); + + message.OneofString = "sample"; + Assert.AreEqual("sample", message.OneofString); + Assert.AreEqual(0, message.OneofUint32); + Assert.AreEqual(ByteString.Empty, message.OneofBytes); + Assert.IsNull(message.OneofNestedMessage); + Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofString, message.OneofFieldCase); + + var bytes = ByteString.CopyFrom(1, 2, 3); + message.OneofBytes = bytes; + Assert.AreEqual("", message.OneofString); + Assert.AreEqual(0, message.OneofUint32); + Assert.AreEqual(bytes, message.OneofBytes); + Assert.IsNull(message.OneofNestedMessage); + Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofBytes, message.OneofFieldCase); + + message.OneofUint32 = 20; + Assert.AreEqual("", message.OneofString); + Assert.AreEqual(20, message.OneofUint32); + Assert.AreEqual(ByteString.Empty, message.OneofBytes); + Assert.IsNull(message.OneofNestedMessage); + Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofUint32, message.OneofFieldCase); + + var nestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 25 }; + message.OneofNestedMessage = nestedMessage; + Assert.AreEqual("", message.OneofString); + Assert.AreEqual(0, message.OneofUint32); + Assert.AreEqual(ByteString.Empty, message.OneofBytes); + Assert.AreEqual(nestedMessage, message.OneofNestedMessage); + Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofNestedMessage, message.OneofFieldCase); + + message.ClearOneofField(); + Assert.AreEqual("", message.OneofString); + Assert.AreEqual(0, message.OneofUint32); + Assert.AreEqual(ByteString.Empty, message.OneofBytes); + Assert.IsNull(message.OneofNestedMessage); + Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.None, message.OneofFieldCase); + } + + [Test] + public void OneofSerialization_NonDefaultValue() + { + var message = new TestAllTypes(); + message.OneofString = "this would take a bit of space"; + message.OneofUint32 = 10; + 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); + } + + [Test] + public void OneofSerialization_DefaultValue() + { + var message = new TestAllTypes(); + message.OneofString = "this would take a bit of space"; + message.OneofUint32 = 0; // This is the default value for UInt32; normally wouldn't be serialized + 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); + } + + // TODO: Consider moving these tests to a separate reflection test - although they do require generated messages. + + [Test] + public void Reflection_GetValue() + { + var message = SampleMessages.CreateFullTestAllTypes(); + var fields = ((IReflectedMessage) message).Fields; + Assert.AreEqual(message.SingleBool, fields[TestAllTypes.SingleBoolFieldNumber].GetValue(message)); + Assert.AreEqual(message.SingleBytes, fields[TestAllTypes.SingleBytesFieldNumber].GetValue(message)); + Assert.AreEqual(message.SingleDouble, fields[TestAllTypes.SingleDoubleFieldNumber].GetValue(message)); + Assert.AreEqual(message.SingleFixed32, fields[TestAllTypes.SingleFixed32FieldNumber].GetValue(message)); + Assert.AreEqual(message.SingleFixed64, fields[TestAllTypes.SingleFixed64FieldNumber].GetValue(message)); + Assert.AreEqual(message.SingleFloat, fields[TestAllTypes.SingleFloatFieldNumber].GetValue(message)); + Assert.AreEqual(message.SingleForeignEnum, fields[TestAllTypes.SingleForeignEnumFieldNumber].GetValue(message)); + Assert.AreEqual(message.SingleForeignMessage, fields[TestAllTypes.SingleForeignMessageFieldNumber].GetValue(message)); + Assert.AreEqual(message.SingleImportEnum, fields[TestAllTypes.SingleImportEnumFieldNumber].GetValue(message)); + Assert.AreEqual(message.SingleImportMessage, fields[TestAllTypes.SingleImportMessageFieldNumber].GetValue(message)); + Assert.AreEqual(message.SingleInt32, fields[TestAllTypes.SingleInt32FieldNumber].GetValue(message)); + Assert.AreEqual(message.SingleInt64, fields[TestAllTypes.SingleInt64FieldNumber].GetValue(message)); + Assert.AreEqual(message.SingleNestedEnum, fields[TestAllTypes.SingleNestedEnumFieldNumber].GetValue(message)); + Assert.AreEqual(message.SingleNestedMessage, fields[TestAllTypes.SingleNestedMessageFieldNumber].GetValue(message)); + Assert.AreEqual(message.SinglePublicImportMessage, fields[TestAllTypes.SinglePublicImportMessageFieldNumber].GetValue(message)); + Assert.AreEqual(message.SingleSint32, fields[TestAllTypes.SingleSint32FieldNumber].GetValue(message)); + Assert.AreEqual(message.SingleSint64, fields[TestAllTypes.SingleSint64FieldNumber].GetValue(message)); + Assert.AreEqual(message.SingleString, fields[TestAllTypes.SingleStringFieldNumber].GetValue(message)); + Assert.AreEqual(message.SingleSfixed32, fields[TestAllTypes.SingleSfixed32FieldNumber].GetValue(message)); + Assert.AreEqual(message.SingleSfixed64, fields[TestAllTypes.SingleSfixed64FieldNumber].GetValue(message)); + Assert.AreEqual(message.SingleUint32, fields[TestAllTypes.SingleUint32FieldNumber].GetValue(message)); + Assert.AreEqual(message.SingleUint64, fields[TestAllTypes.SingleUint64FieldNumber].GetValue(message)); + Assert.AreEqual(message.OneofBytes, fields[TestAllTypes.OneofBytesFieldNumber].GetValue(message)); + Assert.AreEqual(message.OneofString, fields[TestAllTypes.OneofStringFieldNumber].GetValue(message)); + Assert.AreEqual(message.OneofNestedMessage, fields[TestAllTypes.OneofNestedMessageFieldNumber].GetValue(message)); + Assert.AreEqual(message.OneofUint32, fields[TestAllTypes.OneofUint32FieldNumber].GetValue(message)); + + // Just one example for repeated fields - they're all just returning the list + var list = (IList)fields[TestAllTypes.RepeatedInt32FieldNumber].GetValue(message); + Assert.AreEqual(message.RepeatedInt32, list); + Assert.AreEqual(message.RepeatedInt32[0], list[0]); // Just in case there was any doubt... + + // Just a single map field, for the same reason + var mapMessage = new TestMap { MapStringString = { { "key1", "value1" }, { "key2", "value2" } } }; + fields = ((IReflectedMessage) mapMessage).Fields; + var dictionary = (IDictionary) fields[TestMap.MapStringStringFieldNumber].GetValue(mapMessage); + Assert.AreEqual(mapMessage.MapStringString, dictionary); + Assert.AreEqual("value1", dictionary["key1"]); + } + + [Test] + public void Reflection_Clear() + { + IReflectedMessage message = SampleMessages.CreateFullTestAllTypes(); + var fields = message.Fields; + fields[TestAllTypes.SingleBoolFieldNumber].Clear(message); + fields[TestAllTypes.SingleInt32FieldNumber].Clear(message); + fields[TestAllTypes.SingleStringFieldNumber].Clear(message); + fields[TestAllTypes.SingleBytesFieldNumber].Clear(message); + fields[TestAllTypes.SingleForeignEnumFieldNumber].Clear(message); + fields[TestAllTypes.SingleForeignMessageFieldNumber].Clear(message); + fields[TestAllTypes.RepeatedDoubleFieldNumber].Clear(message); + + var expected = new TestAllTypes(SampleMessages.CreateFullTestAllTypes()) + { + SingleBool = false, + SingleInt32 = 0, + SingleString = "", + SingleBytes = ByteString.Empty, + SingleForeignEnum = 0, + SingleForeignMessage = null, + }; + expected.RepeatedDouble.Clear(); + + Assert.AreEqual(expected, message); + + // Separately, maps. + var mapMessage = new TestMap { MapStringString = { { "key1", "value1" }, { "key2", "value2" } } }; + fields = ((IReflectedMessage) mapMessage).Fields; + fields[TestMap.MapStringStringFieldNumber].Clear(mapMessage); + Assert.AreEqual(0, mapMessage.MapStringString.Count); + } + + [Test] + public void Reflection_SetValue_SingleFields() + { + // Just a sample (primitives, messages, enums, strings, byte strings) + IReflectedMessage message = SampleMessages.CreateFullTestAllTypes(); + var fields = message.Fields; + fields[TestAllTypes.SingleBoolFieldNumber].SetValue(message, false); + fields[TestAllTypes.SingleInt32FieldNumber].SetValue(message, 500); + fields[TestAllTypes.SingleStringFieldNumber].SetValue(message, "It's a string"); + fields[TestAllTypes.SingleBytesFieldNumber].SetValue(message, ByteString.CopyFrom(99, 98, 97)); + fields[TestAllTypes.SingleForeignEnumFieldNumber].SetValue(message, ForeignEnum.FOREIGN_FOO); + fields[TestAllTypes.SingleForeignMessageFieldNumber].SetValue(message, new ForeignMessage { C = 12345 }); + fields[TestAllTypes.SingleDoubleFieldNumber].SetValue(message, 20150701.5); + + var expected = new TestAllTypes(SampleMessages.CreateFullTestAllTypes()) + { + SingleBool = false, + SingleInt32 = 500, + SingleString = "It's a string", + SingleBytes = ByteString.CopyFrom(99, 98, 97), + SingleForeignEnum = ForeignEnum.FOREIGN_FOO, + SingleForeignMessage = new ForeignMessage { C = 12345 }, + SingleDouble = 20150701.5 + }; + + Assert.AreEqual(expected, message); + } + + [Test] + public void Reflection_SetValue_SingleFields_WrongType() + { + IReflectedMessage message = SampleMessages.CreateFullTestAllTypes(); + var fields = message.Fields; + Assert.Throws(() => fields[TestAllTypes.SingleBoolFieldNumber].SetValue(message, "This isn't a bool")); + } + + [Test] + public void Reflection_SetValue_MapFields() + { + IReflectedMessage message = new TestMap(); + var fields = message.Fields; + Assert.Throws(() => fields[TestMap.MapStringStringFieldNumber].SetValue(message, new Dictionary())); + } + + [Test] + public void Reflection_SetValue_RepeatedFields() + { + IReflectedMessage message = SampleMessages.CreateFullTestAllTypes(); + var fields = message.Fields; + Assert.Throws(() => fields[TestAllTypes.RepeatedDoubleFieldNumber].SetValue(message, new double[10])); + } + + [Test] + public void Reflection_GetValue_IncorrectType() + { + IReflectedMessage message = SampleMessages.CreateFullTestAllTypes(); + Assert.Throws(() => message.Fields[TestAllTypes.SingleBoolFieldNumber].GetValue(new TestMap())); + } + + [Test] + public void Reflection_Oneof() + { + var message = new TestAllTypes(); + var fields = ((IReflectedMessage) message).Fields; + Assert.AreEqual(1, fields.Oneofs.Count); + var oneof = fields.Oneofs[0]; + Assert.AreEqual("oneof_field", oneof.Descriptor.Name); + Assert.IsNull(oneof.GetCaseFieldDescriptor(message)); + + message.OneofString = "foo"; + Assert.AreSame(fields[TestAllTypes.OneofStringFieldNumber].Descriptor, oneof.GetCaseFieldDescriptor(message)); + + message.OneofUint32 = 10; + Assert.AreSame(fields[TestAllTypes.OneofUint32FieldNumber].Descriptor, oneof.GetCaseFieldDescriptor(message)); + + oneof.Clear(message); + Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.None, message.OneofFieldCase); + } + } +} diff --git a/csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj b/csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj new file mode 100644 index 00000000..6d8b4de2 --- /dev/null +++ b/csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj @@ -0,0 +1,120 @@ + + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {DD01ED24-3750-4567-9A23-1DB676A15610} + Library + Properties + Google.Protobuf + Google.Protobuf.Test + v4.5 + 512 + true + ..\..\keys\Google.Protobuf.snk + 3.5 + + + + + + + true + full + false + bin\Debug + obj\Debug\ + DEBUG;TRACE;$(EnvironmentFlavor);$(EnvironmentTemplate) + prompt + 4 + true + Off + false + + + pdbonly + true + bin\Release + obj\Release\ + TRACE;$(EnvironmentFlavor);$(EnvironmentTemplate) + prompt + 4 + true + Off + false + + + + + ..\packages\NUnitTestAdapter.2.0.0\lib\nunit.core.dll + True + + + ..\packages\NUnitTestAdapter.2.0.0\lib\nunit.core.interfaces.dll + True + + + ..\packages\NUnit.2.6.4\lib\nunit.framework.dll + True + + + ..\packages\NUnitTestAdapter.2.0.0\lib\nunit.util.dll + True + + + ..\packages\NUnitTestAdapter.2.0.0\lib\NUnit.VisualStudio.TestAdapter.dll + True + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {6908BDCE-D925-43F3-94AC-A531E6DF2591} + Google.Protobuf + + + + + + + + + + + + \ No newline at end of file diff --git a/csharp/src/Google.Protobuf.Test/IssuesTest.cs b/csharp/src/Google.Protobuf.Test/IssuesTest.cs new file mode 100644 index 00000000..b5ad34ae --- /dev/null +++ b/csharp/src/Google.Protobuf.Test/IssuesTest.cs @@ -0,0 +1,56 @@ +#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 Google.Protobuf.Reflection; +using UnitTest.Issues.TestProtos; +using NUnit.Framework; + + +namespace Google.Protobuf +{ + /// + /// Tests for issues which aren't easily compartmentalized into other unit tests. + /// + public class IssuesTest + { + // Issue 45 + [Test] + public void FieldCalledItem() + { + ItemField message = new ItemField { Item = 3 }; + FieldDescriptor field = ItemField.Descriptor.FindFieldByName("item"); + Assert.NotNull(field); + // TODO(jonskeet): Reflection... + // Assert.AreEqual(3, (int)message[field]); + } + } +} diff --git a/csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs b/csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs new file mode 100644 index 00000000..5441bf47 --- /dev/null +++ b/csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs @@ -0,0 +1,261 @@ +#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; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Google.Protobuf.TestProtos; +using NUnit.Framework; + +namespace Google.Protobuf +{ + public class JsonFormatterTest + { + [Test] + public void DefaultValues_WhenOmitted() + { + var formatter = new JsonFormatter(new JsonFormatter.Settings(formatDefaultValues: false)); + + Assert.AreEqual("{ }", formatter.Format(new ForeignMessage())); + Assert.AreEqual("{ }", formatter.Format(new TestAllTypes())); + Assert.AreEqual("{ }", formatter.Format(new TestMap())); + } + + [Test] + public void DefaultValues_WhenIncluded() + { + var formatter = new JsonFormatter(new JsonFormatter.Settings(formatDefaultValues: true)); + Assert.AreEqual("{ \"c\": 0 }", formatter.Format(new ForeignMessage())); + } + + [Test] + public void AllSingleFields() + { + var message = new TestAllTypes + { + SingleBool = true, + SingleBytes = ByteString.CopyFrom(1, 2, 3, 4), + SingleDouble = 23.5, + SingleFixed32 = 23, + SingleFixed64 = 1234567890123, + SingleFloat = 12.25f, + SingleForeignEnum = ForeignEnum.FOREIGN_BAR, + SingleForeignMessage = new ForeignMessage { C = 10 }, + SingleImportEnum = ImportEnum.IMPORT_BAZ, + SingleImportMessage = new ImportMessage { D = 20 }, + SingleInt32 = 100, + SingleInt64 = 3210987654321, + SingleNestedEnum = TestAllTypes.Types.NestedEnum.FOO, + SingleNestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 35 }, + SinglePublicImportMessage = new PublicImportMessage { E = 54 }, + SingleSfixed32 = -123, + SingleSfixed64 = -12345678901234, + SingleSint32 = -456, + SingleSint64 = -12345678901235, + SingleString = "test\twith\ttabs", + SingleUint32 = uint.MaxValue, + SingleUint64 = ulong.MaxValue, + }; + var actualText = JsonFormatter.Default.Format(message); + + // Fields in declaration order, which matches numeric order. + var expectedText = "{ " + + "\"singleInt32\": 100, " + + "\"singleInt64\": \"3210987654321\", " + + "\"singleUint32\": 4294967295, " + + "\"singleUint64\": \"18446744073709551615\", " + + "\"singleSint32\": -456, " + + "\"singleSint64\": \"-12345678901235\", " + + "\"singleFixed32\": 23, " + + "\"singleFixed64\": \"1234567890123\", " + + "\"singleSfixed32\": -123, " + + "\"singleSfixed64\": \"-12345678901234\", " + + "\"singleFloat\": 12.25, " + + "\"singleDouble\": 23.5, " + + "\"singleBool\": true, " + + "\"singleString\": \"test\\twith\\ttabs\", " + + "\"singleBytes\": \"AQIDBA==\", " + + "\"singleNestedMessage\": { \"bb\": 35 }, " + + "\"singleForeignMessage\": { \"c\": 10 }, " + + "\"singleImportMessage\": { \"d\": 20 }, " + + "\"singleNestedEnum\": \"FOO\", " + + "\"singleForeignEnum\": \"FOREIGN_BAR\", " + + "\"singleImportEnum\": \"IMPORT_BAZ\", " + + "\"singlePublicImportMessage\": { \"e\": 54 }" + + " }"; + Assert.AreEqual(expectedText, actualText); + } + + [Test] + public void RepeatedField() + { + Assert.AreEqual("{ \"repeatedInt32\": [ 1, 2, 3, 4, 5 ] }", + JsonFormatter.Default.Format(new TestAllTypes { RepeatedInt32 = { 1, 2, 3, 4, 5 } })); + } + + [Test] + public void MapField_StringString() + { + Assert.AreEqual("{ \"mapStringString\": { \"with spaces\": \"bar\", \"a\": \"b\" } }", + JsonFormatter.Default.Format(new TestMap { MapStringString = { { "with spaces", "bar" }, { "a", "b" } } })); + } + + [Test] + public void MapField_Int32Int32() + { + // The keys are quoted, but the values aren't. + Assert.AreEqual("{ \"mapInt32Int32\": { \"0\": 1, \"2\": 3 } }", + JsonFormatter.Default.Format(new TestMap { MapInt32Int32 = { { 0, 1 }, { 2, 3 } } })); + } + + [Test] + public void MapField_BoolBool() + { + // The keys are quoted, but the values aren't. + Assert.AreEqual("{ \"mapBoolBool\": { \"false\": true, \"true\": false } }", + JsonFormatter.Default.Format(new TestMap { MapBoolBool = { { false, true }, { true, false } } })); + } + + [TestCase(1.0, "1")] + [TestCase(double.NaN, "\"NaN\"")] + [TestCase(double.PositiveInfinity, "\"Infinity\"")] + [TestCase(double.NegativeInfinity, "\"-Infinity\"")] + public void DoubleRepresentations(double value, string expectedValueText) + { + var message = new TestAllTypes { SingleDouble = value }; + string actualText = JsonFormatter.Default.Format(message); + string expectedText = "{ \"singleDouble\": " + expectedValueText + " }"; + Assert.AreEqual(expectedText, actualText); + } + + [Test] + public void UnknownEnumValueOmitted_SingleField() + { + var message = new TestAllTypes { SingleForeignEnum = (ForeignEnum) 100 }; + Assert.AreEqual("{ }", JsonFormatter.Default.Format(message)); + } + + [Test] + public void UnknownEnumValueOmitted_RepeatedField() + { + var message = new TestAllTypes { RepeatedForeignEnum = { ForeignEnum.FOREIGN_BAZ, (ForeignEnum) 100, ForeignEnum.FOREIGN_FOO } }; + Assert.AreEqual("{ \"repeatedForeignEnum\": [ \"FOREIGN_BAZ\", \"FOREIGN_FOO\" ] }", JsonFormatter.Default.Format(message)); + } + + [Test] + public void UnknownEnumValueOmitted_MapField() + { + // This matches the C++ behaviour. + var message = new TestMap { MapInt32Enum = { { 1, MapEnum.MAP_ENUM_FOO }, { 2, (MapEnum) 100 }, { 3, MapEnum.MAP_ENUM_BAR } } }; + Assert.AreEqual("{ \"mapInt32Enum\": { \"1\": \"MAP_ENUM_FOO\", \"3\": \"MAP_ENUM_BAR\" } }", JsonFormatter.Default.Format(message)); + } + + [Test] + public void UnknownEnumValueOmitted_RepeatedField_AllEntriesUnknown() + { + // *Maybe* we should hold off on writing the "[" until we find that we've got at least one value to write... + // but this is what happens at the moment, and it doesn't seem too awful. + var message = new TestAllTypes { RepeatedForeignEnum = { (ForeignEnum) 200, (ForeignEnum) 100 } }; + Assert.AreEqual("{ \"repeatedForeignEnum\": [ ] }", JsonFormatter.Default.Format(message)); + } + + [Test] + public void NullValueForMessage() + { + var message = new TestMap { MapInt32ForeignMessage = { { 10, null } } }; + Assert.AreEqual("{ \"mapInt32ForeignMessage\": { \"10\": null } }", JsonFormatter.Default.Format(message)); + } + + [Test] + [TestCase("a\u17b4b", "a\\u17b4b")] // Explicit + [TestCase("a\u0601b", "a\\u0601b")] // Ranged + [TestCase("a\u0605b", "a\u0605b")] // Passthrough (note lack of double backslash...) + public void SimpleNonAscii(string text, string encoded) + { + var message = new TestAllTypes { SingleString = text }; + Assert.AreEqual("{ \"singleString\": \"" + encoded + "\" }", JsonFormatter.Default.Format(message)); + } + + [Test] + public void SurrogatePairEscaping() + { + var message = new TestAllTypes { SingleString = "a\uD801\uDC01b" }; + Assert.AreEqual("{ \"singleString\": \"a\\ud801\\udc01b\" }", JsonFormatter.Default.Format(message)); + } + + [Test] + public void InvalidSurrogatePairsFail() + { + // Note: don't use TestCase for these, as the strings can't be reliably represented + // See http://codeblog.jonskeet.uk/2014/11/07/when-is-a-string-not-a-string/ + + // Lone low surrogate + var message = new TestAllTypes { SingleString = "a\uDC01b" }; + Assert.Throws(() => JsonFormatter.Default.Format(message)); + + // Lone high surrogate + message = new TestAllTypes { SingleString = "a\uD801b" }; + Assert.Throws(() => JsonFormatter.Default.Format(message)); + } + + [Test] + [TestCase("foo_bar", "fooBar")] + [TestCase("bananaBanana", "bananaBanana")] + [TestCase("BANANABanana", "bananaBanana")] + public void ToCamelCase(string original, string expected) + { + Assert.AreEqual(expected, JsonFormatter.ToCamelCase(original)); + } + + [Test] + [TestCase(null, "{ }")] + [TestCase("x", "{ \"fooString\": \"x\" }")] + [TestCase("", "{ \"fooString\": \"\" }")] + [TestCase(null, "{ }")] + public void Oneof(string fooStringValue, string expectedJson) + { + var message = new TestOneof(); + if (fooStringValue != null) + { + message.FooString = fooStringValue; + } + + // We should get the same result both with and without "format default values". + var formatter = new JsonFormatter(new JsonFormatter.Settings(false)); + Assert.AreEqual(expectedJson, formatter.Format(message)); + formatter = new JsonFormatter(new JsonFormatter.Settings(true)); + Assert.AreEqual(expectedJson, formatter.Format(message)); + } + } +} diff --git a/csharp/src/Google.Protobuf.Test/Properties/AppManifest.xml b/csharp/src/Google.Protobuf.Test/Properties/AppManifest.xml new file mode 100644 index 00000000..a9552327 --- /dev/null +++ b/csharp/src/Google.Protobuf.Test/Properties/AppManifest.xml @@ -0,0 +1,6 @@ + + + + diff --git a/csharp/src/Google.Protobuf.Test/Properties/AssemblyInfo.cs b/csharp/src/Google.Protobuf.Test/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..b551388c --- /dev/null +++ b/csharp/src/Google.Protobuf.Test/Properties/AssemblyInfo.cs @@ -0,0 +1,30 @@ +using System; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. + +[assembly: AssemblyTitle("Google.Protobuf.Test")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Google.Protobuf.Test")] +[assembly: AssemblyCopyright("Copyright � 2008")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("2.4.1.555")] + +[assembly: AssemblyVersion("2.4.1.555")] diff --git a/csharp/src/Google.Protobuf.Test/Reflection/DescriptorsTest.cs b/csharp/src/Google.Protobuf.Test/Reflection/DescriptorsTest.cs new file mode 100644 index 00000000..0db01a5e --- /dev/null +++ b/csharp/src/Google.Protobuf.Test/Reflection/DescriptorsTest.cs @@ -0,0 +1,223 @@ +#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.Linq; +using Google.Protobuf.TestProtos; +using NUnit.Framework; + +namespace Google.Protobuf.Reflection +{ + /// + /// Tests for descriptors. (Not in its own namespace or broken up into individual classes as the + /// size doesn't warrant it. On the other hand, this makes me feel a bit dirty...) + /// + public class DescriptorsTest + { + [Test] + public void FileDescriptor() + { + FileDescriptor file = UnittestProto3.Descriptor; + + Assert.AreEqual("google/protobuf/unittest_proto3.proto", file.Name); + Assert.AreEqual("protobuf_unittest", file.Package); + + Assert.AreEqual("UnittestProto", file.Proto.Options.JavaOuterClassname); + Assert.AreEqual("google/protobuf/unittest_proto3.proto", file.Proto.Name); + + // unittest.proto doesn't have any public imports, but unittest_import.proto does. + Assert.AreEqual(0, file.PublicDependencies.Count); + Assert.AreEqual(1, UnittestImportProto3.Descriptor.PublicDependencies.Count); + Assert.AreEqual(UnittestImportPublicProto3.Descriptor, UnittestImportProto3.Descriptor.PublicDependencies[0]); + + Assert.AreEqual(1, file.Dependencies.Count); + Assert.AreEqual(UnittestImportProto3.Descriptor, file.Dependencies[0]); + + MessageDescriptor messageType = TestAllTypes.Descriptor; + Assert.AreEqual(messageType, file.MessageTypes[0]); + Assert.AreEqual(messageType, file.FindTypeByName("TestAllTypes")); + Assert.Null(file.FindTypeByName("NoSuchType")); + Assert.Null(file.FindTypeByName("protobuf_unittest.TestAllTypes")); + for (int i = 0; i < file.MessageTypes.Count; i++) + { + Assert.AreEqual(i, file.MessageTypes[i].Index); + } + + Assert.AreEqual(file.EnumTypes[0], file.FindTypeByName("ForeignEnum")); + Assert.Null(file.FindTypeByName("NoSuchType")); + Assert.Null(file.FindTypeByName("protobuf_unittest.ForeignEnum")); + Assert.AreEqual(1, UnittestImportProto3.Descriptor.EnumTypes.Count); + Assert.AreEqual("ImportEnum", UnittestImportProto3.Descriptor.EnumTypes[0].Name); + for (int i = 0; i < file.EnumTypes.Count; i++) + { + Assert.AreEqual(i, file.EnumTypes[i].Index); + } + } + + [Test] + public void MessageDescriptor() + { + MessageDescriptor messageType = TestAllTypes.Descriptor; + MessageDescriptor nestedType = TestAllTypes.Types.NestedMessage.Descriptor; + + Assert.AreEqual("TestAllTypes", messageType.Name); + Assert.AreEqual("protobuf_unittest.TestAllTypes", messageType.FullName); + Assert.AreEqual(UnittestProto3.Descriptor, messageType.File); + Assert.IsNull(messageType.ContainingType); + Assert.IsNull(messageType.Proto.Options); + + Assert.AreEqual("TestAllTypes", messageType.Name); + + Assert.AreEqual("NestedMessage", nestedType.Name); + Assert.AreEqual("protobuf_unittest.TestAllTypes.NestedMessage", nestedType.FullName); + Assert.AreEqual(UnittestProto3.Descriptor, nestedType.File); + Assert.AreEqual(messageType, nestedType.ContainingType); + + FieldDescriptor field = messageType.Fields[0]; + Assert.AreEqual("single_int32", field.Name); + Assert.AreEqual(field, messageType.FindDescriptor("single_int32")); + Assert.Null(messageType.FindDescriptor("no_such_field")); + Assert.AreEqual(field, messageType.FindFieldByNumber(1)); + Assert.Null(messageType.FindFieldByNumber(571283)); + for (int i = 0; i < messageType.Fields.Count; i++) + { + Assert.AreEqual(i, messageType.Fields[i].Index); + } + + Assert.AreEqual(nestedType, messageType.NestedTypes[0]); + Assert.AreEqual(nestedType, messageType.FindDescriptor("NestedMessage")); + Assert.Null(messageType.FindDescriptor("NoSuchType")); + for (int i = 0; i < messageType.NestedTypes.Count; i++) + { + Assert.AreEqual(i, messageType.NestedTypes[i].Index); + } + + Assert.AreEqual(messageType.EnumTypes[0], messageType.FindDescriptor("NestedEnum")); + Assert.Null(messageType.FindDescriptor("NoSuchType")); + for (int i = 0; i < messageType.EnumTypes.Count; i++) + { + Assert.AreEqual(i, messageType.EnumTypes[i].Index); + } + } + + [Test] + public void FieldDescriptor() + { + MessageDescriptor messageType = TestAllTypes.Descriptor; + FieldDescriptor primitiveField = messageType.FindDescriptor("single_int32"); + FieldDescriptor enumField = messageType.FindDescriptor("single_nested_enum"); + FieldDescriptor messageField = messageType.FindDescriptor("single_foreign_message"); + + Assert.AreEqual("single_int32", primitiveField.Name); + Assert.AreEqual("protobuf_unittest.TestAllTypes.single_int32", + primitiveField.FullName); + Assert.AreEqual(1, primitiveField.FieldNumber); + Assert.AreEqual(messageType, primitiveField.ContainingType); + Assert.AreEqual(UnittestProto3.Descriptor, primitiveField.File); + Assert.AreEqual(FieldType.Int32, primitiveField.FieldType); + Assert.IsNull(primitiveField.Proto.Options); + + Assert.AreEqual("single_nested_enum", enumField.Name); + Assert.AreEqual(FieldType.Enum, enumField.FieldType); + // Assert.AreEqual(TestAllTypes.Types.NestedEnum.DescriptorProtoFile, enumField.EnumType); + + Assert.AreEqual("single_foreign_message", messageField.Name); + Assert.AreEqual(FieldType.Message, messageField.FieldType); + Assert.AreEqual(ForeignMessage.Descriptor, messageField.MessageType); + } + + [Test] + public void FieldDescriptorLabel() + { + FieldDescriptor singleField = + TestAllTypes.Descriptor.FindDescriptor("single_int32"); + FieldDescriptor repeatedField = + TestAllTypes.Descriptor.FindDescriptor("repeated_int32"); + + Assert.IsFalse(singleField.IsRepeated); + Assert.IsTrue(repeatedField.IsRepeated); + } + + [Test] + public void EnumDescriptor() + { + // Note: this test is a bit different to the Java version because there's no static way of getting to the descriptor + EnumDescriptor enumType = UnittestProto3.Descriptor.FindTypeByName("ForeignEnum"); + EnumDescriptor nestedType = TestAllTypes.Descriptor.FindDescriptor("NestedEnum"); + + Assert.AreEqual("ForeignEnum", enumType.Name); + Assert.AreEqual("protobuf_unittest.ForeignEnum", enumType.FullName); + Assert.AreEqual(UnittestProto3.Descriptor, enumType.File); + Assert.Null(enumType.ContainingType); + Assert.Null(enumType.Proto.Options); + + Assert.AreEqual("NestedEnum", nestedType.Name); + Assert.AreEqual("protobuf_unittest.TestAllTypes.NestedEnum", + nestedType.FullName); + Assert.AreEqual(UnittestProto3.Descriptor, nestedType.File); + Assert.AreEqual(TestAllTypes.Descriptor, nestedType.ContainingType); + + EnumValueDescriptor value = enumType.FindValueByName("FOREIGN_FOO"); + Assert.AreEqual(value, enumType.Values[1]); + Assert.AreEqual("FOREIGN_FOO", value.Name); + Assert.AreEqual(4, value.Number); + Assert.AreEqual((int) ForeignEnum.FOREIGN_FOO, value.Number); + Assert.AreEqual(value, enumType.FindValueByNumber(4)); + Assert.Null(enumType.FindValueByName("NO_SUCH_VALUE")); + for (int i = 0; i < enumType.Values.Count; i++) + { + Assert.AreEqual(i, enumType.Values[i].Index); + } + } + + [Test] + public void OneofDescriptor() + { + OneofDescriptor descriptor = TestAllTypes.Descriptor.FindDescriptor("oneof_field"); + Assert.AreEqual("oneof_field", descriptor.Name); + Assert.AreEqual("protobuf_unittest.TestAllTypes.oneof_field", descriptor.FullName); + + var expectedFields = new[] { + TestAllTypes.OneofBytesFieldNumber, + TestAllTypes.OneofNestedMessageFieldNumber, + TestAllTypes.OneofStringFieldNumber, + TestAllTypes.OneofUint32FieldNumber } + .Select(fieldNumber => TestAllTypes.Descriptor.FindFieldByNumber(fieldNumber)) + .ToList(); + foreach (var field in expectedFields) + { + Assert.AreSame(descriptor, field.ContainingOneof); + } + + CollectionAssert.AreEquivalent(expectedFields, descriptor.Fields); + } + } +} \ No newline at end of file diff --git a/csharp/src/Google.Protobuf.Test/SampleEnum.cs b/csharp/src/Google.Protobuf.Test/SampleEnum.cs new file mode 100644 index 00000000..77447afa --- /dev/null +++ b/csharp/src/Google.Protobuf.Test/SampleEnum.cs @@ -0,0 +1,42 @@ +#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 + +namespace Google.Protobuf +{ + // Just a sample enum with positive and negative values to be used in tests. + internal enum SampleEnum + { + NegativeValue = -2, + None = 0, + PositiveValue = 3 + } +} diff --git a/csharp/src/Google.Protobuf.Test/SampleMessages.cs b/csharp/src/Google.Protobuf.Test/SampleMessages.cs new file mode 100644 index 00000000..8a9c7f86 --- /dev/null +++ b/csharp/src/Google.Protobuf.Test/SampleMessages.cs @@ -0,0 +1,99 @@ +#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 System; +using Google.Protobuf.TestProtos; + +namespace Google.Protobuf +{ + /// + /// Helper methods to create sample instances of types generated from unit test messages. + /// + public class SampleMessages + { + /// + /// Creates a new sample TestAllTypes message with all fields populated. + /// The "oneof" field is populated with the string property (OneofString). + /// + public static TestAllTypes CreateFullTestAllTypes() + { + return new TestAllTypes + { + SingleBool = true, + SingleBytes = ByteString.CopyFrom(1, 2, 3, 4), + SingleDouble = 23.5, + SingleFixed32 = 23, + SingleFixed64 = 1234567890123, + SingleFloat = 12.25f, + SingleForeignEnum = ForeignEnum.FOREIGN_BAR, + SingleForeignMessage = new ForeignMessage { C = 10 }, + SingleImportEnum = ImportEnum.IMPORT_BAZ, + SingleImportMessage = new ImportMessage { D = 20 }, + SingleInt32 = 100, + SingleInt64 = 3210987654321, + SingleNestedEnum = TestAllTypes.Types.NestedEnum.FOO, + SingleNestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 35 }, + SinglePublicImportMessage = new PublicImportMessage { E = 54 }, + SingleSfixed32 = -123, + SingleSfixed64 = -12345678901234, + SingleSint32 = -456, + SingleSint64 = -12345678901235, + SingleString = "test", + SingleUint32 = UInt32.MaxValue, + SingleUint64 = UInt64.MaxValue, + RepeatedBool = { true, false }, + RepeatedBytes = { ByteString.CopyFrom(1, 2, 3, 4), ByteString.CopyFrom(5, 6), ByteString.CopyFrom(new byte[1000]) }, + RepeatedDouble = { -12.25, 23.5 }, + RepeatedFixed32 = { UInt32.MaxValue, 23 }, + RepeatedFixed64 = { UInt64.MaxValue, 1234567890123 }, + RepeatedFloat = { 100f, 12.25f }, + RepeatedForeignEnum = { ForeignEnum.FOREIGN_FOO, ForeignEnum.FOREIGN_BAR }, + RepeatedForeignMessage = { new ForeignMessage(), new ForeignMessage { C = 10 } }, + RepeatedImportEnum = { ImportEnum.IMPORT_BAZ, ImportEnum.IMPORT_ENUM_UNSPECIFIED }, + RepeatedImportMessage = { new ImportMessage { D = 20 }, new ImportMessage { D = 25 } }, + RepeatedInt32 = { 100, 200 }, + RepeatedInt64 = { 3210987654321, Int64.MaxValue }, + RepeatedNestedEnum = { TestAllTypes.Types.NestedEnum.FOO, TestAllTypes.Types.NestedEnum.NEG }, + RepeatedNestedMessage = { new TestAllTypes.Types.NestedMessage { Bb = 35 }, new TestAllTypes.Types.NestedMessage { Bb = 10 } }, + RepeatedPublicImportMessage = { new PublicImportMessage { E = 54 }, new PublicImportMessage { E = -1 } }, + RepeatedSfixed32 = { -123, 123 }, + RepeatedSfixed64 = { -12345678901234, 12345678901234 }, + RepeatedSint32 = { -456, 100 }, + RepeatedSint64 = { -12345678901235, 123 }, + RepeatedString = { "foo", "bar" }, + RepeatedUint32 = { UInt32.MaxValue, UInt32.MinValue }, + RepeatedUint64 = { UInt64.MaxValue, UInt32.MinValue }, + OneofString = "Oneof string" + }; + } + } +} diff --git a/csharp/src/Google.Protobuf.Test/TestCornerCases.cs b/csharp/src/Google.Protobuf.Test/TestCornerCases.cs new file mode 100644 index 00000000..b270a6f9 --- /dev/null +++ b/csharp/src/Google.Protobuf.Test/TestCornerCases.cs @@ -0,0 +1,62 @@ +#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 UnitTest.Issues.TestProtos; +using NUnit.Framework; + +namespace Google.Protobuf +{ + public class TestCornerCases + { + [Test] + public void TestRoundTripNegativeEnums() + { + NegativeEnumMessage msg = new NegativeEnumMessage + { + Value = NegativeEnum.MinusOne, + Values = { NegativeEnum.NEGATIVE_ENUM_ZERO, NegativeEnum.MinusOne, NegativeEnum.FiveBelow }, + PackedValues = { NegativeEnum.NEGATIVE_ENUM_ZERO, NegativeEnum.MinusOne, NegativeEnum.FiveBelow } + }; + + Assert.AreEqual(58, msg.CalculateSize()); + + byte[] bytes = new byte[58]; + CodedOutputStream output = CodedOutputStream.CreateInstance(bytes); + + msg.WriteTo(output); + Assert.AreEqual(0, output.SpaceLeft); + + NegativeEnumMessage copy = NegativeEnumMessage.Parser.ParseFrom(bytes); + Assert.AreEqual(msg, copy); + } + } +} diff --git a/csharp/src/Google.Protobuf.Test/TestProtos/MapUnittestProto3.cs b/csharp/src/Google.Protobuf.Test/TestProtos/MapUnittestProto3.cs new file mode 100644 index 00000000..5f6eae0c --- /dev/null +++ b/csharp/src/Google.Protobuf.Test/TestProtos/MapUnittestProto3.cs @@ -0,0 +1,1591 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/map_unittest_proto3.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Google.Protobuf.TestProtos { + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static partial class MapUnittestProto3 { + + #region Static variables + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_TestMap__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_TestMapSubmessage__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_TestMessageMap__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_TestSameTypeMap__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_TestArenaMap__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_MessageContainingEnumCalledType__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_MessageContainingMapCalledEntry__FieldAccessorTable; + #endregion + #region Descriptor + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static MapUnittestProto3() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "Cilnb29nbGUvcHJvdG9idWYvbWFwX3VuaXR0ZXN0X3Byb3RvMy5wcm90bxIR", + "cHJvdG9idWZfdW5pdHRlc3QaJWdvb2dsZS9wcm90b2J1Zi91bml0dGVzdF9w", + "cm90bzMucHJvdG8ilhIKB1Rlc3RNYXASRgoPbWFwX2ludDMyX2ludDMyGAEg", + "AygLMi0ucHJvdG9idWZfdW5pdHRlc3QuVGVzdE1hcC5NYXBJbnQzMkludDMy", + "RW50cnkSRgoPbWFwX2ludDY0X2ludDY0GAIgAygLMi0ucHJvdG9idWZfdW5p", + "dHRlc3QuVGVzdE1hcC5NYXBJbnQ2NEludDY0RW50cnkSSgoRbWFwX3VpbnQz", + "Ml91aW50MzIYAyADKAsyLy5wcm90b2J1Zl91bml0dGVzdC5UZXN0TWFwLk1h", + "cFVpbnQzMlVpbnQzMkVudHJ5EkoKEW1hcF91aW50NjRfdWludDY0GAQgAygL", + "Mi8ucHJvdG9idWZfdW5pdHRlc3QuVGVzdE1hcC5NYXBVaW50NjRVaW50NjRF", + "bnRyeRJKChFtYXBfc2ludDMyX3NpbnQzMhgFIAMoCzIvLnByb3RvYnVmX3Vu", + "aXR0ZXN0LlRlc3RNYXAuTWFwU2ludDMyU2ludDMyRW50cnkSSgoRbWFwX3Np", + "bnQ2NF9zaW50NjQYBiADKAsyLy5wcm90b2J1Zl91bml0dGVzdC5UZXN0TWFw", + "Lk1hcFNpbnQ2NFNpbnQ2NEVudHJ5Ek4KE21hcF9maXhlZDMyX2ZpeGVkMzIY", + "ByADKAsyMS5wcm90b2J1Zl91bml0dGVzdC5UZXN0TWFwLk1hcEZpeGVkMzJG", + "aXhlZDMyRW50cnkSTgoTbWFwX2ZpeGVkNjRfZml4ZWQ2NBgIIAMoCzIxLnBy", + "b3RvYnVmX3VuaXR0ZXN0LlRlc3RNYXAuTWFwRml4ZWQ2NEZpeGVkNjRFbnRy", + "eRJSChVtYXBfc2ZpeGVkMzJfc2ZpeGVkMzIYCSADKAsyMy5wcm90b2J1Zl91", + "bml0dGVzdC5UZXN0TWFwLk1hcFNmaXhlZDMyU2ZpeGVkMzJFbnRyeRJSChVt", + "YXBfc2ZpeGVkNjRfc2ZpeGVkNjQYCiADKAsyMy5wcm90b2J1Zl91bml0dGVz", + "dC5UZXN0TWFwLk1hcFNmaXhlZDY0U2ZpeGVkNjRFbnRyeRJGCg9tYXBfaW50", + "MzJfZmxvYXQYCyADKAsyLS5wcm90b2J1Zl91bml0dGVzdC5UZXN0TWFwLk1h", + "cEludDMyRmxvYXRFbnRyeRJIChBtYXBfaW50MzJfZG91YmxlGAwgAygLMi4u", + "cHJvdG9idWZfdW5pdHRlc3QuVGVzdE1hcC5NYXBJbnQzMkRvdWJsZUVudHJ5", + "EkIKDW1hcF9ib29sX2Jvb2wYDSADKAsyKy5wcm90b2J1Zl91bml0dGVzdC5U", + "ZXN0TWFwLk1hcEJvb2xCb29sRW50cnkSSgoRbWFwX3N0cmluZ19zdHJpbmcY", + "DiADKAsyLy5wcm90b2J1Zl91bml0dGVzdC5UZXN0TWFwLk1hcFN0cmluZ1N0", + "cmluZ0VudHJ5EkYKD21hcF9pbnQzMl9ieXRlcxgPIAMoCzItLnByb3RvYnVm", + "X3VuaXR0ZXN0LlRlc3RNYXAuTWFwSW50MzJCeXRlc0VudHJ5EkQKDm1hcF9p", + "bnQzMl9lbnVtGBAgAygLMiwucHJvdG9idWZfdW5pdHRlc3QuVGVzdE1hcC5N", + "YXBJbnQzMkVudW1FbnRyeRJZChltYXBfaW50MzJfZm9yZWlnbl9tZXNzYWdl", + "GBEgAygLMjYucHJvdG9idWZfdW5pdHRlc3QuVGVzdE1hcC5NYXBJbnQzMkZv", + "cmVpZ25NZXNzYWdlRW50cnkaNAoSTWFwSW50MzJJbnQzMkVudHJ5EgsKA2tl", + "eRgBIAEoBRINCgV2YWx1ZRgCIAEoBToCOAEaNAoSTWFwSW50NjRJbnQ2NEVu", + "dHJ5EgsKA2tleRgBIAEoAxINCgV2YWx1ZRgCIAEoAzoCOAEaNgoUTWFwVWlu", + "dDMyVWludDMyRW50cnkSCwoDa2V5GAEgASgNEg0KBXZhbHVlGAIgASgNOgI4", + "ARo2ChRNYXBVaW50NjRVaW50NjRFbnRyeRILCgNrZXkYASABKAQSDQoFdmFs", + "dWUYAiABKAQ6AjgBGjYKFE1hcFNpbnQzMlNpbnQzMkVudHJ5EgsKA2tleRgB", + "IAEoERINCgV2YWx1ZRgCIAEoEToCOAEaNgoUTWFwU2ludDY0U2ludDY0RW50", + "cnkSCwoDa2V5GAEgASgSEg0KBXZhbHVlGAIgASgSOgI4ARo4ChZNYXBGaXhl", + "ZDMyRml4ZWQzMkVudHJ5EgsKA2tleRgBIAEoBxINCgV2YWx1ZRgCIAEoBzoC", + "OAEaOAoWTWFwRml4ZWQ2NEZpeGVkNjRFbnRyeRILCgNrZXkYASABKAYSDQoF", + "dmFsdWUYAiABKAY6AjgBGjoKGE1hcFNmaXhlZDMyU2ZpeGVkMzJFbnRyeRIL", + "CgNrZXkYASABKA8SDQoFdmFsdWUYAiABKA86AjgBGjoKGE1hcFNmaXhlZDY0", + "U2ZpeGVkNjRFbnRyeRILCgNrZXkYASABKBASDQoFdmFsdWUYAiABKBA6AjgB", + "GjQKEk1hcEludDMyRmxvYXRFbnRyeRILCgNrZXkYASABKAUSDQoFdmFsdWUY", + "AiABKAI6AjgBGjUKE01hcEludDMyRG91YmxlRW50cnkSCwoDa2V5GAEgASgF", + "Eg0KBXZhbHVlGAIgASgBOgI4ARoyChBNYXBCb29sQm9vbEVudHJ5EgsKA2tl", + "eRgBIAEoCBINCgV2YWx1ZRgCIAEoCDoCOAEaNgoUTWFwU3RyaW5nU3RyaW5n", + "RW50cnkSCwoDa2V5GAEgASgJEg0KBXZhbHVlGAIgASgJOgI4ARo0ChJNYXBJ", + "bnQzMkJ5dGVzRW50cnkSCwoDa2V5GAEgASgFEg0KBXZhbHVlGAIgASgMOgI4", + "ARpPChFNYXBJbnQzMkVudW1FbnRyeRILCgNrZXkYASABKAUSKQoFdmFsdWUY", + "AiABKA4yGi5wcm90b2J1Zl91bml0dGVzdC5NYXBFbnVtOgI4ARpgChtNYXBJ", + "bnQzMkZvcmVpZ25NZXNzYWdlRW50cnkSCwoDa2V5GAEgASgFEjAKBXZhbHVl", + "GAIgASgLMiEucHJvdG9idWZfdW5pdHRlc3QuRm9yZWlnbk1lc3NhZ2U6AjgB", + "IkEKEVRlc3RNYXBTdWJtZXNzYWdlEiwKCHRlc3RfbWFwGAEgASgLMhoucHJv", + "dG9idWZfdW5pdHRlc3QuVGVzdE1hcCK8AQoOVGVzdE1lc3NhZ2VNYXASUQoR", + "bWFwX2ludDMyX21lc3NhZ2UYASADKAsyNi5wcm90b2J1Zl91bml0dGVzdC5U", + "ZXN0TWVzc2FnZU1hcC5NYXBJbnQzMk1lc3NhZ2VFbnRyeRpXChRNYXBJbnQz", + "Mk1lc3NhZ2VFbnRyeRILCgNrZXkYASABKAUSLgoFdmFsdWUYAiABKAsyHy5w", + "cm90b2J1Zl91bml0dGVzdC5UZXN0QWxsVHlwZXM6AjgBIuMBCg9UZXN0U2Ft", + "ZVR5cGVNYXASOgoEbWFwMRgBIAMoCzIsLnByb3RvYnVmX3VuaXR0ZXN0LlRl", + "c3RTYW1lVHlwZU1hcC5NYXAxRW50cnkSOgoEbWFwMhgCIAMoCzIsLnByb3Rv", + "YnVmX3VuaXR0ZXN0LlRlc3RTYW1lVHlwZU1hcC5NYXAyRW50cnkaKwoJTWFw", + "MUVudHJ5EgsKA2tleRgBIAEoBRINCgV2YWx1ZRgCIAEoBToCOAEaKwoJTWFw", + "MkVudHJ5EgsKA2tleRgBIAEoBRINCgV2YWx1ZRgCIAEoBToCOAEi5BAKDFRl", + "c3RBcmVuYU1hcBJLCg9tYXBfaW50MzJfaW50MzIYASADKAsyMi5wcm90b2J1", + "Zl91bml0dGVzdC5UZXN0QXJlbmFNYXAuTWFwSW50MzJJbnQzMkVudHJ5EksK", + "D21hcF9pbnQ2NF9pbnQ2NBgCIAMoCzIyLnByb3RvYnVmX3VuaXR0ZXN0LlRl", + "c3RBcmVuYU1hcC5NYXBJbnQ2NEludDY0RW50cnkSTwoRbWFwX3VpbnQzMl91", + "aW50MzIYAyADKAsyNC5wcm90b2J1Zl91bml0dGVzdC5UZXN0QXJlbmFNYXAu", + "TWFwVWludDMyVWludDMyRW50cnkSTwoRbWFwX3VpbnQ2NF91aW50NjQYBCAD", + "KAsyNC5wcm90b2J1Zl91bml0dGVzdC5UZXN0QXJlbmFNYXAuTWFwVWludDY0", + "VWludDY0RW50cnkSTwoRbWFwX3NpbnQzMl9zaW50MzIYBSADKAsyNC5wcm90", + "b2J1Zl91bml0dGVzdC5UZXN0QXJlbmFNYXAuTWFwU2ludDMyU2ludDMyRW50", + "cnkSTwoRbWFwX3NpbnQ2NF9zaW50NjQYBiADKAsyNC5wcm90b2J1Zl91bml0", + "dGVzdC5UZXN0QXJlbmFNYXAuTWFwU2ludDY0U2ludDY0RW50cnkSUwoTbWFw", + "X2ZpeGVkMzJfZml4ZWQzMhgHIAMoCzI2LnByb3RvYnVmX3VuaXR0ZXN0LlRl", + "c3RBcmVuYU1hcC5NYXBGaXhlZDMyRml4ZWQzMkVudHJ5ElMKE21hcF9maXhl", + "ZDY0X2ZpeGVkNjQYCCADKAsyNi5wcm90b2J1Zl91bml0dGVzdC5UZXN0QXJl", + "bmFNYXAuTWFwRml4ZWQ2NEZpeGVkNjRFbnRyeRJXChVtYXBfc2ZpeGVkMzJf", + "c2ZpeGVkMzIYCSADKAsyOC5wcm90b2J1Zl91bml0dGVzdC5UZXN0QXJlbmFN", + "YXAuTWFwU2ZpeGVkMzJTZml4ZWQzMkVudHJ5ElcKFW1hcF9zZml4ZWQ2NF9z", + "Zml4ZWQ2NBgKIAMoCzI4LnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RBcmVuYU1h", + "cC5NYXBTZml4ZWQ2NFNmaXhlZDY0RW50cnkSSwoPbWFwX2ludDMyX2Zsb2F0", + "GAsgAygLMjIucHJvdG9idWZfdW5pdHRlc3QuVGVzdEFyZW5hTWFwLk1hcElu", + "dDMyRmxvYXRFbnRyeRJNChBtYXBfaW50MzJfZG91YmxlGAwgAygLMjMucHJv", + "dG9idWZfdW5pdHRlc3QuVGVzdEFyZW5hTWFwLk1hcEludDMyRG91YmxlRW50", + "cnkSRwoNbWFwX2Jvb2xfYm9vbBgNIAMoCzIwLnByb3RvYnVmX3VuaXR0ZXN0", + "LlRlc3RBcmVuYU1hcC5NYXBCb29sQm9vbEVudHJ5EkkKDm1hcF9pbnQzMl9l", + "bnVtGA4gAygLMjEucHJvdG9idWZfdW5pdHRlc3QuVGVzdEFyZW5hTWFwLk1h", + "cEludDMyRW51bUVudHJ5El4KGW1hcF9pbnQzMl9mb3JlaWduX21lc3NhZ2UY", + "DyADKAsyOy5wcm90b2J1Zl91bml0dGVzdC5UZXN0QXJlbmFNYXAuTWFwSW50", + "MzJGb3JlaWduTWVzc2FnZUVudHJ5GjQKEk1hcEludDMySW50MzJFbnRyeRIL", + "CgNrZXkYASABKAUSDQoFdmFsdWUYAiABKAU6AjgBGjQKEk1hcEludDY0SW50", + "NjRFbnRyeRILCgNrZXkYASABKAMSDQoFdmFsdWUYAiABKAM6AjgBGjYKFE1h", + "cFVpbnQzMlVpbnQzMkVudHJ5EgsKA2tleRgBIAEoDRINCgV2YWx1ZRgCIAEo", + "DToCOAEaNgoUTWFwVWludDY0VWludDY0RW50cnkSCwoDa2V5GAEgASgEEg0K", + "BXZhbHVlGAIgASgEOgI4ARo2ChRNYXBTaW50MzJTaW50MzJFbnRyeRILCgNr", + "ZXkYASABKBESDQoFdmFsdWUYAiABKBE6AjgBGjYKFE1hcFNpbnQ2NFNpbnQ2", + "NEVudHJ5EgsKA2tleRgBIAEoEhINCgV2YWx1ZRgCIAEoEjoCOAEaOAoWTWFw", + "Rml4ZWQzMkZpeGVkMzJFbnRyeRILCgNrZXkYASABKAcSDQoFdmFsdWUYAiAB", + "KAc6AjgBGjgKFk1hcEZpeGVkNjRGaXhlZDY0RW50cnkSCwoDa2V5GAEgASgG", + "Eg0KBXZhbHVlGAIgASgGOgI4ARo6ChhNYXBTZml4ZWQzMlNmaXhlZDMyRW50", + "cnkSCwoDa2V5GAEgASgPEg0KBXZhbHVlGAIgASgPOgI4ARo6ChhNYXBTZml4", + "ZWQ2NFNmaXhlZDY0RW50cnkSCwoDa2V5GAEgASgQEg0KBXZhbHVlGAIgASgQ", + "OgI4ARo0ChJNYXBJbnQzMkZsb2F0RW50cnkSCwoDa2V5GAEgASgFEg0KBXZh", + "bHVlGAIgASgCOgI4ARo1ChNNYXBJbnQzMkRvdWJsZUVudHJ5EgsKA2tleRgB", + "IAEoBRINCgV2YWx1ZRgCIAEoAToCOAEaMgoQTWFwQm9vbEJvb2xFbnRyeRIL", + "CgNrZXkYASABKAgSDQoFdmFsdWUYAiABKAg6AjgBGk8KEU1hcEludDMyRW51", + "bUVudHJ5EgsKA2tleRgBIAEoBRIpCgV2YWx1ZRgCIAEoDjIaLnByb3RvYnVm", + "X3VuaXR0ZXN0Lk1hcEVudW06AjgBGmAKG01hcEludDMyRm9yZWlnbk1lc3Nh", + "Z2VFbnRyeRILCgNrZXkYASABKAUSMAoFdmFsdWUYAiABKAsyIS5wcm90b2J1", + "Zl91bml0dGVzdC5Gb3JlaWduTWVzc2FnZToCOAEi5AEKH01lc3NhZ2VDb250", + "YWluaW5nRW51bUNhbGxlZFR5cGUSSgoEdHlwZRgBIAMoCzI8LnByb3RvYnVm", + "X3VuaXR0ZXN0Lk1lc3NhZ2VDb250YWluaW5nRW51bUNhbGxlZFR5cGUuVHlw", + "ZUVudHJ5Gl8KCVR5cGVFbnRyeRILCgNrZXkYASABKAUSQQoFdmFsdWUYAiAB", + "KAsyMi5wcm90b2J1Zl91bml0dGVzdC5NZXNzYWdlQ29udGFpbmluZ0VudW1D", + "YWxsZWRUeXBlOgI4ASIUCgRUeXBlEgwKCFRZUEVfRk9PEAAinQEKH01lc3Nh", + "Z2VDb250YWluaW5nTWFwQ2FsbGVkRW50cnkSTAoFZW50cnkYASADKAsyPS5w", + "cm90b2J1Zl91bml0dGVzdC5NZXNzYWdlQ29udGFpbmluZ01hcENhbGxlZEVu", + "dHJ5LkVudHJ5RW50cnkaLAoKRW50cnlFbnRyeRILCgNrZXkYASABKAUSDQoF", + "dmFsdWUYAiABKAU6AjgBKj8KB01hcEVudW0SEAoMTUFQX0VOVU1fRk9PEAAS", + "EAoMTUFQX0VOVU1fQkFSEAESEAoMTUFQX0VOVU1fQkFaEAJCIPgBAaoCGkdv", + "b2dsZS5Qcm90b2J1Zi5UZXN0UHJvdG9zYgZwcm90bzM=")); + descriptor = pbr::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, + new pbr::FileDescriptor[] { + global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor, + }); + internal__static_protobuf_unittest_TestMap__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMap), descriptor.MessageTypes[0], + new string[] { "MapInt32Int32", "MapInt64Int64", "MapUint32Uint32", "MapUint64Uint64", "MapSint32Sint32", "MapSint64Sint64", "MapFixed32Fixed32", "MapFixed64Fixed64", "MapSfixed32Sfixed32", "MapSfixed64Sfixed64", "MapInt32Float", "MapInt32Double", "MapBoolBool", "MapStringString", "MapInt32Bytes", "MapInt32Enum", "MapInt32ForeignMessage", }, new string[] { }); + internal__static_protobuf_unittest_TestMapSubmessage__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMapSubmessage), descriptor.MessageTypes[1], + new string[] { "TestMap", }, new string[] { }); + internal__static_protobuf_unittest_TestMessageMap__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMessageMap), descriptor.MessageTypes[2], + new string[] { "MapInt32Message", }, new string[] { }); + internal__static_protobuf_unittest_TestSameTypeMap__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestSameTypeMap), descriptor.MessageTypes[3], + new string[] { "Map1", "Map2", }, new string[] { }); + internal__static_protobuf_unittest_TestArenaMap__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestArenaMap), descriptor.MessageTypes[4], + new string[] { "MapInt32Int32", "MapInt64Int64", "MapUint32Uint32", "MapUint64Uint64", "MapSint32Sint32", "MapSint64Sint64", "MapFixed32Fixed32", "MapFixed64Fixed64", "MapSfixed32Sfixed32", "MapSfixed64Sfixed64", "MapInt32Float", "MapInt32Double", "MapBoolBool", "MapInt32Enum", "MapInt32ForeignMessage", }, new string[] { }); + internal__static_protobuf_unittest_MessageContainingEnumCalledType__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.MessageContainingEnumCalledType), descriptor.MessageTypes[5], + new string[] { "Type", }, new string[] { }); + internal__static_protobuf_unittest_MessageContainingMapCalledEntry__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.MessageContainingMapCalledEntry), descriptor.MessageTypes[6], + new string[] { "Entry", }, new string[] { }); + } + #endregion + + } + #region Enums + public enum MapEnum { + MAP_ENUM_FOO = 0, + MAP_ENUM_BAR = 1, + MAP_ENUM_BAZ = 2, + } + + #endregion + + #region Messages + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class TestMap : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestMap()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "map_bool_bool", "map_fixed32_fixed32", "map_fixed64_fixed64", "map_int32_bytes", "map_int32_double", "map_int32_enum", "map_int32_float", "map_int32_foreign_message", "map_int32_int32", "map_int64_int64", "map_sfixed32_sfixed32", "map_sfixed64_sfixed64", "map_sint32_sint32", "map_sint64_sint64", "map_string_string", "map_uint32_uint32", "map_uint64_uint64" }; + private static readonly uint[] _fieldTags = new uint[] { 106, 58, 66, 122, 98, 130, 90, 138, 10, 18, 74, 82, 42, 50, 114, 26, 34 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.Descriptor.MessageTypes[0]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMap__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public TestMap() { + OnConstruction(); + } + + partial void OnConstruction(); + + public TestMap(TestMap other) : this() { + mapInt32Int32_ = other.mapInt32Int32_.Clone(); + mapInt64Int64_ = other.mapInt64Int64_.Clone(); + mapUint32Uint32_ = other.mapUint32Uint32_.Clone(); + mapUint64Uint64_ = other.mapUint64Uint64_.Clone(); + mapSint32Sint32_ = other.mapSint32Sint32_.Clone(); + mapSint64Sint64_ = other.mapSint64Sint64_.Clone(); + mapFixed32Fixed32_ = other.mapFixed32Fixed32_.Clone(); + mapFixed64Fixed64_ = other.mapFixed64Fixed64_.Clone(); + mapSfixed32Sfixed32_ = other.mapSfixed32Sfixed32_.Clone(); + mapSfixed64Sfixed64_ = other.mapSfixed64Sfixed64_.Clone(); + mapInt32Float_ = other.mapInt32Float_.Clone(); + mapInt32Double_ = other.mapInt32Double_.Clone(); + mapBoolBool_ = other.mapBoolBool_.Clone(); + mapStringString_ = other.mapStringString_.Clone(); + mapInt32Bytes_ = other.mapInt32Bytes_.Clone(); + mapInt32Enum_ = other.mapInt32Enum_.Clone(); + mapInt32ForeignMessage_ = other.mapInt32ForeignMessage_.Clone(); + } + + public TestMap Clone() { + return new TestMap(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + mapInt32Int32_.Freeze(); + mapInt64Int64_.Freeze(); + mapUint32Uint32_.Freeze(); + mapUint64Uint64_.Freeze(); + mapSint32Sint32_.Freeze(); + mapSint64Sint64_.Freeze(); + mapFixed32Fixed32_.Freeze(); + mapFixed64Fixed64_.Freeze(); + mapSfixed32Sfixed32_.Freeze(); + mapSfixed64Sfixed64_.Freeze(); + mapInt32Float_.Freeze(); + mapInt32Double_.Freeze(); + mapBoolBool_.Freeze(); + mapStringString_.Freeze(); + mapInt32Bytes_.Freeze(); + mapInt32Enum_.Freeze(); + mapInt32ForeignMessage_.Freeze(); + } + + public const int MapInt32Int32FieldNumber = 1; + private static readonly pbc::MapField.Codec _map_mapInt32Int32_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForInt32(16), 10); + private readonly pbc::MapField mapInt32Int32_ = new pbc::MapField(); + public pbc::MapField MapInt32Int32 { + get { return mapInt32Int32_; } + } + + public const int MapInt64Int64FieldNumber = 2; + private static readonly pbc::MapField.Codec _map_mapInt64Int64_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForInt64(8), pb::FieldCodec.ForInt64(16), 18); + private readonly pbc::MapField mapInt64Int64_ = new pbc::MapField(); + public pbc::MapField MapInt64Int64 { + get { return mapInt64Int64_; } + } + + public const int MapUint32Uint32FieldNumber = 3; + private static readonly pbc::MapField.Codec _map_mapUint32Uint32_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForUInt32(8), pb::FieldCodec.ForUInt32(16), 26); + private readonly pbc::MapField mapUint32Uint32_ = new pbc::MapField(); + public pbc::MapField MapUint32Uint32 { + get { return mapUint32Uint32_; } + } + + public const int MapUint64Uint64FieldNumber = 4; + private static readonly pbc::MapField.Codec _map_mapUint64Uint64_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForUInt64(8), pb::FieldCodec.ForUInt64(16), 34); + private readonly pbc::MapField mapUint64Uint64_ = new pbc::MapField(); + public pbc::MapField MapUint64Uint64 { + get { return mapUint64Uint64_; } + } + + public const int MapSint32Sint32FieldNumber = 5; + private static readonly pbc::MapField.Codec _map_mapSint32Sint32_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForSInt32(8), pb::FieldCodec.ForSInt32(16), 42); + private readonly pbc::MapField mapSint32Sint32_ = new pbc::MapField(); + public pbc::MapField MapSint32Sint32 { + get { return mapSint32Sint32_; } + } + + public const int MapSint64Sint64FieldNumber = 6; + private static readonly pbc::MapField.Codec _map_mapSint64Sint64_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForSInt64(8), pb::FieldCodec.ForSInt64(16), 50); + private readonly pbc::MapField mapSint64Sint64_ = new pbc::MapField(); + public pbc::MapField MapSint64Sint64 { + get { return mapSint64Sint64_; } + } + + public const int MapFixed32Fixed32FieldNumber = 7; + private static readonly pbc::MapField.Codec _map_mapFixed32Fixed32_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForFixed32(13), pb::FieldCodec.ForFixed32(21), 58); + private readonly pbc::MapField mapFixed32Fixed32_ = new pbc::MapField(); + public pbc::MapField MapFixed32Fixed32 { + get { return mapFixed32Fixed32_; } + } + + public const int MapFixed64Fixed64FieldNumber = 8; + private static readonly pbc::MapField.Codec _map_mapFixed64Fixed64_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForFixed64(9), pb::FieldCodec.ForFixed64(17), 66); + private readonly pbc::MapField mapFixed64Fixed64_ = new pbc::MapField(); + public pbc::MapField MapFixed64Fixed64 { + get { return mapFixed64Fixed64_; } + } + + public const int MapSfixed32Sfixed32FieldNumber = 9; + private static readonly pbc::MapField.Codec _map_mapSfixed32Sfixed32_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForSFixed32(13), pb::FieldCodec.ForSFixed32(21), 74); + private readonly pbc::MapField mapSfixed32Sfixed32_ = new pbc::MapField(); + public pbc::MapField MapSfixed32Sfixed32 { + get { return mapSfixed32Sfixed32_; } + } + + public const int MapSfixed64Sfixed64FieldNumber = 10; + private static readonly pbc::MapField.Codec _map_mapSfixed64Sfixed64_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForSFixed64(9), pb::FieldCodec.ForSFixed64(17), 82); + private readonly pbc::MapField mapSfixed64Sfixed64_ = new pbc::MapField(); + public pbc::MapField MapSfixed64Sfixed64 { + get { return mapSfixed64Sfixed64_; } + } + + public const int MapInt32FloatFieldNumber = 11; + private static readonly pbc::MapField.Codec _map_mapInt32Float_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForFloat(21), 90); + private readonly pbc::MapField mapInt32Float_ = new pbc::MapField(); + public pbc::MapField MapInt32Float { + get { return mapInt32Float_; } + } + + public const int MapInt32DoubleFieldNumber = 12; + private static readonly pbc::MapField.Codec _map_mapInt32Double_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForDouble(17), 98); + private readonly pbc::MapField mapInt32Double_ = new pbc::MapField(); + public pbc::MapField MapInt32Double { + get { return mapInt32Double_; } + } + + public const int MapBoolBoolFieldNumber = 13; + private static readonly pbc::MapField.Codec _map_mapBoolBool_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForBool(8), pb::FieldCodec.ForBool(16), 106); + private readonly pbc::MapField mapBoolBool_ = new pbc::MapField(); + public pbc::MapField MapBoolBool { + get { return mapBoolBool_; } + } + + public const int MapStringStringFieldNumber = 14; + private static readonly pbc::MapField.Codec _map_mapStringString_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForString(10), pb::FieldCodec.ForString(18), 114); + private readonly pbc::MapField mapStringString_ = new pbc::MapField(); + public pbc::MapField MapStringString { + get { return mapStringString_; } + } + + public const int MapInt32BytesFieldNumber = 15; + private static readonly pbc::MapField.Codec _map_mapInt32Bytes_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForBytes(18), 122); + private readonly pbc::MapField mapInt32Bytes_ = new pbc::MapField(); + public pbc::MapField MapInt32Bytes { + get { return mapInt32Bytes_; } + } + + public const int MapInt32EnumFieldNumber = 16; + private static readonly pbc::MapField.Codec _map_mapInt32Enum_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForEnum(16, x => (int) x, x => (global::Google.Protobuf.TestProtos.MapEnum) x), 130); + private readonly pbc::MapField mapInt32Enum_ = new pbc::MapField(); + public pbc::MapField MapInt32Enum { + get { return mapInt32Enum_; } + } + + public const int MapInt32ForeignMessageFieldNumber = 17; + private static readonly pbc::MapField.Codec _map_mapInt32ForeignMessage_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForMessage(18, global::Google.Protobuf.TestProtos.ForeignMessage.Parser), 138); + private readonly pbc::MapField mapInt32ForeignMessage_ = new pbc::MapField(); + public pbc::MapField MapInt32ForeignMessage { + get { return mapInt32ForeignMessage_; } + } + + public override bool Equals(object other) { + return Equals(other as TestMap); + } + + public bool Equals(TestMap other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (!MapInt32Int32.Equals(other.MapInt32Int32)) return false; + if (!MapInt64Int64.Equals(other.MapInt64Int64)) return false; + if (!MapUint32Uint32.Equals(other.MapUint32Uint32)) return false; + if (!MapUint64Uint64.Equals(other.MapUint64Uint64)) return false; + if (!MapSint32Sint32.Equals(other.MapSint32Sint32)) return false; + if (!MapSint64Sint64.Equals(other.MapSint64Sint64)) return false; + if (!MapFixed32Fixed32.Equals(other.MapFixed32Fixed32)) return false; + if (!MapFixed64Fixed64.Equals(other.MapFixed64Fixed64)) return false; + if (!MapSfixed32Sfixed32.Equals(other.MapSfixed32Sfixed32)) return false; + if (!MapSfixed64Sfixed64.Equals(other.MapSfixed64Sfixed64)) return false; + if (!MapInt32Float.Equals(other.MapInt32Float)) return false; + if (!MapInt32Double.Equals(other.MapInt32Double)) return false; + if (!MapBoolBool.Equals(other.MapBoolBool)) return false; + if (!MapStringString.Equals(other.MapStringString)) return false; + if (!MapInt32Bytes.Equals(other.MapInt32Bytes)) return false; + if (!MapInt32Enum.Equals(other.MapInt32Enum)) return false; + if (!MapInt32ForeignMessage.Equals(other.MapInt32ForeignMessage)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + hash ^= MapInt32Int32.GetHashCode(); + hash ^= MapInt64Int64.GetHashCode(); + hash ^= MapUint32Uint32.GetHashCode(); + hash ^= MapUint64Uint64.GetHashCode(); + hash ^= MapSint32Sint32.GetHashCode(); + hash ^= MapSint64Sint64.GetHashCode(); + hash ^= MapFixed32Fixed32.GetHashCode(); + hash ^= MapFixed64Fixed64.GetHashCode(); + hash ^= MapSfixed32Sfixed32.GetHashCode(); + hash ^= MapSfixed64Sfixed64.GetHashCode(); + hash ^= MapInt32Float.GetHashCode(); + hash ^= MapInt32Double.GetHashCode(); + hash ^= MapBoolBool.GetHashCode(); + hash ^= MapStringString.GetHashCode(); + hash ^= MapInt32Bytes.GetHashCode(); + hash ^= MapInt32Enum.GetHashCode(); + hash ^= MapInt32ForeignMessage.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + mapInt32Int32_.WriteTo(output, _map_mapInt32Int32_codec); + mapInt64Int64_.WriteTo(output, _map_mapInt64Int64_codec); + mapUint32Uint32_.WriteTo(output, _map_mapUint32Uint32_codec); + mapUint64Uint64_.WriteTo(output, _map_mapUint64Uint64_codec); + mapSint32Sint32_.WriteTo(output, _map_mapSint32Sint32_codec); + mapSint64Sint64_.WriteTo(output, _map_mapSint64Sint64_codec); + mapFixed32Fixed32_.WriteTo(output, _map_mapFixed32Fixed32_codec); + mapFixed64Fixed64_.WriteTo(output, _map_mapFixed64Fixed64_codec); + mapSfixed32Sfixed32_.WriteTo(output, _map_mapSfixed32Sfixed32_codec); + mapSfixed64Sfixed64_.WriteTo(output, _map_mapSfixed64Sfixed64_codec); + mapInt32Float_.WriteTo(output, _map_mapInt32Float_codec); + mapInt32Double_.WriteTo(output, _map_mapInt32Double_codec); + mapBoolBool_.WriteTo(output, _map_mapBoolBool_codec); + mapStringString_.WriteTo(output, _map_mapStringString_codec); + mapInt32Bytes_.WriteTo(output, _map_mapInt32Bytes_codec); + mapInt32Enum_.WriteTo(output, _map_mapInt32Enum_codec); + mapInt32ForeignMessage_.WriteTo(output, _map_mapInt32ForeignMessage_codec); + } + + public int CalculateSize() { + int size = 0; + size += mapInt32Int32_.CalculateSize(_map_mapInt32Int32_codec); + size += mapInt64Int64_.CalculateSize(_map_mapInt64Int64_codec); + size += mapUint32Uint32_.CalculateSize(_map_mapUint32Uint32_codec); + size += mapUint64Uint64_.CalculateSize(_map_mapUint64Uint64_codec); + size += mapSint32Sint32_.CalculateSize(_map_mapSint32Sint32_codec); + size += mapSint64Sint64_.CalculateSize(_map_mapSint64Sint64_codec); + size += mapFixed32Fixed32_.CalculateSize(_map_mapFixed32Fixed32_codec); + size += mapFixed64Fixed64_.CalculateSize(_map_mapFixed64Fixed64_codec); + size += mapSfixed32Sfixed32_.CalculateSize(_map_mapSfixed32Sfixed32_codec); + size += mapSfixed64Sfixed64_.CalculateSize(_map_mapSfixed64Sfixed64_codec); + size += mapInt32Float_.CalculateSize(_map_mapInt32Float_codec); + size += mapInt32Double_.CalculateSize(_map_mapInt32Double_codec); + size += mapBoolBool_.CalculateSize(_map_mapBoolBool_codec); + size += mapStringString_.CalculateSize(_map_mapStringString_codec); + size += mapInt32Bytes_.CalculateSize(_map_mapInt32Bytes_codec); + size += mapInt32Enum_.CalculateSize(_map_mapInt32Enum_codec); + size += mapInt32ForeignMessage_.CalculateSize(_map_mapInt32ForeignMessage_codec); + return size; + } + + public void MergeFrom(TestMap other) { + if (other == null) { + return; + } + mapInt32Int32_.Add(other.mapInt32Int32_); + mapInt64Int64_.Add(other.mapInt64Int64_); + mapUint32Uint32_.Add(other.mapUint32Uint32_); + mapUint64Uint64_.Add(other.mapUint64Uint64_); + mapSint32Sint32_.Add(other.mapSint32Sint32_); + mapSint64Sint64_.Add(other.mapSint64Sint64_); + mapFixed32Fixed32_.Add(other.mapFixed32Fixed32_); + mapFixed64Fixed64_.Add(other.mapFixed64Fixed64_); + mapSfixed32Sfixed32_.Add(other.mapSfixed32Sfixed32_); + mapSfixed64Sfixed64_.Add(other.mapSfixed64Sfixed64_); + mapInt32Float_.Add(other.mapInt32Float_); + mapInt32Double_.Add(other.mapInt32Double_); + mapBoolBool_.Add(other.mapBoolBool_); + mapStringString_.Add(other.mapStringString_); + mapInt32Bytes_.Add(other.mapInt32Bytes_); + mapInt32Enum_.Add(other.mapInt32Enum_); + mapInt32ForeignMessage_.Add(other.mapInt32ForeignMessage_); + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + mapInt32Int32_.AddEntriesFrom(input, _map_mapInt32Int32_codec); + break; + } + case 18: { + mapInt64Int64_.AddEntriesFrom(input, _map_mapInt64Int64_codec); + break; + } + case 26: { + mapUint32Uint32_.AddEntriesFrom(input, _map_mapUint32Uint32_codec); + break; + } + case 34: { + mapUint64Uint64_.AddEntriesFrom(input, _map_mapUint64Uint64_codec); + break; + } + case 42: { + mapSint32Sint32_.AddEntriesFrom(input, _map_mapSint32Sint32_codec); + break; + } + case 50: { + mapSint64Sint64_.AddEntriesFrom(input, _map_mapSint64Sint64_codec); + break; + } + case 58: { + mapFixed32Fixed32_.AddEntriesFrom(input, _map_mapFixed32Fixed32_codec); + break; + } + case 66: { + mapFixed64Fixed64_.AddEntriesFrom(input, _map_mapFixed64Fixed64_codec); + break; + } + case 74: { + mapSfixed32Sfixed32_.AddEntriesFrom(input, _map_mapSfixed32Sfixed32_codec); + break; + } + case 82: { + mapSfixed64Sfixed64_.AddEntriesFrom(input, _map_mapSfixed64Sfixed64_codec); + break; + } + case 90: { + mapInt32Float_.AddEntriesFrom(input, _map_mapInt32Float_codec); + break; + } + case 98: { + mapInt32Double_.AddEntriesFrom(input, _map_mapInt32Double_codec); + break; + } + case 106: { + mapBoolBool_.AddEntriesFrom(input, _map_mapBoolBool_codec); + break; + } + case 114: { + mapStringString_.AddEntriesFrom(input, _map_mapStringString_codec); + break; + } + case 122: { + mapInt32Bytes_.AddEntriesFrom(input, _map_mapInt32Bytes_codec); + break; + } + case 130: { + mapInt32Enum_.AddEntriesFrom(input, _map_mapInt32Enum_codec); + break; + } + case 138: { + mapInt32ForeignMessage_.AddEntriesFrom(input, _map_mapInt32ForeignMessage_codec); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class TestMapSubmessage : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestMapSubmessage()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "test_map" }; + private static readonly uint[] _fieldTags = new uint[] { 10 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.Descriptor.MessageTypes[1]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMapSubmessage__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public TestMapSubmessage() { + OnConstruction(); + } + + partial void OnConstruction(); + + public TestMapSubmessage(TestMapSubmessage other) : this() { + TestMap = other.testMap_ != null ? other.TestMap.Clone() : null; + } + + public TestMapSubmessage Clone() { + return new TestMapSubmessage(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + if (testMap_ != null) TestMap.Freeze(); + } + + public const int TestMapFieldNumber = 1; + private global::Google.Protobuf.TestProtos.TestMap testMap_; + public global::Google.Protobuf.TestProtos.TestMap TestMap { + get { return testMap_; } + set { + pb::Freezable.CheckMutable(this); + testMap_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as TestMapSubmessage); + } + + public bool Equals(TestMapSubmessage other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (!object.Equals(TestMap, other.TestMap)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (testMap_ != null) hash ^= TestMap.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (testMap_ != null) { + output.WriteRawTag(10); + output.WriteMessage(TestMap); + } + } + + public int CalculateSize() { + int size = 0; + if (testMap_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(TestMap); + } + return size; + } + + public void MergeFrom(TestMapSubmessage other) { + if (other == null) { + return; + } + if (other.testMap_ != null) { + if (testMap_ == null) { + testMap_ = new global::Google.Protobuf.TestProtos.TestMap(); + } + TestMap.MergeFrom(other.TestMap); + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + if (testMap_ == null) { + testMap_ = new global::Google.Protobuf.TestProtos.TestMap(); + } + input.ReadMessage(testMap_); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class TestMessageMap : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestMessageMap()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "map_int32_message" }; + private static readonly uint[] _fieldTags = new uint[] { 10 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.Descriptor.MessageTypes[2]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestMessageMap__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public TestMessageMap() { + OnConstruction(); + } + + partial void OnConstruction(); + + public TestMessageMap(TestMessageMap other) : this() { + mapInt32Message_ = other.mapInt32Message_.Clone(); + } + + public TestMessageMap Clone() { + return new TestMessageMap(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + mapInt32Message_.Freeze(); + } + + public const int MapInt32MessageFieldNumber = 1; + private static readonly pbc::MapField.Codec _map_mapInt32Message_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForMessage(18, global::Google.Protobuf.TestProtos.TestAllTypes.Parser), 10); + private readonly pbc::MapField mapInt32Message_ = new pbc::MapField(); + public pbc::MapField MapInt32Message { + get { return mapInt32Message_; } + } + + public override bool Equals(object other) { + return Equals(other as TestMessageMap); + } + + public bool Equals(TestMessageMap other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (!MapInt32Message.Equals(other.MapInt32Message)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + hash ^= MapInt32Message.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + mapInt32Message_.WriteTo(output, _map_mapInt32Message_codec); + } + + public int CalculateSize() { + int size = 0; + size += mapInt32Message_.CalculateSize(_map_mapInt32Message_codec); + return size; + } + + public void MergeFrom(TestMessageMap other) { + if (other == null) { + return; + } + mapInt32Message_.Add(other.mapInt32Message_); + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + mapInt32Message_.AddEntriesFrom(input, _map_mapInt32Message_codec); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class TestSameTypeMap : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestSameTypeMap()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "map1", "map2" }; + private static readonly uint[] _fieldTags = new uint[] { 10, 18 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.Descriptor.MessageTypes[3]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestSameTypeMap__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public TestSameTypeMap() { + OnConstruction(); + } + + partial void OnConstruction(); + + public TestSameTypeMap(TestSameTypeMap other) : this() { + map1_ = other.map1_.Clone(); + map2_ = other.map2_.Clone(); + } + + public TestSameTypeMap Clone() { + return new TestSameTypeMap(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + map1_.Freeze(); + map2_.Freeze(); + } + + public const int Map1FieldNumber = 1; + private static readonly pbc::MapField.Codec _map_map1_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForInt32(16), 10); + private readonly pbc::MapField map1_ = new pbc::MapField(); + public pbc::MapField Map1 { + get { return map1_; } + } + + public const int Map2FieldNumber = 2; + private static readonly pbc::MapField.Codec _map_map2_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForInt32(16), 18); + private readonly pbc::MapField map2_ = new pbc::MapField(); + public pbc::MapField Map2 { + get { return map2_; } + } + + public override bool Equals(object other) { + return Equals(other as TestSameTypeMap); + } + + public bool Equals(TestSameTypeMap other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (!Map1.Equals(other.Map1)) return false; + if (!Map2.Equals(other.Map2)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + hash ^= Map1.GetHashCode(); + hash ^= Map2.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + map1_.WriteTo(output, _map_map1_codec); + map2_.WriteTo(output, _map_map2_codec); + } + + public int CalculateSize() { + int size = 0; + size += map1_.CalculateSize(_map_map1_codec); + size += map2_.CalculateSize(_map_map2_codec); + return size; + } + + public void MergeFrom(TestSameTypeMap other) { + if (other == null) { + return; + } + map1_.Add(other.map1_); + map2_.Add(other.map2_); + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + map1_.AddEntriesFrom(input, _map_map1_codec); + break; + } + case 18: { + map2_.AddEntriesFrom(input, _map_map2_codec); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class TestArenaMap : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestArenaMap()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "map_bool_bool", "map_fixed32_fixed32", "map_fixed64_fixed64", "map_int32_double", "map_int32_enum", "map_int32_float", "map_int32_foreign_message", "map_int32_int32", "map_int64_int64", "map_sfixed32_sfixed32", "map_sfixed64_sfixed64", "map_sint32_sint32", "map_sint64_sint64", "map_uint32_uint32", "map_uint64_uint64" }; + private static readonly uint[] _fieldTags = new uint[] { 106, 58, 66, 98, 114, 90, 122, 10, 18, 74, 82, 42, 50, 26, 34 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.Descriptor.MessageTypes[4]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_TestArenaMap__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public TestArenaMap() { + OnConstruction(); + } + + partial void OnConstruction(); + + public TestArenaMap(TestArenaMap other) : this() { + mapInt32Int32_ = other.mapInt32Int32_.Clone(); + mapInt64Int64_ = other.mapInt64Int64_.Clone(); + mapUint32Uint32_ = other.mapUint32Uint32_.Clone(); + mapUint64Uint64_ = other.mapUint64Uint64_.Clone(); + mapSint32Sint32_ = other.mapSint32Sint32_.Clone(); + mapSint64Sint64_ = other.mapSint64Sint64_.Clone(); + mapFixed32Fixed32_ = other.mapFixed32Fixed32_.Clone(); + mapFixed64Fixed64_ = other.mapFixed64Fixed64_.Clone(); + mapSfixed32Sfixed32_ = other.mapSfixed32Sfixed32_.Clone(); + mapSfixed64Sfixed64_ = other.mapSfixed64Sfixed64_.Clone(); + mapInt32Float_ = other.mapInt32Float_.Clone(); + mapInt32Double_ = other.mapInt32Double_.Clone(); + mapBoolBool_ = other.mapBoolBool_.Clone(); + mapInt32Enum_ = other.mapInt32Enum_.Clone(); + mapInt32ForeignMessage_ = other.mapInt32ForeignMessage_.Clone(); + } + + public TestArenaMap Clone() { + return new TestArenaMap(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + mapInt32Int32_.Freeze(); + mapInt64Int64_.Freeze(); + mapUint32Uint32_.Freeze(); + mapUint64Uint64_.Freeze(); + mapSint32Sint32_.Freeze(); + mapSint64Sint64_.Freeze(); + mapFixed32Fixed32_.Freeze(); + mapFixed64Fixed64_.Freeze(); + mapSfixed32Sfixed32_.Freeze(); + mapSfixed64Sfixed64_.Freeze(); + mapInt32Float_.Freeze(); + mapInt32Double_.Freeze(); + mapBoolBool_.Freeze(); + mapInt32Enum_.Freeze(); + mapInt32ForeignMessage_.Freeze(); + } + + public const int MapInt32Int32FieldNumber = 1; + private static readonly pbc::MapField.Codec _map_mapInt32Int32_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForInt32(16), 10); + private readonly pbc::MapField mapInt32Int32_ = new pbc::MapField(); + public pbc::MapField MapInt32Int32 { + get { return mapInt32Int32_; } + } + + public const int MapInt64Int64FieldNumber = 2; + private static readonly pbc::MapField.Codec _map_mapInt64Int64_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForInt64(8), pb::FieldCodec.ForInt64(16), 18); + private readonly pbc::MapField mapInt64Int64_ = new pbc::MapField(); + public pbc::MapField MapInt64Int64 { + get { return mapInt64Int64_; } + } + + public const int MapUint32Uint32FieldNumber = 3; + private static readonly pbc::MapField.Codec _map_mapUint32Uint32_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForUInt32(8), pb::FieldCodec.ForUInt32(16), 26); + private readonly pbc::MapField mapUint32Uint32_ = new pbc::MapField(); + public pbc::MapField MapUint32Uint32 { + get { return mapUint32Uint32_; } + } + + public const int MapUint64Uint64FieldNumber = 4; + private static readonly pbc::MapField.Codec _map_mapUint64Uint64_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForUInt64(8), pb::FieldCodec.ForUInt64(16), 34); + private readonly pbc::MapField mapUint64Uint64_ = new pbc::MapField(); + public pbc::MapField MapUint64Uint64 { + get { return mapUint64Uint64_; } + } + + public const int MapSint32Sint32FieldNumber = 5; + private static readonly pbc::MapField.Codec _map_mapSint32Sint32_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForSInt32(8), pb::FieldCodec.ForSInt32(16), 42); + private readonly pbc::MapField mapSint32Sint32_ = new pbc::MapField(); + public pbc::MapField MapSint32Sint32 { + get { return mapSint32Sint32_; } + } + + public const int MapSint64Sint64FieldNumber = 6; + private static readonly pbc::MapField.Codec _map_mapSint64Sint64_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForSInt64(8), pb::FieldCodec.ForSInt64(16), 50); + private readonly pbc::MapField mapSint64Sint64_ = new pbc::MapField(); + public pbc::MapField MapSint64Sint64 { + get { return mapSint64Sint64_; } + } + + public const int MapFixed32Fixed32FieldNumber = 7; + private static readonly pbc::MapField.Codec _map_mapFixed32Fixed32_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForFixed32(13), pb::FieldCodec.ForFixed32(21), 58); + private readonly pbc::MapField mapFixed32Fixed32_ = new pbc::MapField(); + public pbc::MapField MapFixed32Fixed32 { + get { return mapFixed32Fixed32_; } + } + + public const int MapFixed64Fixed64FieldNumber = 8; + private static readonly pbc::MapField.Codec _map_mapFixed64Fixed64_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForFixed64(9), pb::FieldCodec.ForFixed64(17), 66); + private readonly pbc::MapField mapFixed64Fixed64_ = new pbc::MapField(); + public pbc::MapField MapFixed64Fixed64 { + get { return mapFixed64Fixed64_; } + } + + public const int MapSfixed32Sfixed32FieldNumber = 9; + private static readonly pbc::MapField.Codec _map_mapSfixed32Sfixed32_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForSFixed32(13), pb::FieldCodec.ForSFixed32(21), 74); + private readonly pbc::MapField mapSfixed32Sfixed32_ = new pbc::MapField(); + public pbc::MapField MapSfixed32Sfixed32 { + get { return mapSfixed32Sfixed32_; } + } + + public const int MapSfixed64Sfixed64FieldNumber = 10; + private static readonly pbc::MapField.Codec _map_mapSfixed64Sfixed64_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForSFixed64(9), pb::FieldCodec.ForSFixed64(17), 82); + private readonly pbc::MapField mapSfixed64Sfixed64_ = new pbc::MapField(); + public pbc::MapField MapSfixed64Sfixed64 { + get { return mapSfixed64Sfixed64_; } + } + + public const int MapInt32FloatFieldNumber = 11; + private static readonly pbc::MapField.Codec _map_mapInt32Float_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForFloat(21), 90); + private readonly pbc::MapField mapInt32Float_ = new pbc::MapField(); + public pbc::MapField MapInt32Float { + get { return mapInt32Float_; } + } + + public const int MapInt32DoubleFieldNumber = 12; + private static readonly pbc::MapField.Codec _map_mapInt32Double_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForDouble(17), 98); + private readonly pbc::MapField mapInt32Double_ = new pbc::MapField(); + public pbc::MapField MapInt32Double { + get { return mapInt32Double_; } + } + + public const int MapBoolBoolFieldNumber = 13; + private static readonly pbc::MapField.Codec _map_mapBoolBool_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForBool(8), pb::FieldCodec.ForBool(16), 106); + private readonly pbc::MapField mapBoolBool_ = new pbc::MapField(); + public pbc::MapField MapBoolBool { + get { return mapBoolBool_; } + } + + public const int MapInt32EnumFieldNumber = 14; + private static readonly pbc::MapField.Codec _map_mapInt32Enum_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForEnum(16, x => (int) x, x => (global::Google.Protobuf.TestProtos.MapEnum) x), 114); + private readonly pbc::MapField mapInt32Enum_ = new pbc::MapField(); + public pbc::MapField MapInt32Enum { + get { return mapInt32Enum_; } + } + + public const int MapInt32ForeignMessageFieldNumber = 15; + private static readonly pbc::MapField.Codec _map_mapInt32ForeignMessage_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForMessage(18, global::Google.Protobuf.TestProtos.ForeignMessage.Parser), 122); + private readonly pbc::MapField mapInt32ForeignMessage_ = new pbc::MapField(); + public pbc::MapField MapInt32ForeignMessage { + get { return mapInt32ForeignMessage_; } + } + + public override bool Equals(object other) { + return Equals(other as TestArenaMap); + } + + public bool Equals(TestArenaMap other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (!MapInt32Int32.Equals(other.MapInt32Int32)) return false; + if (!MapInt64Int64.Equals(other.MapInt64Int64)) return false; + if (!MapUint32Uint32.Equals(other.MapUint32Uint32)) return false; + if (!MapUint64Uint64.Equals(other.MapUint64Uint64)) return false; + if (!MapSint32Sint32.Equals(other.MapSint32Sint32)) return false; + if (!MapSint64Sint64.Equals(other.MapSint64Sint64)) return false; + if (!MapFixed32Fixed32.Equals(other.MapFixed32Fixed32)) return false; + if (!MapFixed64Fixed64.Equals(other.MapFixed64Fixed64)) return false; + if (!MapSfixed32Sfixed32.Equals(other.MapSfixed32Sfixed32)) return false; + if (!MapSfixed64Sfixed64.Equals(other.MapSfixed64Sfixed64)) return false; + if (!MapInt32Float.Equals(other.MapInt32Float)) return false; + if (!MapInt32Double.Equals(other.MapInt32Double)) return false; + if (!MapBoolBool.Equals(other.MapBoolBool)) return false; + if (!MapInt32Enum.Equals(other.MapInt32Enum)) return false; + if (!MapInt32ForeignMessage.Equals(other.MapInt32ForeignMessage)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + hash ^= MapInt32Int32.GetHashCode(); + hash ^= MapInt64Int64.GetHashCode(); + hash ^= MapUint32Uint32.GetHashCode(); + hash ^= MapUint64Uint64.GetHashCode(); + hash ^= MapSint32Sint32.GetHashCode(); + hash ^= MapSint64Sint64.GetHashCode(); + hash ^= MapFixed32Fixed32.GetHashCode(); + hash ^= MapFixed64Fixed64.GetHashCode(); + hash ^= MapSfixed32Sfixed32.GetHashCode(); + hash ^= MapSfixed64Sfixed64.GetHashCode(); + hash ^= MapInt32Float.GetHashCode(); + hash ^= MapInt32Double.GetHashCode(); + hash ^= MapBoolBool.GetHashCode(); + hash ^= MapInt32Enum.GetHashCode(); + hash ^= MapInt32ForeignMessage.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + mapInt32Int32_.WriteTo(output, _map_mapInt32Int32_codec); + mapInt64Int64_.WriteTo(output, _map_mapInt64Int64_codec); + mapUint32Uint32_.WriteTo(output, _map_mapUint32Uint32_codec); + mapUint64Uint64_.WriteTo(output, _map_mapUint64Uint64_codec); + mapSint32Sint32_.WriteTo(output, _map_mapSint32Sint32_codec); + mapSint64Sint64_.WriteTo(output, _map_mapSint64Sint64_codec); + mapFixed32Fixed32_.WriteTo(output, _map_mapFixed32Fixed32_codec); + mapFixed64Fixed64_.WriteTo(output, _map_mapFixed64Fixed64_codec); + mapSfixed32Sfixed32_.WriteTo(output, _map_mapSfixed32Sfixed32_codec); + mapSfixed64Sfixed64_.WriteTo(output, _map_mapSfixed64Sfixed64_codec); + mapInt32Float_.WriteTo(output, _map_mapInt32Float_codec); + mapInt32Double_.WriteTo(output, _map_mapInt32Double_codec); + mapBoolBool_.WriteTo(output, _map_mapBoolBool_codec); + mapInt32Enum_.WriteTo(output, _map_mapInt32Enum_codec); + mapInt32ForeignMessage_.WriteTo(output, _map_mapInt32ForeignMessage_codec); + } + + public int CalculateSize() { + int size = 0; + size += mapInt32Int32_.CalculateSize(_map_mapInt32Int32_codec); + size += mapInt64Int64_.CalculateSize(_map_mapInt64Int64_codec); + size += mapUint32Uint32_.CalculateSize(_map_mapUint32Uint32_codec); + size += mapUint64Uint64_.CalculateSize(_map_mapUint64Uint64_codec); + size += mapSint32Sint32_.CalculateSize(_map_mapSint32Sint32_codec); + size += mapSint64Sint64_.CalculateSize(_map_mapSint64Sint64_codec); + size += mapFixed32Fixed32_.CalculateSize(_map_mapFixed32Fixed32_codec); + size += mapFixed64Fixed64_.CalculateSize(_map_mapFixed64Fixed64_codec); + size += mapSfixed32Sfixed32_.CalculateSize(_map_mapSfixed32Sfixed32_codec); + size += mapSfixed64Sfixed64_.CalculateSize(_map_mapSfixed64Sfixed64_codec); + size += mapInt32Float_.CalculateSize(_map_mapInt32Float_codec); + size += mapInt32Double_.CalculateSize(_map_mapInt32Double_codec); + size += mapBoolBool_.CalculateSize(_map_mapBoolBool_codec); + size += mapInt32Enum_.CalculateSize(_map_mapInt32Enum_codec); + size += mapInt32ForeignMessage_.CalculateSize(_map_mapInt32ForeignMessage_codec); + return size; + } + + public void MergeFrom(TestArenaMap other) { + if (other == null) { + return; + } + mapInt32Int32_.Add(other.mapInt32Int32_); + mapInt64Int64_.Add(other.mapInt64Int64_); + mapUint32Uint32_.Add(other.mapUint32Uint32_); + mapUint64Uint64_.Add(other.mapUint64Uint64_); + mapSint32Sint32_.Add(other.mapSint32Sint32_); + mapSint64Sint64_.Add(other.mapSint64Sint64_); + mapFixed32Fixed32_.Add(other.mapFixed32Fixed32_); + mapFixed64Fixed64_.Add(other.mapFixed64Fixed64_); + mapSfixed32Sfixed32_.Add(other.mapSfixed32Sfixed32_); + mapSfixed64Sfixed64_.Add(other.mapSfixed64Sfixed64_); + mapInt32Float_.Add(other.mapInt32Float_); + mapInt32Double_.Add(other.mapInt32Double_); + mapBoolBool_.Add(other.mapBoolBool_); + mapInt32Enum_.Add(other.mapInt32Enum_); + mapInt32ForeignMessage_.Add(other.mapInt32ForeignMessage_); + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + mapInt32Int32_.AddEntriesFrom(input, _map_mapInt32Int32_codec); + break; + } + case 18: { + mapInt64Int64_.AddEntriesFrom(input, _map_mapInt64Int64_codec); + break; + } + case 26: { + mapUint32Uint32_.AddEntriesFrom(input, _map_mapUint32Uint32_codec); + break; + } + case 34: { + mapUint64Uint64_.AddEntriesFrom(input, _map_mapUint64Uint64_codec); + break; + } + case 42: { + mapSint32Sint32_.AddEntriesFrom(input, _map_mapSint32Sint32_codec); + break; + } + case 50: { + mapSint64Sint64_.AddEntriesFrom(input, _map_mapSint64Sint64_codec); + break; + } + case 58: { + mapFixed32Fixed32_.AddEntriesFrom(input, _map_mapFixed32Fixed32_codec); + break; + } + case 66: { + mapFixed64Fixed64_.AddEntriesFrom(input, _map_mapFixed64Fixed64_codec); + break; + } + case 74: { + mapSfixed32Sfixed32_.AddEntriesFrom(input, _map_mapSfixed32Sfixed32_codec); + break; + } + case 82: { + mapSfixed64Sfixed64_.AddEntriesFrom(input, _map_mapSfixed64Sfixed64_codec); + break; + } + case 90: { + mapInt32Float_.AddEntriesFrom(input, _map_mapInt32Float_codec); + break; + } + case 98: { + mapInt32Double_.AddEntriesFrom(input, _map_mapInt32Double_codec); + break; + } + case 106: { + mapBoolBool_.AddEntriesFrom(input, _map_mapBoolBool_codec); + break; + } + case 114: { + mapInt32Enum_.AddEntriesFrom(input, _map_mapInt32Enum_codec); + break; + } + case 122: { + mapInt32ForeignMessage_.AddEntriesFrom(input, _map_mapInt32ForeignMessage_codec); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class MessageContainingEnumCalledType : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MessageContainingEnumCalledType()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "type" }; + private static readonly uint[] _fieldTags = new uint[] { 10 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.Descriptor.MessageTypes[5]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_MessageContainingEnumCalledType__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public MessageContainingEnumCalledType() { + OnConstruction(); + } + + partial void OnConstruction(); + + public MessageContainingEnumCalledType(MessageContainingEnumCalledType other) : this() { + type_ = other.type_.Clone(); + } + + public MessageContainingEnumCalledType Clone() { + return new MessageContainingEnumCalledType(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + type_.Freeze(); + } + + public const int TypeFieldNumber = 1; + private static readonly pbc::MapField.Codec _map_type_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForMessage(18, global::Google.Protobuf.TestProtos.MessageContainingEnumCalledType.Parser), 10); + private readonly pbc::MapField type_ = new pbc::MapField(); + public pbc::MapField Type { + get { return type_; } + } + + public override bool Equals(object other) { + return Equals(other as MessageContainingEnumCalledType); + } + + public bool Equals(MessageContainingEnumCalledType other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (!Type.Equals(other.Type)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + hash ^= Type.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + type_.WriteTo(output, _map_type_codec); + } + + public int CalculateSize() { + int size = 0; + size += type_.CalculateSize(_map_type_codec); + return size; + } + + public void MergeFrom(MessageContainingEnumCalledType other) { + if (other == null) { + return; + } + type_.Add(other.type_); + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + type_.AddEntriesFrom(input, _map_type_codec); + break; + } + } + } + } + + #region Nested types + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static partial class Types { + public enum Type { + TYPE_FOO = 0, + } + + } + #endregion + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class MessageContainingMapCalledEntry : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MessageContainingMapCalledEntry()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "entry" }; + private static readonly uint[] _fieldTags = new uint[] { 10 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.Descriptor.MessageTypes[6]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.TestProtos.MapUnittestProto3.internal__static_protobuf_unittest_MessageContainingMapCalledEntry__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public MessageContainingMapCalledEntry() { + OnConstruction(); + } + + partial void OnConstruction(); + + public MessageContainingMapCalledEntry(MessageContainingMapCalledEntry other) : this() { + entry_ = other.entry_.Clone(); + } + + public MessageContainingMapCalledEntry Clone() { + return new MessageContainingMapCalledEntry(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + entry_.Freeze(); + } + + public const int EntryFieldNumber = 1; + private static readonly pbc::MapField.Codec _map_entry_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForInt32(16), 10); + private readonly pbc::MapField entry_ = new pbc::MapField(); + public pbc::MapField Entry { + get { return entry_; } + } + + public override bool Equals(object other) { + return Equals(other as MessageContainingMapCalledEntry); + } + + public bool Equals(MessageContainingMapCalledEntry other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (!Entry.Equals(other.Entry)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + hash ^= Entry.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + entry_.WriteTo(output, _map_entry_codec); + } + + public int CalculateSize() { + int size = 0; + size += entry_.CalculateSize(_map_entry_codec); + return size; + } + + public void MergeFrom(MessageContainingMapCalledEntry other) { + if (other == null) { + return; + } + entry_.Add(other.entry_); + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + entry_.AddEntriesFrom(input, _map_entry_codec); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportProto3.cs b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportProto3.cs new file mode 100644 index 00000000..3875a4c3 --- /dev/null +++ b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportProto3.cs @@ -0,0 +1,180 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/unittest_import_proto3.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Google.Protobuf.TestProtos { + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static partial class UnittestImportProto3 { + + #region Static variables + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_import_ImportMessage__FieldAccessorTable; + #endregion + #region Descriptor + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static UnittestImportProto3() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "Cixnb29nbGUvcHJvdG9idWYvdW5pdHRlc3RfaW1wb3J0X3Byb3RvMy5wcm90", + "bxIYcHJvdG9idWZfdW5pdHRlc3RfaW1wb3J0GjNnb29nbGUvcHJvdG9idWYv", + "dW5pdHRlc3RfaW1wb3J0X3B1YmxpY19wcm90bzMucHJvdG8iGgoNSW1wb3J0", + "TWVzc2FnZRIJCgFkGAEgASgFKlkKCkltcG9ydEVudW0SGwoXSU1QT1JUX0VO", + "VU1fVU5TUEVDSUZJRUQQABIOCgpJTVBPUlRfRk9PEAcSDgoKSU1QT1JUX0JB", + "UhAIEg4KCklNUE9SVF9CQVoQCUI8Chhjb20uZ29vZ2xlLnByb3RvYnVmLnRl", + "c3RIAfgBAaoCGkdvb2dsZS5Qcm90b2J1Zi5UZXN0UHJvdG9zUABiBnByb3Rv", + "Mw==")); + descriptor = pbr::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, + new pbr::FileDescriptor[] { + global::Google.Protobuf.TestProtos.UnittestImportPublicProto3.Descriptor, + }); + internal__static_protobuf_unittest_import_ImportMessage__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.ImportMessage), descriptor.MessageTypes[0], + new string[] { "D", }, new string[] { }); + } + #endregion + + } + #region Enums + public enum ImportEnum { + IMPORT_ENUM_UNSPECIFIED = 0, + IMPORT_FOO = 7, + IMPORT_BAR = 8, + IMPORT_BAZ = 9, + } + + #endregion + + #region Messages + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class ImportMessage : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ImportMessage()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "d" }; + private static readonly uint[] _fieldTags = new uint[] { 8 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.UnittestImportProto3.Descriptor.MessageTypes[0]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.TestProtos.UnittestImportProto3.internal__static_protobuf_unittest_import_ImportMessage__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public ImportMessage() { + OnConstruction(); + } + + partial void OnConstruction(); + + public ImportMessage(ImportMessage other) : this() { + d_ = other.d_; + } + + public ImportMessage Clone() { + return new ImportMessage(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public const int DFieldNumber = 1; + private int d_; + public int D { + get { return d_; } + set { + pb::Freezable.CheckMutable(this); + d_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as ImportMessage); + } + + public bool Equals(ImportMessage other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (D != other.D) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (D != 0) hash ^= D.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (D != 0) { + output.WriteRawTag(8); + output.WriteInt32(D); + } + } + + public int CalculateSize() { + int size = 0; + if (D != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(D); + } + return size; + } + + public void MergeFrom(ImportMessage other) { + if (other == null) { + return; + } + if (other.D != 0) { + D = other.D; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 8: { + D = input.ReadInt32(); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportPublicProto3.cs b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportPublicProto3.cs new file mode 100644 index 00000000..048ae5e9 --- /dev/null +++ b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportPublicProto3.cs @@ -0,0 +1,165 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/unittest_import_public_proto3.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Google.Protobuf.TestProtos { + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static partial class UnittestImportPublicProto3 { + + #region Static variables + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_import_PublicImportMessage__FieldAccessorTable; + #endregion + #region Descriptor + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static UnittestImportPublicProto3() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "CjNnb29nbGUvcHJvdG9idWYvdW5pdHRlc3RfaW1wb3J0X3B1YmxpY19wcm90", + "bzMucHJvdG8SGHByb3RvYnVmX3VuaXR0ZXN0X2ltcG9ydCIgChNQdWJsaWNJ", + "bXBvcnRNZXNzYWdlEgkKAWUYASABKAVCNwoYY29tLmdvb2dsZS5wcm90b2J1", + "Zi50ZXN0qgIaR29vZ2xlLlByb3RvYnVmLlRlc3RQcm90b3NiBnByb3RvMw==")); + descriptor = pbr::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, + new pbr::FileDescriptor[] { + }); + internal__static_protobuf_unittest_import_PublicImportMessage__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.PublicImportMessage), descriptor.MessageTypes[0], + new string[] { "E", }, new string[] { }); + } + #endregion + + } + #region Messages + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class PublicImportMessage : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new PublicImportMessage()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "e" }; + private static readonly uint[] _fieldTags = new uint[] { 8 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.UnittestImportPublicProto3.Descriptor.MessageTypes[0]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.TestProtos.UnittestImportPublicProto3.internal__static_protobuf_unittest_import_PublicImportMessage__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public PublicImportMessage() { + OnConstruction(); + } + + partial void OnConstruction(); + + public PublicImportMessage(PublicImportMessage other) : this() { + e_ = other.e_; + } + + public PublicImportMessage Clone() { + return new PublicImportMessage(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public const int EFieldNumber = 1; + private int e_; + public int E { + get { return e_; } + set { + pb::Freezable.CheckMutable(this); + e_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as PublicImportMessage); + } + + public bool Equals(PublicImportMessage other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (E != other.E) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (E != 0) hash ^= E.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (E != 0) { + output.WriteRawTag(8); + output.WriteInt32(E); + } + } + + public int CalculateSize() { + int size = 0; + if (E != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(E); + } + return size; + } + + public void MergeFrom(PublicImportMessage other) { + if (other == null) { + return; + } + if (other.E != 0) { + E = other.E; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 8: { + E = input.ReadInt32(); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/csharp/src/Google.Protobuf.Test/TestProtos/UnittestIssues.cs b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestIssues.cs new file mode 100644 index 00000000..c68c67fb --- /dev/null +++ b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestIssues.cs @@ -0,0 +1,998 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: unittest_issues.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace UnitTest.Issues.TestProtos { + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static partial class UnittestIssues { + + #region Static variables + internal static pbr::FieldAccessorTable internal__static_unittest_issues_Issue307__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_unittest_issues_Issue307_NestedOnce__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_unittest_issues_Issue307_NestedOnce_NestedTwice__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_unittest_issues_NegativeEnumMessage__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_unittest_issues_DeprecatedChild__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_unittest_issues_DeprecatedFieldsMessage__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_unittest_issues_ItemField__FieldAccessorTable; + #endregion + #region Descriptor + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static UnittestIssues() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "ChV1bml0dGVzdF9pc3N1ZXMucHJvdG8SD3VuaXR0ZXN0X2lzc3VlcyInCghJ", + "c3N1ZTMwNxobCgpOZXN0ZWRPbmNlGg0KC05lc3RlZFR3aWNlIrABChNOZWdh", + "dGl2ZUVudW1NZXNzYWdlEiwKBXZhbHVlGAEgASgOMh0udW5pdHRlc3RfaXNz", + "dWVzLk5lZ2F0aXZlRW51bRIxCgZ2YWx1ZXMYAiADKA4yHS51bml0dGVzdF9p", + "c3N1ZXMuTmVnYXRpdmVFbnVtQgIQABI4Cg1wYWNrZWRfdmFsdWVzGAMgAygO", + "Mh0udW5pdHRlc3RfaXNzdWVzLk5lZ2F0aXZlRW51bUICEAEiEQoPRGVwcmVj", + "YXRlZENoaWxkIrkCChdEZXByZWNhdGVkRmllbGRzTWVzc2FnZRIaCg5Qcmlt", + "aXRpdmVWYWx1ZRgBIAEoBUICGAESGgoOUHJpbWl0aXZlQXJyYXkYAiADKAVC", + "AhgBEjoKDE1lc3NhZ2VWYWx1ZRgDIAEoCzIgLnVuaXR0ZXN0X2lzc3Vlcy5E", + "ZXByZWNhdGVkQ2hpbGRCAhgBEjoKDE1lc3NhZ2VBcnJheRgEIAMoCzIgLnVu", + "aXR0ZXN0X2lzc3Vlcy5EZXByZWNhdGVkQ2hpbGRCAhgBEjYKCUVudW1WYWx1", + "ZRgFIAEoDjIfLnVuaXR0ZXN0X2lzc3Vlcy5EZXByZWNhdGVkRW51bUICGAES", + "NgoJRW51bUFycmF5GAYgAygOMh8udW5pdHRlc3RfaXNzdWVzLkRlcHJlY2F0", + "ZWRFbnVtQgIYASIZCglJdGVtRmllbGQSDAoEaXRlbRgBIAEoBSpVCgxOZWdh", + "dGl2ZUVudW0SFgoSTkVHQVRJVkVfRU5VTV9aRVJPEAASFgoJRml2ZUJlbG93", + "EPv//////////wESFQoITWludXNPbmUQ////////////ASouCg5EZXByZWNh", + "dGVkRW51bRITCg9ERVBSRUNBVEVEX1pFUk8QABIHCgNvbmUQAUIfSAGqAhpV", + "bml0VGVzdC5Jc3N1ZXMuVGVzdFByb3Rvc2IGcHJvdG8z")); + descriptor = pbr::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, + new pbr::FileDescriptor[] { + }); + internal__static_unittest_issues_Issue307__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::UnitTest.Issues.TestProtos.Issue307), descriptor.MessageTypes[0], + new string[] { }, new string[] { }); + internal__static_unittest_issues_Issue307_NestedOnce__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::UnitTest.Issues.TestProtos.Issue307.Types.NestedOnce), descriptor.MessageTypes[0].NestedTypes[0], + new string[] { }, new string[] { }); + internal__static_unittest_issues_Issue307_NestedOnce_NestedTwice__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::UnitTest.Issues.TestProtos.Issue307.Types.NestedOnce.Types.NestedTwice), descriptor.MessageTypes[0].NestedTypes[0].NestedTypes[0], + new string[] { }, new string[] { }); + internal__static_unittest_issues_NegativeEnumMessage__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::UnitTest.Issues.TestProtos.NegativeEnumMessage), descriptor.MessageTypes[1], + new string[] { "Value", "Values", "PackedValues", }, new string[] { }); + internal__static_unittest_issues_DeprecatedChild__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::UnitTest.Issues.TestProtos.DeprecatedChild), descriptor.MessageTypes[2], + new string[] { }, new string[] { }); + internal__static_unittest_issues_DeprecatedFieldsMessage__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::UnitTest.Issues.TestProtos.DeprecatedFieldsMessage), descriptor.MessageTypes[3], + new string[] { "PrimitiveValue", "PrimitiveArray", "MessageValue", "MessageArray", "EnumValue", "EnumArray", }, new string[] { }); + internal__static_unittest_issues_ItemField__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::UnitTest.Issues.TestProtos.ItemField), descriptor.MessageTypes[4], + new string[] { "Item", }, new string[] { }); + } + #endregion + + } + #region Enums + public enum NegativeEnum { + NEGATIVE_ENUM_ZERO = 0, + FiveBelow = -5, + MinusOne = -1, + } + + public enum DeprecatedEnum { + DEPRECATED_ZERO = 0, + one = 1, + } + + #endregion + + #region Messages + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class Issue307 : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Issue307()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { }; + private static readonly uint[] _fieldTags = new uint[] { }; + public static pbr::MessageDescriptor Descriptor { + get { return global::UnitTest.Issues.TestProtos.UnittestIssues.Descriptor.MessageTypes[0]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::UnitTest.Issues.TestProtos.UnittestIssues.internal__static_unittest_issues_Issue307__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public Issue307() { + OnConstruction(); + } + + partial void OnConstruction(); + + public Issue307(Issue307 other) : this() { + } + + public Issue307 Clone() { + return new Issue307(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public override bool Equals(object other) { + return Equals(other as Issue307); + } + + public bool Equals(Issue307 other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + return true; + } + + public override int GetHashCode() { + int hash = 1; + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + } + + public int CalculateSize() { + int size = 0; + return size; + } + + public void MergeFrom(Issue307 other) { + if (other == null) { + return; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + } + } + } + + #region Nested types + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static partial class Types { + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class NestedOnce : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedOnce()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { }; + private static readonly uint[] _fieldTags = new uint[] { }; + public static pbr::MessageDescriptor Descriptor { + get { return global::UnitTest.Issues.TestProtos.Issue307.Descriptor.NestedTypes[0]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::UnitTest.Issues.TestProtos.UnittestIssues.internal__static_unittest_issues_Issue307_NestedOnce__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public NestedOnce() { + OnConstruction(); + } + + partial void OnConstruction(); + + public NestedOnce(NestedOnce other) : this() { + } + + public NestedOnce Clone() { + return new NestedOnce(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public override bool Equals(object other) { + return Equals(other as NestedOnce); + } + + public bool Equals(NestedOnce other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + return true; + } + + public override int GetHashCode() { + int hash = 1; + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + } + + public int CalculateSize() { + int size = 0; + return size; + } + + public void MergeFrom(NestedOnce other) { + if (other == null) { + return; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + } + } + } + + #region Nested types + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static partial class Types { + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class NestedTwice : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedTwice()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { }; + private static readonly uint[] _fieldTags = new uint[] { }; + public static pbr::MessageDescriptor Descriptor { + get { return global::UnitTest.Issues.TestProtos.Issue307.Types.NestedOnce.Descriptor.NestedTypes[0]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::UnitTest.Issues.TestProtos.UnittestIssues.internal__static_unittest_issues_Issue307_NestedOnce_NestedTwice__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public NestedTwice() { + OnConstruction(); + } + + partial void OnConstruction(); + + public NestedTwice(NestedTwice other) : this() { + } + + public NestedTwice Clone() { + return new NestedTwice(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public override bool Equals(object other) { + return Equals(other as NestedTwice); + } + + public bool Equals(NestedTwice other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + return true; + } + + public override int GetHashCode() { + int hash = 1; + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + } + + public int CalculateSize() { + int size = 0; + return size; + } + + public void MergeFrom(NestedTwice other) { + if (other == null) { + return; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + } + } + } + + } + + } + #endregion + + } + + } + #endregion + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class NegativeEnumMessage : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NegativeEnumMessage()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "packed_values", "value", "values" }; + private static readonly uint[] _fieldTags = new uint[] { 26, 8, 16 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::UnitTest.Issues.TestProtos.UnittestIssues.Descriptor.MessageTypes[1]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::UnitTest.Issues.TestProtos.UnittestIssues.internal__static_unittest_issues_NegativeEnumMessage__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public NegativeEnumMessage() { + OnConstruction(); + } + + partial void OnConstruction(); + + public NegativeEnumMessage(NegativeEnumMessage other) : this() { + value_ = other.value_; + values_ = other.values_.Clone(); + packedValues_ = other.packedValues_.Clone(); + } + + public NegativeEnumMessage Clone() { + return new NegativeEnumMessage(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + values_.Freeze(); + packedValues_.Freeze(); + } + + public const int ValueFieldNumber = 1; + private global::UnitTest.Issues.TestProtos.NegativeEnum value_ = global::UnitTest.Issues.TestProtos.NegativeEnum.NEGATIVE_ENUM_ZERO; + public global::UnitTest.Issues.TestProtos.NegativeEnum Value { + get { return value_; } + set { + pb::Freezable.CheckMutable(this); + value_ = value; + } + } + + public const int ValuesFieldNumber = 2; + private static readonly pb::FieldCodec _repeated_values_codec + = pb::FieldCodec.ForEnum(16, x => (int) x, x => (global::UnitTest.Issues.TestProtos.NegativeEnum) x);private readonly pbc::RepeatedField values_ = new pbc::RepeatedField(); + public pbc::RepeatedField Values { + get { return values_; } + } + + public const int PackedValuesFieldNumber = 3; + private static readonly pb::FieldCodec _repeated_packedValues_codec + = pb::FieldCodec.ForEnum(26, x => (int) x, x => (global::UnitTest.Issues.TestProtos.NegativeEnum) x);private readonly pbc::RepeatedField packedValues_ = new pbc::RepeatedField(); + public pbc::RepeatedField PackedValues { + get { return packedValues_; } + } + + public override bool Equals(object other) { + return Equals(other as NegativeEnumMessage); + } + + public bool Equals(NegativeEnumMessage other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Value != other.Value) return false; + if(!values_.Equals(other.values_)) return false; + if(!packedValues_.Equals(other.packedValues_)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Value != global::UnitTest.Issues.TestProtos.NegativeEnum.NEGATIVE_ENUM_ZERO) hash ^= Value.GetHashCode(); + hash ^= values_.GetHashCode(); + hash ^= packedValues_.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Value != global::UnitTest.Issues.TestProtos.NegativeEnum.NEGATIVE_ENUM_ZERO) { + output.WriteRawTag(8); + output.WriteEnum((int) Value); + } + values_.WriteTo(output, _repeated_values_codec); + packedValues_.WriteTo(output, _repeated_packedValues_codec); + } + + public int CalculateSize() { + int size = 0; + if (Value != global::UnitTest.Issues.TestProtos.NegativeEnum.NEGATIVE_ENUM_ZERO) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Value); + } + size += values_.CalculateSize(_repeated_values_codec); + size += packedValues_.CalculateSize(_repeated_packedValues_codec); + return size; + } + + public void MergeFrom(NegativeEnumMessage other) { + if (other == null) { + return; + } + if (other.Value != global::UnitTest.Issues.TestProtos.NegativeEnum.NEGATIVE_ENUM_ZERO) { + Value = other.Value; + } + values_.Add(other.values_); + packedValues_.Add(other.packedValues_); + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 8: { + value_ = (global::UnitTest.Issues.TestProtos.NegativeEnum) input.ReadEnum(); + break; + } + case 18: + case 16: { + values_.AddEntriesFrom(input, _repeated_values_codec); + break; + } + case 26: + case 24: { + packedValues_.AddEntriesFrom(input, _repeated_packedValues_codec); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class DeprecatedChild : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new DeprecatedChild()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { }; + private static readonly uint[] _fieldTags = new uint[] { }; + public static pbr::MessageDescriptor Descriptor { + get { return global::UnitTest.Issues.TestProtos.UnittestIssues.Descriptor.MessageTypes[2]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::UnitTest.Issues.TestProtos.UnittestIssues.internal__static_unittest_issues_DeprecatedChild__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public DeprecatedChild() { + OnConstruction(); + } + + partial void OnConstruction(); + + public DeprecatedChild(DeprecatedChild other) : this() { + } + + public DeprecatedChild Clone() { + return new DeprecatedChild(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public override bool Equals(object other) { + return Equals(other as DeprecatedChild); + } + + public bool Equals(DeprecatedChild other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + return true; + } + + public override int GetHashCode() { + int hash = 1; + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + } + + public int CalculateSize() { + int size = 0; + return size; + } + + public void MergeFrom(DeprecatedChild other) { + if (other == null) { + return; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class DeprecatedFieldsMessage : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new DeprecatedFieldsMessage()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "EnumArray", "EnumValue", "MessageArray", "MessageValue", "PrimitiveArray", "PrimitiveValue" }; + private static readonly uint[] _fieldTags = new uint[] { 50, 40, 34, 26, 18, 8 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::UnitTest.Issues.TestProtos.UnittestIssues.Descriptor.MessageTypes[3]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::UnitTest.Issues.TestProtos.UnittestIssues.internal__static_unittest_issues_DeprecatedFieldsMessage__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public DeprecatedFieldsMessage() { + OnConstruction(); + } + + partial void OnConstruction(); + + public DeprecatedFieldsMessage(DeprecatedFieldsMessage other) : this() { + primitiveValue_ = other.primitiveValue_; + primitiveArray_ = other.primitiveArray_.Clone(); + MessageValue = other.messageValue_ != null ? other.MessageValue.Clone() : null; + messageArray_ = other.messageArray_.Clone(); + enumValue_ = other.enumValue_; + enumArray_ = other.enumArray_.Clone(); + } + + public DeprecatedFieldsMessage Clone() { + return new DeprecatedFieldsMessage(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + primitiveArray_.Freeze(); + if (messageValue_ != null) MessageValue.Freeze(); + messageArray_.Freeze(); + enumArray_.Freeze(); + } + + public const int PrimitiveValueFieldNumber = 1; + private int primitiveValue_; + [global::System.ObsoleteAttribute()] + public int PrimitiveValue { + get { return primitiveValue_; } + set { + pb::Freezable.CheckMutable(this); + primitiveValue_ = value; + } + } + + public const int PrimitiveArrayFieldNumber = 2; + private static readonly pb::FieldCodec _repeated_primitiveArray_codec + = pb::FieldCodec.ForInt32(18); + private readonly pbc::RepeatedField primitiveArray_ = new pbc::RepeatedField(); + [global::System.ObsoleteAttribute()] + public pbc::RepeatedField PrimitiveArray { + get { return primitiveArray_; } + } + + public const int MessageValueFieldNumber = 3; + private global::UnitTest.Issues.TestProtos.DeprecatedChild messageValue_; + [global::System.ObsoleteAttribute()] + public global::UnitTest.Issues.TestProtos.DeprecatedChild MessageValue { + get { return messageValue_; } + set { + pb::Freezable.CheckMutable(this); + messageValue_ = value; + } + } + + public const int MessageArrayFieldNumber = 4; + private static readonly pb::FieldCodec _repeated_messageArray_codec + = pb::FieldCodec.ForMessage(34, global::UnitTest.Issues.TestProtos.DeprecatedChild.Parser); + private readonly pbc::RepeatedField messageArray_ = new pbc::RepeatedField(); + [global::System.ObsoleteAttribute()] + public pbc::RepeatedField MessageArray { + get { return messageArray_; } + } + + public const int EnumValueFieldNumber = 5; + private global::UnitTest.Issues.TestProtos.DeprecatedEnum enumValue_ = global::UnitTest.Issues.TestProtos.DeprecatedEnum.DEPRECATED_ZERO; + [global::System.ObsoleteAttribute()] + public global::UnitTest.Issues.TestProtos.DeprecatedEnum EnumValue { + get { return enumValue_; } + set { + pb::Freezable.CheckMutable(this); + enumValue_ = value; + } + } + + public const int EnumArrayFieldNumber = 6; + private static readonly pb::FieldCodec _repeated_enumArray_codec + = pb::FieldCodec.ForEnum(50, x => (int) x, x => (global::UnitTest.Issues.TestProtos.DeprecatedEnum) x);private readonly pbc::RepeatedField enumArray_ = new pbc::RepeatedField(); + [global::System.ObsoleteAttribute()] + public pbc::RepeatedField EnumArray { + get { return enumArray_; } + } + + public override bool Equals(object other) { + return Equals(other as DeprecatedFieldsMessage); + } + + public bool Equals(DeprecatedFieldsMessage other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (PrimitiveValue != other.PrimitiveValue) return false; + if(!primitiveArray_.Equals(other.primitiveArray_)) return false; + if (!object.Equals(MessageValue, other.MessageValue)) return false; + if(!messageArray_.Equals(other.messageArray_)) return false; + if (EnumValue != other.EnumValue) return false; + if(!enumArray_.Equals(other.enumArray_)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (PrimitiveValue != 0) hash ^= PrimitiveValue.GetHashCode(); + hash ^= primitiveArray_.GetHashCode(); + if (messageValue_ != null) hash ^= MessageValue.GetHashCode(); + hash ^= messageArray_.GetHashCode(); + if (EnumValue != global::UnitTest.Issues.TestProtos.DeprecatedEnum.DEPRECATED_ZERO) hash ^= EnumValue.GetHashCode(); + hash ^= enumArray_.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (PrimitiveValue != 0) { + output.WriteRawTag(8); + output.WriteInt32(PrimitiveValue); + } + primitiveArray_.WriteTo(output, _repeated_primitiveArray_codec); + if (messageValue_ != null) { + output.WriteRawTag(26); + output.WriteMessage(MessageValue); + } + messageArray_.WriteTo(output, _repeated_messageArray_codec); + if (EnumValue != global::UnitTest.Issues.TestProtos.DeprecatedEnum.DEPRECATED_ZERO) { + output.WriteRawTag(40); + output.WriteEnum((int) EnumValue); + } + enumArray_.WriteTo(output, _repeated_enumArray_codec); + } + + public int CalculateSize() { + int size = 0; + if (PrimitiveValue != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(PrimitiveValue); + } + size += primitiveArray_.CalculateSize(_repeated_primitiveArray_codec); + if (messageValue_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(MessageValue); + } + size += messageArray_.CalculateSize(_repeated_messageArray_codec); + if (EnumValue != global::UnitTest.Issues.TestProtos.DeprecatedEnum.DEPRECATED_ZERO) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) EnumValue); + } + size += enumArray_.CalculateSize(_repeated_enumArray_codec); + return size; + } + + public void MergeFrom(DeprecatedFieldsMessage other) { + if (other == null) { + return; + } + if (other.PrimitiveValue != 0) { + PrimitiveValue = other.PrimitiveValue; + } + primitiveArray_.Add(other.primitiveArray_); + if (other.messageValue_ != null) { + if (messageValue_ == null) { + messageValue_ = new global::UnitTest.Issues.TestProtos.DeprecatedChild(); + } + MessageValue.MergeFrom(other.MessageValue); + } + messageArray_.Add(other.messageArray_); + if (other.EnumValue != global::UnitTest.Issues.TestProtos.DeprecatedEnum.DEPRECATED_ZERO) { + EnumValue = other.EnumValue; + } + enumArray_.Add(other.enumArray_); + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 8: { + PrimitiveValue = input.ReadInt32(); + break; + } + case 18: + case 16: { + primitiveArray_.AddEntriesFrom(input, _repeated_primitiveArray_codec); + break; + } + case 26: { + if (messageValue_ == null) { + messageValue_ = new global::UnitTest.Issues.TestProtos.DeprecatedChild(); + } + input.ReadMessage(messageValue_); + break; + } + case 34: { + messageArray_.AddEntriesFrom(input, _repeated_messageArray_codec); + break; + } + case 40: { + enumValue_ = (global::UnitTest.Issues.TestProtos.DeprecatedEnum) input.ReadEnum(); + break; + } + case 50: + case 48: { + enumArray_.AddEntriesFrom(input, _repeated_enumArray_codec); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class ItemField : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ItemField()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "item" }; + private static readonly uint[] _fieldTags = new uint[] { 8 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::UnitTest.Issues.TestProtos.UnittestIssues.Descriptor.MessageTypes[4]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::UnitTest.Issues.TestProtos.UnittestIssues.internal__static_unittest_issues_ItemField__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public ItemField() { + OnConstruction(); + } + + partial void OnConstruction(); + + public ItemField(ItemField other) : this() { + item_ = other.item_; + } + + public ItemField Clone() { + return new ItemField(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public const int ItemFieldNumber = 1; + private int item_; + public int Item { + get { return item_; } + set { + pb::Freezable.CheckMutable(this); + item_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as ItemField); + } + + public bool Equals(ItemField other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Item != other.Item) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Item != 0) hash ^= Item.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Item != 0) { + output.WriteRawTag(8); + output.WriteInt32(Item); + } + } + + public int CalculateSize() { + int size = 0; + if (Item != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Item); + } + return size; + } + + public void MergeFrom(ItemField other) { + if (other == null) { + return; + } + if (other.Item != 0) { + Item = other.Item; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 8: { + Item = input.ReadInt32(); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/csharp/src/Google.Protobuf.Test/TestProtos/UnittestProto3.cs b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestProto3.cs new file mode 100644 index 00000000..67c42708 --- /dev/null +++ b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestProto3.cs @@ -0,0 +1,6633 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/unittest_proto3.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Google.Protobuf.TestProtos { + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static partial class UnittestProto3 { + + #region Static variables + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_TestAllTypes__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_TestAllTypes_NestedMessage__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_NestedTestAllTypes__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_TestDeprecatedFields__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_ForeignMessage__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_TestReservedFields__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_TestForeignNested__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_TestReallyLargeTagNumber__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_TestRecursiveMessage__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_TestMutualRecursionA__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_TestMutualRecursionB__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_TestCamelCaseFieldNames__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_TestFieldOrderings__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_TestFieldOrderings_NestedMessage__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_SparseEnumMessage__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_OneString__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_MoreString__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_OneBytes__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_MoreBytes__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_Int32Message__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_Uint32Message__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_Int64Message__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_Uint64Message__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_BoolMessage__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_TestOneof__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_TestPackedTypes__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_TestUnpackedTypes__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_TestRepeatedScalarDifferentTagSizes__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_TestCommentInjectionMessage__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_FooRequest__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_FooResponse__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_FooClientMessage__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_FooServerMessage__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_BarRequest__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_BarResponse__FieldAccessorTable; + #endregion + #region Descriptor + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static UnittestProto3() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "CiVnb29nbGUvcHJvdG9idWYvdW5pdHRlc3RfcHJvdG8zLnByb3RvEhFwcm90", + "b2J1Zl91bml0dGVzdBosZ29vZ2xlL3Byb3RvYnVmL3VuaXR0ZXN0X2ltcG9y", + "dF9wcm90bzMucHJvdG8i8A8KDFRlc3RBbGxUeXBlcxIUCgxzaW5nbGVfaW50", + "MzIYASABKAUSFAoMc2luZ2xlX2ludDY0GAIgASgDEhUKDXNpbmdsZV91aW50", + "MzIYAyABKA0SFQoNc2luZ2xlX3VpbnQ2NBgEIAEoBBIVCg1zaW5nbGVfc2lu", + "dDMyGAUgASgREhUKDXNpbmdsZV9zaW50NjQYBiABKBISFgoOc2luZ2xlX2Zp", + "eGVkMzIYByABKAcSFgoOc2luZ2xlX2ZpeGVkNjQYCCABKAYSFwoPc2luZ2xl", + "X3NmaXhlZDMyGAkgASgPEhcKD3NpbmdsZV9zZml4ZWQ2NBgKIAEoEBIUCgxz", + "aW5nbGVfZmxvYXQYCyABKAISFQoNc2luZ2xlX2RvdWJsZRgMIAEoARITCgtz", + "aW5nbGVfYm9vbBgNIAEoCBIVCg1zaW5nbGVfc3RyaW5nGA4gASgJEhQKDHNp", + "bmdsZV9ieXRlcxgPIAEoDBJMChVzaW5nbGVfbmVzdGVkX21lc3NhZ2UYEiAB", + "KAsyLS5wcm90b2J1Zl91bml0dGVzdC5UZXN0QWxsVHlwZXMuTmVzdGVkTWVz", + "c2FnZRJBChZzaW5nbGVfZm9yZWlnbl9tZXNzYWdlGBMgASgLMiEucHJvdG9i", + "dWZfdW5pdHRlc3QuRm9yZWlnbk1lc3NhZ2USRgoVc2luZ2xlX2ltcG9ydF9t", + "ZXNzYWdlGBQgASgLMicucHJvdG9idWZfdW5pdHRlc3RfaW1wb3J0LkltcG9y", + "dE1lc3NhZ2USRgoSc2luZ2xlX25lc3RlZF9lbnVtGBUgASgOMioucHJvdG9i", + "dWZfdW5pdHRlc3QuVGVzdEFsbFR5cGVzLk5lc3RlZEVudW0SOwoTc2luZ2xl", + "X2ZvcmVpZ25fZW51bRgWIAEoDjIeLnByb3RvYnVmX3VuaXR0ZXN0LkZvcmVp", + "Z25FbnVtEkAKEnNpbmdsZV9pbXBvcnRfZW51bRgXIAEoDjIkLnByb3RvYnVm", + "X3VuaXR0ZXN0X2ltcG9ydC5JbXBvcnRFbnVtElMKHHNpbmdsZV9wdWJsaWNf", + "aW1wb3J0X21lc3NhZ2UYGiABKAsyLS5wcm90b2J1Zl91bml0dGVzdF9pbXBv", + "cnQuUHVibGljSW1wb3J0TWVzc2FnZRIWCg5yZXBlYXRlZF9pbnQzMhgfIAMo", + "BRIWCg5yZXBlYXRlZF9pbnQ2NBggIAMoAxIXCg9yZXBlYXRlZF91aW50MzIY", + "ISADKA0SFwoPcmVwZWF0ZWRfdWludDY0GCIgAygEEhcKD3JlcGVhdGVkX3Np", + "bnQzMhgjIAMoERIXCg9yZXBlYXRlZF9zaW50NjQYJCADKBISGAoQcmVwZWF0", + "ZWRfZml4ZWQzMhglIAMoBxIYChByZXBlYXRlZF9maXhlZDY0GCYgAygGEhkK", + "EXJlcGVhdGVkX3NmaXhlZDMyGCcgAygPEhkKEXJlcGVhdGVkX3NmaXhlZDY0", + "GCggAygQEhYKDnJlcGVhdGVkX2Zsb2F0GCkgAygCEhcKD3JlcGVhdGVkX2Rv", + "dWJsZRgqIAMoARIVCg1yZXBlYXRlZF9ib29sGCsgAygIEhcKD3JlcGVhdGVk", + "X3N0cmluZxgsIAMoCRIWCg5yZXBlYXRlZF9ieXRlcxgtIAMoDBJOChdyZXBl", + "YXRlZF9uZXN0ZWRfbWVzc2FnZRgwIAMoCzItLnByb3RvYnVmX3VuaXR0ZXN0", + "LlRlc3RBbGxUeXBlcy5OZXN0ZWRNZXNzYWdlEkMKGHJlcGVhdGVkX2ZvcmVp", + "Z25fbWVzc2FnZRgxIAMoCzIhLnByb3RvYnVmX3VuaXR0ZXN0LkZvcmVpZ25N", + "ZXNzYWdlEkgKF3JlcGVhdGVkX2ltcG9ydF9tZXNzYWdlGDIgAygLMicucHJv", + "dG9idWZfdW5pdHRlc3RfaW1wb3J0LkltcG9ydE1lc3NhZ2USSAoUcmVwZWF0", + "ZWRfbmVzdGVkX2VudW0YMyADKA4yKi5wcm90b2J1Zl91bml0dGVzdC5UZXN0", + "QWxsVHlwZXMuTmVzdGVkRW51bRI9ChVyZXBlYXRlZF9mb3JlaWduX2VudW0Y", + "NCADKA4yHi5wcm90b2J1Zl91bml0dGVzdC5Gb3JlaWduRW51bRJCChRyZXBl", + "YXRlZF9pbXBvcnRfZW51bRg1IAMoDjIkLnByb3RvYnVmX3VuaXR0ZXN0X2lt", + "cG9ydC5JbXBvcnRFbnVtElUKHnJlcGVhdGVkX3B1YmxpY19pbXBvcnRfbWVz", + "c2FnZRg2IAMoCzItLnByb3RvYnVmX3VuaXR0ZXN0X2ltcG9ydC5QdWJsaWNJ", + "bXBvcnRNZXNzYWdlEhYKDG9uZW9mX3VpbnQzMhhvIAEoDUgAEk0KFG9uZW9m", + "X25lc3RlZF9tZXNzYWdlGHAgASgLMi0ucHJvdG9idWZfdW5pdHRlc3QuVGVz", + "dEFsbFR5cGVzLk5lc3RlZE1lc3NhZ2VIABIWCgxvbmVvZl9zdHJpbmcYcSAB", + "KAlIABIVCgtvbmVvZl9ieXRlcxhyIAEoDEgAGhsKDU5lc3RlZE1lc3NhZ2US", + "CgoCYmIYASABKAUiVgoKTmVzdGVkRW51bRIbChdORVNURURfRU5VTV9VTlNQ", + "RUNJRklFRBAAEgcKA0ZPTxABEgcKA0JBUhACEgcKA0JBWhADEhAKA05FRxD/", + "//////////8BQg0KC29uZW9mX2ZpZWxkIrsBChJOZXN0ZWRUZXN0QWxsVHlw", + "ZXMSNAoFY2hpbGQYASABKAsyJS5wcm90b2J1Zl91bml0dGVzdC5OZXN0ZWRU", + "ZXN0QWxsVHlwZXMSMAoHcGF5bG9hZBgCIAEoCzIfLnByb3RvYnVmX3VuaXR0", + "ZXN0LlRlc3RBbGxUeXBlcxI9Cg5yZXBlYXRlZF9jaGlsZBgDIAMoCzIlLnBy", + "b3RvYnVmX3VuaXR0ZXN0Lk5lc3RlZFRlc3RBbGxUeXBlcyI0ChRUZXN0RGVw", + "cmVjYXRlZEZpZWxkcxIcChBkZXByZWNhdGVkX2ludDMyGAEgASgFQgIYASIb", + "Cg5Gb3JlaWduTWVzc2FnZRIJCgFjGAEgASgFIjAKElRlc3RSZXNlcnZlZEZp", + "ZWxkc0oECAIQA0oECA8QEEoECAkQDFIDYmFyUgNiYXoiWgoRVGVzdEZvcmVp", + "Z25OZXN0ZWQSRQoOZm9yZWlnbl9uZXN0ZWQYASABKAsyLS5wcm90b2J1Zl91", + "bml0dGVzdC5UZXN0QWxsVHlwZXMuTmVzdGVkTWVzc2FnZSI0ChhUZXN0UmVh", + "bGx5TGFyZ2VUYWdOdW1iZXISCQoBYRgBIAEoBRINCgJiYhj///9/IAEoBSJV", + "ChRUZXN0UmVjdXJzaXZlTWVzc2FnZRIyCgFhGAEgASgLMicucHJvdG9idWZf", + "dW5pdHRlc3QuVGVzdFJlY3Vyc2l2ZU1lc3NhZ2USCQoBaRgCIAEoBSJLChRU", + "ZXN0TXV0dWFsUmVjdXJzaW9uQRIzCgJiYhgBIAEoCzInLnByb3RvYnVmX3Vu", + "aXR0ZXN0LlRlc3RNdXR1YWxSZWN1cnNpb25CImIKFFRlc3RNdXR1YWxSZWN1", + "cnNpb25CEjIKAWEYASABKAsyJy5wcm90b2J1Zl91bml0dGVzdC5UZXN0TXV0", + "dWFsUmVjdXJzaW9uQRIWCg5vcHRpb25hbF9pbnQzMhgCIAEoBSLrAgoXVGVz", + "dENhbWVsQ2FzZUZpZWxkTmFtZXMSFgoOUHJpbWl0aXZlRmllbGQYASABKAUS", + "EwoLU3RyaW5nRmllbGQYAiABKAkSMQoJRW51bUZpZWxkGAMgASgOMh4ucHJv", + "dG9idWZfdW5pdHRlc3QuRm9yZWlnbkVudW0SNwoMTWVzc2FnZUZpZWxkGAQg", + "ASgLMiEucHJvdG9idWZfdW5pdHRlc3QuRm9yZWlnbk1lc3NhZ2USHgoWUmVw", + "ZWF0ZWRQcmltaXRpdmVGaWVsZBgHIAMoBRIbChNSZXBlYXRlZFN0cmluZ0Zp", + "ZWxkGAggAygJEjkKEVJlcGVhdGVkRW51bUZpZWxkGAkgAygOMh4ucHJvdG9i", + "dWZfdW5pdHRlc3QuRm9yZWlnbkVudW0SPwoUUmVwZWF0ZWRNZXNzYWdlRmll", + "bGQYCiADKAsyIS5wcm90b2J1Zl91bml0dGVzdC5Gb3JlaWduTWVzc2FnZSLH", + "AQoSVGVzdEZpZWxkT3JkZXJpbmdzEhEKCW15X3N0cmluZxgLIAEoCRIOCgZt", + "eV9pbnQYASABKAMSEAoIbXlfZmxvYXQYZSABKAISUwoVc2luZ2xlX25lc3Rl", + "ZF9tZXNzYWdlGMgBIAEoCzIzLnByb3RvYnVmX3VuaXR0ZXN0LlRlc3RGaWVs", + "ZE9yZGVyaW5ncy5OZXN0ZWRNZXNzYWdlGicKDU5lc3RlZE1lc3NhZ2USCgoC", + "b28YAiABKAMSCgoCYmIYASABKAUiSwoRU3BhcnNlRW51bU1lc3NhZ2USNgoL", + "c3BhcnNlX2VudW0YASABKA4yIS5wcm90b2J1Zl91bml0dGVzdC5UZXN0U3Bh", + "cnNlRW51bSIZCglPbmVTdHJpbmcSDAoEZGF0YRgBIAEoCSIaCgpNb3JlU3Ry", + "aW5nEgwKBGRhdGEYASADKAkiGAoIT25lQnl0ZXMSDAoEZGF0YRgBIAEoDCIZ", + "CglNb3JlQnl0ZXMSDAoEZGF0YRgBIAEoDCIcCgxJbnQzMk1lc3NhZ2USDAoE", + "ZGF0YRgBIAEoBSIdCg1VaW50MzJNZXNzYWdlEgwKBGRhdGEYASABKA0iHAoM", + "SW50NjRNZXNzYWdlEgwKBGRhdGEYASABKAMiHQoNVWludDY0TWVzc2FnZRIM", + "CgRkYXRhGAEgASgEIhsKC0Jvb2xNZXNzYWdlEgwKBGRhdGEYASABKAgicwoJ", + "VGVzdE9uZW9mEhEKB2Zvb19pbnQYASABKAVIABIUCgpmb29fc3RyaW5nGAIg", + "ASgJSAASNgoLZm9vX21lc3NhZ2UYAyABKAsyHy5wcm90b2J1Zl91bml0dGVz", + "dC5UZXN0QWxsVHlwZXNIAEIFCgNmb28iqgMKD1Rlc3RQYWNrZWRUeXBlcxIY", + "CgxwYWNrZWRfaW50MzIYWiADKAVCAhABEhgKDHBhY2tlZF9pbnQ2NBhbIAMo", + "A0ICEAESGQoNcGFja2VkX3VpbnQzMhhcIAMoDUICEAESGQoNcGFja2VkX3Vp", + "bnQ2NBhdIAMoBEICEAESGQoNcGFja2VkX3NpbnQzMhheIAMoEUICEAESGQoN", + "cGFja2VkX3NpbnQ2NBhfIAMoEkICEAESGgoOcGFja2VkX2ZpeGVkMzIYYCAD", + "KAdCAhABEhoKDnBhY2tlZF9maXhlZDY0GGEgAygGQgIQARIbCg9wYWNrZWRf", + "c2ZpeGVkMzIYYiADKA9CAhABEhsKD3BhY2tlZF9zZml4ZWQ2NBhjIAMoEEIC", + "EAESGAoMcGFja2VkX2Zsb2F0GGQgAygCQgIQARIZCg1wYWNrZWRfZG91Ymxl", + "GGUgAygBQgIQARIXCgtwYWNrZWRfYm9vbBhmIAMoCEICEAESNwoLcGFja2Vk", + "X2VudW0YZyADKA4yHi5wcm90b2J1Zl91bml0dGVzdC5Gb3JlaWduRW51bUIC", + "EAEiyAMKEVRlc3RVbnBhY2tlZFR5cGVzEhoKDnVucGFja2VkX2ludDMyGFog", + "AygFQgIQABIaCg51bnBhY2tlZF9pbnQ2NBhbIAMoA0ICEAASGwoPdW5wYWNr", + "ZWRfdWludDMyGFwgAygNQgIQABIbCg91bnBhY2tlZF91aW50NjQYXSADKARC", + "AhAAEhsKD3VucGFja2VkX3NpbnQzMhheIAMoEUICEAASGwoPdW5wYWNrZWRf", + "c2ludDY0GF8gAygSQgIQABIcChB1bnBhY2tlZF9maXhlZDMyGGAgAygHQgIQ", + "ABIcChB1bnBhY2tlZF9maXhlZDY0GGEgAygGQgIQABIdChF1bnBhY2tlZF9z", + "Zml4ZWQzMhhiIAMoD0ICEAASHQoRdW5wYWNrZWRfc2ZpeGVkNjQYYyADKBBC", + "AhAAEhoKDnVucGFja2VkX2Zsb2F0GGQgAygCQgIQABIbCg91bnBhY2tlZF9k", + "b3VibGUYZSADKAFCAhAAEhkKDXVucGFja2VkX2Jvb2wYZiADKAhCAhAAEjkK", + "DXVucGFja2VkX2VudW0YZyADKA4yHi5wcm90b2J1Zl91bml0dGVzdC5Gb3Jl", + "aWduRW51bUICEAAiwAEKI1Rlc3RSZXBlYXRlZFNjYWxhckRpZmZlcmVudFRh", + "Z1NpemVzEhgKEHJlcGVhdGVkX2ZpeGVkMzIYDCADKAcSFgoOcmVwZWF0ZWRf", + "aW50MzIYDSADKAUSGQoQcmVwZWF0ZWRfZml4ZWQ2NBj+DyADKAYSFwoOcmVw", + "ZWF0ZWRfaW50NjQY/w8gAygDEhgKDnJlcGVhdGVkX2Zsb2F0GP7/DyADKAIS", + "GQoPcmVwZWF0ZWRfdWludDY0GP//DyADKAQiKAobVGVzdENvbW1lbnRJbmpl", + "Y3Rpb25NZXNzYWdlEgkKAWEYASABKAkiDAoKRm9vUmVxdWVzdCINCgtGb29S", + "ZXNwb25zZSISChBGb29DbGllbnRNZXNzYWdlIhIKEEZvb1NlcnZlck1lc3Nh", + "Z2UiDAoKQmFyUmVxdWVzdCINCgtCYXJSZXNwb25zZSpZCgtGb3JlaWduRW51", + "bRIXChNGT1JFSUdOX1VOU1BFQ0lGSUVEEAASDwoLRk9SRUlHTl9GT08QBBIP", + "CgtGT1JFSUdOX0JBUhAFEg8KC0ZPUkVJR05fQkFaEAYqdQoUVGVzdEVudW1X", + "aXRoRHVwVmFsdWUSKAokVEVTVF9FTlVNX1dJVEhfRFVQX1ZBTFVFX1VOU1BF", + "Q0lGSUVEEAASCAoERk9PMRABEggKBEJBUjEQAhIHCgNCQVoQAxIICgRGT08y", + "EAESCAoEQkFSMhACGgIQASqdAQoOVGVzdFNwYXJzZUVudW0SIAocVEVTVF9T", + "UEFSU0VfRU5VTV9VTlNQRUNJRklFRBAAEgwKCFNQQVJTRV9BEHsSDgoIU1BB", + "UlNFX0IQpucDEg8KCFNQQVJTRV9DELKxgAYSFQoIU1BBUlNFX0QQ8f//////", + "////ARIVCghTUEFSU0VfRRC03vz///////8BEgwKCFNQQVJTRV9HEAIymQEK", + "C1Rlc3RTZXJ2aWNlEkQKA0ZvbxIdLnByb3RvYnVmX3VuaXR0ZXN0LkZvb1Jl", + "cXVlc3QaHi5wcm90b2J1Zl91bml0dGVzdC5Gb29SZXNwb25zZRJECgNCYXIS", + "HS5wcm90b2J1Zl91bml0dGVzdC5CYXJSZXF1ZXN0Gh4ucHJvdG9idWZfdW5p", + "dHRlc3QuQmFyUmVzcG9uc2VCOkINVW5pdHRlc3RQcm90b0gBgAEBiAEBkAEB", + "+AEBqgIaR29vZ2xlLlByb3RvYnVmLlRlc3RQcm90b3NiBnByb3RvMw==")); + descriptor = pbr::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, + new pbr::FileDescriptor[] { + global::Google.Protobuf.TestProtos.UnittestImportProto3.Descriptor, + }); + internal__static_protobuf_unittest_TestAllTypes__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestAllTypes), descriptor.MessageTypes[0], + new string[] { "SingleInt32", "SingleInt64", "SingleUint32", "SingleUint64", "SingleSint32", "SingleSint64", "SingleFixed32", "SingleFixed64", "SingleSfixed32", "SingleSfixed64", "SingleFloat", "SingleDouble", "SingleBool", "SingleString", "SingleBytes", "SingleNestedMessage", "SingleForeignMessage", "SingleImportMessage", "SingleNestedEnum", "SingleForeignEnum", "SingleImportEnum", "SinglePublicImportMessage", "RepeatedInt32", "RepeatedInt64", "RepeatedUint32", "RepeatedUint64", "RepeatedSint32", "RepeatedSint64", "RepeatedFixed32", "RepeatedFixed64", "RepeatedSfixed32", "RepeatedSfixed64", "RepeatedFloat", "RepeatedDouble", "RepeatedBool", "RepeatedString", "RepeatedBytes", "RepeatedNestedMessage", "RepeatedForeignMessage", "RepeatedImportMessage", "RepeatedNestedEnum", "RepeatedForeignEnum", "RepeatedImportEnum", "RepeatedPublicImportMessage", "OneofUint32", "OneofNestedMessage", "OneofString", "OneofBytes", }, new string[] { "OneofField", }); + internal__static_protobuf_unittest_TestAllTypes_NestedMessage__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage), descriptor.MessageTypes[0].NestedTypes[0], + new string[] { "Bb", }, new string[] { }); + internal__static_protobuf_unittest_NestedTestAllTypes__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.NestedTestAllTypes), descriptor.MessageTypes[1], + new string[] { "Child", "Payload", "RepeatedChild", }, new string[] { }); + internal__static_protobuf_unittest_TestDeprecatedFields__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestDeprecatedFields), descriptor.MessageTypes[2], + new string[] { "DeprecatedInt32", }, new string[] { }); + internal__static_protobuf_unittest_ForeignMessage__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.ForeignMessage), descriptor.MessageTypes[3], + new string[] { "C", }, new string[] { }); + internal__static_protobuf_unittest_TestReservedFields__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestReservedFields), descriptor.MessageTypes[4], + new string[] { }, new string[] { }); + internal__static_protobuf_unittest_TestForeignNested__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestForeignNested), descriptor.MessageTypes[5], + new string[] { "ForeignNested", }, new string[] { }); + internal__static_protobuf_unittest_TestReallyLargeTagNumber__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestReallyLargeTagNumber), descriptor.MessageTypes[6], + new string[] { "A", "Bb", }, new string[] { }); + internal__static_protobuf_unittest_TestRecursiveMessage__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestRecursiveMessage), descriptor.MessageTypes[7], + new string[] { "A", "I", }, new string[] { }); + internal__static_protobuf_unittest_TestMutualRecursionA__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMutualRecursionA), descriptor.MessageTypes[8], + new string[] { "Bb", }, new string[] { }); + internal__static_protobuf_unittest_TestMutualRecursionB__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestMutualRecursionB), descriptor.MessageTypes[9], + new string[] { "A", "OptionalInt32", }, new string[] { }); + internal__static_protobuf_unittest_TestCamelCaseFieldNames__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestCamelCaseFieldNames), descriptor.MessageTypes[10], + new string[] { "PrimitiveField", "StringField", "EnumField", "MessageField", "RepeatedPrimitiveField", "RepeatedStringField", "RepeatedEnumField", "RepeatedMessageField", }, new string[] { }); + internal__static_protobuf_unittest_TestFieldOrderings__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestFieldOrderings), descriptor.MessageTypes[11], + new string[] { "MyString", "MyInt", "MyFloat", "SingleNestedMessage", }, new string[] { }); + internal__static_protobuf_unittest_TestFieldOrderings_NestedMessage__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestFieldOrderings.Types.NestedMessage), descriptor.MessageTypes[11].NestedTypes[0], + new string[] { "Oo", "Bb", }, new string[] { }); + internal__static_protobuf_unittest_SparseEnumMessage__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.SparseEnumMessage), descriptor.MessageTypes[12], + new string[] { "SparseEnum", }, new string[] { }); + internal__static_protobuf_unittest_OneString__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.OneString), descriptor.MessageTypes[13], + new string[] { "Data", }, new string[] { }); + internal__static_protobuf_unittest_MoreString__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.MoreString), descriptor.MessageTypes[14], + new string[] { "Data", }, new string[] { }); + internal__static_protobuf_unittest_OneBytes__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.OneBytes), descriptor.MessageTypes[15], + new string[] { "Data", }, new string[] { }); + internal__static_protobuf_unittest_MoreBytes__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.MoreBytes), descriptor.MessageTypes[16], + new string[] { "Data", }, new string[] { }); + internal__static_protobuf_unittest_Int32Message__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.Int32Message), descriptor.MessageTypes[17], + new string[] { "Data", }, new string[] { }); + internal__static_protobuf_unittest_Uint32Message__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.Uint32Message), descriptor.MessageTypes[18], + new string[] { "Data", }, new string[] { }); + internal__static_protobuf_unittest_Int64Message__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.Int64Message), descriptor.MessageTypes[19], + new string[] { "Data", }, new string[] { }); + internal__static_protobuf_unittest_Uint64Message__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.Uint64Message), descriptor.MessageTypes[20], + new string[] { "Data", }, new string[] { }); + internal__static_protobuf_unittest_BoolMessage__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.BoolMessage), descriptor.MessageTypes[21], + new string[] { "Data", }, new string[] { }); + internal__static_protobuf_unittest_TestOneof__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestOneof), descriptor.MessageTypes[22], + new string[] { "FooInt", "FooString", "FooMessage", }, new string[] { "Foo", }); + internal__static_protobuf_unittest_TestPackedTypes__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestPackedTypes), descriptor.MessageTypes[23], + new string[] { "PackedInt32", "PackedInt64", "PackedUint32", "PackedUint64", "PackedSint32", "PackedSint64", "PackedFixed32", "PackedFixed64", "PackedSfixed32", "PackedSfixed64", "PackedFloat", "PackedDouble", "PackedBool", "PackedEnum", }, new string[] { }); + internal__static_protobuf_unittest_TestUnpackedTypes__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestUnpackedTypes), descriptor.MessageTypes[24], + new string[] { "UnpackedInt32", "UnpackedInt64", "UnpackedUint32", "UnpackedUint64", "UnpackedSint32", "UnpackedSint64", "UnpackedFixed32", "UnpackedFixed64", "UnpackedSfixed32", "UnpackedSfixed64", "UnpackedFloat", "UnpackedDouble", "UnpackedBool", "UnpackedEnum", }, new string[] { }); + internal__static_protobuf_unittest_TestRepeatedScalarDifferentTagSizes__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestRepeatedScalarDifferentTagSizes), descriptor.MessageTypes[25], + new string[] { "RepeatedFixed32", "RepeatedInt32", "RepeatedFixed64", "RepeatedInt64", "RepeatedFloat", "RepeatedUint64", }, new string[] { }); + internal__static_protobuf_unittest_TestCommentInjectionMessage__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestCommentInjectionMessage), descriptor.MessageTypes[26], + new string[] { "A", }, new string[] { }); + internal__static_protobuf_unittest_FooRequest__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.FooRequest), descriptor.MessageTypes[27], + new string[] { }, new string[] { }); + internal__static_protobuf_unittest_FooResponse__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.FooResponse), descriptor.MessageTypes[28], + new string[] { }, new string[] { }); + internal__static_protobuf_unittest_FooClientMessage__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.FooClientMessage), descriptor.MessageTypes[29], + new string[] { }, new string[] { }); + internal__static_protobuf_unittest_FooServerMessage__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.FooServerMessage), descriptor.MessageTypes[30], + new string[] { }, new string[] { }); + internal__static_protobuf_unittest_BarRequest__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.BarRequest), descriptor.MessageTypes[31], + new string[] { }, new string[] { }); + internal__static_protobuf_unittest_BarResponse__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.BarResponse), descriptor.MessageTypes[32], + new string[] { }, new string[] { }); + } + #endregion + + } + #region Enums + public enum ForeignEnum { + FOREIGN_UNSPECIFIED = 0, + FOREIGN_FOO = 4, + FOREIGN_BAR = 5, + FOREIGN_BAZ = 6, + } + + public enum TestEnumWithDupValue { + TEST_ENUM_WITH_DUP_VALUE_UNSPECIFIED = 0, + FOO1 = 1, + BAR1 = 2, + BAZ = 3, + FOO2 = 1, + BAR2 = 2, + } + + public enum TestSparseEnum { + TEST_SPARSE_ENUM_UNSPECIFIED = 0, + SPARSE_A = 123, + SPARSE_B = 62374, + SPARSE_C = 12589234, + SPARSE_D = -15, + SPARSE_E = -53452, + SPARSE_G = 2, + } + + #endregion + + #region Messages + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class TestAllTypes : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestAllTypes()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "oneof_bytes", "oneof_nested_message", "oneof_string", "oneof_uint32", "repeated_bool", "repeated_bytes", "repeated_double", "repeated_fixed32", "repeated_fixed64", "repeated_float", "repeated_foreign_enum", "repeated_foreign_message", "repeated_import_enum", "repeated_import_message", "repeated_int32", "repeated_int64", "repeated_nested_enum", "repeated_nested_message", "repeated_public_import_message", "repeated_sfixed32", "repeated_sfixed64", "repeated_sint32", "repeated_sint64", "repeated_string", "repeated_uint32", "repeated_uint64", "single_bool", "single_bytes", "single_double", "single_fixed32", "single_fixed64", "single_float", "single_foreign_enum", "single_foreign_message", "single_import_enum", "single_import_message", "single_int32", "single_int64", "single_nested_enum", "single_nested_message", "single_public_import_message", "single_sfixed32", "single_sfixed64", "single_sint32", "single_sint64", "single_string", "single_uint32", "single_uint64" }; + private static readonly uint[] _fieldTags = new uint[] { 914, 898, 906, 888, 346, 362, 338, 298, 306, 330, 418, 394, 426, 402, 250, 258, 410, 386, 434, 314, 322, 282, 290, 354, 266, 274, 104, 122, 97, 61, 65, 93, 176, 154, 184, 162, 8, 16, 168, 146, 210, 77, 81, 40, 48, 114, 24, 32 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[0]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestAllTypes__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public TestAllTypes() { + OnConstruction(); + } + + partial void OnConstruction(); + + public TestAllTypes(TestAllTypes other) : this() { + singleInt32_ = other.singleInt32_; + singleInt64_ = other.singleInt64_; + singleUint32_ = other.singleUint32_; + singleUint64_ = other.singleUint64_; + singleSint32_ = other.singleSint32_; + singleSint64_ = other.singleSint64_; + singleFixed32_ = other.singleFixed32_; + singleFixed64_ = other.singleFixed64_; + singleSfixed32_ = other.singleSfixed32_; + singleSfixed64_ = other.singleSfixed64_; + singleFloat_ = other.singleFloat_; + singleDouble_ = other.singleDouble_; + singleBool_ = other.singleBool_; + singleString_ = other.singleString_; + singleBytes_ = other.singleBytes_; + SingleNestedMessage = other.singleNestedMessage_ != null ? other.SingleNestedMessage.Clone() : null; + SingleForeignMessage = other.singleForeignMessage_ != null ? other.SingleForeignMessage.Clone() : null; + SingleImportMessage = other.singleImportMessage_ != null ? other.SingleImportMessage.Clone() : null; + singleNestedEnum_ = other.singleNestedEnum_; + singleForeignEnum_ = other.singleForeignEnum_; + singleImportEnum_ = other.singleImportEnum_; + SinglePublicImportMessage = other.singlePublicImportMessage_ != null ? other.SinglePublicImportMessage.Clone() : null; + repeatedInt32_ = other.repeatedInt32_.Clone(); + repeatedInt64_ = other.repeatedInt64_.Clone(); + repeatedUint32_ = other.repeatedUint32_.Clone(); + repeatedUint64_ = other.repeatedUint64_.Clone(); + repeatedSint32_ = other.repeatedSint32_.Clone(); + repeatedSint64_ = other.repeatedSint64_.Clone(); + repeatedFixed32_ = other.repeatedFixed32_.Clone(); + repeatedFixed64_ = other.repeatedFixed64_.Clone(); + repeatedSfixed32_ = other.repeatedSfixed32_.Clone(); + repeatedSfixed64_ = other.repeatedSfixed64_.Clone(); + repeatedFloat_ = other.repeatedFloat_.Clone(); + repeatedDouble_ = other.repeatedDouble_.Clone(); + repeatedBool_ = other.repeatedBool_.Clone(); + repeatedString_ = other.repeatedString_.Clone(); + repeatedBytes_ = other.repeatedBytes_.Clone(); + repeatedNestedMessage_ = other.repeatedNestedMessage_.Clone(); + repeatedForeignMessage_ = other.repeatedForeignMessage_.Clone(); + repeatedImportMessage_ = other.repeatedImportMessage_.Clone(); + repeatedNestedEnum_ = other.repeatedNestedEnum_.Clone(); + repeatedForeignEnum_ = other.repeatedForeignEnum_.Clone(); + repeatedImportEnum_ = other.repeatedImportEnum_.Clone(); + repeatedPublicImportMessage_ = other.repeatedPublicImportMessage_.Clone(); + switch (other.OneofFieldCase) { + case OneofFieldOneofCase.OneofUint32: + OneofUint32 = other.OneofUint32; + break; + case OneofFieldOneofCase.OneofNestedMessage: + OneofNestedMessage = other.OneofNestedMessage.Clone(); + break; + case OneofFieldOneofCase.OneofString: + OneofString = other.OneofString; + break; + case OneofFieldOneofCase.OneofBytes: + OneofBytes = other.OneofBytes; + break; + } + + } + + public TestAllTypes Clone() { + return new TestAllTypes(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + if (singleNestedMessage_ != null) SingleNestedMessage.Freeze(); + if (singleForeignMessage_ != null) SingleForeignMessage.Freeze(); + if (singleImportMessage_ != null) SingleImportMessage.Freeze(); + if (singlePublicImportMessage_ != null) SinglePublicImportMessage.Freeze(); + repeatedInt32_.Freeze(); + repeatedInt64_.Freeze(); + repeatedUint32_.Freeze(); + repeatedUint64_.Freeze(); + repeatedSint32_.Freeze(); + repeatedSint64_.Freeze(); + repeatedFixed32_.Freeze(); + repeatedFixed64_.Freeze(); + repeatedSfixed32_.Freeze(); + repeatedSfixed64_.Freeze(); + repeatedFloat_.Freeze(); + repeatedDouble_.Freeze(); + repeatedBool_.Freeze(); + repeatedString_.Freeze(); + repeatedBytes_.Freeze(); + repeatedNestedMessage_.Freeze(); + repeatedForeignMessage_.Freeze(); + repeatedImportMessage_.Freeze(); + repeatedNestedEnum_.Freeze(); + repeatedForeignEnum_.Freeze(); + repeatedImportEnum_.Freeze(); + repeatedPublicImportMessage_.Freeze(); + if (oneofField_ is IFreezable) ((IFreezable) oneofField_).Freeze(); + } + + public const int SingleInt32FieldNumber = 1; + private int singleInt32_; + public int SingleInt32 { + get { return singleInt32_; } + set { + pb::Freezable.CheckMutable(this); + singleInt32_ = value; + } + } + + public const int SingleInt64FieldNumber = 2; + private long singleInt64_; + public long SingleInt64 { + get { return singleInt64_; } + set { + pb::Freezable.CheckMutable(this); + singleInt64_ = value; + } + } + + public const int SingleUint32FieldNumber = 3; + private uint singleUint32_; + public uint SingleUint32 { + get { return singleUint32_; } + set { + pb::Freezable.CheckMutable(this); + singleUint32_ = value; + } + } + + public const int SingleUint64FieldNumber = 4; + private ulong singleUint64_; + public ulong SingleUint64 { + get { return singleUint64_; } + set { + pb::Freezable.CheckMutable(this); + singleUint64_ = value; + } + } + + public const int SingleSint32FieldNumber = 5; + private int singleSint32_; + public int SingleSint32 { + get { return singleSint32_; } + set { + pb::Freezable.CheckMutable(this); + singleSint32_ = value; + } + } + + public const int SingleSint64FieldNumber = 6; + private long singleSint64_; + public long SingleSint64 { + get { return singleSint64_; } + set { + pb::Freezable.CheckMutable(this); + singleSint64_ = value; + } + } + + public const int SingleFixed32FieldNumber = 7; + private uint singleFixed32_; + public uint SingleFixed32 { + get { return singleFixed32_; } + set { + pb::Freezable.CheckMutable(this); + singleFixed32_ = value; + } + } + + public const int SingleFixed64FieldNumber = 8; + private ulong singleFixed64_; + public ulong SingleFixed64 { + get { return singleFixed64_; } + set { + pb::Freezable.CheckMutable(this); + singleFixed64_ = value; + } + } + + public const int SingleSfixed32FieldNumber = 9; + private int singleSfixed32_; + public int SingleSfixed32 { + get { return singleSfixed32_; } + set { + pb::Freezable.CheckMutable(this); + singleSfixed32_ = value; + } + } + + public const int SingleSfixed64FieldNumber = 10; + private long singleSfixed64_; + public long SingleSfixed64 { + get { return singleSfixed64_; } + set { + pb::Freezable.CheckMutable(this); + singleSfixed64_ = value; + } + } + + public const int SingleFloatFieldNumber = 11; + private float singleFloat_; + public float SingleFloat { + get { return singleFloat_; } + set { + pb::Freezable.CheckMutable(this); + singleFloat_ = value; + } + } + + public const int SingleDoubleFieldNumber = 12; + private double singleDouble_; + public double SingleDouble { + get { return singleDouble_; } + set { + pb::Freezable.CheckMutable(this); + singleDouble_ = value; + } + } + + public const int SingleBoolFieldNumber = 13; + private bool singleBool_; + public bool SingleBool { + get { return singleBool_; } + set { + pb::Freezable.CheckMutable(this); + singleBool_ = value; + } + } + + public const int SingleStringFieldNumber = 14; + private string singleString_ = ""; + public string SingleString { + get { return singleString_; } + set { + pb::Freezable.CheckMutable(this); + singleString_ = value ?? ""; + } + } + + public const int SingleBytesFieldNumber = 15; + private pb::ByteString singleBytes_ = pb::ByteString.Empty; + public pb::ByteString SingleBytes { + get { return singleBytes_; } + set { + pb::Freezable.CheckMutable(this); + singleBytes_ = value ?? pb::ByteString.Empty; + } + } + + public const int SingleNestedMessageFieldNumber = 18; + private global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage singleNestedMessage_; + public global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage SingleNestedMessage { + get { return singleNestedMessage_; } + set { + pb::Freezable.CheckMutable(this); + singleNestedMessage_ = value; + } + } + + public const int SingleForeignMessageFieldNumber = 19; + private global::Google.Protobuf.TestProtos.ForeignMessage singleForeignMessage_; + public global::Google.Protobuf.TestProtos.ForeignMessage SingleForeignMessage { + get { return singleForeignMessage_; } + set { + pb::Freezable.CheckMutable(this); + singleForeignMessage_ = value; + } + } + + public const int SingleImportMessageFieldNumber = 20; + private global::Google.Protobuf.TestProtos.ImportMessage singleImportMessage_; + public global::Google.Protobuf.TestProtos.ImportMessage SingleImportMessage { + get { return singleImportMessage_; } + set { + pb::Freezable.CheckMutable(this); + singleImportMessage_ = value; + } + } + + public const int SingleNestedEnumFieldNumber = 21; + private global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum singleNestedEnum_ = global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum.NESTED_ENUM_UNSPECIFIED; + public global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum SingleNestedEnum { + get { return singleNestedEnum_; } + set { + pb::Freezable.CheckMutable(this); + singleNestedEnum_ = value; + } + } + + public const int SingleForeignEnumFieldNumber = 22; + private global::Google.Protobuf.TestProtos.ForeignEnum singleForeignEnum_ = global::Google.Protobuf.TestProtos.ForeignEnum.FOREIGN_UNSPECIFIED; + public global::Google.Protobuf.TestProtos.ForeignEnum SingleForeignEnum { + get { return singleForeignEnum_; } + set { + pb::Freezable.CheckMutable(this); + singleForeignEnum_ = value; + } + } + + public const int SingleImportEnumFieldNumber = 23; + private global::Google.Protobuf.TestProtos.ImportEnum singleImportEnum_ = global::Google.Protobuf.TestProtos.ImportEnum.IMPORT_ENUM_UNSPECIFIED; + public global::Google.Protobuf.TestProtos.ImportEnum SingleImportEnum { + get { return singleImportEnum_; } + set { + pb::Freezable.CheckMutable(this); + singleImportEnum_ = value; + } + } + + public const int SinglePublicImportMessageFieldNumber = 26; + private global::Google.Protobuf.TestProtos.PublicImportMessage singlePublicImportMessage_; + public global::Google.Protobuf.TestProtos.PublicImportMessage SinglePublicImportMessage { + get { return singlePublicImportMessage_; } + set { + pb::Freezable.CheckMutable(this); + singlePublicImportMessage_ = value; + } + } + + public const int RepeatedInt32FieldNumber = 31; + private static readonly pb::FieldCodec _repeated_repeatedInt32_codec + = pb::FieldCodec.ForInt32(250); + private readonly pbc::RepeatedField repeatedInt32_ = new pbc::RepeatedField(); + public pbc::RepeatedField RepeatedInt32 { + get { return repeatedInt32_; } + } + + public const int RepeatedInt64FieldNumber = 32; + private static readonly pb::FieldCodec _repeated_repeatedInt64_codec + = pb::FieldCodec.ForInt64(258); + private readonly pbc::RepeatedField repeatedInt64_ = new pbc::RepeatedField(); + public pbc::RepeatedField RepeatedInt64 { + get { return repeatedInt64_; } + } + + public const int RepeatedUint32FieldNumber = 33; + private static readonly pb::FieldCodec _repeated_repeatedUint32_codec + = pb::FieldCodec.ForUInt32(266); + private readonly pbc::RepeatedField repeatedUint32_ = new pbc::RepeatedField(); + public pbc::RepeatedField RepeatedUint32 { + get { return repeatedUint32_; } + } + + public const int RepeatedUint64FieldNumber = 34; + private static readonly pb::FieldCodec _repeated_repeatedUint64_codec + = pb::FieldCodec.ForUInt64(274); + private readonly pbc::RepeatedField repeatedUint64_ = new pbc::RepeatedField(); + public pbc::RepeatedField RepeatedUint64 { + get { return repeatedUint64_; } + } + + public const int RepeatedSint32FieldNumber = 35; + private static readonly pb::FieldCodec _repeated_repeatedSint32_codec + = pb::FieldCodec.ForSInt32(282); + private readonly pbc::RepeatedField repeatedSint32_ = new pbc::RepeatedField(); + public pbc::RepeatedField RepeatedSint32 { + get { return repeatedSint32_; } + } + + public const int RepeatedSint64FieldNumber = 36; + private static readonly pb::FieldCodec _repeated_repeatedSint64_codec + = pb::FieldCodec.ForSInt64(290); + private readonly pbc::RepeatedField repeatedSint64_ = new pbc::RepeatedField(); + public pbc::RepeatedField RepeatedSint64 { + get { return repeatedSint64_; } + } + + public const int RepeatedFixed32FieldNumber = 37; + private static readonly pb::FieldCodec _repeated_repeatedFixed32_codec + = pb::FieldCodec.ForFixed32(298); + private readonly pbc::RepeatedField repeatedFixed32_ = new pbc::RepeatedField(); + public pbc::RepeatedField RepeatedFixed32 { + get { return repeatedFixed32_; } + } + + public const int RepeatedFixed64FieldNumber = 38; + private static readonly pb::FieldCodec _repeated_repeatedFixed64_codec + = pb::FieldCodec.ForFixed64(306); + private readonly pbc::RepeatedField repeatedFixed64_ = new pbc::RepeatedField(); + public pbc::RepeatedField RepeatedFixed64 { + get { return repeatedFixed64_; } + } + + public const int RepeatedSfixed32FieldNumber = 39; + private static readonly pb::FieldCodec _repeated_repeatedSfixed32_codec + = pb::FieldCodec.ForSFixed32(314); + private readonly pbc::RepeatedField repeatedSfixed32_ = new pbc::RepeatedField(); + public pbc::RepeatedField RepeatedSfixed32 { + get { return repeatedSfixed32_; } + } + + public const int RepeatedSfixed64FieldNumber = 40; + private static readonly pb::FieldCodec _repeated_repeatedSfixed64_codec + = pb::FieldCodec.ForSFixed64(322); + private readonly pbc::RepeatedField repeatedSfixed64_ = new pbc::RepeatedField(); + public pbc::RepeatedField RepeatedSfixed64 { + get { return repeatedSfixed64_; } + } + + public const int RepeatedFloatFieldNumber = 41; + private static readonly pb::FieldCodec _repeated_repeatedFloat_codec + = pb::FieldCodec.ForFloat(330); + private readonly pbc::RepeatedField repeatedFloat_ = new pbc::RepeatedField(); + public pbc::RepeatedField RepeatedFloat { + get { return repeatedFloat_; } + } + + public const int RepeatedDoubleFieldNumber = 42; + private static readonly pb::FieldCodec _repeated_repeatedDouble_codec + = pb::FieldCodec.ForDouble(338); + private readonly pbc::RepeatedField repeatedDouble_ = new pbc::RepeatedField(); + public pbc::RepeatedField RepeatedDouble { + get { return repeatedDouble_; } + } + + public const int RepeatedBoolFieldNumber = 43; + private static readonly pb::FieldCodec _repeated_repeatedBool_codec + = pb::FieldCodec.ForBool(346); + private readonly pbc::RepeatedField repeatedBool_ = new pbc::RepeatedField(); + public pbc::RepeatedField RepeatedBool { + get { return repeatedBool_; } + } + + public const int RepeatedStringFieldNumber = 44; + private static readonly pb::FieldCodec _repeated_repeatedString_codec + = pb::FieldCodec.ForString(354); + private readonly pbc::RepeatedField repeatedString_ = new pbc::RepeatedField(); + public pbc::RepeatedField RepeatedString { + get { return repeatedString_; } + } + + public const int RepeatedBytesFieldNumber = 45; + private static readonly pb::FieldCodec _repeated_repeatedBytes_codec + = pb::FieldCodec.ForBytes(362); + private readonly pbc::RepeatedField repeatedBytes_ = new pbc::RepeatedField(); + public pbc::RepeatedField RepeatedBytes { + get { return repeatedBytes_; } + } + + public const int RepeatedNestedMessageFieldNumber = 48; + private static readonly pb::FieldCodec _repeated_repeatedNestedMessage_codec + = pb::FieldCodec.ForMessage(386, global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage.Parser); + private readonly pbc::RepeatedField repeatedNestedMessage_ = new pbc::RepeatedField(); + public pbc::RepeatedField RepeatedNestedMessage { + get { return repeatedNestedMessage_; } + } + + public const int RepeatedForeignMessageFieldNumber = 49; + private static readonly pb::FieldCodec _repeated_repeatedForeignMessage_codec + = pb::FieldCodec.ForMessage(394, global::Google.Protobuf.TestProtos.ForeignMessage.Parser); + private readonly pbc::RepeatedField repeatedForeignMessage_ = new pbc::RepeatedField(); + public pbc::RepeatedField RepeatedForeignMessage { + get { return repeatedForeignMessage_; } + } + + public const int RepeatedImportMessageFieldNumber = 50; + private static readonly pb::FieldCodec _repeated_repeatedImportMessage_codec + = pb::FieldCodec.ForMessage(402, global::Google.Protobuf.TestProtos.ImportMessage.Parser); + private readonly pbc::RepeatedField repeatedImportMessage_ = new pbc::RepeatedField(); + public pbc::RepeatedField RepeatedImportMessage { + get { return repeatedImportMessage_; } + } + + public const int RepeatedNestedEnumFieldNumber = 51; + private static readonly pb::FieldCodec _repeated_repeatedNestedEnum_codec + = pb::FieldCodec.ForEnum(410, x => (int) x, x => (global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum) x);private readonly pbc::RepeatedField repeatedNestedEnum_ = new pbc::RepeatedField(); + public pbc::RepeatedField RepeatedNestedEnum { + get { return repeatedNestedEnum_; } + } + + public const int RepeatedForeignEnumFieldNumber = 52; + private static readonly pb::FieldCodec _repeated_repeatedForeignEnum_codec + = pb::FieldCodec.ForEnum(418, x => (int) x, x => (global::Google.Protobuf.TestProtos.ForeignEnum) x);private readonly pbc::RepeatedField repeatedForeignEnum_ = new pbc::RepeatedField(); + public pbc::RepeatedField RepeatedForeignEnum { + get { return repeatedForeignEnum_; } + } + + public const int RepeatedImportEnumFieldNumber = 53; + private static readonly pb::FieldCodec _repeated_repeatedImportEnum_codec + = pb::FieldCodec.ForEnum(426, x => (int) x, x => (global::Google.Protobuf.TestProtos.ImportEnum) x);private readonly pbc::RepeatedField repeatedImportEnum_ = new pbc::RepeatedField(); + public pbc::RepeatedField RepeatedImportEnum { + get { return repeatedImportEnum_; } + } + + public const int RepeatedPublicImportMessageFieldNumber = 54; + private static readonly pb::FieldCodec _repeated_repeatedPublicImportMessage_codec + = pb::FieldCodec.ForMessage(434, global::Google.Protobuf.TestProtos.PublicImportMessage.Parser); + private readonly pbc::RepeatedField repeatedPublicImportMessage_ = new pbc::RepeatedField(); + public pbc::RepeatedField RepeatedPublicImportMessage { + get { return repeatedPublicImportMessage_; } + } + + public const int OneofUint32FieldNumber = 111; + public uint OneofUint32 { + get { return oneofFieldCase_ == OneofFieldOneofCase.OneofUint32 ? (uint) oneofField_ : 0; } + set { + pb::Freezable.CheckMutable(this); + oneofField_ = value; + oneofFieldCase_ = OneofFieldOneofCase.OneofUint32; + } + } + + public const int OneofNestedMessageFieldNumber = 112; + public global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage OneofNestedMessage { + get { return oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage ? (global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage) oneofField_ : null; } + set { + pb::Freezable.CheckMutable(this); + oneofField_ = value; + oneofFieldCase_ = value == null ? OneofFieldOneofCase.None : OneofFieldOneofCase.OneofNestedMessage; + } + } + + public const int OneofStringFieldNumber = 113; + public string OneofString { + get { return oneofFieldCase_ == OneofFieldOneofCase.OneofString ? (string) oneofField_ : ""; } + set { + pb::Freezable.CheckMutable(this); + oneofField_ = value ?? ""; + oneofFieldCase_ = OneofFieldOneofCase.OneofString; + } + } + + public const int OneofBytesFieldNumber = 114; + public pb::ByteString OneofBytes { + get { return oneofFieldCase_ == OneofFieldOneofCase.OneofBytes ? (pb::ByteString) oneofField_ : pb::ByteString.Empty; } + set { + pb::Freezable.CheckMutable(this); + oneofField_ = value ?? pb::ByteString.Empty; + oneofFieldCase_ = OneofFieldOneofCase.OneofBytes; + } + } + + private object oneofField_; + public enum OneofFieldOneofCase { + None = 0, + OneofUint32 = 111, + OneofNestedMessage = 112, + OneofString = 113, + OneofBytes = 114, + } + private OneofFieldOneofCase oneofFieldCase_ = OneofFieldOneofCase.None; + public OneofFieldOneofCase OneofFieldCase { + get { return oneofFieldCase_; } + } + + public void ClearOneofField() { + pb::Freezable.CheckMutable(this); + oneofFieldCase_ = OneofFieldOneofCase.None; + oneofField_ = null; + } + + public override bool Equals(object other) { + return Equals(other as TestAllTypes); + } + + public bool Equals(TestAllTypes other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (SingleInt32 != other.SingleInt32) return false; + if (SingleInt64 != other.SingleInt64) return false; + if (SingleUint32 != other.SingleUint32) return false; + if (SingleUint64 != other.SingleUint64) return false; + if (SingleSint32 != other.SingleSint32) return false; + if (SingleSint64 != other.SingleSint64) return false; + if (SingleFixed32 != other.SingleFixed32) return false; + if (SingleFixed64 != other.SingleFixed64) return false; + if (SingleSfixed32 != other.SingleSfixed32) return false; + if (SingleSfixed64 != other.SingleSfixed64) return false; + if (SingleFloat != other.SingleFloat) return false; + if (SingleDouble != other.SingleDouble) return false; + if (SingleBool != other.SingleBool) return false; + if (SingleString != other.SingleString) return false; + if (SingleBytes != other.SingleBytes) return false; + if (!object.Equals(SingleNestedMessage, other.SingleNestedMessage)) return false; + if (!object.Equals(SingleForeignMessage, other.SingleForeignMessage)) return false; + if (!object.Equals(SingleImportMessage, other.SingleImportMessage)) return false; + if (SingleNestedEnum != other.SingleNestedEnum) return false; + if (SingleForeignEnum != other.SingleForeignEnum) return false; + if (SingleImportEnum != other.SingleImportEnum) return false; + if (!object.Equals(SinglePublicImportMessage, other.SinglePublicImportMessage)) return false; + if(!repeatedInt32_.Equals(other.repeatedInt32_)) return false; + if(!repeatedInt64_.Equals(other.repeatedInt64_)) return false; + if(!repeatedUint32_.Equals(other.repeatedUint32_)) return false; + if(!repeatedUint64_.Equals(other.repeatedUint64_)) return false; + if(!repeatedSint32_.Equals(other.repeatedSint32_)) return false; + if(!repeatedSint64_.Equals(other.repeatedSint64_)) return false; + if(!repeatedFixed32_.Equals(other.repeatedFixed32_)) return false; + if(!repeatedFixed64_.Equals(other.repeatedFixed64_)) return false; + if(!repeatedSfixed32_.Equals(other.repeatedSfixed32_)) return false; + if(!repeatedSfixed64_.Equals(other.repeatedSfixed64_)) return false; + if(!repeatedFloat_.Equals(other.repeatedFloat_)) return false; + if(!repeatedDouble_.Equals(other.repeatedDouble_)) return false; + if(!repeatedBool_.Equals(other.repeatedBool_)) return false; + if(!repeatedString_.Equals(other.repeatedString_)) return false; + if(!repeatedBytes_.Equals(other.repeatedBytes_)) return false; + if(!repeatedNestedMessage_.Equals(other.repeatedNestedMessage_)) return false; + if(!repeatedForeignMessage_.Equals(other.repeatedForeignMessage_)) return false; + if(!repeatedImportMessage_.Equals(other.repeatedImportMessage_)) return false; + if(!repeatedNestedEnum_.Equals(other.repeatedNestedEnum_)) return false; + if(!repeatedForeignEnum_.Equals(other.repeatedForeignEnum_)) return false; + if(!repeatedImportEnum_.Equals(other.repeatedImportEnum_)) return false; + if(!repeatedPublicImportMessage_.Equals(other.repeatedPublicImportMessage_)) return false; + if (OneofUint32 != other.OneofUint32) return false; + if (!object.Equals(OneofNestedMessage, other.OneofNestedMessage)) return false; + if (OneofString != other.OneofString) return false; + if (OneofBytes != other.OneofBytes) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (SingleInt32 != 0) hash ^= SingleInt32.GetHashCode(); + if (SingleInt64 != 0L) hash ^= SingleInt64.GetHashCode(); + if (SingleUint32 != 0) hash ^= SingleUint32.GetHashCode(); + if (SingleUint64 != 0UL) hash ^= SingleUint64.GetHashCode(); + if (SingleSint32 != 0) hash ^= SingleSint32.GetHashCode(); + if (SingleSint64 != 0L) hash ^= SingleSint64.GetHashCode(); + if (SingleFixed32 != 0) hash ^= SingleFixed32.GetHashCode(); + if (SingleFixed64 != 0UL) hash ^= SingleFixed64.GetHashCode(); + if (SingleSfixed32 != 0) hash ^= SingleSfixed32.GetHashCode(); + if (SingleSfixed64 != 0L) hash ^= SingleSfixed64.GetHashCode(); + if (SingleFloat != 0F) hash ^= SingleFloat.GetHashCode(); + if (SingleDouble != 0D) hash ^= SingleDouble.GetHashCode(); + if (SingleBool != false) hash ^= SingleBool.GetHashCode(); + if (SingleString.Length != 0) hash ^= SingleString.GetHashCode(); + if (SingleBytes.Length != 0) hash ^= SingleBytes.GetHashCode(); + if (singleNestedMessage_ != null) hash ^= SingleNestedMessage.GetHashCode(); + if (singleForeignMessage_ != null) hash ^= SingleForeignMessage.GetHashCode(); + if (singleImportMessage_ != null) hash ^= SingleImportMessage.GetHashCode(); + if (SingleNestedEnum != global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum.NESTED_ENUM_UNSPECIFIED) hash ^= SingleNestedEnum.GetHashCode(); + if (SingleForeignEnum != global::Google.Protobuf.TestProtos.ForeignEnum.FOREIGN_UNSPECIFIED) hash ^= SingleForeignEnum.GetHashCode(); + if (SingleImportEnum != global::Google.Protobuf.TestProtos.ImportEnum.IMPORT_ENUM_UNSPECIFIED) hash ^= SingleImportEnum.GetHashCode(); + if (singlePublicImportMessage_ != null) hash ^= SinglePublicImportMessage.GetHashCode(); + hash ^= repeatedInt32_.GetHashCode(); + hash ^= repeatedInt64_.GetHashCode(); + hash ^= repeatedUint32_.GetHashCode(); + hash ^= repeatedUint64_.GetHashCode(); + hash ^= repeatedSint32_.GetHashCode(); + hash ^= repeatedSint64_.GetHashCode(); + hash ^= repeatedFixed32_.GetHashCode(); + hash ^= repeatedFixed64_.GetHashCode(); + hash ^= repeatedSfixed32_.GetHashCode(); + hash ^= repeatedSfixed64_.GetHashCode(); + hash ^= repeatedFloat_.GetHashCode(); + hash ^= repeatedDouble_.GetHashCode(); + hash ^= repeatedBool_.GetHashCode(); + hash ^= repeatedString_.GetHashCode(); + hash ^= repeatedBytes_.GetHashCode(); + hash ^= repeatedNestedMessage_.GetHashCode(); + hash ^= repeatedForeignMessage_.GetHashCode(); + hash ^= repeatedImportMessage_.GetHashCode(); + hash ^= repeatedNestedEnum_.GetHashCode(); + hash ^= repeatedForeignEnum_.GetHashCode(); + hash ^= repeatedImportEnum_.GetHashCode(); + hash ^= repeatedPublicImportMessage_.GetHashCode(); + if (oneofFieldCase_ == OneofFieldOneofCase.OneofUint32) hash ^= OneofUint32.GetHashCode(); + if (oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage) hash ^= OneofNestedMessage.GetHashCode(); + if (oneofFieldCase_ == OneofFieldOneofCase.OneofString) hash ^= OneofString.GetHashCode(); + if (oneofFieldCase_ == OneofFieldOneofCase.OneofBytes) hash ^= OneofBytes.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream 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.NESTED_ENUM_UNSPECIFIED) { + output.WriteRawTag(168, 1); + output.WriteEnum((int) SingleNestedEnum); + } + if (SingleForeignEnum != global::Google.Protobuf.TestProtos.ForeignEnum.FOREIGN_UNSPECIFIED) { + output.WriteRawTag(176, 1); + output.WriteEnum((int) SingleForeignEnum); + } + if (SingleImportEnum != global::Google.Protobuf.TestProtos.ImportEnum.IMPORT_ENUM_UNSPECIFIED) { + output.WriteRawTag(184, 1); + output.WriteEnum((int) SingleImportEnum); + } + if (singlePublicImportMessage_ != null) { + output.WriteRawTag(210, 1); + output.WriteMessage(SinglePublicImportMessage); + } + repeatedInt32_.WriteTo(output, _repeated_repeatedInt32_codec); + repeatedInt64_.WriteTo(output, _repeated_repeatedInt64_codec); + repeatedUint32_.WriteTo(output, _repeated_repeatedUint32_codec); + repeatedUint64_.WriteTo(output, _repeated_repeatedUint64_codec); + repeatedSint32_.WriteTo(output, _repeated_repeatedSint32_codec); + repeatedSint64_.WriteTo(output, _repeated_repeatedSint64_codec); + repeatedFixed32_.WriteTo(output, _repeated_repeatedFixed32_codec); + repeatedFixed64_.WriteTo(output, _repeated_repeatedFixed64_codec); + repeatedSfixed32_.WriteTo(output, _repeated_repeatedSfixed32_codec); + repeatedSfixed64_.WriteTo(output, _repeated_repeatedSfixed64_codec); + repeatedFloat_.WriteTo(output, _repeated_repeatedFloat_codec); + repeatedDouble_.WriteTo(output, _repeated_repeatedDouble_codec); + repeatedBool_.WriteTo(output, _repeated_repeatedBool_codec); + repeatedString_.WriteTo(output, _repeated_repeatedString_codec); + repeatedBytes_.WriteTo(output, _repeated_repeatedBytes_codec); + repeatedNestedMessage_.WriteTo(output, _repeated_repeatedNestedMessage_codec); + repeatedForeignMessage_.WriteTo(output, _repeated_repeatedForeignMessage_codec); + repeatedImportMessage_.WriteTo(output, _repeated_repeatedImportMessage_codec); + repeatedNestedEnum_.WriteTo(output, _repeated_repeatedNestedEnum_codec); + repeatedForeignEnum_.WriteTo(output, _repeated_repeatedForeignEnum_codec); + repeatedImportEnum_.WriteTo(output, _repeated_repeatedImportEnum_codec); + repeatedPublicImportMessage_.WriteTo(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); + } + } + + public int CalculateSize() { + int size = 0; + if (SingleInt32 != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(SingleInt32); + } + if (SingleInt64 != 0L) { + size += 1 + pb::CodedOutputStream.ComputeInt64Size(SingleInt64); + } + if (SingleUint32 != 0) { + size += 1 + pb::CodedOutputStream.ComputeUInt32Size(SingleUint32); + } + if (SingleUint64 != 0UL) { + size += 1 + pb::CodedOutputStream.ComputeUInt64Size(SingleUint64); + } + if (SingleSint32 != 0) { + size += 1 + pb::CodedOutputStream.ComputeSInt32Size(SingleSint32); + } + if (SingleSint64 != 0L) { + size += 1 + pb::CodedOutputStream.ComputeSInt64Size(SingleSint64); + } + if (SingleFixed32 != 0) { + size += 1 + 4; + } + if (SingleFixed64 != 0UL) { + size += 1 + 8; + } + if (SingleSfixed32 != 0) { + size += 1 + 4; + } + if (SingleSfixed64 != 0L) { + size += 1 + 8; + } + if (SingleFloat != 0F) { + size += 1 + 4; + } + if (SingleDouble != 0D) { + size += 1 + 8; + } + if (SingleBool != false) { + size += 1 + 1; + } + if (SingleString.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(SingleString); + } + if (SingleBytes.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeBytesSize(SingleBytes); + } + if (singleNestedMessage_ != null) { + size += 2 + pb::CodedOutputStream.ComputeMessageSize(SingleNestedMessage); + } + if (singleForeignMessage_ != null) { + size += 2 + pb::CodedOutputStream.ComputeMessageSize(SingleForeignMessage); + } + if (singleImportMessage_ != null) { + size += 2 + pb::CodedOutputStream.ComputeMessageSize(SingleImportMessage); + } + if (SingleNestedEnum != global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum.NESTED_ENUM_UNSPECIFIED) { + size += 2 + pb::CodedOutputStream.ComputeEnumSize((int) SingleNestedEnum); + } + if (SingleForeignEnum != global::Google.Protobuf.TestProtos.ForeignEnum.FOREIGN_UNSPECIFIED) { + size += 2 + pb::CodedOutputStream.ComputeEnumSize((int) SingleForeignEnum); + } + if (SingleImportEnum != global::Google.Protobuf.TestProtos.ImportEnum.IMPORT_ENUM_UNSPECIFIED) { + size += 2 + pb::CodedOutputStream.ComputeEnumSize((int) SingleImportEnum); + } + if (singlePublicImportMessage_ != null) { + size += 2 + pb::CodedOutputStream.ComputeMessageSize(SinglePublicImportMessage); + } + size += repeatedInt32_.CalculateSize(_repeated_repeatedInt32_codec); + size += repeatedInt64_.CalculateSize(_repeated_repeatedInt64_codec); + size += repeatedUint32_.CalculateSize(_repeated_repeatedUint32_codec); + size += repeatedUint64_.CalculateSize(_repeated_repeatedUint64_codec); + size += repeatedSint32_.CalculateSize(_repeated_repeatedSint32_codec); + size += repeatedSint64_.CalculateSize(_repeated_repeatedSint64_codec); + size += repeatedFixed32_.CalculateSize(_repeated_repeatedFixed32_codec); + size += repeatedFixed64_.CalculateSize(_repeated_repeatedFixed64_codec); + size += repeatedSfixed32_.CalculateSize(_repeated_repeatedSfixed32_codec); + size += repeatedSfixed64_.CalculateSize(_repeated_repeatedSfixed64_codec); + size += repeatedFloat_.CalculateSize(_repeated_repeatedFloat_codec); + size += repeatedDouble_.CalculateSize(_repeated_repeatedDouble_codec); + size += repeatedBool_.CalculateSize(_repeated_repeatedBool_codec); + size += repeatedString_.CalculateSize(_repeated_repeatedString_codec); + size += repeatedBytes_.CalculateSize(_repeated_repeatedBytes_codec); + size += repeatedNestedMessage_.CalculateSize(_repeated_repeatedNestedMessage_codec); + size += repeatedForeignMessage_.CalculateSize(_repeated_repeatedForeignMessage_codec); + size += repeatedImportMessage_.CalculateSize(_repeated_repeatedImportMessage_codec); + size += repeatedNestedEnum_.CalculateSize(_repeated_repeatedNestedEnum_codec); + size += repeatedForeignEnum_.CalculateSize(_repeated_repeatedForeignEnum_codec); + size += repeatedImportEnum_.CalculateSize(_repeated_repeatedImportEnum_codec); + size += repeatedPublicImportMessage_.CalculateSize(_repeated_repeatedPublicImportMessage_codec); + if (oneofFieldCase_ == OneofFieldOneofCase.OneofUint32) { + size += 2 + pb::CodedOutputStream.ComputeUInt32Size(OneofUint32); + } + if (oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage) { + size += 2 + pb::CodedOutputStream.ComputeMessageSize(OneofNestedMessage); + } + if (oneofFieldCase_ == OneofFieldOneofCase.OneofString) { + size += 2 + pb::CodedOutputStream.ComputeStringSize(OneofString); + } + if (oneofFieldCase_ == OneofFieldOneofCase.OneofBytes) { + size += 2 + pb::CodedOutputStream.ComputeBytesSize(OneofBytes); + } + return size; + } + + public void MergeFrom(TestAllTypes other) { + if (other == null) { + return; + } + if (other.SingleInt32 != 0) { + SingleInt32 = other.SingleInt32; + } + if (other.SingleInt64 != 0L) { + SingleInt64 = other.SingleInt64; + } + if (other.SingleUint32 != 0) { + SingleUint32 = other.SingleUint32; + } + if (other.SingleUint64 != 0UL) { + SingleUint64 = other.SingleUint64; + } + if (other.SingleSint32 != 0) { + SingleSint32 = other.SingleSint32; + } + if (other.SingleSint64 != 0L) { + SingleSint64 = other.SingleSint64; + } + if (other.SingleFixed32 != 0) { + SingleFixed32 = other.SingleFixed32; + } + if (other.SingleFixed64 != 0UL) { + SingleFixed64 = other.SingleFixed64; + } + if (other.SingleSfixed32 != 0) { + SingleSfixed32 = other.SingleSfixed32; + } + if (other.SingleSfixed64 != 0L) { + SingleSfixed64 = other.SingleSfixed64; + } + if (other.SingleFloat != 0F) { + SingleFloat = other.SingleFloat; + } + if (other.SingleDouble != 0D) { + SingleDouble = other.SingleDouble; + } + if (other.SingleBool != false) { + SingleBool = other.SingleBool; + } + if (other.SingleString.Length != 0) { + SingleString = other.SingleString; + } + if (other.SingleBytes.Length != 0) { + SingleBytes = other.SingleBytes; + } + if (other.singleNestedMessage_ != null) { + if (singleNestedMessage_ == null) { + singleNestedMessage_ = new global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage(); + } + SingleNestedMessage.MergeFrom(other.SingleNestedMessage); + } + if (other.singleForeignMessage_ != null) { + if (singleForeignMessage_ == null) { + singleForeignMessage_ = new global::Google.Protobuf.TestProtos.ForeignMessage(); + } + SingleForeignMessage.MergeFrom(other.SingleForeignMessage); + } + if (other.singleImportMessage_ != null) { + if (singleImportMessage_ == null) { + singleImportMessage_ = new global::Google.Protobuf.TestProtos.ImportMessage(); + } + SingleImportMessage.MergeFrom(other.SingleImportMessage); + } + if (other.SingleNestedEnum != global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum.NESTED_ENUM_UNSPECIFIED) { + SingleNestedEnum = other.SingleNestedEnum; + } + if (other.SingleForeignEnum != global::Google.Protobuf.TestProtos.ForeignEnum.FOREIGN_UNSPECIFIED) { + SingleForeignEnum = other.SingleForeignEnum; + } + if (other.SingleImportEnum != global::Google.Protobuf.TestProtos.ImportEnum.IMPORT_ENUM_UNSPECIFIED) { + SingleImportEnum = other.SingleImportEnum; + } + if (other.singlePublicImportMessage_ != null) { + if (singlePublicImportMessage_ == null) { + singlePublicImportMessage_ = new global::Google.Protobuf.TestProtos.PublicImportMessage(); + } + SinglePublicImportMessage.MergeFrom(other.SinglePublicImportMessage); + } + repeatedInt32_.Add(other.repeatedInt32_); + repeatedInt64_.Add(other.repeatedInt64_); + repeatedUint32_.Add(other.repeatedUint32_); + repeatedUint64_.Add(other.repeatedUint64_); + repeatedSint32_.Add(other.repeatedSint32_); + repeatedSint64_.Add(other.repeatedSint64_); + repeatedFixed32_.Add(other.repeatedFixed32_); + repeatedFixed64_.Add(other.repeatedFixed64_); + repeatedSfixed32_.Add(other.repeatedSfixed32_); + repeatedSfixed64_.Add(other.repeatedSfixed64_); + repeatedFloat_.Add(other.repeatedFloat_); + repeatedDouble_.Add(other.repeatedDouble_); + repeatedBool_.Add(other.repeatedBool_); + repeatedString_.Add(other.repeatedString_); + repeatedBytes_.Add(other.repeatedBytes_); + repeatedNestedMessage_.Add(other.repeatedNestedMessage_); + repeatedForeignMessage_.Add(other.repeatedForeignMessage_); + repeatedImportMessage_.Add(other.repeatedImportMessage_); + repeatedNestedEnum_.Add(other.repeatedNestedEnum_); + repeatedForeignEnum_.Add(other.repeatedForeignEnum_); + repeatedImportEnum_.Add(other.repeatedImportEnum_); + repeatedPublicImportMessage_.Add(other.repeatedPublicImportMessage_); + switch (other.OneofFieldCase) { + case OneofFieldOneofCase.OneofUint32: + OneofUint32 = other.OneofUint32; + break; + case OneofFieldOneofCase.OneofNestedMessage: + OneofNestedMessage = other.OneofNestedMessage; + break; + case OneofFieldOneofCase.OneofString: + OneofString = other.OneofString; + break; + case OneofFieldOneofCase.OneofBytes: + OneofBytes = other.OneofBytes; + break; + } + + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + 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(input, _repeated_repeatedInt32_codec); + break; + } + case 258: + case 256: { + repeatedInt64_.AddEntriesFrom(input, _repeated_repeatedInt64_codec); + break; + } + case 266: + case 264: { + repeatedUint32_.AddEntriesFrom(input, _repeated_repeatedUint32_codec); + break; + } + case 274: + case 272: { + repeatedUint64_.AddEntriesFrom(input, _repeated_repeatedUint64_codec); + break; + } + case 282: + case 280: { + repeatedSint32_.AddEntriesFrom(input, _repeated_repeatedSint32_codec); + break; + } + case 290: + case 288: { + repeatedSint64_.AddEntriesFrom(input, _repeated_repeatedSint64_codec); + break; + } + case 298: + case 301: { + repeatedFixed32_.AddEntriesFrom(input, _repeated_repeatedFixed32_codec); + break; + } + case 306: + case 305: { + repeatedFixed64_.AddEntriesFrom(input, _repeated_repeatedFixed64_codec); + break; + } + case 314: + case 317: { + repeatedSfixed32_.AddEntriesFrom(input, _repeated_repeatedSfixed32_codec); + break; + } + case 322: + case 321: { + repeatedSfixed64_.AddEntriesFrom(input, _repeated_repeatedSfixed64_codec); + break; + } + case 330: + case 333: { + repeatedFloat_.AddEntriesFrom(input, _repeated_repeatedFloat_codec); + break; + } + case 338: + case 337: { + repeatedDouble_.AddEntriesFrom(input, _repeated_repeatedDouble_codec); + break; + } + case 346: + case 344: { + repeatedBool_.AddEntriesFrom(input, _repeated_repeatedBool_codec); + break; + } + case 354: { + repeatedString_.AddEntriesFrom(input, _repeated_repeatedString_codec); + break; + } + case 362: { + repeatedBytes_.AddEntriesFrom(input, _repeated_repeatedBytes_codec); + break; + } + case 386: { + repeatedNestedMessage_.AddEntriesFrom(input, _repeated_repeatedNestedMessage_codec); + break; + } + case 394: { + repeatedForeignMessage_.AddEntriesFrom(input, _repeated_repeatedForeignMessage_codec); + break; + } + case 402: { + repeatedImportMessage_.AddEntriesFrom(input, _repeated_repeatedImportMessage_codec); + break; + } + case 410: + case 408: { + repeatedNestedEnum_.AddEntriesFrom(input, _repeated_repeatedNestedEnum_codec); + break; + } + case 418: + case 416: { + repeatedForeignEnum_.AddEntriesFrom(input, _repeated_repeatedForeignEnum_codec); + break; + } + case 426: + case 424: { + repeatedImportEnum_.AddEntriesFrom(input, _repeated_repeatedImportEnum_codec); + break; + } + case 434: { + repeatedPublicImportMessage_.AddEntriesFrom(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; + } + } + } + } + + #region Nested types + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static partial class Types { + public enum NestedEnum { + NESTED_ENUM_UNSPECIFIED = 0, + FOO = 1, + BAR = 2, + BAZ = 3, + NEG = -1, + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class NestedMessage : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedMessage()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "bb" }; + private static readonly uint[] _fieldTags = new uint[] { 8 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.TestAllTypes.Descriptor.NestedTypes[0]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestAllTypes_NestedMessage__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public NestedMessage() { + OnConstruction(); + } + + partial void OnConstruction(); + + public NestedMessage(NestedMessage other) : this() { + bb_ = other.bb_; + } + + public NestedMessage Clone() { + return new NestedMessage(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public const int BbFieldNumber = 1; + private int bb_; + public int Bb { + get { return bb_; } + set { + pb::Freezable.CheckMutable(this); + bb_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as NestedMessage); + } + + public bool Equals(NestedMessage other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Bb != other.Bb) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Bb != 0) hash ^= Bb.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Bb != 0) { + output.WriteRawTag(8); + output.WriteInt32(Bb); + } + } + + public int CalculateSize() { + int size = 0; + if (Bb != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Bb); + } + return size; + } + + public void MergeFrom(NestedMessage other) { + if (other == null) { + return; + } + if (other.Bb != 0) { + Bb = other.Bb; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 8: { + Bb = input.ReadInt32(); + break; + } + } + } + } + + } + + } + #endregion + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class NestedTestAllTypes : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedTestAllTypes()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "child", "payload", "repeated_child" }; + private static readonly uint[] _fieldTags = new uint[] { 10, 18, 26 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[1]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_NestedTestAllTypes__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public NestedTestAllTypes() { + OnConstruction(); + } + + partial void OnConstruction(); + + public NestedTestAllTypes(NestedTestAllTypes other) : this() { + Child = other.child_ != null ? other.Child.Clone() : null; + Payload = other.payload_ != null ? other.Payload.Clone() : null; + repeatedChild_ = other.repeatedChild_.Clone(); + } + + public NestedTestAllTypes Clone() { + return new NestedTestAllTypes(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + if (child_ != null) Child.Freeze(); + if (payload_ != null) Payload.Freeze(); + repeatedChild_.Freeze(); + } + + public const int ChildFieldNumber = 1; + private global::Google.Protobuf.TestProtos.NestedTestAllTypes child_; + public global::Google.Protobuf.TestProtos.NestedTestAllTypes Child { + get { return child_; } + set { + pb::Freezable.CheckMutable(this); + child_ = value; + } + } + + public const int PayloadFieldNumber = 2; + private global::Google.Protobuf.TestProtos.TestAllTypes payload_; + public global::Google.Protobuf.TestProtos.TestAllTypes Payload { + get { return payload_; } + set { + pb::Freezable.CheckMutable(this); + payload_ = value; + } + } + + public const int RepeatedChildFieldNumber = 3; + private static readonly pb::FieldCodec _repeated_repeatedChild_codec + = pb::FieldCodec.ForMessage(26, global::Google.Protobuf.TestProtos.NestedTestAllTypes.Parser); + private readonly pbc::RepeatedField repeatedChild_ = new pbc::RepeatedField(); + public pbc::RepeatedField RepeatedChild { + get { return repeatedChild_; } + } + + public override bool Equals(object other) { + return Equals(other as NestedTestAllTypes); + } + + public bool Equals(NestedTestAllTypes other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (!object.Equals(Child, other.Child)) return false; + if (!object.Equals(Payload, other.Payload)) return false; + if(!repeatedChild_.Equals(other.repeatedChild_)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (child_ != null) hash ^= Child.GetHashCode(); + if (payload_ != null) hash ^= Payload.GetHashCode(); + hash ^= repeatedChild_.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (child_ != null) { + output.WriteRawTag(10); + output.WriteMessage(Child); + } + if (payload_ != null) { + output.WriteRawTag(18); + output.WriteMessage(Payload); + } + repeatedChild_.WriteTo(output, _repeated_repeatedChild_codec); + } + + public int CalculateSize() { + int size = 0; + if (child_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Child); + } + if (payload_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Payload); + } + size += repeatedChild_.CalculateSize(_repeated_repeatedChild_codec); + return size; + } + + public void MergeFrom(NestedTestAllTypes other) { + if (other == null) { + return; + } + if (other.child_ != null) { + if (child_ == null) { + child_ = new global::Google.Protobuf.TestProtos.NestedTestAllTypes(); + } + Child.MergeFrom(other.Child); + } + if (other.payload_ != null) { + if (payload_ == null) { + payload_ = new global::Google.Protobuf.TestProtos.TestAllTypes(); + } + Payload.MergeFrom(other.Payload); + } + repeatedChild_.Add(other.repeatedChild_); + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + if (child_ == null) { + child_ = new global::Google.Protobuf.TestProtos.NestedTestAllTypes(); + } + input.ReadMessage(child_); + break; + } + case 18: { + if (payload_ == null) { + payload_ = new global::Google.Protobuf.TestProtos.TestAllTypes(); + } + input.ReadMessage(payload_); + break; + } + case 26: { + repeatedChild_.AddEntriesFrom(input, _repeated_repeatedChild_codec); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class TestDeprecatedFields : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestDeprecatedFields()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "deprecated_int32" }; + private static readonly uint[] _fieldTags = new uint[] { 8 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[2]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestDeprecatedFields__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public TestDeprecatedFields() { + OnConstruction(); + } + + partial void OnConstruction(); + + public TestDeprecatedFields(TestDeprecatedFields other) : this() { + deprecatedInt32_ = other.deprecatedInt32_; + } + + public TestDeprecatedFields Clone() { + return new TestDeprecatedFields(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public const int DeprecatedInt32FieldNumber = 1; + private int deprecatedInt32_; + [global::System.ObsoleteAttribute()] + public int DeprecatedInt32 { + get { return deprecatedInt32_; } + set { + pb::Freezable.CheckMutable(this); + deprecatedInt32_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as TestDeprecatedFields); + } + + public bool Equals(TestDeprecatedFields other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (DeprecatedInt32 != other.DeprecatedInt32) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (DeprecatedInt32 != 0) hash ^= DeprecatedInt32.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (DeprecatedInt32 != 0) { + output.WriteRawTag(8); + output.WriteInt32(DeprecatedInt32); + } + } + + public int CalculateSize() { + int size = 0; + if (DeprecatedInt32 != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(DeprecatedInt32); + } + return size; + } + + public void MergeFrom(TestDeprecatedFields other) { + if (other == null) { + return; + } + if (other.DeprecatedInt32 != 0) { + DeprecatedInt32 = other.DeprecatedInt32; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 8: { + DeprecatedInt32 = input.ReadInt32(); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class ForeignMessage : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ForeignMessage()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "c" }; + private static readonly uint[] _fieldTags = new uint[] { 8 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[3]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_ForeignMessage__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public ForeignMessage() { + OnConstruction(); + } + + partial void OnConstruction(); + + public ForeignMessage(ForeignMessage other) : this() { + c_ = other.c_; + } + + public ForeignMessage Clone() { + return new ForeignMessage(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public const int CFieldNumber = 1; + private int c_; + public int C { + get { return c_; } + set { + pb::Freezable.CheckMutable(this); + c_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as ForeignMessage); + } + + public bool Equals(ForeignMessage other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (C != other.C) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (C != 0) hash ^= C.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (C != 0) { + output.WriteRawTag(8); + output.WriteInt32(C); + } + } + + public int CalculateSize() { + int size = 0; + if (C != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(C); + } + return size; + } + + public void MergeFrom(ForeignMessage other) { + if (other == null) { + return; + } + if (other.C != 0) { + C = other.C; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 8: { + C = input.ReadInt32(); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class TestReservedFields : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestReservedFields()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { }; + private static readonly uint[] _fieldTags = new uint[] { }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[4]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestReservedFields__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public TestReservedFields() { + OnConstruction(); + } + + partial void OnConstruction(); + + public TestReservedFields(TestReservedFields other) : this() { + } + + public TestReservedFields Clone() { + return new TestReservedFields(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public override bool Equals(object other) { + return Equals(other as TestReservedFields); + } + + public bool Equals(TestReservedFields other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + return true; + } + + public override int GetHashCode() { + int hash = 1; + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + } + + public int CalculateSize() { + int size = 0; + return size; + } + + public void MergeFrom(TestReservedFields other) { + if (other == null) { + return; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class TestForeignNested : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestForeignNested()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "foreign_nested" }; + private static readonly uint[] _fieldTags = new uint[] { 10 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[5]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestForeignNested__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public TestForeignNested() { + OnConstruction(); + } + + partial void OnConstruction(); + + public TestForeignNested(TestForeignNested other) : this() { + ForeignNested = other.foreignNested_ != null ? other.ForeignNested.Clone() : null; + } + + public TestForeignNested Clone() { + return new TestForeignNested(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + if (foreignNested_ != null) ForeignNested.Freeze(); + } + + public const int ForeignNestedFieldNumber = 1; + private global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage foreignNested_; + public global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage ForeignNested { + get { return foreignNested_; } + set { + pb::Freezable.CheckMutable(this); + foreignNested_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as TestForeignNested); + } + + public bool Equals(TestForeignNested other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (!object.Equals(ForeignNested, other.ForeignNested)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (foreignNested_ != null) hash ^= ForeignNested.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (foreignNested_ != null) { + output.WriteRawTag(10); + output.WriteMessage(ForeignNested); + } + } + + public int CalculateSize() { + int size = 0; + if (foreignNested_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(ForeignNested); + } + return size; + } + + public void MergeFrom(TestForeignNested other) { + if (other == null) { + return; + } + if (other.foreignNested_ != null) { + if (foreignNested_ == null) { + foreignNested_ = new global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage(); + } + ForeignNested.MergeFrom(other.ForeignNested); + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + if (foreignNested_ == null) { + foreignNested_ = new global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage(); + } + input.ReadMessage(foreignNested_); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class TestReallyLargeTagNumber : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestReallyLargeTagNumber()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "a", "bb" }; + private static readonly uint[] _fieldTags = new uint[] { 8, 2147483640 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[6]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestReallyLargeTagNumber__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public TestReallyLargeTagNumber() { + OnConstruction(); + } + + partial void OnConstruction(); + + public TestReallyLargeTagNumber(TestReallyLargeTagNumber other) : this() { + a_ = other.a_; + bb_ = other.bb_; + } + + public TestReallyLargeTagNumber Clone() { + return new TestReallyLargeTagNumber(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public const int AFieldNumber = 1; + private int a_; + public int A { + get { return a_; } + set { + pb::Freezable.CheckMutable(this); + a_ = value; + } + } + + public const int BbFieldNumber = 268435455; + private int bb_; + public int Bb { + get { return bb_; } + set { + pb::Freezable.CheckMutable(this); + bb_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as TestReallyLargeTagNumber); + } + + public bool Equals(TestReallyLargeTagNumber other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (A != other.A) return false; + if (Bb != other.Bb) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (A != 0) hash ^= A.GetHashCode(); + if (Bb != 0) hash ^= Bb.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (A != 0) { + output.WriteRawTag(8); + output.WriteInt32(A); + } + if (Bb != 0) { + output.WriteRawTag(248, 255, 255, 255, 7); + output.WriteInt32(Bb); + } + } + + public int CalculateSize() { + int size = 0; + if (A != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(A); + } + if (Bb != 0) { + size += 5 + pb::CodedOutputStream.ComputeInt32Size(Bb); + } + return size; + } + + public void MergeFrom(TestReallyLargeTagNumber other) { + if (other == null) { + return; + } + if (other.A != 0) { + A = other.A; + } + if (other.Bb != 0) { + Bb = other.Bb; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 8: { + A = input.ReadInt32(); + break; + } + case 2147483640: { + Bb = input.ReadInt32(); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class TestRecursiveMessage : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestRecursiveMessage()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "a", "i" }; + private static readonly uint[] _fieldTags = new uint[] { 10, 16 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[7]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestRecursiveMessage__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public TestRecursiveMessage() { + OnConstruction(); + } + + partial void OnConstruction(); + + public TestRecursiveMessage(TestRecursiveMessage other) : this() { + A = other.a_ != null ? other.A.Clone() : null; + i_ = other.i_; + } + + public TestRecursiveMessage Clone() { + return new TestRecursiveMessage(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + if (a_ != null) A.Freeze(); + } + + public const int AFieldNumber = 1; + private global::Google.Protobuf.TestProtos.TestRecursiveMessage a_; + public global::Google.Protobuf.TestProtos.TestRecursiveMessage A { + get { return a_; } + set { + pb::Freezable.CheckMutable(this); + a_ = value; + } + } + + public const int IFieldNumber = 2; + private int i_; + public int I { + get { return i_; } + set { + pb::Freezable.CheckMutable(this); + i_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as TestRecursiveMessage); + } + + public bool Equals(TestRecursiveMessage other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (!object.Equals(A, other.A)) return false; + if (I != other.I) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (a_ != null) hash ^= A.GetHashCode(); + if (I != 0) hash ^= I.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (a_ != null) { + output.WriteRawTag(10); + output.WriteMessage(A); + } + if (I != 0) { + output.WriteRawTag(16); + output.WriteInt32(I); + } + } + + public int CalculateSize() { + int size = 0; + if (a_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(A); + } + if (I != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(I); + } + return size; + } + + public void MergeFrom(TestRecursiveMessage other) { + if (other == null) { + return; + } + if (other.a_ != null) { + if (a_ == null) { + a_ = new global::Google.Protobuf.TestProtos.TestRecursiveMessage(); + } + A.MergeFrom(other.A); + } + if (other.I != 0) { + I = other.I; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + if (a_ == null) { + a_ = new global::Google.Protobuf.TestProtos.TestRecursiveMessage(); + } + input.ReadMessage(a_); + break; + } + case 16: { + I = input.ReadInt32(); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class TestMutualRecursionA : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestMutualRecursionA()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "bb" }; + private static readonly uint[] _fieldTags = new uint[] { 10 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[8]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestMutualRecursionA__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public TestMutualRecursionA() { + OnConstruction(); + } + + partial void OnConstruction(); + + public TestMutualRecursionA(TestMutualRecursionA other) : this() { + Bb = other.bb_ != null ? other.Bb.Clone() : null; + } + + public TestMutualRecursionA Clone() { + return new TestMutualRecursionA(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + if (bb_ != null) Bb.Freeze(); + } + + public const int BbFieldNumber = 1; + private global::Google.Protobuf.TestProtos.TestMutualRecursionB bb_; + public global::Google.Protobuf.TestProtos.TestMutualRecursionB Bb { + get { return bb_; } + set { + pb::Freezable.CheckMutable(this); + bb_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as TestMutualRecursionA); + } + + public bool Equals(TestMutualRecursionA other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (!object.Equals(Bb, other.Bb)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (bb_ != null) hash ^= Bb.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (bb_ != null) { + output.WriteRawTag(10); + output.WriteMessage(Bb); + } + } + + public int CalculateSize() { + int size = 0; + if (bb_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Bb); + } + return size; + } + + public void MergeFrom(TestMutualRecursionA other) { + if (other == null) { + return; + } + if (other.bb_ != null) { + if (bb_ == null) { + bb_ = new global::Google.Protobuf.TestProtos.TestMutualRecursionB(); + } + Bb.MergeFrom(other.Bb); + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + if (bb_ == null) { + bb_ = new global::Google.Protobuf.TestProtos.TestMutualRecursionB(); + } + input.ReadMessage(bb_); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class TestMutualRecursionB : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestMutualRecursionB()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "a", "optional_int32" }; + private static readonly uint[] _fieldTags = new uint[] { 10, 16 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[9]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestMutualRecursionB__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public TestMutualRecursionB() { + OnConstruction(); + } + + partial void OnConstruction(); + + public TestMutualRecursionB(TestMutualRecursionB other) : this() { + A = other.a_ != null ? other.A.Clone() : null; + optionalInt32_ = other.optionalInt32_; + } + + public TestMutualRecursionB Clone() { + return new TestMutualRecursionB(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + if (a_ != null) A.Freeze(); + } + + public const int AFieldNumber = 1; + private global::Google.Protobuf.TestProtos.TestMutualRecursionA a_; + public global::Google.Protobuf.TestProtos.TestMutualRecursionA A { + get { return a_; } + set { + pb::Freezable.CheckMutable(this); + a_ = value; + } + } + + public const int OptionalInt32FieldNumber = 2; + private int optionalInt32_; + public int OptionalInt32 { + get { return optionalInt32_; } + set { + pb::Freezable.CheckMutable(this); + optionalInt32_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as TestMutualRecursionB); + } + + public bool Equals(TestMutualRecursionB other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (!object.Equals(A, other.A)) return false; + if (OptionalInt32 != other.OptionalInt32) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (a_ != null) hash ^= A.GetHashCode(); + if (OptionalInt32 != 0) hash ^= OptionalInt32.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (a_ != null) { + output.WriteRawTag(10); + output.WriteMessage(A); + } + if (OptionalInt32 != 0) { + output.WriteRawTag(16); + output.WriteInt32(OptionalInt32); + } + } + + public int CalculateSize() { + int size = 0; + if (a_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(A); + } + if (OptionalInt32 != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(OptionalInt32); + } + return size; + } + + public void MergeFrom(TestMutualRecursionB other) { + if (other == null) { + return; + } + if (other.a_ != null) { + if (a_ == null) { + a_ = new global::Google.Protobuf.TestProtos.TestMutualRecursionA(); + } + A.MergeFrom(other.A); + } + if (other.OptionalInt32 != 0) { + OptionalInt32 = other.OptionalInt32; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + if (a_ == null) { + a_ = new global::Google.Protobuf.TestProtos.TestMutualRecursionA(); + } + input.ReadMessage(a_); + break; + } + case 16: { + OptionalInt32 = input.ReadInt32(); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class TestCamelCaseFieldNames : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestCamelCaseFieldNames()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "EnumField", "MessageField", "PrimitiveField", "RepeatedEnumField", "RepeatedMessageField", "RepeatedPrimitiveField", "RepeatedStringField", "StringField" }; + private static readonly uint[] _fieldTags = new uint[] { 24, 34, 8, 74, 82, 58, 66, 18 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[10]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestCamelCaseFieldNames__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public TestCamelCaseFieldNames() { + OnConstruction(); + } + + partial void OnConstruction(); + + public TestCamelCaseFieldNames(TestCamelCaseFieldNames other) : this() { + primitiveField_ = other.primitiveField_; + stringField_ = other.stringField_; + enumField_ = other.enumField_; + MessageField = other.messageField_ != null ? other.MessageField.Clone() : null; + repeatedPrimitiveField_ = other.repeatedPrimitiveField_.Clone(); + repeatedStringField_ = other.repeatedStringField_.Clone(); + repeatedEnumField_ = other.repeatedEnumField_.Clone(); + repeatedMessageField_ = other.repeatedMessageField_.Clone(); + } + + public TestCamelCaseFieldNames Clone() { + return new TestCamelCaseFieldNames(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + if (messageField_ != null) MessageField.Freeze(); + repeatedPrimitiveField_.Freeze(); + repeatedStringField_.Freeze(); + repeatedEnumField_.Freeze(); + repeatedMessageField_.Freeze(); + } + + public const int PrimitiveFieldFieldNumber = 1; + private int primitiveField_; + public int PrimitiveField { + get { return primitiveField_; } + set { + pb::Freezable.CheckMutable(this); + primitiveField_ = value; + } + } + + public const int StringFieldFieldNumber = 2; + private string stringField_ = ""; + public string StringField { + get { return stringField_; } + set { + pb::Freezable.CheckMutable(this); + stringField_ = value ?? ""; + } + } + + public const int EnumFieldFieldNumber = 3; + private global::Google.Protobuf.TestProtos.ForeignEnum enumField_ = global::Google.Protobuf.TestProtos.ForeignEnum.FOREIGN_UNSPECIFIED; + public global::Google.Protobuf.TestProtos.ForeignEnum EnumField { + get { return enumField_; } + set { + pb::Freezable.CheckMutable(this); + enumField_ = value; + } + } + + public const int MessageFieldFieldNumber = 4; + private global::Google.Protobuf.TestProtos.ForeignMessage messageField_; + public global::Google.Protobuf.TestProtos.ForeignMessage MessageField { + get { return messageField_; } + set { + pb::Freezable.CheckMutable(this); + messageField_ = value; + } + } + + public const int RepeatedPrimitiveFieldFieldNumber = 7; + private static readonly pb::FieldCodec _repeated_repeatedPrimitiveField_codec + = pb::FieldCodec.ForInt32(58); + private readonly pbc::RepeatedField repeatedPrimitiveField_ = new pbc::RepeatedField(); + public pbc::RepeatedField RepeatedPrimitiveField { + get { return repeatedPrimitiveField_; } + } + + public const int RepeatedStringFieldFieldNumber = 8; + private static readonly pb::FieldCodec _repeated_repeatedStringField_codec + = pb::FieldCodec.ForString(66); + private readonly pbc::RepeatedField repeatedStringField_ = new pbc::RepeatedField(); + public pbc::RepeatedField RepeatedStringField { + get { return repeatedStringField_; } + } + + public const int RepeatedEnumFieldFieldNumber = 9; + private static readonly pb::FieldCodec _repeated_repeatedEnumField_codec + = pb::FieldCodec.ForEnum(74, x => (int) x, x => (global::Google.Protobuf.TestProtos.ForeignEnum) x);private readonly pbc::RepeatedField repeatedEnumField_ = new pbc::RepeatedField(); + public pbc::RepeatedField RepeatedEnumField { + get { return repeatedEnumField_; } + } + + public const int RepeatedMessageFieldFieldNumber = 10; + private static readonly pb::FieldCodec _repeated_repeatedMessageField_codec + = pb::FieldCodec.ForMessage(82, global::Google.Protobuf.TestProtos.ForeignMessage.Parser); + private readonly pbc::RepeatedField repeatedMessageField_ = new pbc::RepeatedField(); + public pbc::RepeatedField RepeatedMessageField { + get { return repeatedMessageField_; } + } + + public override bool Equals(object other) { + return Equals(other as TestCamelCaseFieldNames); + } + + public bool Equals(TestCamelCaseFieldNames other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (PrimitiveField != other.PrimitiveField) return false; + if (StringField != other.StringField) return false; + if (EnumField != other.EnumField) return false; + if (!object.Equals(MessageField, other.MessageField)) return false; + if(!repeatedPrimitiveField_.Equals(other.repeatedPrimitiveField_)) return false; + if(!repeatedStringField_.Equals(other.repeatedStringField_)) return false; + if(!repeatedEnumField_.Equals(other.repeatedEnumField_)) return false; + if(!repeatedMessageField_.Equals(other.repeatedMessageField_)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (PrimitiveField != 0) hash ^= PrimitiveField.GetHashCode(); + if (StringField.Length != 0) hash ^= StringField.GetHashCode(); + if (EnumField != global::Google.Protobuf.TestProtos.ForeignEnum.FOREIGN_UNSPECIFIED) hash ^= EnumField.GetHashCode(); + if (messageField_ != null) hash ^= MessageField.GetHashCode(); + hash ^= repeatedPrimitiveField_.GetHashCode(); + hash ^= repeatedStringField_.GetHashCode(); + hash ^= repeatedEnumField_.GetHashCode(); + hash ^= repeatedMessageField_.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (PrimitiveField != 0) { + output.WriteRawTag(8); + output.WriteInt32(PrimitiveField); + } + if (StringField.Length != 0) { + output.WriteRawTag(18); + output.WriteString(StringField); + } + if (EnumField != global::Google.Protobuf.TestProtos.ForeignEnum.FOREIGN_UNSPECIFIED) { + output.WriteRawTag(24); + output.WriteEnum((int) EnumField); + } + if (messageField_ != null) { + output.WriteRawTag(34); + output.WriteMessage(MessageField); + } + repeatedPrimitiveField_.WriteTo(output, _repeated_repeatedPrimitiveField_codec); + repeatedStringField_.WriteTo(output, _repeated_repeatedStringField_codec); + repeatedEnumField_.WriteTo(output, _repeated_repeatedEnumField_codec); + repeatedMessageField_.WriteTo(output, _repeated_repeatedMessageField_codec); + } + + public int CalculateSize() { + int size = 0; + if (PrimitiveField != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(PrimitiveField); + } + if (StringField.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(StringField); + } + if (EnumField != global::Google.Protobuf.TestProtos.ForeignEnum.FOREIGN_UNSPECIFIED) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) EnumField); + } + if (messageField_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(MessageField); + } + size += repeatedPrimitiveField_.CalculateSize(_repeated_repeatedPrimitiveField_codec); + size += repeatedStringField_.CalculateSize(_repeated_repeatedStringField_codec); + size += repeatedEnumField_.CalculateSize(_repeated_repeatedEnumField_codec); + size += repeatedMessageField_.CalculateSize(_repeated_repeatedMessageField_codec); + return size; + } + + public void MergeFrom(TestCamelCaseFieldNames other) { + if (other == null) { + return; + } + if (other.PrimitiveField != 0) { + PrimitiveField = other.PrimitiveField; + } + if (other.StringField.Length != 0) { + StringField = other.StringField; + } + if (other.EnumField != global::Google.Protobuf.TestProtos.ForeignEnum.FOREIGN_UNSPECIFIED) { + EnumField = other.EnumField; + } + if (other.messageField_ != null) { + if (messageField_ == null) { + messageField_ = new global::Google.Protobuf.TestProtos.ForeignMessage(); + } + MessageField.MergeFrom(other.MessageField); + } + repeatedPrimitiveField_.Add(other.repeatedPrimitiveField_); + repeatedStringField_.Add(other.repeatedStringField_); + repeatedEnumField_.Add(other.repeatedEnumField_); + repeatedMessageField_.Add(other.repeatedMessageField_); + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 8: { + PrimitiveField = input.ReadInt32(); + break; + } + case 18: { + StringField = input.ReadString(); + break; + } + case 24: { + enumField_ = (global::Google.Protobuf.TestProtos.ForeignEnum) input.ReadEnum(); + break; + } + case 34: { + if (messageField_ == null) { + messageField_ = new global::Google.Protobuf.TestProtos.ForeignMessage(); + } + input.ReadMessage(messageField_); + break; + } + case 58: + case 56: { + repeatedPrimitiveField_.AddEntriesFrom(input, _repeated_repeatedPrimitiveField_codec); + break; + } + case 66: { + repeatedStringField_.AddEntriesFrom(input, _repeated_repeatedStringField_codec); + break; + } + case 74: + case 72: { + repeatedEnumField_.AddEntriesFrom(input, _repeated_repeatedEnumField_codec); + break; + } + case 82: { + repeatedMessageField_.AddEntriesFrom(input, _repeated_repeatedMessageField_codec); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class TestFieldOrderings : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestFieldOrderings()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "my_float", "my_int", "my_string", "single_nested_message" }; + private static readonly uint[] _fieldTags = new uint[] { 813, 8, 90, 1602 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[11]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestFieldOrderings__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public TestFieldOrderings() { + OnConstruction(); + } + + partial void OnConstruction(); + + public TestFieldOrderings(TestFieldOrderings other) : this() { + myString_ = other.myString_; + myInt_ = other.myInt_; + myFloat_ = other.myFloat_; + SingleNestedMessage = other.singleNestedMessage_ != null ? other.SingleNestedMessage.Clone() : null; + } + + public TestFieldOrderings Clone() { + return new TestFieldOrderings(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + if (singleNestedMessage_ != null) SingleNestedMessage.Freeze(); + } + + public const int MyStringFieldNumber = 11; + private string myString_ = ""; + public string MyString { + get { return myString_; } + set { + pb::Freezable.CheckMutable(this); + myString_ = value ?? ""; + } + } + + public const int MyIntFieldNumber = 1; + private long myInt_; + public long MyInt { + get { return myInt_; } + set { + pb::Freezable.CheckMutable(this); + myInt_ = value; + } + } + + public const int MyFloatFieldNumber = 101; + private float myFloat_; + public float MyFloat { + get { return myFloat_; } + set { + pb::Freezable.CheckMutable(this); + myFloat_ = value; + } + } + + public const int SingleNestedMessageFieldNumber = 200; + private global::Google.Protobuf.TestProtos.TestFieldOrderings.Types.NestedMessage singleNestedMessage_; + public global::Google.Protobuf.TestProtos.TestFieldOrderings.Types.NestedMessage SingleNestedMessage { + get { return singleNestedMessage_; } + set { + pb::Freezable.CheckMutable(this); + singleNestedMessage_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as TestFieldOrderings); + } + + public bool Equals(TestFieldOrderings other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (MyString != other.MyString) return false; + if (MyInt != other.MyInt) return false; + if (MyFloat != other.MyFloat) return false; + if (!object.Equals(SingleNestedMessage, other.SingleNestedMessage)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (MyString.Length != 0) hash ^= MyString.GetHashCode(); + if (MyInt != 0L) hash ^= MyInt.GetHashCode(); + if (MyFloat != 0F) hash ^= MyFloat.GetHashCode(); + if (singleNestedMessage_ != null) hash ^= SingleNestedMessage.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (MyInt != 0L) { + output.WriteRawTag(8); + output.WriteInt64(MyInt); + } + if (MyString.Length != 0) { + output.WriteRawTag(90); + output.WriteString(MyString); + } + if (MyFloat != 0F) { + output.WriteRawTag(173, 6); + output.WriteFloat(MyFloat); + } + if (singleNestedMessage_ != null) { + output.WriteRawTag(194, 12); + output.WriteMessage(SingleNestedMessage); + } + } + + public int CalculateSize() { + int size = 0; + if (MyString.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(MyString); + } + if (MyInt != 0L) { + size += 1 + pb::CodedOutputStream.ComputeInt64Size(MyInt); + } + if (MyFloat != 0F) { + size += 2 + 4; + } + if (singleNestedMessage_ != null) { + size += 2 + pb::CodedOutputStream.ComputeMessageSize(SingleNestedMessage); + } + return size; + } + + public void MergeFrom(TestFieldOrderings other) { + if (other == null) { + return; + } + if (other.MyString.Length != 0) { + MyString = other.MyString; + } + if (other.MyInt != 0L) { + MyInt = other.MyInt; + } + if (other.MyFloat != 0F) { + MyFloat = other.MyFloat; + } + if (other.singleNestedMessage_ != null) { + if (singleNestedMessage_ == null) { + singleNestedMessage_ = new global::Google.Protobuf.TestProtos.TestFieldOrderings.Types.NestedMessage(); + } + SingleNestedMessage.MergeFrom(other.SingleNestedMessage); + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 8: { + MyInt = input.ReadInt64(); + break; + } + case 90: { + MyString = input.ReadString(); + break; + } + case 813: { + MyFloat = input.ReadFloat(); + break; + } + case 1602: { + if (singleNestedMessage_ == null) { + singleNestedMessage_ = new global::Google.Protobuf.TestProtos.TestFieldOrderings.Types.NestedMessage(); + } + input.ReadMessage(singleNestedMessage_); + break; + } + } + } + } + + #region Nested types + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static partial class Types { + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class NestedMessage : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NestedMessage()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "bb", "oo" }; + private static readonly uint[] _fieldTags = new uint[] { 8, 16 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.TestFieldOrderings.Descriptor.NestedTypes[0]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestFieldOrderings_NestedMessage__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public NestedMessage() { + OnConstruction(); + } + + partial void OnConstruction(); + + public NestedMessage(NestedMessage other) : this() { + oo_ = other.oo_; + bb_ = other.bb_; + } + + public NestedMessage Clone() { + return new NestedMessage(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public const int OoFieldNumber = 2; + private long oo_; + public long Oo { + get { return oo_; } + set { + pb::Freezable.CheckMutable(this); + oo_ = value; + } + } + + public const int BbFieldNumber = 1; + private int bb_; + public int Bb { + get { return bb_; } + set { + pb::Freezable.CheckMutable(this); + bb_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as NestedMessage); + } + + public bool Equals(NestedMessage other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Oo != other.Oo) return false; + if (Bb != other.Bb) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Oo != 0L) hash ^= Oo.GetHashCode(); + if (Bb != 0) hash ^= Bb.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Bb != 0) { + output.WriteRawTag(8); + output.WriteInt32(Bb); + } + if (Oo != 0L) { + output.WriteRawTag(16); + output.WriteInt64(Oo); + } + } + + public int CalculateSize() { + int size = 0; + if (Oo != 0L) { + size += 1 + pb::CodedOutputStream.ComputeInt64Size(Oo); + } + if (Bb != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Bb); + } + return size; + } + + public void MergeFrom(NestedMessage other) { + if (other == null) { + return; + } + if (other.Oo != 0L) { + Oo = other.Oo; + } + if (other.Bb != 0) { + Bb = other.Bb; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 8: { + Bb = input.ReadInt32(); + break; + } + case 16: { + Oo = input.ReadInt64(); + break; + } + } + } + } + + } + + } + #endregion + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class SparseEnumMessage : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new SparseEnumMessage()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "sparse_enum" }; + private static readonly uint[] _fieldTags = new uint[] { 8 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[12]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_SparseEnumMessage__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public SparseEnumMessage() { + OnConstruction(); + } + + partial void OnConstruction(); + + public SparseEnumMessage(SparseEnumMessage other) : this() { + sparseEnum_ = other.sparseEnum_; + } + + public SparseEnumMessage Clone() { + return new SparseEnumMessage(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public const int SparseEnumFieldNumber = 1; + private global::Google.Protobuf.TestProtos.TestSparseEnum sparseEnum_ = global::Google.Protobuf.TestProtos.TestSparseEnum.TEST_SPARSE_ENUM_UNSPECIFIED; + public global::Google.Protobuf.TestProtos.TestSparseEnum SparseEnum { + get { return sparseEnum_; } + set { + pb::Freezable.CheckMutable(this); + sparseEnum_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as SparseEnumMessage); + } + + public bool Equals(SparseEnumMessage other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (SparseEnum != other.SparseEnum) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (SparseEnum != global::Google.Protobuf.TestProtos.TestSparseEnum.TEST_SPARSE_ENUM_UNSPECIFIED) hash ^= SparseEnum.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (SparseEnum != global::Google.Protobuf.TestProtos.TestSparseEnum.TEST_SPARSE_ENUM_UNSPECIFIED) { + output.WriteRawTag(8); + output.WriteEnum((int) SparseEnum); + } + } + + public int CalculateSize() { + int size = 0; + if (SparseEnum != global::Google.Protobuf.TestProtos.TestSparseEnum.TEST_SPARSE_ENUM_UNSPECIFIED) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) SparseEnum); + } + return size; + } + + public void MergeFrom(SparseEnumMessage other) { + if (other == null) { + return; + } + if (other.SparseEnum != global::Google.Protobuf.TestProtos.TestSparseEnum.TEST_SPARSE_ENUM_UNSPECIFIED) { + SparseEnum = other.SparseEnum; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 8: { + sparseEnum_ = (global::Google.Protobuf.TestProtos.TestSparseEnum) input.ReadEnum(); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class OneString : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new OneString()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "data" }; + private static readonly uint[] _fieldTags = new uint[] { 10 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[13]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_OneString__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public OneString() { + OnConstruction(); + } + + partial void OnConstruction(); + + public OneString(OneString other) : this() { + data_ = other.data_; + } + + public OneString Clone() { + return new OneString(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public const int DataFieldNumber = 1; + private string data_ = ""; + public string Data { + get { return data_; } + set { + pb::Freezable.CheckMutable(this); + data_ = value ?? ""; + } + } + + public override bool Equals(object other) { + return Equals(other as OneString); + } + + public bool Equals(OneString other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Data != other.Data) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Data.Length != 0) hash ^= Data.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Data.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Data); + } + } + + public int CalculateSize() { + int size = 0; + if (Data.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Data); + } + return size; + } + + public void MergeFrom(OneString other) { + if (other == null) { + return; + } + if (other.Data.Length != 0) { + Data = other.Data; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + Data = input.ReadString(); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class MoreString : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MoreString()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "data" }; + private static readonly uint[] _fieldTags = new uint[] { 10 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[14]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_MoreString__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public MoreString() { + OnConstruction(); + } + + partial void OnConstruction(); + + public MoreString(MoreString other) : this() { + data_ = other.data_.Clone(); + } + + public MoreString Clone() { + return new MoreString(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + data_.Freeze(); + } + + public const int DataFieldNumber = 1; + private static readonly pb::FieldCodec _repeated_data_codec + = pb::FieldCodec.ForString(10); + private readonly pbc::RepeatedField data_ = new pbc::RepeatedField(); + public pbc::RepeatedField Data { + get { return data_; } + } + + public override bool Equals(object other) { + return Equals(other as MoreString); + } + + public bool Equals(MoreString other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if(!data_.Equals(other.data_)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + hash ^= data_.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + data_.WriteTo(output, _repeated_data_codec); + } + + public int CalculateSize() { + int size = 0; + size += data_.CalculateSize(_repeated_data_codec); + return size; + } + + public void MergeFrom(MoreString other) { + if (other == null) { + return; + } + data_.Add(other.data_); + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + data_.AddEntriesFrom(input, _repeated_data_codec); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class OneBytes : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new OneBytes()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "data" }; + private static readonly uint[] _fieldTags = new uint[] { 10 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[15]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_OneBytes__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public OneBytes() { + OnConstruction(); + } + + partial void OnConstruction(); + + public OneBytes(OneBytes other) : this() { + data_ = other.data_; + } + + public OneBytes Clone() { + return new OneBytes(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public const int DataFieldNumber = 1; + private pb::ByteString data_ = pb::ByteString.Empty; + public pb::ByteString Data { + get { return data_; } + set { + pb::Freezable.CheckMutable(this); + data_ = value ?? pb::ByteString.Empty; + } + } + + public override bool Equals(object other) { + return Equals(other as OneBytes); + } + + public bool Equals(OneBytes other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Data != other.Data) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Data.Length != 0) hash ^= Data.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Data.Length != 0) { + output.WriteRawTag(10); + output.WriteBytes(Data); + } + } + + public int CalculateSize() { + int size = 0; + if (Data.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeBytesSize(Data); + } + return size; + } + + public void MergeFrom(OneBytes other) { + if (other == null) { + return; + } + if (other.Data.Length != 0) { + Data = other.Data; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + Data = input.ReadBytes(); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class MoreBytes : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MoreBytes()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "data" }; + private static readonly uint[] _fieldTags = new uint[] { 10 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[16]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_MoreBytes__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public MoreBytes() { + OnConstruction(); + } + + partial void OnConstruction(); + + public MoreBytes(MoreBytes other) : this() { + data_ = other.data_; + } + + public MoreBytes Clone() { + return new MoreBytes(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public const int DataFieldNumber = 1; + private pb::ByteString data_ = pb::ByteString.Empty; + public pb::ByteString Data { + get { return data_; } + set { + pb::Freezable.CheckMutable(this); + data_ = value ?? pb::ByteString.Empty; + } + } + + public override bool Equals(object other) { + return Equals(other as MoreBytes); + } + + public bool Equals(MoreBytes other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Data != other.Data) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Data.Length != 0) hash ^= Data.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Data.Length != 0) { + output.WriteRawTag(10); + output.WriteBytes(Data); + } + } + + public int CalculateSize() { + int size = 0; + if (Data.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeBytesSize(Data); + } + return size; + } + + public void MergeFrom(MoreBytes other) { + if (other == null) { + return; + } + if (other.Data.Length != 0) { + Data = other.Data; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + Data = input.ReadBytes(); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class Int32Message : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Int32Message()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "data" }; + private static readonly uint[] _fieldTags = new uint[] { 8 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[17]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_Int32Message__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public Int32Message() { + OnConstruction(); + } + + partial void OnConstruction(); + + public Int32Message(Int32Message other) : this() { + data_ = other.data_; + } + + public Int32Message Clone() { + return new Int32Message(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public const int DataFieldNumber = 1; + private int data_; + public int Data { + get { return data_; } + set { + pb::Freezable.CheckMutable(this); + data_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as Int32Message); + } + + public bool Equals(Int32Message other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Data != other.Data) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Data != 0) hash ^= Data.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Data != 0) { + output.WriteRawTag(8); + output.WriteInt32(Data); + } + } + + public int CalculateSize() { + int size = 0; + if (Data != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Data); + } + return size; + } + + public void MergeFrom(Int32Message other) { + if (other == null) { + return; + } + if (other.Data != 0) { + Data = other.Data; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 8: { + Data = input.ReadInt32(); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class Uint32Message : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Uint32Message()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "data" }; + private static readonly uint[] _fieldTags = new uint[] { 8 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[18]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_Uint32Message__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public Uint32Message() { + OnConstruction(); + } + + partial void OnConstruction(); + + public Uint32Message(Uint32Message other) : this() { + data_ = other.data_; + } + + public Uint32Message Clone() { + return new Uint32Message(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public const int DataFieldNumber = 1; + private uint data_; + public uint Data { + get { return data_; } + set { + pb::Freezable.CheckMutable(this); + data_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as Uint32Message); + } + + public bool Equals(Uint32Message other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Data != other.Data) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Data != 0) hash ^= Data.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Data != 0) { + output.WriteRawTag(8); + output.WriteUInt32(Data); + } + } + + public int CalculateSize() { + int size = 0; + if (Data != 0) { + size += 1 + pb::CodedOutputStream.ComputeUInt32Size(Data); + } + return size; + } + + public void MergeFrom(Uint32Message other) { + if (other == null) { + return; + } + if (other.Data != 0) { + Data = other.Data; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 8: { + Data = input.ReadUInt32(); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class Int64Message : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Int64Message()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "data" }; + private static readonly uint[] _fieldTags = new uint[] { 8 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[19]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_Int64Message__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public Int64Message() { + OnConstruction(); + } + + partial void OnConstruction(); + + public Int64Message(Int64Message other) : this() { + data_ = other.data_; + } + + public Int64Message Clone() { + return new Int64Message(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public const int DataFieldNumber = 1; + private long data_; + public long Data { + get { return data_; } + set { + pb::Freezable.CheckMutable(this); + data_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as Int64Message); + } + + public bool Equals(Int64Message other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Data != other.Data) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Data != 0L) hash ^= Data.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Data != 0L) { + output.WriteRawTag(8); + output.WriteInt64(Data); + } + } + + public int CalculateSize() { + int size = 0; + if (Data != 0L) { + size += 1 + pb::CodedOutputStream.ComputeInt64Size(Data); + } + return size; + } + + public void MergeFrom(Int64Message other) { + if (other == null) { + return; + } + if (other.Data != 0L) { + Data = other.Data; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 8: { + Data = input.ReadInt64(); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class Uint64Message : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Uint64Message()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "data" }; + private static readonly uint[] _fieldTags = new uint[] { 8 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[20]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_Uint64Message__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public Uint64Message() { + OnConstruction(); + } + + partial void OnConstruction(); + + public Uint64Message(Uint64Message other) : this() { + data_ = other.data_; + } + + public Uint64Message Clone() { + return new Uint64Message(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public const int DataFieldNumber = 1; + private ulong data_; + public ulong Data { + get { return data_; } + set { + pb::Freezable.CheckMutable(this); + data_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as Uint64Message); + } + + public bool Equals(Uint64Message other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Data != other.Data) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Data != 0UL) hash ^= Data.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Data != 0UL) { + output.WriteRawTag(8); + output.WriteUInt64(Data); + } + } + + public int CalculateSize() { + int size = 0; + if (Data != 0UL) { + size += 1 + pb::CodedOutputStream.ComputeUInt64Size(Data); + } + return size; + } + + public void MergeFrom(Uint64Message other) { + if (other == null) { + return; + } + if (other.Data != 0UL) { + Data = other.Data; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 8: { + Data = input.ReadUInt64(); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class BoolMessage : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new BoolMessage()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "data" }; + private static readonly uint[] _fieldTags = new uint[] { 8 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[21]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_BoolMessage__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public BoolMessage() { + OnConstruction(); + } + + partial void OnConstruction(); + + public BoolMessage(BoolMessage other) : this() { + data_ = other.data_; + } + + public BoolMessage Clone() { + return new BoolMessage(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public const int DataFieldNumber = 1; + private bool data_; + public bool Data { + get { return data_; } + set { + pb::Freezable.CheckMutable(this); + data_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as BoolMessage); + } + + public bool Equals(BoolMessage other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Data != other.Data) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Data != false) hash ^= Data.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Data != false) { + output.WriteRawTag(8); + output.WriteBool(Data); + } + } + + public int CalculateSize() { + int size = 0; + if (Data != false) { + size += 1 + 1; + } + return size; + } + + public void MergeFrom(BoolMessage other) { + if (other == null) { + return; + } + if (other.Data != false) { + Data = other.Data; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 8: { + Data = input.ReadBool(); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class TestOneof : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestOneof()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "foo_int", "foo_message", "foo_string" }; + private static readonly uint[] _fieldTags = new uint[] { 8, 26, 18 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[22]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestOneof__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public TestOneof() { + OnConstruction(); + } + + partial void OnConstruction(); + + public TestOneof(TestOneof other) : this() { + switch (other.FooCase) { + case FooOneofCase.FooInt: + FooInt = other.FooInt; + break; + case FooOneofCase.FooString: + FooString = other.FooString; + break; + case FooOneofCase.FooMessage: + FooMessage = other.FooMessage.Clone(); + break; + } + + } + + public TestOneof Clone() { + return new TestOneof(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + if (foo_ is IFreezable) ((IFreezable) foo_).Freeze(); + } + + public const int FooIntFieldNumber = 1; + public int FooInt { + get { return fooCase_ == FooOneofCase.FooInt ? (int) foo_ : 0; } + set { + pb::Freezable.CheckMutable(this); + foo_ = value; + fooCase_ = FooOneofCase.FooInt; + } + } + + public const int FooStringFieldNumber = 2; + public string FooString { + get { return fooCase_ == FooOneofCase.FooString ? (string) foo_ : ""; } + set { + pb::Freezable.CheckMutable(this); + foo_ = value ?? ""; + fooCase_ = FooOneofCase.FooString; + } + } + + public const int FooMessageFieldNumber = 3; + public global::Google.Protobuf.TestProtos.TestAllTypes FooMessage { + get { return fooCase_ == FooOneofCase.FooMessage ? (global::Google.Protobuf.TestProtos.TestAllTypes) foo_ : null; } + set { + pb::Freezable.CheckMutable(this); + foo_ = value; + fooCase_ = value == null ? FooOneofCase.None : FooOneofCase.FooMessage; + } + } + + private object foo_; + public enum FooOneofCase { + None = 0, + FooInt = 1, + FooString = 2, + FooMessage = 3, + } + private FooOneofCase fooCase_ = FooOneofCase.None; + public FooOneofCase FooCase { + get { return fooCase_; } + } + + public void ClearFoo() { + pb::Freezable.CheckMutable(this); + fooCase_ = FooOneofCase.None; + foo_ = null; + } + + public override bool Equals(object other) { + return Equals(other as TestOneof); + } + + public bool Equals(TestOneof other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (FooInt != other.FooInt) return false; + if (FooString != other.FooString) return false; + if (!object.Equals(FooMessage, other.FooMessage)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (fooCase_ == FooOneofCase.FooInt) hash ^= FooInt.GetHashCode(); + if (fooCase_ == FooOneofCase.FooString) hash ^= FooString.GetHashCode(); + if (fooCase_ == FooOneofCase.FooMessage) hash ^= FooMessage.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream 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); + } + } + + public int CalculateSize() { + int size = 0; + if (fooCase_ == FooOneofCase.FooInt) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(FooInt); + } + if (fooCase_ == FooOneofCase.FooString) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(FooString); + } + if (fooCase_ == FooOneofCase.FooMessage) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(FooMessage); + } + return size; + } + + public void MergeFrom(TestOneof other) { + if (other == null) { + return; + } + switch (other.FooCase) { + case FooOneofCase.FooInt: + FooInt = other.FooInt; + break; + case FooOneofCase.FooString: + FooString = other.FooString; + break; + case FooOneofCase.FooMessage: + FooMessage = other.FooMessage; + break; + } + + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + 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; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class TestPackedTypes : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestPackedTypes()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "packed_bool", "packed_double", "packed_enum", "packed_fixed32", "packed_fixed64", "packed_float", "packed_int32", "packed_int64", "packed_sfixed32", "packed_sfixed64", "packed_sint32", "packed_sint64", "packed_uint32", "packed_uint64" }; + private static readonly uint[] _fieldTags = new uint[] { 818, 810, 826, 770, 778, 802, 722, 730, 786, 794, 754, 762, 738, 746 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[23]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestPackedTypes__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public TestPackedTypes() { + OnConstruction(); + } + + partial void OnConstruction(); + + public TestPackedTypes(TestPackedTypes other) : this() { + packedInt32_ = other.packedInt32_.Clone(); + packedInt64_ = other.packedInt64_.Clone(); + packedUint32_ = other.packedUint32_.Clone(); + packedUint64_ = other.packedUint64_.Clone(); + packedSint32_ = other.packedSint32_.Clone(); + packedSint64_ = other.packedSint64_.Clone(); + packedFixed32_ = other.packedFixed32_.Clone(); + packedFixed64_ = other.packedFixed64_.Clone(); + packedSfixed32_ = other.packedSfixed32_.Clone(); + packedSfixed64_ = other.packedSfixed64_.Clone(); + packedFloat_ = other.packedFloat_.Clone(); + packedDouble_ = other.packedDouble_.Clone(); + packedBool_ = other.packedBool_.Clone(); + packedEnum_ = other.packedEnum_.Clone(); + } + + public TestPackedTypes Clone() { + return new TestPackedTypes(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + packedInt32_.Freeze(); + packedInt64_.Freeze(); + packedUint32_.Freeze(); + packedUint64_.Freeze(); + packedSint32_.Freeze(); + packedSint64_.Freeze(); + packedFixed32_.Freeze(); + packedFixed64_.Freeze(); + packedSfixed32_.Freeze(); + packedSfixed64_.Freeze(); + packedFloat_.Freeze(); + packedDouble_.Freeze(); + packedBool_.Freeze(); + packedEnum_.Freeze(); + } + + public const int PackedInt32FieldNumber = 90; + private static readonly pb::FieldCodec _repeated_packedInt32_codec + = pb::FieldCodec.ForInt32(722); + private readonly pbc::RepeatedField packedInt32_ = new pbc::RepeatedField(); + public pbc::RepeatedField PackedInt32 { + get { return packedInt32_; } + } + + public const int PackedInt64FieldNumber = 91; + private static readonly pb::FieldCodec _repeated_packedInt64_codec + = pb::FieldCodec.ForInt64(730); + private readonly pbc::RepeatedField packedInt64_ = new pbc::RepeatedField(); + public pbc::RepeatedField PackedInt64 { + get { return packedInt64_; } + } + + public const int PackedUint32FieldNumber = 92; + private static readonly pb::FieldCodec _repeated_packedUint32_codec + = pb::FieldCodec.ForUInt32(738); + private readonly pbc::RepeatedField packedUint32_ = new pbc::RepeatedField(); + public pbc::RepeatedField PackedUint32 { + get { return packedUint32_; } + } + + public const int PackedUint64FieldNumber = 93; + private static readonly pb::FieldCodec _repeated_packedUint64_codec + = pb::FieldCodec.ForUInt64(746); + private readonly pbc::RepeatedField packedUint64_ = new pbc::RepeatedField(); + public pbc::RepeatedField PackedUint64 { + get { return packedUint64_; } + } + + public const int PackedSint32FieldNumber = 94; + private static readonly pb::FieldCodec _repeated_packedSint32_codec + = pb::FieldCodec.ForSInt32(754); + private readonly pbc::RepeatedField packedSint32_ = new pbc::RepeatedField(); + public pbc::RepeatedField PackedSint32 { + get { return packedSint32_; } + } + + public const int PackedSint64FieldNumber = 95; + private static readonly pb::FieldCodec _repeated_packedSint64_codec + = pb::FieldCodec.ForSInt64(762); + private readonly pbc::RepeatedField packedSint64_ = new pbc::RepeatedField(); + public pbc::RepeatedField PackedSint64 { + get { return packedSint64_; } + } + + public const int PackedFixed32FieldNumber = 96; + private static readonly pb::FieldCodec _repeated_packedFixed32_codec + = pb::FieldCodec.ForFixed32(770); + private readonly pbc::RepeatedField packedFixed32_ = new pbc::RepeatedField(); + public pbc::RepeatedField PackedFixed32 { + get { return packedFixed32_; } + } + + public const int PackedFixed64FieldNumber = 97; + private static readonly pb::FieldCodec _repeated_packedFixed64_codec + = pb::FieldCodec.ForFixed64(778); + private readonly pbc::RepeatedField packedFixed64_ = new pbc::RepeatedField(); + public pbc::RepeatedField PackedFixed64 { + get { return packedFixed64_; } + } + + public const int PackedSfixed32FieldNumber = 98; + private static readonly pb::FieldCodec _repeated_packedSfixed32_codec + = pb::FieldCodec.ForSFixed32(786); + private readonly pbc::RepeatedField packedSfixed32_ = new pbc::RepeatedField(); + public pbc::RepeatedField PackedSfixed32 { + get { return packedSfixed32_; } + } + + public const int PackedSfixed64FieldNumber = 99; + private static readonly pb::FieldCodec _repeated_packedSfixed64_codec + = pb::FieldCodec.ForSFixed64(794); + private readonly pbc::RepeatedField packedSfixed64_ = new pbc::RepeatedField(); + public pbc::RepeatedField PackedSfixed64 { + get { return packedSfixed64_; } + } + + public const int PackedFloatFieldNumber = 100; + private static readonly pb::FieldCodec _repeated_packedFloat_codec + = pb::FieldCodec.ForFloat(802); + private readonly pbc::RepeatedField packedFloat_ = new pbc::RepeatedField(); + public pbc::RepeatedField PackedFloat { + get { return packedFloat_; } + } + + public const int PackedDoubleFieldNumber = 101; + private static readonly pb::FieldCodec _repeated_packedDouble_codec + = pb::FieldCodec.ForDouble(810); + private readonly pbc::RepeatedField packedDouble_ = new pbc::RepeatedField(); + public pbc::RepeatedField PackedDouble { + get { return packedDouble_; } + } + + public const int PackedBoolFieldNumber = 102; + private static readonly pb::FieldCodec _repeated_packedBool_codec + = pb::FieldCodec.ForBool(818); + private readonly pbc::RepeatedField packedBool_ = new pbc::RepeatedField(); + public pbc::RepeatedField PackedBool { + get { return packedBool_; } + } + + public const int PackedEnumFieldNumber = 103; + private static readonly pb::FieldCodec _repeated_packedEnum_codec + = pb::FieldCodec.ForEnum(826, x => (int) x, x => (global::Google.Protobuf.TestProtos.ForeignEnum) x);private readonly pbc::RepeatedField packedEnum_ = new pbc::RepeatedField(); + public pbc::RepeatedField PackedEnum { + get { return packedEnum_; } + } + + public override bool Equals(object other) { + return Equals(other as TestPackedTypes); + } + + public bool Equals(TestPackedTypes other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if(!packedInt32_.Equals(other.packedInt32_)) return false; + if(!packedInt64_.Equals(other.packedInt64_)) return false; + if(!packedUint32_.Equals(other.packedUint32_)) return false; + if(!packedUint64_.Equals(other.packedUint64_)) return false; + if(!packedSint32_.Equals(other.packedSint32_)) return false; + if(!packedSint64_.Equals(other.packedSint64_)) return false; + if(!packedFixed32_.Equals(other.packedFixed32_)) return false; + if(!packedFixed64_.Equals(other.packedFixed64_)) return false; + if(!packedSfixed32_.Equals(other.packedSfixed32_)) return false; + if(!packedSfixed64_.Equals(other.packedSfixed64_)) return false; + if(!packedFloat_.Equals(other.packedFloat_)) return false; + if(!packedDouble_.Equals(other.packedDouble_)) return false; + if(!packedBool_.Equals(other.packedBool_)) return false; + if(!packedEnum_.Equals(other.packedEnum_)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + hash ^= packedInt32_.GetHashCode(); + hash ^= packedInt64_.GetHashCode(); + hash ^= packedUint32_.GetHashCode(); + hash ^= packedUint64_.GetHashCode(); + hash ^= packedSint32_.GetHashCode(); + hash ^= packedSint64_.GetHashCode(); + hash ^= packedFixed32_.GetHashCode(); + hash ^= packedFixed64_.GetHashCode(); + hash ^= packedSfixed32_.GetHashCode(); + hash ^= packedSfixed64_.GetHashCode(); + hash ^= packedFloat_.GetHashCode(); + hash ^= packedDouble_.GetHashCode(); + hash ^= packedBool_.GetHashCode(); + hash ^= packedEnum_.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + packedInt32_.WriteTo(output, _repeated_packedInt32_codec); + packedInt64_.WriteTo(output, _repeated_packedInt64_codec); + packedUint32_.WriteTo(output, _repeated_packedUint32_codec); + packedUint64_.WriteTo(output, _repeated_packedUint64_codec); + packedSint32_.WriteTo(output, _repeated_packedSint32_codec); + packedSint64_.WriteTo(output, _repeated_packedSint64_codec); + packedFixed32_.WriteTo(output, _repeated_packedFixed32_codec); + packedFixed64_.WriteTo(output, _repeated_packedFixed64_codec); + packedSfixed32_.WriteTo(output, _repeated_packedSfixed32_codec); + packedSfixed64_.WriteTo(output, _repeated_packedSfixed64_codec); + packedFloat_.WriteTo(output, _repeated_packedFloat_codec); + packedDouble_.WriteTo(output, _repeated_packedDouble_codec); + packedBool_.WriteTo(output, _repeated_packedBool_codec); + packedEnum_.WriteTo(output, _repeated_packedEnum_codec); + } + + public int CalculateSize() { + int size = 0; + size += packedInt32_.CalculateSize(_repeated_packedInt32_codec); + size += packedInt64_.CalculateSize(_repeated_packedInt64_codec); + size += packedUint32_.CalculateSize(_repeated_packedUint32_codec); + size += packedUint64_.CalculateSize(_repeated_packedUint64_codec); + size += packedSint32_.CalculateSize(_repeated_packedSint32_codec); + size += packedSint64_.CalculateSize(_repeated_packedSint64_codec); + size += packedFixed32_.CalculateSize(_repeated_packedFixed32_codec); + size += packedFixed64_.CalculateSize(_repeated_packedFixed64_codec); + size += packedSfixed32_.CalculateSize(_repeated_packedSfixed32_codec); + size += packedSfixed64_.CalculateSize(_repeated_packedSfixed64_codec); + size += packedFloat_.CalculateSize(_repeated_packedFloat_codec); + size += packedDouble_.CalculateSize(_repeated_packedDouble_codec); + size += packedBool_.CalculateSize(_repeated_packedBool_codec); + size += packedEnum_.CalculateSize(_repeated_packedEnum_codec); + return size; + } + + public void MergeFrom(TestPackedTypes other) { + if (other == null) { + return; + } + packedInt32_.Add(other.packedInt32_); + packedInt64_.Add(other.packedInt64_); + packedUint32_.Add(other.packedUint32_); + packedUint64_.Add(other.packedUint64_); + packedSint32_.Add(other.packedSint32_); + packedSint64_.Add(other.packedSint64_); + packedFixed32_.Add(other.packedFixed32_); + packedFixed64_.Add(other.packedFixed64_); + packedSfixed32_.Add(other.packedSfixed32_); + packedSfixed64_.Add(other.packedSfixed64_); + packedFloat_.Add(other.packedFloat_); + packedDouble_.Add(other.packedDouble_); + packedBool_.Add(other.packedBool_); + packedEnum_.Add(other.packedEnum_); + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 722: + case 720: { + packedInt32_.AddEntriesFrom(input, _repeated_packedInt32_codec); + break; + } + case 730: + case 728: { + packedInt64_.AddEntriesFrom(input, _repeated_packedInt64_codec); + break; + } + case 738: + case 736: { + packedUint32_.AddEntriesFrom(input, _repeated_packedUint32_codec); + break; + } + case 746: + case 744: { + packedUint64_.AddEntriesFrom(input, _repeated_packedUint64_codec); + break; + } + case 754: + case 752: { + packedSint32_.AddEntriesFrom(input, _repeated_packedSint32_codec); + break; + } + case 762: + case 760: { + packedSint64_.AddEntriesFrom(input, _repeated_packedSint64_codec); + break; + } + case 770: + case 773: { + packedFixed32_.AddEntriesFrom(input, _repeated_packedFixed32_codec); + break; + } + case 778: + case 777: { + packedFixed64_.AddEntriesFrom(input, _repeated_packedFixed64_codec); + break; + } + case 786: + case 789: { + packedSfixed32_.AddEntriesFrom(input, _repeated_packedSfixed32_codec); + break; + } + case 794: + case 793: { + packedSfixed64_.AddEntriesFrom(input, _repeated_packedSfixed64_codec); + break; + } + case 802: + case 805: { + packedFloat_.AddEntriesFrom(input, _repeated_packedFloat_codec); + break; + } + case 810: + case 809: { + packedDouble_.AddEntriesFrom(input, _repeated_packedDouble_codec); + break; + } + case 818: + case 816: { + packedBool_.AddEntriesFrom(input, _repeated_packedBool_codec); + break; + } + case 826: + case 824: { + packedEnum_.AddEntriesFrom(input, _repeated_packedEnum_codec); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class TestUnpackedTypes : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestUnpackedTypes()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "unpacked_bool", "unpacked_double", "unpacked_enum", "unpacked_fixed32", "unpacked_fixed64", "unpacked_float", "unpacked_int32", "unpacked_int64", "unpacked_sfixed32", "unpacked_sfixed64", "unpacked_sint32", "unpacked_sint64", "unpacked_uint32", "unpacked_uint64" }; + private static readonly uint[] _fieldTags = new uint[] { 816, 809, 824, 773, 777, 805, 720, 728, 789, 793, 752, 760, 736, 744 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[24]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestUnpackedTypes__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public TestUnpackedTypes() { + OnConstruction(); + } + + partial void OnConstruction(); + + public TestUnpackedTypes(TestUnpackedTypes other) : this() { + unpackedInt32_ = other.unpackedInt32_.Clone(); + unpackedInt64_ = other.unpackedInt64_.Clone(); + unpackedUint32_ = other.unpackedUint32_.Clone(); + unpackedUint64_ = other.unpackedUint64_.Clone(); + unpackedSint32_ = other.unpackedSint32_.Clone(); + unpackedSint64_ = other.unpackedSint64_.Clone(); + unpackedFixed32_ = other.unpackedFixed32_.Clone(); + unpackedFixed64_ = other.unpackedFixed64_.Clone(); + unpackedSfixed32_ = other.unpackedSfixed32_.Clone(); + unpackedSfixed64_ = other.unpackedSfixed64_.Clone(); + unpackedFloat_ = other.unpackedFloat_.Clone(); + unpackedDouble_ = other.unpackedDouble_.Clone(); + unpackedBool_ = other.unpackedBool_.Clone(); + unpackedEnum_ = other.unpackedEnum_.Clone(); + } + + public TestUnpackedTypes Clone() { + return new TestUnpackedTypes(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + unpackedInt32_.Freeze(); + unpackedInt64_.Freeze(); + unpackedUint32_.Freeze(); + unpackedUint64_.Freeze(); + unpackedSint32_.Freeze(); + unpackedSint64_.Freeze(); + unpackedFixed32_.Freeze(); + unpackedFixed64_.Freeze(); + unpackedSfixed32_.Freeze(); + unpackedSfixed64_.Freeze(); + unpackedFloat_.Freeze(); + unpackedDouble_.Freeze(); + unpackedBool_.Freeze(); + unpackedEnum_.Freeze(); + } + + public const int UnpackedInt32FieldNumber = 90; + private static readonly pb::FieldCodec _repeated_unpackedInt32_codec + = pb::FieldCodec.ForInt32(720); + private readonly pbc::RepeatedField unpackedInt32_ = new pbc::RepeatedField(); + public pbc::RepeatedField UnpackedInt32 { + get { return unpackedInt32_; } + } + + public const int UnpackedInt64FieldNumber = 91; + private static readonly pb::FieldCodec _repeated_unpackedInt64_codec + = pb::FieldCodec.ForInt64(728); + private readonly pbc::RepeatedField unpackedInt64_ = new pbc::RepeatedField(); + public pbc::RepeatedField UnpackedInt64 { + get { return unpackedInt64_; } + } + + public const int UnpackedUint32FieldNumber = 92; + private static readonly pb::FieldCodec _repeated_unpackedUint32_codec + = pb::FieldCodec.ForUInt32(736); + private readonly pbc::RepeatedField unpackedUint32_ = new pbc::RepeatedField(); + public pbc::RepeatedField UnpackedUint32 { + get { return unpackedUint32_; } + } + + public const int UnpackedUint64FieldNumber = 93; + private static readonly pb::FieldCodec _repeated_unpackedUint64_codec + = pb::FieldCodec.ForUInt64(744); + private readonly pbc::RepeatedField unpackedUint64_ = new pbc::RepeatedField(); + public pbc::RepeatedField UnpackedUint64 { + get { return unpackedUint64_; } + } + + public const int UnpackedSint32FieldNumber = 94; + private static readonly pb::FieldCodec _repeated_unpackedSint32_codec + = pb::FieldCodec.ForSInt32(752); + private readonly pbc::RepeatedField unpackedSint32_ = new pbc::RepeatedField(); + public pbc::RepeatedField UnpackedSint32 { + get { return unpackedSint32_; } + } + + public const int UnpackedSint64FieldNumber = 95; + private static readonly pb::FieldCodec _repeated_unpackedSint64_codec + = pb::FieldCodec.ForSInt64(760); + private readonly pbc::RepeatedField unpackedSint64_ = new pbc::RepeatedField(); + public pbc::RepeatedField UnpackedSint64 { + get { return unpackedSint64_; } + } + + public const int UnpackedFixed32FieldNumber = 96; + private static readonly pb::FieldCodec _repeated_unpackedFixed32_codec + = pb::FieldCodec.ForFixed32(773); + private readonly pbc::RepeatedField unpackedFixed32_ = new pbc::RepeatedField(); + public pbc::RepeatedField UnpackedFixed32 { + get { return unpackedFixed32_; } + } + + public const int UnpackedFixed64FieldNumber = 97; + private static readonly pb::FieldCodec _repeated_unpackedFixed64_codec + = pb::FieldCodec.ForFixed64(777); + private readonly pbc::RepeatedField unpackedFixed64_ = new pbc::RepeatedField(); + public pbc::RepeatedField UnpackedFixed64 { + get { return unpackedFixed64_; } + } + + public const int UnpackedSfixed32FieldNumber = 98; + private static readonly pb::FieldCodec _repeated_unpackedSfixed32_codec + = pb::FieldCodec.ForSFixed32(789); + private readonly pbc::RepeatedField unpackedSfixed32_ = new pbc::RepeatedField(); + public pbc::RepeatedField UnpackedSfixed32 { + get { return unpackedSfixed32_; } + } + + public const int UnpackedSfixed64FieldNumber = 99; + private static readonly pb::FieldCodec _repeated_unpackedSfixed64_codec + = pb::FieldCodec.ForSFixed64(793); + private readonly pbc::RepeatedField unpackedSfixed64_ = new pbc::RepeatedField(); + public pbc::RepeatedField UnpackedSfixed64 { + get { return unpackedSfixed64_; } + } + + public const int UnpackedFloatFieldNumber = 100; + private static readonly pb::FieldCodec _repeated_unpackedFloat_codec + = pb::FieldCodec.ForFloat(805); + private readonly pbc::RepeatedField unpackedFloat_ = new pbc::RepeatedField(); + public pbc::RepeatedField UnpackedFloat { + get { return unpackedFloat_; } + } + + public const int UnpackedDoubleFieldNumber = 101; + private static readonly pb::FieldCodec _repeated_unpackedDouble_codec + = pb::FieldCodec.ForDouble(809); + private readonly pbc::RepeatedField unpackedDouble_ = new pbc::RepeatedField(); + public pbc::RepeatedField UnpackedDouble { + get { return unpackedDouble_; } + } + + public const int UnpackedBoolFieldNumber = 102; + private static readonly pb::FieldCodec _repeated_unpackedBool_codec + = pb::FieldCodec.ForBool(816); + private readonly pbc::RepeatedField unpackedBool_ = new pbc::RepeatedField(); + public pbc::RepeatedField UnpackedBool { + get { return unpackedBool_; } + } + + public const int UnpackedEnumFieldNumber = 103; + private static readonly pb::FieldCodec _repeated_unpackedEnum_codec + = pb::FieldCodec.ForEnum(824, x => (int) x, x => (global::Google.Protobuf.TestProtos.ForeignEnum) x);private readonly pbc::RepeatedField unpackedEnum_ = new pbc::RepeatedField(); + public pbc::RepeatedField UnpackedEnum { + get { return unpackedEnum_; } + } + + public override bool Equals(object other) { + return Equals(other as TestUnpackedTypes); + } + + public bool Equals(TestUnpackedTypes other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if(!unpackedInt32_.Equals(other.unpackedInt32_)) return false; + if(!unpackedInt64_.Equals(other.unpackedInt64_)) return false; + if(!unpackedUint32_.Equals(other.unpackedUint32_)) return false; + if(!unpackedUint64_.Equals(other.unpackedUint64_)) return false; + if(!unpackedSint32_.Equals(other.unpackedSint32_)) return false; + if(!unpackedSint64_.Equals(other.unpackedSint64_)) return false; + if(!unpackedFixed32_.Equals(other.unpackedFixed32_)) return false; + if(!unpackedFixed64_.Equals(other.unpackedFixed64_)) return false; + if(!unpackedSfixed32_.Equals(other.unpackedSfixed32_)) return false; + if(!unpackedSfixed64_.Equals(other.unpackedSfixed64_)) return false; + if(!unpackedFloat_.Equals(other.unpackedFloat_)) return false; + if(!unpackedDouble_.Equals(other.unpackedDouble_)) return false; + if(!unpackedBool_.Equals(other.unpackedBool_)) return false; + if(!unpackedEnum_.Equals(other.unpackedEnum_)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + hash ^= unpackedInt32_.GetHashCode(); + hash ^= unpackedInt64_.GetHashCode(); + hash ^= unpackedUint32_.GetHashCode(); + hash ^= unpackedUint64_.GetHashCode(); + hash ^= unpackedSint32_.GetHashCode(); + hash ^= unpackedSint64_.GetHashCode(); + hash ^= unpackedFixed32_.GetHashCode(); + hash ^= unpackedFixed64_.GetHashCode(); + hash ^= unpackedSfixed32_.GetHashCode(); + hash ^= unpackedSfixed64_.GetHashCode(); + hash ^= unpackedFloat_.GetHashCode(); + hash ^= unpackedDouble_.GetHashCode(); + hash ^= unpackedBool_.GetHashCode(); + hash ^= unpackedEnum_.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + unpackedInt32_.WriteTo(output, _repeated_unpackedInt32_codec); + unpackedInt64_.WriteTo(output, _repeated_unpackedInt64_codec); + unpackedUint32_.WriteTo(output, _repeated_unpackedUint32_codec); + unpackedUint64_.WriteTo(output, _repeated_unpackedUint64_codec); + unpackedSint32_.WriteTo(output, _repeated_unpackedSint32_codec); + unpackedSint64_.WriteTo(output, _repeated_unpackedSint64_codec); + unpackedFixed32_.WriteTo(output, _repeated_unpackedFixed32_codec); + unpackedFixed64_.WriteTo(output, _repeated_unpackedFixed64_codec); + unpackedSfixed32_.WriteTo(output, _repeated_unpackedSfixed32_codec); + unpackedSfixed64_.WriteTo(output, _repeated_unpackedSfixed64_codec); + unpackedFloat_.WriteTo(output, _repeated_unpackedFloat_codec); + unpackedDouble_.WriteTo(output, _repeated_unpackedDouble_codec); + unpackedBool_.WriteTo(output, _repeated_unpackedBool_codec); + unpackedEnum_.WriteTo(output, _repeated_unpackedEnum_codec); + } + + public int CalculateSize() { + int size = 0; + size += unpackedInt32_.CalculateSize(_repeated_unpackedInt32_codec); + size += unpackedInt64_.CalculateSize(_repeated_unpackedInt64_codec); + size += unpackedUint32_.CalculateSize(_repeated_unpackedUint32_codec); + size += unpackedUint64_.CalculateSize(_repeated_unpackedUint64_codec); + size += unpackedSint32_.CalculateSize(_repeated_unpackedSint32_codec); + size += unpackedSint64_.CalculateSize(_repeated_unpackedSint64_codec); + size += unpackedFixed32_.CalculateSize(_repeated_unpackedFixed32_codec); + size += unpackedFixed64_.CalculateSize(_repeated_unpackedFixed64_codec); + size += unpackedSfixed32_.CalculateSize(_repeated_unpackedSfixed32_codec); + size += unpackedSfixed64_.CalculateSize(_repeated_unpackedSfixed64_codec); + size += unpackedFloat_.CalculateSize(_repeated_unpackedFloat_codec); + size += unpackedDouble_.CalculateSize(_repeated_unpackedDouble_codec); + size += unpackedBool_.CalculateSize(_repeated_unpackedBool_codec); + size += unpackedEnum_.CalculateSize(_repeated_unpackedEnum_codec); + return size; + } + + public void MergeFrom(TestUnpackedTypes other) { + if (other == null) { + return; + } + unpackedInt32_.Add(other.unpackedInt32_); + unpackedInt64_.Add(other.unpackedInt64_); + unpackedUint32_.Add(other.unpackedUint32_); + unpackedUint64_.Add(other.unpackedUint64_); + unpackedSint32_.Add(other.unpackedSint32_); + unpackedSint64_.Add(other.unpackedSint64_); + unpackedFixed32_.Add(other.unpackedFixed32_); + unpackedFixed64_.Add(other.unpackedFixed64_); + unpackedSfixed32_.Add(other.unpackedSfixed32_); + unpackedSfixed64_.Add(other.unpackedSfixed64_); + unpackedFloat_.Add(other.unpackedFloat_); + unpackedDouble_.Add(other.unpackedDouble_); + unpackedBool_.Add(other.unpackedBool_); + unpackedEnum_.Add(other.unpackedEnum_); + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + 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; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class TestRepeatedScalarDifferentTagSizes : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestRepeatedScalarDifferentTagSizes()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "repeated_fixed32", "repeated_fixed64", "repeated_float", "repeated_int32", "repeated_int64", "repeated_uint64" }; + private static readonly uint[] _fieldTags = new uint[] { 98, 16370, 2097138, 106, 16378, 2097146 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[25]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestRepeatedScalarDifferentTagSizes__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public TestRepeatedScalarDifferentTagSizes() { + OnConstruction(); + } + + partial void OnConstruction(); + + public TestRepeatedScalarDifferentTagSizes(TestRepeatedScalarDifferentTagSizes other) : this() { + repeatedFixed32_ = other.repeatedFixed32_.Clone(); + repeatedInt32_ = other.repeatedInt32_.Clone(); + repeatedFixed64_ = other.repeatedFixed64_.Clone(); + repeatedInt64_ = other.repeatedInt64_.Clone(); + repeatedFloat_ = other.repeatedFloat_.Clone(); + repeatedUint64_ = other.repeatedUint64_.Clone(); + } + + public TestRepeatedScalarDifferentTagSizes Clone() { + return new TestRepeatedScalarDifferentTagSizes(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + repeatedFixed32_.Freeze(); + repeatedInt32_.Freeze(); + repeatedFixed64_.Freeze(); + repeatedInt64_.Freeze(); + repeatedFloat_.Freeze(); + repeatedUint64_.Freeze(); + } + + public const int RepeatedFixed32FieldNumber = 12; + private static readonly pb::FieldCodec _repeated_repeatedFixed32_codec + = pb::FieldCodec.ForFixed32(98); + private readonly pbc::RepeatedField repeatedFixed32_ = new pbc::RepeatedField(); + public pbc::RepeatedField RepeatedFixed32 { + get { return repeatedFixed32_; } + } + + public const int RepeatedInt32FieldNumber = 13; + private static readonly pb::FieldCodec _repeated_repeatedInt32_codec + = pb::FieldCodec.ForInt32(106); + private readonly pbc::RepeatedField repeatedInt32_ = new pbc::RepeatedField(); + public pbc::RepeatedField RepeatedInt32 { + get { return repeatedInt32_; } + } + + public const int RepeatedFixed64FieldNumber = 2046; + private static readonly pb::FieldCodec _repeated_repeatedFixed64_codec + = pb::FieldCodec.ForFixed64(16370); + private readonly pbc::RepeatedField repeatedFixed64_ = new pbc::RepeatedField(); + public pbc::RepeatedField RepeatedFixed64 { + get { return repeatedFixed64_; } + } + + public const int RepeatedInt64FieldNumber = 2047; + private static readonly pb::FieldCodec _repeated_repeatedInt64_codec + = pb::FieldCodec.ForInt64(16378); + private readonly pbc::RepeatedField repeatedInt64_ = new pbc::RepeatedField(); + public pbc::RepeatedField RepeatedInt64 { + get { return repeatedInt64_; } + } + + public const int RepeatedFloatFieldNumber = 262142; + private static readonly pb::FieldCodec _repeated_repeatedFloat_codec + = pb::FieldCodec.ForFloat(2097138); + private readonly pbc::RepeatedField repeatedFloat_ = new pbc::RepeatedField(); + public pbc::RepeatedField RepeatedFloat { + get { return repeatedFloat_; } + } + + public const int RepeatedUint64FieldNumber = 262143; + private static readonly pb::FieldCodec _repeated_repeatedUint64_codec + = pb::FieldCodec.ForUInt64(2097146); + private readonly pbc::RepeatedField repeatedUint64_ = new pbc::RepeatedField(); + public pbc::RepeatedField RepeatedUint64 { + get { return repeatedUint64_; } + } + + public override bool Equals(object other) { + return Equals(other as TestRepeatedScalarDifferentTagSizes); + } + + public bool Equals(TestRepeatedScalarDifferentTagSizes other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if(!repeatedFixed32_.Equals(other.repeatedFixed32_)) return false; + if(!repeatedInt32_.Equals(other.repeatedInt32_)) return false; + if(!repeatedFixed64_.Equals(other.repeatedFixed64_)) return false; + if(!repeatedInt64_.Equals(other.repeatedInt64_)) return false; + if(!repeatedFloat_.Equals(other.repeatedFloat_)) return false; + if(!repeatedUint64_.Equals(other.repeatedUint64_)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + hash ^= repeatedFixed32_.GetHashCode(); + hash ^= repeatedInt32_.GetHashCode(); + hash ^= repeatedFixed64_.GetHashCode(); + hash ^= repeatedInt64_.GetHashCode(); + hash ^= repeatedFloat_.GetHashCode(); + hash ^= repeatedUint64_.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + repeatedFixed32_.WriteTo(output, _repeated_repeatedFixed32_codec); + repeatedInt32_.WriteTo(output, _repeated_repeatedInt32_codec); + repeatedFixed64_.WriteTo(output, _repeated_repeatedFixed64_codec); + repeatedInt64_.WriteTo(output, _repeated_repeatedInt64_codec); + repeatedFloat_.WriteTo(output, _repeated_repeatedFloat_codec); + repeatedUint64_.WriteTo(output, _repeated_repeatedUint64_codec); + } + + public int CalculateSize() { + int size = 0; + size += repeatedFixed32_.CalculateSize(_repeated_repeatedFixed32_codec); + size += repeatedInt32_.CalculateSize(_repeated_repeatedInt32_codec); + size += repeatedFixed64_.CalculateSize(_repeated_repeatedFixed64_codec); + size += repeatedInt64_.CalculateSize(_repeated_repeatedInt64_codec); + size += repeatedFloat_.CalculateSize(_repeated_repeatedFloat_codec); + size += repeatedUint64_.CalculateSize(_repeated_repeatedUint64_codec); + return size; + } + + public void MergeFrom(TestRepeatedScalarDifferentTagSizes other) { + if (other == null) { + return; + } + repeatedFixed32_.Add(other.repeatedFixed32_); + repeatedInt32_.Add(other.repeatedInt32_); + repeatedFixed64_.Add(other.repeatedFixed64_); + repeatedInt64_.Add(other.repeatedInt64_); + repeatedFloat_.Add(other.repeatedFloat_); + repeatedUint64_.Add(other.repeatedUint64_); + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 98: + case 101: { + repeatedFixed32_.AddEntriesFrom(input, _repeated_repeatedFixed32_codec); + break; + } + case 106: + case 104: { + repeatedInt32_.AddEntriesFrom(input, _repeated_repeatedInt32_codec); + break; + } + case 16370: + case 16369: { + repeatedFixed64_.AddEntriesFrom(input, _repeated_repeatedFixed64_codec); + break; + } + case 16378: + case 16376: { + repeatedInt64_.AddEntriesFrom(input, _repeated_repeatedInt64_codec); + break; + } + case 2097138: + case 2097141: { + repeatedFloat_.AddEntriesFrom(input, _repeated_repeatedFloat_codec); + break; + } + case 2097146: + case 2097144: { + repeatedUint64_.AddEntriesFrom(input, _repeated_repeatedUint64_codec); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class TestCommentInjectionMessage : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestCommentInjectionMessage()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "a" }; + private static readonly uint[] _fieldTags = new uint[] { 10 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[26]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_TestCommentInjectionMessage__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public TestCommentInjectionMessage() { + OnConstruction(); + } + + partial void OnConstruction(); + + public TestCommentInjectionMessage(TestCommentInjectionMessage other) : this() { + a_ = other.a_; + } + + public TestCommentInjectionMessage Clone() { + return new TestCommentInjectionMessage(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public const int AFieldNumber = 1; + private string a_ = ""; + public string A { + get { return a_; } + set { + pb::Freezable.CheckMutable(this); + a_ = value ?? ""; + } + } + + public override bool Equals(object other) { + return Equals(other as TestCommentInjectionMessage); + } + + public bool Equals(TestCommentInjectionMessage other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (A != other.A) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (A.Length != 0) hash ^= A.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (A.Length != 0) { + output.WriteRawTag(10); + output.WriteString(A); + } + } + + public int CalculateSize() { + int size = 0; + if (A.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(A); + } + return size; + } + + public void MergeFrom(TestCommentInjectionMessage other) { + if (other == null) { + return; + } + if (other.A.Length != 0) { + A = other.A; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + A = input.ReadString(); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class FooRequest : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FooRequest()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { }; + private static readonly uint[] _fieldTags = new uint[] { }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[27]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_FooRequest__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public FooRequest() { + OnConstruction(); + } + + partial void OnConstruction(); + + public FooRequest(FooRequest other) : this() { + } + + public FooRequest Clone() { + return new FooRequest(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public override bool Equals(object other) { + return Equals(other as FooRequest); + } + + public bool Equals(FooRequest other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + return true; + } + + public override int GetHashCode() { + int hash = 1; + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + } + + public int CalculateSize() { + int size = 0; + return size; + } + + public void MergeFrom(FooRequest other) { + if (other == null) { + return; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class FooResponse : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FooResponse()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { }; + private static readonly uint[] _fieldTags = new uint[] { }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[28]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_FooResponse__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public FooResponse() { + OnConstruction(); + } + + partial void OnConstruction(); + + public FooResponse(FooResponse other) : this() { + } + + public FooResponse Clone() { + return new FooResponse(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public override bool Equals(object other) { + return Equals(other as FooResponse); + } + + public bool Equals(FooResponse other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + return true; + } + + public override int GetHashCode() { + int hash = 1; + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + } + + public int CalculateSize() { + int size = 0; + return size; + } + + public void MergeFrom(FooResponse other) { + if (other == null) { + return; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class FooClientMessage : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FooClientMessage()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { }; + private static readonly uint[] _fieldTags = new uint[] { }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[29]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_FooClientMessage__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public FooClientMessage() { + OnConstruction(); + } + + partial void OnConstruction(); + + public FooClientMessage(FooClientMessage other) : this() { + } + + public FooClientMessage Clone() { + return new FooClientMessage(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public override bool Equals(object other) { + return Equals(other as FooClientMessage); + } + + public bool Equals(FooClientMessage other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + return true; + } + + public override int GetHashCode() { + int hash = 1; + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + } + + public int CalculateSize() { + int size = 0; + return size; + } + + public void MergeFrom(FooClientMessage other) { + if (other == null) { + return; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class FooServerMessage : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FooServerMessage()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { }; + private static readonly uint[] _fieldTags = new uint[] { }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[30]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_FooServerMessage__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public FooServerMessage() { + OnConstruction(); + } + + partial void OnConstruction(); + + public FooServerMessage(FooServerMessage other) : this() { + } + + public FooServerMessage Clone() { + return new FooServerMessage(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public override bool Equals(object other) { + return Equals(other as FooServerMessage); + } + + public bool Equals(FooServerMessage other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + return true; + } + + public override int GetHashCode() { + int hash = 1; + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + } + + public int CalculateSize() { + int size = 0; + return size; + } + + public void MergeFrom(FooServerMessage other) { + if (other == null) { + return; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class BarRequest : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new BarRequest()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { }; + private static readonly uint[] _fieldTags = new uint[] { }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[31]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_BarRequest__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public BarRequest() { + OnConstruction(); + } + + partial void OnConstruction(); + + public BarRequest(BarRequest other) : this() { + } + + public BarRequest Clone() { + return new BarRequest(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public override bool Equals(object other) { + return Equals(other as BarRequest); + } + + public bool Equals(BarRequest other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + return true; + } + + public override int GetHashCode() { + int hash = 1; + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + } + + public int CalculateSize() { + int size = 0; + return size; + } + + public void MergeFrom(BarRequest other) { + if (other == null) { + return; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class BarResponse : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new BarResponse()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { }; + private static readonly uint[] _fieldTags = new uint[] { }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.Descriptor.MessageTypes[32]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.TestProtos.UnittestProto3.internal__static_protobuf_unittest_BarResponse__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public BarResponse() { + OnConstruction(); + } + + partial void OnConstruction(); + + public BarResponse(BarResponse other) : this() { + } + + public BarResponse Clone() { + return new BarResponse(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public override bool Equals(object other) { + return Equals(other as BarResponse); + } + + public bool Equals(BarResponse other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + return true; + } + + public override int GetHashCode() { + int hash = 1; + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + } + + public int CalculateSize() { + int size = 0; + return size; + } + + public void MergeFrom(BarResponse other) { + if (other == null) { + return; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/csharp/src/Google.Protobuf.Test/TestProtos/UnittestWellKnownTypes.cs b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestWellKnownTypes.cs new file mode 100644 index 00000000..af7d83ba --- /dev/null +++ b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestWellKnownTypes.cs @@ -0,0 +1,2453 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/unittest_well_known_types.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Google.Protobuf.TestProtos { + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static partial class UnittestWellKnownTypes { + + #region Static variables + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_TestWellKnownTypes__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_RepeatedWellKnownTypes__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_OneofWellKnownTypes__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_protobuf_unittest_MapWellKnownTypes__FieldAccessorTable; + #endregion + #region Descriptor + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static UnittestWellKnownTypes() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "Ci9nb29nbGUvcHJvdG9idWYvdW5pdHRlc3Rfd2VsbF9rbm93bl90eXBlcy5w", + "cm90bxIRcHJvdG9idWZfdW5pdHRlc3QaGWdvb2dsZS9wcm90b2J1Zi9hbnku", + "cHJvdG8aGWdvb2dsZS9wcm90b2J1Zi9hcGkucHJvdG8aHmdvb2dsZS9wcm90", + "b2J1Zi9kdXJhdGlvbi5wcm90bxobZ29vZ2xlL3Byb3RvYnVmL2VtcHR5LnBy", + "b3RvGiBnb29nbGUvcHJvdG9idWYvZmllbGRfbWFzay5wcm90bxokZ29vZ2xl", + "L3Byb3RvYnVmL3NvdXJjZV9jb250ZXh0LnByb3RvGhxnb29nbGUvcHJvdG9i", + "dWYvc3RydWN0LnByb3RvGh9nb29nbGUvcHJvdG9idWYvdGltZXN0YW1wLnBy", + "b3RvGhpnb29nbGUvcHJvdG9idWYvdHlwZS5wcm90bxoeZ29vZ2xlL3Byb3Rv", + "YnVmL3dyYXBwZXJzLnByb3RvIpEHChJUZXN0V2VsbEtub3duVHlwZXMSJwoJ", + "YW55X2ZpZWxkGAEgASgLMhQuZ29vZ2xlLnByb3RvYnVmLkFueRInCglhcGlf", + "ZmllbGQYAiABKAsyFC5nb29nbGUucHJvdG9idWYuQXBpEjEKDmR1cmF0aW9u", + "X2ZpZWxkGAMgASgLMhkuZ29vZ2xlLnByb3RvYnVmLkR1cmF0aW9uEisKC2Vt", + "cHR5X2ZpZWxkGAQgASgLMhYuZ29vZ2xlLnByb3RvYnVmLkVtcHR5EjQKEGZp", + "ZWxkX21hc2tfZmllbGQYBSABKAsyGi5nb29nbGUucHJvdG9idWYuRmllbGRN", + "YXNrEjwKFHNvdXJjZV9jb250ZXh0X2ZpZWxkGAYgASgLMh4uZ29vZ2xlLnBy", + "b3RvYnVmLlNvdXJjZUNvbnRleHQSLQoMc3RydWN0X2ZpZWxkGAcgASgLMhcu", + "Z29vZ2xlLnByb3RvYnVmLlN0cnVjdBIzCg90aW1lc3RhbXBfZmllbGQYCCAB", + "KAsyGi5nb29nbGUucHJvdG9idWYuVGltZXN0YW1wEikKCnR5cGVfZmllbGQY", + "CSABKAsyFS5nb29nbGUucHJvdG9idWYuVHlwZRIyCgxkb3VibGVfZmllbGQY", + "CiABKAsyHC5nb29nbGUucHJvdG9idWYuRG91YmxlVmFsdWUSMAoLZmxvYXRf", + "ZmllbGQYCyABKAsyGy5nb29nbGUucHJvdG9idWYuRmxvYXRWYWx1ZRIwCgtp", + "bnQ2NF9maWVsZBgMIAEoCzIbLmdvb2dsZS5wcm90b2J1Zi5JbnQ2NFZhbHVl", + "EjIKDHVpbnQ2NF9maWVsZBgNIAEoCzIcLmdvb2dsZS5wcm90b2J1Zi5VSW50", + "NjRWYWx1ZRIwCgtpbnQzMl9maWVsZBgOIAEoCzIbLmdvb2dsZS5wcm90b2J1", + "Zi5JbnQzMlZhbHVlEjIKDHVpbnQzMl9maWVsZBgPIAEoCzIcLmdvb2dsZS5w", + "cm90b2J1Zi5VSW50MzJWYWx1ZRIuCgpib29sX2ZpZWxkGBAgASgLMhouZ29v", + "Z2xlLnByb3RvYnVmLkJvb2xWYWx1ZRIyCgxzdHJpbmdfZmllbGQYESABKAsy", + "HC5nb29nbGUucHJvdG9idWYuU3RyaW5nVmFsdWUSMAoLYnl0ZXNfZmllbGQY", + "EiABKAsyGy5nb29nbGUucHJvdG9idWYuQnl0ZXNWYWx1ZSKVBwoWUmVwZWF0", + "ZWRXZWxsS25vd25UeXBlcxInCglhbnlfZmllbGQYASADKAsyFC5nb29nbGUu", + "cHJvdG9idWYuQW55EicKCWFwaV9maWVsZBgCIAMoCzIULmdvb2dsZS5wcm90", + "b2J1Zi5BcGkSMQoOZHVyYXRpb25fZmllbGQYAyADKAsyGS5nb29nbGUucHJv", + "dG9idWYuRHVyYXRpb24SKwoLZW1wdHlfZmllbGQYBCADKAsyFi5nb29nbGUu", + "cHJvdG9idWYuRW1wdHkSNAoQZmllbGRfbWFza19maWVsZBgFIAMoCzIaLmdv", + "b2dsZS5wcm90b2J1Zi5GaWVsZE1hc2sSPAoUc291cmNlX2NvbnRleHRfZmll", + "bGQYBiADKAsyHi5nb29nbGUucHJvdG9idWYuU291cmNlQ29udGV4dBItCgxz", + "dHJ1Y3RfZmllbGQYByADKAsyFy5nb29nbGUucHJvdG9idWYuU3RydWN0EjMK", + "D3RpbWVzdGFtcF9maWVsZBgIIAMoCzIaLmdvb2dsZS5wcm90b2J1Zi5UaW1l", + "c3RhbXASKQoKdHlwZV9maWVsZBgJIAMoCzIVLmdvb2dsZS5wcm90b2J1Zi5U", + "eXBlEjIKDGRvdWJsZV9maWVsZBgKIAMoCzIcLmdvb2dsZS5wcm90b2J1Zi5E", + "b3VibGVWYWx1ZRIwCgtmbG9hdF9maWVsZBgLIAMoCzIbLmdvb2dsZS5wcm90", + "b2J1Zi5GbG9hdFZhbHVlEjAKC2ludDY0X2ZpZWxkGAwgAygLMhsuZ29vZ2xl", + "LnByb3RvYnVmLkludDY0VmFsdWUSMgoMdWludDY0X2ZpZWxkGA0gAygLMhwu", + "Z29vZ2xlLnByb3RvYnVmLlVJbnQ2NFZhbHVlEjAKC2ludDMyX2ZpZWxkGA4g", + "AygLMhsuZ29vZ2xlLnByb3RvYnVmLkludDMyVmFsdWUSMgoMdWludDMyX2Zp", + "ZWxkGA8gAygLMhwuZ29vZ2xlLnByb3RvYnVmLlVJbnQzMlZhbHVlEi4KCmJv", + "b2xfZmllbGQYECADKAsyGi5nb29nbGUucHJvdG9idWYuQm9vbFZhbHVlEjIK", + "DHN0cmluZ19maWVsZBgRIAMoCzIcLmdvb2dsZS5wcm90b2J1Zi5TdHJpbmdW", + "YWx1ZRIwCgtieXRlc19maWVsZBgSIAMoCzIbLmdvb2dsZS5wcm90b2J1Zi5C", + "eXRlc1ZhbHVlIsUHChNPbmVvZldlbGxLbm93blR5cGVzEikKCWFueV9maWVs", + "ZBgBIAEoCzIULmdvb2dsZS5wcm90b2J1Zi5BbnlIABIpCglhcGlfZmllbGQY", + "AiABKAsyFC5nb29nbGUucHJvdG9idWYuQXBpSAASMwoOZHVyYXRpb25fZmll", + "bGQYAyABKAsyGS5nb29nbGUucHJvdG9idWYuRHVyYXRpb25IABItCgtlbXB0", + "eV9maWVsZBgEIAEoCzIWLmdvb2dsZS5wcm90b2J1Zi5FbXB0eUgAEjYKEGZp", + "ZWxkX21hc2tfZmllbGQYBSABKAsyGi5nb29nbGUucHJvdG9idWYuRmllbGRN", + "YXNrSAASPgoUc291cmNlX2NvbnRleHRfZmllbGQYBiABKAsyHi5nb29nbGUu", + "cHJvdG9idWYuU291cmNlQ29udGV4dEgAEi8KDHN0cnVjdF9maWVsZBgHIAEo", + "CzIXLmdvb2dsZS5wcm90b2J1Zi5TdHJ1Y3RIABI1Cg90aW1lc3RhbXBfZmll", + "bGQYCCABKAsyGi5nb29nbGUucHJvdG9idWYuVGltZXN0YW1wSAASKwoKdHlw", + "ZV9maWVsZBgJIAEoCzIVLmdvb2dsZS5wcm90b2J1Zi5UeXBlSAASNAoMZG91", + "YmxlX2ZpZWxkGAogASgLMhwuZ29vZ2xlLnByb3RvYnVmLkRvdWJsZVZhbHVl", + "SAASMgoLZmxvYXRfZmllbGQYCyABKAsyGy5nb29nbGUucHJvdG9idWYuRmxv", + "YXRWYWx1ZUgAEjIKC2ludDY0X2ZpZWxkGAwgASgLMhsuZ29vZ2xlLnByb3Rv", + "YnVmLkludDY0VmFsdWVIABI0Cgx1aW50NjRfZmllbGQYDSABKAsyHC5nb29n", + "bGUucHJvdG9idWYuVUludDY0VmFsdWVIABIyCgtpbnQzMl9maWVsZBgOIAEo", + "CzIbLmdvb2dsZS5wcm90b2J1Zi5JbnQzMlZhbHVlSAASNAoMdWludDMyX2Zp", + "ZWxkGA8gASgLMhwuZ29vZ2xlLnByb3RvYnVmLlVJbnQzMlZhbHVlSAASMAoK", + "Ym9vbF9maWVsZBgQIAEoCzIaLmdvb2dsZS5wcm90b2J1Zi5Cb29sVmFsdWVI", + "ABI0CgxzdHJpbmdfZmllbGQYESABKAsyHC5nb29nbGUucHJvdG9idWYuU3Ry", + "aW5nVmFsdWVIABIyCgtieXRlc19maWVsZBgSIAEoCzIbLmdvb2dsZS5wcm90", + "b2J1Zi5CeXRlc1ZhbHVlSABCDQoLb25lb2ZfZmllbGQilhYKEU1hcFdlbGxL", + "bm93blR5cGVzEkUKCWFueV9maWVsZBgBIAMoCzIyLnByb3RvYnVmX3VuaXR0", + "ZXN0Lk1hcFdlbGxLbm93blR5cGVzLkFueUZpZWxkRW50cnkSRQoJYXBpX2Zp", + "ZWxkGAIgAygLMjIucHJvdG9idWZfdW5pdHRlc3QuTWFwV2VsbEtub3duVHlw", + "ZXMuQXBpRmllbGRFbnRyeRJPCg5kdXJhdGlvbl9maWVsZBgDIAMoCzI3LnBy", + "b3RvYnVmX3VuaXR0ZXN0Lk1hcFdlbGxLbm93blR5cGVzLkR1cmF0aW9uRmll", + "bGRFbnRyeRJJCgtlbXB0eV9maWVsZBgEIAMoCzI0LnByb3RvYnVmX3VuaXR0", + "ZXN0Lk1hcFdlbGxLbm93blR5cGVzLkVtcHR5RmllbGRFbnRyeRJSChBmaWVs", + "ZF9tYXNrX2ZpZWxkGAUgAygLMjgucHJvdG9idWZfdW5pdHRlc3QuTWFwV2Vs", + "bEtub3duVHlwZXMuRmllbGRNYXNrRmllbGRFbnRyeRJaChRzb3VyY2VfY29u", + "dGV4dF9maWVsZBgGIAMoCzI8LnByb3RvYnVmX3VuaXR0ZXN0Lk1hcFdlbGxL", + "bm93blR5cGVzLlNvdXJjZUNvbnRleHRGaWVsZEVudHJ5EksKDHN0cnVjdF9m", + "aWVsZBgHIAMoCzI1LnByb3RvYnVmX3VuaXR0ZXN0Lk1hcFdlbGxLbm93blR5", + "cGVzLlN0cnVjdEZpZWxkRW50cnkSUQoPdGltZXN0YW1wX2ZpZWxkGAggAygL", + "MjgucHJvdG9idWZfdW5pdHRlc3QuTWFwV2VsbEtub3duVHlwZXMuVGltZXN0", + "YW1wRmllbGRFbnRyeRJHCgp0eXBlX2ZpZWxkGAkgAygLMjMucHJvdG9idWZf", + "dW5pdHRlc3QuTWFwV2VsbEtub3duVHlwZXMuVHlwZUZpZWxkRW50cnkSSwoM", + "ZG91YmxlX2ZpZWxkGAogAygLMjUucHJvdG9idWZfdW5pdHRlc3QuTWFwV2Vs", + "bEtub3duVHlwZXMuRG91YmxlRmllbGRFbnRyeRJJCgtmbG9hdF9maWVsZBgL", + "IAMoCzI0LnByb3RvYnVmX3VuaXR0ZXN0Lk1hcFdlbGxLbm93blR5cGVzLkZs", + "b2F0RmllbGRFbnRyeRJJCgtpbnQ2NF9maWVsZBgMIAMoCzI0LnByb3RvYnVm", + "X3VuaXR0ZXN0Lk1hcFdlbGxLbm93blR5cGVzLkludDY0RmllbGRFbnRyeRJL", + "Cgx1aW50NjRfZmllbGQYDSADKAsyNS5wcm90b2J1Zl91bml0dGVzdC5NYXBX", + "ZWxsS25vd25UeXBlcy5VaW50NjRGaWVsZEVudHJ5EkkKC2ludDMyX2ZpZWxk", + "GA4gAygLMjQucHJvdG9idWZfdW5pdHRlc3QuTWFwV2VsbEtub3duVHlwZXMu", + "SW50MzJGaWVsZEVudHJ5EksKDHVpbnQzMl9maWVsZBgPIAMoCzI1LnByb3Rv", + "YnVmX3VuaXR0ZXN0Lk1hcFdlbGxLbm93blR5cGVzLlVpbnQzMkZpZWxkRW50", + "cnkSRwoKYm9vbF9maWVsZBgQIAMoCzIzLnByb3RvYnVmX3VuaXR0ZXN0Lk1h", + "cFdlbGxLbm93blR5cGVzLkJvb2xGaWVsZEVudHJ5EksKDHN0cmluZ19maWVs", + "ZBgRIAMoCzI1LnByb3RvYnVmX3VuaXR0ZXN0Lk1hcFdlbGxLbm93blR5cGVz", + "LlN0cmluZ0ZpZWxkRW50cnkSSQoLYnl0ZXNfZmllbGQYEiADKAsyNC5wcm90", + "b2J1Zl91bml0dGVzdC5NYXBXZWxsS25vd25UeXBlcy5CeXRlc0ZpZWxkRW50", + "cnkaRQoNQW55RmllbGRFbnRyeRILCgNrZXkYASABKAUSIwoFdmFsdWUYAiAB", + "KAsyFC5nb29nbGUucHJvdG9idWYuQW55OgI4ARpFCg1BcGlGaWVsZEVudHJ5", + "EgsKA2tleRgBIAEoBRIjCgV2YWx1ZRgCIAEoCzIULmdvb2dsZS5wcm90b2J1", + "Zi5BcGk6AjgBGk8KEkR1cmF0aW9uRmllbGRFbnRyeRILCgNrZXkYASABKAUS", + "KAoFdmFsdWUYAiABKAsyGS5nb29nbGUucHJvdG9idWYuRHVyYXRpb246AjgB", + "GkkKD0VtcHR5RmllbGRFbnRyeRILCgNrZXkYASABKAUSJQoFdmFsdWUYAiAB", + "KAsyFi5nb29nbGUucHJvdG9idWYuRW1wdHk6AjgBGlEKE0ZpZWxkTWFza0Zp", + "ZWxkRW50cnkSCwoDa2V5GAEgASgFEikKBXZhbHVlGAIgASgLMhouZ29vZ2xl", + "LnByb3RvYnVmLkZpZWxkTWFzazoCOAEaWQoXU291cmNlQ29udGV4dEZpZWxk", + "RW50cnkSCwoDa2V5GAEgASgFEi0KBXZhbHVlGAIgASgLMh4uZ29vZ2xlLnBy", + "b3RvYnVmLlNvdXJjZUNvbnRleHQ6AjgBGksKEFN0cnVjdEZpZWxkRW50cnkS", + "CwoDa2V5GAEgASgFEiYKBXZhbHVlGAIgASgLMhcuZ29vZ2xlLnByb3RvYnVm", + "LlN0cnVjdDoCOAEaUQoTVGltZXN0YW1wRmllbGRFbnRyeRILCgNrZXkYASAB", + "KAUSKQoFdmFsdWUYAiABKAsyGi5nb29nbGUucHJvdG9idWYuVGltZXN0YW1w", + "OgI4ARpHCg5UeXBlRmllbGRFbnRyeRILCgNrZXkYASABKAUSJAoFdmFsdWUY", + "AiABKAsyFS5nb29nbGUucHJvdG9idWYuVHlwZToCOAEaUAoQRG91YmxlRmll", + "bGRFbnRyeRILCgNrZXkYASABKAUSKwoFdmFsdWUYAiABKAsyHC5nb29nbGUu", + "cHJvdG9idWYuRG91YmxlVmFsdWU6AjgBGk4KD0Zsb2F0RmllbGRFbnRyeRIL", + "CgNrZXkYASABKAUSKgoFdmFsdWUYAiABKAsyGy5nb29nbGUucHJvdG9idWYu", + "RmxvYXRWYWx1ZToCOAEaTgoPSW50NjRGaWVsZEVudHJ5EgsKA2tleRgBIAEo", + "BRIqCgV2YWx1ZRgCIAEoCzIbLmdvb2dsZS5wcm90b2J1Zi5JbnQ2NFZhbHVl", + "OgI4ARpQChBVaW50NjRGaWVsZEVudHJ5EgsKA2tleRgBIAEoBRIrCgV2YWx1", + "ZRgCIAEoCzIcLmdvb2dsZS5wcm90b2J1Zi5VSW50NjRWYWx1ZToCOAEaTgoP", + "SW50MzJGaWVsZEVudHJ5EgsKA2tleRgBIAEoBRIqCgV2YWx1ZRgCIAEoCzIb", + "Lmdvb2dsZS5wcm90b2J1Zi5JbnQzMlZhbHVlOgI4ARpQChBVaW50MzJGaWVs", + "ZEVudHJ5EgsKA2tleRgBIAEoBRIrCgV2YWx1ZRgCIAEoCzIcLmdvb2dsZS5w", + "cm90b2J1Zi5VSW50MzJWYWx1ZToCOAEaTAoOQm9vbEZpZWxkRW50cnkSCwoD", + "a2V5GAEgASgFEikKBXZhbHVlGAIgASgLMhouZ29vZ2xlLnByb3RvYnVmLkJv", + "b2xWYWx1ZToCOAEaUAoQU3RyaW5nRmllbGRFbnRyeRILCgNrZXkYASABKAUS", + "KwoFdmFsdWUYAiABKAsyHC5nb29nbGUucHJvdG9idWYuU3RyaW5nVmFsdWU6", + "AjgBGk4KD0J5dGVzRmllbGRFbnRyeRILCgNrZXkYASABKAUSKgoFdmFsdWUY", + "AiABKAsyGy5nb29nbGUucHJvdG9idWYuQnl0ZXNWYWx1ZToCOAFCOQoYY29t", + "Lmdvb2dsZS5wcm90b2J1Zi50ZXN0UAGqAhpHb29nbGUuUHJvdG9idWYuVGVz", + "dFByb3Rvc2IGcHJvdG8z")); + descriptor = pbr::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, + new pbr::FileDescriptor[] { + global::Google.Protobuf.WellKnownTypes.Proto.Any.Descriptor, + global::Google.Protobuf.WellKnownTypes.Proto.Api.Descriptor, + global::Google.Protobuf.WellKnownTypes.Proto.Duration.Descriptor, + global::Google.Protobuf.WellKnownTypes.Proto.Empty.Descriptor, + global::Google.Protobuf.WellKnownTypes.Proto.FieldMask.Descriptor, + global::Google.Protobuf.WellKnownTypes.Proto.SourceContext.Descriptor, + global::Google.Protobuf.WellKnownTypes.Proto.Struct.Descriptor, + global::Google.Protobuf.WellKnownTypes.Proto.Timestamp.Descriptor, + global::Google.Protobuf.WellKnownTypes.Proto.Type.Descriptor, + global::Google.Protobuf.WellKnownTypes.Wrappers.Descriptor, + }); + internal__static_protobuf_unittest_TestWellKnownTypes__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.TestWellKnownTypes), descriptor.MessageTypes[0], + new string[] { "AnyField", "ApiField", "DurationField", "EmptyField", "FieldMaskField", "SourceContextField", "StructField", "TimestampField", "TypeField", "DoubleField", "FloatField", "Int64Field", "Uint64Field", "Int32Field", "Uint32Field", "BoolField", "StringField", "BytesField", }, new string[] { }); + internal__static_protobuf_unittest_RepeatedWellKnownTypes__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.RepeatedWellKnownTypes), descriptor.MessageTypes[1], + new string[] { "AnyField", "ApiField", "DurationField", "EmptyField", "FieldMaskField", "SourceContextField", "StructField", "TimestampField", "TypeField", "DoubleField", "FloatField", "Int64Field", "Uint64Field", "Int32Field", "Uint32Field", "BoolField", "StringField", "BytesField", }, new string[] { }); + internal__static_protobuf_unittest_OneofWellKnownTypes__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.OneofWellKnownTypes), descriptor.MessageTypes[2], + new string[] { "AnyField", "ApiField", "DurationField", "EmptyField", "FieldMaskField", "SourceContextField", "StructField", "TimestampField", "TypeField", "DoubleField", "FloatField", "Int64Field", "Uint64Field", "Int32Field", "Uint32Field", "BoolField", "StringField", "BytesField", }, new string[] { "OneofField", }); + internal__static_protobuf_unittest_MapWellKnownTypes__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.TestProtos.MapWellKnownTypes), descriptor.MessageTypes[3], + new string[] { "AnyField", "ApiField", "DurationField", "EmptyField", "FieldMaskField", "SourceContextField", "StructField", "TimestampField", "TypeField", "DoubleField", "FloatField", "Int64Field", "Uint64Field", "Int32Field", "Uint32Field", "BoolField", "StringField", "BytesField", }, new string[] { }); + } + #endregion + + } + #region Messages + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class TestWellKnownTypes : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new TestWellKnownTypes()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "any_field", "api_field", "bool_field", "bytes_field", "double_field", "duration_field", "empty_field", "field_mask_field", "float_field", "int32_field", "int64_field", "source_context_field", "string_field", "struct_field", "timestamp_field", "type_field", "uint32_field", "uint64_field" }; + private static readonly uint[] _fieldTags = new uint[] { 10, 18, 130, 146, 82, 26, 34, 42, 90, 114, 98, 50, 138, 58, 66, 74, 122, 106 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.UnittestWellKnownTypes.Descriptor.MessageTypes[0]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.TestProtos.UnittestWellKnownTypes.internal__static_protobuf_unittest_TestWellKnownTypes__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public TestWellKnownTypes() { + OnConstruction(); + } + + partial void OnConstruction(); + + public TestWellKnownTypes(TestWellKnownTypes other) : this() { + AnyField = other.anyField_ != null ? other.AnyField.Clone() : null; + ApiField = other.apiField_ != null ? other.ApiField.Clone() : null; + DurationField = other.durationField_ != null ? other.DurationField.Clone() : null; + EmptyField = other.emptyField_ != null ? other.EmptyField.Clone() : null; + FieldMaskField = other.fieldMaskField_ != null ? other.FieldMaskField.Clone() : null; + SourceContextField = other.sourceContextField_ != null ? other.SourceContextField.Clone() : null; + StructField = other.structField_ != null ? other.StructField.Clone() : null; + TimestampField = other.timestampField_ != null ? other.TimestampField.Clone() : null; + TypeField = other.typeField_ != null ? other.TypeField.Clone() : null; + DoubleField = other.DoubleField; + FloatField = other.FloatField; + Int64Field = other.Int64Field; + Uint64Field = other.Uint64Field; + Int32Field = other.Int32Field; + Uint32Field = other.Uint32Field; + BoolField = other.BoolField; + StringField = other.StringField; + BytesField = other.BytesField; + } + + public TestWellKnownTypes Clone() { + return new TestWellKnownTypes(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + if (anyField_ != null) AnyField.Freeze(); + if (apiField_ != null) ApiField.Freeze(); + if (durationField_ != null) DurationField.Freeze(); + if (emptyField_ != null) EmptyField.Freeze(); + if (fieldMaskField_ != null) FieldMaskField.Freeze(); + if (sourceContextField_ != null) SourceContextField.Freeze(); + if (structField_ != null) StructField.Freeze(); + if (timestampField_ != null) TimestampField.Freeze(); + if (typeField_ != null) TypeField.Freeze(); + } + + public const int AnyFieldFieldNumber = 1; + private global::Google.Protobuf.WellKnownTypes.Any anyField_; + public global::Google.Protobuf.WellKnownTypes.Any AnyField { + get { return anyField_; } + set { + pb::Freezable.CheckMutable(this); + anyField_ = value; + } + } + + public const int ApiFieldFieldNumber = 2; + private global::Google.Protobuf.WellKnownTypes.Api apiField_; + public global::Google.Protobuf.WellKnownTypes.Api ApiField { + get { return apiField_; } + set { + pb::Freezable.CheckMutable(this); + apiField_ = value; + } + } + + public const int DurationFieldFieldNumber = 3; + private global::Google.Protobuf.WellKnownTypes.Duration durationField_; + public global::Google.Protobuf.WellKnownTypes.Duration DurationField { + get { return durationField_; } + set { + pb::Freezable.CheckMutable(this); + durationField_ = value; + } + } + + public const int EmptyFieldFieldNumber = 4; + private global::Google.Protobuf.WellKnownTypes.Empty emptyField_; + public global::Google.Protobuf.WellKnownTypes.Empty EmptyField { + get { return emptyField_; } + set { + pb::Freezable.CheckMutable(this); + emptyField_ = value; + } + } + + public const int FieldMaskFieldFieldNumber = 5; + private global::Google.Protobuf.WellKnownTypes.FieldMask fieldMaskField_; + public global::Google.Protobuf.WellKnownTypes.FieldMask FieldMaskField { + get { return fieldMaskField_; } + set { + pb::Freezable.CheckMutable(this); + fieldMaskField_ = value; + } + } + + public const int SourceContextFieldFieldNumber = 6; + private global::Google.Protobuf.WellKnownTypes.SourceContext sourceContextField_; + public global::Google.Protobuf.WellKnownTypes.SourceContext SourceContextField { + get { return sourceContextField_; } + set { + pb::Freezable.CheckMutable(this); + sourceContextField_ = value; + } + } + + public const int StructFieldFieldNumber = 7; + private global::Google.Protobuf.WellKnownTypes.Struct structField_; + public global::Google.Protobuf.WellKnownTypes.Struct StructField { + get { return structField_; } + set { + pb::Freezable.CheckMutable(this); + structField_ = value; + } + } + + public const int TimestampFieldFieldNumber = 8; + private global::Google.Protobuf.WellKnownTypes.Timestamp timestampField_; + public global::Google.Protobuf.WellKnownTypes.Timestamp TimestampField { + get { return timestampField_; } + set { + pb::Freezable.CheckMutable(this); + timestampField_ = value; + } + } + + public const int TypeFieldFieldNumber = 9; + private global::Google.Protobuf.WellKnownTypes.Type typeField_; + public global::Google.Protobuf.WellKnownTypes.Type TypeField { + get { return typeField_; } + set { + pb::Freezable.CheckMutable(this); + typeField_ = value; + } + } + + public const int DoubleFieldFieldNumber = 10; + private static readonly pb::FieldCodec _single_doubleField_codec = pb::FieldCodec.ForStructWrapper(82); + private double? doubleField_; + public double? DoubleField { + get { return doubleField_; } + set { + pb::Freezable.CheckMutable(this); + doubleField_ = value; + } + } + + public const int FloatFieldFieldNumber = 11; + private static readonly pb::FieldCodec _single_floatField_codec = pb::FieldCodec.ForStructWrapper(90); + private float? floatField_; + public float? FloatField { + get { return floatField_; } + set { + pb::Freezable.CheckMutable(this); + floatField_ = value; + } + } + + public const int Int64FieldFieldNumber = 12; + private static readonly pb::FieldCodec _single_int64Field_codec = pb::FieldCodec.ForStructWrapper(98); + private long? int64Field_; + public long? Int64Field { + get { return int64Field_; } + set { + pb::Freezable.CheckMutable(this); + int64Field_ = value; + } + } + + public const int Uint64FieldFieldNumber = 13; + private static readonly pb::FieldCodec _single_uint64Field_codec = pb::FieldCodec.ForStructWrapper(106); + private ulong? uint64Field_; + public ulong? Uint64Field { + get { return uint64Field_; } + set { + pb::Freezable.CheckMutable(this); + uint64Field_ = value; + } + } + + public const int Int32FieldFieldNumber = 14; + private static readonly pb::FieldCodec _single_int32Field_codec = pb::FieldCodec.ForStructWrapper(114); + private int? int32Field_; + public int? Int32Field { + get { return int32Field_; } + set { + pb::Freezable.CheckMutable(this); + int32Field_ = value; + } + } + + public const int Uint32FieldFieldNumber = 15; + private static readonly pb::FieldCodec _single_uint32Field_codec = pb::FieldCodec.ForStructWrapper(122); + private uint? uint32Field_; + public uint? Uint32Field { + get { return uint32Field_; } + set { + pb::Freezable.CheckMutable(this); + uint32Field_ = value; + } + } + + public const int BoolFieldFieldNumber = 16; + private static readonly pb::FieldCodec _single_boolField_codec = pb::FieldCodec.ForStructWrapper(130); + private bool? boolField_; + public bool? BoolField { + get { return boolField_; } + set { + pb::Freezable.CheckMutable(this); + boolField_ = value; + } + } + + public const int StringFieldFieldNumber = 17; + private static readonly pb::FieldCodec _single_stringField_codec = pb::FieldCodec.ForClassWrapper(138); + private string stringField_; + public string StringField { + get { return stringField_; } + set { + pb::Freezable.CheckMutable(this); + stringField_ = value; + } + } + + public const int BytesFieldFieldNumber = 18; + private static readonly pb::FieldCodec _single_bytesField_codec = pb::FieldCodec.ForClassWrapper(146); + private pb::ByteString bytesField_; + public pb::ByteString BytesField { + get { return bytesField_; } + set { + pb::Freezable.CheckMutable(this); + bytesField_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as TestWellKnownTypes); + } + + public bool Equals(TestWellKnownTypes other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (!object.Equals(AnyField, other.AnyField)) return false; + if (!object.Equals(ApiField, other.ApiField)) return false; + if (!object.Equals(DurationField, other.DurationField)) return false; + if (!object.Equals(EmptyField, other.EmptyField)) return false; + if (!object.Equals(FieldMaskField, other.FieldMaskField)) return false; + if (!object.Equals(SourceContextField, other.SourceContextField)) return false; + if (!object.Equals(StructField, other.StructField)) return false; + if (!object.Equals(TimestampField, other.TimestampField)) return false; + if (!object.Equals(TypeField, other.TypeField)) return false; + if (DoubleField != other.DoubleField) return false; + if (FloatField != other.FloatField) return false; + if (Int64Field != other.Int64Field) return false; + if (Uint64Field != other.Uint64Field) return false; + if (Int32Field != other.Int32Field) return false; + if (Uint32Field != other.Uint32Field) return false; + if (BoolField != other.BoolField) return false; + if (StringField != other.StringField) return false; + if (BytesField != other.BytesField) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (anyField_ != null) hash ^= AnyField.GetHashCode(); + if (apiField_ != null) hash ^= ApiField.GetHashCode(); + if (durationField_ != null) hash ^= DurationField.GetHashCode(); + if (emptyField_ != null) hash ^= EmptyField.GetHashCode(); + if (fieldMaskField_ != null) hash ^= FieldMaskField.GetHashCode(); + if (sourceContextField_ != null) hash ^= SourceContextField.GetHashCode(); + if (structField_ != null) hash ^= StructField.GetHashCode(); + if (timestampField_ != null) hash ^= TimestampField.GetHashCode(); + if (typeField_ != null) hash ^= TypeField.GetHashCode(); + if (doubleField_ != null) hash ^= DoubleField.GetHashCode(); + if (floatField_ != null) hash ^= FloatField.GetHashCode(); + if (int64Field_ != null) hash ^= Int64Field.GetHashCode(); + if (uint64Field_ != null) hash ^= Uint64Field.GetHashCode(); + if (int32Field_ != null) hash ^= Int32Field.GetHashCode(); + if (uint32Field_ != null) hash ^= Uint32Field.GetHashCode(); + if (boolField_ != null) hash ^= BoolField.GetHashCode(); + if (stringField_ != null) hash ^= StringField.GetHashCode(); + if (bytesField_ != null) hash ^= BytesField.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (anyField_ != null) { + output.WriteRawTag(10); + output.WriteMessage(AnyField); + } + if (apiField_ != null) { + output.WriteRawTag(18); + output.WriteMessage(ApiField); + } + if (durationField_ != null) { + output.WriteRawTag(26); + output.WriteMessage(DurationField); + } + if (emptyField_ != null) { + output.WriteRawTag(34); + output.WriteMessage(EmptyField); + } + if (fieldMaskField_ != null) { + output.WriteRawTag(42); + output.WriteMessage(FieldMaskField); + } + if (sourceContextField_ != null) { + output.WriteRawTag(50); + output.WriteMessage(SourceContextField); + } + if (structField_ != null) { + output.WriteRawTag(58); + output.WriteMessage(StructField); + } + if (timestampField_ != null) { + output.WriteRawTag(66); + output.WriteMessage(TimestampField); + } + if (typeField_ != null) { + output.WriteRawTag(74); + output.WriteMessage(TypeField); + } + if (doubleField_ != null) { + _single_doubleField_codec.WriteTagAndValue(output, DoubleField); + } + if (floatField_ != null) { + _single_floatField_codec.WriteTagAndValue(output, FloatField); + } + if (int64Field_ != null) { + _single_int64Field_codec.WriteTagAndValue(output, Int64Field); + } + if (uint64Field_ != null) { + _single_uint64Field_codec.WriteTagAndValue(output, Uint64Field); + } + if (int32Field_ != null) { + _single_int32Field_codec.WriteTagAndValue(output, Int32Field); + } + if (uint32Field_ != null) { + _single_uint32Field_codec.WriteTagAndValue(output, Uint32Field); + } + if (boolField_ != null) { + _single_boolField_codec.WriteTagAndValue(output, BoolField); + } + if (stringField_ != null) { + _single_stringField_codec.WriteTagAndValue(output, StringField); + } + if (bytesField_ != null) { + _single_bytesField_codec.WriteTagAndValue(output, BytesField); + } + } + + public int CalculateSize() { + int size = 0; + if (anyField_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(AnyField); + } + if (apiField_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(ApiField); + } + if (durationField_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(DurationField); + } + if (emptyField_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(EmptyField); + } + if (fieldMaskField_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(FieldMaskField); + } + if (sourceContextField_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(SourceContextField); + } + if (structField_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(StructField); + } + if (timestampField_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(TimestampField); + } + if (typeField_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(TypeField); + } + if (doubleField_ != null) { + size += _single_doubleField_codec.CalculateSizeWithTag(DoubleField); + } + if (floatField_ != null) { + size += _single_floatField_codec.CalculateSizeWithTag(FloatField); + } + if (int64Field_ != null) { + size += _single_int64Field_codec.CalculateSizeWithTag(Int64Field); + } + if (uint64Field_ != null) { + size += _single_uint64Field_codec.CalculateSizeWithTag(Uint64Field); + } + if (int32Field_ != null) { + size += _single_int32Field_codec.CalculateSizeWithTag(Int32Field); + } + if (uint32Field_ != null) { + size += _single_uint32Field_codec.CalculateSizeWithTag(Uint32Field); + } + if (boolField_ != null) { + size += _single_boolField_codec.CalculateSizeWithTag(BoolField); + } + if (stringField_ != null) { + size += _single_stringField_codec.CalculateSizeWithTag(StringField); + } + if (bytesField_ != null) { + size += _single_bytesField_codec.CalculateSizeWithTag(BytesField); + } + return size; + } + + public void MergeFrom(TestWellKnownTypes other) { + if (other == null) { + return; + } + if (other.anyField_ != null) { + if (anyField_ == null) { + anyField_ = new global::Google.Protobuf.WellKnownTypes.Any(); + } + AnyField.MergeFrom(other.AnyField); + } + if (other.apiField_ != null) { + if (apiField_ == null) { + apiField_ = new global::Google.Protobuf.WellKnownTypes.Api(); + } + ApiField.MergeFrom(other.ApiField); + } + if (other.durationField_ != null) { + if (durationField_ == null) { + durationField_ = new global::Google.Protobuf.WellKnownTypes.Duration(); + } + DurationField.MergeFrom(other.DurationField); + } + if (other.emptyField_ != null) { + if (emptyField_ == null) { + emptyField_ = new global::Google.Protobuf.WellKnownTypes.Empty(); + } + EmptyField.MergeFrom(other.EmptyField); + } + if (other.fieldMaskField_ != null) { + if (fieldMaskField_ == null) { + fieldMaskField_ = new global::Google.Protobuf.WellKnownTypes.FieldMask(); + } + FieldMaskField.MergeFrom(other.FieldMaskField); + } + if (other.sourceContextField_ != null) { + if (sourceContextField_ == null) { + sourceContextField_ = new global::Google.Protobuf.WellKnownTypes.SourceContext(); + } + SourceContextField.MergeFrom(other.SourceContextField); + } + if (other.structField_ != null) { + if (structField_ == null) { + structField_ = new global::Google.Protobuf.WellKnownTypes.Struct(); + } + StructField.MergeFrom(other.StructField); + } + if (other.timestampField_ != null) { + if (timestampField_ == null) { + timestampField_ = new global::Google.Protobuf.WellKnownTypes.Timestamp(); + } + TimestampField.MergeFrom(other.TimestampField); + } + if (other.typeField_ != null) { + if (typeField_ == null) { + typeField_ = new global::Google.Protobuf.WellKnownTypes.Type(); + } + TypeField.MergeFrom(other.TypeField); + } + if (other.doubleField_ != null) { + if (doubleField_ == null || other.DoubleField != 0D) { + DoubleField = other.DoubleField; + } + } + if (other.floatField_ != null) { + if (floatField_ == null || other.FloatField != 0F) { + FloatField = other.FloatField; + } + } + if (other.int64Field_ != null) { + if (int64Field_ == null || other.Int64Field != 0L) { + Int64Field = other.Int64Field; + } + } + if (other.uint64Field_ != null) { + if (uint64Field_ == null || other.Uint64Field != 0UL) { + Uint64Field = other.Uint64Field; + } + } + if (other.int32Field_ != null) { + if (int32Field_ == null || other.Int32Field != 0) { + Int32Field = other.Int32Field; + } + } + if (other.uint32Field_ != null) { + if (uint32Field_ == null || other.Uint32Field != 0) { + Uint32Field = other.Uint32Field; + } + } + if (other.boolField_ != null) { + if (boolField_ == null || other.BoolField != false) { + BoolField = other.BoolField; + } + } + if (other.stringField_ != null) { + if (stringField_ == null || other.StringField != "") { + StringField = other.StringField; + } + } + if (other.bytesField_ != null) { + if (bytesField_ == null || other.BytesField != pb::ByteString.Empty) { + BytesField = other.BytesField; + } + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + if (anyField_ == null) { + anyField_ = new global::Google.Protobuf.WellKnownTypes.Any(); + } + input.ReadMessage(anyField_); + break; + } + case 18: { + if (apiField_ == null) { + apiField_ = new global::Google.Protobuf.WellKnownTypes.Api(); + } + input.ReadMessage(apiField_); + break; + } + case 26: { + if (durationField_ == null) { + durationField_ = new global::Google.Protobuf.WellKnownTypes.Duration(); + } + input.ReadMessage(durationField_); + break; + } + case 34: { + if (emptyField_ == null) { + emptyField_ = new global::Google.Protobuf.WellKnownTypes.Empty(); + } + input.ReadMessage(emptyField_); + break; + } + case 42: { + if (fieldMaskField_ == null) { + fieldMaskField_ = new global::Google.Protobuf.WellKnownTypes.FieldMask(); + } + input.ReadMessage(fieldMaskField_); + break; + } + case 50: { + if (sourceContextField_ == null) { + sourceContextField_ = new global::Google.Protobuf.WellKnownTypes.SourceContext(); + } + input.ReadMessage(sourceContextField_); + break; + } + case 58: { + if (structField_ == null) { + structField_ = new global::Google.Protobuf.WellKnownTypes.Struct(); + } + input.ReadMessage(structField_); + break; + } + case 66: { + if (timestampField_ == null) { + timestampField_ = new global::Google.Protobuf.WellKnownTypes.Timestamp(); + } + input.ReadMessage(timestampField_); + break; + } + case 74: { + if (typeField_ == null) { + typeField_ = new global::Google.Protobuf.WellKnownTypes.Type(); + } + input.ReadMessage(typeField_); + break; + } + case 82: { + double? value = _single_doubleField_codec.Read(input); + if (doubleField_ == null || value != 0D) { + DoubleField = value; + } + break; + } + case 90: { + float? value = _single_floatField_codec.Read(input); + if (floatField_ == null || value != 0F) { + FloatField = value; + } + break; + } + case 98: { + long? value = _single_int64Field_codec.Read(input); + if (int64Field_ == null || value != 0L) { + Int64Field = value; + } + break; + } + case 106: { + ulong? value = _single_uint64Field_codec.Read(input); + if (uint64Field_ == null || value != 0UL) { + Uint64Field = value; + } + break; + } + case 114: { + int? value = _single_int32Field_codec.Read(input); + if (int32Field_ == null || value != 0) { + Int32Field = value; + } + break; + } + case 122: { + uint? value = _single_uint32Field_codec.Read(input); + if (uint32Field_ == null || value != 0) { + Uint32Field = value; + } + break; + } + case 130: { + bool? value = _single_boolField_codec.Read(input); + if (boolField_ == null || value != false) { + BoolField = value; + } + break; + } + case 138: { + string value = _single_stringField_codec.Read(input); + if (stringField_ == null || value != "") { + StringField = value; + } + break; + } + case 146: { + pb::ByteString value = _single_bytesField_codec.Read(input); + if (bytesField_ == null || value != pb::ByteString.Empty) { + BytesField = value; + } + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class RepeatedWellKnownTypes : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new RepeatedWellKnownTypes()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "any_field", "api_field", "bool_field", "bytes_field", "double_field", "duration_field", "empty_field", "field_mask_field", "float_field", "int32_field", "int64_field", "source_context_field", "string_field", "struct_field", "timestamp_field", "type_field", "uint32_field", "uint64_field" }; + private static readonly uint[] _fieldTags = new uint[] { 10, 18, 130, 146, 82, 26, 34, 42, 90, 114, 98, 50, 138, 58, 66, 74, 122, 106 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.UnittestWellKnownTypes.Descriptor.MessageTypes[1]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.TestProtos.UnittestWellKnownTypes.internal__static_protobuf_unittest_RepeatedWellKnownTypes__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public RepeatedWellKnownTypes() { + OnConstruction(); + } + + partial void OnConstruction(); + + public RepeatedWellKnownTypes(RepeatedWellKnownTypes other) : this() { + anyField_ = other.anyField_.Clone(); + apiField_ = other.apiField_.Clone(); + durationField_ = other.durationField_.Clone(); + emptyField_ = other.emptyField_.Clone(); + fieldMaskField_ = other.fieldMaskField_.Clone(); + sourceContextField_ = other.sourceContextField_.Clone(); + structField_ = other.structField_.Clone(); + timestampField_ = other.timestampField_.Clone(); + typeField_ = other.typeField_.Clone(); + doubleField_ = other.doubleField_.Clone(); + floatField_ = other.floatField_.Clone(); + int64Field_ = other.int64Field_.Clone(); + uint64Field_ = other.uint64Field_.Clone(); + int32Field_ = other.int32Field_.Clone(); + uint32Field_ = other.uint32Field_.Clone(); + boolField_ = other.boolField_.Clone(); + stringField_ = other.stringField_.Clone(); + bytesField_ = other.bytesField_.Clone(); + } + + public RepeatedWellKnownTypes Clone() { + return new RepeatedWellKnownTypes(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + anyField_.Freeze(); + apiField_.Freeze(); + durationField_.Freeze(); + emptyField_.Freeze(); + fieldMaskField_.Freeze(); + sourceContextField_.Freeze(); + structField_.Freeze(); + timestampField_.Freeze(); + typeField_.Freeze(); + doubleField_.Freeze(); + floatField_.Freeze(); + int64Field_.Freeze(); + uint64Field_.Freeze(); + int32Field_.Freeze(); + uint32Field_.Freeze(); + boolField_.Freeze(); + stringField_.Freeze(); + bytesField_.Freeze(); + } + + public const int AnyFieldFieldNumber = 1; + private static readonly pb::FieldCodec _repeated_anyField_codec + = pb::FieldCodec.ForMessage(10, global::Google.Protobuf.WellKnownTypes.Any.Parser); + private readonly pbc::RepeatedField anyField_ = new pbc::RepeatedField(); + public pbc::RepeatedField AnyField { + get { return anyField_; } + } + + public const int ApiFieldFieldNumber = 2; + private static readonly pb::FieldCodec _repeated_apiField_codec + = pb::FieldCodec.ForMessage(18, global::Google.Protobuf.WellKnownTypes.Api.Parser); + private readonly pbc::RepeatedField apiField_ = new pbc::RepeatedField(); + public pbc::RepeatedField ApiField { + get { return apiField_; } + } + + public const int DurationFieldFieldNumber = 3; + private static readonly pb::FieldCodec _repeated_durationField_codec + = pb::FieldCodec.ForMessage(26, global::Google.Protobuf.WellKnownTypes.Duration.Parser); + private readonly pbc::RepeatedField durationField_ = new pbc::RepeatedField(); + public pbc::RepeatedField DurationField { + get { return durationField_; } + } + + public const int EmptyFieldFieldNumber = 4; + private static readonly pb::FieldCodec _repeated_emptyField_codec + = pb::FieldCodec.ForMessage(34, global::Google.Protobuf.WellKnownTypes.Empty.Parser); + private readonly pbc::RepeatedField emptyField_ = new pbc::RepeatedField(); + public pbc::RepeatedField EmptyField { + get { return emptyField_; } + } + + public const int FieldMaskFieldFieldNumber = 5; + private static readonly pb::FieldCodec _repeated_fieldMaskField_codec + = pb::FieldCodec.ForMessage(42, global::Google.Protobuf.WellKnownTypes.FieldMask.Parser); + private readonly pbc::RepeatedField fieldMaskField_ = new pbc::RepeatedField(); + public pbc::RepeatedField FieldMaskField { + get { return fieldMaskField_; } + } + + public const int SourceContextFieldFieldNumber = 6; + private static readonly pb::FieldCodec _repeated_sourceContextField_codec + = pb::FieldCodec.ForMessage(50, global::Google.Protobuf.WellKnownTypes.SourceContext.Parser); + private readonly pbc::RepeatedField sourceContextField_ = new pbc::RepeatedField(); + public pbc::RepeatedField SourceContextField { + get { return sourceContextField_; } + } + + public const int StructFieldFieldNumber = 7; + private static readonly pb::FieldCodec _repeated_structField_codec + = pb::FieldCodec.ForMessage(58, global::Google.Protobuf.WellKnownTypes.Struct.Parser); + private readonly pbc::RepeatedField structField_ = new pbc::RepeatedField(); + public pbc::RepeatedField StructField { + get { return structField_; } + } + + public const int TimestampFieldFieldNumber = 8; + private static readonly pb::FieldCodec _repeated_timestampField_codec + = pb::FieldCodec.ForMessage(66, global::Google.Protobuf.WellKnownTypes.Timestamp.Parser); + private readonly pbc::RepeatedField timestampField_ = new pbc::RepeatedField(); + public pbc::RepeatedField TimestampField { + get { return timestampField_; } + } + + public const int TypeFieldFieldNumber = 9; + private static readonly pb::FieldCodec _repeated_typeField_codec + = pb::FieldCodec.ForMessage(74, global::Google.Protobuf.WellKnownTypes.Type.Parser); + private readonly pbc::RepeatedField typeField_ = new pbc::RepeatedField(); + public pbc::RepeatedField TypeField { + get { return typeField_; } + } + + public const int DoubleFieldFieldNumber = 10; + private static readonly pb::FieldCodec _repeated_doubleField_codec + = pb::FieldCodec.ForStructWrapper(82); + private readonly pbc::RepeatedField doubleField_ = new pbc::RepeatedField(); + public pbc::RepeatedField DoubleField { + get { return doubleField_; } + } + + public const int FloatFieldFieldNumber = 11; + private static readonly pb::FieldCodec _repeated_floatField_codec + = pb::FieldCodec.ForStructWrapper(90); + private readonly pbc::RepeatedField floatField_ = new pbc::RepeatedField(); + public pbc::RepeatedField FloatField { + get { return floatField_; } + } + + public const int Int64FieldFieldNumber = 12; + private static readonly pb::FieldCodec _repeated_int64Field_codec + = pb::FieldCodec.ForStructWrapper(98); + private readonly pbc::RepeatedField int64Field_ = new pbc::RepeatedField(); + public pbc::RepeatedField Int64Field { + get { return int64Field_; } + } + + public const int Uint64FieldFieldNumber = 13; + private static readonly pb::FieldCodec _repeated_uint64Field_codec + = pb::FieldCodec.ForStructWrapper(106); + private readonly pbc::RepeatedField uint64Field_ = new pbc::RepeatedField(); + public pbc::RepeatedField Uint64Field { + get { return uint64Field_; } + } + + public const int Int32FieldFieldNumber = 14; + private static readonly pb::FieldCodec _repeated_int32Field_codec + = pb::FieldCodec.ForStructWrapper(114); + private readonly pbc::RepeatedField int32Field_ = new pbc::RepeatedField(); + public pbc::RepeatedField Int32Field { + get { return int32Field_; } + } + + public const int Uint32FieldFieldNumber = 15; + private static readonly pb::FieldCodec _repeated_uint32Field_codec + = pb::FieldCodec.ForStructWrapper(122); + private readonly pbc::RepeatedField uint32Field_ = new pbc::RepeatedField(); + public pbc::RepeatedField Uint32Field { + get { return uint32Field_; } + } + + public const int BoolFieldFieldNumber = 16; + private static readonly pb::FieldCodec _repeated_boolField_codec + = pb::FieldCodec.ForStructWrapper(130); + private readonly pbc::RepeatedField boolField_ = new pbc::RepeatedField(); + public pbc::RepeatedField BoolField { + get { return boolField_; } + } + + public const int StringFieldFieldNumber = 17; + private static readonly pb::FieldCodec _repeated_stringField_codec + = pb::FieldCodec.ForClassWrapper(138); + private readonly pbc::RepeatedField stringField_ = new pbc::RepeatedField(); + public pbc::RepeatedField StringField { + get { return stringField_; } + } + + public const int BytesFieldFieldNumber = 18; + private static readonly pb::FieldCodec _repeated_bytesField_codec + = pb::FieldCodec.ForClassWrapper(146); + private readonly pbc::RepeatedField bytesField_ = new pbc::RepeatedField(); + public pbc::RepeatedField BytesField { + get { return bytesField_; } + } + + public override bool Equals(object other) { + return Equals(other as RepeatedWellKnownTypes); + } + + public bool Equals(RepeatedWellKnownTypes other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if(!anyField_.Equals(other.anyField_)) return false; + if(!apiField_.Equals(other.apiField_)) return false; + if(!durationField_.Equals(other.durationField_)) return false; + if(!emptyField_.Equals(other.emptyField_)) return false; + if(!fieldMaskField_.Equals(other.fieldMaskField_)) return false; + if(!sourceContextField_.Equals(other.sourceContextField_)) return false; + if(!structField_.Equals(other.structField_)) return false; + if(!timestampField_.Equals(other.timestampField_)) return false; + if(!typeField_.Equals(other.typeField_)) return false; + if(!doubleField_.Equals(other.doubleField_)) return false; + if(!floatField_.Equals(other.floatField_)) return false; + if(!int64Field_.Equals(other.int64Field_)) return false; + if(!uint64Field_.Equals(other.uint64Field_)) return false; + if(!int32Field_.Equals(other.int32Field_)) return false; + if(!uint32Field_.Equals(other.uint32Field_)) return false; + if(!boolField_.Equals(other.boolField_)) return false; + if(!stringField_.Equals(other.stringField_)) return false; + if(!bytesField_.Equals(other.bytesField_)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + hash ^= anyField_.GetHashCode(); + hash ^= apiField_.GetHashCode(); + hash ^= durationField_.GetHashCode(); + hash ^= emptyField_.GetHashCode(); + hash ^= fieldMaskField_.GetHashCode(); + hash ^= sourceContextField_.GetHashCode(); + hash ^= structField_.GetHashCode(); + hash ^= timestampField_.GetHashCode(); + hash ^= typeField_.GetHashCode(); + hash ^= doubleField_.GetHashCode(); + hash ^= floatField_.GetHashCode(); + hash ^= int64Field_.GetHashCode(); + hash ^= uint64Field_.GetHashCode(); + hash ^= int32Field_.GetHashCode(); + hash ^= uint32Field_.GetHashCode(); + hash ^= boolField_.GetHashCode(); + hash ^= stringField_.GetHashCode(); + hash ^= bytesField_.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + anyField_.WriteTo(output, _repeated_anyField_codec); + apiField_.WriteTo(output, _repeated_apiField_codec); + durationField_.WriteTo(output, _repeated_durationField_codec); + emptyField_.WriteTo(output, _repeated_emptyField_codec); + fieldMaskField_.WriteTo(output, _repeated_fieldMaskField_codec); + sourceContextField_.WriteTo(output, _repeated_sourceContextField_codec); + structField_.WriteTo(output, _repeated_structField_codec); + timestampField_.WriteTo(output, _repeated_timestampField_codec); + typeField_.WriteTo(output, _repeated_typeField_codec); + doubleField_.WriteTo(output, _repeated_doubleField_codec); + floatField_.WriteTo(output, _repeated_floatField_codec); + int64Field_.WriteTo(output, _repeated_int64Field_codec); + uint64Field_.WriteTo(output, _repeated_uint64Field_codec); + int32Field_.WriteTo(output, _repeated_int32Field_codec); + uint32Field_.WriteTo(output, _repeated_uint32Field_codec); + boolField_.WriteTo(output, _repeated_boolField_codec); + stringField_.WriteTo(output, _repeated_stringField_codec); + bytesField_.WriteTo(output, _repeated_bytesField_codec); + } + + public int CalculateSize() { + int size = 0; + size += anyField_.CalculateSize(_repeated_anyField_codec); + size += apiField_.CalculateSize(_repeated_apiField_codec); + size += durationField_.CalculateSize(_repeated_durationField_codec); + size += emptyField_.CalculateSize(_repeated_emptyField_codec); + size += fieldMaskField_.CalculateSize(_repeated_fieldMaskField_codec); + size += sourceContextField_.CalculateSize(_repeated_sourceContextField_codec); + size += structField_.CalculateSize(_repeated_structField_codec); + size += timestampField_.CalculateSize(_repeated_timestampField_codec); + size += typeField_.CalculateSize(_repeated_typeField_codec); + size += doubleField_.CalculateSize(_repeated_doubleField_codec); + size += floatField_.CalculateSize(_repeated_floatField_codec); + size += int64Field_.CalculateSize(_repeated_int64Field_codec); + size += uint64Field_.CalculateSize(_repeated_uint64Field_codec); + size += int32Field_.CalculateSize(_repeated_int32Field_codec); + size += uint32Field_.CalculateSize(_repeated_uint32Field_codec); + size += boolField_.CalculateSize(_repeated_boolField_codec); + size += stringField_.CalculateSize(_repeated_stringField_codec); + size += bytesField_.CalculateSize(_repeated_bytesField_codec); + return size; + } + + public void MergeFrom(RepeatedWellKnownTypes other) { + if (other == null) { + return; + } + anyField_.Add(other.anyField_); + apiField_.Add(other.apiField_); + durationField_.Add(other.durationField_); + emptyField_.Add(other.emptyField_); + fieldMaskField_.Add(other.fieldMaskField_); + sourceContextField_.Add(other.sourceContextField_); + structField_.Add(other.structField_); + timestampField_.Add(other.timestampField_); + typeField_.Add(other.typeField_); + doubleField_.Add(other.doubleField_); + floatField_.Add(other.floatField_); + int64Field_.Add(other.int64Field_); + uint64Field_.Add(other.uint64Field_); + int32Field_.Add(other.int32Field_); + uint32Field_.Add(other.uint32Field_); + boolField_.Add(other.boolField_); + stringField_.Add(other.stringField_); + bytesField_.Add(other.bytesField_); + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + anyField_.AddEntriesFrom(input, _repeated_anyField_codec); + break; + } + case 18: { + apiField_.AddEntriesFrom(input, _repeated_apiField_codec); + break; + } + case 26: { + durationField_.AddEntriesFrom(input, _repeated_durationField_codec); + break; + } + case 34: { + emptyField_.AddEntriesFrom(input, _repeated_emptyField_codec); + break; + } + case 42: { + fieldMaskField_.AddEntriesFrom(input, _repeated_fieldMaskField_codec); + break; + } + case 50: { + sourceContextField_.AddEntriesFrom(input, _repeated_sourceContextField_codec); + break; + } + case 58: { + structField_.AddEntriesFrom(input, _repeated_structField_codec); + break; + } + case 66: { + timestampField_.AddEntriesFrom(input, _repeated_timestampField_codec); + break; + } + case 74: { + typeField_.AddEntriesFrom(input, _repeated_typeField_codec); + break; + } + case 82: { + doubleField_.AddEntriesFrom(input, _repeated_doubleField_codec); + break; + } + case 90: { + floatField_.AddEntriesFrom(input, _repeated_floatField_codec); + break; + } + case 98: { + int64Field_.AddEntriesFrom(input, _repeated_int64Field_codec); + break; + } + case 106: { + uint64Field_.AddEntriesFrom(input, _repeated_uint64Field_codec); + break; + } + case 114: { + int32Field_.AddEntriesFrom(input, _repeated_int32Field_codec); + break; + } + case 122: { + uint32Field_.AddEntriesFrom(input, _repeated_uint32Field_codec); + break; + } + case 130: { + boolField_.AddEntriesFrom(input, _repeated_boolField_codec); + break; + } + case 138: { + stringField_.AddEntriesFrom(input, _repeated_stringField_codec); + break; + } + case 146: { + bytesField_.AddEntriesFrom(input, _repeated_bytesField_codec); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class OneofWellKnownTypes : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new OneofWellKnownTypes()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "any_field", "api_field", "bool_field", "bytes_field", "double_field", "duration_field", "empty_field", "field_mask_field", "float_field", "int32_field", "int64_field", "source_context_field", "string_field", "struct_field", "timestamp_field", "type_field", "uint32_field", "uint64_field" }; + private static readonly uint[] _fieldTags = new uint[] { 10, 18, 130, 146, 82, 26, 34, 42, 90, 114, 98, 50, 138, 58, 66, 74, 122, 106 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.UnittestWellKnownTypes.Descriptor.MessageTypes[2]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.TestProtos.UnittestWellKnownTypes.internal__static_protobuf_unittest_OneofWellKnownTypes__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public OneofWellKnownTypes() { + OnConstruction(); + } + + partial void OnConstruction(); + + public OneofWellKnownTypes(OneofWellKnownTypes other) : this() { + switch (other.OneofFieldCase) { + case OneofFieldOneofCase.AnyField: + AnyField = other.AnyField.Clone(); + break; + case OneofFieldOneofCase.ApiField: + ApiField = other.ApiField.Clone(); + break; + case OneofFieldOneofCase.DurationField: + DurationField = other.DurationField.Clone(); + break; + case OneofFieldOneofCase.EmptyField: + EmptyField = other.EmptyField.Clone(); + break; + case OneofFieldOneofCase.FieldMaskField: + FieldMaskField = other.FieldMaskField.Clone(); + break; + case OneofFieldOneofCase.SourceContextField: + SourceContextField = other.SourceContextField.Clone(); + break; + case OneofFieldOneofCase.StructField: + StructField = other.StructField.Clone(); + break; + case OneofFieldOneofCase.TimestampField: + TimestampField = other.TimestampField.Clone(); + break; + case OneofFieldOneofCase.TypeField: + TypeField = other.TypeField.Clone(); + break; + case OneofFieldOneofCase.DoubleField: + DoubleField = other.DoubleField; + break; + case OneofFieldOneofCase.FloatField: + FloatField = other.FloatField; + break; + case OneofFieldOneofCase.Int64Field: + Int64Field = other.Int64Field; + break; + case OneofFieldOneofCase.Uint64Field: + Uint64Field = other.Uint64Field; + break; + case OneofFieldOneofCase.Int32Field: + Int32Field = other.Int32Field; + break; + case OneofFieldOneofCase.Uint32Field: + Uint32Field = other.Uint32Field; + break; + case OneofFieldOneofCase.BoolField: + BoolField = other.BoolField; + break; + case OneofFieldOneofCase.StringField: + StringField = other.StringField; + break; + case OneofFieldOneofCase.BytesField: + BytesField = other.BytesField; + break; + } + + } + + public OneofWellKnownTypes Clone() { + return new OneofWellKnownTypes(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + if (oneofField_ is IFreezable) ((IFreezable) oneofField_).Freeze(); + } + + public const int AnyFieldFieldNumber = 1; + public global::Google.Protobuf.WellKnownTypes.Any AnyField { + get { return oneofFieldCase_ == OneofFieldOneofCase.AnyField ? (global::Google.Protobuf.WellKnownTypes.Any) oneofField_ : null; } + set { + pb::Freezable.CheckMutable(this); + oneofField_ = value; + oneofFieldCase_ = value == null ? OneofFieldOneofCase.None : OneofFieldOneofCase.AnyField; + } + } + + public const int ApiFieldFieldNumber = 2; + public global::Google.Protobuf.WellKnownTypes.Api ApiField { + get { return oneofFieldCase_ == OneofFieldOneofCase.ApiField ? (global::Google.Protobuf.WellKnownTypes.Api) oneofField_ : null; } + set { + pb::Freezable.CheckMutable(this); + oneofField_ = value; + oneofFieldCase_ = value == null ? OneofFieldOneofCase.None : OneofFieldOneofCase.ApiField; + } + } + + public const int DurationFieldFieldNumber = 3; + public global::Google.Protobuf.WellKnownTypes.Duration DurationField { + get { return oneofFieldCase_ == OneofFieldOneofCase.DurationField ? (global::Google.Protobuf.WellKnownTypes.Duration) oneofField_ : null; } + set { + pb::Freezable.CheckMutable(this); + oneofField_ = value; + oneofFieldCase_ = value == null ? OneofFieldOneofCase.None : OneofFieldOneofCase.DurationField; + } + } + + public const int EmptyFieldFieldNumber = 4; + public global::Google.Protobuf.WellKnownTypes.Empty EmptyField { + get { return oneofFieldCase_ == OneofFieldOneofCase.EmptyField ? (global::Google.Protobuf.WellKnownTypes.Empty) oneofField_ : null; } + set { + pb::Freezable.CheckMutable(this); + oneofField_ = value; + oneofFieldCase_ = value == null ? OneofFieldOneofCase.None : OneofFieldOneofCase.EmptyField; + } + } + + public const int FieldMaskFieldFieldNumber = 5; + public global::Google.Protobuf.WellKnownTypes.FieldMask FieldMaskField { + get { return oneofFieldCase_ == OneofFieldOneofCase.FieldMaskField ? (global::Google.Protobuf.WellKnownTypes.FieldMask) oneofField_ : null; } + set { + pb::Freezable.CheckMutable(this); + oneofField_ = value; + oneofFieldCase_ = value == null ? OneofFieldOneofCase.None : OneofFieldOneofCase.FieldMaskField; + } + } + + public const int SourceContextFieldFieldNumber = 6; + public global::Google.Protobuf.WellKnownTypes.SourceContext SourceContextField { + get { return oneofFieldCase_ == OneofFieldOneofCase.SourceContextField ? (global::Google.Protobuf.WellKnownTypes.SourceContext) oneofField_ : null; } + set { + pb::Freezable.CheckMutable(this); + oneofField_ = value; + oneofFieldCase_ = value == null ? OneofFieldOneofCase.None : OneofFieldOneofCase.SourceContextField; + } + } + + public const int StructFieldFieldNumber = 7; + public global::Google.Protobuf.WellKnownTypes.Struct StructField { + get { return oneofFieldCase_ == OneofFieldOneofCase.StructField ? (global::Google.Protobuf.WellKnownTypes.Struct) oneofField_ : null; } + set { + pb::Freezable.CheckMutable(this); + oneofField_ = value; + oneofFieldCase_ = value == null ? OneofFieldOneofCase.None : OneofFieldOneofCase.StructField; + } + } + + public const int TimestampFieldFieldNumber = 8; + public global::Google.Protobuf.WellKnownTypes.Timestamp TimestampField { + get { return oneofFieldCase_ == OneofFieldOneofCase.TimestampField ? (global::Google.Protobuf.WellKnownTypes.Timestamp) oneofField_ : null; } + set { + pb::Freezable.CheckMutable(this); + oneofField_ = value; + oneofFieldCase_ = value == null ? OneofFieldOneofCase.None : OneofFieldOneofCase.TimestampField; + } + } + + public const int TypeFieldFieldNumber = 9; + public global::Google.Protobuf.WellKnownTypes.Type TypeField { + get { return oneofFieldCase_ == OneofFieldOneofCase.TypeField ? (global::Google.Protobuf.WellKnownTypes.Type) oneofField_ : null; } + set { + pb::Freezable.CheckMutable(this); + oneofField_ = value; + oneofFieldCase_ = value == null ? OneofFieldOneofCase.None : OneofFieldOneofCase.TypeField; + } + } + + public const int DoubleFieldFieldNumber = 10; + private static readonly pb::FieldCodec _oneof_doubleField_codec = pb::FieldCodec.ForStructWrapper(82); + public double? DoubleField { + get { return oneofFieldCase_ == OneofFieldOneofCase.DoubleField ? (double?) oneofField_ : (double?) null; } + set { + pb::Freezable.CheckMutable(this); + oneofField_ = value; + oneofFieldCase_ = value == null ? OneofFieldOneofCase.None : OneofFieldOneofCase.DoubleField; + } + } + + public const int FloatFieldFieldNumber = 11; + private static readonly pb::FieldCodec _oneof_floatField_codec = pb::FieldCodec.ForStructWrapper(90); + public float? FloatField { + get { return oneofFieldCase_ == OneofFieldOneofCase.FloatField ? (float?) oneofField_ : (float?) null; } + set { + pb::Freezable.CheckMutable(this); + oneofField_ = value; + oneofFieldCase_ = value == null ? OneofFieldOneofCase.None : OneofFieldOneofCase.FloatField; + } + } + + public const int Int64FieldFieldNumber = 12; + private static readonly pb::FieldCodec _oneof_int64Field_codec = pb::FieldCodec.ForStructWrapper(98); + public long? Int64Field { + get { return oneofFieldCase_ == OneofFieldOneofCase.Int64Field ? (long?) oneofField_ : (long?) null; } + set { + pb::Freezable.CheckMutable(this); + oneofField_ = value; + oneofFieldCase_ = value == null ? OneofFieldOneofCase.None : OneofFieldOneofCase.Int64Field; + } + } + + public const int Uint64FieldFieldNumber = 13; + private static readonly pb::FieldCodec _oneof_uint64Field_codec = pb::FieldCodec.ForStructWrapper(106); + public ulong? Uint64Field { + get { return oneofFieldCase_ == OneofFieldOneofCase.Uint64Field ? (ulong?) oneofField_ : (ulong?) null; } + set { + pb::Freezable.CheckMutable(this); + oneofField_ = value; + oneofFieldCase_ = value == null ? OneofFieldOneofCase.None : OneofFieldOneofCase.Uint64Field; + } + } + + public const int Int32FieldFieldNumber = 14; + private static readonly pb::FieldCodec _oneof_int32Field_codec = pb::FieldCodec.ForStructWrapper(114); + public int? Int32Field { + get { return oneofFieldCase_ == OneofFieldOneofCase.Int32Field ? (int?) oneofField_ : (int?) null; } + set { + pb::Freezable.CheckMutable(this); + oneofField_ = value; + oneofFieldCase_ = value == null ? OneofFieldOneofCase.None : OneofFieldOneofCase.Int32Field; + } + } + + public const int Uint32FieldFieldNumber = 15; + private static readonly pb::FieldCodec _oneof_uint32Field_codec = pb::FieldCodec.ForStructWrapper(122); + public uint? Uint32Field { + get { return oneofFieldCase_ == OneofFieldOneofCase.Uint32Field ? (uint?) oneofField_ : (uint?) null; } + set { + pb::Freezable.CheckMutable(this); + oneofField_ = value; + oneofFieldCase_ = value == null ? OneofFieldOneofCase.None : OneofFieldOneofCase.Uint32Field; + } + } + + public const int BoolFieldFieldNumber = 16; + private static readonly pb::FieldCodec _oneof_boolField_codec = pb::FieldCodec.ForStructWrapper(130); + public bool? BoolField { + get { return oneofFieldCase_ == OneofFieldOneofCase.BoolField ? (bool?) oneofField_ : (bool?) null; } + set { + pb::Freezable.CheckMutable(this); + oneofField_ = value; + oneofFieldCase_ = value == null ? OneofFieldOneofCase.None : OneofFieldOneofCase.BoolField; + } + } + + public const int StringFieldFieldNumber = 17; + private static readonly pb::FieldCodec _oneof_stringField_codec = pb::FieldCodec.ForClassWrapper(138); + public string StringField { + get { return oneofFieldCase_ == OneofFieldOneofCase.StringField ? (string) oneofField_ : (string) null; } + set { + pb::Freezable.CheckMutable(this); + oneofField_ = value; + oneofFieldCase_ = value == null ? OneofFieldOneofCase.None : OneofFieldOneofCase.StringField; + } + } + + public const int BytesFieldFieldNumber = 18; + private static readonly pb::FieldCodec _oneof_bytesField_codec = pb::FieldCodec.ForClassWrapper(146); + public pb::ByteString BytesField { + get { return oneofFieldCase_ == OneofFieldOneofCase.BytesField ? (pb::ByteString) oneofField_ : (pb::ByteString) null; } + set { + pb::Freezable.CheckMutable(this); + oneofField_ = value; + oneofFieldCase_ = value == null ? OneofFieldOneofCase.None : OneofFieldOneofCase.BytesField; + } + } + + private object oneofField_; + public enum OneofFieldOneofCase { + None = 0, + AnyField = 1, + ApiField = 2, + DurationField = 3, + EmptyField = 4, + FieldMaskField = 5, + SourceContextField = 6, + StructField = 7, + TimestampField = 8, + TypeField = 9, + DoubleField = 10, + FloatField = 11, + Int64Field = 12, + Uint64Field = 13, + Int32Field = 14, + Uint32Field = 15, + BoolField = 16, + StringField = 17, + BytesField = 18, + } + private OneofFieldOneofCase oneofFieldCase_ = OneofFieldOneofCase.None; + public OneofFieldOneofCase OneofFieldCase { + get { return oneofFieldCase_; } + } + + public void ClearOneofField() { + pb::Freezable.CheckMutable(this); + oneofFieldCase_ = OneofFieldOneofCase.None; + oneofField_ = null; + } + + public override bool Equals(object other) { + return Equals(other as OneofWellKnownTypes); + } + + public bool Equals(OneofWellKnownTypes other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (!object.Equals(AnyField, other.AnyField)) return false; + if (!object.Equals(ApiField, other.ApiField)) return false; + if (!object.Equals(DurationField, other.DurationField)) return false; + if (!object.Equals(EmptyField, other.EmptyField)) return false; + if (!object.Equals(FieldMaskField, other.FieldMaskField)) return false; + if (!object.Equals(SourceContextField, other.SourceContextField)) return false; + if (!object.Equals(StructField, other.StructField)) return false; + if (!object.Equals(TimestampField, other.TimestampField)) return false; + if (!object.Equals(TypeField, other.TypeField)) return false; + if (DoubleField != other.DoubleField) return false; + if (FloatField != other.FloatField) return false; + if (Int64Field != other.Int64Field) return false; + if (Uint64Field != other.Uint64Field) return false; + if (Int32Field != other.Int32Field) return false; + if (Uint32Field != other.Uint32Field) return false; + if (BoolField != other.BoolField) return false; + if (StringField != other.StringField) return false; + if (BytesField != other.BytesField) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (oneofFieldCase_ == OneofFieldOneofCase.AnyField) hash ^= AnyField.GetHashCode(); + if (oneofFieldCase_ == OneofFieldOneofCase.ApiField) hash ^= ApiField.GetHashCode(); + if (oneofFieldCase_ == OneofFieldOneofCase.DurationField) hash ^= DurationField.GetHashCode(); + if (oneofFieldCase_ == OneofFieldOneofCase.EmptyField) hash ^= EmptyField.GetHashCode(); + if (oneofFieldCase_ == OneofFieldOneofCase.FieldMaskField) hash ^= FieldMaskField.GetHashCode(); + if (oneofFieldCase_ == OneofFieldOneofCase.SourceContextField) hash ^= SourceContextField.GetHashCode(); + if (oneofFieldCase_ == OneofFieldOneofCase.StructField) hash ^= StructField.GetHashCode(); + if (oneofFieldCase_ == OneofFieldOneofCase.TimestampField) hash ^= TimestampField.GetHashCode(); + if (oneofFieldCase_ == OneofFieldOneofCase.TypeField) hash ^= TypeField.GetHashCode(); + if (oneofFieldCase_ == OneofFieldOneofCase.DoubleField) hash ^= DoubleField.GetHashCode(); + if (oneofFieldCase_ == OneofFieldOneofCase.FloatField) hash ^= FloatField.GetHashCode(); + if (oneofFieldCase_ == OneofFieldOneofCase.Int64Field) hash ^= Int64Field.GetHashCode(); + if (oneofFieldCase_ == OneofFieldOneofCase.Uint64Field) hash ^= Uint64Field.GetHashCode(); + if (oneofFieldCase_ == OneofFieldOneofCase.Int32Field) hash ^= Int32Field.GetHashCode(); + if (oneofFieldCase_ == OneofFieldOneofCase.Uint32Field) hash ^= Uint32Field.GetHashCode(); + if (oneofFieldCase_ == OneofFieldOneofCase.BoolField) hash ^= BoolField.GetHashCode(); + if (oneofFieldCase_ == OneofFieldOneofCase.StringField) hash ^= StringField.GetHashCode(); + if (oneofFieldCase_ == OneofFieldOneofCase.BytesField) hash ^= BytesField.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream 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(output, (double?) oneofField_); + } + if (oneofFieldCase_ == OneofFieldOneofCase.FloatField) { + _oneof_floatField_codec.WriteTagAndValue(output, (float?) oneofField_); + } + if (oneofFieldCase_ == OneofFieldOneofCase.Int64Field) { + _oneof_int64Field_codec.WriteTagAndValue(output, (long?) oneofField_); + } + if (oneofFieldCase_ == OneofFieldOneofCase.Uint64Field) { + _oneof_uint64Field_codec.WriteTagAndValue(output, (ulong?) oneofField_); + } + if (oneofFieldCase_ == OneofFieldOneofCase.Int32Field) { + _oneof_int32Field_codec.WriteTagAndValue(output, (int?) oneofField_); + } + if (oneofFieldCase_ == OneofFieldOneofCase.Uint32Field) { + _oneof_uint32Field_codec.WriteTagAndValue(output, (uint?) oneofField_); + } + if (oneofFieldCase_ == OneofFieldOneofCase.BoolField) { + _oneof_boolField_codec.WriteTagAndValue(output, (bool?) oneofField_); + } + if (oneofFieldCase_ == OneofFieldOneofCase.StringField) { + _oneof_stringField_codec.WriteTagAndValue(output, (string) oneofField_); + } + if (oneofFieldCase_ == OneofFieldOneofCase.BytesField) { + _oneof_bytesField_codec.WriteTagAndValue(output, (pb::ByteString) oneofField_); + } + } + + public int CalculateSize() { + int size = 0; + if (oneofFieldCase_ == OneofFieldOneofCase.AnyField) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(AnyField); + } + if (oneofFieldCase_ == OneofFieldOneofCase.ApiField) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(ApiField); + } + if (oneofFieldCase_ == OneofFieldOneofCase.DurationField) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(DurationField); + } + if (oneofFieldCase_ == OneofFieldOneofCase.EmptyField) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(EmptyField); + } + if (oneofFieldCase_ == OneofFieldOneofCase.FieldMaskField) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(FieldMaskField); + } + if (oneofFieldCase_ == OneofFieldOneofCase.SourceContextField) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(SourceContextField); + } + if (oneofFieldCase_ == OneofFieldOneofCase.StructField) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(StructField); + } + if (oneofFieldCase_ == OneofFieldOneofCase.TimestampField) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(TimestampField); + } + if (oneofFieldCase_ == OneofFieldOneofCase.TypeField) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(TypeField); + } + if (oneofFieldCase_ == OneofFieldOneofCase.DoubleField) { + size += _oneof_doubleField_codec.CalculateSizeWithTag(DoubleField); + } + if (oneofFieldCase_ == OneofFieldOneofCase.FloatField) { + size += _oneof_floatField_codec.CalculateSizeWithTag(FloatField); + } + if (oneofFieldCase_ == OneofFieldOneofCase.Int64Field) { + size += _oneof_int64Field_codec.CalculateSizeWithTag(Int64Field); + } + if (oneofFieldCase_ == OneofFieldOneofCase.Uint64Field) { + size += _oneof_uint64Field_codec.CalculateSizeWithTag(Uint64Field); + } + if (oneofFieldCase_ == OneofFieldOneofCase.Int32Field) { + size += _oneof_int32Field_codec.CalculateSizeWithTag(Int32Field); + } + if (oneofFieldCase_ == OneofFieldOneofCase.Uint32Field) { + size += _oneof_uint32Field_codec.CalculateSizeWithTag(Uint32Field); + } + if (oneofFieldCase_ == OneofFieldOneofCase.BoolField) { + size += _oneof_boolField_codec.CalculateSizeWithTag(BoolField); + } + if (oneofFieldCase_ == OneofFieldOneofCase.StringField) { + size += _oneof_stringField_codec.CalculateSizeWithTag(StringField); + } + if (oneofFieldCase_ == OneofFieldOneofCase.BytesField) { + size += _oneof_bytesField_codec.CalculateSizeWithTag(BytesField); + } + return size; + } + + public void MergeFrom(OneofWellKnownTypes other) { + if (other == null) { + return; + } + switch (other.OneofFieldCase) { + case OneofFieldOneofCase.AnyField: + AnyField = other.AnyField; + break; + case OneofFieldOneofCase.ApiField: + ApiField = other.ApiField; + break; + case OneofFieldOneofCase.DurationField: + DurationField = other.DurationField; + break; + case OneofFieldOneofCase.EmptyField: + EmptyField = other.EmptyField; + break; + case OneofFieldOneofCase.FieldMaskField: + FieldMaskField = other.FieldMaskField; + break; + case OneofFieldOneofCase.SourceContextField: + SourceContextField = other.SourceContextField; + break; + case OneofFieldOneofCase.StructField: + StructField = other.StructField; + break; + case OneofFieldOneofCase.TimestampField: + TimestampField = other.TimestampField; + break; + case OneofFieldOneofCase.TypeField: + TypeField = other.TypeField; + break; + case OneofFieldOneofCase.DoubleField: + DoubleField = other.DoubleField; + break; + case OneofFieldOneofCase.FloatField: + FloatField = other.FloatField; + break; + case OneofFieldOneofCase.Int64Field: + Int64Field = other.Int64Field; + break; + case OneofFieldOneofCase.Uint64Field: + Uint64Field = other.Uint64Field; + break; + case OneofFieldOneofCase.Int32Field: + Int32Field = other.Int32Field; + break; + case OneofFieldOneofCase.Uint32Field: + Uint32Field = other.Uint32Field; + break; + case OneofFieldOneofCase.BoolField: + BoolField = other.BoolField; + break; + case OneofFieldOneofCase.StringField: + StringField = other.StringField; + break; + case OneofFieldOneofCase.BytesField: + BytesField = other.BytesField; + break; + } + + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + 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(input); + break; + } + case 90: { + FloatField = _oneof_floatField_codec.Read(input); + break; + } + case 98: { + Int64Field = _oneof_int64Field_codec.Read(input); + break; + } + case 106: { + Uint64Field = _oneof_uint64Field_codec.Read(input); + break; + } + case 114: { + Int32Field = _oneof_int32Field_codec.Read(input); + break; + } + case 122: { + Uint32Field = _oneof_uint32Field_codec.Read(input); + break; + } + case 130: { + BoolField = _oneof_boolField_codec.Read(input); + break; + } + case 138: { + StringField = _oneof_stringField_codec.Read(input); + break; + } + case 146: { + BytesField = _oneof_bytesField_codec.Read(input); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class MapWellKnownTypes : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MapWellKnownTypes()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "any_field", "api_field", "bool_field", "bytes_field", "double_field", "duration_field", "empty_field", "field_mask_field", "float_field", "int32_field", "int64_field", "source_context_field", "string_field", "struct_field", "timestamp_field", "type_field", "uint32_field", "uint64_field" }; + private static readonly uint[] _fieldTags = new uint[] { 10, 18, 130, 146, 82, 26, 34, 42, 90, 114, 98, 50, 138, 58, 66, 74, 122, 106 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.TestProtos.UnittestWellKnownTypes.Descriptor.MessageTypes[3]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.TestProtos.UnittestWellKnownTypes.internal__static_protobuf_unittest_MapWellKnownTypes__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public MapWellKnownTypes() { + OnConstruction(); + } + + partial void OnConstruction(); + + public MapWellKnownTypes(MapWellKnownTypes other) : this() { + anyField_ = other.anyField_.Clone(); + apiField_ = other.apiField_.Clone(); + durationField_ = other.durationField_.Clone(); + emptyField_ = other.emptyField_.Clone(); + fieldMaskField_ = other.fieldMaskField_.Clone(); + sourceContextField_ = other.sourceContextField_.Clone(); + structField_ = other.structField_.Clone(); + timestampField_ = other.timestampField_.Clone(); + typeField_ = other.typeField_.Clone(); + doubleField_ = other.doubleField_.Clone(); + floatField_ = other.floatField_.Clone(); + int64Field_ = other.int64Field_.Clone(); + uint64Field_ = other.uint64Field_.Clone(); + int32Field_ = other.int32Field_.Clone(); + uint32Field_ = other.uint32Field_.Clone(); + boolField_ = other.boolField_.Clone(); + stringField_ = other.stringField_.Clone(); + bytesField_ = other.bytesField_.Clone(); + } + + public MapWellKnownTypes Clone() { + return new MapWellKnownTypes(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + anyField_.Freeze(); + apiField_.Freeze(); + durationField_.Freeze(); + emptyField_.Freeze(); + fieldMaskField_.Freeze(); + sourceContextField_.Freeze(); + structField_.Freeze(); + timestampField_.Freeze(); + typeField_.Freeze(); + doubleField_.Freeze(); + floatField_.Freeze(); + int64Field_.Freeze(); + uint64Field_.Freeze(); + int32Field_.Freeze(); + uint32Field_.Freeze(); + boolField_.Freeze(); + stringField_.Freeze(); + bytesField_.Freeze(); + } + + public const int AnyFieldFieldNumber = 1; + private static readonly pbc::MapField.Codec _map_anyField_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForMessage(18, global::Google.Protobuf.WellKnownTypes.Any.Parser), 10); + private readonly pbc::MapField anyField_ = new pbc::MapField(); + public pbc::MapField AnyField { + get { return anyField_; } + } + + public const int ApiFieldFieldNumber = 2; + private static readonly pbc::MapField.Codec _map_apiField_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForMessage(18, global::Google.Protobuf.WellKnownTypes.Api.Parser), 18); + private readonly pbc::MapField apiField_ = new pbc::MapField(); + public pbc::MapField ApiField { + get { return apiField_; } + } + + public const int DurationFieldFieldNumber = 3; + private static readonly pbc::MapField.Codec _map_durationField_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForMessage(18, global::Google.Protobuf.WellKnownTypes.Duration.Parser), 26); + private readonly pbc::MapField durationField_ = new pbc::MapField(); + public pbc::MapField DurationField { + get { return durationField_; } + } + + public const int EmptyFieldFieldNumber = 4; + private static readonly pbc::MapField.Codec _map_emptyField_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForMessage(18, global::Google.Protobuf.WellKnownTypes.Empty.Parser), 34); + private readonly pbc::MapField emptyField_ = new pbc::MapField(); + public pbc::MapField EmptyField { + get { return emptyField_; } + } + + public const int FieldMaskFieldFieldNumber = 5; + private static readonly pbc::MapField.Codec _map_fieldMaskField_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForMessage(18, global::Google.Protobuf.WellKnownTypes.FieldMask.Parser), 42); + private readonly pbc::MapField fieldMaskField_ = new pbc::MapField(); + public pbc::MapField FieldMaskField { + get { return fieldMaskField_; } + } + + public const int SourceContextFieldFieldNumber = 6; + private static readonly pbc::MapField.Codec _map_sourceContextField_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForMessage(18, global::Google.Protobuf.WellKnownTypes.SourceContext.Parser), 50); + private readonly pbc::MapField sourceContextField_ = new pbc::MapField(); + public pbc::MapField SourceContextField { + get { return sourceContextField_; } + } + + public const int StructFieldFieldNumber = 7; + private static readonly pbc::MapField.Codec _map_structField_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForMessage(18, global::Google.Protobuf.WellKnownTypes.Struct.Parser), 58); + private readonly pbc::MapField structField_ = new pbc::MapField(); + public pbc::MapField StructField { + get { return structField_; } + } + + public const int TimestampFieldFieldNumber = 8; + private static readonly pbc::MapField.Codec _map_timestampField_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForMessage(18, global::Google.Protobuf.WellKnownTypes.Timestamp.Parser), 66); + private readonly pbc::MapField timestampField_ = new pbc::MapField(); + public pbc::MapField TimestampField { + get { return timestampField_; } + } + + public const int TypeFieldFieldNumber = 9; + private static readonly pbc::MapField.Codec _map_typeField_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForMessage(18, global::Google.Protobuf.WellKnownTypes.Type.Parser), 74); + private readonly pbc::MapField typeField_ = new pbc::MapField(); + public pbc::MapField TypeField { + get { return typeField_; } + } + + public const int DoubleFieldFieldNumber = 10; + private static readonly pbc::MapField.Codec _map_doubleField_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForStructWrapper(18), 82); + private readonly pbc::MapField doubleField_ = new pbc::MapField(true); + public pbc::MapField DoubleField { + get { return doubleField_; } + } + + public const int FloatFieldFieldNumber = 11; + private static readonly pbc::MapField.Codec _map_floatField_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForStructWrapper(18), 90); + private readonly pbc::MapField floatField_ = new pbc::MapField(true); + public pbc::MapField FloatField { + get { return floatField_; } + } + + public const int Int64FieldFieldNumber = 12; + private static readonly pbc::MapField.Codec _map_int64Field_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForStructWrapper(18), 98); + private readonly pbc::MapField int64Field_ = new pbc::MapField(true); + public pbc::MapField Int64Field { + get { return int64Field_; } + } + + public const int Uint64FieldFieldNumber = 13; + private static readonly pbc::MapField.Codec _map_uint64Field_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForStructWrapper(18), 106); + private readonly pbc::MapField uint64Field_ = new pbc::MapField(true); + public pbc::MapField Uint64Field { + get { return uint64Field_; } + } + + public const int Int32FieldFieldNumber = 14; + private static readonly pbc::MapField.Codec _map_int32Field_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForStructWrapper(18), 114); + private readonly pbc::MapField int32Field_ = new pbc::MapField(true); + public pbc::MapField Int32Field { + get { return int32Field_; } + } + + public const int Uint32FieldFieldNumber = 15; + private static readonly pbc::MapField.Codec _map_uint32Field_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForStructWrapper(18), 122); + private readonly pbc::MapField uint32Field_ = new pbc::MapField(true); + public pbc::MapField Uint32Field { + get { return uint32Field_; } + } + + public const int BoolFieldFieldNumber = 16; + private static readonly pbc::MapField.Codec _map_boolField_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForStructWrapper(18), 130); + private readonly pbc::MapField boolField_ = new pbc::MapField(true); + public pbc::MapField BoolField { + get { return boolField_; } + } + + public const int StringFieldFieldNumber = 17; + private static readonly pbc::MapField.Codec _map_stringField_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForClassWrapper(18), 138); + private readonly pbc::MapField stringField_ = new pbc::MapField(true); + public pbc::MapField StringField { + get { return stringField_; } + } + + public const int BytesFieldFieldNumber = 18; + private static readonly pbc::MapField.Codec _map_bytesField_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForClassWrapper(18), 146); + private readonly pbc::MapField bytesField_ = new pbc::MapField(true); + public pbc::MapField BytesField { + get { return bytesField_; } + } + + public override bool Equals(object other) { + return Equals(other as MapWellKnownTypes); + } + + public bool Equals(MapWellKnownTypes other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (!AnyField.Equals(other.AnyField)) return false; + if (!ApiField.Equals(other.ApiField)) return false; + if (!DurationField.Equals(other.DurationField)) return false; + if (!EmptyField.Equals(other.EmptyField)) return false; + if (!FieldMaskField.Equals(other.FieldMaskField)) return false; + if (!SourceContextField.Equals(other.SourceContextField)) return false; + if (!StructField.Equals(other.StructField)) return false; + if (!TimestampField.Equals(other.TimestampField)) return false; + if (!TypeField.Equals(other.TypeField)) return false; + if (!DoubleField.Equals(other.DoubleField)) return false; + if (!FloatField.Equals(other.FloatField)) return false; + if (!Int64Field.Equals(other.Int64Field)) return false; + if (!Uint64Field.Equals(other.Uint64Field)) return false; + if (!Int32Field.Equals(other.Int32Field)) return false; + if (!Uint32Field.Equals(other.Uint32Field)) return false; + if (!BoolField.Equals(other.BoolField)) return false; + if (!StringField.Equals(other.StringField)) return false; + if (!BytesField.Equals(other.BytesField)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + hash ^= AnyField.GetHashCode(); + hash ^= ApiField.GetHashCode(); + hash ^= DurationField.GetHashCode(); + hash ^= EmptyField.GetHashCode(); + hash ^= FieldMaskField.GetHashCode(); + hash ^= SourceContextField.GetHashCode(); + hash ^= StructField.GetHashCode(); + hash ^= TimestampField.GetHashCode(); + hash ^= TypeField.GetHashCode(); + hash ^= DoubleField.GetHashCode(); + hash ^= FloatField.GetHashCode(); + hash ^= Int64Field.GetHashCode(); + hash ^= Uint64Field.GetHashCode(); + hash ^= Int32Field.GetHashCode(); + hash ^= Uint32Field.GetHashCode(); + hash ^= BoolField.GetHashCode(); + hash ^= StringField.GetHashCode(); + hash ^= BytesField.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + anyField_.WriteTo(output, _map_anyField_codec); + apiField_.WriteTo(output, _map_apiField_codec); + durationField_.WriteTo(output, _map_durationField_codec); + emptyField_.WriteTo(output, _map_emptyField_codec); + fieldMaskField_.WriteTo(output, _map_fieldMaskField_codec); + sourceContextField_.WriteTo(output, _map_sourceContextField_codec); + structField_.WriteTo(output, _map_structField_codec); + timestampField_.WriteTo(output, _map_timestampField_codec); + typeField_.WriteTo(output, _map_typeField_codec); + doubleField_.WriteTo(output, _map_doubleField_codec); + floatField_.WriteTo(output, _map_floatField_codec); + int64Field_.WriteTo(output, _map_int64Field_codec); + uint64Field_.WriteTo(output, _map_uint64Field_codec); + int32Field_.WriteTo(output, _map_int32Field_codec); + uint32Field_.WriteTo(output, _map_uint32Field_codec); + boolField_.WriteTo(output, _map_boolField_codec); + stringField_.WriteTo(output, _map_stringField_codec); + bytesField_.WriteTo(output, _map_bytesField_codec); + } + + public int CalculateSize() { + int size = 0; + size += anyField_.CalculateSize(_map_anyField_codec); + size += apiField_.CalculateSize(_map_apiField_codec); + size += durationField_.CalculateSize(_map_durationField_codec); + size += emptyField_.CalculateSize(_map_emptyField_codec); + size += fieldMaskField_.CalculateSize(_map_fieldMaskField_codec); + size += sourceContextField_.CalculateSize(_map_sourceContextField_codec); + size += structField_.CalculateSize(_map_structField_codec); + size += timestampField_.CalculateSize(_map_timestampField_codec); + size += typeField_.CalculateSize(_map_typeField_codec); + size += doubleField_.CalculateSize(_map_doubleField_codec); + size += floatField_.CalculateSize(_map_floatField_codec); + size += int64Field_.CalculateSize(_map_int64Field_codec); + size += uint64Field_.CalculateSize(_map_uint64Field_codec); + size += int32Field_.CalculateSize(_map_int32Field_codec); + size += uint32Field_.CalculateSize(_map_uint32Field_codec); + size += boolField_.CalculateSize(_map_boolField_codec); + size += stringField_.CalculateSize(_map_stringField_codec); + size += bytesField_.CalculateSize(_map_bytesField_codec); + return size; + } + + public void MergeFrom(MapWellKnownTypes other) { + if (other == null) { + return; + } + anyField_.Add(other.anyField_); + apiField_.Add(other.apiField_); + durationField_.Add(other.durationField_); + emptyField_.Add(other.emptyField_); + fieldMaskField_.Add(other.fieldMaskField_); + sourceContextField_.Add(other.sourceContextField_); + structField_.Add(other.structField_); + timestampField_.Add(other.timestampField_); + typeField_.Add(other.typeField_); + doubleField_.Add(other.doubleField_); + floatField_.Add(other.floatField_); + int64Field_.Add(other.int64Field_); + uint64Field_.Add(other.uint64Field_); + int32Field_.Add(other.int32Field_); + uint32Field_.Add(other.uint32Field_); + boolField_.Add(other.boolField_); + stringField_.Add(other.stringField_); + bytesField_.Add(other.bytesField_); + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + anyField_.AddEntriesFrom(input, _map_anyField_codec); + break; + } + case 18: { + apiField_.AddEntriesFrom(input, _map_apiField_codec); + break; + } + case 26: { + durationField_.AddEntriesFrom(input, _map_durationField_codec); + break; + } + case 34: { + emptyField_.AddEntriesFrom(input, _map_emptyField_codec); + break; + } + case 42: { + fieldMaskField_.AddEntriesFrom(input, _map_fieldMaskField_codec); + break; + } + case 50: { + sourceContextField_.AddEntriesFrom(input, _map_sourceContextField_codec); + break; + } + case 58: { + structField_.AddEntriesFrom(input, _map_structField_codec); + break; + } + case 66: { + timestampField_.AddEntriesFrom(input, _map_timestampField_codec); + break; + } + case 74: { + typeField_.AddEntriesFrom(input, _map_typeField_codec); + break; + } + case 82: { + doubleField_.AddEntriesFrom(input, _map_doubleField_codec); + break; + } + case 90: { + floatField_.AddEntriesFrom(input, _map_floatField_codec); + break; + } + case 98: { + int64Field_.AddEntriesFrom(input, _map_int64Field_codec); + break; + } + case 106: { + uint64Field_.AddEntriesFrom(input, _map_uint64Field_codec); + break; + } + case 114: { + int32Field_.AddEntriesFrom(input, _map_int32Field_codec); + break; + } + case 122: { + uint32Field_.AddEntriesFrom(input, _map_uint32Field_codec); + break; + } + case 130: { + boolField_.AddEntriesFrom(input, _map_boolField_codec); + break; + } + case 138: { + stringField_.AddEntriesFrom(input, _map_stringField_codec); + break; + } + case 146: { + bytesField_.AddEntriesFrom(input, _map_bytesField_codec); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs b/csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs new file mode 100644 index 00000000..ad88c4eb --- /dev/null +++ b/csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs @@ -0,0 +1,326 @@ +#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 System; +using Google.Protobuf.TestProtos; +using NUnit.Framework; +using System.Collections; +using System.IO; + +namespace Google.Protobuf.WellKnownTypes +{ + public class WrappersTest + { + [Test] + public void NullIsDefault() + { + var message = new TestWellKnownTypes(); + Assert.IsNull(message.StringField); + Assert.IsNull(message.BytesField); + Assert.IsNull(message.BoolField); + Assert.IsNull(message.FloatField); + Assert.IsNull(message.DoubleField); + Assert.IsNull(message.Int32Field); + Assert.IsNull(message.Int64Field); + Assert.IsNull(message.Uint32Field); + Assert.IsNull(message.Uint64Field); + } + + [Test] + public void NonDefaultSingleValues() + { + var message = new TestWellKnownTypes + { + StringField = "x", + BytesField = ByteString.CopyFrom(1, 2, 3), + BoolField = true, + FloatField = 12.5f, + DoubleField = 12.25d, + Int32Field = 1, + Int64Field = 2, + Uint32Field = 3, + 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); + } + + [Test] + public void NonNullDefaultIsPreservedThroughSerialization() + { + var message = new TestWellKnownTypes + { + StringField = "", + BytesField = ByteString.Empty, + BoolField = false, + FloatField = 0f, + DoubleField = 0d, + Int32Field = 0, + Int64Field = 0, + Uint32Field = 0, + 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); + } + + [Test] + public void RepeatedWrappersProhibitNullItems() + { + var message = new RepeatedWellKnownTypes(); + Assert.Throws(() => message.BoolField.Add((bool?) null)); + Assert.Throws(() => message.Int32Field.Add((int?) null)); + Assert.Throws(() => message.StringField.Add((string) null)); + Assert.Throws(() => message.BytesField.Add((ByteString) null)); + } + + [Test] + public void RepeatedWrappersSerializeDeserialize() + { + var message = new RepeatedWellKnownTypes + { + BoolField = { true, false }, + BytesField = { ByteString.CopyFrom(1, 2, 3), ByteString.CopyFrom(4, 5, 6), ByteString.Empty }, + DoubleField = { 12.5, -1.5, 0d }, + FloatField = { 123.25f, -20f, 0f }, + Int32Field = { int.MaxValue, int.MinValue, 0 }, + Int64Field = { long.MaxValue, long.MinValue, 0L }, + StringField = { "First", "Second", "" }, + 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]); + } + + [Test] + public void MapWrappersSerializeDeserialize() + { + var message = new MapWellKnownTypes + { + BoolField = { { 10, false }, { 20, true } }, + BytesField = { + { -1, ByteString.CopyFrom(1, 2, 3) }, + { 10, ByteString.CopyFrom(4, 5, 6) }, + { 1000, ByteString.Empty }, + { 10000, null } + }, + DoubleField = { { 1, 12.5 }, { 10, -1.5 }, { 20, 0d } }, + FloatField = { { 2, 123.25f }, { 3, -20f }, { 4, 0f } }, + Int32Field = { { 5, int.MaxValue }, { 6, int.MinValue }, { 7, 0 } }, + Int64Field = { { 8, long.MaxValue }, { 9, long.MinValue }, { 10, 0L } }, + StringField = { { 11, "First" }, { 12, "Second" }, { 13, "" }, { 14, null } }, + Uint32Field = { { 15, uint.MaxValue }, { 16, uint.MinValue }, { 17, 0U } }, + 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]); + } + + [Test] + public void Reflection_SingleValues() + { + var message = new TestWellKnownTypes + { + StringField = "x", + BytesField = ByteString.CopyFrom(1, 2, 3), + BoolField = true, + FloatField = 12.5f, + DoubleField = 12.25d, + Int32Field = 1, + Int64Field = 2, + Uint32Field = 3, + Uint64Field = 4 + }; + var fields = ((IReflectedMessage) message).Fields; + + Assert.AreEqual("x", fields[TestWellKnownTypes.StringFieldFieldNumber].GetValue(message)); + Assert.AreEqual(ByteString.CopyFrom(1, 2, 3), fields[TestWellKnownTypes.BytesFieldFieldNumber].GetValue(message)); + Assert.AreEqual(true, fields[TestWellKnownTypes.BoolFieldFieldNumber].GetValue(message)); + Assert.AreEqual(12.5f, fields[TestWellKnownTypes.FloatFieldFieldNumber].GetValue(message)); + Assert.AreEqual(12.25d, fields[TestWellKnownTypes.DoubleFieldFieldNumber].GetValue(message)); + Assert.AreEqual(1, fields[TestWellKnownTypes.Int32FieldFieldNumber].GetValue(message)); + Assert.AreEqual(2L, fields[TestWellKnownTypes.Int64FieldFieldNumber].GetValue(message)); + Assert.AreEqual(3U, fields[TestWellKnownTypes.Uint32FieldFieldNumber].GetValue(message)); + Assert.AreEqual(4UL, fields[TestWellKnownTypes.Uint64FieldFieldNumber].GetValue(message)); + + // And a couple of null fields... + message.StringField = null; + message.FloatField = null; + Assert.IsNull(fields[TestWellKnownTypes.StringFieldFieldNumber].GetValue(message)); + Assert.IsNull(fields[TestWellKnownTypes.FloatFieldFieldNumber].GetValue(message)); + } + + [Test] + public void Reflection_RepeatedFields() + { + // Just a single example... note that we can't have a null value here + var message = new RepeatedWellKnownTypes { Int32Field = { 1, 2 } }; + var fields = ((IReflectedMessage) message).Fields; + var list = (IList) fields[RepeatedWellKnownTypes.Int32FieldFieldNumber].GetValue(message); + CollectionAssert.AreEqual(new[] { 1, 2 }, list); + } + + [Test] + public void Reflection_MapFields() + { + // Just a single example... note that we can't have a null value here + var message = new MapWellKnownTypes { Int32Field = { { 1, 2 }, { 3, null } } }; + var fields = ((IReflectedMessage) message).Fields; + var dictionary = (IDictionary) fields[MapWellKnownTypes.Int32FieldFieldNumber].GetValue(message); + Assert.AreEqual(2, dictionary[1]); + Assert.IsNull(dictionary[3]); + Assert.IsTrue(dictionary.Contains(3)); + } + + [Test] + public void Oneof() + { + var message = new OneofWellKnownTypes { EmptyField = new Empty() }; + // Start off with a non-wrapper + Assert.AreEqual(OneofWellKnownTypes.OneofFieldOneofCase.EmptyField, message.OneofFieldCase); + AssertOneofRoundTrip(message); + + message.StringField = "foo"; + Assert.AreEqual(OneofWellKnownTypes.OneofFieldOneofCase.StringField, message.OneofFieldCase); + AssertOneofRoundTrip(message); + + message.StringField = "foo"; + Assert.AreEqual(OneofWellKnownTypes.OneofFieldOneofCase.StringField, message.OneofFieldCase); + AssertOneofRoundTrip(message); + + message.DoubleField = 0.0f; + Assert.AreEqual(OneofWellKnownTypes.OneofFieldOneofCase.DoubleField, message.OneofFieldCase); + AssertOneofRoundTrip(message); + + message.DoubleField = 1.0f; + Assert.AreEqual(OneofWellKnownTypes.OneofFieldOneofCase.DoubleField, message.OneofFieldCase); + AssertOneofRoundTrip(message); + + message.ClearOneofField(); + Assert.AreEqual(OneofWellKnownTypes.OneofFieldOneofCase.None, message.OneofFieldCase); + AssertOneofRoundTrip(message); + } + + 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); + } + + [Test] + [TestCase("x", "y", "y")] + [TestCase("x", "", "x")] + [TestCase("x", null, "x")] + [TestCase("", "y", "y")] + [TestCase("", "", "")] + [TestCase("", null, "")] + [TestCase(null, "y", "y")] + [TestCase(null, "", "")] + [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); + } + + // Merging is odd with wrapper types, due to the way that default values aren't emitted in + // the binary stream. In fact we cheat a little bit - a message with an explicitly present default + // value will have that default value ignored. + [Test] + public void MergingCornerCase() + { + 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; + var wrapperTag = WireFormat.MakeTag(TestWellKnownTypes.Int32FieldFieldNumber, WireFormat.WireType.LengthDelimited); + var valueTag = WireFormat.MakeTag(Int32Value.ValueFieldNumber, WireFormat.WireType.Varint); + using (var stream = new MemoryStream()) + { + var coded = CodedOutputStream.CreateInstance(stream); + coded.WriteTag(wrapperTag); + coded.WriteLength(2); // valueTag + a value 0, each one byte + coded.WriteTag(valueTag); + coded.WriteInt32(0); + coded.Flush(); + bytes = stream.ToArray(); + } + + message.MergeFrom(bytes); + // A normal implementation would have 0 now, as the explicit default would have been overwritten the 5. + Assert.AreEqual(5, message.Int32Field); + } + } +} diff --git a/csharp/src/Google.Protobuf.Test/packages.config b/csharp/src/Google.Protobuf.Test/packages.config new file mode 100644 index 00000000..c7653992 --- /dev/null +++ b/csharp/src/Google.Protobuf.Test/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/csharp/src/Google.Protobuf.sln b/csharp/src/Google.Protobuf.sln new file mode 100644 index 00000000..a290ae82 --- /dev/null +++ b/csharp/src/Google.Protobuf.sln @@ -0,0 +1,39 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.22823.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Google.Protobuf", "Google.Protobuf\Google.Protobuf.csproj", "{6908BDCE-D925-43F3-94AC-A531E6DF2591}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Google.Protobuf.Test", "Google.Protobuf.Test\Google.Protobuf.Test.csproj", "{DD01ED24-3750-4567-9A23-1DB676A15610}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AddressBook", "AddressBook\AddressBook.csproj", "{A31F5FB2-4FF3-432A-B35B-5CD203606311}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Google.Protobuf.JsonDump", "Google.Protobuf.JsonDump\Google.Protobuf.JsonDump.csproj", "{D7282E99-2DC3-405B-946F-177DB2FD2AE2}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6908BDCE-D925-43F3-94AC-A531E6DF2591}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6908BDCE-D925-43F3-94AC-A531E6DF2591}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6908BDCE-D925-43F3-94AC-A531E6DF2591}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6908BDCE-D925-43F3-94AC-A531E6DF2591}.Release|Any CPU.Build.0 = Release|Any CPU + {DD01ED24-3750-4567-9A23-1DB676A15610}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DD01ED24-3750-4567-9A23-1DB676A15610}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DD01ED24-3750-4567-9A23-1DB676A15610}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DD01ED24-3750-4567-9A23-1DB676A15610}.Release|Any CPU.Build.0 = Release|Any CPU + {A31F5FB2-4FF3-432A-B35B-5CD203606311}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A31F5FB2-4FF3-432A-B35B-5CD203606311}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A31F5FB2-4FF3-432A-B35B-5CD203606311}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A31F5FB2-4FF3-432A-B35B-5CD203606311}.Release|Any CPU.Build.0 = Release|Any CPU + {D7282E99-2DC3-405B-946F-177DB2FD2AE2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D7282E99-2DC3-405B-946F-177DB2FD2AE2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D7282E99-2DC3-405B-946F-177DB2FD2AE2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D7282E99-2DC3-405B-946F-177DB2FD2AE2}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/csharp/src/Google.Protobuf/ByteArray.cs b/csharp/src/Google.Protobuf/ByteArray.cs new file mode 100644 index 00000000..69b6ef8d --- /dev/null +++ b/csharp/src/Google.Protobuf/ByteArray.cs @@ -0,0 +1,79 @@ +#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; + +namespace Google.Protobuf +{ + /// + /// Provides a utility routine to copy small arrays much more quickly than Buffer.BlockCopy + /// + internal static class ByteArray + { + /// + /// The threshold above which you should use Buffer.BlockCopy rather than ByteArray.Copy + /// + private const int CopyThreshold = 12; + + /// + /// Determines which copy routine to use based on the number of bytes to be copied. + /// + internal static void Copy(byte[] src, int srcOffset, byte[] dst, int dstOffset, int count) + { + if (count > CopyThreshold) + { + Buffer.BlockCopy(src, srcOffset, dst, dstOffset, count); + } + else + { + int stop = srcOffset + count; + for (int i = srcOffset; i < stop; i++) + { + dst[dstOffset++] = src[i]; + } + } + } + + /// + /// Reverses the order of bytes in the array + /// + internal static void Reverse(byte[] bytes) + { + for (int first = 0, last = bytes.Length - 1; first < last; first++, last--) + { + byte temp = bytes[first]; + bytes[first] = bytes[last]; + bytes[last] = temp; + } + } + } +} \ No newline at end of file diff --git a/csharp/src/Google.Protobuf/ByteString.cs b/csharp/src/Google.Protobuf/ByteString.cs new file mode 100644 index 00000000..329f47f6 --- /dev/null +++ b/csharp/src/Google.Protobuf/ByteString.cs @@ -0,0 +1,284 @@ +#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; +using System.Collections; +using System.Collections.Generic; +using System.IO; +using System.Text; + +namespace Google.Protobuf +{ + /// + /// Immutable array of bytes. + /// TODO(jonskeet): Implement the common collection interfaces? + /// + public sealed class ByteString : IEnumerable, IEquatable + { + private static readonly ByteString empty = new ByteString(new byte[0]); + + private readonly byte[] bytes; + + /// + /// Unsafe operations that can cause IO Failure and/or other catestrophic side-effects. + /// + public static class Unsafe + { + /// + /// Constructs a new ByteString from the given byte array. The array is + /// *not* copied, and must not be modified after this constructor is called. + /// + public static ByteString FromBytes(byte[] bytes) + { + return new ByteString(bytes); + } + + /// + /// Provides direct, unrestricted access to the bytes contained in this instance. + /// You must not modify or resize the byte array returned by this method. + /// + public static byte[] GetBuffer(ByteString bytes) + { + return bytes.bytes; + } + } + + /// + /// Internal use only. Ensure that the provided array is not mutated and belongs to this instance. + /// + internal static ByteString AttachBytes(byte[] bytes) + { + return new ByteString(bytes); + } + + /// + /// Constructs a new ByteString from the given byte array. The array is + /// *not* copied, and must not be modified after this constructor is called. + /// + private ByteString(byte[] bytes) + { + this.bytes = bytes; + } + + /// + /// Returns an empty ByteString. + /// + public static ByteString Empty + { + get { return empty; } + } + + /// + /// Returns the length of this ByteString in bytes. + /// + public int Length + { + get { return bytes.Length; } + } + + public bool IsEmpty + { + get { return Length == 0; } + } + + public byte[] ToByteArray() + { + return (byte[]) bytes.Clone(); + } + + public string ToBase64() + { + return Convert.ToBase64String(bytes); + } + + /// + /// Constructs a ByteString from the Base64 Encoded String. + /// + public static ByteString FromBase64(string bytes) + { + // By handling the empty string explicitly, we not only optimize but we fix a + // problem on CF 2.0. See issue 61 for details. + return bytes == "" ? Empty : new ByteString(Convert.FromBase64String(bytes)); + } + + /// + /// Constructs a ByteString from the given array. The contents + /// are copied, so further modifications to the array will not + /// be reflected in the returned ByteString. + /// This method can also be invoked in ByteString.CopyFrom(0xaa, 0xbb, ...) form + /// which is primarily useful for testing. + /// + public static ByteString CopyFrom(params byte[] bytes) + { + return new ByteString((byte[]) bytes.Clone()); + } + + /// + /// Constructs a ByteString from a portion of a byte array. + /// + public static ByteString CopyFrom(byte[] bytes, int offset, int count) + { + byte[] portion = new byte[count]; + ByteArray.Copy(bytes, offset, portion, 0, count); + return new ByteString(portion); + } + + /// + /// Creates a new ByteString by encoding the specified text with + /// the given encoding. + /// + public static ByteString CopyFrom(string text, Encoding encoding) + { + return new ByteString(encoding.GetBytes(text)); + } + + /// + /// Creates a new ByteString by encoding the specified text in UTF-8. + /// + public static ByteString CopyFromUtf8(string text) + { + return CopyFrom(text, Encoding.UTF8); + } + + /// + /// Retuns the byte at the given index. + /// + public byte this[int index] + { + get { return bytes[index]; } + } + + public string ToString(Encoding encoding) + { + return encoding.GetString(bytes, 0, bytes.Length); + } + + public string ToStringUtf8() + { + return ToString(Encoding.UTF8); + } + + public IEnumerator GetEnumerator() + { + return ((IEnumerable) bytes).GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + /// + /// Creates a CodedInputStream from this ByteString's data. + /// + public CodedInputStream CreateCodedInput() + { + // We trust CodedInputStream not to reveal the provided byte array or modify it + return CodedInputStream.CreateInstance(bytes); + } + + public static bool operator ==(ByteString lhs, ByteString rhs) + { + if (ReferenceEquals(lhs, rhs)) + { + return true; + } + if (ReferenceEquals(lhs, null) || ReferenceEquals(rhs, null)) + { + return false; + } + if (lhs.bytes.Length != rhs.bytes.Length) + { + return false; + } + for (int i = 0; i < lhs.Length; i++) + { + if (rhs.bytes[i] != lhs.bytes[i]) + { + return false; + } + } + return true; + } + + public static bool operator !=(ByteString lhs, ByteString rhs) + { + return !(lhs == rhs); + } + + // TODO(jonskeet): CopyTo if it turns out to be required + + public override bool Equals(object obj) + { + return this == (obj as ByteString); + } + + public override int GetHashCode() + { + int ret = 23; + foreach (byte b in bytes) + { + ret = (ret << 8) | b; + } + return ret; + } + + public bool Equals(ByteString other) + { + return this == other; + } + + /// + /// Used internally by CodedOutputStream to avoid creating a copy for the write + /// + internal void WriteRawBytesTo(CodedOutputStream outputStream) + { + outputStream.WriteRawBytes(bytes, 0, bytes.Length); + } + + /// + /// Copies the entire byte array to the destination array provided at the offset specified. + /// + public void CopyTo(byte[] array, int position) + { + ByteArray.Copy(bytes, 0, array, position, bytes.Length); + } + + /// + /// Writes the entire byte array to the provided stream + /// + public void WriteTo(Stream outputStream) + { + outputStream.Write(bytes, 0, bytes.Length); + } + } +} \ No newline at end of file diff --git a/csharp/src/Google.Protobuf/CodedInputStream.cs b/csharp/src/Google.Protobuf/CodedInputStream.cs new file mode 100644 index 00000000..ef7cf114 --- /dev/null +++ b/csharp/src/Google.Protobuf/CodedInputStream.cs @@ -0,0 +1,1144 @@ +#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; +using System.Collections.Generic; +using System.IO; + +namespace Google.Protobuf +{ + /// + /// Readings and decodes protocol message fields. + /// + /// + /// This class contains two kinds of methods: methods that read specific + /// protocol message constructs and field types (e.g. ReadTag and + /// ReadInt32) and methods that read low-level values (e.g. + /// ReadRawVarint32 and ReadRawBytes). If you are reading encoded protocol + /// messages, you should use the former methods, but if you are reading some + /// other format of your own design, use the latter. The names of the former + /// methods are taken from the protocol buffer type names, not .NET types. + /// (Hence ReadFloat instead of ReadSingle, and ReadBool instead of ReadBoolean.) + /// + /// TODO(jonskeet): Consider whether recursion and size limits shouldn't be readonly, + /// set at construction time. + /// + public sealed class CodedInputStream + { + private readonly byte[] buffer; + private int bufferSize; + private int bufferSizeAfterLimit = 0; + private int bufferPos = 0; + private readonly Stream input; + private uint lastTag = 0; + + private uint nextTag = 0; + private bool hasNextTag = false; + + internal const int DefaultRecursionLimit = 64; + internal const int DefaultSizeLimit = 64 << 20; // 64MB + public const int BufferSize = 4096; + + /// + /// The total number of bytes read before the current buffer. The + /// total bytes read up to the current position can be computed as + /// totalBytesRetired + bufferPos. + /// + private int totalBytesRetired = 0; + + /// + /// The absolute position of the end of the current message. + /// + private int currentLimit = int.MaxValue; + + /// + /// + /// + private int recursionDepth = 0; + + private int recursionLimit = DefaultRecursionLimit; + + /// + /// + /// + private int sizeLimit = DefaultSizeLimit; + + #region Construction + + /// + /// Creates a new CodedInputStream reading data from the given + /// stream. + /// + public static CodedInputStream CreateInstance(Stream input) + { + return new CodedInputStream(input); + } + /// + /// Creates a new CodedInputStream reading data from the given + /// stream and a pre-allocated memory buffer. + /// + public static CodedInputStream CreateInstance(Stream input, byte[] buffer) + { + return new CodedInputStream(input, buffer); + } + + /// + /// Creates a new CodedInputStream reading data from the given + /// byte array. + /// + public static CodedInputStream CreateInstance(byte[] buf) + { + return new CodedInputStream(buf, 0, buf.Length); + } + + /// + /// Creates a new CodedInputStream that reads from the given + /// byte array slice. + /// + public static CodedInputStream CreateInstance(byte[] buf, int offset, int length) + { + return new CodedInputStream(buf, offset, length); + } + + private CodedInputStream(byte[] buffer, int offset, int length) + { + this.buffer = buffer; + this.bufferPos = offset; + this.bufferSize = offset + length; + this.input = null; + } + + private CodedInputStream(Stream input) + { + this.buffer = new byte[BufferSize]; + this.bufferSize = 0; + this.input = input; + } + + private CodedInputStream(Stream input, byte[] buffer) + { + this.buffer = buffer; + this.bufferSize = 0; + this.input = input; + } + #endregion + + /// + /// Returns the current position in the input stream, or the position in the input buffer + /// + public long Position + { + get + { + if (input != null) + { + return input.Position - ((bufferSize + bufferSizeAfterLimit) - bufferPos); + } + return bufferPos; + } + } + + /// + /// Returns the last tag read, or 0 if no tags have been read or we've read beyond + /// the end of the stream. + /// + internal uint LastTag { get { return lastTag; } } + + #region Limits for recursion and length + /// + /// Set the maximum message recursion depth. + /// + /// + /// In order to prevent malicious + /// messages from causing stack overflows, CodedInputStream limits + /// how deeply messages may be nested. The default limit is 64. + /// + public int SetRecursionLimit(int limit) + { + if (limit < 0) + { + throw new ArgumentOutOfRangeException("Recursion limit cannot be negative: " + limit); + } + int oldLimit = recursionLimit; + recursionLimit = limit; + return oldLimit; + } + + /// + /// Set the maximum message size. + /// + /// + /// In order to prevent malicious messages from exhausting memory or + /// causing integer overflows, CodedInputStream limits how large a message may be. + /// The default limit is 64MB. You should set this limit as small + /// as you can without harming your app's functionality. Note that + /// size limits only apply when reading from an InputStream, not + /// when constructed around a raw byte array (nor with ByteString.NewCodedInput). + /// If you want to read several messages from a single CodedInputStream, you + /// can call ResetSizeCounter() after each message to avoid hitting the + /// size limit. + /// + public int SetSizeLimit(int limit) + { + if (limit < 0) + { + throw new ArgumentOutOfRangeException("Size limit cannot be negative: " + limit); + } + int oldLimit = sizeLimit; + sizeLimit = limit; + return oldLimit; + } + + /// + /// Resets the current size counter to zero (see ). + /// + public void ResetSizeCounter() + { + totalBytesRetired = 0; + } + #endregion + + #region Validation + /// + /// Verifies that the last call to ReadTag() returned the given tag value. + /// This is used to verify that a nested group ended with the correct + /// end tag. + /// + /// The last + /// tag read was not the one specified + internal void CheckLastTagWas(uint value) + { + if (lastTag != value) + { + throw InvalidProtocolBufferException.InvalidEndTag(); + } + } + #endregion + + #region Reading of tags etc + + /// + /// Attempts to peek at the next field tag. + /// + public bool PeekNextTag(out uint fieldTag) + { + if (hasNextTag) + { + fieldTag = nextTag; + return true; + } + + uint savedLast = lastTag; + hasNextTag = ReadTag(out nextTag); + lastTag = savedLast; + fieldTag = nextTag; + return hasNextTag; + } + + /// + /// Attempts to read a field tag, returning false if we have reached the end + /// of the input data. + /// + /// The 'tag' of the field (id * 8 + wire-format) + /// true if the next fieldTag was read + public bool ReadTag(out uint fieldTag) + { + if (hasNextTag) + { + fieldTag = nextTag; + lastTag = fieldTag; + hasNextTag = false; + return true; + } + + // Optimize for the incredibly common case of having at least two bytes left in the buffer, + // and those two bytes being enough to get the tag. This will be true for fields up to 4095. + if (bufferPos + 2 <= bufferSize) + { + int tmp = buffer[bufferPos++]; + if (tmp < 128) + { + fieldTag = (uint)tmp; + } + else + { + int result = tmp & 0x7f; + if ((tmp = buffer[bufferPos++]) < 128) + { + result |= tmp << 7; + fieldTag = (uint) result; + } + else + { + // Nope, rewind and go the potentially slow route. + bufferPos -= 2; + fieldTag = ReadRawVarint32(); + } + } + } + else + { + if (IsAtEnd) + { + fieldTag = 0; + lastTag = fieldTag; + return false; + } + + fieldTag = ReadRawVarint32(); + } + lastTag = fieldTag; + if (lastTag == 0) + { + // If we actually read zero, that's not a valid tag. + throw InvalidProtocolBufferException.InvalidTag(); + } + return true; + } + + /// + /// Reads a double field from the stream. + /// + public double ReadDouble() + { + return BitConverter.Int64BitsToDouble((long) ReadRawLittleEndian64()); + } + + /// + /// Reads a float field from the stream. + /// + public float ReadFloat() + { + if (BitConverter.IsLittleEndian && 4 <= bufferSize - bufferPos) + { + float ret = BitConverter.ToSingle(buffer, bufferPos); + bufferPos += 4; + return ret; + } + else + { + byte[] rawBytes = ReadRawBytes(4); + if (!BitConverter.IsLittleEndian) + { + ByteArray.Reverse(rawBytes); + } + return BitConverter.ToSingle(rawBytes, 0); + } + } + + /// + /// Reads a uint64 field from the stream. + /// + public ulong ReadUInt64() + { + return ReadRawVarint64(); + } + + /// + /// Reads an int64 field from the stream. + /// + public long ReadInt64() + { + return (long) ReadRawVarint64(); + } + + /// + /// Reads an int32 field from the stream. + /// + public int ReadInt32() + { + return (int) ReadRawVarint32(); + } + + /// + /// Reads a fixed64 field from the stream. + /// + public ulong ReadFixed64() + { + return ReadRawLittleEndian64(); + } + + /// + /// Reads a fixed32 field from the stream. + /// + public uint ReadFixed32() + { + return ReadRawLittleEndian32(); + } + + /// + /// Reads a bool field from the stream. + /// + public bool ReadBool() + { + return ReadRawVarint32() != 0; + } + + /// + /// Reads a string field from the stream. + /// + public string ReadString() + { + int length = ReadLength(); + // No need to read any data for an empty string. + if (length == 0) + { + return ""; + } + if (length <= bufferSize - bufferPos) + { + // Fast path: We already have the bytes in a contiguous buffer, so + // just copy directly from it. + String result = CodedOutputStream.Utf8Encoding.GetString(buffer, bufferPos, length); + bufferPos += length; + return result; + } + // Slow path: Build a byte array first then copy it. + return CodedOutputStream.Utf8Encoding.GetString(ReadRawBytes(length), 0, length); + } + + /// + /// Reads an embedded message field value from the stream. + /// + public void ReadMessage(IMessage builder) + { + int length = ReadLength(); + if (recursionDepth >= recursionLimit) + { + throw InvalidProtocolBufferException.RecursionLimitExceeded(); + } + int oldLimit = PushLimit(length); + ++recursionDepth; + builder.MergeFrom(this); + CheckLastTagWas(0); + --recursionDepth; + PopLimit(oldLimit); + } + + /// + /// Reads a bytes field value from the stream. + /// + public ByteString ReadBytes() + { + int length = ReadLength(); + if (length <= bufferSize - bufferPos && length > 0) + { + // Fast path: We already have the bytes in a contiguous buffer, so + // just copy directly from it. + ByteString result = ByteString.CopyFrom(buffer, bufferPos, length); + bufferPos += length; + return result; + } + else + { + // Slow path: Build a byte array and attach it to a new ByteString. + return ByteString.AttachBytes(ReadRawBytes(length)); + } + } + + /// + /// Reads a uint32 field value from the stream. + /// + public uint ReadUInt32() + { + return ReadRawVarint32(); + } + + /// + /// Reads an enum field value from the stream. If the enum is valid for type T, + /// then the ref value is set and it returns true. Otherwise the unknown output + /// value is set and this method returns false. + /// + 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 stream. + /// + public int ReadSFixed32() + { + return (int) ReadRawLittleEndian32(); + } + + /// + /// Reads an sfixed64 field value from the stream. + /// + public long ReadSFixed64() + { + return (long) ReadRawLittleEndian64(); + } + + /// + /// Reads an sint32 field value from the stream. + /// + public int ReadSInt32() + { + return DecodeZigZag32(ReadRawVarint32()); + } + + /// + /// Reads an sint64 field value from the stream. + /// + public long ReadSInt64() + { + return 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 stream. If it matches , + /// the tag is consumed and the method returns true; otherwise, the + /// stream is left in the original position and the method returns false. + /// + public bool MaybeConsumeTag(uint tag) + { + uint next; + if (PeekNextTag(out next)) + { + if (next == tag) + { + hasNextTag = false; + return true; + } + } + return false; + } + + #endregion + + #region Underlying reading primitives + + /// + /// Same code as ReadRawVarint32, but read each byte individually, checking for + /// buffer overflow. + /// + private uint SlowReadRawVarint32() + { + int tmp = ReadRawByte(); + if (tmp < 128) + { + return (uint) tmp; + } + int result = tmp & 0x7f; + if ((tmp = ReadRawByte()) < 128) + { + result |= tmp << 7; + } + else + { + result |= (tmp & 0x7f) << 7; + if ((tmp = ReadRawByte()) < 128) + { + result |= tmp << 14; + } + else + { + result |= (tmp & 0x7f) << 14; + if ((tmp = ReadRawByte()) < 128) + { + result |= tmp << 21; + } + else + { + result |= (tmp & 0x7f) << 21; + result |= (tmp = ReadRawByte()) << 28; + if (tmp >= 128) + { + // Discard upper 32 bits. + for (int i = 0; i < 5; i++) + { + if (ReadRawByte() < 128) + { + return (uint) result; + } + } + throw InvalidProtocolBufferException.MalformedVarint(); + } + } + } + } + return (uint) result; + } + + /// + /// Reads a raw Varint from the stream. 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() + { + if (bufferPos + 5 > bufferSize) + { + return SlowReadRawVarint32(); + } + + int tmp = buffer[bufferPos++]; + if (tmp < 128) + { + return (uint) tmp; + } + int result = tmp & 0x7f; + if ((tmp = buffer[bufferPos++]) < 128) + { + result |= tmp << 7; + } + else + { + result |= (tmp & 0x7f) << 7; + if ((tmp = buffer[bufferPos++]) < 128) + { + result |= tmp << 14; + } + else + { + result |= (tmp & 0x7f) << 14; + if ((tmp = buffer[bufferPos++]) < 128) + { + result |= tmp << 21; + } + else + { + result |= (tmp & 0x7f) << 21; + result |= (tmp = buffer[bufferPos++]) << 28; + if (tmp >= 128) + { + // Discard upper 32 bits. + // Note that this has to use ReadRawByte() 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++) + { + if (ReadRawByte() < 128) + { + return (uint) result; + } + } + throw InvalidProtocolBufferException.MalformedVarint(); + } + } + } + } + return (uint) result; + } + + /// + /// Reads a varint from the input one byte at a time, so that it does not + /// read any bytes after the end of the varint. If you simply wrapped the + /// stream in a CodedInputStream and used ReadRawVarint32(Stream) + /// then you would probably end up reading past the end of the varint since + /// CodedInputStream buffers its input. + /// + /// + /// + internal static uint ReadRawVarint32(Stream input) + { + int result = 0; + int offset = 0; + for (; offset < 32; offset += 7) + { + int b = input.ReadByte(); + if (b == -1) + { + throw InvalidProtocolBufferException.TruncatedMessage(); + } + result |= (b & 0x7f) << offset; + if ((b & 0x80) == 0) + { + return (uint) result; + } + } + // Keep reading up to 64 bits. + for (; offset < 64; offset += 7) + { + int b = input.ReadByte(); + if (b == -1) + { + throw InvalidProtocolBufferException.TruncatedMessage(); + } + if ((b & 0x80) == 0) + { + return (uint) result; + } + } + throw InvalidProtocolBufferException.MalformedVarint(); + } + + /// + /// Reads a raw varint from the stream. + /// + internal ulong ReadRawVarint64() + { + int shift = 0; + ulong result = 0; + while (shift < 64) + { + byte b = ReadRawByte(); + result |= (ulong) (b & 0x7F) << shift; + if ((b & 0x80) == 0) + { + return result; + } + shift += 7; + } + throw InvalidProtocolBufferException.MalformedVarint(); + } + + /// + /// Reads a 32-bit little-endian integer from the stream. + /// + internal uint ReadRawLittleEndian32() + { + uint b1 = ReadRawByte(); + uint b2 = ReadRawByte(); + uint b3 = ReadRawByte(); + uint b4 = ReadRawByte(); + return b1 | (b2 << 8) | (b3 << 16) | (b4 << 24); + } + + /// + /// Reads a 64-bit little-endian integer from the stream. + /// + internal ulong ReadRawLittleEndian64() + { + ulong b1 = ReadRawByte(); + ulong b2 = ReadRawByte(); + ulong b3 = ReadRawByte(); + ulong b4 = ReadRawByte(); + ulong b5 = ReadRawByte(); + ulong b6 = ReadRawByte(); + ulong b7 = ReadRawByte(); + ulong b8 = ReadRawByte(); + return b1 | (b2 << 8) | (b3 << 16) | (b4 << 24) + | (b5 << 32) | (b6 << 40) | (b7 << 48) | (b8 << 56); + } + + /// + /// Decode a 32-bit value with ZigZag encoding. + /// + /// + /// ZigZag encodes signed integers into values that can be efficiently + /// encoded with varint. (Otherwise, negative values must be + /// sign-extended to 64 bits to be varint encoded, thus always taking + /// 10 bytes on the wire.) + /// + internal static int DecodeZigZag32(uint n) + { + return (int)(n >> 1) ^ -(int)(n & 1); + } + + /// + /// Decode a 32-bit value with ZigZag encoding. + /// + /// + /// ZigZag encodes signed integers into values that can be efficiently + /// encoded with varint. (Otherwise, negative values must be + /// sign-extended to 64 bits to be varint encoded, thus always taking + /// 10 bytes on the wire.) + /// + internal static long DecodeZigZag64(ulong n) + { + return (long)(n >> 1) ^ -(long)(n & 1); + } + #endregion + + #region Internal reading and buffer management + + /// + /// 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 += totalBytesRetired + bufferPos; + int oldLimit = currentLimit; + if (byteLimit > oldLimit) + { + throw InvalidProtocolBufferException.TruncatedMessage(); + } + currentLimit = byteLimit; + + RecomputeBufferSizeAfterLimit(); + + return oldLimit; + } + + private void RecomputeBufferSizeAfterLimit() + { + bufferSize += bufferSizeAfterLimit; + int bufferEnd = totalBytesRetired + bufferSize; + if (bufferEnd > currentLimit) + { + // Limit is in current buffer. + bufferSizeAfterLimit = bufferEnd - currentLimit; + bufferSize -= bufferSizeAfterLimit; + } + else + { + bufferSizeAfterLimit = 0; + } + } + + /// + /// Discards the current limit, returning the previous limit. + /// + internal void PopLimit(int oldLimit) + { + currentLimit = oldLimit; + RecomputeBufferSizeAfterLimit(); + } + + /// + /// Returns whether or not all the data before the limit has been read. + /// + /// + internal bool ReachedLimit + { + get + { + if (currentLimit == int.MaxValue) + { + return false; + } + int currentAbsolutePosition = totalBytesRetired + bufferPos; + return currentAbsolutePosition >= currentLimit; + } + } + + /// + /// Returns true if the stream 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 stream has reached a limit created using PushLimit. + /// + public bool IsAtEnd + { + get { return bufferPos == bufferSize && !RefillBuffer(false); } + } + + /// + /// Called when buffer is empty to read more bytes from the + /// input. If is true, RefillBuffer() gurantees that + /// either there will be at least one byte in the buffer when it returns + /// or it will throw an exception. If is false, + /// RefillBuffer() returns false if no more bytes were available. + /// + /// + /// + private bool RefillBuffer(bool mustSucceed) + { + if (bufferPos < bufferSize) + { + throw new InvalidOperationException("RefillBuffer() called when buffer wasn't empty."); + } + + if (totalBytesRetired + bufferSize == currentLimit) + { + // Oops, we hit a limit. + if (mustSucceed) + { + throw InvalidProtocolBufferException.TruncatedMessage(); + } + else + { + return false; + } + } + + totalBytesRetired += bufferSize; + + bufferPos = 0; + bufferSize = (input == null) ? 0 : input.Read(buffer, 0, buffer.Length); + if (bufferSize < 0) + { + throw new InvalidOperationException("Stream.Read returned a negative count"); + } + if (bufferSize == 0) + { + if (mustSucceed) + { + throw InvalidProtocolBufferException.TruncatedMessage(); + } + else + { + return false; + } + } + else + { + RecomputeBufferSizeAfterLimit(); + int totalBytesRead = + totalBytesRetired + bufferSize + bufferSizeAfterLimit; + if (totalBytesRead > sizeLimit || totalBytesRead < 0) + { + throw InvalidProtocolBufferException.SizeLimitExceeded(); + } + return true; + } + } + + /// + /// Read one byte from the input. + /// + /// + /// the end of the stream or the current limit was reached + /// + internal byte ReadRawByte() + { + if (bufferPos == bufferSize) + { + RefillBuffer(true); + } + return buffer[bufferPos++]; + } + + /// + /// Reads a fixed size of bytes from the input. + /// + /// + /// the end of the stream or the current limit was reached + /// + internal byte[] ReadRawBytes(int size) + { + if (size < 0) + { + throw InvalidProtocolBufferException.NegativeSize(); + } + + if (totalBytesRetired + bufferPos + size > currentLimit) + { + // Read to the end of the stream (up to the current limit) anyway. + // TODO(jonskeet): This is the only usage of SkipRawBytes. Do we really need to do it? + SkipRawBytes(currentLimit - totalBytesRetired - bufferPos); + // Then fail. + throw InvalidProtocolBufferException.TruncatedMessage(); + } + + if (size <= bufferSize - bufferPos) + { + // We have all the bytes we need already. + byte[] bytes = new byte[size]; + ByteArray.Copy(buffer, bufferPos, bytes, 0, size); + bufferPos += size; + return bytes; + } + else if (size < buffer.Length) + { + // Reading more bytes than are in the buffer, but not an excessive number + // of bytes. We can safely allocate the resulting array ahead of time. + + // First copy what we have. + byte[] bytes = new byte[size]; + int pos = bufferSize - bufferPos; + ByteArray.Copy(buffer, bufferPos, bytes, 0, pos); + bufferPos = bufferSize; + + // We want to use RefillBuffer() and then copy from the buffer into our + // byte array rather than reading directly into our byte array because + // the input may be unbuffered. + RefillBuffer(true); + + while (size - pos > bufferSize) + { + Buffer.BlockCopy(buffer, 0, bytes, pos, bufferSize); + pos += bufferSize; + bufferPos = bufferSize; + RefillBuffer(true); + } + + ByteArray.Copy(buffer, 0, bytes, pos, size - pos); + bufferPos = size - pos; + + return bytes; + } + else + { + // The size is very large. For security reasons, we can't allocate the + // entire byte array yet. The size comes directly from the input, so a + // maliciously-crafted message could provide a bogus very large size in + // order to trick the app into allocating a lot of memory. We avoid this + // by allocating and reading only a small chunk at a time, so that the + // malicious message must actually *be* extremely large to cause + // problems. Meanwhile, we limit the allowed size of a message elsewhere. + + // Remember the buffer markers since we'll have to copy the bytes out of + // it later. + int originalBufferPos = bufferPos; + int originalBufferSize = bufferSize; + + // Mark the current buffer consumed. + totalBytesRetired += bufferSize; + bufferPos = 0; + bufferSize = 0; + + // Read all the rest of the bytes we need. + int sizeLeft = size - (originalBufferSize - originalBufferPos); + List chunks = new List(); + + while (sizeLeft > 0) + { + byte[] chunk = new byte[Math.Min(sizeLeft, buffer.Length)]; + int pos = 0; + while (pos < chunk.Length) + { + int n = (input == null) ? -1 : input.Read(chunk, pos, chunk.Length - pos); + if (n <= 0) + { + throw InvalidProtocolBufferException.TruncatedMessage(); + } + totalBytesRetired += n; + pos += n; + } + sizeLeft -= chunk.Length; + chunks.Add(chunk); + } + + // OK, got everything. Now concatenate it all into one buffer. + byte[] bytes = new byte[size]; + + // Start by copying the leftover bytes from this.buffer. + int newPos = originalBufferSize - originalBufferPos; + ByteArray.Copy(buffer, originalBufferPos, bytes, 0, newPos); + + // And now all the chunks. + foreach (byte[] chunk in chunks) + { + Buffer.BlockCopy(chunk, 0, bytes, newPos, chunk.Length); + newPos += chunk.Length; + } + + // Done. + return bytes; + } + } + + /// + /// Reads and discards bytes. + /// + /// the end of the stream + /// or the current limit was reached + private void SkipRawBytes(int size) + { + if (size < 0) + { + throw InvalidProtocolBufferException.NegativeSize(); + } + + if (totalBytesRetired + bufferPos + size > currentLimit) + { + // Read to the end of the stream anyway. + SkipRawBytes(currentLimit - totalBytesRetired - bufferPos); + // Then fail. + throw InvalidProtocolBufferException.TruncatedMessage(); + } + + if (size <= bufferSize - bufferPos) + { + // We have all the bytes we need already. + bufferPos += size; + } + else + { + // Skipping more bytes than are in the buffer. First skip what we have. + int pos = bufferSize - bufferPos; + + // ROK 5/7/2013 Issue #54: should retire all bytes in buffer (bufferSize) + // totalBytesRetired += pos; + totalBytesRetired += bufferSize; + + bufferPos = 0; + bufferSize = 0; + + // Then skip directly from the InputStream for the rest. + if (pos < size) + { + if (input == null) + { + throw InvalidProtocolBufferException.TruncatedMessage(); + } + SkipImpl(size - pos); + totalBytesRetired += size - pos; + } + } + } + + /// + /// Abstraction of skipping to cope with streams which can't really skip. + /// + private void SkipImpl(int amountToSkip) + { + if (input.CanSeek) + { + long previousPosition = input.Position; + input.Position += amountToSkip; + if (input.Position != previousPosition + amountToSkip) + { + throw InvalidProtocolBufferException.TruncatedMessage(); + } + } + else + { + byte[] skipBuffer = new byte[Math.Min(1024, amountToSkip)]; + while (amountToSkip > 0) + { + int bytesRead = input.Read(skipBuffer, 0, Math.Min(skipBuffer.Length, amountToSkip)); + if (bytesRead <= 0) + { + throw InvalidProtocolBufferException.TruncatedMessage(); + } + amountToSkip -= bytesRead; + } + } + } + + #endregion + } +} \ No newline at end of file diff --git a/csharp/src/Google.Protobuf/CodedOutputStream.ComputeSize.cs b/csharp/src/Google.Protobuf/CodedOutputStream.ComputeSize.cs new file mode 100644 index 00000000..bf221c9c --- /dev/null +++ b/csharp/src/Google.Protobuf/CodedOutputStream.ComputeSize.cs @@ -0,0 +1,304 @@ +#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; + +namespace Google.Protobuf +{ + // This part of CodedOutputStream provides all the static entry points that are used + // by generated code and internally to compute the size of messages prior to being + // written to an instance of CodedOutputStream. + public sealed partial class CodedOutputStream + { + private const int LittleEndian64Size = 8; + private const int LittleEndian32Size = 4; + + /// + /// Computes the number of bytes that would be needed to encode a + /// double field, including the tag. + /// + public static int ComputeDoubleSize(double value) + { + return LittleEndian64Size; + } + + /// + /// Computes the number of bytes that would be needed to encode a + /// float field, including the tag. + /// + public static int ComputeFloatSize(float value) + { + return LittleEndian32Size; + } + + /// + /// Computes the number of bytes that would be needed to encode a + /// uint64 field, including the tag. + /// + public static int ComputeUInt64Size(ulong value) + { + return ComputeRawVarint64Size(value); + } + + /// + /// Computes the number of bytes that would be needed to encode an + /// int64 field, including the tag. + /// + public static int ComputeInt64Size(long value) + { + return ComputeRawVarint64Size((ulong) value); + } + + /// + /// Computes the number of bytes that would be needed to encode an + /// int32 field, including the tag. + /// + public static int ComputeInt32Size(int value) + { + if (value >= 0) + { + return ComputeRawVarint32Size((uint) value); + } + else + { + // Must sign-extend. + return 10; + } + } + + /// + /// Computes the number of bytes that would be needed to encode a + /// fixed64 field, including the tag. + /// + public static int ComputeFixed64Size(ulong value) + { + return LittleEndian64Size; + } + + /// + /// Computes the number of bytes that would be needed to encode a + /// fixed32 field, including the tag. + /// + public static int ComputeFixed32Size(uint value) + { + return LittleEndian32Size; + } + + /// + /// Computes the number of bytes that would be needed to encode a + /// bool field, including the tag. + /// + public static int ComputeBoolSize(bool value) + { + return 1; + } + + /// + /// Computes the number of bytes that would be needed to encode a + /// string field, including the tag. + /// + public static int ComputeStringSize(String value) + { + int byteArraySize = Utf8Encoding.GetByteCount(value); + return ComputeLengthSize(byteArraySize) + byteArraySize; + } + + /// + /// Computes the number of bytes that would be needed to encode a + /// group field, including the tag. + /// + public static int ComputeGroupSize(IMessage value) + { + return value.CalculateSize(); + } + + /// + /// Computes the number of bytes that would be needed to encode an + /// embedded message field, including the tag. + /// + public static int ComputeMessageSize(IMessage value) + { + int size = value.CalculateSize(); + return ComputeLengthSize(size) + size; + } + + /// + /// Computes the number of bytes that would be needed to encode a + /// bytes field, including the tag. + /// + public static int ComputeBytesSize(ByteString value) + { + return ComputeLengthSize(value.Length) + value.Length; + } + + /// + /// Computes the number of bytes that would be needed to encode a + /// uint32 field, including the tag. + /// + public static int ComputeUInt32Size(uint value) + { + return ComputeRawVarint32Size(value); + } + + /// + /// Computes the number of bytes that would be needed to encode a + /// enum field, including the tag. The caller is responsible for + /// converting the enum value to its numeric value. + /// + public static int ComputeEnumSize(int value) + { + // Currently just a pass-through, but it's nice to separate it logically. + return ComputeInt32Size(value); + } + + /// + /// Computes the number of bytes that would be needed to encode an + /// sfixed32 field, including the tag. + /// + public static int ComputeSFixed32Size(int value) + { + return LittleEndian32Size; + } + + /// + /// Computes the number of bytes that would be needed to encode an + /// sfixed64 field, including the tag. + /// + public static int ComputeSFixed64Size(long value) + { + return LittleEndian64Size; + } + + /// + /// Computes the number of bytes that would be needed to encode an + /// sint32 field, including the tag. + /// + public static int ComputeSInt32Size(int value) + { + return ComputeRawVarint32Size(EncodeZigZag32(value)); + } + + /// + /// Computes the number of bytes that would be needed to encode an + /// sint64 field, including the tag. + /// + public static int ComputeSInt64Size(long value) + { + return ComputeRawVarint64Size(EncodeZigZag64(value)); + } + + /// + /// Computes the number of bytes that would be needed to encode a length, + /// as written by . + /// + public static int ComputeLengthSize(int length) + { + return ComputeRawVarint32Size((uint) length); + } + + /// + /// Computes the number of bytes that would be needed to encode a varint. + /// + public static int ComputeRawVarint32Size(uint value) + { + if ((value & (0xffffffff << 7)) == 0) + { + return 1; + } + if ((value & (0xffffffff << 14)) == 0) + { + return 2; + } + if ((value & (0xffffffff << 21)) == 0) + { + return 3; + } + if ((value & (0xffffffff << 28)) == 0) + { + return 4; + } + return 5; + } + + /// + /// Computes the number of bytes that would be needed to encode a varint. + /// + public static int ComputeRawVarint64Size(ulong value) + { + if ((value & (0xffffffffffffffffL << 7)) == 0) + { + return 1; + } + if ((value & (0xffffffffffffffffL << 14)) == 0) + { + return 2; + } + if ((value & (0xffffffffffffffffL << 21)) == 0) + { + return 3; + } + if ((value & (0xffffffffffffffffL << 28)) == 0) + { + return 4; + } + if ((value & (0xffffffffffffffffL << 35)) == 0) + { + return 5; + } + if ((value & (0xffffffffffffffffL << 42)) == 0) + { + return 6; + } + if ((value & (0xffffffffffffffffL << 49)) == 0) + { + return 7; + } + if ((value & (0xffffffffffffffffL << 56)) == 0) + { + return 8; + } + if ((value & (0xffffffffffffffffL << 63)) == 0) + { + return 9; + } + return 10; + } + + /// + /// Computes the number of bytes that would be needed to encode a tag. + /// + public static int ComputeTagSize(int fieldNumber) + { + return ComputeRawVarint32Size(WireFormat.MakeTag(fieldNumber, 0)); + } + } +} \ No newline at end of file diff --git a/csharp/src/Google.Protobuf/CodedOutputStream.cs b/csharp/src/Google.Protobuf/CodedOutputStream.cs new file mode 100644 index 00000000..b91d6d70 --- /dev/null +++ b/csharp/src/Google.Protobuf/CodedOutputStream.cs @@ -0,0 +1,705 @@ +#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; +using System.IO; +using System.Text; + +namespace Google.Protobuf +{ + /// + /// Encodes and writes protocol message fields. + /// + /// + /// This class contains two kinds of methods: methods that write specific + /// protocol message constructs and field types (e.g. WriteTag and + /// WriteInt32) and methods that write low-level values (e.g. + /// WriteRawVarint32 and WriteRawBytes). If you are writing encoded protocol + /// messages, you should use the former methods, but if you are writing some + /// other format of your own design, use the latter. The names of the former + /// methods are taken from the protocol buffer type names, not .NET types. + /// (Hence WriteFloat instead of WriteSingle, and WriteBool instead of WriteBoolean.) + /// + public sealed partial class CodedOutputStream + { + // "Local" copy of Encoding.UTF8, for efficiency. (Yes, it makes a difference.) + internal static readonly Encoding Utf8Encoding = Encoding.UTF8; + + /// + /// The buffer size used by CreateInstance(Stream). + /// + public static readonly int DefaultBufferSize = 4096; + + private readonly byte[] buffer; + private readonly int limit; + private int position; + private readonly Stream output; + + #region Construction + + private CodedOutputStream(byte[] buffer, int offset, int length) + { + this.output = null; + this.buffer = buffer; + this.position = offset; + this.limit = offset + length; + } + + private CodedOutputStream(Stream output, byte[] buffer) + { + this.output = output; + this.buffer = buffer; + this.position = 0; + this.limit = buffer.Length; + } + + /// + /// Creates a new CodedOutputStream which write to the given stream. + /// + public static CodedOutputStream CreateInstance(Stream output) + { + return CreateInstance(output, DefaultBufferSize); + } + + /// + /// Creates a new CodedOutputStream which write to the given stream and uses + /// the specified buffer size. + /// + public static CodedOutputStream CreateInstance(Stream output, int bufferSize) + { + return new CodedOutputStream(output, new byte[bufferSize]); + } + + /// + /// Creates a new CodedOutputStream that writes directly to the given + /// byte array. If more bytes are written than fit in the array, + /// OutOfSpaceException will be thrown. + /// + public static CodedOutputStream CreateInstance(byte[] flatArray) + { + return CreateInstance(flatArray, 0, flatArray.Length); + } + + /// + /// Creates a new CodedOutputStream that writes directly to the given + /// byte array slice. If more bytes are written than fit in the array, + /// OutOfSpaceException will be thrown. + /// + public static CodedOutputStream CreateInstance(byte[] flatArray, int offset, int length) + { + return new CodedOutputStream(flatArray, offset, length); + } + + #endregion + + /// + /// Returns the current position in the stream, or the position in the output buffer + /// + public long Position + { + get + { + if (output != null) + { + return output.Position + position; + } + return position; + } + } + + #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) + { + byte[] rawBytes = BitConverter.GetBytes(value); + if (!BitConverter.IsLittleEndian) + { + ByteArray.Reverse(rawBytes); + } + + if (limit - position >= 4) + { + buffer[position++] = rawBytes[0]; + buffer[position++] = rawBytes[1]; + buffer[position++] = rawBytes[2]; + buffer[position++] = rawBytes[3]; + } + else + { + WriteRawBytes(rawBytes, 0, 4); + } + } + + /// + /// 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) + { + // Optimise the case where we have enough space to write + // the string directly to the buffer, which should be common. + int length = Utf8Encoding.GetByteCount(value); + WriteLength(length); + if (limit - position >= length) + { + if (length == value.Length) // Must be all ASCII... + { + for (int i = 0; i < length; i++) + { + buffer[position + i] = (byte)value[i]; + } + } + else + { + Utf8Encoding.GetBytes(value, 0, value.Length, buffer, position); + } + position += length; + } + else + { + byte[] bytes = Utf8Encoding.GetBytes(value); + WriteRawBytes(bytes); + } + } + + /// + /// Writes a message, without a tag, to the stream. + /// The data is length-prefixed. + /// + /// The value to write + public void WriteMessage(IMessage value) + { + WriteLength(value.CalculateSize()); + value.WriteTo(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); + value.WriteRawBytesTo(this); + } + + /// + /// 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); + } + + 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(EncodeZigZag32(value)); + } + + /// + /// Writes an sint64 value, without a tag, to the stream. + /// + /// The value to write + public void WriteSInt64(long value) + { + WriteRawVarint64(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) + { + WriteRawByte(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) + { + WriteRawByte(b1); + WriteRawByte(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) + { + WriteRawByte(b1); + WriteRawByte(b2); + WriteRawByte(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) + { + WriteRawByte(b1); + WriteRawByte(b2); + WriteRawByte(b3); + WriteRawByte(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) + { + WriteRawByte(b1); + WriteRawByte(b2); + WriteRawByte(b3); + WriteRawByte(b4); + WriteRawByte(b5); + } + #endregion + + #region Underlying writing primitives + /// + /// Writes a 32 bit value as a varint. The fast route is taken when + /// there's enough buffer space left to whizz through without checking + /// for each byte; otherwise, we resort to calling WriteRawByte each time. + /// + internal void WriteRawVarint32(uint value) + { + // Optimize for the common case of a single byte value + if (value < 128 && position < limit) + { + buffer[position++] = (byte)value; + return; + } + + while (value > 127 && position < limit) + { + buffer[position++] = (byte) ((value & 0x7F) | 0x80); + value >>= 7; + } + while (value > 127) + { + WriteRawByte((byte) ((value & 0x7F) | 0x80)); + value >>= 7; + } + if (position < limit) + { + buffer[position++] = (byte) value; + } + else + { + WriteRawByte((byte) value); + } + } + + internal void WriteRawVarint64(ulong value) + { + while (value > 127 && position < limit) + { + buffer[position++] = (byte) ((value & 0x7F) | 0x80); + value >>= 7; + } + while (value > 127) + { + WriteRawByte((byte) ((value & 0x7F) | 0x80)); + value >>= 7; + } + if (position < limit) + { + buffer[position++] = (byte) value; + } + else + { + WriteRawByte((byte) value); + } + } + + internal void WriteRawLittleEndian32(uint value) + { + if (position + 4 > limit) + { + WriteRawByte((byte) value); + WriteRawByte((byte) (value >> 8)); + WriteRawByte((byte) (value >> 16)); + WriteRawByte((byte) (value >> 24)); + } + else + { + buffer[position++] = ((byte) value); + buffer[position++] = ((byte) (value >> 8)); + buffer[position++] = ((byte) (value >> 16)); + buffer[position++] = ((byte) (value >> 24)); + } + } + + internal void WriteRawLittleEndian64(ulong value) + { + if (position + 8 > limit) + { + WriteRawByte((byte) value); + WriteRawByte((byte) (value >> 8)); + WriteRawByte((byte) (value >> 16)); + WriteRawByte((byte) (value >> 24)); + WriteRawByte((byte) (value >> 32)); + WriteRawByte((byte) (value >> 40)); + WriteRawByte((byte) (value >> 48)); + WriteRawByte((byte) (value >> 56)); + } + else + { + buffer[position++] = ((byte) value); + buffer[position++] = ((byte) (value >> 8)); + buffer[position++] = ((byte) (value >> 16)); + buffer[position++] = ((byte) (value >> 24)); + buffer[position++] = ((byte) (value >> 32)); + buffer[position++] = ((byte) (value >> 40)); + buffer[position++] = ((byte) (value >> 48)); + buffer[position++] = ((byte) (value >> 56)); + } + } + + internal void WriteRawByte(byte value) + { + if (position == limit) + { + RefreshBuffer(); + } + + buffer[position++] = value; + } + + internal void WriteRawByte(uint value) + { + WriteRawByte((byte) 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) + { + if (limit - position >= length) + { + ByteArray.Copy(value, offset, buffer, position, length); + // We have room in the current buffer. + position += length; + } + else + { + // Write extends past current buffer. Fill the rest of this buffer and + // flush. + int bytesWritten = limit - position; + ByteArray.Copy(value, offset, buffer, position, bytesWritten); + offset += bytesWritten; + length -= bytesWritten; + position = limit; + RefreshBuffer(); + + // Now deal with the rest. + // Since we have an output stream, this is our buffer + // and buffer offset == 0 + if (length <= limit) + { + // Fits in new buffer. + ByteArray.Copy(value, offset, buffer, 0, length); + position = length; + } + else + { + // Write is very big. Let's do it all at once. + output.Write(value, offset, length); + } + } + } + + #endregion + + /// + /// Encode a 32-bit value with ZigZag encoding. + /// + /// + /// ZigZag encodes signed integers into values that can be efficiently + /// encoded with varint. (Otherwise, negative values must be + /// sign-extended to 64 bits to be varint encoded, thus always taking + /// 10 bytes on the wire.) + /// + internal static uint EncodeZigZag32(int n) + { + // Note: the right-shift must be arithmetic + return (uint) ((n << 1) ^ (n >> 31)); + } + + /// + /// Encode a 64-bit value with ZigZag encoding. + /// + /// + /// ZigZag encodes signed integers into values that can be efficiently + /// encoded with varint. (Otherwise, negative values must be + /// sign-extended to 64 bits to be varint encoded, thus always taking + /// 10 bytes on the wire.) + /// + internal static ulong EncodeZigZag64(long n) + { + return (ulong) ((n << 1) ^ (n >> 63)); + } + + private void RefreshBuffer() + { + if (output == null) + { + // We're writing to a single buffer. + throw new OutOfSpaceException(); + } + + // Since we have an output stream, this is our buffer + // and buffer offset == 0 + output.Write(buffer, 0, position); + position = 0; + } + + /// + /// Indicates that a CodedOutputStream wrapping a flat byte array + /// ran out of space. + /// + public sealed class OutOfSpaceException : IOException + { + internal OutOfSpaceException() + : base("CodedOutputStream was writing to a flat byte array and ran out of space.") + { + } + } + + public void Flush() + { + if (output != null) + { + RefreshBuffer(); + } + } + + /// + /// Verifies that SpaceLeft returns zero. It's common to create a byte array + /// that is exactly big enough to hold a message, then write to it with + /// a CodedOutputStream. Calling CheckNoSpaceLeft after writing verifies that + /// the message was actually as big as expected, which can help bugs. + /// + public void CheckNoSpaceLeft() + { + if (SpaceLeft != 0) + { + throw new InvalidOperationException("Did not write as much data as expected."); + } + } + + /// + /// If writing to a flat array, returns the space left in the array. Otherwise, + /// throws an InvalidOperationException. + /// + public int SpaceLeft + { + get + { + if (output == null) + { + return limit - position; + } + else + { + throw new InvalidOperationException( + "SpaceLeft can only be called on CodedOutputStreams that are " + + "writing to a flat array."); + } + } + } + } +} \ No newline at end of file diff --git a/csharp/src/Google.Protobuf/Collections/MapField.cs b/csharp/src/Google.Protobuf/Collections/MapField.cs new file mode 100644 index 00000000..f5e4fd3a --- /dev/null +++ b/csharp/src/Google.Protobuf/Collections/MapField.cs @@ -0,0 +1,565 @@ +#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 System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; + +namespace Google.Protobuf.Collections +{ + /// + /// Representation of a map field in a Protocol Buffer message. + /// + /// + /// This implementation preserves insertion order for simplicity of testing + /// code using maps fields. Overwriting an existing entry does not change the + /// position of that entry within the map. Equality is not order-sensitive. + /// For string keys, the equality comparison is provided by . + /// + /// Key type in the map. Must be a type supported by Protocol Buffer map keys. + /// Value type in the map. Must be a type supported by Protocol Buffers. + public sealed class MapField : IDeepCloneable>, IFreezable, IDictionary, IEquatable>, IDictionary + { + // TODO: Don't create the map/list until we have an entry. (Assume many maps will be empty.) + private readonly bool allowNullValues; + private bool frozen; + private readonly Dictionary>> map = + new Dictionary>>(); + private readonly LinkedList> list = new LinkedList>(); + + /// + /// Constructs a new map field, defaulting the value nullability to only allow null values for message types + /// and non-nullable value types. + /// + public MapField() : this(typeof(IMessage).IsAssignableFrom(typeof(TValue)) || Nullable.GetUnderlyingType(typeof(TValue)) != null) + { + } + + /// + /// Constructs a new map field, overriding the choice of whether null values are permitted in the map. + /// This is used by wrapper types, where maps with string and bytes wrappers as the value types + /// support null values. + /// + /// Whether null values are permitted in the map or not. + public MapField(bool allowNullValues) + { + if (allowNullValues && typeof(TValue).IsValueType && Nullable.GetUnderlyingType(typeof(TValue)) == null) + { + throw new ArgumentException("allowNullValues", "Non-nullable value types do not support null values"); + } + this.allowNullValues = allowNullValues; + } + + public MapField Clone() + { + var clone = new MapField(allowNullValues); + // Keys are never cloneable. Values might be. + if (typeof(IDeepCloneable).IsAssignableFrom(typeof(TValue))) + { + foreach (var pair in list) + { + clone.Add(pair.Key, pair.Value == null ? pair.Value : ((IDeepCloneable)pair.Value).Clone()); + } + } + else + { + // Nothing is cloneable, so we don't need to worry. + clone.Add(this); + } + return clone; + } + + public void Add(TKey key, TValue value) + { + // Validation of arguments happens in ContainsKey and the indexer + if (ContainsKey(key)) + { + throw new ArgumentException("Key already exists in map", "key"); + } + this[key] = value; + } + + public bool ContainsKey(TKey key) + { + ThrowHelper.ThrowIfNull(key, "key"); + return map.ContainsKey(key); + } + + public bool Remove(TKey key) + { + this.CheckMutable(); + ThrowHelper.ThrowIfNull(key, "key"); + LinkedListNode> node; + if (map.TryGetValue(key, out node)) + { + map.Remove(key); + node.List.Remove(node); + return true; + } + else + { + return false; + } + } + + public bool TryGetValue(TKey key, out TValue value) + { + LinkedListNode> node; + if (map.TryGetValue(key, out node)) + { + value = node.Value.Value; + return true; + } + else + { + value = default(TValue); + return false; + } + } + + public TValue this[TKey key] + { + get + { + ThrowHelper.ThrowIfNull(key, "key"); + TValue value; + if (TryGetValue(key, out value)) + { + return value; + } + throw new KeyNotFoundException(); + } + set + { + ThrowHelper.ThrowIfNull(key, "key"); + // value == null check here is redundant, but avoids boxing. + if (value == null && !allowNullValues) + { + ThrowHelper.ThrowIfNull(value, "value"); + } + this.CheckMutable(); + LinkedListNode> node; + var pair = new KeyValuePair(key, value); + if (map.TryGetValue(key, out node)) + { + node.Value = pair; + } + else + { + node = list.AddLast(pair); + map[key] = node; + } + } + } + + // TODO: Make these views? + public ICollection Keys { get { return list.Select(t => t.Key).ToList(); } } + public ICollection Values { get { return list.Select(t => t.Value).ToList(); } } + + public void Add(IDictionary entries) + { + ThrowHelper.ThrowIfNull(entries, "entries"); + foreach (var pair in entries) + { + Add(pair.Key, pair.Value); + } + } + + public IEnumerator> GetEnumerator() + { + return list.GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + void ICollection>.Add(KeyValuePair item) + { + Add(item.Key, item.Value); + } + + public void Clear() + { + this.CheckMutable(); + list.Clear(); + map.Clear(); + } + + bool ICollection>.Contains(KeyValuePair item) + { + TValue value; + return TryGetValue(item.Key, out value) + && EqualityComparer.Default.Equals(item.Value, value); + } + + void ICollection>.CopyTo(KeyValuePair[] array, int arrayIndex) + { + list.CopyTo(array, arrayIndex); + } + + bool ICollection>.Remove(KeyValuePair item) + { + this.CheckMutable(); + if (item.Key == null) + { + throw new ArgumentException("Key is null", "item"); + } + LinkedListNode> node; + if (map.TryGetValue(item.Key, out node) && + EqualityComparer.Default.Equals(item.Value, node.Value.Value)) + { + map.Remove(item.Key); + node.List.Remove(node); + return true; + } + else + { + return false; + } + } + + /// + /// Returns whether or not this map allows values to be null. + /// + public bool AllowsNullValues { get { return allowNullValues; } } + + public int Count { get { return list.Count; } } + public bool IsReadOnly { get { return frozen; } } + + public void Freeze() + { + if (IsFrozen) + { + return; + } + frozen = true; + // Only values can be frozen, as all the key types are simple. + // Everything can be done in-place, as we're just freezing objects. + if (typeof(IFreezable).IsAssignableFrom(typeof(TValue))) + { + for (var node = list.First; node != null; node = node.Next) + { + var pair = node.Value; + IFreezable freezableValue = pair.Value as IFreezable; + if (freezableValue != null) + { + freezableValue.Freeze(); + } + } + } + } + + public bool IsFrozen { get { return frozen; } } + + public override bool Equals(object other) + { + return Equals(other as MapField); + } + + public override int GetHashCode() + { + var valueComparer = EqualityComparer.Default; + int hash = 0; + foreach (var pair in list) + { + hash ^= pair.Key.GetHashCode() * 31 + valueComparer.GetHashCode(pair.Value); + } + return hash; + } + + public bool Equals(MapField other) + { + if (other == null) + { + return false; + } + if (other == this) + { + return true; + } + if (other.Count != this.Count) + { + return false; + } + var valueComparer = EqualityComparer.Default; + foreach (var pair in this) + { + TValue value; + if (!other.TryGetValue(pair.Key, out value)) + { + return false; + } + if (!valueComparer.Equals(value, pair.Value)) + { + return false; + } + } + return true; + } + + /// + /// Adds entries to the map from the given stream. + /// + /// + /// 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 + /// a different tag is encountered. + /// + /// Stream to read from + /// Codec describing how the key/value pairs are encoded + public void AddEntriesFrom(CodedInputStream 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)); + } + + public void WriteTo(CodedOutputStream 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); + } + } + + public int CalculateSize(Codec codec) + { + if (Count == 0) + { + return 0; + } + var message = new Codec.MessageAdapter(codec); + int size = 0; + foreach (var entry in list) + { + message.Key = entry.Key; + message.Value = entry.Value; + size += CodedOutputStream.ComputeRawVarint32Size(codec.MapTag); + size += CodedOutputStream.ComputeMessageSize(message); + } + return size; + } + + #region IDictionary explicit interface implementation + void IDictionary.Add(object key, object value) + { + Add((TKey)key, (TValue)value); + } + + bool IDictionary.Contains(object key) + { + if (!(key is TKey)) + { + return false; + } + return ContainsKey((TKey)key); + } + + IDictionaryEnumerator IDictionary.GetEnumerator() + { + return new DictionaryEnumerator(GetEnumerator()); + } + + void IDictionary.Remove(object key) + { + ThrowHelper.ThrowIfNull(key, "key"); + this.CheckMutable(); + if (!(key is TKey)) + { + return; + } + Remove((TKey)key); + } + + void ICollection.CopyTo(Array array, int index) + { + // This is ugly and slow as heck, but with any luck it will never be used anyway. + ICollection temp = this.Select(pair => new DictionaryEntry(pair.Key, pair.Value)).ToList(); + temp.CopyTo(array, index); + } + + bool IDictionary.IsFixedSize { get { return IsFrozen; } } + + ICollection IDictionary.Keys { get { return (ICollection)Keys; } } + + ICollection IDictionary.Values { get { return (ICollection)Values; } } + + bool ICollection.IsSynchronized { get { return false; } } + + object ICollection.SyncRoot { get { return this; } } + + object IDictionary.this[object key] + { + get + { + ThrowHelper.ThrowIfNull(key, "key"); + if (!(key is TKey)) + { + return null; + } + TValue value; + TryGetValue((TKey)key, out value); + return value; + } + + set + { + if (frozen) + { + throw new NotSupportedException("Dictionary is frozen"); + } + this[(TKey)key] = (TValue)value; + } + } + #endregion + + private class DictionaryEnumerator : IDictionaryEnumerator + { + private readonly IEnumerator> enumerator; + + internal DictionaryEnumerator(IEnumerator> enumerator) + { + this.enumerator = enumerator; + } + + public bool MoveNext() + { + return enumerator.MoveNext(); + } + + public void Reset() + { + enumerator.Reset(); + } + + public object Current { get { return Entry; } } + public DictionaryEntry Entry { get { return new DictionaryEntry(Key, Value); } } + public object Key { get { return enumerator.Current.Key; } } + public object Value { get { return enumerator.Current.Value; } } + } + + /// + /// A codec for a specific map field. This contains all the information required to encoded and + /// decode the nested messages. + /// + public sealed class Codec + { + private readonly FieldCodec keyCodec; + private readonly FieldCodec valueCodec; + private readonly uint mapTag; + + public Codec(FieldCodec keyCodec, FieldCodec valueCodec, uint mapTag) + { + this.keyCodec = keyCodec; + this.valueCodec = valueCodec; + this.mapTag = mapTag; + } + + /// + /// The tag used in the enclosing message to indicate map entries. + /// + internal uint MapTag { get { return mapTag; } } + + /// + /// A mutable message class, used for parsing and serializing. This + /// delegates the work to a codec, but implements the interface + /// for interop with and . + /// This is nested inside Codec as it's tightly coupled to the associated codec, + /// and it's simpler if it has direct access to all its fields. + /// + internal class MessageAdapter : IMessage + { + private readonly Codec codec; + internal TKey Key { get; set; } + internal TValue Value { get; set; } + + internal MessageAdapter(Codec codec) + { + this.codec = codec; + } + + internal void Reset() + { + Key = codec.keyCodec.DefaultValue; + Value = codec.valueCodec.DefaultValue; + } + + public void MergeFrom(CodedInputStream input) + { + uint tag; + while (input.ReadTag(out tag)) + { + if (tag == 0) + { + throw InvalidProtocolBufferException.InvalidTag(); + } + if (tag == codec.keyCodec.Tag) + { + Key = codec.keyCodec.Read(input); + } + else if (tag == codec.valueCodec.Tag) + { + Value = codec.valueCodec.Read(input); + } + else if (WireFormat.IsEndGroupTag(tag)) + { + // TODO(jonskeet): Do we need this? (Given that we don't support groups...) + return; + } + } + } + + public void WriteTo(CodedOutputStream output) + { + codec.keyCodec.WriteTagAndValue(output, Key); + codec.valueCodec.WriteTagAndValue(output, Value); + } + + public int CalculateSize() + { + return codec.keyCodec.CalculateSizeWithTag(Key) + codec.valueCodec.CalculateSizeWithTag(Value); + } + } + } + } +} diff --git a/csharp/src/Google.Protobuf/Collections/ReadOnlyDictionary.cs b/csharp/src/Google.Protobuf/Collections/ReadOnlyDictionary.cs new file mode 100644 index 00000000..84360667 --- /dev/null +++ b/csharp/src/Google.Protobuf/Collections/ReadOnlyDictionary.cs @@ -0,0 +1,147 @@ +#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; +using System.Collections; +using System.Collections.Generic; + +namespace Google.Protobuf.Collections +{ + /// + /// Read-only wrapper around another dictionary. + /// + internal sealed class ReadOnlyDictionary : IDictionary + { + private readonly IDictionary wrapped; + + public ReadOnlyDictionary(IDictionary wrapped) + { + this.wrapped = wrapped; + } + + public void Add(TKey key, TValue value) + { + throw new InvalidOperationException(); + } + + public bool ContainsKey(TKey key) + { + return wrapped.ContainsKey(key); + } + + public ICollection Keys + { + get { return wrapped.Keys; } + } + + public bool Remove(TKey key) + { + throw new InvalidOperationException(); + } + + public bool TryGetValue(TKey key, out TValue value) + { + return wrapped.TryGetValue(key, out value); + } + + public ICollection Values + { + get { return wrapped.Values; } + } + + public TValue this[TKey key] + { + get { return wrapped[key]; } + set { throw new InvalidOperationException(); } + } + + public void Add(KeyValuePair item) + { + throw new InvalidOperationException(); + } + + public void Clear() + { + throw new InvalidOperationException(); + } + + public bool Contains(KeyValuePair item) + { + return wrapped.Contains(item); + } + + public void CopyTo(KeyValuePair[] array, int arrayIndex) + { + wrapped.CopyTo(array, arrayIndex); + } + + public int Count + { + get { return wrapped.Count; } + } + + public bool IsReadOnly + { + get { return true; } + } + + public bool Remove(KeyValuePair item) + { + throw new InvalidOperationException(); + } + + public IEnumerator> GetEnumerator() + { + return wrapped.GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return ((IEnumerable) wrapped).GetEnumerator(); + } + + public override bool Equals(object obj) + { + return wrapped.Equals(obj); + } + + public override int GetHashCode() + { + return wrapped.GetHashCode(); + } + + public override string ToString() + { + return wrapped.ToString(); + } + } +} \ No newline at end of file diff --git a/csharp/src/Google.Protobuf/Collections/RepeatedField.cs b/csharp/src/Google.Protobuf/Collections/RepeatedField.cs new file mode 100644 index 00000000..9bab41ea --- /dev/null +++ b/csharp/src/Google.Protobuf/Collections/RepeatedField.cs @@ -0,0 +1,470 @@ +#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 System; +using System.Collections; +using System.Collections.Generic; + +namespace Google.Protobuf.Collections +{ + /// + /// The contents of a repeated field: essentially, a collection with some extra + /// restrictions (no null values) and capabilities (deep cloning and freezing). + /// + /// The element type of the repeated field. + public sealed class RepeatedField : IList, IList, IDeepCloneable>, IEquatable>, IFreezable + { + private static readonly T[] EmptyArray = new T[0]; + private const int MinArraySize = 8; + + private bool frozen; + private T[] array = EmptyArray; + private int count = 0; + + /// + /// Creates a deep clone of this repeated field. + /// + /// + /// If the field type is + /// a message type, each element is also cloned; otherwise, it is + /// assumed that the field type is primitive (including string and + /// bytes, both of which are immutable) and so a simple copy is + /// equivalent to a deep clone. + /// + /// A deep clone of this repeated field. + public RepeatedField Clone() + { + RepeatedField clone = new RepeatedField(); + // Clone is implicitly *not* frozen, even if this object is. + if (array != EmptyArray) + { + clone.array = (T[])array.Clone(); + IDeepCloneable[] cloneableArray = clone.array as IDeepCloneable[]; + if (cloneableArray != null) + { + for (int i = 0; i < count; i++) + { + clone.array[i] = cloneableArray[i].Clone(); + } + } + } + clone.count = count; + return clone; + } + + public void AddEntriesFrom(CodedInputStream input, FieldCodec codec) + { + // TODO: Inline some of the Add code, so we can avoid checking the size on every + // iteration and the mutability. + uint tag = input.LastTag; + var reader = codec.ValueReader; + // Value types can be packed or not. + if (typeof(T).IsValueType && WireFormat.GetTagWireType(tag) == WireFormat.WireType.LengthDelimited) + { + int length = input.ReadLength(); + if (length > 0) + { + int oldLimit = input.PushLimit(length); + while (!input.ReachedLimit) + { + Add(reader(input)); + } + input.PopLimit(oldLimit); + } + // Empty packed field. Odd, but valid - just ignore. + } + else + { + // Not packed... (possibly not packable) + do + { + Add(reader(input)); + } while (input.MaybeConsumeTag(tag)); + } + } + + public int CalculateSize(FieldCodec codec) + { + if (count == 0) + { + return 0; + } + uint tag = codec.Tag; + if (typeof(T).IsValueType && WireFormat.GetTagWireType(tag) == WireFormat.WireType.LengthDelimited) + { + int dataSize = CalculatePackedDataSize(codec); + return CodedOutputStream.ComputeRawVarint32Size(tag) + + CodedOutputStream.ComputeLengthSize(dataSize) + + dataSize; + } + else + { + var sizeCalculator = codec.ValueSizeCalculator; + int size = count * CodedOutputStream.ComputeRawVarint32Size(tag); + for (int i = 0; i < count; i++) + { + size += sizeCalculator(array[i]); + } + return size; + } + } + + private int CalculatePackedDataSize(FieldCodec codec) + { + int fixedSize = codec.FixedSize; + if (fixedSize == 0) + { + var calculator = codec.ValueSizeCalculator; + int tmp = 0; + for (int i = 0; i < count; i++) + { + tmp += calculator(array[i]); + } + return tmp; + } + else + { + return fixedSize * Count; + } + } + + public void WriteTo(CodedOutputStream output, FieldCodec codec) + { + if (count == 0) + { + return; + } + var writer = codec.ValueWriter; + var tag = codec.Tag; + if (typeof(T).IsValueType && WireFormat.GetTagWireType(tag) == WireFormat.WireType.LengthDelimited) + { + // Packed primitive type + uint size = (uint)CalculatePackedDataSize(codec); + output.WriteTag(tag); + output.WriteRawVarint32(size); + for (int i = 0; i < count; i++) + { + writer(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(output, array[i]); + } + } + } + + public bool IsFrozen { get { return frozen; } } + + public void Freeze() + { + frozen = true; + IFreezable[] freezableArray = array as IFreezable[]; + if (freezableArray != null) + { + for (int i = 0; i < count; i++) + { + freezableArray[i].Freeze(); + } + } + } + + private void EnsureSize(int size) + { + if (array.Length < size) + { + size = Math.Max(size, MinArraySize); + int newSize = Math.Max(array.Length * 2, size); + var tmp = new T[newSize]; + Array.Copy(array, 0, tmp, 0, array.Length); + array = tmp; + } + } + + public void Add(T item) + { + if (item == null) + { + throw new ArgumentNullException("item"); + } + this.CheckMutable(); + EnsureSize(count + 1); + array[count++] = item; + } + + public void Clear() + { + this.CheckMutable(); + array = EmptyArray; + count = 0; + } + + public bool Contains(T item) + { + return IndexOf(item) != -1; + } + + public void CopyTo(T[] array, int arrayIndex) + { + Array.Copy(this.array, 0, array, arrayIndex, count); + } + + public bool Remove(T item) + { + this.CheckMutable(); + int index = IndexOf(item); + if (index == -1) + { + return false; + } + Array.Copy(array, index + 1, array, index, count - index - 1); + count--; + array[count] = default(T); + return true; + } + + public int Count { get { return count; } } + + public bool IsReadOnly { get { return IsFrozen; } } + + public void Add(RepeatedField values) + { + if (values == null) + { + throw new ArgumentNullException("values"); + } + this.CheckMutable(); + EnsureSize(count + values.count); + // We know that all the values will be valid, because it's a RepeatedField. + Array.Copy(values.array, 0, array, count, values.count); + count += values.count; + } + + public void Add(IEnumerable values) + { + if (values == null) + { + throw new ArgumentNullException("values"); + } + this.CheckMutable(); + // TODO: Check for ICollection and get the Count? + foreach (T item in values) + { + Add(item); + } + } + + public IEnumerator GetEnumerator() + { + for (int i = 0; i < count; i++) + { + yield return array[i]; + } + } + + public override bool Equals(object obj) + { + return Equals(obj as RepeatedField); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public override int GetHashCode() + { + int hash = 0; + for (int i = 0; i < count; i++) + { + hash = hash * 31 + array[i].GetHashCode(); + } + return hash; + } + + public bool Equals(RepeatedField other) + { + if (ReferenceEquals(other, null)) + { + return false; + } + if (ReferenceEquals(other, this)) + { + return true; + } + if (other.Count != this.Count) + { + return false; + } + // TODO(jonskeet): Does this box for enums? + EqualityComparer comparer = EqualityComparer.Default; + for (int i = 0; i < count; i++) + { + if (!comparer.Equals(array[i], other.array[i])) + { + return false; + } + } + return true; + } + + public int IndexOf(T item) + { + if (item == null) + { + throw new ArgumentNullException("item"); + } + // TODO(jonskeet): Does this box for enums? + EqualityComparer comparer = EqualityComparer.Default; + for (int i = 0; i < count; i++) + { + if (comparer.Equals(array[i], item)) + { + return i; + } + } + return -1; + } + + public void Insert(int index, T item) + { + if (item == null) + { + throw new ArgumentNullException("item"); + } + if (index < 0 || index > count) + { + throw new ArgumentOutOfRangeException("index"); + } + this.CheckMutable(); + EnsureSize(count + 1); + Array.Copy(array, index, array, index + 1, count - index); + array[index] = item; + count++; + } + + public void RemoveAt(int index) + { + if (index < 0 || index >= count) + { + throw new ArgumentOutOfRangeException("index"); + } + this.CheckMutable(); + Array.Copy(array, index + 1, array, index, count - index - 1); + count--; + array[count] = default(T); + } + + public T this[int index] + { + get + { + if (index < 0 || index >= count) + { + throw new ArgumentOutOfRangeException("index"); + } + return array[index]; + } + set + { + if (index < 0 || index >= count) + { + throw new ArgumentOutOfRangeException("index"); + } + this.CheckMutable(); + if (value == null) + { + throw new ArgumentNullException("value"); + } + array[index] = value; + } + } + + #region Explicit interface implementation for IList and ICollection. + bool IList.IsFixedSize { get { return IsFrozen; } } + + void ICollection.CopyTo(Array array, int index) + { + Array.Copy(this.array, 0, array, index, count); + } + + bool ICollection.IsSynchronized { get { return false; } } + + object ICollection.SyncRoot { get { return this; } } + + object IList.this[int index] + { + get { return this[index]; } + set { this[index] = (T)value; } + } + + int IList.Add(object value) + { + Add((T) value); + return count - 1; + } + + bool IList.Contains(object value) + { + return (value is T && Contains((T)value)); + } + + int IList.IndexOf(object value) + { + if (!(value is T)) + { + return -1; + } + return IndexOf((T)value); + } + + void IList.Insert(int index, object value) + { + Insert(index, (T) value); + } + + void IList.Remove(object value) + { + if (!(value is T)) + { + return; + } + Remove((T)value); + } + #endregion + } +} diff --git a/csharp/src/Google.Protobuf/FieldCodec.cs b/csharp/src/Google.Protobuf/FieldCodec.cs new file mode 100644 index 00000000..85462787 --- /dev/null +++ b/csharp/src/Google.Protobuf/FieldCodec.cs @@ -0,0 +1,382 @@ +#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 System; +using System.Collections.Generic; + +namespace Google.Protobuf +{ + /// + /// Factory methods for . + /// + public static class FieldCodec + { + // TODO: Avoid the "dual hit" of lambda expressions: create open delegates instead. (At least test...) + public static FieldCodec ForString(uint tag) + { + return new FieldCodec(input => input.ReadString(), (output, value) => output.WriteString(value), CodedOutputStream.ComputeStringSize, tag); + } + + public static FieldCodec ForBytes(uint tag) + { + return new FieldCodec(input => input.ReadBytes(), (output, value) => output.WriteBytes(value), CodedOutputStream.ComputeBytesSize, tag); + } + + public static FieldCodec ForBool(uint tag) + { + return new FieldCodec(input => input.ReadBool(), (output, value) => output.WriteBool(value), CodedOutputStream.ComputeBoolSize, tag); + } + + public static FieldCodec ForInt32(uint tag) + { + return new FieldCodec(input => input.ReadInt32(), (output, value) => output.WriteInt32(value), CodedOutputStream.ComputeInt32Size, tag); + } + + public static FieldCodec ForSInt32(uint tag) + { + return new FieldCodec(input => input.ReadSInt32(), (output, value) => output.WriteSInt32(value), CodedOutputStream.ComputeSInt32Size, tag); + } + + public static FieldCodec ForFixed32(uint tag) + { + return new FieldCodec(input => input.ReadFixed32(), (output, value) => output.WriteFixed32(value), 4, tag); + } + + public static FieldCodec ForSFixed32(uint tag) + { + return new FieldCodec(input => input.ReadSFixed32(), (output, value) => output.WriteSFixed32(value), 4, tag); + } + + public static FieldCodec ForUInt32(uint tag) + { + return new FieldCodec(input => input.ReadUInt32(), (output, value) => output.WriteUInt32(value), CodedOutputStream.ComputeUInt32Size, tag); + } + + public static FieldCodec ForInt64(uint tag) + { + return new FieldCodec(input => input.ReadInt64(), (output, value) => output.WriteInt64(value), CodedOutputStream.ComputeInt64Size, tag); + } + + public static FieldCodec ForSInt64(uint tag) + { + return new FieldCodec(input => input.ReadSInt64(), (output, value) => output.WriteSInt64(value), CodedOutputStream.ComputeSInt64Size, tag); + } + + public static FieldCodec ForFixed64(uint tag) + { + return new FieldCodec(input => input.ReadFixed64(), (output, value) => output.WriteFixed64(value), 8, tag); + } + + public static FieldCodec ForSFixed64(uint tag) + { + return new FieldCodec(input => input.ReadSFixed64(), (output, value) => output.WriteSFixed64(value), 8, tag); + } + + public static FieldCodec ForUInt64(uint tag) + { + return new FieldCodec(input => input.ReadUInt64(), (output, value) => output.WriteUInt64(value), CodedOutputStream.ComputeUInt64Size, tag); + } + + public static FieldCodec ForFloat(uint tag) + { + return new FieldCodec(input => input.ReadFloat(), (output, value) => output.WriteFloat(value), CodedOutputStream.ComputeFloatSize, tag); + } + + public static FieldCodec ForDouble(uint tag) + { + return new FieldCodec(input => input.ReadDouble(), (output, value) => output.WriteDouble(value), CodedOutputStream.ComputeDoubleSize, tag); + } + + // Enums are tricky. We can probably use expression trees to build these delegates automatically, + // but it's easy to generate the code for it. + public static FieldCodec ForEnum(uint tag, Func toInt32, Func fromInt32) + { + return new FieldCodec(input => fromInt32( + input.ReadEnum()), + (output, value) => output.WriteEnum(toInt32(value)), + value => CodedOutputStream.ComputeEnumSize(toInt32(value)), tag); + } + + public static FieldCodec ForMessage(uint tag, MessageParser parser) where T : IMessage + { + return new FieldCodec(input => { T message = parser.CreateTemplate(); input.ReadMessage(message); return message; }, + (output, value) => output.WriteMessage(value), message => CodedOutputStream.ComputeMessageSize(message), tag); + } + + /// + /// Creates a codec for a wrapper type of a class - which must be string or ByteString. + /// + public static FieldCodec ForClassWrapper(uint tag) where T : class + { + var nestedCodec = WrapperCodecs.GetCodec(); + return new FieldCodec( + input => WrapperCodecs.Read(input, nestedCodec), + (output, value) => WrapperCodecs.Write(output, value, nestedCodec), + value => WrapperCodecs.CalculateSize(value, nestedCodec), + tag, + null); // Default value for the wrapper + } + + /// + /// Creates a codec for a wrapper type of a struct - which must be Int32, Int64, UInt32, UInt64, + /// Bool, Single or Double. + /// + public static FieldCodec ForStructWrapper(uint tag) where T : struct + { + var nestedCodec = WrapperCodecs.GetCodec(); + return new FieldCodec( + input => WrapperCodecs.Read(input, nestedCodec), + (output, value) => WrapperCodecs.Write(output, value.Value, nestedCodec), + value => value == null ? 0 : WrapperCodecs.CalculateSize(value.Value, nestedCodec), + tag, + null); // Default value for the wrapper + } + + /// + /// Helper code to create codecs for wrapper types. + /// + /// + /// Somewhat ugly with all the static methods, but the conversions involved to/from nullable types make it + /// slightly tricky to improve. So long as we keep the public API (ForClassWrapper, ForStructWrapper) in place, + /// we can refactor later if we come up with something cleaner. + /// + private static class WrapperCodecs + { + // All the field numbers are the same (1). + private const int WrapperValueFieldNumber = Google.Protobuf.WellKnownTypes.Int32Value.ValueFieldNumber; + + private static readonly Dictionary Codecs = new Dictionary + { + { typeof(bool), ForBool(WireFormat.MakeTag(WrapperValueFieldNumber, WireFormat.WireType.Varint)) }, + { typeof(int), ForInt32(WireFormat.MakeTag(WrapperValueFieldNumber, WireFormat.WireType.Varint)) }, + { typeof(long), ForInt64(WireFormat.MakeTag(WrapperValueFieldNumber, WireFormat.WireType.Varint)) }, + { typeof(uint), ForUInt32(WireFormat.MakeTag(WrapperValueFieldNumber, WireFormat.WireType.Varint)) }, + { typeof(ulong), ForUInt64(WireFormat.MakeTag(WrapperValueFieldNumber, WireFormat.WireType.Varint)) }, + { typeof(float), ForFloat(WireFormat.MakeTag(WrapperValueFieldNumber, WireFormat.WireType.Fixed32)) }, + { typeof(double), ForDouble(WireFormat.MakeTag(WrapperValueFieldNumber, WireFormat.WireType.Fixed64)) }, + { typeof(string), ForString(WireFormat.MakeTag(WrapperValueFieldNumber, WireFormat.WireType.LengthDelimited)) }, + { typeof(ByteString), ForBytes(WireFormat.MakeTag(WrapperValueFieldNumber, WireFormat.WireType.LengthDelimited)) } + }; + + /// + /// Returns a field codec which effectively wraps a value of type T in a message. + /// + /// + internal static FieldCodec GetCodec() + { + object value; + if (!Codecs.TryGetValue(typeof(T), out value)) + { + throw new InvalidOperationException("Invalid type argument requested for wrapper codec: " + typeof(T)); + } + return (FieldCodec) value; + } + + internal static T Read(CodedInputStream input, FieldCodec codec) + { + int length = input.ReadLength(); + int oldLimit = input.PushLimit(length); + + uint tag; + T value = codec.DefaultValue; + while (input.ReadTag(out tag)) + { + if (tag == 0) + { + throw InvalidProtocolBufferException.InvalidTag(); + } + if (tag == codec.Tag) + { + value = codec.Read(input); + } + if (WireFormat.IsEndGroupTag(tag)) + { + break; + } + } + input.CheckLastTagWas(0); + input.PopLimit(oldLimit); + + return value; + } + + internal static void Write(CodedOutputStream output, T value, FieldCodec codec) + { + output.WriteLength(codec.CalculateSizeWithTag(value)); + codec.WriteTagAndValue(output, value); + } + + internal static int CalculateSize(T value, FieldCodec codec) + { + int fieldLength = codec.CalculateSizeWithTag(value); + return CodedOutputStream.ComputeLengthSize(fieldLength) + fieldLength; + } + } + } + + /// + /// An encode/decode pair for a single field. This effectively encapsulates + /// all the information needed to read or write the field value from/to a coded + /// stream. + /// + /// + /// This never writes default values to the stream, and is not currently designed + /// to play well with packed arrays. + /// + public sealed class FieldCodec + { + private static readonly T DefaultDefault; + + static FieldCodec() + { + if (typeof(T) == typeof(string)) + { + DefaultDefault = (T)(object)""; + } + else if (typeof(T) == typeof(ByteString)) + { + DefaultDefault = (T)(object)ByteString.Empty; + } + // Otherwise it's the default value of the CLR type + } + + private static Func CreateDefaultValueCheck(Func check) + { + return (Func)(object)check; + } + + private readonly Func reader; + private readonly Action writer; + private readonly Func sizeCalculator; + private readonly uint tag; + private readonly int tagSize; + private readonly int fixedSize; + // Default value for this codec. Usually the same for every instance of the same type, but + // for string/ByteString wrapper fields the codec's default value is null, whereas for + // other string/ByteString fields it's "" or ByteString.Empty. + private readonly T defaultValue; + + internal FieldCodec( + Func reader, + Action writer, + Func sizeCalculator, + uint tag) : this(reader, writer, sizeCalculator, tag, DefaultDefault) + { + } + + internal FieldCodec( + Func reader, + Action writer, + Func sizeCalculator, + uint tag, + T defaultValue) + { + this.reader = reader; + this.writer = writer; + this.sizeCalculator = sizeCalculator; + this.fixedSize = 0; + this.tag = tag; + this.defaultValue = defaultValue; + tagSize = CodedOutputStream.ComputeRawVarint32Size(tag); + } + + internal FieldCodec( + Func reader, + Action writer, + int fixedSize, + uint tag) + { + this.reader = reader; + this.writer = writer; + this.sizeCalculator = _ => fixedSize; + this.fixedSize = fixedSize; + this.tag = tag; + tagSize = CodedOutputStream.ComputeRawVarint32Size(tag); + } + + /// + /// Returns the size calculator for just a value. + /// + internal Func ValueSizeCalculator { get { return sizeCalculator; } } + + /// + /// Returns a delegate to write a value (unconditionally) to a coded output stream. + /// + internal Action ValueWriter { get { return writer; } } + + /// + /// Returns a delegate to read a value from a coded input stream. It is assumed that + /// the stream is already positioned on the appropriate tag. + /// + internal Func ValueReader { get { return reader; } } + + /// + /// Returns the fixed size for an entry, or 0 if sizes vary. + /// + internal int FixedSize { get { return fixedSize; } } + + public uint Tag { get { return tag; } } + + public T DefaultValue { get { return defaultValue; } } + + /// + /// Write a tag and the given value, *if* the value is not the default. + /// + public void WriteTagAndValue(CodedOutputStream output, T value) + { + if (!IsDefault(value)) + { + output.WriteTag(tag); + writer(output, value); + } + } + + public T Read(CodedInputStream input) + { + return reader(input); + } + + /// + /// Calculates the size required to write the given value, with a tag, + /// if the value is not the default. + /// + public int CalculateSizeWithTag(T value) + { + return IsDefault(value) ? 0 : sizeCalculator(value) + tagSize; + } + + private bool IsDefault(T value) + { + return EqualityComparer.Default.Equals(value, defaultValue); + } + } +} diff --git a/csharp/src/Google.Protobuf/FrameworkPortability.cs b/csharp/src/Google.Protobuf/FrameworkPortability.cs new file mode 100644 index 00000000..082eb2e1 --- /dev/null +++ b/csharp/src/Google.Protobuf/FrameworkPortability.cs @@ -0,0 +1,50 @@ +#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; +using System.Text.RegularExpressions; + +namespace Google.Protobuf +{ + /// + /// Class containing helpful workarounds for various platform compatibility + /// + internal static class FrameworkPortability + { + // TODO(jtattermusch): is this still a thing? + // The value of RegexOptions.Compiled is 8. We can test for the presence at + // execution time using Enum.IsDefined, so a single build will do the right thing + // on each platform. + internal static readonly RegexOptions CompiledRegexWhereAvailable = + Enum.IsDefined(typeof(RegexOptions), 8) ? (RegexOptions)8 : RegexOptions.None; + } +} \ No newline at end of file diff --git a/csharp/src/Google.Protobuf/Freezable.cs b/csharp/src/Google.Protobuf/Freezable.cs new file mode 100644 index 00000000..d16e1b42 --- /dev/null +++ b/csharp/src/Google.Protobuf/Freezable.cs @@ -0,0 +1,58 @@ +#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 System; + +namespace Google.Protobuf +{ + /// + /// Extension methods for types. + /// + public static class Freezable + { + /// + /// Throws an if + /// is frozen. + /// + /// + /// This is a convenience methods that freezable types can call before all + /// mutations, to protect frozen objects. + /// + public static void CheckMutable(this IFreezable target) + { + if (target.IsFrozen) + { + throw new InvalidOperationException("Attempt to mutate frozen object"); + } + } + } +} diff --git a/csharp/src/Google.Protobuf/Google.Protobuf.csproj b/csharp/src/Google.Protobuf/Google.Protobuf.csproj new file mode 100644 index 00000000..431668fe --- /dev/null +++ b/csharp/src/Google.Protobuf/Google.Protobuf.csproj @@ -0,0 +1,122 @@ + + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {6908BDCE-D925-43F3-94AC-A531E6DF2591} + Library + Properties + Google.Protobuf + Google.Protobuf + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Profile92 + v4.0 + 512 + true + ..\..\keys\Google.Protobuf.snk + 3.5 + 10.0 + + + true + full + false + bin\Debug + obj\Debug\ + bin\Debug\Google.Protobuf.xml + 1591, 1570, 1571, 1572, 1573, 1574 + DEBUG;TRACE;$(EnvironmentFlavor);$(EnvironmentTemplate) + prompt + 4 + true + Off + + + pdbonly + true + bin\Release + obj\Release\ + $(OutputPath)\$(AssemblyName).xml + 1591, 1570, 1571, 1572, 1573, 1574 + TRACE;$(EnvironmentFlavor);$(EnvironmentTemplate) + prompt + 4 + true + Off + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/csharp/src/Google.Protobuf/Google.Protobuf.nuspec b/csharp/src/Google.Protobuf/Google.Protobuf.nuspec new file mode 100644 index 00000000..9b5e1c83 --- /dev/null +++ b/csharp/src/Google.Protobuf/Google.Protobuf.nuspec @@ -0,0 +1,24 @@ + + + + Google.Protobuf + Google Protocol Buffers C# + C# runtime library for Protocol Buffers - Google's data interchange format. + See project site for more info. + 3.0.0-beta* + Google Inc. + protobuf-packages + https://github.com/google/protobuf/blob/master/LICENSE + https://github.com/google/protobuf + false + Experimental version of C# Protocol Buffers + Copyright 2015, Google Inc. + Protocol Buffers Binary Serialization Format Google proto proto3 + + + + + + + + diff --git a/csharp/src/Google.Protobuf/IMessage.cs b/csharp/src/Google.Protobuf/IMessage.cs new file mode 100644 index 00000000..8c4a4aaf --- /dev/null +++ b/csharp/src/Google.Protobuf/IMessage.cs @@ -0,0 +1,144 @@ +#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; +using Google.Protobuf.Reflection; + +namespace Google.Protobuf +{ + + // TODO(jonskeet): Do we want a "weak" (non-generic) version of IReflectedMessage? + // TODO(jonskeet): Split these interfaces into separate files when we're happy with them. + + /// + /// Reflection support for accessing field values. + /// + public interface IReflectedMessage : IMessage + { + FieldAccessorTable Fields { get; } + // TODO(jonskeet): Descriptor? Or a single property which has "all you need for reflection"? + } + + /// + /// Interface for a Protocol Buffers message, supporting + /// basic operations required for serialization. + /// + public interface IMessage + { + /// + /// Merges the data from the specified coded input stream with the current message. + /// + /// See the user guide for precise merge semantics. + /// + void MergeFrom(CodedInputStream input); + + /// + /// Writes the data to the given coded output stream. + /// + /// Coded output stream to write the data to. Must not be null. + void WriteTo(CodedOutputStream output); + + /// + /// Calculates the size of this message in Protocol Buffer wire format, in bytes. + /// + /// The number of bytes required to write this message + /// to a coded output stream. + int CalculateSize(); + } + + /// + /// Generic interface for a Protocol Buffers message, + /// where the type parameter is expected to be the same type as + /// the implementation class. + /// + /// The message type. + public interface IMessage : IReflectedMessage, IEquatable, IDeepCloneable, IFreezable where T : IMessage + { + /// + /// Merges the given message into this one. + /// + /// See the user guide for precise merge semantics. + /// The message to merge with this one. Must not be null. + void MergeFrom(T message); + } + + /// + /// Generic interface for a deeply cloneable type. + /// + /// + /// All generated messages implement this interface, but so do some non-message types. + /// Additionally, due to the type constraint on T in , + /// it is simpler to keep this as a separate interface. + /// + /// + /// Freezable types which implement this interface should always return a mutable clone, + /// even if the original object is frozen. + /// + /// + /// The type itself, returned by the method. + public interface IDeepCloneable + { + /// + /// Creates a deep clone of this object. + /// + /// A deep clone of this object. + T Clone(); + } + + /// + /// Provides a mechanism for freezing a message (or repeated field collection) + /// to make it immutable. + /// + /// + /// Implementations are under no obligation to make this thread-safe: if a freezable + /// type instance is shared between threads before being frozen, and one thread then + /// freezes it, it is possible for other threads to make changes during the freezing + /// operation and also to observe stale values for mutated fields. Objects should be + /// frozen before being made available to other threads. + /// + public interface IFreezable + { + /// + /// Freezes this object. + /// + /// + /// If the object is already frozen, this method has no effect. + /// + void Freeze(); + + /// + /// Returns whether or not this object is frozen (and therefore immutable). + /// + /// true if this object is frozen; false otherwise. + bool IsFrozen { get; } + } +} diff --git a/csharp/src/Google.Protobuf/InvalidProtocolBufferException.cs b/csharp/src/Google.Protobuf/InvalidProtocolBufferException.cs new file mode 100644 index 00000000..4f89347d --- /dev/null +++ b/csharp/src/Google.Protobuf/InvalidProtocolBufferException.cs @@ -0,0 +1,102 @@ +#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; + +namespace Google.Protobuf +{ + /// + /// Thrown when a protocol message being parsed is invalid in some way, + /// e.g. it contains a malformed varint or a negative byte length. + /// + public sealed class InvalidProtocolBufferException : IOException + { + internal InvalidProtocolBufferException(string message) + : base(message) + { + } + + public static InvalidProtocolBufferException TruncatedMessage() + { + return new InvalidProtocolBufferException( + "While parsing a protocol message, the input ended unexpectedly " + + "in the middle of a field. This could mean either than the " + + "input has been truncated or that an embedded message " + + "misreported its own length."); + } + + internal static InvalidProtocolBufferException NegativeSize() + { + return new InvalidProtocolBufferException( + "CodedInputStream encountered an embedded string or message " + + "which claimed to have negative size."); + } + + public static InvalidProtocolBufferException MalformedVarint() + { + return new InvalidProtocolBufferException( + "CodedInputStream encountered a malformed varint."); + } + + public static InvalidProtocolBufferException InvalidTag() + { + return new InvalidProtocolBufferException( + "Protocol message contained an invalid tag (zero)."); + } + + internal static InvalidProtocolBufferException InvalidEndTag() + { + return new InvalidProtocolBufferException( + "Protocol message end-group tag did not match expected tag."); + } + + internal static InvalidProtocolBufferException RecursionLimitExceeded() + { + return new InvalidProtocolBufferException( + "Protocol message had too many levels of nesting. May be malicious. " + + "Use CodedInputStream.SetRecursionLimit() to increase the depth limit."); + } + + internal static InvalidProtocolBufferException SizeLimitExceeded() + { + return new InvalidProtocolBufferException( + "Protocol message was too large. May be malicious. " + + "Use CodedInputStream.SetSizeLimit() to increase the size limit."); + } + + internal static InvalidProtocolBufferException InvalidMessageStreamTag() + { + return new InvalidProtocolBufferException( + "Stream of protocol messages had invalid tag. Expected tag is length-delimited field 1."); + } + } +} \ No newline at end of file diff --git a/csharp/src/Google.Protobuf/JsonFormatter.cs b/csharp/src/Google.Protobuf/JsonFormatter.cs new file mode 100644 index 00000000..dacc7221 --- /dev/null +++ b/csharp/src/Google.Protobuf/JsonFormatter.cs @@ -0,0 +1,578 @@ +#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 System; +using System.Collections; +using System.Globalization; +using System.Text; +using Google.Protobuf.Reflection; + +namespace Google.Protobuf +{ + /// + /// Reflection-based converter from messages to JSON. + /// + /// + /// + /// Instances of this class are thread-safe, with no mutable state. + /// + /// + /// This is a simple start to get JSON formatting working. As it's reflection-based, + /// it's not as quick as baking calls into generated messages - but is a simpler implementation. + /// (This code is generally not heavily optimized.) + /// + /// + public sealed class JsonFormatter + { + private static JsonFormatter defaultInstance = new JsonFormatter(Settings.Default); + + /// + /// Returns a formatter using the default settings. + /// + public static JsonFormatter Default { get { return defaultInstance; } } + + /// + /// The JSON representation of the first 160 characters of Unicode. + /// Empty strings are replaced by the static constructor. + /// + private static readonly string[] CommonRepresentations = { + // C0 (ASCII and derivatives) control characters + "\\u0000", "\\u0001", "\\u0002", "\\u0003", // 0x00 + "\\u0004", "\\u0005", "\\u0006", "\\u0007", + "\\b", "\\t", "\\n", "\\u000b", + "\\f", "\\r", "\\u000e", "\\u000f", + "\\u0010", "\\u0011", "\\u0012", "\\u0013", // 0x10 + "\\u0014", "\\u0015", "\\u0016", "\\u0017", + "\\u0018", "\\u0019", "\\u001a", "\\u001b", + "\\u001c", "\\u001d", "\\u001e", "\\u001f", + // Escaping of " and \ are required by www.json.org string definition. + // Escaping of < and > are required for HTML security. + "", "", "\\\"", "", "", "", "", "", // 0x20 + "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", // 0x30 + "", "", "", "", "\\u003c", "", "\\u003e", "", + "", "", "", "", "", "", "", "", // 0x40 + "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", // 0x50 + "", "", "", "", "\\\\", "", "", "", + "", "", "", "", "", "", "", "", // 0x60 + "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", // 0x70 + "", "", "", "", "", "", "", "\\u007f", + // C1 (ISO 8859 and Unicode) extended control characters + "\\u0080", "\\u0081", "\\u0082", "\\u0083", // 0x80 + "\\u0084", "\\u0085", "\\u0086", "\\u0087", + "\\u0088", "\\u0089", "\\u008a", "\\u008b", + "\\u008c", "\\u008d", "\\u008e", "\\u008f", + "\\u0090", "\\u0091", "\\u0092", "\\u0093", // 0x90 + "\\u0094", "\\u0095", "\\u0096", "\\u0097", + "\\u0098", "\\u0099", "\\u009a", "\\u009b", + "\\u009c", "\\u009d", "\\u009e", "\\u009f" + }; + + static JsonFormatter() + { + for (int i = 0; i < CommonRepresentations.Length; i++) + { + if (CommonRepresentations[i] == "") + { + CommonRepresentations[i] = ((char) i).ToString(); + } + } + } + + private readonly Settings settings; + + public JsonFormatter(Settings settings) + { + this.settings = settings; + } + + public string Format(IReflectedMessage message) + { + ThrowHelper.ThrowIfNull(message, "message"); + StringBuilder builder = new StringBuilder(); + WriteMessage(builder, message); + return builder.ToString(); + } + + private void WriteMessage(StringBuilder builder, IReflectedMessage message) + { + if (message == null) + { + WriteNull(builder); + return; + } + builder.Append("{ "); + var fields = message.Fields; + bool first = true; + // First non-oneof fields + foreach (var accessor in fields.Accessors) + { + var descriptor = accessor.Descriptor; + // Oneofs are written later + // TODO: Change to write out fields in order, interleaving oneofs appropriately (as per binary format) + if (descriptor.ContainingOneof != null) + { + continue; + } + // Omit default values unless we're asked to format them + object value = accessor.GetValue(message); + if (!settings.FormatDefaultValues && IsDefaultValue(accessor, value)) + { + continue; + } + // Omit awkward (single) values such as unknown enum values + if (!descriptor.IsRepeated && !descriptor.IsMap && !CanWriteSingleValue(accessor.Descriptor, value)) + { + continue; + } + + // Okay, all tests complete: let's write the field value... + if (!first) + { + builder.Append(", "); + } + WriteString(builder, ToCamelCase(accessor.Descriptor.Name)); + builder.Append(": "); + WriteValue(builder, accessor, value); + first = false; + } + + // Now oneofs + foreach (var accessor in fields.Oneofs) + { + var fieldDescriptor = accessor.GetCaseFieldDescriptor(message); + if (fieldDescriptor == null) + { + continue; + } + var fieldAccessor = fields[fieldDescriptor.FieldNumber]; + object value = fieldAccessor.GetValue(message); + // Omit awkward (single) values such as unknown enum values + if (!fieldDescriptor.IsRepeated && !fieldDescriptor.IsMap && !CanWriteSingleValue(fieldDescriptor, value)) + { + continue; + } + + if (!first) + { + builder.Append(", "); + } + WriteString(builder, ToCamelCase(fieldDescriptor.Name)); + builder.Append(": "); + WriteValue(builder, fieldAccessor, value); + first = false; + } + builder.Append(first ? "}" : " }"); + } + + // Converted from src/google/protobuf/util/internal/utility.cc ToCamelCase + internal static string ToCamelCase(string input) + { + bool capitalizeNext = false; + bool wasCap = true; + bool isCap = false; + bool firstWord = true; + StringBuilder result = new StringBuilder(input.Length); + + for (int i = 0; i < input.Length; i++, wasCap = isCap) + { + isCap = char.IsUpper(input[i]); + if (input[i] == '_') + { + capitalizeNext = true; + if (result.Length != 0) + { + firstWord = false; + } + continue; + } + else if (firstWord) + { + // Consider when the current character B is capitalized, + // first word ends when: + // 1) following a lowercase: "...aB..." + // 2) followed by a lowercase: "...ABc..." + if (result.Length != 0 && isCap && + (!wasCap || (i + 1 < input.Length && char.IsLower(input[i + 1])))) + { + firstWord = false; + } + else + { + result.Append(char.ToLowerInvariant(input[i])); + continue; + } + } + else if (capitalizeNext) + { + capitalizeNext = false; + if (char.IsLower(input[i])) + { + result.Append(char.ToUpperInvariant(input[i])); + continue; + } + } + result.Append(input[i]); + } + return result.ToString(); + } + + private static void WriteNull(StringBuilder builder) + { + builder.Append("null"); + } + + private static bool IsDefaultValue(IFieldAccessor accessor, object value) + { + if (accessor.Descriptor.IsMap) + { + IDictionary dictionary = (IDictionary) value; + return dictionary.Count == 0; + } + if (accessor.Descriptor.IsRepeated) + { + IList list = (IList) value; + return list.Count == 0; + } + switch (accessor.Descriptor.FieldType) + { + case FieldType.Bool: + return (bool) value == false; + case FieldType.Bytes: + return (ByteString) value == ByteString.Empty; + case FieldType.String: + return (string) value == ""; + case FieldType.Double: + return (double) value == 0.0; + case FieldType.SInt32: + case FieldType.Int32: + case FieldType.SFixed32: + case FieldType.Enum: + return (int) value == 0; + case FieldType.Fixed32: + case FieldType.UInt32: + return (uint) value == 0; + case FieldType.Fixed64: + case FieldType.UInt64: + return (ulong) value == 0; + case FieldType.SFixed64: + case FieldType.Int64: + case FieldType.SInt64: + return (long) value == 0; + case FieldType.Float: + return (float) value == 0f; + case FieldType.Message: + case FieldType.Group: // Never expect to get this, but... + return value == null; + default: + throw new ArgumentException("Invalid field type"); + } + } + + private void WriteValue(StringBuilder builder, IFieldAccessor accessor, object value) + { + if (accessor.Descriptor.IsMap) + { + WriteDictionary(builder, accessor, (IDictionary) value); + } + else if (accessor.Descriptor.IsRepeated) + { + WriteList(builder, accessor, (IList) value); + } + else + { + WriteSingleValue(builder, accessor.Descriptor, value); + } + } + + private void WriteSingleValue(StringBuilder builder, FieldDescriptor descriptor, object value) + { + switch (descriptor.FieldType) + { + case FieldType.Bool: + builder.Append((bool) value ? "true" : "false"); + break; + case FieldType.Bytes: + // Nothing in Base64 needs escaping + builder.Append('"'); + builder.Append(((ByteString) value).ToBase64()); + builder.Append('"'); + break; + case FieldType.String: + WriteString(builder, (string) value); + break; + case FieldType.Fixed32: + case FieldType.UInt32: + case FieldType.SInt32: + case FieldType.Int32: + case FieldType.SFixed32: + { + IFormattable formattable = (IFormattable) value; + builder.Append(formattable.ToString("d", CultureInfo.InvariantCulture)); + break; + } + case FieldType.Enum: + EnumValueDescriptor enumValue = descriptor.EnumType.FindValueByNumber((int) value); + // We will already have validated that this is a known value. + WriteString(builder, enumValue.Name); + break; + case FieldType.Fixed64: + case FieldType.UInt64: + case FieldType.SFixed64: + case FieldType.Int64: + case FieldType.SInt64: + { + builder.Append('"'); + IFormattable formattable = (IFormattable) value; + builder.Append(formattable.ToString("d", CultureInfo.InvariantCulture)); + builder.Append('"'); + break; + } + case FieldType.Double: + case FieldType.Float: + string text = ((IFormattable) value).ToString("r", CultureInfo.InvariantCulture); + if (text == "NaN" || text == "Infinity" || text == "-Infinity") + { + builder.Append('"'); + builder.Append(text); + builder.Append('"'); + } + else + { + builder.Append(text); + } + break; + case FieldType.Message: + case FieldType.Group: // Never expect to get this, but... + WriteMessage(builder, (IReflectedMessage) value); + break; + default: + throw new ArgumentException("Invalid field type: " + descriptor.FieldType); + } + } + + private void WriteList(StringBuilder builder, IFieldAccessor accessor, IList list) + { + builder.Append("[ "); + bool first = true; + foreach (var value in list) + { + if (!CanWriteSingleValue(accessor.Descriptor, value)) + { + continue; + } + if (!first) + { + builder.Append(", "); + } + WriteSingleValue(builder, accessor.Descriptor, value); + first = false; + } + builder.Append(first ? "]" : " ]"); + } + + private void WriteDictionary(StringBuilder builder, IFieldAccessor accessor, IDictionary dictionary) + { + builder.Append("{ "); + bool first = true; + FieldDescriptor keyType = accessor.Descriptor.MessageType.FindFieldByNumber(1); + FieldDescriptor valueType = accessor.Descriptor.MessageType.FindFieldByNumber(2); + // This will box each pair. Could use IDictionaryEnumerator, but that's ugly in terms of disposal. + foreach (DictionaryEntry pair in dictionary) + { + if (!CanWriteSingleValue(valueType, pair.Value)) + { + continue; + } + if (!first) + { + builder.Append(", "); + } + string keyText; + switch (keyType.FieldType) + { + case FieldType.String: + keyText = (string) pair.Key; + break; + case FieldType.Bool: + keyText = (bool) pair.Key ? "true" : "false"; + break; + case FieldType.Fixed32: + case FieldType.Fixed64: + case FieldType.SFixed32: + case FieldType.SFixed64: + case FieldType.Int32: + case FieldType.Int64: + case FieldType.SInt32: + case FieldType.SInt64: + case FieldType.UInt32: + case FieldType.UInt64: + keyText = ((IFormattable) pair.Key).ToString("d", CultureInfo.InvariantCulture); + break; + default: + throw new ArgumentException("Invalid key type: " + keyType.FieldType); + } + WriteString(builder, keyText); + builder.Append(": "); + WriteSingleValue(builder, valueType, pair.Value); + first = false; + } + builder.Append(first ? "}" : " }"); + } + + /// + /// Returns whether or not a singular value can be represented in JSON. + /// Currently only relevant for enums, where unknown values can't be represented. + /// For repeated/map fields, this always returns true. + /// + private bool CanWriteSingleValue(FieldDescriptor descriptor, object value) + { + if (descriptor.FieldType == FieldType.Enum) + { + EnumValueDescriptor enumValue = descriptor.EnumType.FindValueByNumber((int) value); + return enumValue != null; + } + return true; + } + + /// + /// Writes a string (including leading and trailing double quotes) to a builder, escaping as required. + /// + /// + /// Other than surrogate pair handling, this code is mostly taken from src/google/protobuf/util/internal/json_escaping.cc. + /// + private void WriteString(StringBuilder builder, string text) + { + builder.Append('"'); + for (int i = 0; i < text.Length; i++) + { + char c = text[i]; + if (c < 0xa0) + { + builder.Append(CommonRepresentations[c]); + continue; + } + if (char.IsHighSurrogate(c)) + { + // Encountered first part of a surrogate pair. + // Check that we have the whole pair, and encode both parts as hex. + i++; + if (i == text.Length || !char.IsLowSurrogate(text[i])) + { + throw new ArgumentException("String contains low surrogate not followed by high surrogate"); + } + HexEncodeUtf16CodeUnit(builder, c); + HexEncodeUtf16CodeUnit(builder, text[i]); + continue; + } + else if (char.IsLowSurrogate(c)) + { + throw new ArgumentException("String contains high surrogate not preceded by low surrogate"); + } + switch ((uint) c) + { + // These are not required by json spec + // but used to prevent security bugs in javascript. + case 0xfeff: // Zero width no-break space + case 0xfff9: // Interlinear annotation anchor + case 0xfffa: // Interlinear annotation separator + case 0xfffb: // Interlinear annotation terminator + + case 0x00ad: // Soft-hyphen + case 0x06dd: // Arabic end of ayah + case 0x070f: // Syriac abbreviation mark + case 0x17b4: // Khmer vowel inherent Aq + case 0x17b5: // Khmer vowel inherent Aa + HexEncodeUtf16CodeUnit(builder, c); + break; + + default: + if ((c >= 0x0600 && c <= 0x0603) || // Arabic signs + (c >= 0x200b && c <= 0x200f) || // Zero width etc. + (c >= 0x2028 && c <= 0x202e) || // Separators etc. + (c >= 0x2060 && c <= 0x2064) || // Invisible etc. + (c >= 0x206a && c <= 0x206f)) + { + HexEncodeUtf16CodeUnit(builder, c); + } + else + { + // No handling of surrogates here - that's done earlier + builder.Append(c); + } + break; + } + } + builder.Append('"'); + } + + private const string Hex = "0123456789abcdef"; + private static void HexEncodeUtf16CodeUnit(StringBuilder builder, char c) + { + uint utf16 = c; + builder.Append("\\u"); + builder.Append(Hex[(c >> 12) & 0xf]); + builder.Append(Hex[(c >> 8) & 0xf]); + builder.Append(Hex[(c >> 4) & 0xf]); + builder.Append(Hex[(c >> 0) & 0xf]); + } + + /// + /// Settings controlling JSON formatting. + /// + public sealed class Settings + { + private static readonly Settings defaultInstance = new Settings(false); + + /// + /// Default settings, as used by + /// + public static Settings Default { get { return defaultInstance; } } + + private readonly bool formatDefaultValues; + + + /// + /// Whether fields whose values are the default for the field type (e.g. 0 for integers) + /// should be formatted (true) or omitted (false). + /// + public bool FormatDefaultValues { get { return formatDefaultValues; } } + + public Settings(bool formatDefaultValues) + { + this.formatDefaultValues = formatDefaultValues; + } + } + } +} diff --git a/csharp/src/Google.Protobuf/LimitedInputStream.cs b/csharp/src/Google.Protobuf/LimitedInputStream.cs new file mode 100644 index 00000000..f11d19d9 --- /dev/null +++ b/csharp/src/Google.Protobuf/LimitedInputStream.cs @@ -0,0 +1,110 @@ +#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 System; +using System.IO; + +namespace Google.Protobuf +{ + /// + /// Stream implementation which proxies another stream, only allowing a certain amount + /// of data to be read. Note that this is only used to read delimited streams, so it + /// doesn't attempt to implement everything. + /// + internal sealed class LimitedInputStream : Stream + { + private readonly Stream proxied; + private int bytesLeft; + + internal LimitedInputStream(Stream proxied, int size) + { + this.proxied = proxied; + bytesLeft = size; + } + + public override bool CanRead + { + get { return true; } + } + + public override bool CanSeek + { + get { return false; } + } + + public override bool CanWrite + { + get { return false; } + } + + public override void Flush() + { + } + + public override long Length + { + get { throw new NotSupportedException(); } + } + + public override long Position + { + get { throw new NotSupportedException(); } + set { throw new NotSupportedException(); } + } + + public override int Read(byte[] buffer, int offset, int count) + { + if (bytesLeft > 0) + { + int bytesRead = proxied.Read(buffer, offset, Math.Min(bytesLeft, count)); + bytesLeft -= bytesRead; + return bytesRead; + } + return 0; + } + + public override long Seek(long offset, SeekOrigin origin) + { + throw new NotSupportedException(); + } + + public override void SetLength(long value) + { + throw new NotSupportedException(); + } + + public override void Write(byte[] buffer, int offset, int count) + { + throw new NotSupportedException(); + } + } +} diff --git a/csharp/src/Google.Protobuf/MessageExtensions.cs b/csharp/src/Google.Protobuf/MessageExtensions.cs new file mode 100644 index 00000000..ee2863d1 --- /dev/null +++ b/csharp/src/Google.Protobuf/MessageExtensions.cs @@ -0,0 +1,113 @@ +#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 System.IO; + +namespace Google.Protobuf +{ + /// + /// Extension methods on and . + /// + public static class MessageExtensions + { + public static void MergeFrom(this IMessage message, byte[] data) + { + ThrowHelper.ThrowIfNull(message, "message"); + ThrowHelper.ThrowIfNull(data, "data"); + CodedInputStream input = CodedInputStream.CreateInstance(data); + message.MergeFrom(input); + input.CheckLastTagWas(0); + } + + public static void MergeFrom(this IMessage message, ByteString data) + { + ThrowHelper.ThrowIfNull(message, "message"); + ThrowHelper.ThrowIfNull(data, "data"); + CodedInputStream input = data.CreateCodedInput(); + message.MergeFrom(input); + input.CheckLastTagWas(0); + } + + public static void MergeFrom(this IMessage message, Stream input) + { + ThrowHelper.ThrowIfNull(message, "message"); + ThrowHelper.ThrowIfNull(input, "input"); + CodedInputStream codedInput = CodedInputStream.CreateInstance(input); + message.MergeFrom(codedInput); + codedInput.CheckLastTagWas(0); + } + + public static void MergeDelimitedFrom(this IMessage message, Stream input) + { + ThrowHelper.ThrowIfNull(message, "message"); + ThrowHelper.ThrowIfNull(input, "input"); + int size = (int) CodedInputStream.ReadRawVarint32(input); + Stream limitedStream = new LimitedInputStream(input, size); + message.MergeFrom(limitedStream); + } + + public static byte[] ToByteArray(this IMessage message) + { + ThrowHelper.ThrowIfNull(message, "message"); + byte[] result = new byte[message.CalculateSize()]; + CodedOutputStream output = CodedOutputStream.CreateInstance(result); + message.WriteTo(output); + output.CheckNoSpaceLeft(); + return result; + } + + public static void WriteTo(this IMessage message, Stream output) + { + ThrowHelper.ThrowIfNull(message, "message"); + ThrowHelper.ThrowIfNull(output, "output"); + CodedOutputStream codedOutput = CodedOutputStream.CreateInstance(output); + message.WriteTo(codedOutput); + codedOutput.Flush(); + } + + public static void WriteDelimitedTo(this IMessage message, Stream output) + { + ThrowHelper.ThrowIfNull(message, "message"); + ThrowHelper.ThrowIfNull(output, "output"); + CodedOutputStream codedOutput = CodedOutputStream.CreateInstance(output); + codedOutput.WriteRawVarint32((uint)message.CalculateSize()); + message.WriteTo(codedOutput); + codedOutput.Flush(); + } + + public static ByteString ToByteString(this IMessage message) + { + ThrowHelper.ThrowIfNull(message, "message"); + return ByteString.AttachBytes(message.ToByteArray()); + } + } +} diff --git a/csharp/src/Google.Protobuf/MessageParser.cs b/csharp/src/Google.Protobuf/MessageParser.cs new file mode 100644 index 00000000..5407de06 --- /dev/null +++ b/csharp/src/Google.Protobuf/MessageParser.cs @@ -0,0 +1,122 @@ +#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 System; +using System.IO; + +namespace Google.Protobuf +{ + /// + /// A parser for a specific message type. + /// + /// + ///

+ /// This delegates most behavior to the + /// implementation within the original type, but + /// provides convenient overloads to parse from a variety of sources. + ///

+ ///

+ /// Most applications will never need to create their own instances of this type; + /// instead, use the static Parser property of a generated message type to obtain a + /// parser for that type. + ///

+ ///
+ /// The type of message to be parsed. + public sealed class MessageParser where T : IMessage + { + private readonly Func factory; + + /// + /// Creates a new parser. + /// + /// + /// The factory method is effectively an optimization over using a generic constraint + /// to require a parameterless constructor: delegates are significantly faster to execute. + /// + /// Function to invoke when a new, empty message is required. + public MessageParser(Func factory) + { + this.factory = factory; + } + + /// + /// Creates a template instance ready for population. + /// + /// An empty message. + internal T CreateTemplate() + { + return factory(); + } + + /// + /// Parses a message from a byte array. + /// + /// The byte array containing the message. Must not be null. + /// The newly parsed message. + public T ParseFrom(byte[] data) + { + ThrowHelper.ThrowIfNull(data, "data"); + T message = factory(); + message.MergeFrom(data); + return message; + } + + public T ParseFrom(ByteString data) + { + ThrowHelper.ThrowIfNull(data, "data"); + T message = factory(); + message.MergeFrom(data); + return message; + } + + public T ParseFrom(Stream input) + { + T message = factory(); + message.MergeFrom(input); + return message; + } + + public T ParseDelimitedFrom(Stream input) + { + T message = factory(); + message.MergeDelimitedFrom(input); + return message; + } + + public T ParseFrom(CodedInputStream input) + { + T message = factory(); + message.MergeFrom(input); + return message; + } + } +} diff --git a/csharp/src/Google.Protobuf/Properties/AssemblyInfo.cs b/csharp/src/Google.Protobuf/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..a957e8b3 --- /dev/null +++ b/csharp/src/Google.Protobuf/Properties/AssemblyInfo.cs @@ -0,0 +1,72 @@ +#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.Reflection; +using System.Runtime.CompilerServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. + +[assembly: AssemblyTitle("Google.Protobuf")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Google.Protobuf")] +[assembly: AssemblyCopyright("Copyright © 2008")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("2.4.1.555")] + +[assembly: AssemblyVersion("2.4.1.555")] + +[assembly: InternalsVisibleTo("Google.Protobuf.Test, PublicKey=" + + "00240000048000009400000006020000002400005253413100040000110000003b4611704c5379" + + "39c3e0fbe9447dd6fa5462507f9dd4fd9fbf0712457e415b037da6d2c4eb5d2c7d29c86380af68" + + "7cf400401bb183f2a70bd3b631c1fcb7db8aa66c766694a9fb53fa765df6303104da8c978f3b6d" + + "53909cd30685b8bc9922c726cd82b5995e9e2cfca6df7a2d189d851492e49f4b76f269ce6dfd08" + + "c34a7d98")] + +#if !NOFILEVERSION +[assembly: AssemblyFileVersion("2.4.1.555")] +#endif + diff --git a/csharp/src/Google.Protobuf/Reflection/DescriptorBase.cs b/csharp/src/Google.Protobuf/Reflection/DescriptorBase.cs new file mode 100644 index 00000000..0300cd58 --- /dev/null +++ b/csharp/src/Google.Protobuf/Reflection/DescriptorBase.cs @@ -0,0 +1,82 @@ +#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.Reflection +{ + /// + /// Base class for nearly all descriptors, providing common functionality. + /// + public abstract class DescriptorBase : IDescriptor + { + private readonly FileDescriptor file; + private readonly string fullName; + private readonly int index; + + internal DescriptorBase(FileDescriptor file, string fullName, int index) + { + this.file = file; + this.fullName = fullName; + this.index = index; + } + + /// + /// The index of this descriptor within its parent descriptor. + /// + /// + /// This returns the index of this descriptor within its parent, for + /// this descriptor's type. (There can be duplicate values for different + /// types, e.g. one enum type with index 0 and one message type with index 0.) + /// + public int Index + { + get { return index; } + } + + public abstract string Name { get; } + + /// + /// The fully qualified name of the descriptor's target. + /// + public string FullName + { + get { return fullName; } + } + + /// + /// The file this descriptor was declared in. + /// + public FileDescriptor File + { + get { return file; } + } + } +} \ No newline at end of file diff --git a/csharp/src/Google.Protobuf/Reflection/DescriptorPool.cs b/csharp/src/Google.Protobuf/Reflection/DescriptorPool.cs new file mode 100644 index 00000000..157ea400 --- /dev/null +++ b/csharp/src/Google.Protobuf/Reflection/DescriptorPool.cs @@ -0,0 +1,365 @@ +#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; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; + +namespace Google.Protobuf.Reflection +{ + /// + /// Contains lookup tables containing all the descriptors defined in a particular file. + /// + internal sealed class DescriptorPool + { + private readonly IDictionary descriptorsByName = + new Dictionary(); + + private readonly IDictionary fieldsByNumber = + new Dictionary(); + + private readonly IDictionary enumValuesByNumber = + new Dictionary(); + + private readonly HashSet dependencies; + + internal DescriptorPool(FileDescriptor[] dependencyFiles) + { + dependencies = new HashSet(); + for (int i = 0; i < dependencyFiles.Length; i++) + { + dependencies.Add(dependencyFiles[i]); + ImportPublicDependencies(dependencyFiles[i]); + } + + foreach (FileDescriptor dependency in dependencyFiles) + { + AddPackage(dependency.Package, dependency); + } + } + + private void ImportPublicDependencies(FileDescriptor file) + { + foreach (FileDescriptor dependency in file.PublicDependencies) + { + if (dependencies.Add(dependency)) + { + ImportPublicDependencies(dependency); + } + } + } + + /// + /// Finds a symbol of the given name within the pool. + /// + /// The type of symbol to look for + /// Fully-qualified name to look up + /// The symbol with the given name and type, + /// or null if the symbol doesn't exist or has the wrong type + internal T FindSymbol(string fullName) where T : class + { + IDescriptor result; + descriptorsByName.TryGetValue(fullName, out result); + T descriptor = result as T; + if (descriptor != null) + { + return descriptor; + } + + foreach (FileDescriptor dependency in dependencies) + { + dependency.DescriptorPool.descriptorsByName.TryGetValue(fullName, out result); + descriptor = result as T; + if (descriptor != null) + { + return descriptor; + } + } + + return null; + } + + /// + /// Adds a package to the symbol tables. If a package by the same name + /// already exists, that is fine, but if some other kind of symbol + /// exists under the same name, an exception is thrown. If the package + /// has multiple components, this also adds the parent package(s). + /// + internal void AddPackage(string fullName, FileDescriptor file) + { + int dotpos = fullName.LastIndexOf('.'); + String name; + if (dotpos != -1) + { + AddPackage(fullName.Substring(0, dotpos), file); + name = fullName.Substring(dotpos + 1); + } + else + { + name = fullName; + } + + IDescriptor old; + if (descriptorsByName.TryGetValue(fullName, out old)) + { + if (!(old is PackageDescriptor)) + { + throw new DescriptorValidationException(file, + "\"" + name + + "\" is already defined (as something other than a " + + "package) in file \"" + old.File.Name + "\"."); + } + } + descriptorsByName[fullName] = new PackageDescriptor(name, fullName, file); + } + + /// + /// Adds a symbol to the symbol table. + /// + /// The symbol already existed + /// in the symbol table. + internal void AddSymbol(IDescriptor descriptor) + { + ValidateSymbolName(descriptor); + String fullName = descriptor.FullName; + + IDescriptor old; + if (descriptorsByName.TryGetValue(fullName, out old)) + { + int dotPos = fullName.LastIndexOf('.'); + string message; + if (descriptor.File == old.File) + { + if (dotPos == -1) + { + message = "\"" + fullName + "\" is already defined."; + } + else + { + message = "\"" + fullName.Substring(dotPos + 1) + "\" is already defined in \"" + + fullName.Substring(0, dotPos) + "\"."; + } + } + else + { + message = "\"" + fullName + "\" is already defined in file \"" + old.File.Name + "\"."; + } + throw new DescriptorValidationException(descriptor, message); + } + descriptorsByName[fullName] = descriptor; + } + + private static readonly Regex ValidationRegex = new Regex("^[_A-Za-z][_A-Za-z0-9]*$", + FrameworkPortability.CompiledRegexWhereAvailable); + + /// + /// Verifies that the descriptor's name is valid (i.e. it contains + /// only letters, digits and underscores, and does not start with a digit). + /// + /// + private static void ValidateSymbolName(IDescriptor descriptor) + { + if (descriptor.Name == "") + { + throw new DescriptorValidationException(descriptor, "Missing name."); + } + if (!ValidationRegex.IsMatch(descriptor.Name)) + { + throw new DescriptorValidationException(descriptor, + "\"" + descriptor.Name + "\" is not a valid identifier."); + } + } + + /// + /// Returns the field with the given number in the given descriptor, + /// or null if it can't be found. + /// + internal FieldDescriptor FindFieldByNumber(MessageDescriptor messageDescriptor, int number) + { + FieldDescriptor ret; + fieldsByNumber.TryGetValue(new DescriptorIntPair(messageDescriptor, number), out ret); + return ret; + } + + internal EnumValueDescriptor FindEnumValueByNumber(EnumDescriptor enumDescriptor, int number) + { + EnumValueDescriptor ret; + enumValuesByNumber.TryGetValue(new DescriptorIntPair(enumDescriptor, number), out ret); + return ret; + } + + /// + /// Adds a field to the fieldsByNumber table. + /// + /// A field with the same + /// containing type and number already exists. + internal void AddFieldByNumber(FieldDescriptor field) + { + DescriptorIntPair key = new DescriptorIntPair(field.ContainingType, field.FieldNumber); + FieldDescriptor old; + if (fieldsByNumber.TryGetValue(key, out old)) + { + throw new DescriptorValidationException(field, "Field number " + field.FieldNumber + + "has already been used in \"" + + field.ContainingType.FullName + + "\" by field \"" + old.Name + "\"."); + } + fieldsByNumber[key] = field; + } + + /// + /// Adds an enum value to the enumValuesByNumber table. If an enum value + /// with the same type and number already exists, this method does nothing. + /// (This is allowed; the first value defined with the number takes precedence.) + /// + internal void AddEnumValueByNumber(EnumValueDescriptor enumValue) + { + DescriptorIntPair key = new DescriptorIntPair(enumValue.EnumDescriptor, enumValue.Number); + if (!enumValuesByNumber.ContainsKey(key)) + { + enumValuesByNumber[key] = enumValue; + } + } + + /// + /// Looks up a descriptor by name, relative to some other descriptor. + /// The name may be fully-qualified (with a leading '.'), partially-qualified, + /// or unqualified. C++-like name lookup semantics are used to search for the + /// matching descriptor. + /// + internal IDescriptor LookupSymbol(string name, IDescriptor relativeTo) + { + // TODO(jonskeet): This could be optimized in a number of ways. + + IDescriptor result; + if (name.StartsWith(".")) + { + // Fully-qualified name. + result = FindSymbol(name.Substring(1)); + } + else + { + // If "name" is a compound identifier, we want to search for the + // first component of it, then search within it for the rest. + int firstPartLength = name.IndexOf('.'); + string firstPart = firstPartLength == -1 ? name : name.Substring(0, firstPartLength); + + // We will search each parent scope of "relativeTo" looking for the + // symbol. + StringBuilder scopeToTry = new StringBuilder(relativeTo.FullName); + + while (true) + { + // Chop off the last component of the scope. + + // TODO(jonskeet): Make this more efficient. May not be worth using StringBuilder at all + int dotpos = scopeToTry.ToString().LastIndexOf("."); + if (dotpos == -1) + { + result = FindSymbol(name); + break; + } + else + { + scopeToTry.Length = dotpos + 1; + + // Append firstPart and try to find. + scopeToTry.Append(firstPart); + result = FindSymbol(scopeToTry.ToString()); + + if (result != null) + { + if (firstPartLength != -1) + { + // We only found the first part of the symbol. Now look for + // the whole thing. If this fails, we *don't* want to keep + // searching parent scopes. + scopeToTry.Length = dotpos + 1; + scopeToTry.Append(name); + result = FindSymbol(scopeToTry.ToString()); + } + break; + } + + // Not found. Remove the name so we can try again. + scopeToTry.Length = dotpos; + } + } + } + + if (result == null) + { + throw new DescriptorValidationException(relativeTo, "\"" + name + "\" is not defined."); + } + else + { + return result; + } + } + + /// + /// Struct used to hold the keys for the fieldByNumber table. + /// + private struct DescriptorIntPair : IEquatable + { + private readonly int number; + private readonly IDescriptor descriptor; + + internal DescriptorIntPair(IDescriptor descriptor, int number) + { + this.number = number; + this.descriptor = descriptor; + } + + public bool Equals(DescriptorIntPair other) + { + return descriptor == other.descriptor + && number == other.number; + } + + public override bool Equals(object obj) + { + if (obj is DescriptorIntPair) + { + return Equals((DescriptorIntPair) obj); + } + return false; + } + + public override int GetHashCode() + { + return descriptor.GetHashCode()*((1 << 16) - 1) + number; + } + } + } +} \ No newline at end of file diff --git a/csharp/src/Google.Protobuf/Reflection/DescriptorProtoFile.cs b/csharp/src/Google.Protobuf/Reflection/DescriptorProtoFile.cs new file mode 100644 index 00000000..c87969b9 --- /dev/null +++ b/csharp/src/Google.Protobuf/Reflection/DescriptorProtoFile.cs @@ -0,0 +1,4943 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/descriptor_proto_file.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Google.Protobuf.Reflection { + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + internal static partial class DescriptorProtoFile { + + #region Static variables + internal static pbr::FieldAccessorTable internal__static_google_protobuf_FileDescriptorSet__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_FileDescriptorProto__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_DescriptorProto__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_DescriptorProto_ExtensionRange__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_DescriptorProto_ReservedRange__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_FieldDescriptorProto__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_OneofDescriptorProto__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_EnumDescriptorProto__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_EnumValueDescriptorProto__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_ServiceDescriptorProto__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_MethodDescriptorProto__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_FileOptions__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_MessageOptions__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_FieldOptions__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_EnumOptions__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_EnumValueOptions__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_ServiceOptions__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_MethodOptions__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_UninterpretedOption__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_UninterpretedOption_NamePart__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_SourceCodeInfo__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_SourceCodeInfo_Location__FieldAccessorTable; + #endregion + #region Descriptor + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static DescriptorProtoFile() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "Citnb29nbGUvcHJvdG9idWYvZGVzY3JpcHRvcl9wcm90b19maWxlLnByb3Rv", + "Eg9nb29nbGUucHJvdG9idWYiRwoRRmlsZURlc2NyaXB0b3JTZXQSMgoEZmls", + "ZRgBIAMoCzIkLmdvb2dsZS5wcm90b2J1Zi5GaWxlRGVzY3JpcHRvclByb3Rv", + "ItsDChNGaWxlRGVzY3JpcHRvclByb3RvEgwKBG5hbWUYASABKAkSDwoHcGFj", + "a2FnZRgCIAEoCRISCgpkZXBlbmRlbmN5GAMgAygJEhkKEXB1YmxpY19kZXBl", + "bmRlbmN5GAogAygFEhcKD3dlYWtfZGVwZW5kZW5jeRgLIAMoBRI2CgxtZXNz", + "YWdlX3R5cGUYBCADKAsyIC5nb29nbGUucHJvdG9idWYuRGVzY3JpcHRvclBy", + "b3RvEjcKCWVudW1fdHlwZRgFIAMoCzIkLmdvb2dsZS5wcm90b2J1Zi5FbnVt", + "RGVzY3JpcHRvclByb3RvEjgKB3NlcnZpY2UYBiADKAsyJy5nb29nbGUucHJv", + "dG9idWYuU2VydmljZURlc2NyaXB0b3JQcm90bxI4CglleHRlbnNpb24YByAD", + "KAsyJS5nb29nbGUucHJvdG9idWYuRmllbGREZXNjcmlwdG9yUHJvdG8SLQoH", + "b3B0aW9ucxgIIAEoCzIcLmdvb2dsZS5wcm90b2J1Zi5GaWxlT3B0aW9ucxI5", + "ChBzb3VyY2VfY29kZV9pbmZvGAkgASgLMh8uZ29vZ2xlLnByb3RvYnVmLlNv", + "dXJjZUNvZGVJbmZvEg4KBnN5bnRheBgMIAEoCSLwBAoPRGVzY3JpcHRvclBy", + "b3RvEgwKBG5hbWUYASABKAkSNAoFZmllbGQYAiADKAsyJS5nb29nbGUucHJv", + "dG9idWYuRmllbGREZXNjcmlwdG9yUHJvdG8SOAoJZXh0ZW5zaW9uGAYgAygL", + "MiUuZ29vZ2xlLnByb3RvYnVmLkZpZWxkRGVzY3JpcHRvclByb3RvEjUKC25l", + "c3RlZF90eXBlGAMgAygLMiAuZ29vZ2xlLnByb3RvYnVmLkRlc2NyaXB0b3JQ", + "cm90bxI3CgllbnVtX3R5cGUYBCADKAsyJC5nb29nbGUucHJvdG9idWYuRW51", + "bURlc2NyaXB0b3JQcm90bxJICg9leHRlbnNpb25fcmFuZ2UYBSADKAsyLy5n", + "b29nbGUucHJvdG9idWYuRGVzY3JpcHRvclByb3RvLkV4dGVuc2lvblJhbmdl", + "EjkKCm9uZW9mX2RlY2wYCCADKAsyJS5nb29nbGUucHJvdG9idWYuT25lb2ZE", + "ZXNjcmlwdG9yUHJvdG8SMAoHb3B0aW9ucxgHIAEoCzIfLmdvb2dsZS5wcm90", + "b2J1Zi5NZXNzYWdlT3B0aW9ucxJGCg5yZXNlcnZlZF9yYW5nZRgJIAMoCzIu", + "Lmdvb2dsZS5wcm90b2J1Zi5EZXNjcmlwdG9yUHJvdG8uUmVzZXJ2ZWRSYW5n", + "ZRIVCg1yZXNlcnZlZF9uYW1lGAogAygJGiwKDkV4dGVuc2lvblJhbmdlEg0K", + "BXN0YXJ0GAEgASgFEgsKA2VuZBgCIAEoBRorCg1SZXNlcnZlZFJhbmdlEg0K", + "BXN0YXJ0GAEgASgFEgsKA2VuZBgCIAEoBSKpBQoURmllbGREZXNjcmlwdG9y", + "UHJvdG8SDAoEbmFtZRgBIAEoCRIOCgZudW1iZXIYAyABKAUSOgoFbGFiZWwY", + "BCABKA4yKy5nb29nbGUucHJvdG9idWYuRmllbGREZXNjcmlwdG9yUHJvdG8u", + "TGFiZWwSOAoEdHlwZRgFIAEoDjIqLmdvb2dsZS5wcm90b2J1Zi5GaWVsZERl", + "c2NyaXB0b3JQcm90by5UeXBlEhEKCXR5cGVfbmFtZRgGIAEoCRIQCghleHRl", + "bmRlZRgCIAEoCRIVCg1kZWZhdWx0X3ZhbHVlGAcgASgJEhMKC29uZW9mX2lu", + "ZGV4GAkgASgFEi4KB29wdGlvbnMYCCABKAsyHS5nb29nbGUucHJvdG9idWYu", + "RmllbGRPcHRpb25zIrYCCgRUeXBlEg8KC1RZUEVfRE9VQkxFEAESDgoKVFlQ", + "RV9GTE9BVBACEg4KClRZUEVfSU5UNjQQAxIPCgtUWVBFX1VJTlQ2NBAEEg4K", + "ClRZUEVfSU5UMzIQBRIQCgxUWVBFX0ZJWEVENjQQBhIQCgxUWVBFX0ZJWEVE", + "MzIQBxINCglUWVBFX0JPT0wQCBIPCgtUWVBFX1NUUklORxAJEg4KClRZUEVf", + "R1JPVVAQChIQCgxUWVBFX01FU1NBR0UQCxIOCgpUWVBFX0JZVEVTEAwSDwoL", + "VFlQRV9VSU5UMzIQDRINCglUWVBFX0VOVU0QDhIRCg1UWVBFX1NGSVhFRDMy", + "EA8SEQoNVFlQRV9TRklYRUQ2NBAQEg8KC1RZUEVfU0lOVDMyEBESDwoLVFlQ", + "RV9TSU5UNjQQEiJDCgVMYWJlbBISCg5MQUJFTF9PUFRJT05BTBABEhIKDkxB", + "QkVMX1JFUVVJUkVEEAISEgoOTEFCRUxfUkVQRUFURUQQAyIkChRPbmVvZkRl", + "c2NyaXB0b3JQcm90bxIMCgRuYW1lGAEgASgJIowBChNFbnVtRGVzY3JpcHRv", + "clByb3RvEgwKBG5hbWUYASABKAkSOAoFdmFsdWUYAiADKAsyKS5nb29nbGUu", + "cHJvdG9idWYuRW51bVZhbHVlRGVzY3JpcHRvclByb3RvEi0KB29wdGlvbnMY", + "AyABKAsyHC5nb29nbGUucHJvdG9idWYuRW51bU9wdGlvbnMibAoYRW51bVZh", + "bHVlRGVzY3JpcHRvclByb3RvEgwKBG5hbWUYASABKAkSDgoGbnVtYmVyGAIg", + "ASgFEjIKB29wdGlvbnMYAyABKAsyIS5nb29nbGUucHJvdG9idWYuRW51bVZh", + "bHVlT3B0aW9ucyKQAQoWU2VydmljZURlc2NyaXB0b3JQcm90bxIMCgRuYW1l", + "GAEgASgJEjYKBm1ldGhvZBgCIAMoCzImLmdvb2dsZS5wcm90b2J1Zi5NZXRo", + "b2REZXNjcmlwdG9yUHJvdG8SMAoHb3B0aW9ucxgDIAEoCzIfLmdvb2dsZS5w", + "cm90b2J1Zi5TZXJ2aWNlT3B0aW9ucyLBAQoVTWV0aG9kRGVzY3JpcHRvclBy", + "b3RvEgwKBG5hbWUYASABKAkSEgoKaW5wdXRfdHlwZRgCIAEoCRITCgtvdXRw", + "dXRfdHlwZRgDIAEoCRIvCgdvcHRpb25zGAQgASgLMh4uZ29vZ2xlLnByb3Rv", + "YnVmLk1ldGhvZE9wdGlvbnMSHwoQY2xpZW50X3N0cmVhbWluZxgFIAEoCDoF", + "ZmFsc2USHwoQc2VydmVyX3N0cmVhbWluZxgGIAEoCDoFZmFsc2UigQUKC0Zp", + "bGVPcHRpb25zEhQKDGphdmFfcGFja2FnZRgBIAEoCRIcChRqYXZhX291dGVy", + "X2NsYXNzbmFtZRgIIAEoCRIiChNqYXZhX211bHRpcGxlX2ZpbGVzGAogASgI", + "OgVmYWxzZRIsCh1qYXZhX2dlbmVyYXRlX2VxdWFsc19hbmRfaGFzaBgUIAEo", + "CDoFZmFsc2USJQoWamF2YV9zdHJpbmdfY2hlY2tfdXRmOBgbIAEoCDoFZmFs", + "c2USRgoMb3B0aW1pemVfZm9yGAkgASgOMikuZ29vZ2xlLnByb3RvYnVmLkZp", + "bGVPcHRpb25zLk9wdGltaXplTW9kZToFU1BFRUQSEgoKZ29fcGFja2FnZRgL", + "IAEoCRIiChNjY19nZW5lcmljX3NlcnZpY2VzGBAgASgIOgVmYWxzZRIkChVq", + "YXZhX2dlbmVyaWNfc2VydmljZXMYESABKAg6BWZhbHNlEiIKE3B5X2dlbmVy", + "aWNfc2VydmljZXMYEiABKAg6BWZhbHNlEhkKCmRlcHJlY2F0ZWQYFyABKAg6", + "BWZhbHNlEh8KEGNjX2VuYWJsZV9hcmVuYXMYHyABKAg6BWZhbHNlEhkKEW9i", + "amNfY2xhc3NfcHJlZml4GCQgASgJEhgKEGNzaGFycF9uYW1lc3BhY2UYJSAB", + "KAkSQwoUdW5pbnRlcnByZXRlZF9vcHRpb24Y5wcgAygLMiQuZ29vZ2xlLnBy", + "b3RvYnVmLlVuaW50ZXJwcmV0ZWRPcHRpb24iOgoMT3B0aW1pemVNb2RlEgkK", + "BVNQRUVEEAESDQoJQ09ERV9TSVpFEAISEAoMTElURV9SVU5USU1FEAMqCQjo", + "BxCAgICAAiLmAQoOTWVzc2FnZU9wdGlvbnMSJgoXbWVzc2FnZV9zZXRfd2ly", + "ZV9mb3JtYXQYASABKAg6BWZhbHNlEi4KH25vX3N0YW5kYXJkX2Rlc2NyaXB0", + "b3JfYWNjZXNzb3IYAiABKAg6BWZhbHNlEhkKCmRlcHJlY2F0ZWQYAyABKAg6", + "BWZhbHNlEhEKCW1hcF9lbnRyeRgHIAEoCBJDChR1bmludGVycHJldGVkX29w", + "dGlvbhjnByADKAsyJC5nb29nbGUucHJvdG9idWYuVW5pbnRlcnByZXRlZE9w", + "dGlvbioJCOgHEICAgIACIpgDCgxGaWVsZE9wdGlvbnMSOgoFY3R5cGUYASAB", + "KA4yIy5nb29nbGUucHJvdG9idWYuRmllbGRPcHRpb25zLkNUeXBlOgZTVFJJ", + "TkcSDgoGcGFja2VkGAIgASgIEj8KBmpzdHlwZRgGIAEoDjIkLmdvb2dsZS5w", + "cm90b2J1Zi5GaWVsZE9wdGlvbnMuSlNUeXBlOglKU19OT1JNQUwSEwoEbGF6", + "eRgFIAEoCDoFZmFsc2USGQoKZGVwcmVjYXRlZBgDIAEoCDoFZmFsc2USEwoE", + "d2VhaxgKIAEoCDoFZmFsc2USQwoUdW5pbnRlcnByZXRlZF9vcHRpb24Y5wcg", + "AygLMiQuZ29vZ2xlLnByb3RvYnVmLlVuaW50ZXJwcmV0ZWRPcHRpb24iLwoF", + "Q1R5cGUSCgoGU1RSSU5HEAASCAoEQ09SRBABEhAKDFNUUklOR19QSUVDRRAC", + "IjUKBkpTVHlwZRINCglKU19OT1JNQUwQABINCglKU19TVFJJTkcQARINCglK", + "U19OVU1CRVIQAioJCOgHEICAgIACIo0BCgtFbnVtT3B0aW9ucxITCgthbGxv", + "d19hbGlhcxgCIAEoCBIZCgpkZXByZWNhdGVkGAMgASgIOgVmYWxzZRJDChR1", + "bmludGVycHJldGVkX29wdGlvbhjnByADKAsyJC5nb29nbGUucHJvdG9idWYu", + "VW5pbnRlcnByZXRlZE9wdGlvbioJCOgHEICAgIACIn0KEEVudW1WYWx1ZU9w", + "dGlvbnMSGQoKZGVwcmVjYXRlZBgBIAEoCDoFZmFsc2USQwoUdW5pbnRlcnBy", + "ZXRlZF9vcHRpb24Y5wcgAygLMiQuZ29vZ2xlLnByb3RvYnVmLlVuaW50ZXJw", + "cmV0ZWRPcHRpb24qCQjoBxCAgICAAiJ7Cg5TZXJ2aWNlT3B0aW9ucxIZCgpk", + "ZXByZWNhdGVkGCEgASgIOgVmYWxzZRJDChR1bmludGVycHJldGVkX29wdGlv", + "bhjnByADKAsyJC5nb29nbGUucHJvdG9idWYuVW5pbnRlcnByZXRlZE9wdGlv", + "bioJCOgHEICAgIACInoKDU1ldGhvZE9wdGlvbnMSGQoKZGVwcmVjYXRlZBgh", + "IAEoCDoFZmFsc2USQwoUdW5pbnRlcnByZXRlZF9vcHRpb24Y5wcgAygLMiQu", + "Z29vZ2xlLnByb3RvYnVmLlVuaW50ZXJwcmV0ZWRPcHRpb24qCQjoBxCAgICA", + "AiKeAgoTVW5pbnRlcnByZXRlZE9wdGlvbhI7CgRuYW1lGAIgAygLMi0uZ29v", + "Z2xlLnByb3RvYnVmLlVuaW50ZXJwcmV0ZWRPcHRpb24uTmFtZVBhcnQSGAoQ", + "aWRlbnRpZmllcl92YWx1ZRgDIAEoCRIaChJwb3NpdGl2ZV9pbnRfdmFsdWUY", + "BCABKAQSGgoSbmVnYXRpdmVfaW50X3ZhbHVlGAUgASgDEhQKDGRvdWJsZV92", + "YWx1ZRgGIAEoARIUCgxzdHJpbmdfdmFsdWUYByABKAwSFwoPYWdncmVnYXRl", + "X3ZhbHVlGAggASgJGjMKCE5hbWVQYXJ0EhEKCW5hbWVfcGFydBgBIAIoCRIU", + "Cgxpc19leHRlbnNpb24YAiACKAgi1QEKDlNvdXJjZUNvZGVJbmZvEjoKCGxv", + "Y2F0aW9uGAEgAygLMiguZ29vZ2xlLnByb3RvYnVmLlNvdXJjZUNvZGVJbmZv", + "LkxvY2F0aW9uGoYBCghMb2NhdGlvbhIQCgRwYXRoGAEgAygFQgIQARIQCgRz", + "cGFuGAIgAygFQgIQARIYChBsZWFkaW5nX2NvbW1lbnRzGAMgASgJEhkKEXRy", + "YWlsaW5nX2NvbW1lbnRzGAQgASgJEiEKGWxlYWRpbmdfZGV0YWNoZWRfY29t", + "bWVudHMYBiADKAlCWAoTY29tLmdvb2dsZS5wcm90b2J1ZkIQRGVzY3JpcHRv", + "clByb3Rvc0gBWgpkZXNjcmlwdG9yogIDR1BCqgIaR29vZ2xlLlByb3RvYnVm", + "LlJlZmxlY3Rpb24=")); + descriptor = pbr::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, + new pbr::FileDescriptor[] { + }); + internal__static_google_protobuf_FileDescriptorSet__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.FileDescriptorSet), descriptor.MessageTypes[0], + new string[] { "File", }, new string[] { }); + internal__static_google_protobuf_FileDescriptorProto__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.FileDescriptorProto), descriptor.MessageTypes[1], + new string[] { "Name", "Package", "Dependency", "PublicDependency", "WeakDependency", "MessageType", "EnumType", "Service", "Extension", "Options", "SourceCodeInfo", "Syntax", }, new string[] { }); + internal__static_google_protobuf_DescriptorProto__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.DescriptorProto), descriptor.MessageTypes[2], + new string[] { "Name", "Field", "Extension", "NestedType", "EnumType", "ExtensionRange", "OneofDecl", "Options", "ReservedRange", "ReservedName", }, new string[] { }); + internal__static_google_protobuf_DescriptorProto_ExtensionRange__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.DescriptorProto.Types.ExtensionRange), descriptor.MessageTypes[2].NestedTypes[0], + new string[] { "Start", "End", }, new string[] { }); + internal__static_google_protobuf_DescriptorProto_ReservedRange__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.DescriptorProto.Types.ReservedRange), descriptor.MessageTypes[2].NestedTypes[1], + new string[] { "Start", "End", }, new string[] { }); + internal__static_google_protobuf_FieldDescriptorProto__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.FieldDescriptorProto), descriptor.MessageTypes[3], + new string[] { "Name", "Number", "Label", "Type", "TypeName", "Extendee", "DefaultValue", "OneofIndex", "Options", }, new string[] { }); + internal__static_google_protobuf_OneofDescriptorProto__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.OneofDescriptorProto), descriptor.MessageTypes[4], + new string[] { "Name", }, new string[] { }); + internal__static_google_protobuf_EnumDescriptorProto__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.EnumDescriptorProto), descriptor.MessageTypes[5], + new string[] { "Name", "Value", "Options", }, new string[] { }); + internal__static_google_protobuf_EnumValueDescriptorProto__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.EnumValueDescriptorProto), descriptor.MessageTypes[6], + new string[] { "Name", "Number", "Options", }, new string[] { }); + internal__static_google_protobuf_ServiceDescriptorProto__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.ServiceDescriptorProto), descriptor.MessageTypes[7], + new string[] { "Name", "Method", "Options", }, new string[] { }); + internal__static_google_protobuf_MethodDescriptorProto__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.MethodDescriptorProto), descriptor.MessageTypes[8], + new string[] { "Name", "InputType", "OutputType", "Options", "ClientStreaming", "ServerStreaming", }, new string[] { }); + internal__static_google_protobuf_FileOptions__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.FileOptions), descriptor.MessageTypes[9], + new string[] { "JavaPackage", "JavaOuterClassname", "JavaMultipleFiles", "JavaGenerateEqualsAndHash", "JavaStringCheckUtf8", "OptimizeFor", "GoPackage", "CcGenericServices", "JavaGenericServices", "PyGenericServices", "Deprecated", "CcEnableArenas", "ObjcClassPrefix", "CsharpNamespace", "UninterpretedOption", }, new string[] { }); + internal__static_google_protobuf_MessageOptions__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.MessageOptions), descriptor.MessageTypes[10], + new string[] { "MessageSetWireFormat", "NoStandardDescriptorAccessor", "Deprecated", "MapEntry", "UninterpretedOption", }, new string[] { }); + internal__static_google_protobuf_FieldOptions__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.FieldOptions), descriptor.MessageTypes[11], + new string[] { "Ctype", "Packed", "Jstype", "Lazy", "Deprecated", "Weak", "UninterpretedOption", }, new string[] { }); + internal__static_google_protobuf_EnumOptions__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.EnumOptions), descriptor.MessageTypes[12], + new string[] { "AllowAlias", "Deprecated", "UninterpretedOption", }, new string[] { }); + internal__static_google_protobuf_EnumValueOptions__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.EnumValueOptions), descriptor.MessageTypes[13], + new string[] { "Deprecated", "UninterpretedOption", }, new string[] { }); + internal__static_google_protobuf_ServiceOptions__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.ServiceOptions), descriptor.MessageTypes[14], + new string[] { "Deprecated", "UninterpretedOption", }, new string[] { }); + internal__static_google_protobuf_MethodOptions__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.MethodOptions), descriptor.MessageTypes[15], + new string[] { "Deprecated", "UninterpretedOption", }, new string[] { }); + internal__static_google_protobuf_UninterpretedOption__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.UninterpretedOption), descriptor.MessageTypes[16], + new string[] { "Name", "IdentifierValue", "PositiveIntValue", "NegativeIntValue", "DoubleValue", "StringValue", "AggregateValue", }, new string[] { }); + internal__static_google_protobuf_UninterpretedOption_NamePart__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.UninterpretedOption.Types.NamePart), descriptor.MessageTypes[16].NestedTypes[0], + new string[] { "NamePart_", "IsExtension", }, new string[] { }); + internal__static_google_protobuf_SourceCodeInfo__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.SourceCodeInfo), descriptor.MessageTypes[17], + new string[] { "Location", }, new string[] { }); + internal__static_google_protobuf_SourceCodeInfo_Location__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Reflection.SourceCodeInfo.Types.Location), descriptor.MessageTypes[17].NestedTypes[0], + new string[] { "Path", "Span", "LeadingComments", "TrailingComments", "LeadingDetachedComments", }, new string[] { }); + } + #endregion + + } + #region Messages + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + internal sealed partial class FileDescriptorSet : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FileDescriptorSet()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "file" }; + private static readonly uint[] _fieldTags = new uint[] { 10 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[0]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_FileDescriptorSet__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public FileDescriptorSet() { + OnConstruction(); + } + + partial void OnConstruction(); + + public FileDescriptorSet(FileDescriptorSet other) : this() { + file_ = other.file_.Clone(); + } + + public FileDescriptorSet Clone() { + return new FileDescriptorSet(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + file_.Freeze(); + } + + public const int FileFieldNumber = 1; + private static readonly pb::FieldCodec _repeated_file_codec + = pb::FieldCodec.ForMessage(10, global::Google.Protobuf.Reflection.FileDescriptorProto.Parser); + private readonly pbc::RepeatedField file_ = new pbc::RepeatedField(); + internal pbc::RepeatedField File { + get { return file_; } + } + + public override bool Equals(object other) { + return Equals(other as FileDescriptorSet); + } + + public bool Equals(FileDescriptorSet other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if(!file_.Equals(other.file_)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + hash ^= file_.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + file_.WriteTo(output, _repeated_file_codec); + } + + public int CalculateSize() { + int size = 0; + size += file_.CalculateSize(_repeated_file_codec); + return size; + } + + public void MergeFrom(FileDescriptorSet other) { + if (other == null) { + return; + } + file_.Add(other.file_); + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + file_.AddEntriesFrom(input, _repeated_file_codec); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + internal sealed partial class FileDescriptorProto : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FileDescriptorProto()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "dependency", "enum_type", "extension", "message_type", "name", "options", "package", "public_dependency", "service", "source_code_info", "syntax", "weak_dependency" }; + private static readonly uint[] _fieldTags = new uint[] { 26, 42, 58, 34, 10, 66, 18, 80, 50, 74, 98, 88 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[1]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_FileDescriptorProto__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public FileDescriptorProto() { + OnConstruction(); + } + + partial void OnConstruction(); + + public FileDescriptorProto(FileDescriptorProto other) : this() { + name_ = other.name_; + package_ = other.package_; + dependency_ = other.dependency_.Clone(); + publicDependency_ = other.publicDependency_.Clone(); + weakDependency_ = other.weakDependency_.Clone(); + messageType_ = other.messageType_.Clone(); + enumType_ = other.enumType_.Clone(); + service_ = other.service_.Clone(); + extension_ = other.extension_.Clone(); + Options = other.options_ != null ? other.Options.Clone() : null; + SourceCodeInfo = other.sourceCodeInfo_ != null ? other.SourceCodeInfo.Clone() : null; + syntax_ = other.syntax_; + } + + public FileDescriptorProto Clone() { + return new FileDescriptorProto(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + dependency_.Freeze(); + publicDependency_.Freeze(); + weakDependency_.Freeze(); + messageType_.Freeze(); + enumType_.Freeze(); + service_.Freeze(); + extension_.Freeze(); + if (options_ != null) Options.Freeze(); + if (sourceCodeInfo_ != null) SourceCodeInfo.Freeze(); + } + + public const int NameFieldNumber = 1; + private string name_ = ""; + internal string Name { + get { return name_; } + set { + pb::Freezable.CheckMutable(this); + name_ = value ?? ""; + } + } + + public const int PackageFieldNumber = 2; + private string package_ = ""; + internal string Package { + get { return package_; } + set { + pb::Freezable.CheckMutable(this); + package_ = value ?? ""; + } + } + + public const int DependencyFieldNumber = 3; + private static readonly pb::FieldCodec _repeated_dependency_codec + = pb::FieldCodec.ForString(26); + private readonly pbc::RepeatedField dependency_ = new pbc::RepeatedField(); + internal pbc::RepeatedField Dependency { + get { return dependency_; } + } + + public const int PublicDependencyFieldNumber = 10; + private static readonly pb::FieldCodec _repeated_publicDependency_codec + = pb::FieldCodec.ForInt32(80); + private readonly pbc::RepeatedField publicDependency_ = new pbc::RepeatedField(); + internal pbc::RepeatedField PublicDependency { + get { return publicDependency_; } + } + + public const int WeakDependencyFieldNumber = 11; + private static readonly pb::FieldCodec _repeated_weakDependency_codec + = pb::FieldCodec.ForInt32(88); + private readonly pbc::RepeatedField weakDependency_ = new pbc::RepeatedField(); + internal pbc::RepeatedField WeakDependency { + get { return weakDependency_; } + } + + public const int MessageTypeFieldNumber = 4; + private static readonly pb::FieldCodec _repeated_messageType_codec + = pb::FieldCodec.ForMessage(34, global::Google.Protobuf.Reflection.DescriptorProto.Parser); + private readonly pbc::RepeatedField messageType_ = new pbc::RepeatedField(); + internal pbc::RepeatedField MessageType { + get { return messageType_; } + } + + public const int EnumTypeFieldNumber = 5; + private static readonly pb::FieldCodec _repeated_enumType_codec + = pb::FieldCodec.ForMessage(42, global::Google.Protobuf.Reflection.EnumDescriptorProto.Parser); + private readonly pbc::RepeatedField enumType_ = new pbc::RepeatedField(); + internal pbc::RepeatedField EnumType { + get { return enumType_; } + } + + public const int ServiceFieldNumber = 6; + private static readonly pb::FieldCodec _repeated_service_codec + = pb::FieldCodec.ForMessage(50, global::Google.Protobuf.Reflection.ServiceDescriptorProto.Parser); + private readonly pbc::RepeatedField service_ = new pbc::RepeatedField(); + internal pbc::RepeatedField Service { + get { return service_; } + } + + public const int ExtensionFieldNumber = 7; + private static readonly pb::FieldCodec _repeated_extension_codec + = pb::FieldCodec.ForMessage(58, global::Google.Protobuf.Reflection.FieldDescriptorProto.Parser); + private readonly pbc::RepeatedField extension_ = new pbc::RepeatedField(); + internal pbc::RepeatedField Extension { + get { return extension_; } + } + + public const int OptionsFieldNumber = 8; + private global::Google.Protobuf.Reflection.FileOptions options_; + internal global::Google.Protobuf.Reflection.FileOptions Options { + get { return options_; } + set { + pb::Freezable.CheckMutable(this); + options_ = value; + } + } + + public const int SourceCodeInfoFieldNumber = 9; + private global::Google.Protobuf.Reflection.SourceCodeInfo sourceCodeInfo_; + internal global::Google.Protobuf.Reflection.SourceCodeInfo SourceCodeInfo { + get { return sourceCodeInfo_; } + set { + pb::Freezable.CheckMutable(this); + sourceCodeInfo_ = value; + } + } + + public const int SyntaxFieldNumber = 12; + private string syntax_ = ""; + internal string Syntax { + get { return syntax_; } + set { + pb::Freezable.CheckMutable(this); + syntax_ = value ?? ""; + } + } + + public override bool Equals(object other) { + return Equals(other as FileDescriptorProto); + } + + public bool Equals(FileDescriptorProto other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Name != other.Name) return false; + if (Package != other.Package) return false; + if(!dependency_.Equals(other.dependency_)) return false; + if(!publicDependency_.Equals(other.publicDependency_)) return false; + if(!weakDependency_.Equals(other.weakDependency_)) return false; + if(!messageType_.Equals(other.messageType_)) return false; + if(!enumType_.Equals(other.enumType_)) return false; + if(!service_.Equals(other.service_)) return false; + if(!extension_.Equals(other.extension_)) return false; + if (!object.Equals(Options, other.Options)) return false; + if (!object.Equals(SourceCodeInfo, other.SourceCodeInfo)) return false; + if (Syntax != other.Syntax) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Name.Length != 0) hash ^= Name.GetHashCode(); + if (Package.Length != 0) hash ^= Package.GetHashCode(); + hash ^= dependency_.GetHashCode(); + hash ^= publicDependency_.GetHashCode(); + hash ^= weakDependency_.GetHashCode(); + hash ^= messageType_.GetHashCode(); + hash ^= enumType_.GetHashCode(); + hash ^= service_.GetHashCode(); + hash ^= extension_.GetHashCode(); + if (options_ != null) hash ^= Options.GetHashCode(); + if (sourceCodeInfo_ != null) hash ^= SourceCodeInfo.GetHashCode(); + if (Syntax.Length != 0) hash ^= Syntax.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Name.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Name); + } + if (Package.Length != 0) { + output.WriteRawTag(18); + output.WriteString(Package); + } + dependency_.WriteTo(output, _repeated_dependency_codec); + messageType_.WriteTo(output, _repeated_messageType_codec); + enumType_.WriteTo(output, _repeated_enumType_codec); + service_.WriteTo(output, _repeated_service_codec); + extension_.WriteTo(output, _repeated_extension_codec); + if (options_ != null) { + output.WriteRawTag(66); + output.WriteMessage(Options); + } + if (sourceCodeInfo_ != null) { + output.WriteRawTag(74); + output.WriteMessage(SourceCodeInfo); + } + publicDependency_.WriteTo(output, _repeated_publicDependency_codec); + weakDependency_.WriteTo(output, _repeated_weakDependency_codec); + if (Syntax.Length != 0) { + output.WriteRawTag(98); + output.WriteString(Syntax); + } + } + + public int CalculateSize() { + int size = 0; + if (Name.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); + } + if (Package.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Package); + } + size += dependency_.CalculateSize(_repeated_dependency_codec); + size += publicDependency_.CalculateSize(_repeated_publicDependency_codec); + size += weakDependency_.CalculateSize(_repeated_weakDependency_codec); + size += messageType_.CalculateSize(_repeated_messageType_codec); + size += enumType_.CalculateSize(_repeated_enumType_codec); + size += service_.CalculateSize(_repeated_service_codec); + size += extension_.CalculateSize(_repeated_extension_codec); + if (options_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Options); + } + if (sourceCodeInfo_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(SourceCodeInfo); + } + if (Syntax.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Syntax); + } + return size; + } + + public void MergeFrom(FileDescriptorProto other) { + if (other == null) { + return; + } + if (other.Name.Length != 0) { + Name = other.Name; + } + if (other.Package.Length != 0) { + Package = other.Package; + } + dependency_.Add(other.dependency_); + publicDependency_.Add(other.publicDependency_); + weakDependency_.Add(other.weakDependency_); + messageType_.Add(other.messageType_); + enumType_.Add(other.enumType_); + service_.Add(other.service_); + extension_.Add(other.extension_); + if (other.options_ != null) { + if (options_ == null) { + options_ = new global::Google.Protobuf.Reflection.FileOptions(); + } + Options.MergeFrom(other.Options); + } + if (other.sourceCodeInfo_ != null) { + if (sourceCodeInfo_ == null) { + sourceCodeInfo_ = new global::Google.Protobuf.Reflection.SourceCodeInfo(); + } + SourceCodeInfo.MergeFrom(other.SourceCodeInfo); + } + if (other.Syntax.Length != 0) { + Syntax = other.Syntax; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + Name = input.ReadString(); + break; + } + case 18: { + Package = input.ReadString(); + break; + } + case 26: { + dependency_.AddEntriesFrom(input, _repeated_dependency_codec); + break; + } + case 34: { + messageType_.AddEntriesFrom(input, _repeated_messageType_codec); + break; + } + case 42: { + enumType_.AddEntriesFrom(input, _repeated_enumType_codec); + break; + } + case 50: { + service_.AddEntriesFrom(input, _repeated_service_codec); + break; + } + case 58: { + extension_.AddEntriesFrom(input, _repeated_extension_codec); + break; + } + case 66: { + if (options_ == null) { + options_ = new global::Google.Protobuf.Reflection.FileOptions(); + } + input.ReadMessage(options_); + break; + } + case 74: { + if (sourceCodeInfo_ == null) { + sourceCodeInfo_ = new global::Google.Protobuf.Reflection.SourceCodeInfo(); + } + input.ReadMessage(sourceCodeInfo_); + break; + } + case 82: + case 80: { + publicDependency_.AddEntriesFrom(input, _repeated_publicDependency_codec); + break; + } + case 90: + case 88: { + weakDependency_.AddEntriesFrom(input, _repeated_weakDependency_codec); + break; + } + case 98: { + Syntax = input.ReadString(); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + internal sealed partial class DescriptorProto : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new DescriptorProto()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "enum_type", "extension", "extension_range", "field", "name", "nested_type", "oneof_decl", "options", "reserved_name", "reserved_range" }; + private static readonly uint[] _fieldTags = new uint[] { 34, 50, 42, 18, 10, 26, 66, 58, 82, 74 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[2]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_DescriptorProto__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public DescriptorProto() { + OnConstruction(); + } + + partial void OnConstruction(); + + public DescriptorProto(DescriptorProto other) : this() { + name_ = other.name_; + field_ = other.field_.Clone(); + extension_ = other.extension_.Clone(); + nestedType_ = other.nestedType_.Clone(); + enumType_ = other.enumType_.Clone(); + extensionRange_ = other.extensionRange_.Clone(); + oneofDecl_ = other.oneofDecl_.Clone(); + Options = other.options_ != null ? other.Options.Clone() : null; + reservedRange_ = other.reservedRange_.Clone(); + reservedName_ = other.reservedName_.Clone(); + } + + public DescriptorProto Clone() { + return new DescriptorProto(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + field_.Freeze(); + extension_.Freeze(); + nestedType_.Freeze(); + enumType_.Freeze(); + extensionRange_.Freeze(); + oneofDecl_.Freeze(); + if (options_ != null) Options.Freeze(); + reservedRange_.Freeze(); + reservedName_.Freeze(); + } + + public const int NameFieldNumber = 1; + private string name_ = ""; + internal string Name { + get { return name_; } + set { + pb::Freezable.CheckMutable(this); + name_ = value ?? ""; + } + } + + public const int FieldFieldNumber = 2; + private static readonly pb::FieldCodec _repeated_field_codec + = pb::FieldCodec.ForMessage(18, global::Google.Protobuf.Reflection.FieldDescriptorProto.Parser); + private readonly pbc::RepeatedField field_ = new pbc::RepeatedField(); + internal pbc::RepeatedField Field { + get { return field_; } + } + + public const int ExtensionFieldNumber = 6; + private static readonly pb::FieldCodec _repeated_extension_codec + = pb::FieldCodec.ForMessage(50, global::Google.Protobuf.Reflection.FieldDescriptorProto.Parser); + private readonly pbc::RepeatedField extension_ = new pbc::RepeatedField(); + internal pbc::RepeatedField Extension { + get { return extension_; } + } + + public const int NestedTypeFieldNumber = 3; + private static readonly pb::FieldCodec _repeated_nestedType_codec + = pb::FieldCodec.ForMessage(26, global::Google.Protobuf.Reflection.DescriptorProto.Parser); + private readonly pbc::RepeatedField nestedType_ = new pbc::RepeatedField(); + internal pbc::RepeatedField NestedType { + get { return nestedType_; } + } + + public const int EnumTypeFieldNumber = 4; + private static readonly pb::FieldCodec _repeated_enumType_codec + = pb::FieldCodec.ForMessage(34, global::Google.Protobuf.Reflection.EnumDescriptorProto.Parser); + private readonly pbc::RepeatedField enumType_ = new pbc::RepeatedField(); + internal pbc::RepeatedField EnumType { + get { return enumType_; } + } + + public const int ExtensionRangeFieldNumber = 5; + private static readonly pb::FieldCodec _repeated_extensionRange_codec + = pb::FieldCodec.ForMessage(42, global::Google.Protobuf.Reflection.DescriptorProto.Types.ExtensionRange.Parser); + private readonly pbc::RepeatedField extensionRange_ = new pbc::RepeatedField(); + internal pbc::RepeatedField ExtensionRange { + get { return extensionRange_; } + } + + public const int OneofDeclFieldNumber = 8; + private static readonly pb::FieldCodec _repeated_oneofDecl_codec + = pb::FieldCodec.ForMessage(66, global::Google.Protobuf.Reflection.OneofDescriptorProto.Parser); + private readonly pbc::RepeatedField oneofDecl_ = new pbc::RepeatedField(); + internal pbc::RepeatedField OneofDecl { + get { return oneofDecl_; } + } + + public const int OptionsFieldNumber = 7; + private global::Google.Protobuf.Reflection.MessageOptions options_; + internal global::Google.Protobuf.Reflection.MessageOptions Options { + get { return options_; } + set { + pb::Freezable.CheckMutable(this); + options_ = value; + } + } + + public const int ReservedRangeFieldNumber = 9; + private static readonly pb::FieldCodec _repeated_reservedRange_codec + = pb::FieldCodec.ForMessage(74, global::Google.Protobuf.Reflection.DescriptorProto.Types.ReservedRange.Parser); + private readonly pbc::RepeatedField reservedRange_ = new pbc::RepeatedField(); + internal pbc::RepeatedField ReservedRange { + get { return reservedRange_; } + } + + public const int ReservedNameFieldNumber = 10; + private static readonly pb::FieldCodec _repeated_reservedName_codec + = pb::FieldCodec.ForString(82); + private readonly pbc::RepeatedField reservedName_ = new pbc::RepeatedField(); + internal pbc::RepeatedField ReservedName { + get { return reservedName_; } + } + + public override bool Equals(object other) { + return Equals(other as DescriptorProto); + } + + public bool Equals(DescriptorProto other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Name != other.Name) return false; + if(!field_.Equals(other.field_)) return false; + if(!extension_.Equals(other.extension_)) return false; + if(!nestedType_.Equals(other.nestedType_)) return false; + if(!enumType_.Equals(other.enumType_)) return false; + if(!extensionRange_.Equals(other.extensionRange_)) return false; + if(!oneofDecl_.Equals(other.oneofDecl_)) return false; + if (!object.Equals(Options, other.Options)) return false; + if(!reservedRange_.Equals(other.reservedRange_)) return false; + if(!reservedName_.Equals(other.reservedName_)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Name.Length != 0) hash ^= Name.GetHashCode(); + hash ^= field_.GetHashCode(); + hash ^= extension_.GetHashCode(); + hash ^= nestedType_.GetHashCode(); + hash ^= enumType_.GetHashCode(); + hash ^= extensionRange_.GetHashCode(); + hash ^= oneofDecl_.GetHashCode(); + if (options_ != null) hash ^= Options.GetHashCode(); + hash ^= reservedRange_.GetHashCode(); + hash ^= reservedName_.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Name.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Name); + } + field_.WriteTo(output, _repeated_field_codec); + nestedType_.WriteTo(output, _repeated_nestedType_codec); + enumType_.WriteTo(output, _repeated_enumType_codec); + extensionRange_.WriteTo(output, _repeated_extensionRange_codec); + extension_.WriteTo(output, _repeated_extension_codec); + if (options_ != null) { + output.WriteRawTag(58); + output.WriteMessage(Options); + } + oneofDecl_.WriteTo(output, _repeated_oneofDecl_codec); + reservedRange_.WriteTo(output, _repeated_reservedRange_codec); + reservedName_.WriteTo(output, _repeated_reservedName_codec); + } + + public int CalculateSize() { + int size = 0; + if (Name.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); + } + size += field_.CalculateSize(_repeated_field_codec); + size += extension_.CalculateSize(_repeated_extension_codec); + size += nestedType_.CalculateSize(_repeated_nestedType_codec); + size += enumType_.CalculateSize(_repeated_enumType_codec); + size += extensionRange_.CalculateSize(_repeated_extensionRange_codec); + size += oneofDecl_.CalculateSize(_repeated_oneofDecl_codec); + if (options_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Options); + } + size += reservedRange_.CalculateSize(_repeated_reservedRange_codec); + size += reservedName_.CalculateSize(_repeated_reservedName_codec); + return size; + } + + public void MergeFrom(DescriptorProto other) { + if (other == null) { + return; + } + if (other.Name.Length != 0) { + Name = other.Name; + } + field_.Add(other.field_); + extension_.Add(other.extension_); + nestedType_.Add(other.nestedType_); + enumType_.Add(other.enumType_); + extensionRange_.Add(other.extensionRange_); + oneofDecl_.Add(other.oneofDecl_); + if (other.options_ != null) { + if (options_ == null) { + options_ = new global::Google.Protobuf.Reflection.MessageOptions(); + } + Options.MergeFrom(other.Options); + } + reservedRange_.Add(other.reservedRange_); + reservedName_.Add(other.reservedName_); + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + Name = input.ReadString(); + break; + } + case 18: { + field_.AddEntriesFrom(input, _repeated_field_codec); + break; + } + case 26: { + nestedType_.AddEntriesFrom(input, _repeated_nestedType_codec); + break; + } + case 34: { + enumType_.AddEntriesFrom(input, _repeated_enumType_codec); + break; + } + case 42: { + extensionRange_.AddEntriesFrom(input, _repeated_extensionRange_codec); + break; + } + case 50: { + extension_.AddEntriesFrom(input, _repeated_extension_codec); + break; + } + case 58: { + if (options_ == null) { + options_ = new global::Google.Protobuf.Reflection.MessageOptions(); + } + input.ReadMessage(options_); + break; + } + case 66: { + oneofDecl_.AddEntriesFrom(input, _repeated_oneofDecl_codec); + break; + } + case 74: { + reservedRange_.AddEntriesFrom(input, _repeated_reservedRange_codec); + break; + } + case 82: { + reservedName_.AddEntriesFrom(input, _repeated_reservedName_codec); + break; + } + } + } + } + + #region Nested types + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static partial class Types { + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + internal sealed partial class ExtensionRange : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ExtensionRange()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "end", "start" }; + private static readonly uint[] _fieldTags = new uint[] { 16, 8 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.Reflection.DescriptorProto.Descriptor.NestedTypes[0]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_DescriptorProto_ExtensionRange__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public ExtensionRange() { + OnConstruction(); + } + + partial void OnConstruction(); + + public ExtensionRange(ExtensionRange other) : this() { + start_ = other.start_; + end_ = other.end_; + } + + public ExtensionRange Clone() { + return new ExtensionRange(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public const int StartFieldNumber = 1; + private int start_; + internal int Start { + get { return start_; } + set { + pb::Freezable.CheckMutable(this); + start_ = value; + } + } + + public const int EndFieldNumber = 2; + private int end_; + internal int End { + get { return end_; } + set { + pb::Freezable.CheckMutable(this); + end_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as ExtensionRange); + } + + public bool Equals(ExtensionRange other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Start != other.Start) return false; + if (End != other.End) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Start != 0) hash ^= Start.GetHashCode(); + if (End != 0) hash ^= End.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Start != 0) { + output.WriteRawTag(8); + output.WriteInt32(Start); + } + if (End != 0) { + output.WriteRawTag(16); + output.WriteInt32(End); + } + } + + public int CalculateSize() { + int size = 0; + if (Start != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Start); + } + if (End != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(End); + } + return size; + } + + public void MergeFrom(ExtensionRange other) { + if (other == null) { + return; + } + if (other.Start != 0) { + Start = other.Start; + } + if (other.End != 0) { + End = other.End; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 8: { + Start = input.ReadInt32(); + break; + } + case 16: { + End = input.ReadInt32(); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + internal sealed partial class ReservedRange : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ReservedRange()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "end", "start" }; + private static readonly uint[] _fieldTags = new uint[] { 16, 8 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.Reflection.DescriptorProto.Descriptor.NestedTypes[1]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_DescriptorProto_ReservedRange__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public ReservedRange() { + OnConstruction(); + } + + partial void OnConstruction(); + + public ReservedRange(ReservedRange other) : this() { + start_ = other.start_; + end_ = other.end_; + } + + public ReservedRange Clone() { + return new ReservedRange(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public const int StartFieldNumber = 1; + private int start_; + internal int Start { + get { return start_; } + set { + pb::Freezable.CheckMutable(this); + start_ = value; + } + } + + public const int EndFieldNumber = 2; + private int end_; + internal int End { + get { return end_; } + set { + pb::Freezable.CheckMutable(this); + end_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as ReservedRange); + } + + public bool Equals(ReservedRange other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Start != other.Start) return false; + if (End != other.End) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Start != 0) hash ^= Start.GetHashCode(); + if (End != 0) hash ^= End.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Start != 0) { + output.WriteRawTag(8); + output.WriteInt32(Start); + } + if (End != 0) { + output.WriteRawTag(16); + output.WriteInt32(End); + } + } + + public int CalculateSize() { + int size = 0; + if (Start != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Start); + } + if (End != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(End); + } + return size; + } + + public void MergeFrom(ReservedRange other) { + if (other == null) { + return; + } + if (other.Start != 0) { + Start = other.Start; + } + if (other.End != 0) { + End = other.End; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 8: { + Start = input.ReadInt32(); + break; + } + case 16: { + End = input.ReadInt32(); + break; + } + } + } + } + + } + + } + #endregion + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + internal sealed partial class FieldDescriptorProto : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FieldDescriptorProto()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "default_value", "extendee", "label", "name", "number", "oneof_index", "options", "type", "type_name" }; + private static readonly uint[] _fieldTags = new uint[] { 58, 18, 32, 10, 24, 72, 66, 40, 50 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[3]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_FieldDescriptorProto__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public FieldDescriptorProto() { + OnConstruction(); + } + + partial void OnConstruction(); + + public FieldDescriptorProto(FieldDescriptorProto other) : this() { + name_ = other.name_; + number_ = other.number_; + label_ = other.label_; + type_ = other.type_; + typeName_ = other.typeName_; + extendee_ = other.extendee_; + defaultValue_ = other.defaultValue_; + oneofIndex_ = other.oneofIndex_; + Options = other.options_ != null ? other.Options.Clone() : null; + } + + public FieldDescriptorProto Clone() { + return new FieldDescriptorProto(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + if (options_ != null) Options.Freeze(); + } + + public const int NameFieldNumber = 1; + private string name_ = ""; + internal string Name { + get { return name_; } + set { + pb::Freezable.CheckMutable(this); + name_ = value ?? ""; + } + } + + public const int NumberFieldNumber = 3; + private int number_; + internal int Number { + get { return number_; } + set { + pb::Freezable.CheckMutable(this); + number_ = value; + } + } + + public const int LabelFieldNumber = 4; + private global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Label label_ = global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Label.LABEL_OPTIONAL; + internal global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Label Label { + get { return label_; } + set { + pb::Freezable.CheckMutable(this); + label_ = value; + } + } + + public const int TypeFieldNumber = 5; + private global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Type type_ = global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Type.TYPE_DOUBLE; + internal global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Type Type { + get { return type_; } + set { + pb::Freezable.CheckMutable(this); + type_ = value; + } + } + + public const int TypeNameFieldNumber = 6; + private string typeName_ = ""; + internal string TypeName { + get { return typeName_; } + set { + pb::Freezable.CheckMutable(this); + typeName_ = value ?? ""; + } + } + + public const int ExtendeeFieldNumber = 2; + private string extendee_ = ""; + internal string Extendee { + get { return extendee_; } + set { + pb::Freezable.CheckMutable(this); + extendee_ = value ?? ""; + } + } + + public const int DefaultValueFieldNumber = 7; + private string defaultValue_ = ""; + internal string DefaultValue { + get { return defaultValue_; } + set { + pb::Freezable.CheckMutable(this); + defaultValue_ = value ?? ""; + } + } + + public const int OneofIndexFieldNumber = 9; + private int oneofIndex_; + internal int OneofIndex { + get { return oneofIndex_; } + set { + pb::Freezable.CheckMutable(this); + oneofIndex_ = value; + } + } + + public const int OptionsFieldNumber = 8; + private global::Google.Protobuf.Reflection.FieldOptions options_; + internal global::Google.Protobuf.Reflection.FieldOptions Options { + get { return options_; } + set { + pb::Freezable.CheckMutable(this); + options_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as FieldDescriptorProto); + } + + public bool Equals(FieldDescriptorProto other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Name != other.Name) return false; + if (Number != other.Number) return false; + if (Label != other.Label) return false; + if (Type != other.Type) return false; + if (TypeName != other.TypeName) return false; + if (Extendee != other.Extendee) return false; + if (DefaultValue != other.DefaultValue) return false; + if (OneofIndex != other.OneofIndex) return false; + if (!object.Equals(Options, other.Options)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Name.Length != 0) hash ^= Name.GetHashCode(); + if (Number != 0) hash ^= Number.GetHashCode(); + if (Label != global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Label.LABEL_OPTIONAL) hash ^= Label.GetHashCode(); + if (Type != global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Type.TYPE_DOUBLE) hash ^= Type.GetHashCode(); + if (TypeName.Length != 0) hash ^= TypeName.GetHashCode(); + if (Extendee.Length != 0) hash ^= Extendee.GetHashCode(); + if (DefaultValue.Length != 0) hash ^= DefaultValue.GetHashCode(); + if (OneofIndex != 0) hash ^= OneofIndex.GetHashCode(); + if (options_ != null) hash ^= Options.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Name.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Name); + } + if (Extendee.Length != 0) { + output.WriteRawTag(18); + output.WriteString(Extendee); + } + if (Number != 0) { + output.WriteRawTag(24); + output.WriteInt32(Number); + } + if (Label != global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Label.LABEL_OPTIONAL) { + output.WriteRawTag(32); + output.WriteEnum((int) Label); + } + if (Type != global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Type.TYPE_DOUBLE) { + output.WriteRawTag(40); + output.WriteEnum((int) Type); + } + if (TypeName.Length != 0) { + output.WriteRawTag(50); + output.WriteString(TypeName); + } + if (DefaultValue.Length != 0) { + output.WriteRawTag(58); + output.WriteString(DefaultValue); + } + if (options_ != null) { + output.WriteRawTag(66); + output.WriteMessage(Options); + } + if (OneofIndex != 0) { + output.WriteRawTag(72); + output.WriteInt32(OneofIndex); + } + } + + public int CalculateSize() { + int size = 0; + if (Name.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); + } + if (Number != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Number); + } + if (Label != global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Label.LABEL_OPTIONAL) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Label); + } + if (Type != global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Type.TYPE_DOUBLE) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Type); + } + if (TypeName.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(TypeName); + } + if (Extendee.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Extendee); + } + if (DefaultValue.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(DefaultValue); + } + if (OneofIndex != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(OneofIndex); + } + if (options_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Options); + } + return size; + } + + public void MergeFrom(FieldDescriptorProto other) { + if (other == null) { + return; + } + if (other.Name.Length != 0) { + Name = other.Name; + } + if (other.Number != 0) { + Number = other.Number; + } + if (other.Label != global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Label.LABEL_OPTIONAL) { + Label = other.Label; + } + if (other.Type != global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Type.TYPE_DOUBLE) { + Type = other.Type; + } + if (other.TypeName.Length != 0) { + TypeName = other.TypeName; + } + if (other.Extendee.Length != 0) { + Extendee = other.Extendee; + } + if (other.DefaultValue.Length != 0) { + DefaultValue = other.DefaultValue; + } + if (other.OneofIndex != 0) { + OneofIndex = other.OneofIndex; + } + if (other.options_ != null) { + if (options_ == null) { + options_ = new global::Google.Protobuf.Reflection.FieldOptions(); + } + Options.MergeFrom(other.Options); + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + Name = input.ReadString(); + break; + } + case 18: { + Extendee = input.ReadString(); + break; + } + case 24: { + Number = input.ReadInt32(); + break; + } + case 32: { + label_ = (global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Label) input.ReadEnum(); + break; + } + case 40: { + type_ = (global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Type) input.ReadEnum(); + break; + } + case 50: { + TypeName = input.ReadString(); + break; + } + case 58: { + DefaultValue = input.ReadString(); + break; + } + case 66: { + if (options_ == null) { + options_ = new global::Google.Protobuf.Reflection.FieldOptions(); + } + input.ReadMessage(options_); + break; + } + case 72: { + OneofIndex = input.ReadInt32(); + break; + } + } + } + } + + #region Nested types + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static partial class Types { + internal enum Type { + TYPE_DOUBLE = 1, + TYPE_FLOAT = 2, + TYPE_INT64 = 3, + TYPE_UINT64 = 4, + TYPE_INT32 = 5, + TYPE_FIXED64 = 6, + TYPE_FIXED32 = 7, + TYPE_BOOL = 8, + TYPE_STRING = 9, + TYPE_GROUP = 10, + TYPE_MESSAGE = 11, + TYPE_BYTES = 12, + TYPE_UINT32 = 13, + TYPE_ENUM = 14, + TYPE_SFIXED32 = 15, + TYPE_SFIXED64 = 16, + TYPE_SINT32 = 17, + TYPE_SINT64 = 18, + } + + internal enum Label { + LABEL_OPTIONAL = 1, + LABEL_REQUIRED = 2, + LABEL_REPEATED = 3, + } + + } + #endregion + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + internal sealed partial class OneofDescriptorProto : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new OneofDescriptorProto()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "name" }; + private static readonly uint[] _fieldTags = new uint[] { 10 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[4]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_OneofDescriptorProto__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public OneofDescriptorProto() { + OnConstruction(); + } + + partial void OnConstruction(); + + public OneofDescriptorProto(OneofDescriptorProto other) : this() { + name_ = other.name_; + } + + public OneofDescriptorProto Clone() { + return new OneofDescriptorProto(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public const int NameFieldNumber = 1; + private string name_ = ""; + internal string Name { + get { return name_; } + set { + pb::Freezable.CheckMutable(this); + name_ = value ?? ""; + } + } + + public override bool Equals(object other) { + return Equals(other as OneofDescriptorProto); + } + + public bool Equals(OneofDescriptorProto other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Name != other.Name) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Name.Length != 0) hash ^= Name.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Name.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Name); + } + } + + public int CalculateSize() { + int size = 0; + if (Name.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); + } + return size; + } + + public void MergeFrom(OneofDescriptorProto other) { + if (other == null) { + return; + } + if (other.Name.Length != 0) { + Name = other.Name; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + Name = input.ReadString(); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + internal sealed partial class EnumDescriptorProto : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new EnumDescriptorProto()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "name", "options", "value" }; + private static readonly uint[] _fieldTags = new uint[] { 10, 26, 18 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[5]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_EnumDescriptorProto__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public EnumDescriptorProto() { + OnConstruction(); + } + + partial void OnConstruction(); + + public EnumDescriptorProto(EnumDescriptorProto other) : this() { + name_ = other.name_; + value_ = other.value_.Clone(); + Options = other.options_ != null ? other.Options.Clone() : null; + } + + public EnumDescriptorProto Clone() { + return new EnumDescriptorProto(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + value_.Freeze(); + if (options_ != null) Options.Freeze(); + } + + public const int NameFieldNumber = 1; + private string name_ = ""; + internal string Name { + get { return name_; } + set { + pb::Freezable.CheckMutable(this); + name_ = value ?? ""; + } + } + + public const int ValueFieldNumber = 2; + private static readonly pb::FieldCodec _repeated_value_codec + = pb::FieldCodec.ForMessage(18, global::Google.Protobuf.Reflection.EnumValueDescriptorProto.Parser); + private readonly pbc::RepeatedField value_ = new pbc::RepeatedField(); + internal pbc::RepeatedField Value { + get { return value_; } + } + + public const int OptionsFieldNumber = 3; + private global::Google.Protobuf.Reflection.EnumOptions options_; + internal global::Google.Protobuf.Reflection.EnumOptions Options { + get { return options_; } + set { + pb::Freezable.CheckMutable(this); + options_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as EnumDescriptorProto); + } + + public bool Equals(EnumDescriptorProto other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Name != other.Name) return false; + if(!value_.Equals(other.value_)) return false; + if (!object.Equals(Options, other.Options)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Name.Length != 0) hash ^= Name.GetHashCode(); + hash ^= value_.GetHashCode(); + if (options_ != null) hash ^= Options.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Name.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Name); + } + value_.WriteTo(output, _repeated_value_codec); + if (options_ != null) { + output.WriteRawTag(26); + output.WriteMessage(Options); + } + } + + public int CalculateSize() { + int size = 0; + if (Name.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); + } + size += value_.CalculateSize(_repeated_value_codec); + if (options_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Options); + } + return size; + } + + public void MergeFrom(EnumDescriptorProto other) { + if (other == null) { + return; + } + if (other.Name.Length != 0) { + Name = other.Name; + } + value_.Add(other.value_); + if (other.options_ != null) { + if (options_ == null) { + options_ = new global::Google.Protobuf.Reflection.EnumOptions(); + } + Options.MergeFrom(other.Options); + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + Name = input.ReadString(); + break; + } + case 18: { + value_.AddEntriesFrom(input, _repeated_value_codec); + break; + } + case 26: { + if (options_ == null) { + options_ = new global::Google.Protobuf.Reflection.EnumOptions(); + } + input.ReadMessage(options_); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + internal sealed partial class EnumValueDescriptorProto : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new EnumValueDescriptorProto()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "name", "number", "options" }; + private static readonly uint[] _fieldTags = new uint[] { 10, 16, 26 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[6]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_EnumValueDescriptorProto__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public EnumValueDescriptorProto() { + OnConstruction(); + } + + partial void OnConstruction(); + + public EnumValueDescriptorProto(EnumValueDescriptorProto other) : this() { + name_ = other.name_; + number_ = other.number_; + Options = other.options_ != null ? other.Options.Clone() : null; + } + + public EnumValueDescriptorProto Clone() { + return new EnumValueDescriptorProto(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + if (options_ != null) Options.Freeze(); + } + + public const int NameFieldNumber = 1; + private string name_ = ""; + internal string Name { + get { return name_; } + set { + pb::Freezable.CheckMutable(this); + name_ = value ?? ""; + } + } + + public const int NumberFieldNumber = 2; + private int number_; + internal int Number { + get { return number_; } + set { + pb::Freezable.CheckMutable(this); + number_ = value; + } + } + + public const int OptionsFieldNumber = 3; + private global::Google.Protobuf.Reflection.EnumValueOptions options_; + internal global::Google.Protobuf.Reflection.EnumValueOptions Options { + get { return options_; } + set { + pb::Freezable.CheckMutable(this); + options_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as EnumValueDescriptorProto); + } + + public bool Equals(EnumValueDescriptorProto other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Name != other.Name) return false; + if (Number != other.Number) return false; + if (!object.Equals(Options, other.Options)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Name.Length != 0) hash ^= Name.GetHashCode(); + if (Number != 0) hash ^= Number.GetHashCode(); + if (options_ != null) hash ^= Options.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Name.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Name); + } + if (Number != 0) { + output.WriteRawTag(16); + output.WriteInt32(Number); + } + if (options_ != null) { + output.WriteRawTag(26); + output.WriteMessage(Options); + } + } + + public int CalculateSize() { + int size = 0; + if (Name.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); + } + if (Number != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Number); + } + if (options_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Options); + } + return size; + } + + public void MergeFrom(EnumValueDescriptorProto other) { + if (other == null) { + return; + } + if (other.Name.Length != 0) { + Name = other.Name; + } + if (other.Number != 0) { + Number = other.Number; + } + if (other.options_ != null) { + if (options_ == null) { + options_ = new global::Google.Protobuf.Reflection.EnumValueOptions(); + } + Options.MergeFrom(other.Options); + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + Name = input.ReadString(); + break; + } + case 16: { + Number = input.ReadInt32(); + break; + } + case 26: { + if (options_ == null) { + options_ = new global::Google.Protobuf.Reflection.EnumValueOptions(); + } + input.ReadMessage(options_); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + internal sealed partial class ServiceDescriptorProto : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ServiceDescriptorProto()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "method", "name", "options" }; + private static readonly uint[] _fieldTags = new uint[] { 18, 10, 26 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[7]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_ServiceDescriptorProto__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public ServiceDescriptorProto() { + OnConstruction(); + } + + partial void OnConstruction(); + + public ServiceDescriptorProto(ServiceDescriptorProto other) : this() { + name_ = other.name_; + method_ = other.method_.Clone(); + Options = other.options_ != null ? other.Options.Clone() : null; + } + + public ServiceDescriptorProto Clone() { + return new ServiceDescriptorProto(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + method_.Freeze(); + if (options_ != null) Options.Freeze(); + } + + public const int NameFieldNumber = 1; + private string name_ = ""; + internal string Name { + get { return name_; } + set { + pb::Freezable.CheckMutable(this); + name_ = value ?? ""; + } + } + + public const int MethodFieldNumber = 2; + private static readonly pb::FieldCodec _repeated_method_codec + = pb::FieldCodec.ForMessage(18, global::Google.Protobuf.Reflection.MethodDescriptorProto.Parser); + private readonly pbc::RepeatedField method_ = new pbc::RepeatedField(); + internal pbc::RepeatedField Method { + get { return method_; } + } + + public const int OptionsFieldNumber = 3; + private global::Google.Protobuf.Reflection.ServiceOptions options_; + internal global::Google.Protobuf.Reflection.ServiceOptions Options { + get { return options_; } + set { + pb::Freezable.CheckMutable(this); + options_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as ServiceDescriptorProto); + } + + public bool Equals(ServiceDescriptorProto other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Name != other.Name) return false; + if(!method_.Equals(other.method_)) return false; + if (!object.Equals(Options, other.Options)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Name.Length != 0) hash ^= Name.GetHashCode(); + hash ^= method_.GetHashCode(); + if (options_ != null) hash ^= Options.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Name.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Name); + } + method_.WriteTo(output, _repeated_method_codec); + if (options_ != null) { + output.WriteRawTag(26); + output.WriteMessage(Options); + } + } + + public int CalculateSize() { + int size = 0; + if (Name.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); + } + size += method_.CalculateSize(_repeated_method_codec); + if (options_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Options); + } + return size; + } + + public void MergeFrom(ServiceDescriptorProto other) { + if (other == null) { + return; + } + if (other.Name.Length != 0) { + Name = other.Name; + } + method_.Add(other.method_); + if (other.options_ != null) { + if (options_ == null) { + options_ = new global::Google.Protobuf.Reflection.ServiceOptions(); + } + Options.MergeFrom(other.Options); + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + Name = input.ReadString(); + break; + } + case 18: { + method_.AddEntriesFrom(input, _repeated_method_codec); + break; + } + case 26: { + if (options_ == null) { + options_ = new global::Google.Protobuf.Reflection.ServiceOptions(); + } + input.ReadMessage(options_); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + internal sealed partial class MethodDescriptorProto : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MethodDescriptorProto()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "client_streaming", "input_type", "name", "options", "output_type", "server_streaming" }; + private static readonly uint[] _fieldTags = new uint[] { 40, 18, 10, 34, 26, 48 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[8]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_MethodDescriptorProto__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public MethodDescriptorProto() { + OnConstruction(); + } + + partial void OnConstruction(); + + public MethodDescriptorProto(MethodDescriptorProto other) : this() { + name_ = other.name_; + inputType_ = other.inputType_; + outputType_ = other.outputType_; + Options = other.options_ != null ? other.Options.Clone() : null; + clientStreaming_ = other.clientStreaming_; + serverStreaming_ = other.serverStreaming_; + } + + public MethodDescriptorProto Clone() { + return new MethodDescriptorProto(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + if (options_ != null) Options.Freeze(); + } + + public const int NameFieldNumber = 1; + private string name_ = ""; + internal string Name { + get { return name_; } + set { + pb::Freezable.CheckMutable(this); + name_ = value ?? ""; + } + } + + public const int InputTypeFieldNumber = 2; + private string inputType_ = ""; + internal string InputType { + get { return inputType_; } + set { + pb::Freezable.CheckMutable(this); + inputType_ = value ?? ""; + } + } + + public const int OutputTypeFieldNumber = 3; + private string outputType_ = ""; + internal string OutputType { + get { return outputType_; } + set { + pb::Freezable.CheckMutable(this); + outputType_ = value ?? ""; + } + } + + public const int OptionsFieldNumber = 4; + private global::Google.Protobuf.Reflection.MethodOptions options_; + internal global::Google.Protobuf.Reflection.MethodOptions Options { + get { return options_; } + set { + pb::Freezable.CheckMutable(this); + options_ = value; + } + } + + public const int ClientStreamingFieldNumber = 5; + private bool clientStreaming_; + internal bool ClientStreaming { + get { return clientStreaming_; } + set { + pb::Freezable.CheckMutable(this); + clientStreaming_ = value; + } + } + + public const int ServerStreamingFieldNumber = 6; + private bool serverStreaming_; + internal bool ServerStreaming { + get { return serverStreaming_; } + set { + pb::Freezable.CheckMutable(this); + serverStreaming_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as MethodDescriptorProto); + } + + public bool Equals(MethodDescriptorProto other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Name != other.Name) return false; + if (InputType != other.InputType) return false; + if (OutputType != other.OutputType) return false; + if (!object.Equals(Options, other.Options)) return false; + if (ClientStreaming != other.ClientStreaming) return false; + if (ServerStreaming != other.ServerStreaming) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Name.Length != 0) hash ^= Name.GetHashCode(); + if (InputType.Length != 0) hash ^= InputType.GetHashCode(); + if (OutputType.Length != 0) hash ^= OutputType.GetHashCode(); + if (options_ != null) hash ^= Options.GetHashCode(); + if (ClientStreaming != false) hash ^= ClientStreaming.GetHashCode(); + if (ServerStreaming != false) hash ^= ServerStreaming.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Name.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Name); + } + if (InputType.Length != 0) { + output.WriteRawTag(18); + output.WriteString(InputType); + } + if (OutputType.Length != 0) { + output.WriteRawTag(26); + output.WriteString(OutputType); + } + if (options_ != null) { + output.WriteRawTag(34); + output.WriteMessage(Options); + } + if (ClientStreaming != false) { + output.WriteRawTag(40); + output.WriteBool(ClientStreaming); + } + if (ServerStreaming != false) { + output.WriteRawTag(48); + output.WriteBool(ServerStreaming); + } + } + + public int CalculateSize() { + int size = 0; + if (Name.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); + } + if (InputType.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(InputType); + } + if (OutputType.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(OutputType); + } + if (options_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Options); + } + if (ClientStreaming != false) { + size += 1 + 1; + } + if (ServerStreaming != false) { + size += 1 + 1; + } + return size; + } + + public void MergeFrom(MethodDescriptorProto other) { + if (other == null) { + return; + } + if (other.Name.Length != 0) { + Name = other.Name; + } + if (other.InputType.Length != 0) { + InputType = other.InputType; + } + if (other.OutputType.Length != 0) { + OutputType = other.OutputType; + } + if (other.options_ != null) { + if (options_ == null) { + options_ = new global::Google.Protobuf.Reflection.MethodOptions(); + } + Options.MergeFrom(other.Options); + } + if (other.ClientStreaming != false) { + ClientStreaming = other.ClientStreaming; + } + if (other.ServerStreaming != false) { + ServerStreaming = other.ServerStreaming; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + Name = input.ReadString(); + break; + } + case 18: { + InputType = input.ReadString(); + break; + } + case 26: { + OutputType = input.ReadString(); + break; + } + case 34: { + if (options_ == null) { + options_ = new global::Google.Protobuf.Reflection.MethodOptions(); + } + input.ReadMessage(options_); + break; + } + case 40: { + ClientStreaming = input.ReadBool(); + break; + } + case 48: { + ServerStreaming = input.ReadBool(); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + internal sealed partial class FileOptions : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FileOptions()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "cc_enable_arenas", "cc_generic_services", "csharp_namespace", "deprecated", "go_package", "java_generate_equals_and_hash", "java_generic_services", "java_multiple_files", "java_outer_classname", "java_package", "java_string_check_utf8", "objc_class_prefix", "optimize_for", "py_generic_services", "uninterpreted_option" }; + private static readonly uint[] _fieldTags = new uint[] { 248, 128, 298, 184, 90, 160, 136, 80, 66, 10, 216, 290, 72, 144, 7994 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[9]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_FileOptions__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public FileOptions() { + OnConstruction(); + } + + partial void OnConstruction(); + + public FileOptions(FileOptions other) : this() { + javaPackage_ = other.javaPackage_; + javaOuterClassname_ = other.javaOuterClassname_; + javaMultipleFiles_ = other.javaMultipleFiles_; + javaGenerateEqualsAndHash_ = other.javaGenerateEqualsAndHash_; + javaStringCheckUtf8_ = other.javaStringCheckUtf8_; + optimizeFor_ = other.optimizeFor_; + goPackage_ = other.goPackage_; + ccGenericServices_ = other.ccGenericServices_; + javaGenericServices_ = other.javaGenericServices_; + pyGenericServices_ = other.pyGenericServices_; + deprecated_ = other.deprecated_; + ccEnableArenas_ = other.ccEnableArenas_; + objcClassPrefix_ = other.objcClassPrefix_; + csharpNamespace_ = other.csharpNamespace_; + uninterpretedOption_ = other.uninterpretedOption_.Clone(); + } + + public FileOptions Clone() { + return new FileOptions(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + uninterpretedOption_.Freeze(); + } + + public const int JavaPackageFieldNumber = 1; + private string javaPackage_ = ""; + internal string JavaPackage { + get { return javaPackage_; } + set { + pb::Freezable.CheckMutable(this); + javaPackage_ = value ?? ""; + } + } + + public const int JavaOuterClassnameFieldNumber = 8; + private string javaOuterClassname_ = ""; + internal string JavaOuterClassname { + get { return javaOuterClassname_; } + set { + pb::Freezable.CheckMutable(this); + javaOuterClassname_ = value ?? ""; + } + } + + public const int JavaMultipleFilesFieldNumber = 10; + private bool javaMultipleFiles_; + internal bool JavaMultipleFiles { + get { return javaMultipleFiles_; } + set { + pb::Freezable.CheckMutable(this); + javaMultipleFiles_ = value; + } + } + + public const int JavaGenerateEqualsAndHashFieldNumber = 20; + private bool javaGenerateEqualsAndHash_; + internal bool JavaGenerateEqualsAndHash { + get { return javaGenerateEqualsAndHash_; } + set { + pb::Freezable.CheckMutable(this); + javaGenerateEqualsAndHash_ = value; + } + } + + public const int JavaStringCheckUtf8FieldNumber = 27; + private bool javaStringCheckUtf8_; + internal bool JavaStringCheckUtf8 { + get { return javaStringCheckUtf8_; } + set { + pb::Freezable.CheckMutable(this); + javaStringCheckUtf8_ = value; + } + } + + public const int OptimizeForFieldNumber = 9; + private global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode optimizeFor_ = global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode.SPEED; + internal global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode OptimizeFor { + get { return optimizeFor_; } + set { + pb::Freezable.CheckMutable(this); + optimizeFor_ = value; + } + } + + public const int GoPackageFieldNumber = 11; + private string goPackage_ = ""; + internal string GoPackage { + get { return goPackage_; } + set { + pb::Freezable.CheckMutable(this); + goPackage_ = value ?? ""; + } + } + + public const int CcGenericServicesFieldNumber = 16; + private bool ccGenericServices_; + internal bool CcGenericServices { + get { return ccGenericServices_; } + set { + pb::Freezable.CheckMutable(this); + ccGenericServices_ = value; + } + } + + public const int JavaGenericServicesFieldNumber = 17; + private bool javaGenericServices_; + internal bool JavaGenericServices { + get { return javaGenericServices_; } + set { + pb::Freezable.CheckMutable(this); + javaGenericServices_ = value; + } + } + + public const int PyGenericServicesFieldNumber = 18; + private bool pyGenericServices_; + internal bool PyGenericServices { + get { return pyGenericServices_; } + set { + pb::Freezable.CheckMutable(this); + pyGenericServices_ = value; + } + } + + public const int DeprecatedFieldNumber = 23; + private bool deprecated_; + internal bool Deprecated { + get { return deprecated_; } + set { + pb::Freezable.CheckMutable(this); + deprecated_ = value; + } + } + + public const int CcEnableArenasFieldNumber = 31; + private bool ccEnableArenas_; + internal bool CcEnableArenas { + get { return ccEnableArenas_; } + set { + pb::Freezable.CheckMutable(this); + ccEnableArenas_ = value; + } + } + + public const int ObjcClassPrefixFieldNumber = 36; + private string objcClassPrefix_ = ""; + internal string ObjcClassPrefix { + get { return objcClassPrefix_; } + set { + pb::Freezable.CheckMutable(this); + objcClassPrefix_ = value ?? ""; + } + } + + public const int CsharpNamespaceFieldNumber = 37; + private string csharpNamespace_ = ""; + internal string CsharpNamespace { + get { return csharpNamespace_; } + set { + pb::Freezable.CheckMutable(this); + csharpNamespace_ = value ?? ""; + } + } + + public const int UninterpretedOptionFieldNumber = 999; + private static readonly pb::FieldCodec _repeated_uninterpretedOption_codec + = pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.Reflection.UninterpretedOption.Parser); + private readonly pbc::RepeatedField uninterpretedOption_ = new pbc::RepeatedField(); + internal pbc::RepeatedField UninterpretedOption { + get { return uninterpretedOption_; } + } + + public override bool Equals(object other) { + return Equals(other as FileOptions); + } + + public bool Equals(FileOptions other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (JavaPackage != other.JavaPackage) return false; + if (JavaOuterClassname != other.JavaOuterClassname) return false; + if (JavaMultipleFiles != other.JavaMultipleFiles) return false; + if (JavaGenerateEqualsAndHash != other.JavaGenerateEqualsAndHash) return false; + if (JavaStringCheckUtf8 != other.JavaStringCheckUtf8) return false; + if (OptimizeFor != other.OptimizeFor) return false; + if (GoPackage != other.GoPackage) return false; + if (CcGenericServices != other.CcGenericServices) return false; + if (JavaGenericServices != other.JavaGenericServices) return false; + if (PyGenericServices != other.PyGenericServices) return false; + if (Deprecated != other.Deprecated) return false; + if (CcEnableArenas != other.CcEnableArenas) return false; + if (ObjcClassPrefix != other.ObjcClassPrefix) return false; + if (CsharpNamespace != other.CsharpNamespace) return false; + if(!uninterpretedOption_.Equals(other.uninterpretedOption_)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (JavaPackage.Length != 0) hash ^= JavaPackage.GetHashCode(); + if (JavaOuterClassname.Length != 0) hash ^= JavaOuterClassname.GetHashCode(); + if (JavaMultipleFiles != false) hash ^= JavaMultipleFiles.GetHashCode(); + if (JavaGenerateEqualsAndHash != false) hash ^= JavaGenerateEqualsAndHash.GetHashCode(); + if (JavaStringCheckUtf8 != false) hash ^= JavaStringCheckUtf8.GetHashCode(); + if (OptimizeFor != global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode.SPEED) hash ^= OptimizeFor.GetHashCode(); + if (GoPackage.Length != 0) hash ^= GoPackage.GetHashCode(); + if (CcGenericServices != false) hash ^= CcGenericServices.GetHashCode(); + if (JavaGenericServices != false) hash ^= JavaGenericServices.GetHashCode(); + if (PyGenericServices != false) hash ^= PyGenericServices.GetHashCode(); + if (Deprecated != false) hash ^= Deprecated.GetHashCode(); + if (CcEnableArenas != false) hash ^= CcEnableArenas.GetHashCode(); + if (ObjcClassPrefix.Length != 0) hash ^= ObjcClassPrefix.GetHashCode(); + if (CsharpNamespace.Length != 0) hash ^= CsharpNamespace.GetHashCode(); + hash ^= uninterpretedOption_.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (JavaPackage.Length != 0) { + output.WriteRawTag(10); + output.WriteString(JavaPackage); + } + if (JavaOuterClassname.Length != 0) { + output.WriteRawTag(66); + output.WriteString(JavaOuterClassname); + } + if (OptimizeFor != global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode.SPEED) { + output.WriteRawTag(72); + output.WriteEnum((int) OptimizeFor); + } + if (JavaMultipleFiles != false) { + output.WriteRawTag(80); + output.WriteBool(JavaMultipleFiles); + } + if (GoPackage.Length != 0) { + output.WriteRawTag(90); + output.WriteString(GoPackage); + } + if (CcGenericServices != false) { + output.WriteRawTag(128, 1); + output.WriteBool(CcGenericServices); + } + if (JavaGenericServices != false) { + output.WriteRawTag(136, 1); + output.WriteBool(JavaGenericServices); + } + if (PyGenericServices != false) { + output.WriteRawTag(144, 1); + output.WriteBool(PyGenericServices); + } + if (JavaGenerateEqualsAndHash != false) { + output.WriteRawTag(160, 1); + output.WriteBool(JavaGenerateEqualsAndHash); + } + if (Deprecated != false) { + output.WriteRawTag(184, 1); + output.WriteBool(Deprecated); + } + if (JavaStringCheckUtf8 != false) { + output.WriteRawTag(216, 1); + output.WriteBool(JavaStringCheckUtf8); + } + if (CcEnableArenas != false) { + output.WriteRawTag(248, 1); + output.WriteBool(CcEnableArenas); + } + if (ObjcClassPrefix.Length != 0) { + output.WriteRawTag(162, 2); + output.WriteString(ObjcClassPrefix); + } + if (CsharpNamespace.Length != 0) { + output.WriteRawTag(170, 2); + output.WriteString(CsharpNamespace); + } + uninterpretedOption_.WriteTo(output, _repeated_uninterpretedOption_codec); + } + + public int CalculateSize() { + int size = 0; + if (JavaPackage.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(JavaPackage); + } + if (JavaOuterClassname.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(JavaOuterClassname); + } + if (JavaMultipleFiles != false) { + size += 1 + 1; + } + if (JavaGenerateEqualsAndHash != false) { + size += 2 + 1; + } + if (JavaStringCheckUtf8 != false) { + size += 2 + 1; + } + if (OptimizeFor != global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode.SPEED) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) OptimizeFor); + } + if (GoPackage.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(GoPackage); + } + if (CcGenericServices != false) { + size += 2 + 1; + } + if (JavaGenericServices != false) { + size += 2 + 1; + } + if (PyGenericServices != false) { + size += 2 + 1; + } + if (Deprecated != false) { + size += 2 + 1; + } + if (CcEnableArenas != false) { + size += 2 + 1; + } + if (ObjcClassPrefix.Length != 0) { + size += 2 + pb::CodedOutputStream.ComputeStringSize(ObjcClassPrefix); + } + if (CsharpNamespace.Length != 0) { + size += 2 + pb::CodedOutputStream.ComputeStringSize(CsharpNamespace); + } + size += uninterpretedOption_.CalculateSize(_repeated_uninterpretedOption_codec); + return size; + } + + public void MergeFrom(FileOptions other) { + if (other == null) { + return; + } + if (other.JavaPackage.Length != 0) { + JavaPackage = other.JavaPackage; + } + if (other.JavaOuterClassname.Length != 0) { + JavaOuterClassname = other.JavaOuterClassname; + } + if (other.JavaMultipleFiles != false) { + JavaMultipleFiles = other.JavaMultipleFiles; + } + if (other.JavaGenerateEqualsAndHash != false) { + JavaGenerateEqualsAndHash = other.JavaGenerateEqualsAndHash; + } + if (other.JavaStringCheckUtf8 != false) { + JavaStringCheckUtf8 = other.JavaStringCheckUtf8; + } + if (other.OptimizeFor != global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode.SPEED) { + OptimizeFor = other.OptimizeFor; + } + if (other.GoPackage.Length != 0) { + GoPackage = other.GoPackage; + } + if (other.CcGenericServices != false) { + CcGenericServices = other.CcGenericServices; + } + if (other.JavaGenericServices != false) { + JavaGenericServices = other.JavaGenericServices; + } + if (other.PyGenericServices != false) { + PyGenericServices = other.PyGenericServices; + } + if (other.Deprecated != false) { + Deprecated = other.Deprecated; + } + if (other.CcEnableArenas != false) { + CcEnableArenas = other.CcEnableArenas; + } + if (other.ObjcClassPrefix.Length != 0) { + ObjcClassPrefix = other.ObjcClassPrefix; + } + if (other.CsharpNamespace.Length != 0) { + CsharpNamespace = other.CsharpNamespace; + } + uninterpretedOption_.Add(other.uninterpretedOption_); + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + 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 7994: { + uninterpretedOption_.AddEntriesFrom(input, _repeated_uninterpretedOption_codec); + break; + } + } + } + } + + #region Nested types + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static partial class Types { + internal enum OptimizeMode { + SPEED = 1, + CODE_SIZE = 2, + LITE_RUNTIME = 3, + } + + } + #endregion + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + internal sealed partial class MessageOptions : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MessageOptions()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "deprecated", "map_entry", "message_set_wire_format", "no_standard_descriptor_accessor", "uninterpreted_option" }; + private static readonly uint[] _fieldTags = new uint[] { 24, 56, 8, 16, 7994 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[10]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_MessageOptions__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public MessageOptions() { + OnConstruction(); + } + + partial void OnConstruction(); + + public MessageOptions(MessageOptions other) : this() { + messageSetWireFormat_ = other.messageSetWireFormat_; + noStandardDescriptorAccessor_ = other.noStandardDescriptorAccessor_; + deprecated_ = other.deprecated_; + mapEntry_ = other.mapEntry_; + uninterpretedOption_ = other.uninterpretedOption_.Clone(); + } + + public MessageOptions Clone() { + return new MessageOptions(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + uninterpretedOption_.Freeze(); + } + + public const int MessageSetWireFormatFieldNumber = 1; + private bool messageSetWireFormat_; + internal bool MessageSetWireFormat { + get { return messageSetWireFormat_; } + set { + pb::Freezable.CheckMutable(this); + messageSetWireFormat_ = value; + } + } + + public const int NoStandardDescriptorAccessorFieldNumber = 2; + private bool noStandardDescriptorAccessor_; + internal bool NoStandardDescriptorAccessor { + get { return noStandardDescriptorAccessor_; } + set { + pb::Freezable.CheckMutable(this); + noStandardDescriptorAccessor_ = value; + } + } + + public const int DeprecatedFieldNumber = 3; + private bool deprecated_; + internal bool Deprecated { + get { return deprecated_; } + set { + pb::Freezable.CheckMutable(this); + deprecated_ = value; + } + } + + public const int MapEntryFieldNumber = 7; + private bool mapEntry_; + internal bool MapEntry { + get { return mapEntry_; } + set { + pb::Freezable.CheckMutable(this); + mapEntry_ = value; + } + } + + public const int UninterpretedOptionFieldNumber = 999; + private static readonly pb::FieldCodec _repeated_uninterpretedOption_codec + = pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.Reflection.UninterpretedOption.Parser); + private readonly pbc::RepeatedField uninterpretedOption_ = new pbc::RepeatedField(); + internal pbc::RepeatedField UninterpretedOption { + get { return uninterpretedOption_; } + } + + public override bool Equals(object other) { + return Equals(other as MessageOptions); + } + + public bool Equals(MessageOptions other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (MessageSetWireFormat != other.MessageSetWireFormat) return false; + if (NoStandardDescriptorAccessor != other.NoStandardDescriptorAccessor) return false; + if (Deprecated != other.Deprecated) return false; + if (MapEntry != other.MapEntry) return false; + if(!uninterpretedOption_.Equals(other.uninterpretedOption_)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (MessageSetWireFormat != false) hash ^= MessageSetWireFormat.GetHashCode(); + if (NoStandardDescriptorAccessor != false) hash ^= NoStandardDescriptorAccessor.GetHashCode(); + if (Deprecated != false) hash ^= Deprecated.GetHashCode(); + if (MapEntry != false) hash ^= MapEntry.GetHashCode(); + hash ^= uninterpretedOption_.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (MessageSetWireFormat != false) { + output.WriteRawTag(8); + output.WriteBool(MessageSetWireFormat); + } + if (NoStandardDescriptorAccessor != false) { + output.WriteRawTag(16); + output.WriteBool(NoStandardDescriptorAccessor); + } + if (Deprecated != false) { + output.WriteRawTag(24); + output.WriteBool(Deprecated); + } + if (MapEntry != false) { + output.WriteRawTag(56); + output.WriteBool(MapEntry); + } + uninterpretedOption_.WriteTo(output, _repeated_uninterpretedOption_codec); + } + + public int CalculateSize() { + int size = 0; + if (MessageSetWireFormat != false) { + size += 1 + 1; + } + if (NoStandardDescriptorAccessor != false) { + size += 1 + 1; + } + if (Deprecated != false) { + size += 1 + 1; + } + if (MapEntry != false) { + size += 1 + 1; + } + size += uninterpretedOption_.CalculateSize(_repeated_uninterpretedOption_codec); + return size; + } + + public void MergeFrom(MessageOptions other) { + if (other == null) { + return; + } + if (other.MessageSetWireFormat != false) { + MessageSetWireFormat = other.MessageSetWireFormat; + } + if (other.NoStandardDescriptorAccessor != false) { + NoStandardDescriptorAccessor = other.NoStandardDescriptorAccessor; + } + if (other.Deprecated != false) { + Deprecated = other.Deprecated; + } + if (other.MapEntry != false) { + MapEntry = other.MapEntry; + } + uninterpretedOption_.Add(other.uninterpretedOption_); + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 8: { + MessageSetWireFormat = input.ReadBool(); + break; + } + case 16: { + NoStandardDescriptorAccessor = input.ReadBool(); + break; + } + case 24: { + Deprecated = input.ReadBool(); + break; + } + case 56: { + MapEntry = input.ReadBool(); + break; + } + case 7994: { + uninterpretedOption_.AddEntriesFrom(input, _repeated_uninterpretedOption_codec); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + internal sealed partial class FieldOptions : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FieldOptions()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "ctype", "deprecated", "jstype", "lazy", "packed", "uninterpreted_option", "weak" }; + private static readonly uint[] _fieldTags = new uint[] { 8, 24, 48, 40, 16, 7994, 80 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[11]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_FieldOptions__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public FieldOptions() { + OnConstruction(); + } + + partial void OnConstruction(); + + public FieldOptions(FieldOptions other) : this() { + ctype_ = other.ctype_; + packed_ = other.packed_; + jstype_ = other.jstype_; + lazy_ = other.lazy_; + deprecated_ = other.deprecated_; + weak_ = other.weak_; + uninterpretedOption_ = other.uninterpretedOption_.Clone(); + } + + public FieldOptions Clone() { + return new FieldOptions(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + uninterpretedOption_.Freeze(); + } + + public const int CtypeFieldNumber = 1; + private global::Google.Protobuf.Reflection.FieldOptions.Types.CType ctype_ = global::Google.Protobuf.Reflection.FieldOptions.Types.CType.STRING; + internal global::Google.Protobuf.Reflection.FieldOptions.Types.CType Ctype { + get { return ctype_; } + set { + pb::Freezable.CheckMutable(this); + ctype_ = value; + } + } + + public const int PackedFieldNumber = 2; + private bool packed_; + internal bool Packed { + get { return packed_; } + set { + pb::Freezable.CheckMutable(this); + packed_ = value; + } + } + + public const int JstypeFieldNumber = 6; + private global::Google.Protobuf.Reflection.FieldOptions.Types.JSType jstype_ = global::Google.Protobuf.Reflection.FieldOptions.Types.JSType.JS_NORMAL; + internal global::Google.Protobuf.Reflection.FieldOptions.Types.JSType Jstype { + get { return jstype_; } + set { + pb::Freezable.CheckMutable(this); + jstype_ = value; + } + } + + public const int LazyFieldNumber = 5; + private bool lazy_; + internal bool Lazy { + get { return lazy_; } + set { + pb::Freezable.CheckMutable(this); + lazy_ = value; + } + } + + public const int DeprecatedFieldNumber = 3; + private bool deprecated_; + internal bool Deprecated { + get { return deprecated_; } + set { + pb::Freezable.CheckMutable(this); + deprecated_ = value; + } + } + + public const int WeakFieldNumber = 10; + private bool weak_; + internal bool Weak { + get { return weak_; } + set { + pb::Freezable.CheckMutable(this); + weak_ = value; + } + } + + public const int UninterpretedOptionFieldNumber = 999; + private static readonly pb::FieldCodec _repeated_uninterpretedOption_codec + = pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.Reflection.UninterpretedOption.Parser); + private readonly pbc::RepeatedField uninterpretedOption_ = new pbc::RepeatedField(); + internal pbc::RepeatedField UninterpretedOption { + get { return uninterpretedOption_; } + } + + public override bool Equals(object other) { + return Equals(other as FieldOptions); + } + + public bool Equals(FieldOptions other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Ctype != other.Ctype) return false; + if (Packed != other.Packed) return false; + if (Jstype != other.Jstype) return false; + if (Lazy != other.Lazy) return false; + if (Deprecated != other.Deprecated) return false; + if (Weak != other.Weak) return false; + if(!uninterpretedOption_.Equals(other.uninterpretedOption_)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Ctype != global::Google.Protobuf.Reflection.FieldOptions.Types.CType.STRING) hash ^= Ctype.GetHashCode(); + if (Packed != false) hash ^= Packed.GetHashCode(); + if (Jstype != global::Google.Protobuf.Reflection.FieldOptions.Types.JSType.JS_NORMAL) hash ^= Jstype.GetHashCode(); + if (Lazy != false) hash ^= Lazy.GetHashCode(); + if (Deprecated != false) hash ^= Deprecated.GetHashCode(); + if (Weak != false) hash ^= Weak.GetHashCode(); + hash ^= uninterpretedOption_.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Ctype != global::Google.Protobuf.Reflection.FieldOptions.Types.CType.STRING) { + output.WriteRawTag(8); + output.WriteEnum((int) Ctype); + } + if (Packed != false) { + output.WriteRawTag(16); + output.WriteBool(Packed); + } + if (Deprecated != false) { + output.WriteRawTag(24); + output.WriteBool(Deprecated); + } + if (Lazy != false) { + output.WriteRawTag(40); + output.WriteBool(Lazy); + } + if (Jstype != global::Google.Protobuf.Reflection.FieldOptions.Types.JSType.JS_NORMAL) { + output.WriteRawTag(48); + output.WriteEnum((int) Jstype); + } + if (Weak != false) { + output.WriteRawTag(80); + output.WriteBool(Weak); + } + uninterpretedOption_.WriteTo(output, _repeated_uninterpretedOption_codec); + } + + public int CalculateSize() { + int size = 0; + if (Ctype != global::Google.Protobuf.Reflection.FieldOptions.Types.CType.STRING) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Ctype); + } + if (Packed != false) { + size += 1 + 1; + } + if (Jstype != global::Google.Protobuf.Reflection.FieldOptions.Types.JSType.JS_NORMAL) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Jstype); + } + if (Lazy != false) { + size += 1 + 1; + } + if (Deprecated != false) { + size += 1 + 1; + } + if (Weak != false) { + size += 1 + 1; + } + size += uninterpretedOption_.CalculateSize(_repeated_uninterpretedOption_codec); + return size; + } + + public void MergeFrom(FieldOptions other) { + if (other == null) { + return; + } + if (other.Ctype != global::Google.Protobuf.Reflection.FieldOptions.Types.CType.STRING) { + Ctype = other.Ctype; + } + if (other.Packed != false) { + Packed = other.Packed; + } + if (other.Jstype != global::Google.Protobuf.Reflection.FieldOptions.Types.JSType.JS_NORMAL) { + Jstype = other.Jstype; + } + if (other.Lazy != false) { + Lazy = other.Lazy; + } + if (other.Deprecated != false) { + Deprecated = other.Deprecated; + } + if (other.Weak != false) { + Weak = other.Weak; + } + uninterpretedOption_.Add(other.uninterpretedOption_); + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + 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(input, _repeated_uninterpretedOption_codec); + break; + } + } + } + } + + #region Nested types + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static partial class Types { + internal enum CType { + STRING = 0, + CORD = 1, + STRING_PIECE = 2, + } + + internal enum JSType { + JS_NORMAL = 0, + JS_STRING = 1, + JS_NUMBER = 2, + } + + } + #endregion + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + internal sealed partial class EnumOptions : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new EnumOptions()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "allow_alias", "deprecated", "uninterpreted_option" }; + private static readonly uint[] _fieldTags = new uint[] { 16, 24, 7994 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[12]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_EnumOptions__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public EnumOptions() { + OnConstruction(); + } + + partial void OnConstruction(); + + public EnumOptions(EnumOptions other) : this() { + allowAlias_ = other.allowAlias_; + deprecated_ = other.deprecated_; + uninterpretedOption_ = other.uninterpretedOption_.Clone(); + } + + public EnumOptions Clone() { + return new EnumOptions(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + uninterpretedOption_.Freeze(); + } + + public const int AllowAliasFieldNumber = 2; + private bool allowAlias_; + internal bool AllowAlias { + get { return allowAlias_; } + set { + pb::Freezable.CheckMutable(this); + allowAlias_ = value; + } + } + + public const int DeprecatedFieldNumber = 3; + private bool deprecated_; + internal bool Deprecated { + get { return deprecated_; } + set { + pb::Freezable.CheckMutable(this); + deprecated_ = value; + } + } + + public const int UninterpretedOptionFieldNumber = 999; + private static readonly pb::FieldCodec _repeated_uninterpretedOption_codec + = pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.Reflection.UninterpretedOption.Parser); + private readonly pbc::RepeatedField uninterpretedOption_ = new pbc::RepeatedField(); + internal pbc::RepeatedField UninterpretedOption { + get { return uninterpretedOption_; } + } + + public override bool Equals(object other) { + return Equals(other as EnumOptions); + } + + public bool Equals(EnumOptions other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (AllowAlias != other.AllowAlias) return false; + if (Deprecated != other.Deprecated) return false; + if(!uninterpretedOption_.Equals(other.uninterpretedOption_)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (AllowAlias != false) hash ^= AllowAlias.GetHashCode(); + if (Deprecated != false) hash ^= Deprecated.GetHashCode(); + hash ^= uninterpretedOption_.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (AllowAlias != false) { + output.WriteRawTag(16); + output.WriteBool(AllowAlias); + } + if (Deprecated != false) { + output.WriteRawTag(24); + output.WriteBool(Deprecated); + } + uninterpretedOption_.WriteTo(output, _repeated_uninterpretedOption_codec); + } + + public int CalculateSize() { + int size = 0; + if (AllowAlias != false) { + size += 1 + 1; + } + if (Deprecated != false) { + size += 1 + 1; + } + size += uninterpretedOption_.CalculateSize(_repeated_uninterpretedOption_codec); + return size; + } + + public void MergeFrom(EnumOptions other) { + if (other == null) { + return; + } + if (other.AllowAlias != false) { + AllowAlias = other.AllowAlias; + } + if (other.Deprecated != false) { + Deprecated = other.Deprecated; + } + uninterpretedOption_.Add(other.uninterpretedOption_); + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 16: { + AllowAlias = input.ReadBool(); + break; + } + case 24: { + Deprecated = input.ReadBool(); + break; + } + case 7994: { + uninterpretedOption_.AddEntriesFrom(input, _repeated_uninterpretedOption_codec); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + internal sealed partial class EnumValueOptions : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new EnumValueOptions()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "deprecated", "uninterpreted_option" }; + private static readonly uint[] _fieldTags = new uint[] { 8, 7994 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[13]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_EnumValueOptions__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public EnumValueOptions() { + OnConstruction(); + } + + partial void OnConstruction(); + + public EnumValueOptions(EnumValueOptions other) : this() { + deprecated_ = other.deprecated_; + uninterpretedOption_ = other.uninterpretedOption_.Clone(); + } + + public EnumValueOptions Clone() { + return new EnumValueOptions(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + uninterpretedOption_.Freeze(); + } + + public const int DeprecatedFieldNumber = 1; + private bool deprecated_; + internal bool Deprecated { + get { return deprecated_; } + set { + pb::Freezable.CheckMutable(this); + deprecated_ = value; + } + } + + public const int UninterpretedOptionFieldNumber = 999; + private static readonly pb::FieldCodec _repeated_uninterpretedOption_codec + = pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.Reflection.UninterpretedOption.Parser); + private readonly pbc::RepeatedField uninterpretedOption_ = new pbc::RepeatedField(); + internal pbc::RepeatedField UninterpretedOption { + get { return uninterpretedOption_; } + } + + public override bool Equals(object other) { + return Equals(other as EnumValueOptions); + } + + public bool Equals(EnumValueOptions other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Deprecated != other.Deprecated) return false; + if(!uninterpretedOption_.Equals(other.uninterpretedOption_)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Deprecated != false) hash ^= Deprecated.GetHashCode(); + hash ^= uninterpretedOption_.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Deprecated != false) { + output.WriteRawTag(8); + output.WriteBool(Deprecated); + } + uninterpretedOption_.WriteTo(output, _repeated_uninterpretedOption_codec); + } + + public int CalculateSize() { + int size = 0; + if (Deprecated != false) { + size += 1 + 1; + } + size += uninterpretedOption_.CalculateSize(_repeated_uninterpretedOption_codec); + return size; + } + + public void MergeFrom(EnumValueOptions other) { + if (other == null) { + return; + } + if (other.Deprecated != false) { + Deprecated = other.Deprecated; + } + uninterpretedOption_.Add(other.uninterpretedOption_); + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 8: { + Deprecated = input.ReadBool(); + break; + } + case 7994: { + uninterpretedOption_.AddEntriesFrom(input, _repeated_uninterpretedOption_codec); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + internal sealed partial class ServiceOptions : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ServiceOptions()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "deprecated", "uninterpreted_option" }; + private static readonly uint[] _fieldTags = new uint[] { 264, 7994 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[14]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_ServiceOptions__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public ServiceOptions() { + OnConstruction(); + } + + partial void OnConstruction(); + + public ServiceOptions(ServiceOptions other) : this() { + deprecated_ = other.deprecated_; + uninterpretedOption_ = other.uninterpretedOption_.Clone(); + } + + public ServiceOptions Clone() { + return new ServiceOptions(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + uninterpretedOption_.Freeze(); + } + + public const int DeprecatedFieldNumber = 33; + private bool deprecated_; + internal bool Deprecated { + get { return deprecated_; } + set { + pb::Freezable.CheckMutable(this); + deprecated_ = value; + } + } + + public const int UninterpretedOptionFieldNumber = 999; + private static readonly pb::FieldCodec _repeated_uninterpretedOption_codec + = pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.Reflection.UninterpretedOption.Parser); + private readonly pbc::RepeatedField uninterpretedOption_ = new pbc::RepeatedField(); + internal pbc::RepeatedField UninterpretedOption { + get { return uninterpretedOption_; } + } + + public override bool Equals(object other) { + return Equals(other as ServiceOptions); + } + + public bool Equals(ServiceOptions other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Deprecated != other.Deprecated) return false; + if(!uninterpretedOption_.Equals(other.uninterpretedOption_)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Deprecated != false) hash ^= Deprecated.GetHashCode(); + hash ^= uninterpretedOption_.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Deprecated != false) { + output.WriteRawTag(136, 2); + output.WriteBool(Deprecated); + } + uninterpretedOption_.WriteTo(output, _repeated_uninterpretedOption_codec); + } + + public int CalculateSize() { + int size = 0; + if (Deprecated != false) { + size += 2 + 1; + } + size += uninterpretedOption_.CalculateSize(_repeated_uninterpretedOption_codec); + return size; + } + + public void MergeFrom(ServiceOptions other) { + if (other == null) { + return; + } + if (other.Deprecated != false) { + Deprecated = other.Deprecated; + } + uninterpretedOption_.Add(other.uninterpretedOption_); + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 264: { + Deprecated = input.ReadBool(); + break; + } + case 7994: { + uninterpretedOption_.AddEntriesFrom(input, _repeated_uninterpretedOption_codec); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + internal sealed partial class MethodOptions : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MethodOptions()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "deprecated", "uninterpreted_option" }; + private static readonly uint[] _fieldTags = new uint[] { 264, 7994 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[15]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_MethodOptions__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public MethodOptions() { + OnConstruction(); + } + + partial void OnConstruction(); + + public MethodOptions(MethodOptions other) : this() { + deprecated_ = other.deprecated_; + uninterpretedOption_ = other.uninterpretedOption_.Clone(); + } + + public MethodOptions Clone() { + return new MethodOptions(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + uninterpretedOption_.Freeze(); + } + + public const int DeprecatedFieldNumber = 33; + private bool deprecated_; + internal bool Deprecated { + get { return deprecated_; } + set { + pb::Freezable.CheckMutable(this); + deprecated_ = value; + } + } + + public const int UninterpretedOptionFieldNumber = 999; + private static readonly pb::FieldCodec _repeated_uninterpretedOption_codec + = pb::FieldCodec.ForMessage(7994, global::Google.Protobuf.Reflection.UninterpretedOption.Parser); + private readonly pbc::RepeatedField uninterpretedOption_ = new pbc::RepeatedField(); + internal pbc::RepeatedField UninterpretedOption { + get { return uninterpretedOption_; } + } + + public override bool Equals(object other) { + return Equals(other as MethodOptions); + } + + public bool Equals(MethodOptions other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Deprecated != other.Deprecated) return false; + if(!uninterpretedOption_.Equals(other.uninterpretedOption_)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Deprecated != false) hash ^= Deprecated.GetHashCode(); + hash ^= uninterpretedOption_.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Deprecated != false) { + output.WriteRawTag(136, 2); + output.WriteBool(Deprecated); + } + uninterpretedOption_.WriteTo(output, _repeated_uninterpretedOption_codec); + } + + public int CalculateSize() { + int size = 0; + if (Deprecated != false) { + size += 2 + 1; + } + size += uninterpretedOption_.CalculateSize(_repeated_uninterpretedOption_codec); + return size; + } + + public void MergeFrom(MethodOptions other) { + if (other == null) { + return; + } + if (other.Deprecated != false) { + Deprecated = other.Deprecated; + } + uninterpretedOption_.Add(other.uninterpretedOption_); + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 264: { + Deprecated = input.ReadBool(); + break; + } + case 7994: { + uninterpretedOption_.AddEntriesFrom(input, _repeated_uninterpretedOption_codec); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + internal sealed partial class UninterpretedOption : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new UninterpretedOption()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "aggregate_value", "double_value", "identifier_value", "name", "negative_int_value", "positive_int_value", "string_value" }; + private static readonly uint[] _fieldTags = new uint[] { 66, 49, 26, 18, 40, 32, 58 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[16]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_UninterpretedOption__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public UninterpretedOption() { + OnConstruction(); + } + + partial void OnConstruction(); + + public UninterpretedOption(UninterpretedOption other) : this() { + name_ = other.name_.Clone(); + identifierValue_ = other.identifierValue_; + positiveIntValue_ = other.positiveIntValue_; + negativeIntValue_ = other.negativeIntValue_; + doubleValue_ = other.doubleValue_; + stringValue_ = other.stringValue_; + aggregateValue_ = other.aggregateValue_; + } + + public UninterpretedOption Clone() { + return new UninterpretedOption(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + name_.Freeze(); + } + + public const int NameFieldNumber = 2; + private static readonly pb::FieldCodec _repeated_name_codec + = pb::FieldCodec.ForMessage(18, global::Google.Protobuf.Reflection.UninterpretedOption.Types.NamePart.Parser); + private readonly pbc::RepeatedField name_ = new pbc::RepeatedField(); + internal pbc::RepeatedField Name { + get { return name_; } + } + + public const int IdentifierValueFieldNumber = 3; + private string identifierValue_ = ""; + internal string IdentifierValue { + get { return identifierValue_; } + set { + pb::Freezable.CheckMutable(this); + identifierValue_ = value ?? ""; + } + } + + public const int PositiveIntValueFieldNumber = 4; + private ulong positiveIntValue_; + internal ulong PositiveIntValue { + get { return positiveIntValue_; } + set { + pb::Freezable.CheckMutable(this); + positiveIntValue_ = value; + } + } + + public const int NegativeIntValueFieldNumber = 5; + private long negativeIntValue_; + internal long NegativeIntValue { + get { return negativeIntValue_; } + set { + pb::Freezable.CheckMutable(this); + negativeIntValue_ = value; + } + } + + public const int DoubleValueFieldNumber = 6; + private double doubleValue_; + internal double DoubleValue { + get { return doubleValue_; } + set { + pb::Freezable.CheckMutable(this); + doubleValue_ = value; + } + } + + public const int StringValueFieldNumber = 7; + private pb::ByteString stringValue_ = pb::ByteString.Empty; + internal pb::ByteString StringValue { + get { return stringValue_; } + set { + pb::Freezable.CheckMutable(this); + stringValue_ = value ?? pb::ByteString.Empty; + } + } + + public const int AggregateValueFieldNumber = 8; + private string aggregateValue_ = ""; + internal string AggregateValue { + get { return aggregateValue_; } + set { + pb::Freezable.CheckMutable(this); + aggregateValue_ = value ?? ""; + } + } + + public override bool Equals(object other) { + return Equals(other as UninterpretedOption); + } + + public bool Equals(UninterpretedOption other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if(!name_.Equals(other.name_)) return false; + if (IdentifierValue != other.IdentifierValue) return false; + if (PositiveIntValue != other.PositiveIntValue) return false; + if (NegativeIntValue != other.NegativeIntValue) return false; + if (DoubleValue != other.DoubleValue) return false; + if (StringValue != other.StringValue) return false; + if (AggregateValue != other.AggregateValue) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + hash ^= name_.GetHashCode(); + if (IdentifierValue.Length != 0) hash ^= IdentifierValue.GetHashCode(); + if (PositiveIntValue != 0UL) hash ^= PositiveIntValue.GetHashCode(); + if (NegativeIntValue != 0L) hash ^= NegativeIntValue.GetHashCode(); + if (DoubleValue != 0D) hash ^= DoubleValue.GetHashCode(); + if (StringValue.Length != 0) hash ^= StringValue.GetHashCode(); + if (AggregateValue.Length != 0) hash ^= AggregateValue.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + name_.WriteTo(output, _repeated_name_codec); + if (IdentifierValue.Length != 0) { + output.WriteRawTag(26); + output.WriteString(IdentifierValue); + } + if (PositiveIntValue != 0UL) { + output.WriteRawTag(32); + output.WriteUInt64(PositiveIntValue); + } + if (NegativeIntValue != 0L) { + output.WriteRawTag(40); + output.WriteInt64(NegativeIntValue); + } + if (DoubleValue != 0D) { + output.WriteRawTag(49); + output.WriteDouble(DoubleValue); + } + if (StringValue.Length != 0) { + output.WriteRawTag(58); + output.WriteBytes(StringValue); + } + if (AggregateValue.Length != 0) { + output.WriteRawTag(66); + output.WriteString(AggregateValue); + } + } + + public int CalculateSize() { + int size = 0; + size += name_.CalculateSize(_repeated_name_codec); + if (IdentifierValue.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(IdentifierValue); + } + if (PositiveIntValue != 0UL) { + size += 1 + pb::CodedOutputStream.ComputeUInt64Size(PositiveIntValue); + } + if (NegativeIntValue != 0L) { + size += 1 + pb::CodedOutputStream.ComputeInt64Size(NegativeIntValue); + } + if (DoubleValue != 0D) { + size += 1 + 8; + } + if (StringValue.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeBytesSize(StringValue); + } + if (AggregateValue.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(AggregateValue); + } + return size; + } + + public void MergeFrom(UninterpretedOption other) { + if (other == null) { + return; + } + name_.Add(other.name_); + if (other.IdentifierValue.Length != 0) { + IdentifierValue = other.IdentifierValue; + } + if (other.PositiveIntValue != 0UL) { + PositiveIntValue = other.PositiveIntValue; + } + if (other.NegativeIntValue != 0L) { + NegativeIntValue = other.NegativeIntValue; + } + if (other.DoubleValue != 0D) { + DoubleValue = other.DoubleValue; + } + if (other.StringValue.Length != 0) { + StringValue = other.StringValue; + } + if (other.AggregateValue.Length != 0) { + AggregateValue = other.AggregateValue; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 18: { + name_.AddEntriesFrom(input, _repeated_name_codec); + break; + } + case 26: { + IdentifierValue = input.ReadString(); + break; + } + case 32: { + PositiveIntValue = input.ReadUInt64(); + break; + } + case 40: { + NegativeIntValue = input.ReadInt64(); + break; + } + case 49: { + DoubleValue = input.ReadDouble(); + break; + } + case 58: { + StringValue = input.ReadBytes(); + break; + } + case 66: { + AggregateValue = input.ReadString(); + break; + } + } + } + } + + #region Nested types + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static partial class Types { + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + internal sealed partial class NamePart : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NamePart()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "is_extension", "name_part" }; + private static readonly uint[] _fieldTags = new uint[] { 16, 10 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.Reflection.UninterpretedOption.Descriptor.NestedTypes[0]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_UninterpretedOption_NamePart__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public NamePart() { + OnConstruction(); + } + + partial void OnConstruction(); + + public NamePart(NamePart other) : this() { + namePart_ = other.namePart_; + isExtension_ = other.isExtension_; + } + + public NamePart Clone() { + return new NamePart(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public const int NamePart_FieldNumber = 1; + private string namePart_ = ""; + internal string NamePart_ { + get { return namePart_; } + set { + pb::Freezable.CheckMutable(this); + namePart_ = value ?? ""; + } + } + + public const int IsExtensionFieldNumber = 2; + private bool isExtension_; + internal bool IsExtension { + get { return isExtension_; } + set { + pb::Freezable.CheckMutable(this); + isExtension_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as NamePart); + } + + public bool Equals(NamePart other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (NamePart_ != other.NamePart_) return false; + if (IsExtension != other.IsExtension) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (NamePart_.Length != 0) hash ^= NamePart_.GetHashCode(); + if (IsExtension != false) hash ^= IsExtension.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (NamePart_.Length != 0) { + output.WriteRawTag(10); + output.WriteString(NamePart_); + } + if (IsExtension != false) { + output.WriteRawTag(16); + output.WriteBool(IsExtension); + } + } + + public int CalculateSize() { + int size = 0; + if (NamePart_.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(NamePart_); + } + if (IsExtension != false) { + size += 1 + 1; + } + return size; + } + + public void MergeFrom(NamePart other) { + if (other == null) { + return; + } + if (other.NamePart_.Length != 0) { + NamePart_ = other.NamePart_; + } + if (other.IsExtension != false) { + IsExtension = other.IsExtension; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + NamePart_ = input.ReadString(); + break; + } + case 16: { + IsExtension = input.ReadBool(); + break; + } + } + } + } + + } + + } + #endregion + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + internal sealed partial class SourceCodeInfo : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new SourceCodeInfo()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "location" }; + private static readonly uint[] _fieldTags = new uint[] { 10 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.Descriptor.MessageTypes[17]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_SourceCodeInfo__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public SourceCodeInfo() { + OnConstruction(); + } + + partial void OnConstruction(); + + public SourceCodeInfo(SourceCodeInfo other) : this() { + location_ = other.location_.Clone(); + } + + public SourceCodeInfo Clone() { + return new SourceCodeInfo(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + location_.Freeze(); + } + + public const int LocationFieldNumber = 1; + private static readonly pb::FieldCodec _repeated_location_codec + = pb::FieldCodec.ForMessage(10, global::Google.Protobuf.Reflection.SourceCodeInfo.Types.Location.Parser); + private readonly pbc::RepeatedField location_ = new pbc::RepeatedField(); + internal pbc::RepeatedField Location { + get { return location_; } + } + + public override bool Equals(object other) { + return Equals(other as SourceCodeInfo); + } + + public bool Equals(SourceCodeInfo other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if(!location_.Equals(other.location_)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + hash ^= location_.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + location_.WriteTo(output, _repeated_location_codec); + } + + public int CalculateSize() { + int size = 0; + size += location_.CalculateSize(_repeated_location_codec); + return size; + } + + public void MergeFrom(SourceCodeInfo other) { + if (other == null) { + return; + } + location_.Add(other.location_); + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + location_.AddEntriesFrom(input, _repeated_location_codec); + break; + } + } + } + } + + #region Nested types + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static partial class Types { + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + internal sealed partial class Location : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Location()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "leading_comments", "leading_detached_comments", "path", "span", "trailing_comments" }; + private static readonly uint[] _fieldTags = new uint[] { 26, 50, 10, 18, 34 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.Reflection.SourceCodeInfo.Descriptor.NestedTypes[0]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.Reflection.DescriptorProtoFile.internal__static_google_protobuf_SourceCodeInfo_Location__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public Location() { + OnConstruction(); + } + + partial void OnConstruction(); + + public Location(Location other) : this() { + path_ = other.path_.Clone(); + span_ = other.span_.Clone(); + leadingComments_ = other.leadingComments_; + trailingComments_ = other.trailingComments_; + leadingDetachedComments_ = other.leadingDetachedComments_.Clone(); + } + + public Location Clone() { + return new Location(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + path_.Freeze(); + span_.Freeze(); + leadingDetachedComments_.Freeze(); + } + + public const int PathFieldNumber = 1; + private static readonly pb::FieldCodec _repeated_path_codec + = pb::FieldCodec.ForInt32(10); + private readonly pbc::RepeatedField path_ = new pbc::RepeatedField(); + internal pbc::RepeatedField Path { + get { return path_; } + } + + public const int SpanFieldNumber = 2; + private static readonly pb::FieldCodec _repeated_span_codec + = pb::FieldCodec.ForInt32(18); + private readonly pbc::RepeatedField span_ = new pbc::RepeatedField(); + internal pbc::RepeatedField Span { + get { return span_; } + } + + public const int LeadingCommentsFieldNumber = 3; + private string leadingComments_ = ""; + internal string LeadingComments { + get { return leadingComments_; } + set { + pb::Freezable.CheckMutable(this); + leadingComments_ = value ?? ""; + } + } + + public const int TrailingCommentsFieldNumber = 4; + private string trailingComments_ = ""; + internal string TrailingComments { + get { return trailingComments_; } + set { + pb::Freezable.CheckMutable(this); + trailingComments_ = value ?? ""; + } + } + + public const int LeadingDetachedCommentsFieldNumber = 6; + private static readonly pb::FieldCodec _repeated_leadingDetachedComments_codec + = pb::FieldCodec.ForString(50); + private readonly pbc::RepeatedField leadingDetachedComments_ = new pbc::RepeatedField(); + internal pbc::RepeatedField LeadingDetachedComments { + get { return leadingDetachedComments_; } + } + + public override bool Equals(object other) { + return Equals(other as Location); + } + + public bool Equals(Location other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if(!path_.Equals(other.path_)) return false; + if(!span_.Equals(other.span_)) return false; + if (LeadingComments != other.LeadingComments) return false; + if (TrailingComments != other.TrailingComments) return false; + if(!leadingDetachedComments_.Equals(other.leadingDetachedComments_)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + hash ^= path_.GetHashCode(); + hash ^= span_.GetHashCode(); + if (LeadingComments.Length != 0) hash ^= LeadingComments.GetHashCode(); + if (TrailingComments.Length != 0) hash ^= TrailingComments.GetHashCode(); + hash ^= leadingDetachedComments_.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + path_.WriteTo(output, _repeated_path_codec); + span_.WriteTo(output, _repeated_span_codec); + if (LeadingComments.Length != 0) { + output.WriteRawTag(26); + output.WriteString(LeadingComments); + } + if (TrailingComments.Length != 0) { + output.WriteRawTag(34); + output.WriteString(TrailingComments); + } + leadingDetachedComments_.WriteTo(output, _repeated_leadingDetachedComments_codec); + } + + public int CalculateSize() { + int size = 0; + size += path_.CalculateSize(_repeated_path_codec); + size += span_.CalculateSize(_repeated_span_codec); + if (LeadingComments.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(LeadingComments); + } + if (TrailingComments.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(TrailingComments); + } + size += leadingDetachedComments_.CalculateSize(_repeated_leadingDetachedComments_codec); + return size; + } + + public void MergeFrom(Location other) { + if (other == null) { + return; + } + path_.Add(other.path_); + span_.Add(other.span_); + if (other.LeadingComments.Length != 0) { + LeadingComments = other.LeadingComments; + } + if (other.TrailingComments.Length != 0) { + TrailingComments = other.TrailingComments; + } + leadingDetachedComments_.Add(other.leadingDetachedComments_); + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: + case 8: { + path_.AddEntriesFrom(input, _repeated_path_codec); + break; + } + case 18: + case 16: { + span_.AddEntriesFrom(input, _repeated_span_codec); + break; + } + case 26: { + LeadingComments = input.ReadString(); + break; + } + case 34: { + TrailingComments = input.ReadString(); + break; + } + case 50: { + leadingDetachedComments_.AddEntriesFrom(input, _repeated_leadingDetachedComments_codec); + break; + } + } + } + } + + } + + } + #endregion + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/csharp/src/Google.Protobuf/Reflection/DescriptorUtil.cs b/csharp/src/Google.Protobuf/Reflection/DescriptorUtil.cs new file mode 100644 index 00000000..af31dfb1 --- /dev/null +++ b/csharp/src/Google.Protobuf/Reflection/DescriptorUtil.cs @@ -0,0 +1,65 @@ +#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.Collections.Generic; +using System.Collections.ObjectModel; + +namespace Google.Protobuf.Reflection +{ + /// + /// Internal class containing utility methods when working with descriptors. + /// + internal static class DescriptorUtil + { + /// + /// Equivalent to Func[TInput, int, TOutput] but usable in .NET 2.0. Only used to convert + /// arrays. + /// + internal delegate TOutput IndexedConverter(TInput element, int index); + + /// + /// Converts the given array into a read-only list, applying the specified conversion to + /// each input element. + /// + internal static IList ConvertAndMakeReadOnly(IList input, + IndexedConverter + converter) + { + TOutput[] array = new TOutput[input.Count]; + for (int i = 0; i < array.Length; i++) + { + array[i] = converter(input[i], i); + } + return new ReadOnlyCollection(array); + } + } +} \ No newline at end of file diff --git a/csharp/src/Google.Protobuf/Reflection/DescriptorValidationException.cs b/csharp/src/Google.Protobuf/Reflection/DescriptorValidationException.cs new file mode 100644 index 00000000..143671db --- /dev/null +++ b/csharp/src/Google.Protobuf/Reflection/DescriptorValidationException.cs @@ -0,0 +1,80 @@ +#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; + +namespace Google.Protobuf.Reflection +{ + /// + /// Thrown when building descriptors fails because the source DescriptorProtos + /// are not valid. + /// + public sealed class DescriptorValidationException : Exception + { + private readonly String name; + private readonly string description; + + /// + /// The full name of the descriptor where the error occurred. + /// + public String ProblemSymbolName + { + get { return name; } + } + + /// + /// A human-readable description of the error. (The Message property + /// is made up of the descriptor's name and this description.) + /// + public string Description + { + get { return description; } + } + + internal DescriptorValidationException(IDescriptor problemDescriptor, string description) : + base(problemDescriptor.FullName + ": " + description) + { + // Note that problemDescriptor may be partially uninitialized, so we + // don't want to expose it directly to the user. So, we only provide + // the name and the original proto. + name = problemDescriptor.FullName; + this.description = description; + } + + internal DescriptorValidationException(IDescriptor problemDescriptor, string description, Exception cause) : + base(problemDescriptor.FullName + ": " + description, cause) + { + name = problemDescriptor.FullName; + this.description = description; + } + } +} \ No newline at end of file diff --git a/csharp/src/Google.Protobuf/Reflection/EnumDescriptor.cs b/csharp/src/Google.Protobuf/Reflection/EnumDescriptor.cs new file mode 100644 index 00000000..bf8f8c83 --- /dev/null +++ b/csharp/src/Google.Protobuf/Reflection/EnumDescriptor.cs @@ -0,0 +1,108 @@ +#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.Collections.Generic; + +namespace Google.Protobuf.Reflection +{ + /// + /// Descriptor for an enum type in a .proto file. + /// + public sealed class EnumDescriptor : DescriptorBase + { + private readonly EnumDescriptorProto proto; + private readonly MessageDescriptor containingType; + private readonly IList values; + + internal EnumDescriptor(EnumDescriptorProto proto, FileDescriptor file, MessageDescriptor parent, int index) + : base(file, file.ComputeFullName(parent, proto.Name), index) + { + this.proto = proto; + containingType = parent; + + if (proto.Value.Count == 0) + { + // We cannot allow enums with no values because this would mean there + // would be no valid default value for fields of this type. + throw new DescriptorValidationException(this, "Enums must contain at least one value."); + } + + values = DescriptorUtil.ConvertAndMakeReadOnly(proto.Value, + (value, i) => new EnumValueDescriptor(value, file, this, i)); + + File.DescriptorPool.AddSymbol(this); + } + + internal EnumDescriptorProto Proto { get { return proto; } } + + /// + /// The brief name of the descriptor's target. + /// + public override string Name { get { return proto.Name; } } + + /// + /// If this is a nested type, get the outer descriptor, otherwise null. + /// + public MessageDescriptor ContainingType + { + get { return containingType; } + } + + /// + /// An unmodifiable list of defined value descriptors for this enum. + /// + public IList Values + { + get { return values; } + } + + /// + /// Finds an enum value by number. If multiple enum values have the + /// same number, this returns the first defined value with that number. + /// If there is no value for the given number, this returns null. + /// + public EnumValueDescriptor FindValueByNumber(int number) + { + return File.DescriptorPool.FindEnumValueByNumber(this, number); + } + + /// + /// Finds an enum value by name. + /// + /// The unqualified name of the value (e.g. "FOO"). + /// The value's descriptor, or null if not found. + public EnumValueDescriptor FindValueByName(string name) + { + return File.DescriptorPool.FindSymbol(FullName + "." + name); + } + } +} \ No newline at end of file diff --git a/csharp/src/Google.Protobuf/Reflection/EnumValueDescriptor.cs b/csharp/src/Google.Protobuf/Reflection/EnumValueDescriptor.cs new file mode 100644 index 00000000..29833c4a --- /dev/null +++ b/csharp/src/Google.Protobuf/Reflection/EnumValueDescriptor.cs @@ -0,0 +1,61 @@ +#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.Reflection +{ + /// + /// Descriptor for a single enum value within an enum in a .proto file. + /// + public sealed class EnumValueDescriptor : DescriptorBase + { + private readonly EnumDescriptor enumDescriptor; + private readonly EnumValueDescriptorProto proto; + + internal EnumValueDescriptor(EnumValueDescriptorProto proto, FileDescriptor file, + EnumDescriptor parent, int index) + : base(file, parent.FullName + "." + proto.Name, index) + { + this.proto = proto; + enumDescriptor = parent; + file.DescriptorPool.AddSymbol(this); + file.DescriptorPool.AddEnumValueByNumber(this); + } + + internal EnumValueDescriptorProto Proto { get { return proto; } } + + public override string Name { get { return proto.Name; } } + + public int Number { get { return Proto.Number; } } + + public EnumDescriptor EnumDescriptor { get { return enumDescriptor; } } + } +} \ No newline at end of file diff --git a/csharp/src/Google.Protobuf/Reflection/FieldAccessorBase.cs b/csharp/src/Google.Protobuf/Reflection/FieldAccessorBase.cs new file mode 100644 index 00000000..39a63b47 --- /dev/null +++ b/csharp/src/Google.Protobuf/Reflection/FieldAccessorBase.cs @@ -0,0 +1,67 @@ +#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 System; +using System.Reflection; + +namespace Google.Protobuf.Reflection +{ + /// + /// Base class for field accessors. + /// + internal abstract class FieldAccessorBase : IFieldAccessor + { + private readonly Func getValueDelegate; + private readonly FieldDescriptor descriptor; + + internal FieldAccessorBase(Type type, string propertyName, FieldDescriptor descriptor) + { + PropertyInfo property = type.GetProperty(propertyName); + if (property == null || !property.CanRead) + { + throw new ArgumentException("Not all required properties/methods available"); + } + this.descriptor = descriptor; + getValueDelegate = ReflectionUtil.CreateFuncObjectObject(property.GetGetMethod()); + } + + public FieldDescriptor Descriptor { get { return descriptor; } } + + public object GetValue(object message) + { + return getValueDelegate(message); + } + + public abstract void Clear(object message); + public abstract void SetValue(object message, object value); + } +} diff --git a/csharp/src/Google.Protobuf/Reflection/FieldAccessorTable.cs b/csharp/src/Google.Protobuf/Reflection/FieldAccessorTable.cs new file mode 100644 index 00000000..24fcbc64 --- /dev/null +++ b/csharp/src/Google.Protobuf/Reflection/FieldAccessorTable.cs @@ -0,0 +1,97 @@ +#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; +using System.Collections.ObjectModel; + +namespace Google.Protobuf.Reflection +{ + /// + /// Provides access to fields in generated messages via reflection. + /// + public sealed class FieldAccessorTable + { + private readonly ReadOnlyCollection accessors; + private readonly ReadOnlyCollection oneofs; + private readonly MessageDescriptor descriptor; + + /// + /// Constructs a FieldAccessorTable for a particular message class. + /// Only one FieldAccessorTable should be constructed per class. + /// + /// The CLR type for the message. + /// The type's descriptor + /// The Pascal-case names of all the field-based properties in the message. + public FieldAccessorTable(Type type, MessageDescriptor descriptor, string[] propertyNames, string[] oneofPropertyNames) + { + this.descriptor = descriptor; + var accessorsArray = new IFieldAccessor[descriptor.Fields.Count]; + for (int i = 0; i < accessorsArray.Length; i++) + { + var field = descriptor.Fields[i]; + var name = propertyNames[i]; + accessorsArray[i] = + field.IsMap ? new MapFieldAccessor(type, name, field) + : field.IsRepeated ? new RepeatedFieldAccessor(type, name, field) + : (IFieldAccessor) new SingleFieldAccessor(type, name, field); + } + accessors = new ReadOnlyCollection(accessorsArray); + var oneofsArray = new OneofAccessor[descriptor.Oneofs.Count]; + for (int i = 0; i < oneofsArray.Length; i++) + { + var oneof = descriptor.Oneofs[i]; + oneofsArray[i] = new OneofAccessor(type, oneofPropertyNames[i], oneof); + } + oneofs = new ReadOnlyCollection(oneofsArray); + } + + // TODO: Validate the name here... should possibly make this type a more "general reflection access" type, + // bearing in mind the oneof parts to come as well. + /// + /// Returns all of the field accessors for the message type. + /// + public ReadOnlyCollection Accessors { get { return accessors; } } + + public ReadOnlyCollection Oneofs { get { return oneofs; } } + + // TODO: Review this, as it's easy to get confused between FieldNumber and Index. + // Currently only used to get an accessor related to a oneof... maybe just make that simpler? + public IFieldAccessor this[int fieldNumber] + { + get + { + FieldDescriptor field = descriptor.FindFieldByNumber(fieldNumber); + return accessors[field.Index]; + } + } + } +} \ No newline at end of file diff --git a/csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs b/csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs new file mode 100644 index 00000000..3d9d0d75 --- /dev/null +++ b/csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs @@ -0,0 +1,292 @@ +#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; + +namespace Google.Protobuf.Reflection +{ + /// + /// Descriptor for a field or extension within a message in a .proto file. + /// + public sealed class FieldDescriptor : DescriptorBase, IComparable + { + private readonly FieldDescriptorProto proto; + private EnumDescriptor enumType; + private MessageDescriptor messageType; + private readonly MessageDescriptor containingType; + private readonly OneofDescriptor containingOneof; + private FieldType fieldType; + + internal FieldDescriptor(FieldDescriptorProto proto, FileDescriptor file, + MessageDescriptor parent, int index) + : base(file, file.ComputeFullName(parent, proto.Name), index) + { + this.proto = proto; + if (proto.Type != 0) + { + fieldType = GetFieldTypeFromProtoType(proto.Type); + } + + if (FieldNumber <= 0) + { + throw new DescriptorValidationException(this, + "Field numbers must be positive integers."); + } + containingType = parent; + // OneofIndex "defaults" to -1 due to a hack in FieldDescriptor.OnConstruction. + if (proto.OneofIndex != -1) + { + if (proto.OneofIndex < 0 || proto.OneofIndex >= parent.Proto.OneofDecl.Count) + { + throw new DescriptorValidationException(this, + "FieldDescriptorProto.oneof_index is out of range for type " + parent.Name); + } + containingOneof = parent.Oneofs[proto.OneofIndex]; + } + + file.DescriptorPool.AddSymbol(this); + } + + /// + /// The brief name of the descriptor's target. + /// + public override string Name { get { return proto.Name; } } + + internal FieldDescriptorProto Proto { get { return proto; } } + + /// + /// Maps a field type as included in the .proto file to a FieldType. + /// + private static FieldType GetFieldTypeFromProtoType(FieldDescriptorProto.Types.Type type) + { + switch (type) + { + case FieldDescriptorProto.Types.Type.TYPE_DOUBLE: + return FieldType.Double; + case FieldDescriptorProto.Types.Type.TYPE_FLOAT: + return FieldType.Float; + case FieldDescriptorProto.Types.Type.TYPE_INT64: + return FieldType.Int64; + case FieldDescriptorProto.Types.Type.TYPE_UINT64: + return FieldType.UInt64; + case FieldDescriptorProto.Types.Type.TYPE_INT32: + return FieldType.Int32; + case FieldDescriptorProto.Types.Type.TYPE_FIXED64: + return FieldType.Fixed64; + case FieldDescriptorProto.Types.Type.TYPE_FIXED32: + return FieldType.Fixed32; + case FieldDescriptorProto.Types.Type.TYPE_BOOL: + return FieldType.Bool; + case FieldDescriptorProto.Types.Type.TYPE_STRING: + return FieldType.String; + case FieldDescriptorProto.Types.Type.TYPE_GROUP: + return FieldType.Group; + case FieldDescriptorProto.Types.Type.TYPE_MESSAGE: + return FieldType.Message; + case FieldDescriptorProto.Types.Type.TYPE_BYTES: + return FieldType.Bytes; + case FieldDescriptorProto.Types.Type.TYPE_UINT32: + return FieldType.UInt32; + case FieldDescriptorProto.Types.Type.TYPE_ENUM: + return FieldType.Enum; + case FieldDescriptorProto.Types.Type.TYPE_SFIXED32: + return FieldType.SFixed32; + case FieldDescriptorProto.Types.Type.TYPE_SFIXED64: + return FieldType.SFixed64; + case FieldDescriptorProto.Types.Type.TYPE_SINT32: + return FieldType.SInt32; + case FieldDescriptorProto.Types.Type.TYPE_SINT64: + return FieldType.SInt64; + default: + throw new ArgumentException("Invalid type specified"); + } + } + + public bool IsRepeated + { + get { return Proto.Label == FieldDescriptorProto.Types.Label.LABEL_REPEATED; } + } + + public bool IsMap + { + get { return fieldType == FieldType.Message && messageType.Proto.Options != null && messageType.Proto.Options.MapEntry; } + } + + public bool IsPacked + { + get { return Proto.Options != null && Proto.Options.Packed; } + } + + /// + /// Get the field's containing type. For extensions, this is the type being + /// extended, not the location where the extension was defined. See + /// . + /// + public MessageDescriptor ContainingType + { + get { return containingType; } + } + + public OneofDescriptor ContainingOneof + { + get { return containingOneof; } + } + + public FieldType FieldType + { + get { return fieldType; } + } + + public int FieldNumber + { + get { return Proto.Number; } + } + + /// + /// Compares this descriptor with another one, ordering in "canonical" order + /// which simply means ascending order by field number. + /// must be a field of the same type, i.e. the of + /// both fields must be the same. + /// + public int CompareTo(FieldDescriptor other) + { + if (other.containingType != containingType) + { + throw new ArgumentException("FieldDescriptors can only be compared to other FieldDescriptors " + + "for fields of the same message type."); + } + return FieldNumber - other.FieldNumber; + } + + /// + /// For enum fields, returns the field's type. + /// + public EnumDescriptor EnumType + { + get + { + if (fieldType != FieldType.Enum) + { + throw new InvalidOperationException("EnumType is only valid for enum fields."); + } + return enumType; + } + } + + /// + /// For embedded message and group fields, returns the field's type. + /// + public MessageDescriptor MessageType + { + get + { + if (fieldType != FieldType.Message) + { + throw new InvalidOperationException("MessageType is only valid for enum fields."); + } + return messageType; + } + } + + /// + /// Look up and cross-link all field types etc. + /// + internal void CrossLink() + { + if (Proto.TypeName != "") + { + IDescriptor typeDescriptor = + File.DescriptorPool.LookupSymbol(Proto.TypeName, this); + + if (Proto.Type != 0) + { + // Choose field type based on symbol. + if (typeDescriptor is MessageDescriptor) + { + fieldType = FieldType.Message; + } + else if (typeDescriptor is EnumDescriptor) + { + fieldType = FieldType.Enum; + } + else + { + throw new DescriptorValidationException(this, "\"" + Proto.TypeName + "\" is not a type."); + } + } + + if (fieldType == FieldType.Message) + { + if (!(typeDescriptor is MessageDescriptor)) + { + throw new DescriptorValidationException(this, + "\"" + Proto.TypeName + "\" is not a message type."); + } + messageType = (MessageDescriptor) typeDescriptor; + + if (Proto.DefaultValue != "") + { + throw new DescriptorValidationException(this, "Messages can't have default values."); + } + } + else if (fieldType == FieldType.Enum) + { + if (!(typeDescriptor is EnumDescriptor)) + { + throw new DescriptorValidationException(this, "\"" + Proto.TypeName + "\" is not an enum type."); + } + enumType = (EnumDescriptor) typeDescriptor; + } + else + { + throw new DescriptorValidationException(this, "Field with primitive type has type_name."); + } + } + else + { + if (fieldType == FieldType.Message || fieldType == FieldType.Enum) + { + throw new DescriptorValidationException(this, "Field with message or enum type missing type_name."); + } + } + + // Note: no attempt to perform any default value parsing + + File.DescriptorPool.AddFieldByNumber(this); + + if (containingType != null && containingType.Proto.Options != null && containingType.Proto.Options.MessageSetWireFormat) + { + throw new DescriptorValidationException(this, "MessageSet format is not supported."); + } + } + } +} \ No newline at end of file diff --git a/csharp/src/Google.Protobuf/Reflection/FieldType.cs b/csharp/src/Google.Protobuf/Reflection/FieldType.cs new file mode 100644 index 00000000..41fa702d --- /dev/null +++ b/csharp/src/Google.Protobuf/Reflection/FieldType.cs @@ -0,0 +1,60 @@ +#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.Reflection +{ + /// + /// Enumeration of all the possible field types. The odd formatting is to make it very clear + /// which attribute applies to which value, while maintaining a compact format. + /// + public enum FieldType + { + Double, + Float, + Int64, + UInt64, + Int32, + Fixed64, + Fixed32, + Bool, + String, + Group, + Message, + Bytes, + UInt32, + SFixed32, + SFixed64, + SInt32, + SInt64, + Enum + } +} \ No newline at end of file diff --git a/csharp/src/Google.Protobuf/Reflection/FileDescriptor.cs b/csharp/src/Google.Protobuf/Reflection/FileDescriptor.cs new file mode 100644 index 00000000..db393480 --- /dev/null +++ b/csharp/src/Google.Protobuf/Reflection/FileDescriptor.cs @@ -0,0 +1,352 @@ +#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; +using System.Collections.Generic; +using System.Collections.ObjectModel; + +namespace Google.Protobuf.Reflection +{ + /// + /// Describes a .proto file, including everything defined within. + /// IDescriptor is implemented such that the File property returns this descriptor, + /// and the FullName is the same as the Name. + /// + public sealed class FileDescriptor : IDescriptor + { + private readonly FileDescriptorProto proto; + private readonly IList messageTypes; + private readonly IList enumTypes; + private readonly IList services; + private readonly IList dependencies; + private readonly IList publicDependencies; + private readonly DescriptorPool pool; + + public enum ProtoSyntax + { + Proto2, + Proto3 + } + + public ProtoSyntax Syntax + { + get { return proto.Syntax == "proto3" ? ProtoSyntax.Proto3 : ProtoSyntax.Proto2; } + } + + private FileDescriptor(FileDescriptorProto proto, FileDescriptor[] dependencies, DescriptorPool pool, bool allowUnknownDependencies) + { + this.pool = pool; + this.proto = proto; + this.dependencies = new ReadOnlyCollection((FileDescriptor[]) dependencies.Clone()); + + publicDependencies = DeterminePublicDependencies(this, proto, dependencies, allowUnknownDependencies); + + pool.AddPackage(Package, this); + + messageTypes = DescriptorUtil.ConvertAndMakeReadOnly(proto.MessageType, + (message, index) => + new MessageDescriptor(message, this, null, index)); + + enumTypes = DescriptorUtil.ConvertAndMakeReadOnly(proto.EnumType, + (enumType, index) => + new EnumDescriptor(enumType, this, null, index)); + + services = DescriptorUtil.ConvertAndMakeReadOnly(proto.Service, + (service, index) => + new ServiceDescriptor(service, this, index)); + } + + /// + /// Computes the full name of a descriptor within this file, with an optional parent message. + /// + internal string ComputeFullName(MessageDescriptor parent, string name) + { + if (parent != null) + { + return parent.FullName + "." + name; + } + if (Package.Length > 0) + { + return Package + "." + name; + } + return name; + } + + /// + /// Extracts public dependencies from direct dependencies. This is a static method despite its + /// first parameter, as the value we're in the middle of constructing is only used for exceptions. + /// + private static IList DeterminePublicDependencies(FileDescriptor @this, FileDescriptorProto proto, FileDescriptor[] dependencies, bool allowUnknownDependencies) + { + var nameToFileMap = new Dictionary(); + foreach (var file in dependencies) + { + nameToFileMap[file.Name] = file; + } + var publicDependencies = new List(); + for (int i = 0; i < proto.PublicDependency.Count; i++) + { + int index = proto.PublicDependency[i]; + if (index < 0 || index >= proto.Dependency.Count) + { + throw new DescriptorValidationException(@this, "Invalid public dependency index."); + } + string name = proto.Dependency[index]; + FileDescriptor file = nameToFileMap[name]; + if (file == null) + { + if (!allowUnknownDependencies) + { + throw new DescriptorValidationException(@this, "Invalid public dependency: " + name); + } + // Ignore unknown dependencies. + } + else + { + publicDependencies.Add(file); + } + } + return new ReadOnlyCollection(publicDependencies); + } + + /// + /// The descriptor in its protocol message representation. + /// + internal FileDescriptorProto Proto + { + get { return proto; } + } + + /// + /// The file name. + /// + public string Name + { + get { return proto.Name; } + } + + /// + /// The package as declared in the .proto file. This may or may not + /// be equivalent to the .NET namespace of the generated classes. + /// + public string Package + { + get { return proto.Package; } + } + + /// + /// Unmodifiable list of top-level message types declared in this file. + /// + public IList MessageTypes + { + get { return messageTypes; } + } + + /// + /// Unmodifiable list of top-level enum types declared in this file. + /// + public IList EnumTypes + { + get { return enumTypes; } + } + + /// + /// Unmodifiable list of top-level services declared in this file. + /// + public IList Services + { + get { return services; } + } + + /// + /// Unmodifiable list of this file's dependencies (imports). + /// + public IList Dependencies + { + get { return dependencies; } + } + + /// + /// Unmodifiable list of this file's public dependencies (public imports). + /// + public IList PublicDependencies + { + get { return publicDependencies; } + } + + /// + /// Implementation of IDescriptor.FullName - just returns the same as Name. + /// + string IDescriptor.FullName + { + get { return Name; } + } + + /// + /// Implementation of IDescriptor.File - just returns this descriptor. + /// + FileDescriptor IDescriptor.File + { + get { return this; } + } + + /// + /// Pool containing symbol descriptors. + /// + internal DescriptorPool DescriptorPool + { + get { return pool; } + } + + /// + /// Finds a type (message, enum, service or extension) in the file by name. Does not find nested types. + /// + /// The unqualified type name to look for. + /// The type of descriptor to look for (or ITypeDescriptor for any) + /// The type's descriptor, or null if not found. + public T FindTypeByName(String name) + where T : class, IDescriptor + { + // Don't allow looking up nested types. This will make optimization + // easier later. + if (name.IndexOf('.') != -1) + { + return null; + } + if (Package.Length > 0) + { + name = Package + "." + name; + } + T result = pool.FindSymbol(name); + if (result != null && result.File == this) + { + return result; + } + return null; + } + + /// + /// Builds a FileDescriptor from its protocol buffer representation. + /// + /// The protocol message form of the FileDescriptor. + /// FileDescriptors corresponding to all of the + /// file's dependencies, in the exact order listed in the .proto file. May be null, + /// in which case it is treated as an empty array. + /// Whether unknown dependencies are ignored (true) or cause an exception to be thrown (false). + /// If is not + /// a valid descriptor. This can occur for a number of reasons, such as a field + /// having an undefined type or because two messages were defined with the same name. + private static FileDescriptor BuildFrom(FileDescriptorProto proto, FileDescriptor[] dependencies, bool allowUnknownDependencies) + { + // Building descriptors involves two steps: translating and linking. + // In the translation step (implemented by FileDescriptor's + // constructor), we build an object tree mirroring the + // FileDescriptorProto's tree and put all of the descriptors into the + // DescriptorPool's lookup tables. In the linking step, we look up all + // type references in the DescriptorPool, so that, for example, a + // FieldDescriptor for an embedded message contains a pointer directly + // to the Descriptor for that message's type. We also detect undefined + // types in the linking step. + if (dependencies == null) + { + dependencies = new FileDescriptor[0]; + } + + DescriptorPool pool = new DescriptorPool(dependencies); + FileDescriptor result = new FileDescriptor(proto, dependencies, pool, allowUnknownDependencies); + + // TODO(jonskeet): Reinstate these checks, or get rid of them entirely. They aren't in the Java code, + // and fail for the CustomOptions test right now. (We get "descriptor.proto" vs "google/protobuf/descriptor.proto".) + //if (dependencies.Length != proto.DependencyCount) + //{ + // throw new DescriptorValidationException(result, + // "Dependencies passed to FileDescriptor.BuildFrom() don't match " + + // "those listed in the FileDescriptorProto."); + //} + //for (int i = 0; i < proto.DependencyCount; i++) + //{ + // if (dependencies[i].Name != proto.DependencyList[i]) + // { + // throw new DescriptorValidationException(result, + // "Dependencies passed to FileDescriptor.BuildFrom() don't match " + + // "those listed in the FileDescriptorProto."); + // } + //} + + result.CrossLink(); + return result; + } + + private void CrossLink() + { + foreach (MessageDescriptor message in messageTypes) + { + message.CrossLink(); + } + + foreach (ServiceDescriptor service in services) + { + service.CrossLink(); + } + } + + public static FileDescriptor InternalBuildGeneratedFileFrom(byte[] descriptorData, + FileDescriptor[] dependencies) + { + FileDescriptorProto proto; + try + { + proto = FileDescriptorProto.Parser.ParseFrom(descriptorData); + } + catch (InvalidProtocolBufferException e) + { + throw new ArgumentException("Failed to parse protocol buffer descriptor for generated code.", e); + } + + try + { + // When building descriptors for generated code, we allow unknown + // dependencies by default. + return BuildFrom(proto, dependencies, true); + } + catch (DescriptorValidationException e) + { + throw new ArgumentException("Invalid embedded descriptor for \"" + proto.Name + "\".", e); + } + } + + public override string ToString() + { + return "FileDescriptor for " + proto.Name; + } + } +} \ No newline at end of file diff --git a/csharp/src/Google.Protobuf/Reflection/IDescriptor.cs b/csharp/src/Google.Protobuf/Reflection/IDescriptor.cs new file mode 100644 index 00000000..6506db1b --- /dev/null +++ b/csharp/src/Google.Protobuf/Reflection/IDescriptor.cs @@ -0,0 +1,44 @@ +#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.Reflection +{ + /// + /// Interface implemented by all descriptor types. + /// + public interface IDescriptor + { + string Name { get; } + string FullName { get; } + FileDescriptor File { get; } + } +} \ No newline at end of file diff --git a/csharp/src/Google.Protobuf/Reflection/IFieldAccessor.cs b/csharp/src/Google.Protobuf/Reflection/IFieldAccessor.cs new file mode 100644 index 00000000..3f4f05f4 --- /dev/null +++ b/csharp/src/Google.Protobuf/Reflection/IFieldAccessor.cs @@ -0,0 +1,70 @@ +#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.Reflection +{ + /// + /// Allows fields to be reflectively accessed. + /// + public interface IFieldAccessor + { + /// + /// Returns the descriptor associated with this field. + /// + FieldDescriptor Descriptor { get; } + + // TODO: Should the argument type for these messages be IReflectedMessage? + + /// + /// Clears the field in the specified message. (For repeated fields, + /// this clears the list.) + /// + void Clear(object message); + + /// + /// Fetches the field value. For repeated values, this will be an + /// implementation. For map values, this will be an + /// implementation. + /// + object GetValue(object message); + + /// + /// Mutator for single "simple" fields only. + /// + /// + /// Repeated fields are mutated by fetching the value and manipulating it as a list. + /// Map fields are mutated by fetching the value and manipulating it as a dictionary. + /// + /// The field is not a "simple" field, or the message is frozen. + void SetValue(object message, object value); + } +} \ No newline at end of file diff --git a/csharp/src/Google.Protobuf/Reflection/MapFieldAccessor.cs b/csharp/src/Google.Protobuf/Reflection/MapFieldAccessor.cs new file mode 100644 index 00000000..317fbd8d --- /dev/null +++ b/csharp/src/Google.Protobuf/Reflection/MapFieldAccessor.cs @@ -0,0 +1,58 @@ +#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 System; +using System.Collections; + +namespace Google.Protobuf.Reflection +{ + /// + /// Accessor for map fields. + /// + internal sealed class MapFieldAccessor : FieldAccessorBase + { + internal MapFieldAccessor(Type type, string propertyName, FieldDescriptor descriptor) : base(type, propertyName, descriptor) + { + } + + public override void Clear(object message) + { + IDictionary list = (IDictionary) GetValue(message); + list.Clear(); + } + + public override void SetValue(object message, object value) + { + throw new InvalidOperationException("SetValue is not implemented for map fields"); + } + } +} diff --git a/csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs b/csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs new file mode 100644 index 00000000..b6351d36 --- /dev/null +++ b/csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs @@ -0,0 +1,172 @@ +#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; +using System.Collections.Generic; + +namespace Google.Protobuf.Reflection +{ + /// + /// Describes a message type. + /// + public sealed class MessageDescriptor : DescriptorBase + { + private readonly DescriptorProto proto; + private readonly MessageDescriptor containingType; + private readonly IList nestedTypes; + private readonly IList enumTypes; + private readonly IList fields; + private readonly IList oneofs; + + internal MessageDescriptor(DescriptorProto proto, FileDescriptor file, MessageDescriptor parent, int typeIndex) + : base(file, file.ComputeFullName(parent, proto.Name), typeIndex) + { + this.proto = proto; + containingType = parent; + + oneofs = DescriptorUtil.ConvertAndMakeReadOnly(proto.OneofDecl, + (oneof, index) => + new OneofDescriptor(oneof, file, this, index)); + + nestedTypes = DescriptorUtil.ConvertAndMakeReadOnly(proto.NestedType, + (type, index) => + new MessageDescriptor(type, file, this, index)); + + enumTypes = DescriptorUtil.ConvertAndMakeReadOnly(proto.EnumType, + (type, index) => + new EnumDescriptor(type, file, this, index)); + + // TODO(jonskeet): Sort fields first? + fields = DescriptorUtil.ConvertAndMakeReadOnly(proto.Field, + (field, index) => + new FieldDescriptor(field, file, this, index)); + file.DescriptorPool.AddSymbol(this); + } + + /// + /// The brief name of the descriptor's target. + /// + public override string Name { get { return proto.Name; } } + + internal DescriptorProto Proto { get { return proto; } } + + /// + /// If this is a nested type, get the outer descriptor, otherwise null. + /// + public MessageDescriptor ContainingType + { + get { return containingType; } + } + + /// + /// An unmodifiable list of this message type's fields. + /// + public IList Fields + { + get { return fields; } + } + + /// + /// An unmodifiable list of this message type's nested types. + /// + public IList NestedTypes + { + get { return nestedTypes; } + } + + /// + /// An unmodifiable list of this message type's enum types. + /// + public IList EnumTypes + { + get { return enumTypes; } + } + + public IList Oneofs + { + get { return oneofs; } + } + + /// + /// Finds a field by field name. + /// + /// The unqualified name of the field (e.g. "foo"). + /// The field's descriptor, or null if not found. + public FieldDescriptor FindFieldByName(String name) + { + return File.DescriptorPool.FindSymbol(FullName + "." + name); + } + + /// + /// Finds a field by field number. + /// + /// The field number within this message type. + /// The field's descriptor, or null if not found. + public FieldDescriptor FindFieldByNumber(int number) + { + return File.DescriptorPool.FindFieldByNumber(this, number); + } + + /// + /// Finds a nested descriptor by name. The is valid for fields, nested + /// message types, oneofs and enums. + /// + /// The unqualified name of the descriptor, e.g. "Foo" + /// The descriptor, or null if not found. + public T FindDescriptor(string name) + where T : class, IDescriptor + { + return File.DescriptorPool.FindSymbol(FullName + "." + name); + } + + /// + /// Looks up and cross-links all fields and nested types. + /// + internal void CrossLink() + { + foreach (MessageDescriptor message in nestedTypes) + { + message.CrossLink(); + } + + foreach (FieldDescriptor field in fields) + { + field.CrossLink(); + } + + foreach (OneofDescriptor oneof in oneofs) + { + oneof.CrossLink(); + } + } + } +} \ No newline at end of file diff --git a/csharp/src/Google.Protobuf/Reflection/MethodDescriptor.cs b/csharp/src/Google.Protobuf/Reflection/MethodDescriptor.cs new file mode 100644 index 00000000..0c9c6949 --- /dev/null +++ b/csharp/src/Google.Protobuf/Reflection/MethodDescriptor.cs @@ -0,0 +1,93 @@ +#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.Reflection +{ + /// + /// Describes a single method in a service. + /// + public sealed class MethodDescriptor : DescriptorBase + { + private readonly MethodDescriptorProto proto; + private readonly ServiceDescriptor service; + private MessageDescriptor inputType; + private MessageDescriptor outputType; + + /// + /// The service this method belongs to. + /// + public ServiceDescriptor Service { get { return service; } } + + /// + /// The method's input type. + /// + public MessageDescriptor InputType { get { return inputType; } } + + /// + /// The method's input type. + /// + public MessageDescriptor OutputType { get { return outputType; } } + + internal MethodDescriptor(MethodDescriptorProto proto, FileDescriptor file, + ServiceDescriptor parent, int index) + : base(file, parent.FullName + "." + proto.Name, index) + { + this.proto = proto; + service = parent; + file.DescriptorPool.AddSymbol(this); + } + + internal MethodDescriptorProto Proto { get { return proto; } } + + /// + /// The brief name of the descriptor's target. + /// + public override string Name { get { return proto.Name; } } + + internal void CrossLink() + { + IDescriptor lookup = File.DescriptorPool.LookupSymbol(Proto.InputType, this); + if (!(lookup is MessageDescriptor)) + { + throw new DescriptorValidationException(this, "\"" + Proto.InputType + "\" is not a message type."); + } + inputType = (MessageDescriptor) lookup; + + lookup = File.DescriptorPool.LookupSymbol(Proto.OutputType, this); + if (!(lookup is MessageDescriptor)) + { + throw new DescriptorValidationException(this, "\"" + Proto.OutputType + "\" is not a message type."); + } + outputType = (MessageDescriptor) lookup; + } + } +} \ No newline at end of file diff --git a/csharp/src/Google.Protobuf/Reflection/OneofAccessor.cs b/csharp/src/Google.Protobuf/Reflection/OneofAccessor.cs new file mode 100644 index 00000000..7a11d36b --- /dev/null +++ b/csharp/src/Google.Protobuf/Reflection/OneofAccessor.cs @@ -0,0 +1,85 @@ +#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 System; +using System.Reflection; + +namespace Google.Protobuf.Reflection +{ + /// + /// Reflection access for a oneof, allowing clear and "get case" actions. + /// + public sealed class OneofAccessor + { + private readonly Func caseDelegate; + private readonly Action clearDelegate; + private OneofDescriptor descriptor; + + internal OneofAccessor(Type type, string propertyName, OneofDescriptor descriptor) + { + PropertyInfo property = type.GetProperty(propertyName + "Case"); + if (property == null || !property.CanRead) + { + throw new ArgumentException("Not all required properties/methods available"); + } + this.descriptor = descriptor; + caseDelegate = ReflectionUtil.CreateFuncObjectT(property.GetGetMethod()); + + this.descriptor = descriptor; + MethodInfo clearMethod = type.GetMethod("Clear" + propertyName); + clearDelegate = ReflectionUtil.CreateActionObject(clearMethod); + } + + public OneofDescriptor Descriptor { get { return descriptor; } } + + /// + /// Clears the oneof in the specified message. + /// + public void Clear(object message) + { + clearDelegate(message); + } + + /// + /// Indicates which field in the oneof is set for specified message + /// + public FieldDescriptor GetCaseFieldDescriptor(object message) + { + int fieldNumber = caseDelegate(message); + if (fieldNumber > 0) + { + return descriptor.ContainingType.FindFieldByNumber(fieldNumber); + } + return null; + } + } +} diff --git a/csharp/src/Google.Protobuf/Reflection/OneofDescriptor.cs b/csharp/src/Google.Protobuf/Reflection/OneofDescriptor.cs new file mode 100644 index 00000000..e92dc8bb --- /dev/null +++ b/csharp/src/Google.Protobuf/Reflection/OneofDescriptor.cs @@ -0,0 +1,78 @@ +#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 System.Collections.Generic; +using System.Collections.ObjectModel; + +namespace Google.Protobuf.Reflection +{ + public sealed class OneofDescriptor : DescriptorBase + { + private readonly OneofDescriptorProto proto; + private MessageDescriptor containingType; + private IList fields; + + internal OneofDescriptor(OneofDescriptorProto proto, FileDescriptor file, MessageDescriptor parent, int index) + : base(file, file.ComputeFullName(parent, proto.Name), index) + { + this.proto = proto; + containingType = parent; + + file.DescriptorPool.AddSymbol(this); + } + + /// + /// The brief name of the descriptor's target. + /// + public override string Name { get { return proto.Name; } } + + public MessageDescriptor ContainingType + { + get { return containingType; } + } + + public IList Fields { get { return fields; } } + + internal void CrossLink() + { + List fieldCollection = new List(); + foreach (var field in ContainingType.Fields) + { + if (field.ContainingOneof == this) + { + fieldCollection.Add(field); + } + } + fields = new ReadOnlyCollection(fieldCollection); + } + } +} diff --git a/csharp/src/Google.Protobuf/Reflection/PackageDescriptor.cs b/csharp/src/Google.Protobuf/Reflection/PackageDescriptor.cs new file mode 100644 index 00000000..e547d834 --- /dev/null +++ b/csharp/src/Google.Protobuf/Reflection/PackageDescriptor.cs @@ -0,0 +1,68 @@ +#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.Reflection +{ + /// + /// Represents a package in the symbol table. We use PackageDescriptors + /// just as placeholders so that someone cannot define, say, a message type + /// that has the same name as an existing package. + /// + internal sealed class PackageDescriptor : IDescriptor + { + private readonly string name; + private readonly string fullName; + private readonly FileDescriptor file; + + internal PackageDescriptor(string name, string fullName, FileDescriptor file) + { + this.file = file; + this.fullName = fullName; + this.name = name; + } + + public string Name + { + get { return name; } + } + + public string FullName + { + get { return fullName; } + } + + public FileDescriptor File + { + get { return file; } + } + } +} \ No newline at end of file diff --git a/csharp/src/Google.Protobuf/Reflection/PartialClasses.cs b/csharp/src/Google.Protobuf/Reflection/PartialClasses.cs new file mode 100644 index 00000000..c7ed4342 --- /dev/null +++ b/csharp/src/Google.Protobuf/Reflection/PartialClasses.cs @@ -0,0 +1,47 @@ +#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 + +// This file just contains partial classes for any autogenerated classes that need additional support. +namespace Google.Protobuf.Reflection +{ + internal partial class FieldDescriptorProto + { + // We can't tell the difference between "explicitly set to 0" and "not set" + // in proto3, but we need to tell the difference for OneofIndex. descriptor.proto + // is really a proto2 file, but the runtime doesn't know about proto2 semantics... + // We fake it by defaulting to -1. + partial void OnConstruction() + { + OneofIndex = -1; + } + } +} \ No newline at end of file diff --git a/csharp/src/Google.Protobuf/Reflection/ReflectionUtil.cs b/csharp/src/Google.Protobuf/Reflection/ReflectionUtil.cs new file mode 100644 index 00000000..d0dc3e8b --- /dev/null +++ b/csharp/src/Google.Protobuf/Reflection/ReflectionUtil.cs @@ -0,0 +1,106 @@ +#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; +using System.Linq.Expressions; +using System.Reflection; + +namespace Google.Protobuf.Reflection +{ + /// + /// The methods in this class are somewhat evil, and should not be tampered with lightly. + /// Basically they allow the creation of relatively weakly typed delegates from MethodInfos + /// which are more strongly typed. They do this by creating an appropriate strongly typed + /// delegate from the MethodInfo, and then calling that within an anonymous method. + /// Mind-bending stuff (at least to your humble narrator) but the resulting delegates are + /// very fast compared with calling Invoke later on. + /// + internal static class ReflectionUtil + { + /// + /// Empty Type[] used when calling GetProperty to force property instead of indexer fetching. + /// + internal static readonly Type[] EmptyTypes = new Type[0]; + + /// + /// Creates a delegate which will cast the argument to the appropriate method target type, + /// call the method on it, then convert the result to object. + /// + internal static Func CreateFuncObjectObject(MethodInfo method) + { + ParameterExpression parameter = Expression.Parameter(typeof(object), "p"); + Expression downcast = Expression.Convert(parameter, method.DeclaringType); + Expression call = Expression.Call(downcast, method); + Expression upcast = Expression.Convert(call, typeof(object)); + return Expression.Lambda>(upcast, parameter).Compile(); + } + + /// + /// Creates a delegate which will cast the argument to the appropriate method target type, + /// call the method on it, then convert the result to the specified type. + /// + internal static Func CreateFuncObjectT(MethodInfo method) + { + ParameterExpression parameter = Expression.Parameter(typeof(object), "p"); + Expression downcast = Expression.Convert(parameter, method.DeclaringType); + Expression call = Expression.Call(downcast, method); + Expression upcast = Expression.Convert(call, typeof(T)); + return Expression.Lambda>(upcast, parameter).Compile(); + } + + /// + /// Creates a delegate which will execute the given method after casting the first argument to + /// the target type of the method, and the second argument to the first parameter type of the method. + /// + internal static Action CreateActionObjectObject(MethodInfo method) + { + ParameterExpression targetParameter = Expression.Parameter(typeof(object), "target"); + ParameterExpression argParameter = Expression.Parameter(typeof(object), "arg"); + Expression castTarget = Expression.Convert(targetParameter, method.DeclaringType); + Expression castArgument = Expression.Convert(argParameter, method.GetParameters()[0].ParameterType); + Expression call = Expression.Call(castTarget, method, castArgument); + return Expression.Lambda>(call, targetParameter, argParameter).Compile(); + } + + /// + /// Creates a delegate which will execute the given method after casting the first argument to + /// the target type of the method. + /// + internal static Action CreateActionObject(MethodInfo method) + { + ParameterExpression targetParameter = Expression.Parameter(typeof(object), "target"); + Expression castTarget = Expression.Convert(targetParameter, method.DeclaringType); + Expression call = Expression.Call(castTarget, method); + return Expression.Lambda>(call, targetParameter).Compile(); + } + } +} \ No newline at end of file diff --git a/csharp/src/Google.Protobuf/Reflection/RepeatedFieldAccessor.cs b/csharp/src/Google.Protobuf/Reflection/RepeatedFieldAccessor.cs new file mode 100644 index 00000000..0ada7567 --- /dev/null +++ b/csharp/src/Google.Protobuf/Reflection/RepeatedFieldAccessor.cs @@ -0,0 +1,59 @@ +#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 System; +using System.Collections; + +namespace Google.Protobuf.Reflection +{ + /// + /// Accessor for repeated fields. + /// + internal sealed class RepeatedFieldAccessor : FieldAccessorBase + { + internal RepeatedFieldAccessor(Type type, string propertyName, FieldDescriptor descriptor) : base(type, propertyName, descriptor) + { + } + + public override void Clear(object message) + { + IList list = (IList) GetValue(message); + list.Clear(); + } + + public override void SetValue(object message, object value) + { + throw new InvalidOperationException("SetValue is not implemented for repeated fields"); + } + + } +} diff --git a/csharp/src/Google.Protobuf/Reflection/ServiceDescriptor.cs b/csharp/src/Google.Protobuf/Reflection/ServiceDescriptor.cs new file mode 100644 index 00000000..cc0a5010 --- /dev/null +++ b/csharp/src/Google.Protobuf/Reflection/ServiceDescriptor.cs @@ -0,0 +1,89 @@ +#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; +using System.Collections.Generic; + +namespace Google.Protobuf.Reflection +{ + /// + /// Describes a service type. + /// + public sealed class ServiceDescriptor : DescriptorBase + { + private readonly ServiceDescriptorProto proto; + private readonly IList methods; + + internal ServiceDescriptor(ServiceDescriptorProto proto, FileDescriptor file, int index) + : base(file, file.ComputeFullName(null, proto.Name), index) + { + this.proto = proto; + methods = DescriptorUtil.ConvertAndMakeReadOnly(proto.Method, + (method, i) => new MethodDescriptor(method, file, this, i)); + + file.DescriptorPool.AddSymbol(this); + } + + /// + /// The brief name of the descriptor's target. + /// + public override string Name { get { return proto.Name; } } + + internal ServiceDescriptorProto Proto { get { return proto; } } + + /// + /// An unmodifiable list of methods in this service. + /// + public IList Methods + { + get { return methods; } + } + + /// + /// Finds a method by name. + /// + /// The unqualified name of the method (e.g. "Foo"). + /// The method's decsriptor, or null if not found. + public MethodDescriptor FindMethodByName(String name) + { + return File.DescriptorPool.FindSymbol(FullName + "." + name); + } + + internal void CrossLink() + { + foreach (MethodDescriptor method in methods) + { + method.CrossLink(); + } + } + } +} \ No newline at end of file diff --git a/csharp/src/Google.Protobuf/Reflection/SingleFieldAccessor.cs b/csharp/src/Google.Protobuf/Reflection/SingleFieldAccessor.cs new file mode 100644 index 00000000..8c24e46e --- /dev/null +++ b/csharp/src/Google.Protobuf/Reflection/SingleFieldAccessor.cs @@ -0,0 +1,85 @@ +#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 System; +using System.Reflection; + +namespace Google.Protobuf.Reflection +{ + /// + /// Accessor for single fields. + /// + internal sealed class SingleFieldAccessor : FieldAccessorBase + { + // All the work here is actually done in the constructor - it creates the appropriate delegates. + // There are various cases to consider, based on the property type (message, string/bytes, or "genuine" primitive) + // and proto2 vs proto3 for non-message types, as proto3 doesn't support "full" presence detection or default + // values. + + private readonly Action setValueDelegate; + private readonly Action clearDelegate; + + internal SingleFieldAccessor(Type type, string propertyName, FieldDescriptor descriptor) : base(type, propertyName, descriptor) + { + PropertyInfo property = type.GetProperty(propertyName); + // We know there *is* such a property, or the base class constructor would have thrown. We should be able to write + // to it though. + if (!property.CanWrite) + { + throw new ArgumentException("Not all required properties/methods available"); + } + setValueDelegate = ReflectionUtil.CreateActionObjectObject(property.GetSetMethod()); + + var clrType = property.PropertyType; + + // TODO: What should clear on a oneof member do? Clear the oneof? + + // TODO: Validate that this is a reasonable single field? (Should be a value type, a message type, or string/ByteString.) + object defaultValue = + typeof(IMessage).IsAssignableFrom(clrType) ? null + : clrType == typeof(string) ? "" + : clrType == typeof(ByteString) ? ByteString.Empty + : Activator.CreateInstance(clrType); + clearDelegate = message => SetValue(message, defaultValue); + } + + public override void Clear(object message) + { + clearDelegate(message); + } + + public override void SetValue(object message, object value) + { + setValueDelegate(message, value); + } + } +} diff --git a/csharp/src/Google.Protobuf/ThrowHelper.cs b/csharp/src/Google.Protobuf/ThrowHelper.cs new file mode 100644 index 00000000..62d9ea60 --- /dev/null +++ b/csharp/src/Google.Protobuf/ThrowHelper.cs @@ -0,0 +1,53 @@ +#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; + +namespace Google.Protobuf +{ + /// + /// Helper methods for throwing exceptions + /// + internal static class ThrowHelper + { + /// + /// Throws an ArgumentNullException if the given value is null. + /// + internal static void ThrowIfNull(object value, string name) + { + if (value == null) + { + throw new ArgumentNullException(name); + } + } + } +} \ No newline at end of file diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs new file mode 100644 index 00000000..64d52ac5 --- /dev/null +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs @@ -0,0 +1,195 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/any.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Google.Protobuf.WellKnownTypes { + + namespace Proto { + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static partial class Any { + + #region Static variables + internal static pbr::FieldAccessorTable internal__static_google_protobuf_Any__FieldAccessorTable; + #endregion + #region Descriptor + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static Any() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "Chlnb29nbGUvcHJvdG9idWYvYW55LnByb3RvEg9nb29nbGUucHJvdG9idWYi", + "JgoDQW55EhAKCHR5cGVfdXJsGAEgASgJEg0KBXZhbHVlGAIgASgMQksKE2Nv", + "bS5nb29nbGUucHJvdG9idWZCCEFueVByb3RvUAGgAQGiAgNHUEKqAh5Hb29n", + "bGUuUHJvdG9idWYuV2VsbEtub3duVHlwZXNiBnByb3RvMw==")); + descriptor = pbr::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, + new pbr::FileDescriptor[] { + }); + internal__static_google_protobuf_Any__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.WellKnownTypes.Any), descriptor.MessageTypes[0], + new string[] { "TypeUrl", "Value", }, new string[] { }); + } + #endregion + + } + } + #region Messages + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class Any : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Any()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "type_url", "value" }; + private static readonly uint[] _fieldTags = new uint[] { 10, 18 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Any.Descriptor.MessageTypes[0]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Any.internal__static_google_protobuf_Any__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public Any() { + OnConstruction(); + } + + partial void OnConstruction(); + + public Any(Any other) : this() { + typeUrl_ = other.typeUrl_; + value_ = other.value_; + } + + public Any Clone() { + return new Any(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public const int TypeUrlFieldNumber = 1; + private string typeUrl_ = ""; + public string TypeUrl { + get { return typeUrl_; } + set { + pb::Freezable.CheckMutable(this); + typeUrl_ = value ?? ""; + } + } + + public const int ValueFieldNumber = 2; + private pb::ByteString value_ = pb::ByteString.Empty; + public pb::ByteString Value { + get { return value_; } + set { + pb::Freezable.CheckMutable(this); + value_ = value ?? pb::ByteString.Empty; + } + } + + public override bool Equals(object other) { + return Equals(other as Any); + } + + public bool Equals(Any other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (TypeUrl != other.TypeUrl) return false; + if (Value != other.Value) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (TypeUrl.Length != 0) hash ^= TypeUrl.GetHashCode(); + if (Value.Length != 0) hash ^= Value.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (TypeUrl.Length != 0) { + output.WriteRawTag(10); + output.WriteString(TypeUrl); + } + if (Value.Length != 0) { + output.WriteRawTag(18); + output.WriteBytes(Value); + } + } + + public int CalculateSize() { + int size = 0; + if (TypeUrl.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(TypeUrl); + } + if (Value.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeBytesSize(Value); + } + return size; + } + + public void MergeFrom(Any other) { + if (other == null) { + return; + } + if (other.TypeUrl.Length != 0) { + TypeUrl = other.TypeUrl; + } + if (other.Value.Length != 0) { + Value = other.Value; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + TypeUrl = input.ReadString(); + break; + } + case 18: { + Value = input.ReadBytes(); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs new file mode 100644 index 00000000..1e2506a4 --- /dev/null +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs @@ -0,0 +1,528 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/api.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Google.Protobuf.WellKnownTypes { + + namespace Proto { + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static partial class Api { + + #region Static variables + internal static pbr::FieldAccessorTable internal__static_google_protobuf_Api__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_Method__FieldAccessorTable; + #endregion + #region Descriptor + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static Api() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "Chlnb29nbGUvcHJvdG9idWYvYXBpLnByb3RvEg9nb29nbGUucHJvdG9idWYa", + "JGdvb2dsZS9wcm90b2J1Zi9zb3VyY2VfY29udGV4dC5wcm90bxoaZ29vZ2xl", + "L3Byb3RvYnVmL3R5cGUucHJvdG8isAEKA0FwaRIMCgRuYW1lGAEgASgJEigK", + "B21ldGhvZHMYAiADKAsyFy5nb29nbGUucHJvdG9idWYuTWV0aG9kEigKB29w", + "dGlvbnMYAyADKAsyFy5nb29nbGUucHJvdG9idWYuT3B0aW9uEg8KB3ZlcnNp", + "b24YBCABKAkSNgoOc291cmNlX2NvbnRleHQYBSABKAsyHi5nb29nbGUucHJv", + "dG9idWYuU291cmNlQ29udGV4dCKsAQoGTWV0aG9kEgwKBG5hbWUYASABKAkS", + "GAoQcmVxdWVzdF90eXBlX3VybBgCIAEoCRIZChFyZXF1ZXN0X3N0cmVhbWlu", + "ZxgDIAEoCBIZChFyZXNwb25zZV90eXBlX3VybBgEIAEoCRIaChJyZXNwb25z", + "ZV9zdHJlYW1pbmcYBSABKAgSKAoHb3B0aW9ucxgGIAMoCzIXLmdvb2dsZS5w", + "cm90b2J1Zi5PcHRpb25CSAoTY29tLmdvb2dsZS5wcm90b2J1ZkIIQXBpUHJv", + "dG9QAaICA0dQQqoCHkdvb2dsZS5Qcm90b2J1Zi5XZWxsS25vd25UeXBlc2IG", + "cHJvdG8z")); + descriptor = pbr::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, + new pbr::FileDescriptor[] { + global::Google.Protobuf.WellKnownTypes.Proto.SourceContext.Descriptor, + global::Google.Protobuf.WellKnownTypes.Proto.Type.Descriptor, + }); + internal__static_google_protobuf_Api__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.WellKnownTypes.Api), descriptor.MessageTypes[0], + new string[] { "Name", "Methods", "Options", "Version", "SourceContext", }, new string[] { }); + internal__static_google_protobuf_Method__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.WellKnownTypes.Method), descriptor.MessageTypes[1], + new string[] { "Name", "RequestTypeUrl", "RequestStreaming", "ResponseTypeUrl", "ResponseStreaming", "Options", }, new string[] { }); + } + #endregion + + } + } + #region Messages + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class Api : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Api()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "methods", "name", "options", "source_context", "version" }; + private static readonly uint[] _fieldTags = new uint[] { 18, 10, 26, 42, 34 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Api.Descriptor.MessageTypes[0]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Api.internal__static_google_protobuf_Api__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public Api() { + OnConstruction(); + } + + partial void OnConstruction(); + + public Api(Api other) : this() { + name_ = other.name_; + methods_ = other.methods_.Clone(); + options_ = other.options_.Clone(); + version_ = other.version_; + SourceContext = other.sourceContext_ != null ? other.SourceContext.Clone() : null; + } + + public Api Clone() { + return new Api(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + methods_.Freeze(); + options_.Freeze(); + if (sourceContext_ != null) SourceContext.Freeze(); + } + + public const int NameFieldNumber = 1; + private string name_ = ""; + public string Name { + get { return name_; } + set { + pb::Freezable.CheckMutable(this); + name_ = value ?? ""; + } + } + + public const int MethodsFieldNumber = 2; + private static readonly pb::FieldCodec _repeated_methods_codec + = pb::FieldCodec.ForMessage(18, global::Google.Protobuf.WellKnownTypes.Method.Parser); + private readonly pbc::RepeatedField methods_ = new pbc::RepeatedField(); + public pbc::RepeatedField Methods { + get { return methods_; } + } + + public const int OptionsFieldNumber = 3; + private static readonly pb::FieldCodec _repeated_options_codec + = pb::FieldCodec.ForMessage(26, global::Google.Protobuf.WellKnownTypes.Option.Parser); + private readonly pbc::RepeatedField options_ = new pbc::RepeatedField(); + public pbc::RepeatedField Options { + get { return options_; } + } + + public const int VersionFieldNumber = 4; + private string version_ = ""; + public string Version { + get { return version_; } + set { + pb::Freezable.CheckMutable(this); + version_ = value ?? ""; + } + } + + public const int SourceContextFieldNumber = 5; + private global::Google.Protobuf.WellKnownTypes.SourceContext sourceContext_; + public global::Google.Protobuf.WellKnownTypes.SourceContext SourceContext { + get { return sourceContext_; } + set { + pb::Freezable.CheckMutable(this); + sourceContext_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as Api); + } + + public bool Equals(Api other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Name != other.Name) return false; + if(!methods_.Equals(other.methods_)) return false; + if(!options_.Equals(other.options_)) return false; + if (Version != other.Version) return false; + if (!object.Equals(SourceContext, other.SourceContext)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Name.Length != 0) hash ^= Name.GetHashCode(); + hash ^= methods_.GetHashCode(); + hash ^= options_.GetHashCode(); + if (Version.Length != 0) hash ^= Version.GetHashCode(); + if (sourceContext_ != null) hash ^= SourceContext.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Name.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Name); + } + methods_.WriteTo(output, _repeated_methods_codec); + options_.WriteTo(output, _repeated_options_codec); + if (Version.Length != 0) { + output.WriteRawTag(34); + output.WriteString(Version); + } + if (sourceContext_ != null) { + output.WriteRawTag(42); + output.WriteMessage(SourceContext); + } + } + + public int CalculateSize() { + int size = 0; + if (Name.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); + } + size += methods_.CalculateSize(_repeated_methods_codec); + size += options_.CalculateSize(_repeated_options_codec); + if (Version.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Version); + } + if (sourceContext_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(SourceContext); + } + return size; + } + + public void MergeFrom(Api other) { + if (other == null) { + return; + } + if (other.Name.Length != 0) { + Name = other.Name; + } + methods_.Add(other.methods_); + options_.Add(other.options_); + if (other.Version.Length != 0) { + Version = other.Version; + } + if (other.sourceContext_ != null) { + if (sourceContext_ == null) { + sourceContext_ = new global::Google.Protobuf.WellKnownTypes.SourceContext(); + } + SourceContext.MergeFrom(other.SourceContext); + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + Name = input.ReadString(); + break; + } + case 18: { + methods_.AddEntriesFrom(input, _repeated_methods_codec); + break; + } + case 26: { + options_.AddEntriesFrom(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; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class Method : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Method()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "name", "options", "request_streaming", "request_type_url", "response_streaming", "response_type_url" }; + private static readonly uint[] _fieldTags = new uint[] { 10, 50, 24, 18, 40, 34 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Api.Descriptor.MessageTypes[1]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Api.internal__static_google_protobuf_Method__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public Method() { + OnConstruction(); + } + + partial void OnConstruction(); + + public Method(Method other) : this() { + name_ = other.name_; + requestTypeUrl_ = other.requestTypeUrl_; + requestStreaming_ = other.requestStreaming_; + responseTypeUrl_ = other.responseTypeUrl_; + responseStreaming_ = other.responseStreaming_; + options_ = other.options_.Clone(); + } + + public Method Clone() { + return new Method(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + options_.Freeze(); + } + + public const int NameFieldNumber = 1; + private string name_ = ""; + public string Name { + get { return name_; } + set { + pb::Freezable.CheckMutable(this); + name_ = value ?? ""; + } + } + + public const int RequestTypeUrlFieldNumber = 2; + private string requestTypeUrl_ = ""; + public string RequestTypeUrl { + get { return requestTypeUrl_; } + set { + pb::Freezable.CheckMutable(this); + requestTypeUrl_ = value ?? ""; + } + } + + public const int RequestStreamingFieldNumber = 3; + private bool requestStreaming_; + public bool RequestStreaming { + get { return requestStreaming_; } + set { + pb::Freezable.CheckMutable(this); + requestStreaming_ = value; + } + } + + public const int ResponseTypeUrlFieldNumber = 4; + private string responseTypeUrl_ = ""; + public string ResponseTypeUrl { + get { return responseTypeUrl_; } + set { + pb::Freezable.CheckMutable(this); + responseTypeUrl_ = value ?? ""; + } + } + + public const int ResponseStreamingFieldNumber = 5; + private bool responseStreaming_; + public bool ResponseStreaming { + get { return responseStreaming_; } + set { + pb::Freezable.CheckMutable(this); + responseStreaming_ = value; + } + } + + public const int OptionsFieldNumber = 6; + private static readonly pb::FieldCodec _repeated_options_codec + = pb::FieldCodec.ForMessage(50, global::Google.Protobuf.WellKnownTypes.Option.Parser); + private readonly pbc::RepeatedField options_ = new pbc::RepeatedField(); + public pbc::RepeatedField Options { + get { return options_; } + } + + public override bool Equals(object other) { + return Equals(other as Method); + } + + public bool Equals(Method other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Name != other.Name) return false; + if (RequestTypeUrl != other.RequestTypeUrl) return false; + if (RequestStreaming != other.RequestStreaming) return false; + if (ResponseTypeUrl != other.ResponseTypeUrl) return false; + if (ResponseStreaming != other.ResponseStreaming) return false; + if(!options_.Equals(other.options_)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Name.Length != 0) hash ^= Name.GetHashCode(); + if (RequestTypeUrl.Length != 0) hash ^= RequestTypeUrl.GetHashCode(); + if (RequestStreaming != false) hash ^= RequestStreaming.GetHashCode(); + if (ResponseTypeUrl.Length != 0) hash ^= ResponseTypeUrl.GetHashCode(); + if (ResponseStreaming != false) hash ^= ResponseStreaming.GetHashCode(); + hash ^= options_.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream 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(output, _repeated_options_codec); + } + + public int CalculateSize() { + int size = 0; + if (Name.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); + } + if (RequestTypeUrl.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(RequestTypeUrl); + } + if (RequestStreaming != false) { + size += 1 + 1; + } + if (ResponseTypeUrl.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(ResponseTypeUrl); + } + if (ResponseStreaming != false) { + size += 1 + 1; + } + size += options_.CalculateSize(_repeated_options_codec); + return size; + } + + public void MergeFrom(Method other) { + if (other == null) { + return; + } + if (other.Name.Length != 0) { + Name = other.Name; + } + if (other.RequestTypeUrl.Length != 0) { + RequestTypeUrl = other.RequestTypeUrl; + } + if (other.RequestStreaming != false) { + RequestStreaming = other.RequestStreaming; + } + if (other.ResponseTypeUrl.Length != 0) { + ResponseTypeUrl = other.ResponseTypeUrl; + } + if (other.ResponseStreaming != false) { + ResponseStreaming = other.ResponseStreaming; + } + options_.Add(other.options_); + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + 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(input, _repeated_options_codec); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs new file mode 100644 index 00000000..fbc9c007 --- /dev/null +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs @@ -0,0 +1,196 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/duration.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Google.Protobuf.WellKnownTypes { + + namespace Proto { + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static partial class Duration { + + #region Static variables + internal static pbr::FieldAccessorTable internal__static_google_protobuf_Duration__FieldAccessorTable; + #endregion + #region Descriptor + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static Duration() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "Ch5nb29nbGUvcHJvdG9idWYvZHVyYXRpb24ucHJvdG8SD2dvb2dsZS5wcm90", + "b2J1ZiIqCghEdXJhdGlvbhIPCgdzZWNvbmRzGAEgASgDEg0KBW5hbm9zGAIg", + "ASgFQlAKE2NvbS5nb29nbGUucHJvdG9idWZCDUR1cmF0aW9uUHJvdG9QAaAB", + "AaICA0dQQqoCHkdvb2dsZS5Qcm90b2J1Zi5XZWxsS25vd25UeXBlc2IGcHJv", + "dG8z")); + descriptor = pbr::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, + new pbr::FileDescriptor[] { + }); + internal__static_google_protobuf_Duration__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.WellKnownTypes.Duration), descriptor.MessageTypes[0], + new string[] { "Seconds", "Nanos", }, new string[] { }); + } + #endregion + + } + } + #region Messages + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class Duration : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Duration()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "nanos", "seconds" }; + private static readonly uint[] _fieldTags = new uint[] { 16, 8 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Duration.Descriptor.MessageTypes[0]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Duration.internal__static_google_protobuf_Duration__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public Duration() { + OnConstruction(); + } + + partial void OnConstruction(); + + public Duration(Duration other) : this() { + seconds_ = other.seconds_; + nanos_ = other.nanos_; + } + + public Duration Clone() { + return new Duration(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public const int SecondsFieldNumber = 1; + private long seconds_; + public long Seconds { + get { return seconds_; } + set { + pb::Freezable.CheckMutable(this); + seconds_ = value; + } + } + + public const int NanosFieldNumber = 2; + private int nanos_; + public int Nanos { + get { return nanos_; } + set { + pb::Freezable.CheckMutable(this); + nanos_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as Duration); + } + + public bool Equals(Duration other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Seconds != other.Seconds) return false; + if (Nanos != other.Nanos) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Seconds != 0L) hash ^= Seconds.GetHashCode(); + if (Nanos != 0) hash ^= Nanos.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Seconds != 0L) { + output.WriteRawTag(8); + output.WriteInt64(Seconds); + } + if (Nanos != 0) { + output.WriteRawTag(16); + output.WriteInt32(Nanos); + } + } + + public int CalculateSize() { + int size = 0; + if (Seconds != 0L) { + size += 1 + pb::CodedOutputStream.ComputeInt64Size(Seconds); + } + if (Nanos != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Nanos); + } + return size; + } + + public void MergeFrom(Duration other) { + if (other == null) { + return; + } + if (other.Seconds != 0L) { + Seconds = other.Seconds; + } + if (other.Nanos != 0) { + Nanos = other.Nanos; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 8: { + Seconds = input.ReadInt64(); + break; + } + case 16: { + Nanos = input.ReadInt32(); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs new file mode 100644 index 00000000..c2681e29 --- /dev/null +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs @@ -0,0 +1,141 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/empty.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Google.Protobuf.WellKnownTypes { + + namespace Proto { + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static partial class Empty { + + #region Static variables + internal static pbr::FieldAccessorTable internal__static_google_protobuf_Empty__FieldAccessorTable; + #endregion + #region Descriptor + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static Empty() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "Chtnb29nbGUvcHJvdG9idWYvZW1wdHkucHJvdG8SD2dvb2dsZS5wcm90b2J1", + "ZiIHCgVFbXB0eUJKChNjb20uZ29vZ2xlLnByb3RvYnVmQgpFbXB0eVByb3Rv", + "UAGiAgNHUEKqAh5Hb29nbGUuUHJvdG9idWYuV2VsbEtub3duVHlwZXNiBnBy", + "b3RvMw==")); + descriptor = pbr::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, + new pbr::FileDescriptor[] { + }); + internal__static_google_protobuf_Empty__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.WellKnownTypes.Empty), descriptor.MessageTypes[0], + new string[] { }, new string[] { }); + } + #endregion + + } + } + #region Messages + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class Empty : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Empty()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { }; + private static readonly uint[] _fieldTags = new uint[] { }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Empty.Descriptor.MessageTypes[0]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Empty.internal__static_google_protobuf_Empty__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public Empty() { + OnConstruction(); + } + + partial void OnConstruction(); + + public Empty(Empty other) : this() { + } + + public Empty Clone() { + return new Empty(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public override bool Equals(object other) { + return Equals(other as Empty); + } + + public bool Equals(Empty other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + return true; + } + + public override int GetHashCode() { + int hash = 1; + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + } + + public int CalculateSize() { + int size = 0; + return size; + } + + public void MergeFrom(Empty other) { + if (other == null) { + return; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs b/csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs new file mode 100644 index 00000000..310c0d21 --- /dev/null +++ b/csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs @@ -0,0 +1,160 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/field_mask.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Google.Protobuf.WellKnownTypes { + + namespace Proto { + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static partial class FieldMask { + + #region Static variables + internal static pbr::FieldAccessorTable internal__static_google_protobuf_FieldMask__FieldAccessorTable; + #endregion + #region Descriptor + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static FieldMask() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "CiBnb29nbGUvcHJvdG9idWYvZmllbGRfbWFzay5wcm90bxIPZ29vZ2xlLnBy", + "b3RvYnVmIhoKCUZpZWxkTWFzaxINCgVwYXRocxgBIAMoCUJOChNjb20uZ29v", + "Z2xlLnByb3RvYnVmQg5GaWVsZE1hc2tQcm90b1ABogIDR1BCqgIeR29vZ2xl", + "LlByb3RvYnVmLldlbGxLbm93blR5cGVzYgZwcm90bzM=")); + descriptor = pbr::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, + new pbr::FileDescriptor[] { + }); + internal__static_google_protobuf_FieldMask__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.WellKnownTypes.FieldMask), descriptor.MessageTypes[0], + new string[] { "Paths", }, new string[] { }); + } + #endregion + + } + } + #region Messages + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class FieldMask : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FieldMask()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "paths" }; + private static readonly uint[] _fieldTags = new uint[] { 10 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.WellKnownTypes.Proto.FieldMask.Descriptor.MessageTypes[0]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.WellKnownTypes.Proto.FieldMask.internal__static_google_protobuf_FieldMask__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public FieldMask() { + OnConstruction(); + } + + partial void OnConstruction(); + + public FieldMask(FieldMask other) : this() { + paths_ = other.paths_.Clone(); + } + + public FieldMask Clone() { + return new FieldMask(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + paths_.Freeze(); + } + + public const int PathsFieldNumber = 1; + private static readonly pb::FieldCodec _repeated_paths_codec + = pb::FieldCodec.ForString(10); + private readonly pbc::RepeatedField paths_ = new pbc::RepeatedField(); + public pbc::RepeatedField Paths { + get { return paths_; } + } + + public override bool Equals(object other) { + return Equals(other as FieldMask); + } + + public bool Equals(FieldMask other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if(!paths_.Equals(other.paths_)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + hash ^= paths_.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + paths_.WriteTo(output, _repeated_paths_codec); + } + + public int CalculateSize() { + int size = 0; + size += paths_.CalculateSize(_repeated_paths_codec); + return size; + } + + public void MergeFrom(FieldMask other) { + if (other == null) { + return; + } + paths_.Add(other.paths_); + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + paths_.AddEntriesFrom(input, _repeated_paths_codec); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs b/csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs new file mode 100644 index 00000000..ee60fbe9 --- /dev/null +++ b/csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs @@ -0,0 +1,169 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/source_context.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Google.Protobuf.WellKnownTypes { + + namespace Proto { + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static partial class SourceContext { + + #region Static variables + internal static pbr::FieldAccessorTable internal__static_google_protobuf_SourceContext__FieldAccessorTable; + #endregion + #region Descriptor + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static SourceContext() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "CiRnb29nbGUvcHJvdG9idWYvc291cmNlX2NvbnRleHQucHJvdG8SD2dvb2ds", + "ZS5wcm90b2J1ZiIiCg1Tb3VyY2VDb250ZXh0EhEKCWZpbGVfbmFtZRgBIAEo", + "CUJSChNjb20uZ29vZ2xlLnByb3RvYnVmQhJTb3VyY2VDb250ZXh0UHJvdG9Q", + "AaICA0dQQqoCHkdvb2dsZS5Qcm90b2J1Zi5XZWxsS25vd25UeXBlc2IGcHJv", + "dG8z")); + descriptor = pbr::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, + new pbr::FileDescriptor[] { + }); + internal__static_google_protobuf_SourceContext__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.WellKnownTypes.SourceContext), descriptor.MessageTypes[0], + new string[] { "FileName", }, new string[] { }); + } + #endregion + + } + } + #region Messages + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class SourceContext : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new SourceContext()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "file_name" }; + private static readonly uint[] _fieldTags = new uint[] { 10 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.WellKnownTypes.Proto.SourceContext.Descriptor.MessageTypes[0]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.WellKnownTypes.Proto.SourceContext.internal__static_google_protobuf_SourceContext__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public SourceContext() { + OnConstruction(); + } + + partial void OnConstruction(); + + public SourceContext(SourceContext other) : this() { + fileName_ = other.fileName_; + } + + public SourceContext Clone() { + return new SourceContext(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public const int FileNameFieldNumber = 1; + private string fileName_ = ""; + public string FileName { + get { return fileName_; } + set { + pb::Freezable.CheckMutable(this); + fileName_ = value ?? ""; + } + } + + public override bool Equals(object other) { + return Equals(other as SourceContext); + } + + public bool Equals(SourceContext other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (FileName != other.FileName) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (FileName.Length != 0) hash ^= FileName.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (FileName.Length != 0) { + output.WriteRawTag(10); + output.WriteString(FileName); + } + } + + public int CalculateSize() { + int size = 0; + if (FileName.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(FileName); + } + return size; + } + + public void MergeFrom(SourceContext other) { + if (other == null) { + return; + } + if (other.FileName.Length != 0) { + FileName = other.FileName; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + FileName = input.ReadString(); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs new file mode 100644 index 00000000..99f88a96 --- /dev/null +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs @@ -0,0 +1,601 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/struct.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Google.Protobuf.WellKnownTypes { + + namespace Proto { + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static partial class Struct { + + #region Static variables + internal static pbr::FieldAccessorTable internal__static_google_protobuf_Struct__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_Value__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_ListValue__FieldAccessorTable; + #endregion + #region Descriptor + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static Struct() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "Chxnb29nbGUvcHJvdG9idWYvc3RydWN0LnByb3RvEg9nb29nbGUucHJvdG9i", + "dWYihAEKBlN0cnVjdBIzCgZmaWVsZHMYASADKAsyIy5nb29nbGUucHJvdG9i", + "dWYuU3RydWN0LkZpZWxkc0VudHJ5GkUKC0ZpZWxkc0VudHJ5EgsKA2tleRgB", + "IAEoCRIlCgV2YWx1ZRgCIAEoCzIWLmdvb2dsZS5wcm90b2J1Zi5WYWx1ZToC", + "OAEi6gEKBVZhbHVlEjAKCm51bGxfdmFsdWUYASABKA4yGi5nb29nbGUucHJv", + "dG9idWYuTnVsbFZhbHVlSAASFgoMbnVtYmVyX3ZhbHVlGAIgASgBSAASFgoM", + "c3RyaW5nX3ZhbHVlGAMgASgJSAASFAoKYm9vbF92YWx1ZRgEIAEoCEgAEi8K", + "DHN0cnVjdF92YWx1ZRgFIAEoCzIXLmdvb2dsZS5wcm90b2J1Zi5TdHJ1Y3RI", + "ABIwCgpsaXN0X3ZhbHVlGAYgASgLMhouZ29vZ2xlLnByb3RvYnVmLkxpc3RW", + "YWx1ZUgAQgYKBGtpbmQiMwoJTGlzdFZhbHVlEiYKBnZhbHVlcxgBIAMoCzIW", + "Lmdvb2dsZS5wcm90b2J1Zi5WYWx1ZSobCglOdWxsVmFsdWUSDgoKTlVMTF9W", + "QUxVRRAAQk4KE2NvbS5nb29nbGUucHJvdG9idWZCC1N0cnVjdFByb3RvUAGg", + "AQGiAgNHUEKqAh5Hb29nbGUuUHJvdG9idWYuV2VsbEtub3duVHlwZXNiBnBy", + "b3RvMw==")); + descriptor = pbr::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, + new pbr::FileDescriptor[] { + }); + internal__static_google_protobuf_Struct__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.WellKnownTypes.Struct), descriptor.MessageTypes[0], + new string[] { "Fields", }, new string[] { }); + internal__static_google_protobuf_Value__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.WellKnownTypes.Value), descriptor.MessageTypes[1], + new string[] { "NullValue", "NumberValue", "StringValue", "BoolValue", "StructValue", "ListValue", }, new string[] { "Kind", }); + internal__static_google_protobuf_ListValue__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.WellKnownTypes.ListValue), descriptor.MessageTypes[2], + new string[] { "Values", }, new string[] { }); + } + #endregion + + } + } + #region Enums + public enum NullValue { + NULL_VALUE = 0, + } + + #endregion + + #region Messages + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class Struct : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Struct()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "fields" }; + private static readonly uint[] _fieldTags = new uint[] { 10 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Struct.Descriptor.MessageTypes[0]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Struct.internal__static_google_protobuf_Struct__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public Struct() { + OnConstruction(); + } + + partial void OnConstruction(); + + public Struct(Struct other) : this() { + fields_ = other.fields_.Clone(); + } + + public Struct Clone() { + return new Struct(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + fields_.Freeze(); + } + + public const int FieldsFieldNumber = 1; + private static readonly pbc::MapField.Codec _map_fields_codec + = new pbc::MapField.Codec(pb::FieldCodec.ForString(10), pb::FieldCodec.ForMessage(18, global::Google.Protobuf.WellKnownTypes.Value.Parser), 10); + private readonly pbc::MapField fields_ = new pbc::MapField(); + public pbc::MapField Fields { + get { return fields_; } + } + + public override bool Equals(object other) { + return Equals(other as Struct); + } + + public bool Equals(Struct other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (!Fields.Equals(other.Fields)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + hash ^= Fields.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + fields_.WriteTo(output, _map_fields_codec); + } + + public int CalculateSize() { + int size = 0; + size += fields_.CalculateSize(_map_fields_codec); + return size; + } + + public void MergeFrom(Struct other) { + if (other == null) { + return; + } + fields_.Add(other.fields_); + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + fields_.AddEntriesFrom(input, _map_fields_codec); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class Value : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Value()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "bool_value", "list_value", "null_value", "number_value", "string_value", "struct_value" }; + private static readonly uint[] _fieldTags = new uint[] { 32, 50, 8, 17, 26, 42 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Struct.Descriptor.MessageTypes[1]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Struct.internal__static_google_protobuf_Value__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public Value() { + OnConstruction(); + } + + partial void OnConstruction(); + + public Value(Value other) : this() { + switch (other.KindCase) { + case KindOneofCase.NullValue: + NullValue = other.NullValue; + break; + case KindOneofCase.NumberValue: + NumberValue = other.NumberValue; + break; + case KindOneofCase.StringValue: + StringValue = other.StringValue; + break; + case KindOneofCase.BoolValue: + BoolValue = other.BoolValue; + break; + case KindOneofCase.StructValue: + StructValue = other.StructValue.Clone(); + break; + case KindOneofCase.ListValue: + ListValue = other.ListValue.Clone(); + break; + } + + } + + public Value Clone() { + return new Value(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + if (kind_ is IFreezable) ((IFreezable) kind_).Freeze(); + } + + public const int NullValueFieldNumber = 1; + public global::Google.Protobuf.WellKnownTypes.NullValue NullValue { + get { return kindCase_ == KindOneofCase.NullValue ? (global::Google.Protobuf.WellKnownTypes.NullValue) kind_ : global::Google.Protobuf.WellKnownTypes.NullValue.NULL_VALUE; } + set { + pb::Freezable.CheckMutable(this); + kind_ = value; + kindCase_ = KindOneofCase.NullValue; + } + } + + public const int NumberValueFieldNumber = 2; + public double NumberValue { + get { return kindCase_ == KindOneofCase.NumberValue ? (double) kind_ : 0D; } + set { + pb::Freezable.CheckMutable(this); + kind_ = value; + kindCase_ = KindOneofCase.NumberValue; + } + } + + public const int StringValueFieldNumber = 3; + public string StringValue { + get { return kindCase_ == KindOneofCase.StringValue ? (string) kind_ : ""; } + set { + pb::Freezable.CheckMutable(this); + kind_ = value ?? ""; + kindCase_ = KindOneofCase.StringValue; + } + } + + public const int BoolValueFieldNumber = 4; + public bool BoolValue { + get { return kindCase_ == KindOneofCase.BoolValue ? (bool) kind_ : false; } + set { + pb::Freezable.CheckMutable(this); + kind_ = value; + kindCase_ = KindOneofCase.BoolValue; + } + } + + public const int StructValueFieldNumber = 5; + public global::Google.Protobuf.WellKnownTypes.Struct StructValue { + get { return kindCase_ == KindOneofCase.StructValue ? (global::Google.Protobuf.WellKnownTypes.Struct) kind_ : null; } + set { + pb::Freezable.CheckMutable(this); + kind_ = value; + kindCase_ = value == null ? KindOneofCase.None : KindOneofCase.StructValue; + } + } + + public const int ListValueFieldNumber = 6; + public global::Google.Protobuf.WellKnownTypes.ListValue ListValue { + get { return kindCase_ == KindOneofCase.ListValue ? (global::Google.Protobuf.WellKnownTypes.ListValue) kind_ : null; } + set { + pb::Freezable.CheckMutable(this); + kind_ = value; + kindCase_ = value == null ? KindOneofCase.None : KindOneofCase.ListValue; + } + } + + private object kind_; + public enum KindOneofCase { + None = 0, + NullValue = 1, + NumberValue = 2, + StringValue = 3, + BoolValue = 4, + StructValue = 5, + ListValue = 6, + } + private KindOneofCase kindCase_ = KindOneofCase.None; + public KindOneofCase KindCase { + get { return kindCase_; } + } + + public void ClearKind() { + pb::Freezable.CheckMutable(this); + kindCase_ = KindOneofCase.None; + kind_ = null; + } + + public override bool Equals(object other) { + return Equals(other as Value); + } + + public bool Equals(Value other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (NullValue != other.NullValue) return false; + if (NumberValue != other.NumberValue) return false; + if (StringValue != other.StringValue) return false; + if (BoolValue != other.BoolValue) return false; + if (!object.Equals(StructValue, other.StructValue)) return false; + if (!object.Equals(ListValue, other.ListValue)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (kindCase_ == KindOneofCase.NullValue) hash ^= NullValue.GetHashCode(); + if (kindCase_ == KindOneofCase.NumberValue) hash ^= NumberValue.GetHashCode(); + if (kindCase_ == KindOneofCase.StringValue) hash ^= StringValue.GetHashCode(); + if (kindCase_ == KindOneofCase.BoolValue) hash ^= BoolValue.GetHashCode(); + if (kindCase_ == KindOneofCase.StructValue) hash ^= StructValue.GetHashCode(); + if (kindCase_ == KindOneofCase.ListValue) hash ^= ListValue.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream 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); + } + } + + public int CalculateSize() { + int size = 0; + if (kindCase_ == KindOneofCase.NullValue) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) NullValue); + } + if (kindCase_ == KindOneofCase.NumberValue) { + size += 1 + 8; + } + if (kindCase_ == KindOneofCase.StringValue) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(StringValue); + } + if (kindCase_ == KindOneofCase.BoolValue) { + size += 1 + 1; + } + if (kindCase_ == KindOneofCase.StructValue) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(StructValue); + } + if (kindCase_ == KindOneofCase.ListValue) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(ListValue); + } + return size; + } + + public void MergeFrom(Value other) { + if (other == null) { + return; + } + switch (other.KindCase) { + case KindOneofCase.NullValue: + NullValue = other.NullValue; + break; + case KindOneofCase.NumberValue: + NumberValue = other.NumberValue; + break; + case KindOneofCase.StringValue: + StringValue = other.StringValue; + break; + case KindOneofCase.BoolValue: + BoolValue = other.BoolValue; + break; + case KindOneofCase.StructValue: + StructValue = other.StructValue; + break; + case KindOneofCase.ListValue: + ListValue = other.ListValue; + break; + } + + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + 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; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class ListValue : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ListValue()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "values" }; + private static readonly uint[] _fieldTags = new uint[] { 10 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Struct.Descriptor.MessageTypes[2]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Struct.internal__static_google_protobuf_ListValue__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public ListValue() { + OnConstruction(); + } + + partial void OnConstruction(); + + public ListValue(ListValue other) : this() { + values_ = other.values_.Clone(); + } + + public ListValue Clone() { + return new ListValue(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + values_.Freeze(); + } + + public const int ValuesFieldNumber = 1; + private static readonly pb::FieldCodec _repeated_values_codec + = pb::FieldCodec.ForMessage(10, global::Google.Protobuf.WellKnownTypes.Value.Parser); + private readonly pbc::RepeatedField values_ = new pbc::RepeatedField(); + public pbc::RepeatedField Values { + get { return values_; } + } + + public override bool Equals(object other) { + return Equals(other as ListValue); + } + + public bool Equals(ListValue other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if(!values_.Equals(other.values_)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + hash ^= values_.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + values_.WriteTo(output, _repeated_values_codec); + } + + public int CalculateSize() { + int size = 0; + size += values_.CalculateSize(_repeated_values_codec); + return size; + } + + public void MergeFrom(ListValue other) { + if (other == null) { + return; + } + values_.Add(other.values_); + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + values_.AddEntriesFrom(input, _repeated_values_codec); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs new file mode 100644 index 00000000..e3bb3c37 --- /dev/null +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs @@ -0,0 +1,196 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/timestamp.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Google.Protobuf.WellKnownTypes { + + namespace Proto { + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static partial class Timestamp { + + #region Static variables + internal static pbr::FieldAccessorTable internal__static_google_protobuf_Timestamp__FieldAccessorTable; + #endregion + #region Descriptor + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static Timestamp() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "Ch9nb29nbGUvcHJvdG9idWYvdGltZXN0YW1wLnByb3RvEg9nb29nbGUucHJv", + "dG9idWYiKwoJVGltZXN0YW1wEg8KB3NlY29uZHMYASABKAMSDQoFbmFub3MY", + "AiABKAVCUQoTY29tLmdvb2dsZS5wcm90b2J1ZkIOVGltZXN0YW1wUHJvdG9Q", + "AaABAaICA0dQQqoCHkdvb2dsZS5Qcm90b2J1Zi5XZWxsS25vd25UeXBlc2IG", + "cHJvdG8z")); + descriptor = pbr::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, + new pbr::FileDescriptor[] { + }); + internal__static_google_protobuf_Timestamp__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.WellKnownTypes.Timestamp), descriptor.MessageTypes[0], + new string[] { "Seconds", "Nanos", }, new string[] { }); + } + #endregion + + } + } + #region Messages + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class Timestamp : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Timestamp()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "nanos", "seconds" }; + private static readonly uint[] _fieldTags = new uint[] { 16, 8 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Timestamp.Descriptor.MessageTypes[0]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Timestamp.internal__static_google_protobuf_Timestamp__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public Timestamp() { + OnConstruction(); + } + + partial void OnConstruction(); + + public Timestamp(Timestamp other) : this() { + seconds_ = other.seconds_; + nanos_ = other.nanos_; + } + + public Timestamp Clone() { + return new Timestamp(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + } + + public const int SecondsFieldNumber = 1; + private long seconds_; + public long Seconds { + get { return seconds_; } + set { + pb::Freezable.CheckMutable(this); + seconds_ = value; + } + } + + public const int NanosFieldNumber = 2; + private int nanos_; + public int Nanos { + get { return nanos_; } + set { + pb::Freezable.CheckMutable(this); + nanos_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as Timestamp); + } + + public bool Equals(Timestamp other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Seconds != other.Seconds) return false; + if (Nanos != other.Nanos) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Seconds != 0L) hash ^= Seconds.GetHashCode(); + if (Nanos != 0) hash ^= Nanos.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Seconds != 0L) { + output.WriteRawTag(8); + output.WriteInt64(Seconds); + } + if (Nanos != 0) { + output.WriteRawTag(16); + output.WriteInt32(Nanos); + } + } + + public int CalculateSize() { + int size = 0; + if (Seconds != 0L) { + size += 1 + pb::CodedOutputStream.ComputeInt64Size(Seconds); + } + if (Nanos != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Nanos); + } + return size; + } + + public void MergeFrom(Timestamp other) { + if (other == null) { + return; + } + if (other.Seconds != 0L) { + Seconds = other.Seconds; + } + if (other.Nanos != 0) { + Nanos = other.Nanos; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 8: { + Seconds = input.ReadInt64(); + break; + } + case 16: { + Nanos = input.ReadInt32(); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs new file mode 100644 index 00000000..dbc1ee0d --- /dev/null +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs @@ -0,0 +1,1147 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/type.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Google.Protobuf.WellKnownTypes { + + namespace Proto { + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static partial class Type { + + #region Static variables + internal static pbr::FieldAccessorTable internal__static_google_protobuf_Type__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_Field__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_Enum__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_EnumValue__FieldAccessorTable; + internal static pbr::FieldAccessorTable internal__static_google_protobuf_Option__FieldAccessorTable; + #endregion + #region Descriptor + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static Type() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "Chpnb29nbGUvcHJvdG9idWYvdHlwZS5wcm90bxIPZ29vZ2xlLnByb3RvYnVm", + "Ghlnb29nbGUvcHJvdG9idWYvYW55LnByb3RvGiRnb29nbGUvcHJvdG9idWYv", + "c291cmNlX2NvbnRleHQucHJvdG8irgEKBFR5cGUSDAoEbmFtZRgBIAEoCRIm", + "CgZmaWVsZHMYAiADKAsyFi5nb29nbGUucHJvdG9idWYuRmllbGQSDgoGb25l", + "b2ZzGAMgAygJEigKB29wdGlvbnMYBCADKAsyFy5nb29nbGUucHJvdG9idWYu", + "T3B0aW9uEjYKDnNvdXJjZV9jb250ZXh0GAUgASgLMh4uZ29vZ2xlLnByb3Rv", + "YnVmLlNvdXJjZUNvbnRleHQimwUKBUZpZWxkEikKBGtpbmQYASABKA4yGy5n", + "b29nbGUucHJvdG9idWYuRmllbGQuS2luZBI3CgtjYXJkaW5hbGl0eRgCIAEo", + "DjIiLmdvb2dsZS5wcm90b2J1Zi5GaWVsZC5DYXJkaW5hbGl0eRIOCgZudW1i", + "ZXIYAyABKAUSDAoEbmFtZRgEIAEoCRIQCgh0eXBlX3VybBgGIAEoCRITCgtv", + "bmVvZl9pbmRleBgHIAEoBRIOCgZwYWNrZWQYCCABKAgSKAoHb3B0aW9ucxgJ", + "IAMoCzIXLmdvb2dsZS5wcm90b2J1Zi5PcHRpb24iuAIKBEtpbmQSEAoMVFlQ", + "RV9VTktOT1dOEAASDwoLVFlQRV9ET1VCTEUQARIOCgpUWVBFX0ZMT0FUEAIS", + "DgoKVFlQRV9JTlQ2NBADEg8KC1RZUEVfVUlOVDY0EAQSDgoKVFlQRV9JTlQz", + "MhAFEhAKDFRZUEVfRklYRUQ2NBAGEhAKDFRZUEVfRklYRUQzMhAHEg0KCVRZ", + "UEVfQk9PTBAIEg8KC1RZUEVfU1RSSU5HEAkSEAoMVFlQRV9NRVNTQUdFEAsS", + "DgoKVFlQRV9CWVRFUxAMEg8KC1RZUEVfVUlOVDMyEA0SDQoJVFlQRV9FTlVN", + "EA4SEQoNVFlQRV9TRklYRUQzMhAPEhEKDVRZUEVfU0ZJWEVENjQQEBIPCgtU", + "WVBFX1NJTlQzMhAREg8KC1RZUEVfU0lOVDY0EBIidAoLQ2FyZGluYWxpdHkS", + "FwoTQ0FSRElOQUxJVFlfVU5LTk9XThAAEhgKFENBUkRJTkFMSVRZX09QVElP", + "TkFMEAESGAoUQ0FSRElOQUxJVFlfUkVRVUlSRUQQAhIYChRDQVJESU5BTElU", + "WV9SRVBFQVRFRBADIqUBCgRFbnVtEgwKBG5hbWUYASABKAkSLQoJZW51bXZh", + "bHVlGAIgAygLMhouZ29vZ2xlLnByb3RvYnVmLkVudW1WYWx1ZRIoCgdvcHRp", + "b25zGAMgAygLMhcuZ29vZ2xlLnByb3RvYnVmLk9wdGlvbhI2Cg5zb3VyY2Vf", + "Y29udGV4dBgEIAEoCzIeLmdvb2dsZS5wcm90b2J1Zi5Tb3VyY2VDb250ZXh0", + "IlMKCUVudW1WYWx1ZRIMCgRuYW1lGAEgASgJEg4KBm51bWJlchgCIAEoBRIo", + "CgdvcHRpb25zGAMgAygLMhcuZ29vZ2xlLnByb3RvYnVmLk9wdGlvbiI7CgZP", + "cHRpb24SDAoEbmFtZRgBIAEoCRIjCgV2YWx1ZRgCIAEoCzIULmdvb2dsZS5w", + "cm90b2J1Zi5BbnlCSQoTY29tLmdvb2dsZS5wcm90b2J1ZkIJVHlwZVByb3Rv", + "UAGiAgNHUEKqAh5Hb29nbGUuUHJvdG9idWYuV2VsbEtub3duVHlwZXNiBnBy", + "b3RvMw==")); + descriptor = pbr::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, + new pbr::FileDescriptor[] { + global::Google.Protobuf.WellKnownTypes.Proto.Any.Descriptor, + global::Google.Protobuf.WellKnownTypes.Proto.SourceContext.Descriptor, + }); + internal__static_google_protobuf_Type__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.WellKnownTypes.Type), descriptor.MessageTypes[0], + new string[] { "Name", "Fields", "Oneofs", "Options", "SourceContext", }, new string[] { }); + internal__static_google_protobuf_Field__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.WellKnownTypes.Field), descriptor.MessageTypes[1], + new string[] { "Kind", "Cardinality", "Number", "Name", "TypeUrl", "OneofIndex", "Packed", "Options", }, new string[] { }); + internal__static_google_protobuf_Enum__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.WellKnownTypes.Enum), descriptor.MessageTypes[2], + new string[] { "Name", "Enumvalue", "Options", "SourceContext", }, new string[] { }); + internal__static_google_protobuf_EnumValue__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.WellKnownTypes.EnumValue), descriptor.MessageTypes[3], + new string[] { "Name", "Number", "Options", }, new string[] { }); + internal__static_google_protobuf_Option__FieldAccessorTable = + new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.WellKnownTypes.Option), descriptor.MessageTypes[4], + new string[] { "Name", "Value", }, new string[] { }); + } + #endregion + + } + } + #region Messages + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class Type : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Type()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "fields", "name", "oneofs", "options", "source_context" }; + private static readonly uint[] _fieldTags = new uint[] { 18, 10, 26, 34, 42 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Type.Descriptor.MessageTypes[0]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Type.internal__static_google_protobuf_Type__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public Type() { + OnConstruction(); + } + + partial void OnConstruction(); + + public Type(Type other) : this() { + name_ = other.name_; + fields_ = other.fields_.Clone(); + oneofs_ = other.oneofs_.Clone(); + options_ = other.options_.Clone(); + SourceContext = other.sourceContext_ != null ? other.SourceContext.Clone() : null; + } + + public Type Clone() { + return new Type(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + fields_.Freeze(); + oneofs_.Freeze(); + options_.Freeze(); + if (sourceContext_ != null) SourceContext.Freeze(); + } + + public const int NameFieldNumber = 1; + private string name_ = ""; + public string Name { + get { return name_; } + set { + pb::Freezable.CheckMutable(this); + name_ = value ?? ""; + } + } + + public const int FieldsFieldNumber = 2; + private static readonly pb::FieldCodec _repeated_fields_codec + = pb::FieldCodec.ForMessage(18, global::Google.Protobuf.WellKnownTypes.Field.Parser); + private readonly pbc::RepeatedField fields_ = new pbc::RepeatedField(); + public pbc::RepeatedField Fields { + get { return fields_; } + } + + public const int OneofsFieldNumber = 3; + private static readonly pb::FieldCodec _repeated_oneofs_codec + = pb::FieldCodec.ForString(26); + private readonly pbc::RepeatedField oneofs_ = new pbc::RepeatedField(); + public pbc::RepeatedField Oneofs { + get { return oneofs_; } + } + + public const int OptionsFieldNumber = 4; + private static readonly pb::FieldCodec _repeated_options_codec + = pb::FieldCodec.ForMessage(34, global::Google.Protobuf.WellKnownTypes.Option.Parser); + private readonly pbc::RepeatedField options_ = new pbc::RepeatedField(); + public pbc::RepeatedField Options { + get { return options_; } + } + + public const int SourceContextFieldNumber = 5; + private global::Google.Protobuf.WellKnownTypes.SourceContext sourceContext_; + public global::Google.Protobuf.WellKnownTypes.SourceContext SourceContext { + get { return sourceContext_; } + set { + pb::Freezable.CheckMutable(this); + sourceContext_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as Type); + } + + public bool Equals(Type other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Name != other.Name) return false; + if(!fields_.Equals(other.fields_)) return false; + if(!oneofs_.Equals(other.oneofs_)) return false; + if(!options_.Equals(other.options_)) return false; + if (!object.Equals(SourceContext, other.SourceContext)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Name.Length != 0) hash ^= Name.GetHashCode(); + hash ^= fields_.GetHashCode(); + hash ^= oneofs_.GetHashCode(); + hash ^= options_.GetHashCode(); + if (sourceContext_ != null) hash ^= SourceContext.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Name.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Name); + } + fields_.WriteTo(output, _repeated_fields_codec); + oneofs_.WriteTo(output, _repeated_oneofs_codec); + options_.WriteTo(output, _repeated_options_codec); + if (sourceContext_ != null) { + output.WriteRawTag(42); + output.WriteMessage(SourceContext); + } + } + + public int CalculateSize() { + int size = 0; + if (Name.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); + } + size += fields_.CalculateSize(_repeated_fields_codec); + size += oneofs_.CalculateSize(_repeated_oneofs_codec); + size += options_.CalculateSize(_repeated_options_codec); + if (sourceContext_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(SourceContext); + } + return size; + } + + public void MergeFrom(Type other) { + if (other == null) { + return; + } + if (other.Name.Length != 0) { + Name = other.Name; + } + fields_.Add(other.fields_); + oneofs_.Add(other.oneofs_); + options_.Add(other.options_); + if (other.sourceContext_ != null) { + if (sourceContext_ == null) { + sourceContext_ = new global::Google.Protobuf.WellKnownTypes.SourceContext(); + } + SourceContext.MergeFrom(other.SourceContext); + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + Name = input.ReadString(); + break; + } + case 18: { + fields_.AddEntriesFrom(input, _repeated_fields_codec); + break; + } + case 26: { + oneofs_.AddEntriesFrom(input, _repeated_oneofs_codec); + break; + } + case 34: { + options_.AddEntriesFrom(input, _repeated_options_codec); + break; + } + case 42: { + if (sourceContext_ == null) { + sourceContext_ = new global::Google.Protobuf.WellKnownTypes.SourceContext(); + } + input.ReadMessage(sourceContext_); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class Field : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Field()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "cardinality", "kind", "name", "number", "oneof_index", "options", "packed", "type_url" }; + private static readonly uint[] _fieldTags = new uint[] { 16, 8, 34, 24, 56, 74, 64, 50 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Type.Descriptor.MessageTypes[1]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Type.internal__static_google_protobuf_Field__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public Field() { + OnConstruction(); + } + + partial void OnConstruction(); + + public Field(Field other) : this() { + kind_ = other.kind_; + cardinality_ = other.cardinality_; + number_ = other.number_; + name_ = other.name_; + typeUrl_ = other.typeUrl_; + oneofIndex_ = other.oneofIndex_; + packed_ = other.packed_; + options_ = other.options_.Clone(); + } + + public Field Clone() { + return new Field(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + options_.Freeze(); + } + + public const int KindFieldNumber = 1; + private global::Google.Protobuf.WellKnownTypes.Field.Types.Kind kind_ = global::Google.Protobuf.WellKnownTypes.Field.Types.Kind.TYPE_UNKNOWN; + public global::Google.Protobuf.WellKnownTypes.Field.Types.Kind Kind { + get { return kind_; } + set { + pb::Freezable.CheckMutable(this); + kind_ = value; + } + } + + public const int CardinalityFieldNumber = 2; + private global::Google.Protobuf.WellKnownTypes.Field.Types.Cardinality cardinality_ = global::Google.Protobuf.WellKnownTypes.Field.Types.Cardinality.CARDINALITY_UNKNOWN; + public global::Google.Protobuf.WellKnownTypes.Field.Types.Cardinality Cardinality { + get { return cardinality_; } + set { + pb::Freezable.CheckMutable(this); + cardinality_ = value; + } + } + + public const int NumberFieldNumber = 3; + private int number_; + public int Number { + get { return number_; } + set { + pb::Freezable.CheckMutable(this); + number_ = value; + } + } + + public const int NameFieldNumber = 4; + private string name_ = ""; + public string Name { + get { return name_; } + set { + pb::Freezable.CheckMutable(this); + name_ = value ?? ""; + } + } + + public const int TypeUrlFieldNumber = 6; + private string typeUrl_ = ""; + public string TypeUrl { + get { return typeUrl_; } + set { + pb::Freezable.CheckMutable(this); + typeUrl_ = value ?? ""; + } + } + + public const int OneofIndexFieldNumber = 7; + private int oneofIndex_; + public int OneofIndex { + get { return oneofIndex_; } + set { + pb::Freezable.CheckMutable(this); + oneofIndex_ = value; + } + } + + public const int PackedFieldNumber = 8; + private bool packed_; + public bool Packed { + get { return packed_; } + set { + pb::Freezable.CheckMutable(this); + packed_ = value; + } + } + + public const int OptionsFieldNumber = 9; + private static readonly pb::FieldCodec _repeated_options_codec + = pb::FieldCodec.ForMessage(74, global::Google.Protobuf.WellKnownTypes.Option.Parser); + private readonly pbc::RepeatedField options_ = new pbc::RepeatedField(); + public pbc::RepeatedField Options { + get { return options_; } + } + + public override bool Equals(object other) { + return Equals(other as Field); + } + + public bool Equals(Field other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Kind != other.Kind) return false; + if (Cardinality != other.Cardinality) return false; + if (Number != other.Number) return false; + if (Name != other.Name) return false; + if (TypeUrl != other.TypeUrl) return false; + if (OneofIndex != other.OneofIndex) return false; + if (Packed != other.Packed) return false; + if(!options_.Equals(other.options_)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Kind != global::Google.Protobuf.WellKnownTypes.Field.Types.Kind.TYPE_UNKNOWN) hash ^= Kind.GetHashCode(); + if (Cardinality != global::Google.Protobuf.WellKnownTypes.Field.Types.Cardinality.CARDINALITY_UNKNOWN) hash ^= Cardinality.GetHashCode(); + if (Number != 0) hash ^= Number.GetHashCode(); + if (Name.Length != 0) hash ^= Name.GetHashCode(); + if (TypeUrl.Length != 0) hash ^= TypeUrl.GetHashCode(); + if (OneofIndex != 0) hash ^= OneofIndex.GetHashCode(); + if (Packed != false) hash ^= Packed.GetHashCode(); + hash ^= options_.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Kind != global::Google.Protobuf.WellKnownTypes.Field.Types.Kind.TYPE_UNKNOWN) { + output.WriteRawTag(8); + output.WriteEnum((int) Kind); + } + if (Cardinality != global::Google.Protobuf.WellKnownTypes.Field.Types.Cardinality.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(output, _repeated_options_codec); + } + + public int CalculateSize() { + int size = 0; + if (Kind != global::Google.Protobuf.WellKnownTypes.Field.Types.Kind.TYPE_UNKNOWN) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Kind); + } + if (Cardinality != global::Google.Protobuf.WellKnownTypes.Field.Types.Cardinality.CARDINALITY_UNKNOWN) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Cardinality); + } + if (Number != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Number); + } + if (Name.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); + } + if (TypeUrl.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(TypeUrl); + } + if (OneofIndex != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(OneofIndex); + } + if (Packed != false) { + size += 1 + 1; + } + size += options_.CalculateSize(_repeated_options_codec); + return size; + } + + public void MergeFrom(Field other) { + if (other == null) { + return; + } + if (other.Kind != global::Google.Protobuf.WellKnownTypes.Field.Types.Kind.TYPE_UNKNOWN) { + Kind = other.Kind; + } + if (other.Cardinality != global::Google.Protobuf.WellKnownTypes.Field.Types.Cardinality.CARDINALITY_UNKNOWN) { + Cardinality = other.Cardinality; + } + if (other.Number != 0) { + Number = other.Number; + } + if (other.Name.Length != 0) { + Name = other.Name; + } + if (other.TypeUrl.Length != 0) { + TypeUrl = other.TypeUrl; + } + if (other.OneofIndex != 0) { + OneofIndex = other.OneofIndex; + } + if (other.Packed != false) { + Packed = other.Packed; + } + options_.Add(other.options_); + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + 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(input, _repeated_options_codec); + break; + } + } + } + } + + #region Nested types + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static partial class Types { + public enum Kind { + TYPE_UNKNOWN = 0, + TYPE_DOUBLE = 1, + TYPE_FLOAT = 2, + TYPE_INT64 = 3, + TYPE_UINT64 = 4, + TYPE_INT32 = 5, + TYPE_FIXED64 = 6, + TYPE_FIXED32 = 7, + TYPE_BOOL = 8, + TYPE_STRING = 9, + TYPE_MESSAGE = 11, + TYPE_BYTES = 12, + TYPE_UINT32 = 13, + TYPE_ENUM = 14, + TYPE_SFIXED32 = 15, + TYPE_SFIXED64 = 16, + TYPE_SINT32 = 17, + TYPE_SINT64 = 18, + } + + public enum Cardinality { + CARDINALITY_UNKNOWN = 0, + CARDINALITY_OPTIONAL = 1, + CARDINALITY_REQUIRED = 2, + CARDINALITY_REPEATED = 3, + } + + } + #endregion + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class Enum : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Enum()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "enumvalue", "name", "options", "source_context" }; + private static readonly uint[] _fieldTags = new uint[] { 18, 10, 26, 34 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Type.Descriptor.MessageTypes[2]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Type.internal__static_google_protobuf_Enum__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public Enum() { + OnConstruction(); + } + + partial void OnConstruction(); + + public Enum(Enum other) : this() { + name_ = other.name_; + enumvalue_ = other.enumvalue_.Clone(); + options_ = other.options_.Clone(); + SourceContext = other.sourceContext_ != null ? other.SourceContext.Clone() : null; + } + + public Enum Clone() { + return new Enum(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + enumvalue_.Freeze(); + options_.Freeze(); + if (sourceContext_ != null) SourceContext.Freeze(); + } + + public const int NameFieldNumber = 1; + private string name_ = ""; + public string Name { + get { return name_; } + set { + pb::Freezable.CheckMutable(this); + name_ = value ?? ""; + } + } + + public const int EnumvalueFieldNumber = 2; + private static readonly pb::FieldCodec _repeated_enumvalue_codec + = pb::FieldCodec.ForMessage(18, global::Google.Protobuf.WellKnownTypes.EnumValue.Parser); + private readonly pbc::RepeatedField enumvalue_ = new pbc::RepeatedField(); + public pbc::RepeatedField Enumvalue { + get { return enumvalue_; } + } + + public const int OptionsFieldNumber = 3; + private static readonly pb::FieldCodec _repeated_options_codec + = pb::FieldCodec.ForMessage(26, global::Google.Protobuf.WellKnownTypes.Option.Parser); + private readonly pbc::RepeatedField options_ = new pbc::RepeatedField(); + public pbc::RepeatedField Options { + get { return options_; } + } + + public const int SourceContextFieldNumber = 4; + private global::Google.Protobuf.WellKnownTypes.SourceContext sourceContext_; + public global::Google.Protobuf.WellKnownTypes.SourceContext SourceContext { + get { return sourceContext_; } + set { + pb::Freezable.CheckMutable(this); + sourceContext_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as Enum); + } + + public bool Equals(Enum other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Name != other.Name) return false; + if(!enumvalue_.Equals(other.enumvalue_)) return false; + if(!options_.Equals(other.options_)) return false; + if (!object.Equals(SourceContext, other.SourceContext)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Name.Length != 0) hash ^= Name.GetHashCode(); + hash ^= enumvalue_.GetHashCode(); + hash ^= options_.GetHashCode(); + if (sourceContext_ != null) hash ^= SourceContext.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Name.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Name); + } + enumvalue_.WriteTo(output, _repeated_enumvalue_codec); + options_.WriteTo(output, _repeated_options_codec); + if (sourceContext_ != null) { + output.WriteRawTag(34); + output.WriteMessage(SourceContext); + } + } + + public int CalculateSize() { + int size = 0; + if (Name.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); + } + size += enumvalue_.CalculateSize(_repeated_enumvalue_codec); + size += options_.CalculateSize(_repeated_options_codec); + if (sourceContext_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(SourceContext); + } + return size; + } + + public void MergeFrom(Enum other) { + if (other == null) { + return; + } + if (other.Name.Length != 0) { + Name = other.Name; + } + enumvalue_.Add(other.enumvalue_); + options_.Add(other.options_); + if (other.sourceContext_ != null) { + if (sourceContext_ == null) { + sourceContext_ = new global::Google.Protobuf.WellKnownTypes.SourceContext(); + } + SourceContext.MergeFrom(other.SourceContext); + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + Name = input.ReadString(); + break; + } + case 18: { + enumvalue_.AddEntriesFrom(input, _repeated_enumvalue_codec); + break; + } + case 26: { + options_.AddEntriesFrom(input, _repeated_options_codec); + break; + } + case 34: { + if (sourceContext_ == null) { + sourceContext_ = new global::Google.Protobuf.WellKnownTypes.SourceContext(); + } + input.ReadMessage(sourceContext_); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class EnumValue : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new EnumValue()); + public static pb::MessageParser Parser { get { return _parser; } } + + private static readonly string[] _fieldNames = new string[] { "name", "number", "options" }; + private static readonly uint[] _fieldTags = new uint[] { 10, 16, 26 }; + public static pbr::MessageDescriptor Descriptor { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Type.Descriptor.MessageTypes[3]; } + } + + pbr::FieldAccessorTable pb::IReflectedMessage.Fields { + get { return global::Google.Protobuf.WellKnownTypes.Proto.Type.internal__static_google_protobuf_EnumValue__FieldAccessorTable; } + } + + private bool _frozen = false; + public bool IsFrozen { get { return _frozen; } } + + public EnumValue() { + OnConstruction(); + } + + partial void OnConstruction(); + + public EnumValue(EnumValue other) : this() { + name_ = other.name_; + number_ = other.number_; + options_ = other.options_.Clone(); + } + + public EnumValue Clone() { + return new EnumValue(this); + } + + public void Freeze() { + if (IsFrozen) { + return; + } + _frozen = true; + options_.Freeze(); + } + + public const int NameFieldNumber = 1; + private string name_ = ""; + public string Name { + get { return name_; } + set { + pb::Freezable.CheckMutable(this); + name_ = value ?? ""; + } + } + + public const int NumberFieldNumber = 2; + private int number_; + public int Number { + get { return number_; } + set { + pb::Freezable.CheckMutable(this); + number_ = value; + } + } + + public const int OptionsFieldNumber = 3; + private static readonly pb::FieldCodec _repeated_options_codec + = pb::FieldCodec.ForMessage(26, global::Google.Protobuf.WellKnownTypes.Option.Parser); + private readonly pbc::RepeatedField options_ = new pbc::RepeatedField(); + public pbc::RepeatedField Options { + get { return options_; } + } + + public override bool Equals(object other) { + return Equals(other as EnumValue); + } + + public bool Equals(EnumValue other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Name != other.Name) return false; + if (Number != other.Number) return false; + if(!options_.Equals(other.options_)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Name.Length != 0) hash ^= Name.GetHashCode(); + if (Number != 0) hash ^= Number.GetHashCode(); + hash ^= options_.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.Default.Format(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Name.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Name); + } + if (Number != 0) { + output.WriteRawTag(16); + output.WriteInt32(Number); + } + options_.WriteTo(output, _repeated_options_codec); + } + + public int CalculateSize() { + int size = 0; + if (Name.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); + } + if (Number != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Number); + } + size += options_.CalculateSize(_repeated_options_codec); + return size; + } + + public void MergeFrom(EnumValue other) { + if (other == null) { + return; + } + if (other.Name.Length != 0) { + Name = other.Name; + } + if (other.Number != 0) { + Number = other.Number; + } + options_.Add(other.options_); + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while (input.ReadTag(out tag)) { + switch(tag) { + case 0: + throw pb::InvalidProtocolBufferException.InvalidTag(); + default: + if (pb::WireFormat.IsEndGroupTag(tag)) { + return; + } + break; + case 10: { + Name = input.ReadString(); + break; + } + case 16: { + Number = input.ReadInt32(); + break; + } + case 26: { + options_.AddEntriesFrom(input, _repeated_options_codec); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class Option : pb::IMessage