From 685ae36ca2dbb455b440997f75cca3e88085a23f Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 16 Mar 2015 19:07:16 -0700 Subject: Rewrote C# protogen to C++ (initial version) --- src/Makefile.am | 21 +- src/google/protobuf/compiler/csharp/csharp_enum.cc | 79 ++ src/google/protobuf/compiler/csharp/csharp_enum.h | 65 ++ .../protobuf/compiler/csharp/csharp_enum_field.cc | 160 +++ .../protobuf/compiler/csharp/csharp_enum_field.h | 73 ++ .../protobuf/compiler/csharp/csharp_extension.cc | 170 +++ .../protobuf/compiler/csharp/csharp_extension.h | 80 ++ .../protobuf/compiler/csharp/csharp_field_base.cc | 394 +++++++ .../protobuf/compiler/csharp/csharp_field_base.h | 100 ++ .../protobuf/compiler/csharp/csharp_generator.cc | 82 ++ .../protobuf/compiler/csharp/csharp_generator.h | 58 + .../compiler/csharp/csharp_generator_unittest.cc | 54 + .../protobuf/compiler/csharp/csharp_helpers.cc | 383 +++++++ .../protobuf/compiler/csharp/csharp_helpers.h | 108 ++ .../protobuf/compiler/csharp/csharp_message.cc | 900 ++++++++++++++++ .../protobuf/compiler/csharp/csharp_message.h | 98 ++ .../compiler/csharp/csharp_message_field.cc | 183 ++++ .../compiler/csharp/csharp_message_field.h | 73 ++ .../compiler/csharp/csharp_primitive_field.cc | 148 +++ .../compiler/csharp/csharp_primitive_field.h | 73 ++ .../compiler/csharp/csharp_repeated_enum_field.cc | 226 ++++ .../compiler/csharp/csharp_repeated_enum_field.h | 73 ++ .../csharp/csharp_repeated_message_field.cc | 201 ++++ .../csharp/csharp_repeated_message_field.h | 73 ++ .../csharp/csharp_repeated_primitive_field.cc | 219 ++++ .../csharp/csharp_repeated_primitive_field.h | 73 ++ .../csharp/csharp_source_generator_base.cc | 82 ++ .../compiler/csharp/csharp_source_generator_base.h | 83 ++ .../compiler/csharp/csharp_umbrella_class.cc | 297 ++++++ .../compiler/csharp/csharp_umbrella_class.h | 76 ++ .../protobuf/compiler/csharp/csharp_writer.cc | 136 +++ .../protobuf/compiler/csharp/csharp_writer.h | 93 ++ src/google/protobuf/compiler/main.cc | 6 + src/google/protobuf/descriptor.pb.cc | 1116 +++++++++++++++++++- src/google/protobuf/descriptor.pb.h | 581 +++++++++- src/google/protobuf/descriptor.proto | 52 + 36 files changed, 6640 insertions(+), 49 deletions(-) create mode 100644 src/google/protobuf/compiler/csharp/csharp_enum.cc create mode 100644 src/google/protobuf/compiler/csharp/csharp_enum.h create mode 100644 src/google/protobuf/compiler/csharp/csharp_enum_field.cc create mode 100644 src/google/protobuf/compiler/csharp/csharp_enum_field.h create mode 100644 src/google/protobuf/compiler/csharp/csharp_extension.cc create mode 100644 src/google/protobuf/compiler/csharp/csharp_extension.h create mode 100644 src/google/protobuf/compiler/csharp/csharp_field_base.cc create mode 100644 src/google/protobuf/compiler/csharp/csharp_field_base.h create mode 100644 src/google/protobuf/compiler/csharp/csharp_generator.cc create mode 100644 src/google/protobuf/compiler/csharp/csharp_generator.h create mode 100644 src/google/protobuf/compiler/csharp/csharp_generator_unittest.cc create mode 100644 src/google/protobuf/compiler/csharp/csharp_helpers.cc create mode 100644 src/google/protobuf/compiler/csharp/csharp_helpers.h create mode 100644 src/google/protobuf/compiler/csharp/csharp_message.cc create mode 100644 src/google/protobuf/compiler/csharp/csharp_message.h create mode 100644 src/google/protobuf/compiler/csharp/csharp_message_field.cc create mode 100644 src/google/protobuf/compiler/csharp/csharp_message_field.h create mode 100644 src/google/protobuf/compiler/csharp/csharp_primitive_field.cc create mode 100644 src/google/protobuf/compiler/csharp/csharp_primitive_field.h create mode 100644 src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc create mode 100644 src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.h create mode 100644 src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc create mode 100644 src/google/protobuf/compiler/csharp/csharp_repeated_message_field.h create mode 100644 src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc create mode 100644 src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h create mode 100644 src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc create mode 100644 src/google/protobuf/compiler/csharp/csharp_source_generator_base.h create mode 100644 src/google/protobuf/compiler/csharp/csharp_umbrella_class.cc create mode 100644 src/google/protobuf/compiler/csharp/csharp_umbrella_class.h create mode 100644 src/google/protobuf/compiler/csharp/csharp_writer.cc create mode 100644 src/google/protobuf/compiler/csharp/csharp_writer.h (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 8a27b823..59f7eaa2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -126,7 +126,8 @@ nobase_include_HEADERS = \ google/protobuf/compiler/java/java_names.h \ google/protobuf/compiler/javanano/javanano_generator.h \ google/protobuf/compiler/python/python_generator.h \ - google/protobuf/compiler/ruby/ruby_generator.h + google/protobuf/compiler/ruby/ruby_generator.h \ + google/protobuf/compiler/csharp/csharp_generator.h nobase_nodist_include_HEADERS = \ $(public_config) @@ -288,7 +289,22 @@ libprotoc_la_SOURCES = \ google/protobuf/compiler/javanano/javanano_primitive_field.cc \ google/protobuf/compiler/javanano/javanano_primitive_field.h \ google/protobuf/compiler/python/python_generator.cc \ - google/protobuf/compiler/ruby/ruby_generator.cc + google/protobuf/compiler/ruby/ruby_generator.cc \ + google/protobuf/compiler/csharp/csharp_enum.cc \ + google/protobuf/compiler/csharp/csharp_enum_field.cc \ + google/protobuf/compiler/csharp/csharp_extension.cc \ + google/protobuf/compiler/csharp/csharp_field_base.cc \ + google/protobuf/compiler/csharp/csharp_generator.cc \ + google/protobuf/compiler/csharp/csharp_helpers.cc \ + google/protobuf/compiler/csharp/csharp_message.cc \ + google/protobuf/compiler/csharp/csharp_message_field.cc \ + google/protobuf/compiler/csharp/csharp_primitive_field.cc \ + google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc \ + google/protobuf/compiler/csharp/csharp_repeated_message_field.cc \ + google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc \ + google/protobuf/compiler/csharp/csharp_source_generator_base.cc \ + google/protobuf/compiler/csharp/csharp_umbrella_class.cc \ + google/protobuf/compiler/csharp/csharp_writer.cc bin_PROGRAMS = protoc protoc_LDADD = $(PTHREAD_LIBS) libprotobuf.la libprotoc.la @@ -493,6 +509,7 @@ protobuf_test_SOURCES = \ google/protobuf/compiler/java/java_doc_comment_unittest.cc \ google/protobuf/compiler/python/python_plugin_unittest.cc \ google/protobuf/compiler/ruby/ruby_generator_unittest.cc \ + google/protobuf/compiler/csharp/csharp_generator_unittest.cc \ $(COMMON_TEST_SOURCES) nodist_protobuf_test_SOURCES = $(protoc_outputs) diff --git a/src/google/protobuf/compiler/csharp/csharp_enum.cc b/src/google/protobuf/compiler/csharp/csharp_enum.cc new file mode 100644 index 00000000..27643e61 --- /dev/null +++ b/src/google/protobuf/compiler/csharp/csharp_enum.cc @@ -0,0 +1,79 @@ +// 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 +#include + +using google::protobuf::internal::scoped_ptr; + +namespace google { +namespace protobuf { +namespace compiler { +namespace csharp { + +EnumGenerator::EnumGenerator(const EnumDescriptor* descriptor) : + SourceGeneratorBase(descriptor->file()), + descriptor_(descriptor) { +} + +EnumGenerator::~EnumGenerator() { +} + +void EnumGenerator::Generate(Writer* writer) { + WriteGeneratedCodeAttributes(writer); + writer->WriteLine("$0$ enum $1$ {", + class_access_level(), + descriptor_->name()); + writer->Indent(); + for (int i = 0; i < descriptor_->value_count(); i++) { + writer->WriteLine("$0$ = $1$,", + descriptor_->value(i)->name(), + SimpleItoa(descriptor_->value(i)->number())); + } + writer->Outdent(); + writer->WriteLine("}"); + writer->WriteLine(); +} + +} // namespace csharp +} // namespace compiler +} // namespace protobuf +} // namespace google diff --git a/src/google/protobuf/compiler/csharp/csharp_enum.h b/src/google/protobuf/compiler/csharp/csharp_enum.h new file mode 100644 index 00000000..eaa7a9c5 --- /dev/null +++ b/src/google/protobuf/compiler/csharp/csharp_enum.h @@ -0,0 +1,65 @@ +// 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_ENUM_H__ +#define GOOGLE_PROTOBUF_COMPILER_CSHARP_ENUM_H__ + +#include + +#include +#include + +namespace google { +namespace protobuf { +namespace compiler { +namespace csharp { + +class Writer; + +class EnumGenerator : public SourceGeneratorBase { + public: + EnumGenerator(const EnumDescriptor* descriptor); + ~EnumGenerator(); + + void Generate(Writer* writer); + + private: + const EnumDescriptor* descriptor_; + + GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumGenerator); +}; + +} // namespace csharp +} // namespace compiler +} // namespace protobuf +} // namespace google + +#endif // GOOGLE_PROTOBUF_COMPILER_CSHARP_ENUM_H__ + diff --git a/src/google/protobuf/compiler/csharp/csharp_enum_field.cc b/src/google/protobuf/compiler/csharp/csharp_enum_field.cc new file mode 100644 index 00000000..d5b1b477 --- /dev/null +++ b/src/google/protobuf/compiler/csharp/csharp_enum_field.cc @@ -0,0 +1,160 @@ +// 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 + +namespace google { +namespace protobuf { +namespace compiler { +namespace csharp { + +EnumFieldGenerator::EnumFieldGenerator(const FieldDescriptor* descriptor, + int fieldOrdinal) + : FieldGeneratorBase(descriptor, fieldOrdinal) { +} + +EnumFieldGenerator::~EnumFieldGenerator() { + +} + +void EnumFieldGenerator::GenerateMembers(Writer* writer) { + writer->WriteLine("private bool has$0$;", property_name()); + writer->WriteLine("private $0$ $1$_ = $2$;", type_name(), name(), + default_value()); + AddDeprecatedFlag(writer); + writer->WriteLine("public bool Has$0$ {", property_name()); + writer->WriteLine(" get { return has$0$; }", property_name()); + writer->WriteLine("}"); + AddPublicMemberAttributes(writer); + writer->WriteLine("public $0$ $1$ {", type_name(), property_name()); + writer->WriteLine(" get { return $0$_; }", name()); + writer->WriteLine("}"); +} + +void EnumFieldGenerator::GenerateBuilderMembers(Writer* writer) { + AddDeprecatedFlag(writer); + writer->WriteLine("public bool Has$0$ {", property_name()); + writer->WriteLine(" get { return result.has$0$; }", property_name()); + writer->WriteLine("}"); + AddPublicMemberAttributes(writer); + writer->WriteLine("public $0$ $1$ {", type_name(), property_name()); + writer->WriteLine(" get { return result.$0$; }", property_name()); + writer->WriteLine(" set { Set$0$(value); }", property_name()); + writer->WriteLine("}"); + AddPublicMemberAttributes(writer); + writer->WriteLine("public Builder Set$0$($1$ value) {", property_name(), + type_name()); + writer->WriteLine(" PrepareBuilder();"); + writer->WriteLine(" result.has$0$ = true;", property_name()); + writer->WriteLine(" result.$0$_ = value;", name()); + writer->WriteLine(" return this;"); + writer->WriteLine("}"); + AddDeprecatedFlag(writer); + writer->WriteLine("public Builder Clear$0$() {", property_name()); + writer->WriteLine(" PrepareBuilder();"); + writer->WriteLine(" result.has$0$ = false;", property_name()); + writer->WriteLine(" result.$0$_ = $1$;", name(), default_value()); + writer->WriteLine(" return this;"); + writer->WriteLine("}"); +} + +void EnumFieldGenerator::GenerateMergingCode(Writer* writer) { + writer->WriteLine("if (other.Has$0$) {", property_name()); + writer->WriteLine(" $0$ = other.$0$;", property_name()); + writer->WriteLine("}"); +} + +void EnumFieldGenerator::GenerateBuildingCode(Writer* writer) { + // Nothing to do here for enum types +} + +void EnumFieldGenerator::GenerateParsingCode(Writer* writer) { + writer->WriteLine("object unknown;"); + writer->WriteLine("if(input.ReadEnum(ref result.$0$_, out unknown)) {", + name()); + writer->WriteLine(" result.has$0$ = true;", property_name()); + writer->WriteLine("} else if(unknown is int) {"); + if (!use_lite_runtime()) { + writer->WriteLine(" if (unknownFields == null) {"); // First unknown field - create builder now + writer->WriteLine( + " unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);"); + writer->WriteLine(" }"); + writer->WriteLine( + " unknownFields.MergeVarintField($0$, (ulong)(int)unknown);", + number()); + } + writer->WriteLine("}"); +} + +void EnumFieldGenerator::GenerateSerializationCode(Writer* writer) { + writer->WriteLine("if (has$0$) {", property_name()); + writer->WriteLine( + " output.WriteEnum($0$, field_names[$2$], (int) $1$, $1$);", number(), + property_name(), field_ordinal()); + writer->WriteLine("}"); +} + +void EnumFieldGenerator::GenerateSerializedSizeCode(Writer* writer) { + writer->WriteLine("if (has$0$) {", property_name()); + writer->WriteLine( + " size += pb::CodedOutputStream.ComputeEnumSize($0$, (int) $1$);", + number(), property_name()); + writer->WriteLine("}"); +} + +void EnumFieldGenerator::WriteHash(Writer* writer) { + writer->WriteLine("if (has$0$) hash ^= $1$_.GetHashCode();", property_name(), + name()); +} +void EnumFieldGenerator::WriteEquals(Writer* writer) { + writer->WriteLine( + "if (has$0$ != other.has$0$ || (has$0$ && !$1$_.Equals(other.$1$_))) return false;", + property_name(), name()); +} +void EnumFieldGenerator::WriteToString(Writer* writer) { + writer->WriteLine("PrintField(\"$0$\", has$1$, $2$_, writer);", + descriptor_->name(), property_name(), name()); +} + +} // namespace csharp +} // namespace compiler +} // namespace protobuf +} // namespace google diff --git a/src/google/protobuf/compiler/csharp/csharp_enum_field.h b/src/google/protobuf/compiler/csharp/csharp_enum_field.h new file mode 100644 index 00000000..b21fa9dc --- /dev/null +++ b/src/google/protobuf/compiler/csharp/csharp_enum_field.h @@ -0,0 +1,73 @@ +// 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_ENUM_FIELD_H__ +#define GOOGLE_PROTOBUF_COMPILER_CSHARP_ENUM_FIELD_H__ + +#include + +#include +#include + +namespace google { +namespace protobuf { +namespace compiler { +namespace csharp { + +class Writer; + +class EnumFieldGenerator : public FieldGeneratorBase { + public: + EnumFieldGenerator(const FieldDescriptor* descriptor, int fieldOrdinal); + ~EnumFieldGenerator(); + + virtual void GenerateMembers(Writer* writer); + virtual void GenerateBuilderMembers(Writer* writer); + virtual void GenerateMergingCode(Writer* writer); + virtual void GenerateBuildingCode(Writer* writer); + virtual void GenerateParsingCode(Writer* writer); + virtual void GenerateSerializationCode(Writer* writer); + virtual void GenerateSerializedSizeCode(Writer* writer); + + virtual void WriteHash(Writer* writer); + virtual void WriteEquals(Writer* writer); + virtual void WriteToString(Writer* writer); + + private: + GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumFieldGenerator); +}; + +} // namespace csharp +} // namespace compiler +} // namespace protobuf +} // namespace google + +#endif // GOOGLE_PROTOBUF_COMPILER_CSHARP_ENUM_FIELD_H__ + diff --git a/src/google/protobuf/compiler/csharp/csharp_extension.cc b/src/google/protobuf/compiler/csharp/csharp_extension.cc new file mode 100644 index 00000000..f929f49f --- /dev/null +++ b/src/google/protobuf/compiler/csharp/csharp_extension.cc @@ -0,0 +1,170 @@ +// 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 +#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()) { + scope_ = GetClassName(descriptor_->extension_scope()); + } else { + scope_ = GetFullUmbrellaClassName(descriptor_->file()); + } + extends_ = GetClassName(descriptor_->containing_type()); +} + +ExtensionGenerator::~ExtensionGenerator() { +} + +void ExtensionGenerator::Generate(Writer* writer) { + if (descriptor_->file()->options().csharp_cls_compliance() + && (GetFieldConstantName(descriptor_).substr(0, 1) == "_")) { + writer->WriteLine("[global::System.CLSCompliant(false)]"); + } + + writer->WriteLine("public const int $0$ = $1$;", + GetFieldConstantName(descriptor_), + SimpleItoa(descriptor_->number())); + + if (use_lite_runtime()) { + // TODO(jtattermusch): check the argument... + //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."); + //} + + AddClsComplianceCheck(writer); + writer->Write("$0$ ", class_access_level()); + writer->WriteLine( + "static pb::$3$<$0$, $1$> $2$;", + extends_, + type_name(), + property_name(), + descriptor_->is_repeated() ? + "GeneratedRepeatExtensionLite" : "GeneratedExtensionLite"); + } else if (descriptor_->is_repeated()) { + AddClsComplianceCheck(writer); + writer->WriteLine( + "$0$ static pb::GeneratedExtensionBase> $2$;", + class_access_level(), type_name(), property_name()); + } else { + AddClsComplianceCheck(writer); + writer->WriteLine("$0$ static pb::GeneratedExtensionBase<$1$> $2$;", + class_access_level(), type_name(), property_name()); + } +} + +void ExtensionGenerator::GenerateStaticVariableInitializers(Writer* writer) { + if (use_lite_runtime()) { + writer->WriteLine("$0$.$1$ = ", scope_, property_name()); + writer->Indent(); + writer->WriteLine( + "new pb::$0$<$1$, $2$>(", + descriptor_->is_repeated() ? + "GeneratedRepeatExtensionLite" : "GeneratedExtensionLite", + extends_, type_name()); + writer->Indent(); + writer->WriteLine("\"$0$\",", descriptor_->full_name()); + writer->WriteLine("$0$.DefaultInstance,", extends_); + 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() + ")"); + } + writer->WriteLine("$0$,", default_val); + } + // TODO(jtattermusch): + //writer.WriteLine("{0},", + // (Descriptor.MappedType == MappedType.Message) ? type + ".DefaultInstance" : "null"); + //writer.WriteLine("{0},", + // (Descriptor.MappedType == MappedType.Enum) ? "new EnumLiteMap<" + type + ">()" : "null"); + //writer.WriteLine("{0}.{1}FieldNumber,", scope, name); + //writer.Write("pbd::FieldType.{0}", Descriptor.FieldType); + if (descriptor_->is_repeated()) { + writer->WriteLine(","); + writer->Write(descriptor_->is_packed() ? "true" : "false"); + } + writer->Outdent(); + writer->WriteLine(");"); + writer->Outdent(); + } + else if (descriptor_->is_repeated()) + { + writer->WriteLine( + "$0$.$1$ = pb::GeneratedRepeatExtension<$2$>.CreateInstance($0$.Descriptor.Extensions[$3$]);", + scope_, property_name(), type_name(), SimpleItoa(descriptor_->index())); + } + else + { + writer->WriteLine( + "$0$.$1$ = pb::GeneratedSingleExtension<$2$>.CreateInstance($0$.Descriptor.Extensions[$3$]);", + scope_, property_name(), type_name(), SimpleItoa(descriptor_->index())); + } +} + +void ExtensionGenerator::GenerateExtensionRegistrationCode(Writer* writer) { + writer->WriteLine("registry.Add($0$.$1$);", scope_, property_name()); +} + +void ExtensionGenerator::WriteHash(Writer* writer) { +} + +void ExtensionGenerator::WriteEquals(Writer* writer) { +} + +void ExtensionGenerator::WriteToString(Writer* writer) { +} + +} // 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 new file mode 100644 index 00000000..203f6e5e --- /dev/null +++ b/src/google/protobuf/compiler/csharp/csharp_extension.h @@ -0,0 +1,80 @@ +// 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 Writer; + +class ExtensionGenerator : public FieldGeneratorBase { + public: + ExtensionGenerator(const FieldDescriptor* descriptor); + ~ExtensionGenerator(); + + void GenerateStaticVariableInitializers(Writer* writer); + void GenerateExtensionRegistrationCode(Writer* writer); + void Generate(Writer* writer); + + virtual void WriteHash(Writer* writer); + virtual void WriteEquals(Writer* writer); + virtual void WriteToString(Writer* writer); + + virtual void GenerateMembers(Writer* writer) {}; + virtual void GenerateBuilderMembers(Writer* writer) {}; + virtual void GenerateMergingCode(Writer* writer) {}; + virtual void GenerateBuildingCode(Writer* writer) {}; + virtual void GenerateParsingCode(Writer* writer) {}; + virtual void GenerateSerializationCode(Writer* writer) {}; + virtual void GenerateSerializedSizeCode(Writer* writer) {}; + + 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 new file mode 100644 index 00000000..48af999c --- /dev/null +++ b/src/google/protobuf/compiler/csharp/csharp_field_base.cc @@ -0,0 +1,394 @@ +// 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 +#include +#include + +using google::protobuf::internal::scoped_ptr; + +namespace google { +namespace protobuf { +namespace compiler { +namespace csharp { + +FieldGeneratorBase::FieldGeneratorBase(const FieldDescriptor* descriptor, + int fieldOrdinal) + : SourceGeneratorBase(descriptor->file()), + descriptor_(descriptor), + fieldOrdinal_(fieldOrdinal) { +} + +FieldGeneratorBase::~FieldGeneratorBase() { +} + +void FieldGeneratorBase::AddDeprecatedFlag(Writer* writer) { + // TODO(jtattermusch): + //if (IsObsolete) + //{ + // writer.WriteLine("[global::System.ObsoleteAttribute()]"); + //} +} + +void FieldGeneratorBase::AddNullCheck(Writer* writer) { + AddNullCheck(writer, "value"); +} + +void FieldGeneratorBase::AddNullCheck(Writer* writer, const std::string& name) { + if (is_nullable_type()) { + writer->WriteLine(" pb::ThrowHelper.ThrowIfNull($0$, \"$0$\");", name); + } +} + +void FieldGeneratorBase::AddPublicMemberAttributes(Writer* writer) { + AddDeprecatedFlag(writer); + AddClsComplianceCheck(writer); +} + +void FieldGeneratorBase::AddClsComplianceCheck(Writer* writer) { + if (!is_cls_compliant() && descriptor_->file()->options().csharp_cls_compliance()) { + writer->WriteLine("[global::System.CLSCompliant(false)]"); + } +} + +std::string FieldGeneratorBase::property_name() { + return GetPropertyName(descriptor_); +} + +std::string FieldGeneratorBase::name() { + return UnderscoresToCamelCase(GetFieldName(descriptor_), false); +} + +std::string FieldGeneratorBase::type_name() { + switch (descriptor_->type()) { + case FieldDescriptor::TYPE_ENUM: + return GetClassName(descriptor_->enum_type()); + case FieldDescriptor::TYPE_MESSAGE: + case FieldDescriptor::TYPE_GROUP: + return GetClassName(descriptor_->message_type()); + case FieldDescriptor::TYPE_DOUBLE: + return "double"; + case FieldDescriptor::TYPE_FLOAT: + return "float"; + case FieldDescriptor::TYPE_INT64: + return "long"; + case FieldDescriptor::TYPE_UINT64: + return "ulong"; + case FieldDescriptor::TYPE_INT32: + return "int"; + case FieldDescriptor::TYPE_FIXED64: + return "ulong"; + case FieldDescriptor::TYPE_FIXED32: + return "uint"; + case FieldDescriptor::TYPE_BOOL: + return "bool"; + case FieldDescriptor::TYPE_STRING: + return "string"; + case FieldDescriptor::TYPE_BYTES: + return "pb::ByteString"; + case FieldDescriptor::TYPE_UINT32: + return "uint"; + case FieldDescriptor::TYPE_SFIXED32: + return "int"; + case FieldDescriptor::TYPE_SFIXED64: + return "long"; + case FieldDescriptor::TYPE_SINT32: + return "int"; + case FieldDescriptor::TYPE_SINT64: + return "long"; + default: + GOOGLE_LOG(FATAL)<< "Unknown field type."; + return ""; + } +} + +bool FieldGeneratorBase::has_default_value() { + switch (descriptor_->type()) { + case FieldDescriptor::TYPE_ENUM: + case FieldDescriptor::TYPE_MESSAGE: + case FieldDescriptor::TYPE_GROUP: + return true; + case FieldDescriptor::TYPE_DOUBLE: + return descriptor_->default_value_double() != 0.0; + case FieldDescriptor::TYPE_FLOAT: + return descriptor_->default_value_float() != 0.0; + case FieldDescriptor::TYPE_INT64: + return descriptor_->default_value_int64() != 0L; + case FieldDescriptor::TYPE_UINT64: + return descriptor_->default_value_uint64() != 0L; + case FieldDescriptor::TYPE_INT32: + return descriptor_->default_value_int32() != 0; + case FieldDescriptor::TYPE_FIXED64: + return descriptor_->default_value_uint64() != 0L; + case FieldDescriptor::TYPE_FIXED32: + return descriptor_->default_value_uint32() != 0; + case FieldDescriptor::TYPE_BOOL: + return descriptor_->default_value_bool(); + case FieldDescriptor::TYPE_STRING: + return true; + case FieldDescriptor::TYPE_BYTES: + return true; + case FieldDescriptor::TYPE_UINT32: + return descriptor_->default_value_uint32() != 0; + case FieldDescriptor::TYPE_SFIXED32: + return descriptor_->default_value_int32() != 0; + case FieldDescriptor::TYPE_SFIXED64: + return descriptor_->default_value_int64() != 0L; + case FieldDescriptor::TYPE_SINT32: + return descriptor_->default_value_int32() != 0; + case FieldDescriptor::TYPE_SINT64: + return descriptor_->default_value_int64() != 0L; + default: + GOOGLE_LOG(FATAL)<< "Unknown field type."; + return true; + } +} + +bool FieldGeneratorBase::is_nullable_type() { + switch (descriptor_->type()) { + case FieldDescriptor::TYPE_ENUM: + case FieldDescriptor::TYPE_DOUBLE: + case FieldDescriptor::TYPE_FLOAT: + case FieldDescriptor::TYPE_INT64: + case FieldDescriptor::TYPE_UINT64: + case FieldDescriptor::TYPE_INT32: + case FieldDescriptor::TYPE_FIXED64: + case FieldDescriptor::TYPE_FIXED32: + case FieldDescriptor::TYPE_BOOL: + case FieldDescriptor::TYPE_UINT32: + case FieldDescriptor::TYPE_SFIXED32: + case FieldDescriptor::TYPE_SFIXED64: + case FieldDescriptor::TYPE_SINT32: + case FieldDescriptor::TYPE_SINT64: + return false; + + case FieldDescriptor::TYPE_MESSAGE: + case FieldDescriptor::TYPE_GROUP: + case FieldDescriptor::TYPE_STRING: + case FieldDescriptor::TYPE_BYTES: + return true; + + default: + GOOGLE_LOG(FATAL)<< "Unknown field type."; + return true; + } +} + +bool FieldGeneratorBase::is_cls_compliant() { + CSharpType type = GetCSharpType(descriptor_->type()); + return (type != CSHARPTYPE_UINT32) && (type != CSHARPTYPE_UINT64) + && (UnderscoresToPascalCase(name()).substr(0, 1) != "_"); +} + +inline bool IsNaN(double value) { + // NaN is never equal to anything, even itself. + return value != value; +} + +bool AllPrintableAscii(const std::string& text) { + for(int i = 0; i < text.size(); i++) { + if (text[i] < 0x20 || text[i] > 0x7e) { + return false; + } + } + return true; +} + +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"; +} + +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"; +} + +std::string FieldGeneratorBase::default_value() { + switch (descriptor_->type()) { + case FieldDescriptor::TYPE_ENUM: + return type_name() + "." + descriptor_->default_value_enum()->name(); + case FieldDescriptor::TYPE_MESSAGE: + case FieldDescriptor::TYPE_GROUP: + return type_name() + ".DefaultInstance"; + case FieldDescriptor::TYPE_DOUBLE: { + double value = descriptor_->default_value_double(); + if (value == numeric_limits::infinity()) { + return "double.PositiveInfinity"; + } else if (value == -numeric_limits::infinity()) { + return "double.NegativeInfinity"; + } else if (IsNaN(value)) { + return "double.NaN"; + } + return SimpleDtoa(value) + "D"; + } + case FieldDescriptor::TYPE_FLOAT: { + float value = descriptor_->default_value_float(); + if (value == numeric_limits::infinity()) { + return "float.PositiveInfinity"; + } else if (value == -numeric_limits::infinity()) { + return "float.NegativeInfinity"; + } else if (IsNaN(value)) { + return "float.NaN"; + } + return SimpleFtoa(value) + "F"; + } + case FieldDescriptor::TYPE_INT64: + return SimpleItoa(descriptor_->default_value_int64()) + "L"; + case FieldDescriptor::TYPE_UINT64: + return SimpleItoa(descriptor_->default_value_uint64()) + "UL"; + case FieldDescriptor::TYPE_INT32: + return SimpleItoa(descriptor_->default_value_int32()); + case FieldDescriptor::TYPE_FIXED64: + return SimpleItoa(descriptor_->default_value_uint64()) + "UL"; + case FieldDescriptor::TYPE_FIXED32: + return SimpleItoa(descriptor_->default_value_uint32()); + case FieldDescriptor::TYPE_BOOL: + if (descriptor_->default_value_bool()) { + return "true"; + } else { + return "false"; + } + case FieldDescriptor::TYPE_STRING: + return GetStringDefaultValueInternal(); + case FieldDescriptor::TYPE_BYTES: + return GetBytesDefaultValueInternal(); + case FieldDescriptor::TYPE_UINT32: + return SimpleItoa(descriptor_->default_value_uint32()); + case FieldDescriptor::TYPE_SFIXED32: + return SimpleItoa(descriptor_->default_value_int32()); + case FieldDescriptor::TYPE_SFIXED64: + return SimpleItoa(descriptor_->default_value_int64()) + "L"; + case FieldDescriptor::TYPE_SINT32: + return SimpleItoa(descriptor_->default_value_int32()); + case FieldDescriptor::TYPE_SINT64: + return SimpleItoa(descriptor_->default_value_int64()) + "L"; + default: + GOOGLE_LOG(FATAL)<< "Unknown field type."; + return ""; + } +} + +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: + return "Enum"; + case FieldDescriptor::TYPE_MESSAGE: + return "Message"; + case FieldDescriptor::TYPE_GROUP: + return "Group"; + case FieldDescriptor::TYPE_DOUBLE: + return "Double"; + case FieldDescriptor::TYPE_FLOAT: + return "Float"; + case FieldDescriptor::TYPE_INT64: + return "Int64"; + case FieldDescriptor::TYPE_UINT64: + return "UInt64"; + case FieldDescriptor::TYPE_INT32: + return "Int32"; + case FieldDescriptor::TYPE_FIXED64: + return "Fixed64"; + case FieldDescriptor::TYPE_FIXED32: + return "Fixed32"; + case FieldDescriptor::TYPE_BOOL: + return "Bool"; + case FieldDescriptor::TYPE_STRING: + return "String"; + case FieldDescriptor::TYPE_BYTES: + return "Bytes"; + case FieldDescriptor::TYPE_UINT32: + return "UInt32"; + case FieldDescriptor::TYPE_SFIXED32: + return "SFixed32"; + case FieldDescriptor::TYPE_SFIXED64: + return "SFixed64"; + case FieldDescriptor::TYPE_SINT32: + return "SInt32"; + case FieldDescriptor::TYPE_SINT64: + return "SInt64"; + default: + GOOGLE_LOG(FATAL)<< "Unknown field type."; + return ""; + } +} + +std::string FieldGeneratorBase::field_ordinal() { + return SimpleItoa(fieldOrdinal_); +} + +} // namespace csharp +} // namespace compiler +} // namespace protobuf +} // namespace google diff --git a/src/google/protobuf/compiler/csharp/csharp_field_base.h b/src/google/protobuf/compiler/csharp/csharp_field_base.h new file mode 100644 index 00000000..4f3a7658 --- /dev/null +++ b/src/google/protobuf/compiler/csharp/csharp_field_base.h @@ -0,0 +1,100 @@ +// 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_FIELD_BASE_H__ +#define GOOGLE_PROTOBUF_COMPILER_CSHARP_FIELD_BASE_H__ + +#include +#include + +#include +#include + +namespace google { +namespace protobuf { +namespace compiler { +namespace csharp { + +class Writer; + +class FieldGeneratorBase : public SourceGeneratorBase { + public: + FieldGeneratorBase(const FieldDescriptor* descriptor, int fieldOrdinal); + ~FieldGeneratorBase(); + + virtual void GenerateMembers(Writer* writer) = 0; + virtual void GenerateBuilderMembers(Writer* writer) = 0; + virtual void GenerateMergingCode(Writer* writer) = 0; + virtual void GenerateBuildingCode(Writer* writer) = 0; + virtual void GenerateParsingCode(Writer* writer) = 0; + virtual void GenerateSerializationCode(Writer* writer) = 0; + virtual void GenerateSerializedSizeCode(Writer* writer) = 0; + + virtual void WriteHash(Writer* writer) = 0; + virtual void WriteEquals(Writer* writer) = 0; + virtual void WriteToString(Writer* writer) = 0; + + protected: + const FieldDescriptor* descriptor_; + const int fieldOrdinal_; + + void AddDeprecatedFlag(Writer* writer); + void AddNullCheck(Writer* writer); + void AddNullCheck(Writer* writer, const std::string& name); + + void AddPublicMemberAttributes(Writer* writer); + void AddClsComplianceCheck(Writer* writer); + + std::string property_name(); + std::string name(); + std::string type_name(); + bool has_default_value(); + bool is_nullable_type(); + bool is_cls_compliant(); + std::string default_value(); + std::string number(); + std::string message_or_group(); + std::string capitalized_type_name(); + std::string field_ordinal(); + + private: + std::string GetStringDefaultValueInternal(); + std::string GetBytesDefaultValueInternal(); + + GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldGeneratorBase); +}; + +} // namespace csharp +} // namespace compiler +} // namespace protobuf +} // namespace google + +#endif // GOOGLE_PROTOBUF_COMPILER_CSHARP_FIELD_BASE_H__ + diff --git a/src/google/protobuf/compiler/csharp/csharp_generator.cc b/src/google/protobuf/compiler/csharp/csharp_generator.cc new file mode 100644 index 00000000..0cac22df --- /dev/null +++ b/src/google/protobuf/compiler/csharp/csharp_generator.cc @@ -0,0 +1,82 @@ +// 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 +#include + +using google::protobuf::internal::scoped_ptr; + +namespace google { +namespace protobuf { +namespace compiler { +namespace csharp { + +void GenerateFile(const google::protobuf::FileDescriptor* file, + Writer* writer) { + UmbrellaClassGenerator umbrellaGenerator(file); + umbrellaGenerator.Generate(writer); +} + +bool Generator::Generate( + const FileDescriptor* file, + const string& parameter, + GeneratorContext* generator_context, + string* error) const { + + // TODO: parse generator parameters... + + // TODO: file output file naming logic + std::string filename = + StripDotProto(file->name()) + ".cs"; + scoped_ptr output( + generator_context->Open(filename)); + io::Printer printer(output.get(), '$'); + Writer writer(&printer); + + GenerateFile(file, &writer); + + return true; +} + +} // namespace csharp +} // namespace compiler +} // namespace protobuf +} // namespace google diff --git a/src/google/protobuf/compiler/csharp/csharp_generator.h b/src/google/protobuf/compiler/csharp/csharp_generator.h new file mode 100644 index 00000000..9b54e914 --- /dev/null +++ b/src/google/protobuf/compiler/csharp/csharp_generator.h @@ -0,0 +1,58 @@ +// 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_GENERATOR_H__ +#define GOOGLE_PROTOBUF_COMPILER_CSHARP_GENERATOR_H__ + +#include + +#include + +namespace google { +namespace protobuf { +namespace compiler { +namespace csharp { + +class LIBPROTOC_EXPORT Generator + : public google::protobuf::compiler::CodeGenerator { + virtual bool Generate( + const FileDescriptor* file, + const string& parameter, + GeneratorContext* generator_context, + string* error) const; +}; + +} // namespace csharp +} // namespace compiler +} // namespace protobuf +} // namespace google + +#endif // GOOGLE_PROTOBUF_COMPILER_CSHARP_GENERATOR_H__ + diff --git a/src/google/protobuf/compiler/csharp/csharp_generator_unittest.cc b/src/google/protobuf/compiler/csharp/csharp_generator_unittest.cc new file mode 100644 index 00000000..7ef7df42 --- /dev/null +++ b/src/google/protobuf/compiler/csharp/csharp_generator_unittest.cc @@ -0,0 +1,54 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2014 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 + +namespace google { +namespace protobuf { +namespace compiler { +namespace csharp { +namespace { + +// TODO(jtattermusch): add some tests. + +} // namespace +} // namespace csharp +} // namespace compiler +} // namespace protobuf +} // namespace google diff --git a/src/google/protobuf/compiler/csharp/csharp_helpers.cc b/src/google/protobuf/compiler/csharp/csharp_helpers.cc new file mode 100644 index 00000000..49ae2c94 --- /dev/null +++ b/src/google/protobuf/compiler/csharp/csharp_helpers.cc @@ -0,0 +1,383 @@ +// 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 { + +CSharpType GetCSharpType(FieldDescriptor::Type type) { + switch (type) { + case FieldDescriptor::TYPE_INT32: + return CSHARPTYPE_INT32; + case FieldDescriptor::TYPE_INT64: + return CSHARPTYPE_INT64; + case FieldDescriptor::TYPE_UINT32: + return CSHARPTYPE_UINT32; + case FieldDescriptor::TYPE_UINT64: + return CSHARPTYPE_UINT32; + case FieldDescriptor::TYPE_SINT32: + return CSHARPTYPE_INT32; + case FieldDescriptor::TYPE_SINT64: + return CSHARPTYPE_INT64; + case FieldDescriptor::TYPE_FIXED32: + return CSHARPTYPE_UINT32; + case FieldDescriptor::TYPE_FIXED64: + return CSHARPTYPE_UINT64; + case FieldDescriptor::TYPE_SFIXED32: + return CSHARPTYPE_INT32; + case FieldDescriptor::TYPE_SFIXED64: + return CSHARPTYPE_INT64; + case FieldDescriptor::TYPE_FLOAT: + return CSHARPTYPE_FLOAT; + case FieldDescriptor::TYPE_DOUBLE: + return CSHARPTYPE_DOUBLE; + case FieldDescriptor::TYPE_BOOL: + return CSHARPTYPE_BOOL; + case FieldDescriptor::TYPE_ENUM: + return CSHARPTYPE_ENUM; + case FieldDescriptor::TYPE_STRING: + return CSHARPTYPE_STRING; + case FieldDescriptor::TYPE_BYTES: + return CSHARPTYPE_BYTESTRING; + case FieldDescriptor::TYPE_GROUP: + return CSHARPTYPE_MESSAGE; + case FieldDescriptor::TYPE_MESSAGE: + return CSHARPTYPE_MESSAGE; + + // No default because we want the compiler to complain if any new + // types are added. + } + GOOGLE_LOG(FATAL)<< "Can't get here."; + return (CSharpType) -1; +} + +std::string StripDotProto(const std::string& proto_file) { + int lastindex = proto_file.find_last_of("."); + return proto_file.substr(0, lastindex); +} + +std::string GetFileNamespace(const FileDescriptor* descriptor) { + if (descriptor->options().has_csharp_namespace()) { + return descriptor->options().csharp_namespace(); + } + return descriptor->package(); +} + +std::string GetUmbrellaClassNameInternal(const std::string& proto_file) { + int lastslash = proto_file.find_last_of("/"); + std::string base = proto_file.substr(lastslash + 1); + return UnderscoresToPascalCase(StripDotProto(base)); +} + +std::string GetFileUmbrellaClassname(const FileDescriptor* descriptor) { + if (descriptor->options().has_csharp_umbrella_classname()) { + return descriptor->options().csharp_umbrella_namespace(); + } else { + return GetUmbrellaClassNameInternal(descriptor->name()); + } +} + +std::string GetFileUmbrellaNamespace(const FileDescriptor* descriptor) { + if (!descriptor->options().csharp_nest_classes() + && !descriptor->options().has_csharp_umbrella_namespace()) { + bool collision = false; + // TODO(jtattermusch): detect collisions! +// foreach (IDescriptor d in MessageTypes) +// { +// collision |= d.Name == builder.UmbrellaClassname; +// } +// foreach (IDescriptor d in Services) +// { +// collision |= d.Name == builder.UmbrellaClassname; +// } +// foreach (IDescriptor d in EnumTypes) +// { +// collision |= d.Name == builder.UmbrellaClassname; +// } + if (collision) { + return "Proto"; + } + } + return ""; +} + +// TODO(jtattermusch): can we reuse a utility function? +std::string UnderscoresToCamelCase(const std::string& input, + bool cap_next_letter) { + string result; + // Note: I distrust ctype.h due to locales. + for (int i = 0; i < input.size(); i++) { + if ('a' <= input[i] && input[i] <= 'z') { + if (cap_next_letter) { + result += input[i] + ('A' - 'a'); + } else { + result += input[i]; + } + cap_next_letter = false; + } else if ('A' <= input[i] && input[i] <= 'Z') { + if (i == 0 && !cap_next_letter) { + // Force first letter to lower-case unless explicitly told to + // capitalize it. + result += input[i] + ('a' - 'A'); + } else { + // Capital letters after the first are left as-is. + result += input[i]; + } + cap_next_letter = false; + } else if ('0' <= input[i] && input[i] <= '9') { + result += input[i]; + cap_next_letter = true; + } else { + cap_next_letter = true; + } + } + // Add a trailing "_" if the name should be altered. + if (input[input.size() - 1] == '#') { + result += '_'; + } + return result; +} + +std::string UnderscoresToPascalCase(const std::string& input) { + return UnderscoresToCamelCase(input, true); +} + +std::string ToCSharpName(const std::string& name, const FileDescriptor* file) { + std::string result = GetFileNamespace(file); + if (file->options().csharp_nest_classes()) { + if (result != "") { + result += "."; + } + result += GetFileUmbrellaClassname(file); + } + if (result != "") { + result += '.'; + } + string classname; + if (file->package().empty()) { + classname = name; + } else { + // Strip the proto package from full_name since we've replaced it with + // the C# namespace. + classname = name.substr(file->package().size() + 1); + } + result += StringReplace(classname, ".", ".Types.", false); + return "global::" + result; +} + + + +std::string GetFullUmbrellaClassName(const FileDescriptor* descriptor) { + std::string result = GetFileNamespace(descriptor); + if (!result.empty()) { + result += '.'; + } + result += GetQualifiedUmbrellaClassName(descriptor); + return "global::" + result; +} + +std::string GetQualifiedUmbrellaClassName(const FileDescriptor* descriptor) { + std::string umbrellaNamespace = GetFileUmbrellaNamespace(descriptor); + std::string umbrellaClassname = GetFileUmbrellaClassname(descriptor); + + std::string fullName = umbrellaClassname; + if (!descriptor->options().csharp_nest_classes() + && !umbrellaNamespace.empty()) { + fullName = umbrellaNamespace + "." + umbrellaClassname; + } + return fullName; +} + +std::string GetClassName(const Descriptor* descriptor) { + return ToCSharpName(descriptor->full_name(), descriptor->file()); +} + +std::string GetClassName(const EnumDescriptor* descriptor) { + return ToCSharpName(descriptor->full_name(), descriptor->file()); +} + +// Groups are hacky: The name of the field is just the lower-cased name +// of the group type. In C#, though, we would like to retain the original +// capitalization of the type name. +std::string GetFieldName(const FieldDescriptor* descriptor) { + if (descriptor->type() == FieldDescriptor::TYPE_GROUP) { + return descriptor->message_type()->name(); + } else { + return descriptor->name(); + } +} + +std::string GetFieldConstantName(const FieldDescriptor* field) { + return GetPropertyName(field) + "FieldNumber"; +} + +std::string GetPropertyName(const FieldDescriptor* descriptor) { + // TODO: fix this. + std::string property_name = UnderscoresToPascalCase(GetFieldName(descriptor)); + if (property_name == descriptor->containing_type()->name()) { + property_name += "_"; + } + return property_name; +} + +// TODO: c&p from Java protoc plugin +// For encodings with fixed sizes, returns that size in bytes. Otherwise +// returns -1. +int GetFixedSize(FieldDescriptor::Type type) { + switch (type) { + case FieldDescriptor::TYPE_INT32 : return -1; + case FieldDescriptor::TYPE_INT64 : return -1; + case FieldDescriptor::TYPE_UINT32 : return -1; + case FieldDescriptor::TYPE_UINT64 : return -1; + case FieldDescriptor::TYPE_SINT32 : return -1; + case FieldDescriptor::TYPE_SINT64 : return -1; + case FieldDescriptor::TYPE_FIXED32 : return internal::WireFormatLite::kFixed32Size; + case FieldDescriptor::TYPE_FIXED64 : return internal::WireFormatLite::kFixed64Size; + case FieldDescriptor::TYPE_SFIXED32: return internal::WireFormatLite::kSFixed32Size; + case FieldDescriptor::TYPE_SFIXED64: return internal::WireFormatLite::kSFixed64Size; + case FieldDescriptor::TYPE_FLOAT : return internal::WireFormatLite::kFloatSize; + case FieldDescriptor::TYPE_DOUBLE : return internal::WireFormatLite::kDoubleSize; + + case FieldDescriptor::TYPE_BOOL : return internal::WireFormatLite::kBoolSize; + case FieldDescriptor::TYPE_ENUM : return -1; + + case FieldDescriptor::TYPE_STRING : return -1; + case FieldDescriptor::TYPE_BYTES : return -1; + case FieldDescriptor::TYPE_GROUP : return -1; + case FieldDescriptor::TYPE_MESSAGE : return -1; + + // No default because we want the compiler to complain if any new + // types are added. + } + GOOGLE_LOG(FATAL) << "Can't get here."; + return -1; +} + +static const char base64_chars[] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + +std::string StringToBase64(const std::string& input) { + std::string result; + size_t remaining = input.size(); + const unsigned char *src = (const unsigned char*) input.c_str(); + while (remaining > 2) { + result += base64_chars[src[0] >> 2]; + result += base64_chars[((src[0] & 0x3) << 4) | (src[1] >> 4)]; + result += base64_chars[((src[1] & 0xf) << 2) | (src[2] >> 6)]; + result += base64_chars[src[2] & 0x3f]; + remaining -= 3; + src += 3; + } + switch (remaining) { + case 2: + result += base64_chars[src[0] >> 2]; + result += base64_chars[((src[0] & 0x3) << 4) | (src[1] >> 4)]; + result += base64_chars[(src[1] & 0xf) << 2]; + result += '='; + src += 2; + break; + case 1: + result += base64_chars[src[0] >> 2]; + result += base64_chars[((src[0] & 0x3) << 4)]; + result += '='; + result += '='; + src += 1; + break; + } + return result; +} + +std::string FileDescriptorToBase64(const FileDescriptor* descriptor) { + std::string fdp_bytes; + FileDescriptorProto fdp; + descriptor->CopyTo(&fdp); + fdp.SerializeToString(&fdp_bytes); + return StringToBase64(fdp_bytes); +} + +FieldGeneratorBase* CreateFieldGenerator(const FieldDescriptor* descriptor, + int fieldOrdinal) { + switch (descriptor->type()) { + case FieldDescriptor::TYPE_GROUP: + case FieldDescriptor::TYPE_MESSAGE: + if (descriptor->is_repeated()) { + return new RepeatedMessageFieldGenerator(descriptor, fieldOrdinal); + } else { + return new MessageFieldGenerator(descriptor, fieldOrdinal); + } + case FieldDescriptor::TYPE_ENUM: + if (descriptor->is_repeated()) { + return new RepeatedEnumFieldGenerator(descriptor, fieldOrdinal); + } else { + return new EnumFieldGenerator(descriptor, fieldOrdinal); + } + default: + if (descriptor->is_repeated()) { + return new RepeatedPrimitiveFieldGenerator(descriptor, fieldOrdinal); + } else { + return new PrimitiveFieldGenerator(descriptor, fieldOrdinal); + } + } +} + +bool HasRequiredFields(const Descriptor* descriptor) { + // TODO(jtattermusch): implement this. + return true; +} + +} // namespace java +} // 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 new file mode 100644 index 00000000..8fdd214e --- /dev/null +++ b/src/google/protobuf/compiler/csharp/csharp_helpers.h @@ -0,0 +1,108 @@ +// 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_HELPERS_H__ +#define GOOGLE_PROTOBUF_COMPILER_CSHARP_HELPERS_H__ + +#include +#include +#include +#include +#include + +namespace google { +namespace protobuf { +namespace compiler { +namespace csharp { + +class FieldGeneratorBase; + +// TODO: start using this enum. +enum CSharpType { + CSHARPTYPE_INT32 = 1, + CSHARPTYPE_INT64 = 2, + CSHARPTYPE_UINT32 = 3, + CSHARPTYPE_UINT64 = 4, + CSHARPTYPE_FLOAT = 5, + CSHARPTYPE_DOUBLE = 6, + CSHARPTYPE_BOOL = 7, + CSHARPTYPE_STRING = 8, + CSHARPTYPE_BYTESTRING = 9, + CSHARPTYPE_MESSAGE = 10, + CSHARPTYPE_ENUM = 11, + MAX_CSHARPTYPE = 11 +}; + +// Converts field type to corresponding C# type. +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); + +std::string GetFieldConstantName(const FieldDescriptor* field); + +std::string GetPropertyName(const FieldDescriptor* descriptor); + +int GetFixedSize(FieldDescriptor::Type type); + +std::string UnderscoresToCamelCase(const std::string& input, bool cap_next_letter); + +std::string UnderscoresToPascalCase(const std::string& input); + +// TODO(jtattermusch): perhaps we could move this to strutil +std::string StringToBase64(const std::string& input); + +std::string FileDescriptorToBase64(const FileDescriptor* descriptor); + +FieldGeneratorBase* CreateFieldGenerator(const FieldDescriptor* descriptor, int fieldOrdinal); + +bool HasRequiredFields(const Descriptor* descriptor); + +} // namespace csharp +} // namespace compiler +} // namespace protobuf +} // namespace google +#endif // GOOGLE_PROTOBUF_COMPILER_CSHARP_HELPERS_H__ diff --git a/src/google/protobuf/compiler/csharp/csharp_message.cc b/src/google/protobuf/compiler/csharp/csharp_message.cc new file mode 100644 index 00000000..2df3bd2d --- /dev/null +++ b/src/google/protobuf/compiler/csharp/csharp_message.cc @@ -0,0 +1,900 @@ +// 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 +#include + +#include +#include +#include +#include +#include +#include + +using google::protobuf::internal::scoped_ptr; + +namespace google { +namespace protobuf { +namespace compiler { +namespace csharp { + +bool CompareFieldNumbers(const FieldDescriptor* d1, const FieldDescriptor* d2) { + return d1->number() < d2->number(); +} + +MessageGenerator::MessageGenerator(const Descriptor* descriptor) + : SourceGeneratorBase(descriptor->file()), + descriptor_(descriptor) { + + // sorted field names + for (int i = 0; i < descriptor_->field_count(); i++) { + field_names_.push_back(descriptor_->field(i)->name()); + } + std::sort(field_names_.begin(), field_names_.end()); + + // fields by number + for (int i = 0; i < descriptor_->field_count(); i++) { + fields_by_number_.push_back(descriptor_->field(i)); + } + std::sort(fields_by_number_.begin(), fields_by_number_.end(), + CompareFieldNumbers); +} + +MessageGenerator::~MessageGenerator() { +} + +std::string MessageGenerator::class_name() { + // TODO: check correctness. + return descriptor_->name(); +} + +std::string MessageGenerator::full_class_name() { + return GetClassName(descriptor_); +} + +const std::vector& MessageGenerator::field_names() { + return field_names_; +} + +const std::vector& MessageGenerator::fields_by_number() { + return fields_by_number_; +} + +/// Get an identifier that uniquely identifies this type within the file. +/// This is used to declare static variables related to this type at the +/// outermost file scope. +std::string GetUniqueFileScopeIdentifier(const Descriptor* descriptor) { + std::string result = descriptor->full_name(); + std::replace(result.begin(), result.end(), '.', '_'); + return "static_" + result; +} + +void MessageGenerator::GenerateStaticVariables(Writer* writer) { + // Because descriptor.proto (Google.ProtocolBuffers.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 + // the proto-descriptor class. This way, they will be initialized in + // a deterministic order. + + std::string identifier = GetUniqueFileScopeIdentifier(descriptor_); + + if (!use_lite_runtime()) { + // The descriptor for this type. + std::string access = + descriptor_->file()->options().csharp_nest_classes() ? + "private" : "internal"; + writer->WriteLine( + "$0$ static pbd::MessageDescriptor internal__$1$__Descriptor;", access, + identifier); + writer->WriteLine( + "$0$ static pb::FieldAccess.FieldAccessorTable<$1$, $1$.Builder> internal__$2$__FieldAccessorTable;", + access, full_class_name(), identifier); + } + + for (int i = 0; i < descriptor_->nested_type_count(); i++) { + MessageGenerator messageGenerator(descriptor_->nested_type(i)); + messageGenerator.GenerateStaticVariables(writer); + } +} + +void MessageGenerator::GenerateStaticVariableInitializers(Writer* writer) { + std::string identifier = GetUniqueFileScopeIdentifier(descriptor_); + + if (!use_lite_runtime()) { + writer->Write("internal__$0$__Descriptor = ", identifier); + + if (!descriptor_->containing_type()) { + writer->WriteLine("Descriptor.MessageTypes[$0$];", + SimpleItoa(descriptor_->index())); + } else { + writer->WriteLine( + "internal__$0$__Descriptor.NestedTypes[$1$];", + GetUniqueFileScopeIdentifier(descriptor_->containing_type()), + SimpleItoa(descriptor_->index())); + } + + writer->WriteLine("internal__$0$__FieldAccessorTable = ", identifier); + writer->WriteLine( + " new pb::FieldAccess.FieldAccessorTable<$1$, $1$.Builder>(internal__$0$__Descriptor,", + identifier, full_class_name()); + writer->Write(" new string[] { "); + for (int i = 0; i < descriptor_->field_count(); i++) { + writer->Write("\"$0$\", ", GetPropertyName(descriptor_->field(i))); + } + writer->WriteLine("});"); + } + + // 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(writer); + } + + for (int i = 0; i < descriptor_->extension_count(); i++) { + ExtensionGenerator extensionGenerator(descriptor_->extension(i)); + extensionGenerator.GenerateStaticVariableInitializers(writer); + } +} + +void MessageGenerator::Generate(Writer* writer) { + if (descriptor_->file()->options().csharp_add_serializable()) { + writer->WriteLine("[global::System.SerializableAttribute()]"); + } + writer->WriteLine( + "[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]"); + WriteGeneratedCodeAttributes(writer); + writer->WriteLine( + "$0$ sealed partial class $1$ : pb::$2$Message$3$<$1$, $1$.Builder> {", + class_access_level(), class_name(), + descriptor_->extension_range_count() > 0 ? "Extendable" : "Generated", + runtime_suffix()); + writer->Indent(); + if (descriptor_->file()->options().csharp_generate_private_ctor()) { + writer->WriteLine("private $0$() { }", class_name()); + } + // Must call MakeReadOnly() to make sure all lists are made read-only + writer->WriteLine( + "private static readonly $0$ defaultInstance = new $0$().MakeReadOnly();", + class_name()); + + if (optimize_speed()) { + writer->WriteLine( + "private static readonly string[] _$0$FieldNames = new string[] { $2$$1$$2$ };", + UnderscoresToCamelCase(class_name(), false), + JoinStrings(field_names(), "\", \""), + 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)); + } + writer->WriteLine( + "private static readonly uint[] _$0$FieldTags = new uint[] { $1$ };", + UnderscoresToCamelCase(class_name(), false), JoinStrings(tags, ", ")); + } + writer->WriteLine("public static $0$ DefaultInstance {", class_name()); + writer->WriteLine(" get { return defaultInstance; }"); + writer->WriteLine("}"); + writer->WriteLine(); + writer->WriteLine("public override $0$ DefaultInstanceForType {", + class_name()); + writer->WriteLine(" get { return DefaultInstance; }"); + writer->WriteLine("}"); + writer->WriteLine(); + writer->WriteLine("protected override $0$ ThisMessage {", class_name()); + writer->WriteLine(" get { return this; }"); + writer->WriteLine("}"); + writer->WriteLine(); + if (!use_lite_runtime()) { + writer->WriteLine("public static pbd::MessageDescriptor Descriptor {"); + writer->WriteLine(" get { return $0$.internal__$1$__Descriptor; }", + GetFullUmbrellaClassName(descriptor_->file()), + GetUniqueFileScopeIdentifier(descriptor_)); + writer->WriteLine("}"); + writer->WriteLine(); + writer->WriteLine( + "protected override pb::FieldAccess.FieldAccessorTable<$0$, $0$.Builder> InternalFieldAccessors {", + class_name()); + writer->WriteLine(" get { return $0$.internal__$1$__FieldAccessorTable; }", + GetFullUmbrellaClassName(descriptor_->file()), + GetUniqueFileScopeIdentifier(descriptor_)); + writer->WriteLine("}"); + writer->WriteLine(); + } + + // 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(writer); + } + + if (descriptor_->enum_type_count() + descriptor_->nested_type_count() > 0) { + writer->WriteLine("#region Nested types"); + writer->WriteLine( + "[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]"); + WriteGeneratedCodeAttributes(writer); + writer->WriteLine("public static partial class Types {"); + writer->Indent(); + for (int i = 0; i < descriptor_->enum_type_count(); i++) { + EnumGenerator enumGenerator(descriptor_->enum_type(i)); + enumGenerator.Generate(writer); + } + for (int i = 0; i < descriptor_->nested_type_count(); i++) { + MessageGenerator messageGenerator(descriptor_->nested_type(i)); + messageGenerator.Generate(writer); + } + writer->Outdent(); + writer->WriteLine("}"); + writer->WriteLine("#endregion"); + writer->WriteLine(); + } + + for (int i = 0; i < descriptor_->field_count(); i++) { + const FieldDescriptor* fieldDescriptor = descriptor_->field(i); + // TODO(jtattermusch): same code for cls compliance is in csharp_extension + if (descriptor_->file()->options().csharp_cls_compliance() + && GetFieldConstantName(fieldDescriptor)[0] == '_') { + writer->WriteLine("[global::System.CLSCompliant(false)]"); + } + + // Rats: we lose the debug comment here :( + writer->WriteLine("public const int $0$ = $1$;", + GetFieldConstantName(fieldDescriptor), + SimpleItoa(fieldDescriptor->number())); + scoped_ptr generator( + CreateFieldGeneratorInternal(fieldDescriptor)); + generator->GenerateMembers(writer); + writer->WriteLine(); + } + + if (optimize_speed()) { + GenerateIsInitialized(writer); + GenerateMessageSerializationMethods(writer); + } + if (use_lite_runtime()) { + GenerateLiteRuntimeMethods(writer); + } + + GenerateParseFromMethods(writer); + GenerateBuilder(writer); + + // Force the static initialization code for the file to run, since it may + // initialize static variables declared in this class. + writer->WriteLine("static $0$() {", class_name()); + // 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. + writer->WriteLine(" object.ReferenceEquals($0$.Descriptor, null);", + GetFullUmbrellaClassName(descriptor_->file())); + writer->WriteLine("}"); + + writer->Outdent(); + writer->WriteLine("}"); + writer->WriteLine(); + +} + +void MessageGenerator::GenerateLiteRuntimeMethods(Writer* writer) { + bool callbase = descriptor_->extension_range_count() > 0; + writer->WriteLine("#region Lite runtime methods"); + writer->WriteLine("public override int GetHashCode() {"); + writer->Indent(); + writer->WriteLine("int hash = GetType().GetHashCode();"); + for (int i = 0; i < descriptor_->field_count(); i++) { + scoped_ptr generator( + CreateFieldGeneratorInternal(descriptor_->field(i))); + generator->WriteHash(writer); + } + if (callbase) { + writer->WriteLine("hash ^= base.GetHashCode();"); + } + writer->WriteLine("return hash;"); + writer->Outdent(); + writer->WriteLine("}"); + writer->WriteLine(); + + writer->WriteLine("public override bool Equals(object obj) {"); + writer->Indent(); + writer->WriteLine("$0$ other = obj as $0$;", class_name()); + writer->WriteLine("if (other == null) return false;"); + for (int i = 0; i < descriptor_->field_count(); i++) { + scoped_ptr generator( + CreateFieldGeneratorInternal(descriptor_->field(i))); + generator->WriteEquals(writer); + } + if (callbase) { + writer->WriteLine("if (!base.Equals(other)) return false;"); + } + writer->WriteLine("return true;"); + writer->Outdent(); + writer->WriteLine("}"); + writer->WriteLine(); + + writer->WriteLine( + "public override void PrintTo(global::System.IO.TextWriter writer) {"); + writer->Indent(); + + for (int i = 0; i < fields_by_number().size(); i++) { + scoped_ptr generator( + CreateFieldGeneratorInternal(fields_by_number()[i])); + generator->WriteToString(writer); + } + + if (callbase) { + writer->WriteLine("base.PrintTo(writer);"); + } + writer->Outdent(); + writer->WriteLine("}"); + writer->WriteLine("#endregion"); + writer->WriteLine(); +} + +bool CompareExtensionRangesStart(const Descriptor::ExtensionRange* r1, + const Descriptor::ExtensionRange* r2) { + return r1->start < r2->start; +} + +void MessageGenerator::GenerateMessageSerializationMethods(Writer* writer) { + 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); + + writer->WriteLine( + "public override void WriteTo(pb::ICodedOutputStream output) {"); + writer->Indent(); + // Make sure we've computed the serialized length, so that packed fields are generated correctly. + writer->WriteLine("int size = SerializedSize;"); + writer->WriteLine("string[] field_names = _$0$FieldNames;", + UnderscoresToCamelCase(class_name(), false)); + if (descriptor_->extension_range_count()) { + writer->WriteLine( + "pb::ExtendableMessage$1$<$0$, $0$.Builder>.ExtensionWriter extensionWriter = CreateExtensionWriter(this);", + class_name(), 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(writer, extension_ranges_sorted[j++]); + } else if (j == extension_ranges_sorted.size()) { + GenerateSerializeOneField(writer, fields_by_number()[i++]); + } else if (fields_by_number()[i]->number() + < extension_ranges_sorted[j]->start) { + GenerateSerializeOneField(writer, fields_by_number()[i++]); + } else { + GenerateSerializeOneExtensionRange(writer, extension_ranges_sorted[j++]); + } + } + + if (!use_lite_runtime()) { + if (descriptor_->options().message_set_wire_format()) + { + writer->WriteLine("UnknownFields.WriteAsMessageSetTo(output);"); + } else { + writer->WriteLine("UnknownFields.WriteTo(output);"); + } + } + + writer->Outdent(); + writer->WriteLine("}"); + writer->WriteLine(); + writer->WriteLine("private int memoizedSerializedSize = -1;"); + writer->WriteLine("public override int SerializedSize {"); + writer->Indent(); + writer->WriteLine("get {"); + writer->Indent(); + writer->WriteLine("int size = memoizedSerializedSize;"); + writer->WriteLine("if (size != -1) return size;"); + writer->WriteLine(); + writer->WriteLine("size = 0;"); + for (int i = 0; i < descriptor_->field_count(); i++) { + scoped_ptr generator( + CreateFieldGeneratorInternal(descriptor_->field(i))); + generator->GenerateSerializedSizeCode(writer); + } + if (descriptor_->extension_range_count() > 0) { + writer->WriteLine("size += ExtensionsSerializedSize;"); + } + + if (!use_lite_runtime()) { + if (descriptor_->options().message_set_wire_format()) { + writer->WriteLine("size += UnknownFields.SerializedSizeAsMessageSet;"); + } else { + writer->WriteLine("size += UnknownFields.SerializedSize;"); + } + } + writer->WriteLine("memoizedSerializedSize = size;"); + writer->WriteLine("return size;"); + writer->Outdent(); + writer->WriteLine("}"); + writer->Outdent(); + writer->WriteLine("}"); + writer->WriteLine(); +} + +void MessageGenerator::GenerateSerializeOneField( + Writer* writer, const FieldDescriptor* fieldDescriptor) { + scoped_ptr generator( + CreateFieldGeneratorInternal(fieldDescriptor)); + generator->GenerateSerializationCode(writer); +} + +void MessageGenerator::GenerateSerializeOneExtensionRange( + Writer* writer, const Descriptor::ExtensionRange* extensionRange) { + writer->WriteLine("extensionWriter.WriteUntil($0$, output);", + SimpleItoa(extensionRange->end)); +} + +void MessageGenerator::GenerateParseFromMethods(Writer* writer) { + // Note: These are separate from GenerateMessageSerializationMethods() + // because they need to be generated even for messages that are optimized + // for code size. + + writer->WriteLine("public static $0$ ParseFrom(pb::ByteString data) {", + class_name()); + writer->WriteLine( + " return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed();"); + writer->WriteLine("}"); + writer->WriteLine( + "public static $0$ ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) {", + class_name()); + writer->WriteLine( + " return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();"); + writer->WriteLine("}"); + writer->WriteLine("public static $0$ ParseFrom(byte[] data) {", class_name()); + writer->WriteLine( + " return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed();"); + writer->WriteLine("}"); + writer->WriteLine( + "public static $0$ ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) {", + class_name()); + writer->WriteLine( + " return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();"); + writer->WriteLine("}"); + writer->WriteLine( + "public static $0$ ParseFrom(global::System.IO.Stream input) {", + class_name()); + writer->WriteLine( + " return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed();"); + writer->WriteLine("}"); + writer->WriteLine( + "public static $0$ ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) {", + class_name()); + writer->WriteLine( + " return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();"); + writer->WriteLine("}"); + writer->WriteLine( + "public static $0$ ParseDelimitedFrom(global::System.IO.Stream input) {", + class_name()); + writer->WriteLine( + " return CreateBuilder().MergeDelimitedFrom(input).BuildParsed();"); + writer->WriteLine("}"); + writer->WriteLine( + "public static $0$ ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) {", + class_name()); + writer->WriteLine( + " return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed();"); + writer->WriteLine("}"); + writer->WriteLine( + "public static $0$ ParseFrom(pb::ICodedInputStream input) {", + class_name()); + writer->WriteLine( + " return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed();"); + writer->WriteLine("}"); + writer->WriteLine( + "public static $0$ ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {", + class_name()); + writer->WriteLine( + " return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();"); + writer->WriteLine("}"); +} + +void MessageGenerator::GenerateBuilder(Writer* writer) { + writer->WriteLine("private $0$ MakeReadOnly() {", class_name()); + writer->Indent(); + for (int i = 0; i < descriptor_->field_count(); i++) { + scoped_ptr generator( + CreateFieldGeneratorInternal(descriptor_->field(i))); + generator->GenerateBuildingCode(writer); + } + writer->WriteLine("return this;"); + writer->Outdent(); + writer->WriteLine("}"); + writer->WriteLine(); + + writer->WriteLine( + "public static Builder CreateBuilder() { return new Builder(); }"); + writer->WriteLine( + "public override Builder ToBuilder() { return CreateBuilder(this); }"); + writer->WriteLine( + "public override Builder CreateBuilderForType() { return new Builder(); }"); + writer->WriteLine("public static Builder CreateBuilder($0$ prototype) {", + class_name()); + writer->WriteLine(" return new Builder(prototype);"); + writer->WriteLine("}"); + writer->WriteLine(); + if (descriptor_->file()->options().csharp_add_serializable()) { + writer->WriteLine("[global::System.SerializableAttribute()]"); + } + writer->WriteLine( + "[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]"); + WriteGeneratedCodeAttributes(writer); + writer->WriteLine( + "$0$ sealed partial class Builder : pb::$2$Builder$3$<$1$, Builder> {", + class_access_level(), class_name(), + descriptor_->extension_range_count() > 0 ? "Extendable" : "Generated", + runtime_suffix()); + writer->Indent(); + writer->WriteLine("protected override Builder ThisBuilder {"); + writer->WriteLine(" get { return this; }"); + writer->WriteLine("}"); + GenerateCommonBuilderMethods(writer); + if (optimize_speed()) { + GenerateBuilderParsingMethods(writer); + } + for (int i = 0; i < descriptor_->field_count(); i++) { + scoped_ptr generator( + CreateFieldGeneratorInternal(descriptor_->field(i))); + writer->WriteLine(); + // No field comment :( + generator->GenerateBuilderMembers(writer); + } + writer->Outdent(); + writer->WriteLine("}"); +} + +void MessageGenerator::GenerateCommonBuilderMethods(Writer* writer) { + //default constructor + writer->WriteLine("public Builder() {"); + //Durring static initialization of message, DefaultInstance is expected to return null. + writer->WriteLine(" result = DefaultInstance;"); + writer->WriteLine(" resultIsReadOnly = true;"); + writer->WriteLine("}"); + //clone constructor + writer->WriteLine("internal Builder($0$ cloneFrom) {", class_name()); + writer->WriteLine(" result = cloneFrom;"); + writer->WriteLine(" resultIsReadOnly = true;"); + writer->WriteLine("}"); + writer->WriteLine(); + writer->WriteLine("private bool resultIsReadOnly;"); + writer->WriteLine("private $0$ result;", class_name()); + writer->WriteLine(); + writer->WriteLine("private $0$ PrepareBuilder() {", class_name()); + writer->WriteLine(" if (resultIsReadOnly) {"); + writer->WriteLine(" $0$ original = result;", class_name()); + writer->WriteLine(" result = new $0$();", class_name()); + writer->WriteLine(" resultIsReadOnly = false;"); + writer->WriteLine(" MergeFrom(original);"); + writer->WriteLine(" }"); + writer->WriteLine(" return result;"); + writer->WriteLine("}"); + writer->WriteLine(); + writer->WriteLine("public override bool IsInitialized {"); + writer->WriteLine(" get { return result.IsInitialized; }"); + writer->WriteLine("}"); + writer->WriteLine(); + writer->WriteLine("protected override $0$ MessageBeingBuilt {", class_name()); + writer->WriteLine(" get { return PrepareBuilder(); }"); + writer->WriteLine("}"); + writer->WriteLine(); + //Not actually expecting that DefaultInstance would ever be null here; however, we will ensure it does not break + writer->WriteLine("public override Builder Clear() {"); + writer->WriteLine(" result = DefaultInstance;"); + writer->WriteLine(" resultIsReadOnly = true;"); + writer->WriteLine(" return this;"); + writer->WriteLine("}"); + writer->WriteLine(); + writer->WriteLine("public override Builder Clone() {"); + writer->WriteLine(" if (resultIsReadOnly) {"); + writer->WriteLine(" return new Builder(result);"); + writer->WriteLine(" } else {"); + writer->WriteLine(" return new Builder().MergeFrom(result);"); + writer->WriteLine(" }"); + writer->WriteLine("}"); + writer->WriteLine(); + if (!use_lite_runtime()) { + writer->WriteLine( + "public override pbd::MessageDescriptor DescriptorForType {"); + writer->WriteLine(" get { return $0$.Descriptor; }", full_class_name()); + writer->WriteLine("}"); + writer->WriteLine(); + } + writer->WriteLine("public override $0$ DefaultInstanceForType {", + class_name()); + writer->WriteLine(" get { return $0$.DefaultInstance; }", full_class_name()); + writer->WriteLine("}"); + writer->WriteLine(); + + writer->WriteLine("public override $0$ BuildPartial() {", class_name()); + writer->Indent(); + writer->WriteLine("if (resultIsReadOnly) {"); + writer->WriteLine(" return result;"); + writer->WriteLine("}"); + writer->WriteLine("resultIsReadOnly = true;"); + writer->WriteLine("return result.MakeReadOnly();"); + writer->Outdent(); + writer->WriteLine("}"); + writer->WriteLine(); + + if (optimize_speed()) { + writer->WriteLine( + "public override Builder MergeFrom(pb::IMessage$0$ other) {", + runtime_suffix()); + writer->WriteLine(" if (other is $0$) {", class_name()); + writer->WriteLine(" return MergeFrom(($0$) other);", class_name()); + writer->WriteLine(" } else {"); + writer->WriteLine(" base.MergeFrom(other);"); + writer->WriteLine(" return this;"); + writer->WriteLine(" }"); + writer->WriteLine("}"); + writer->WriteLine(); + writer->WriteLine("public override Builder MergeFrom($0$ other) {", + class_name()); + // Optimization: If other is the default instance, we know none of its + // fields are set so we can skip the merge. + writer->Indent(); + writer->WriteLine("if (other == $0$.DefaultInstance) return this;", + full_class_name()); + writer->WriteLine("PrepareBuilder();"); + for (int i = 0; i < descriptor_->field_count(); i++) { + scoped_ptr generator( + CreateFieldGeneratorInternal(descriptor_->field(i))); + generator->GenerateMergingCode(writer); + } + // if message type has extensions + if (descriptor_->extension_range_count() > 0) { + writer->WriteLine(" this.MergeExtensionFields(other);"); + } + if (!use_lite_runtime()) { + writer->WriteLine("this.MergeUnknownFields(other.UnknownFields);"); + } + writer->WriteLine("return this;"); + writer->Outdent(); + writer->WriteLine("}"); + writer->WriteLine(); + } + +} + +void MessageGenerator::GenerateBuilderParsingMethods(Writer* writer) { + writer->WriteLine( + "public override Builder MergeFrom(pb::ICodedInputStream input) {"); + writer->WriteLine(" return MergeFrom(input, pb::ExtensionRegistry.Empty);"); + writer->WriteLine("}"); + writer->WriteLine(); + writer->WriteLine( + "public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {"); + writer->Indent(); + writer->WriteLine("PrepareBuilder();"); + if (!use_lite_runtime()) { + writer->WriteLine("pb::UnknownFieldSet.Builder unknownFields = null;"); + } + writer->WriteLine("uint tag;"); + writer->WriteLine("string field_name;"); + writer->WriteLine("while (input.ReadTag(out tag, out field_name)) {"); + writer->Indent(); + writer->WriteLine("if(tag == 0 && field_name != null) {"); + writer->Indent(); + //if you change from StringComparer.Ordinal, the array sort in FieldNames { get; } must also change + writer->WriteLine( + "int field_ordinal = global::System.Array.BinarySearch(_$0$FieldNames, field_name, global::System.StringComparer.Ordinal);", + UnderscoresToCamelCase(class_name(), false)); + writer->WriteLine("if(field_ordinal >= 0)"); + writer->WriteLine(" tag = _$0$FieldTags[field_ordinal];", + UnderscoresToCamelCase(class_name(), false)); + writer->WriteLine("else {"); + if (!use_lite_runtime()) { + writer->WriteLine(" if (unknownFields == null) {"); // First unknown field - create builder now + writer->WriteLine( + " unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);"); + writer->WriteLine(" }"); + } + writer->WriteLine( + " ParseUnknownField(input, $0$extensionRegistry, tag, field_name);", + use_lite_runtime() ? "" : "unknownFields, "); + writer->WriteLine(" continue;"); + writer->WriteLine("}"); + writer->Outdent(); + writer->WriteLine("}"); + + writer->WriteLine("switch (tag) {"); + writer->Indent(); + writer->WriteLine("case 0: {"); // 0 signals EOF / limit reached + writer->WriteLine(" throw pb::InvalidProtocolBufferException.InvalidTag();"); + writer->WriteLine("}"); + writer->WriteLine("default: {"); + writer->WriteLine(" if (pb::WireFormat.IsEndGroupTag(tag)) {"); + if (!use_lite_runtime()) { + writer->WriteLine(" if (unknownFields != null) {"); + writer->WriteLine(" this.UnknownFields = unknownFields.Build();"); + writer->WriteLine(" }"); + } + writer->WriteLine(" return this;"); // it's an endgroup tag + writer->WriteLine(" }"); + if (!use_lite_runtime()) { + writer->WriteLine(" if (unknownFields == null) {"); // First unknown field - create builder now + writer->WriteLine( + " unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);"); + writer->WriteLine(" }"); + } + writer->WriteLine( + " ParseUnknownField(input, $0$extensionRegistry, tag, field_name);", + use_lite_runtime() ? "" : "unknownFields, "); + writer->WriteLine(" break;"); + writer->WriteLine("}"); + + 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); + if (field->is_repeated() + && (wt == internal::WireFormatLite::WIRETYPE_VARINT + || wt == internal::WireFormatLite::WIRETYPE_FIXED32 + || wt == internal::WireFormatLite::WIRETYPE_FIXED64)) { + writer->WriteLine( + "case $0$:", + SimpleItoa( + internal::WireFormatLite::MakeTag( + field->number(), + internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED))); + } + + writer->WriteLine("case $0$: {", SimpleItoa(tag)); + writer->Indent(); + scoped_ptr generator( + CreateFieldGeneratorInternal(field)); + generator->GenerateParsingCode(writer); + writer->WriteLine("break;"); + writer->Outdent(); + writer->WriteLine("}"); + } + + writer->Outdent(); + writer->WriteLine("}"); + writer->Outdent(); + writer->WriteLine("}"); + writer->WriteLine(); + if (!use_lite_runtime()) { + writer->WriteLine("if (unknownFields != null) {"); + writer->WriteLine(" this.UnknownFields = unknownFields.Build();"); + writer->WriteLine("}"); + } + writer->WriteLine("return this;"); + writer->Outdent(); + writer->WriteLine("}"); + writer->WriteLine(); +} + +void MessageGenerator::GenerateIsInitialized(Writer* writer) { + writer->WriteLine("public override bool IsInitialized {"); + writer->Indent(); + writer->WriteLine("get {"); + writer->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()) { + writer->WriteLine("if (!has$0$) return false;", + 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()) + { + writer->WriteLine("foreach ($0$ element in $1$List) {", + GetClassName(field->message_type()), + propertyName); + writer->WriteLine(" if (!element.IsInitialized) return false;"); + writer->WriteLine("}"); + } + else if (field->is_optional()) + { + writer->WriteLine("if (Has$0$) {", propertyName); + writer->WriteLine(" if (!$0$.IsInitialized) return false;", propertyName); + writer->WriteLine("}"); + } + else + { + writer->WriteLine("if (!$0$.IsInitialized) return false;", propertyName); + } + } + + if (descriptor_->extension_range_count() > 0) { + writer->WriteLine("if (!ExtensionsAreInitialized) return false;"); + } + writer->WriteLine("return true;"); + writer->Outdent(); + writer->WriteLine("}"); + writer->Outdent(); + writer->WriteLine("}"); + writer->WriteLine(); +} + +void MessageGenerator::GenerateExtensionRegistrationCode(Writer* writer) { + for (int i = 0; i < descriptor_->extension_count(); i++) { + ExtensionGenerator extensionGenerator(descriptor_->extension(i)); + extensionGenerator.GenerateExtensionRegistrationCode(writer); + } + for (int i = 0; i < descriptor_->nested_type_count(); i++) { + MessageGenerator messageGenerator(descriptor_->nested_type(i)); + messageGenerator.GenerateExtensionRegistrationCode(writer); + } +} + +int MessageGenerator::GetFieldOrdinal(const FieldDescriptor* descriptor) { + for (int i = 0; i < field_names().size(); i++) { + if (field_names()[i] == descriptor->name()) { + return i; + } + } + GOOGLE_LOG(DFATAL)<< "Could not find ordinal for field " << descriptor->name(); + return -1; +} + +FieldGeneratorBase* MessageGenerator::CreateFieldGeneratorInternal( + const FieldDescriptor* descriptor) { + return CreateFieldGenerator(descriptor, GetFieldOrdinal(descriptor)); +} + +} // namespace csharp +} // namespace compiler +} // namespace protobuf +} // namespace google diff --git a/src/google/protobuf/compiler/csharp/csharp_message.h b/src/google/protobuf/compiler/csharp/csharp_message.h new file mode 100644 index 00000000..b8d15df0 --- /dev/null +++ b/src/google/protobuf/compiler/csharp/csharp_message.h @@ -0,0 +1,98 @@ +// 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_MESSAGE_H__ +#define GOOGLE_PROTOBUF_COMPILER_CSHARP_MESSAGE_H__ + +#include +#include + +#include +#include +#include + +namespace google { +namespace protobuf { +namespace compiler { +namespace csharp { + +class Writer; +class FieldGeneratorBase; + +class MessageGenerator : public SourceGeneratorBase { + public: + MessageGenerator(const Descriptor* descriptor); + ~MessageGenerator(); + + void GenerateStaticVariables(Writer* printer); + void GenerateStaticVariableInitializers(Writer* printer); + void GenerateExtensionRegistrationCode(Writer* printer); + void Generate(Writer* printer); + + private: + const Descriptor* descriptor_; + std::vector field_names_; + std::vector fields_by_number_; + + void GenerateLiteRuntimeMethods(Writer* writer); + void GenerateMessageSerializationMethods(Writer* writer); + void GenerateSerializeOneField(Writer* writer, + const FieldDescriptor* fieldDescriptor); + void GenerateSerializeOneExtensionRange( + Writer* writer, const Descriptor::ExtensionRange* extendsionRange); + void GenerateParseFromMethods(Writer* writer); + void GenerateBuilder(Writer* writer); + void GenerateCommonBuilderMethods(Writer* writer); + void GenerateBuilderParsingMethods(Writer* writer); + void GenerateIsInitialized(Writer* writer); + + int GetFieldOrdinal(const FieldDescriptor* descriptor); + FieldGeneratorBase* CreateFieldGeneratorInternal( + const FieldDescriptor* descriptor); + + std::string class_name(); + std::string full_class_name(); + + // field names sorted alphabetically + const std::vector& field_names(); + + // field descriptors sorted by number + const std::vector& fields_by_number(); + + GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageGenerator); +}; + +} // namespace csharp +} // namespace compiler +} // namespace protobuf +} // 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 new file mode 100644 index 00000000..10464c4b --- /dev/null +++ b/src/google/protobuf/compiler/csharp/csharp_message_field.cc @@ -0,0 +1,183 @@ +// 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 +#include + +namespace google { +namespace protobuf { +namespace compiler { +namespace csharp { + +MessageFieldGenerator::MessageFieldGenerator(const FieldDescriptor* descriptor, + int fieldOrdinal) + : FieldGeneratorBase(descriptor, fieldOrdinal) { +} + +MessageFieldGenerator::~MessageFieldGenerator() { + +} + +void MessageFieldGenerator::GenerateMembers(Writer* writer) { + writer->WriteLine("private bool has$0$;", property_name()); + writer->WriteLine("private $0$ $1$_;", type_name(), name()); + AddDeprecatedFlag(writer); + writer->WriteLine("public bool Has$0$ {", property_name()); + writer->WriteLine(" get { return has$0$; }", property_name()); + writer->WriteLine("}"); + AddDeprecatedFlag(writer); + writer->WriteLine("public $0$ $1$ {", type_name(), property_name()); + writer->WriteLine(" get { return $0$_ ?? $1$; }", name(), default_value()); + writer->WriteLine("}"); +} + +void MessageFieldGenerator::GenerateBuilderMembers(Writer* writer) { + AddDeprecatedFlag(writer); + writer->WriteLine("public bool Has$0$ {", property_name()); + writer->WriteLine(" get { return result.has$0$; }", property_name()); + writer->WriteLine("}"); + AddDeprecatedFlag(writer); + writer->WriteLine("public $0$ $1$ {", type_name(), property_name()); + writer->WriteLine(" get { return result.$0$; }", property_name()); + writer->WriteLine(" set { Set$0$(value); }", property_name()); + writer->WriteLine("}"); + AddDeprecatedFlag(writer); + writer->WriteLine("public Builder Set$0$($1$ value) {", property_name(), + type_name()); + AddNullCheck(writer); + writer->WriteLine(" PrepareBuilder();"); + writer->WriteLine(" result.has$0$ = true;", property_name()); + writer->WriteLine(" result.$0$_ = value;", name()); + writer->WriteLine(" return this;"); + writer->WriteLine("}"); + AddDeprecatedFlag(writer); + writer->WriteLine("public Builder Set$0$($1$.Builder builderForValue) {", + property_name(), type_name()); + AddNullCheck(writer, "builderForValue"); + writer->WriteLine(" PrepareBuilder();"); + writer->WriteLine(" result.has$0$ = true;", property_name()); + writer->WriteLine(" result.$0$_ = builderForValue.Build();", name()); + writer->WriteLine(" return this;"); + writer->WriteLine("}"); + AddDeprecatedFlag(writer); + writer->WriteLine("public Builder Merge$0$($1$ value) {", property_name(), + type_name()); + AddNullCheck(writer); + writer->WriteLine(" PrepareBuilder();"); + writer->WriteLine(" if (result.has$0$ &&", property_name()); + writer->WriteLine(" result.$0$_ != $1$) {", name(), default_value()); + writer->WriteLine( + " result.$0$_ = $1$.CreateBuilder(result.$0$_).MergeFrom(value).BuildPartial();", + name(), type_name()); + writer->WriteLine(" } else {"); + writer->WriteLine(" result.$0$_ = value;", name()); + writer->WriteLine(" }"); + writer->WriteLine(" result.has$0$ = true;", property_name()); + writer->WriteLine(" return this;"); + writer->WriteLine("}"); + AddDeprecatedFlag(writer); + writer->WriteLine("public Builder Clear$0$() {", property_name()); + writer->WriteLine(" PrepareBuilder();"); + writer->WriteLine(" result.has$0$ = false;", property_name()); + writer->WriteLine(" result.$0$_ = null;", name()); + writer->WriteLine(" return this;"); + writer->WriteLine("}"); +} + +void MessageFieldGenerator::GenerateMergingCode(Writer* writer) { + writer->WriteLine("if (other.Has$0$) {", property_name()); + writer->WriteLine(" Merge$0$(other.$0$);", property_name()); + writer->WriteLine("}"); +} + +void MessageFieldGenerator::GenerateBuildingCode(Writer* writer) { + // Nothing to do for singular fields +} + +void MessageFieldGenerator::GenerateParsingCode(Writer* writer) { + writer->WriteLine("$0$.Builder subBuilder = $0$.CreateBuilder();", + type_name()); + writer->WriteLine("if (result.has$0$) {", property_name()); + writer->WriteLine(" subBuilder.MergeFrom($0$);", property_name()); + writer->WriteLine("}"); + + if (descriptor_->type() == FieldDescriptor::TYPE_GROUP) { + writer->WriteLine("input.ReadGroup($0$, subBuilder, extensionRegistry);", + number()); + } else { + writer->WriteLine("input.ReadMessage(subBuilder, extensionRegistry);"); + } + writer->WriteLine("$0$ = subBuilder.BuildPartial();", property_name()); +} + +void MessageFieldGenerator::GenerateSerializationCode(Writer* writer) { + writer->WriteLine("if (has$0$) {", property_name()); + writer->WriteLine(" output.Write$0$($1$, field_names[$3$], $2$);", + message_or_group(), number(), property_name(), + field_ordinal()); + writer->WriteLine("}"); +} + +void MessageFieldGenerator::GenerateSerializedSizeCode(Writer* writer) { + writer->WriteLine("if (has$0$) {", property_name()); + writer->WriteLine(" size += pb::CodedOutputStream.Compute$0$Size($1$, $2$);", + message_or_group(), number(), property_name()); + writer->WriteLine("}"); +} + +void MessageFieldGenerator::WriteHash(Writer* writer) { + writer->WriteLine("if (has$0$) hash ^= $1$_.GetHashCode();", property_name(), + name()); +} +void MessageFieldGenerator::WriteEquals(Writer* writer) { + writer->WriteLine( + "if (has$0$ != other.has$0$ || (has$0$ && !$1$_.Equals(other.$1$_))) return false;", + property_name(), name()); +} +void MessageFieldGenerator::WriteToString(Writer* writer) { + writer->WriteLine("PrintField(\"$2$\", has$0$, $1$_, writer);", + property_name(), name(), GetFieldName(descriptor_)); +} + +} // namespace csharp +} // namespace compiler +} // namespace protobuf +} // namespace google diff --git a/src/google/protobuf/compiler/csharp/csharp_message_field.h b/src/google/protobuf/compiler/csharp/csharp_message_field.h new file mode 100644 index 00000000..48bf8be5 --- /dev/null +++ b/src/google/protobuf/compiler/csharp/csharp_message_field.h @@ -0,0 +1,73 @@ +// 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_MESSAGE_FIELD_H__ +#define GOOGLE_PROTOBUF_COMPILER_CSHARP_MESSAGE_FIELD_H__ + +#include + +#include +#include + +namespace google { +namespace protobuf { +namespace compiler { +namespace csharp { + +class Writer; + +class MessageFieldGenerator : public FieldGeneratorBase { + public: + MessageFieldGenerator(const FieldDescriptor* descriptor, int fieldOrdinal); + ~MessageFieldGenerator(); + + virtual void GenerateMembers(Writer* writer); + virtual void GenerateBuilderMembers(Writer* writer); + virtual void GenerateMergingCode(Writer* writer); + virtual void GenerateBuildingCode(Writer* writer); + virtual void GenerateParsingCode(Writer* writer); + virtual void GenerateSerializationCode(Writer* writer); + virtual void GenerateSerializedSizeCode(Writer* writer); + + virtual void WriteHash(Writer* writer); + virtual void WriteEquals(Writer* writer); + virtual void WriteToString(Writer* writer); + + private: + GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageFieldGenerator); +}; + +} // namespace csharp +} // namespace compiler +} // namespace protobuf +} // namespace google + +#endif // GOOGLE_PROTOBUF_COMPILER_CSHARP_MESSAGE_FIELD_H__ + diff --git a/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc b/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc new file mode 100644 index 00000000..54287b41 --- /dev/null +++ b/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc @@ -0,0 +1,148 @@ +// 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 +#include + +namespace google { +namespace protobuf { +namespace compiler { +namespace csharp { + +PrimitiveFieldGenerator::PrimitiveFieldGenerator( + const FieldDescriptor* descriptor, int fieldOrdinal) + : FieldGeneratorBase(descriptor, fieldOrdinal) { +} + +PrimitiveFieldGenerator::~PrimitiveFieldGenerator() { + +} + +void PrimitiveFieldGenerator::GenerateMembers(Writer* writer) { + writer->WriteLine("private bool has$0$;", property_name()); + writer->WriteLine("private $0$ $1$_$2$;", type_name(), name(), + has_default_value() ? " = " + default_value() : ""); + AddDeprecatedFlag(writer); + writer->WriteLine("public bool Has$0$ {", property_name()); + writer->WriteLine(" get { return has$0$; }", property_name()); + writer->WriteLine("}"); + AddPublicMemberAttributes(writer); + writer->WriteLine("public $0$ $1$ {", type_name(), property_name()); + writer->WriteLine(" get { return $0$_; }", name()); + writer->WriteLine("}"); +} + +void PrimitiveFieldGenerator::GenerateBuilderMembers(Writer* writer) { + AddDeprecatedFlag(writer); + writer->WriteLine("public bool Has$0$ {", property_name()); + writer->WriteLine(" get { return result.has$0$; }", property_name()); + writer->WriteLine("}"); + AddPublicMemberAttributes(writer); + writer->WriteLine("public $0$ $1$ {", type_name(), property_name()); + writer->WriteLine(" get { return result.$0$; }", property_name()); + writer->WriteLine(" set { Set$0$(value); }", property_name()); + writer->WriteLine("}"); + AddPublicMemberAttributes(writer); + writer->WriteLine("public Builder Set$0$($1$ value) {", property_name(), + type_name()); + AddNullCheck(writer); + writer->WriteLine(" PrepareBuilder();"); + writer->WriteLine(" result.has$0$ = true;", property_name()); + writer->WriteLine(" result.$0$_ = value;", name()); + writer->WriteLine(" return this;"); + writer->WriteLine("}"); + AddDeprecatedFlag(writer); + writer->WriteLine("public Builder Clear$0$() {", property_name()); + writer->WriteLine(" PrepareBuilder();"); + writer->WriteLine(" result.has$0$ = false;", property_name()); + writer->WriteLine(" result.$0$_ = $1$;", name(), default_value()); + writer->WriteLine(" return this;"); + writer->WriteLine("}"); +} + +void PrimitiveFieldGenerator::GenerateMergingCode(Writer* writer) { + writer->WriteLine("if (other.Has$0$) {", property_name()); + writer->WriteLine(" $0$ = other.$0$;", property_name()); + writer->WriteLine("}"); +} + +void PrimitiveFieldGenerator::GenerateBuildingCode(Writer* writer) { + // Nothing to do here for primitive types +} + +void PrimitiveFieldGenerator::GenerateParsingCode(Writer* writer) { + writer->WriteLine("result.has$0$ = input.Read$1$(ref result.$2$_);", + property_name(), capitalized_type_name(), name()); +} + +void PrimitiveFieldGenerator::GenerateSerializationCode(Writer* writer) { + writer->WriteLine("if (has$0$) {", property_name()); + writer->WriteLine(" output.Write$0$($1$, field_names[$3$], $2$);", + capitalized_type_name(), number(), property_name(), + field_ordinal()); + writer->WriteLine("}"); +} + +void PrimitiveFieldGenerator::GenerateSerializedSizeCode(Writer* writer) { + writer->WriteLine("if (has$0$) {", property_name()); + writer->WriteLine(" size += pb::CodedOutputStream.Compute$0$Size($1$, $2$);", + capitalized_type_name(), number(), property_name()); + writer->WriteLine("}"); +} + +void PrimitiveFieldGenerator::WriteHash(Writer* writer) { + writer->WriteLine("if (has$0$) hash ^= $1$_.GetHashCode();", property_name(), + name()); +} +void PrimitiveFieldGenerator::WriteEquals(Writer* writer) { + writer->WriteLine( + "if (has$0$ != other.has$0$ || (has$0$ && !$1$_.Equals(other.$1$_))) return false;", + property_name(), name()); +} +void PrimitiveFieldGenerator::WriteToString(Writer* writer) { + writer->WriteLine("PrintField(\"$0$\", has$1$, $2$_, writer);", + descriptor_->name(), property_name(), name()); +} + +} // namespace csharp +} // namespace compiler +} // namespace protobuf +} // namespace google diff --git a/src/google/protobuf/compiler/csharp/csharp_primitive_field.h b/src/google/protobuf/compiler/csharp/csharp_primitive_field.h new file mode 100644 index 00000000..fb27ab43 --- /dev/null +++ b/src/google/protobuf/compiler/csharp/csharp_primitive_field.h @@ -0,0 +1,73 @@ +// 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_PRIMITIVE_FIELD_H__ +#define GOOGLE_PROTOBUF_COMPILER_CSHARP_PRIMITIVE_FIELD_H__ + +#include + +#include +#include + +namespace google { +namespace protobuf { +namespace compiler { +namespace csharp { + +class Writer; + +class PrimitiveFieldGenerator : public FieldGeneratorBase { + public: + PrimitiveFieldGenerator(const FieldDescriptor* descriptor, int fieldOrdinal); + ~PrimitiveFieldGenerator(); + + virtual void GenerateMembers(Writer* writer); + virtual void GenerateBuilderMembers(Writer* writer); + virtual void GenerateMergingCode(Writer* writer); + virtual void GenerateBuildingCode(Writer* writer); + virtual void GenerateParsingCode(Writer* writer); + virtual void GenerateSerializationCode(Writer* writer); + virtual void GenerateSerializedSizeCode(Writer* writer); + + virtual void WriteHash(Writer* writer); + virtual void WriteEquals(Writer* writer); + virtual void WriteToString(Writer* writer); + + private: + GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(PrimitiveFieldGenerator); +}; + +} // namespace csharp +} // namespace compiler +} // namespace protobuf +} // namespace google + +#endif // GOOGLE_PROTOBUF_COMPILER_CSHARP_PRIMITIVE_FIELD_H__ + diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc b/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc new file mode 100644 index 00000000..cc8745ae --- /dev/null +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc @@ -0,0 +1,226 @@ +// 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 +#include + +namespace google { +namespace protobuf { +namespace compiler { +namespace csharp { + +RepeatedEnumFieldGenerator::RepeatedEnumFieldGenerator( + const FieldDescriptor* descriptor, int fieldOrdinal) + : FieldGeneratorBase(descriptor, fieldOrdinal) { +} + +RepeatedEnumFieldGenerator::~RepeatedEnumFieldGenerator() { + +} + +void RepeatedEnumFieldGenerator::GenerateMembers(Writer* writer) { + if (descriptor_->is_packed() && optimize_speed()) { + writer->WriteLine("private int $0$MemoizedSerializedSize;", name()); + } + writer->WriteLine( + "private pbc::PopsicleList<$0$> $1$_ = new pbc::PopsicleList<$0$>();", + type_name(), name()); + AddDeprecatedFlag(writer); + writer->WriteLine("public scg::IList<$0$> $1$List {", type_name(), + property_name()); + writer->WriteLine(" get { return pbc::Lists.AsReadOnly($0$_); }", name()); + writer->WriteLine("}"); + + // TODO(jonskeet): Redundant API calls? Possibly - include for portability though. Maybe create an option. + AddDeprecatedFlag(writer); + writer->WriteLine("public int $0$Count {", property_name()); + writer->WriteLine(" get { return $0$_.Count; }", name()); + writer->WriteLine("}"); + + AddDeprecatedFlag(writer); + writer->WriteLine("public $0$ Get$1$(int index) {", type_name(), + property_name()); + writer->WriteLine(" return $0$_[index];", name()); + writer->WriteLine("}"); +} + +void RepeatedEnumFieldGenerator::GenerateBuilderMembers(Writer* writer) { + // 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(writer); + writer->WriteLine("public pbc::IPopsicleList<$0$> $1$List {", type_name(), + property_name()); + writer->WriteLine(" get { return PrepareBuilder().$0$_; }", name()); + writer->WriteLine("}"); + AddDeprecatedFlag(writer); + writer->WriteLine("public int $0$Count {", property_name()); + writer->WriteLine(" get { return result.$0$Count; }", property_name()); + writer->WriteLine("}"); + AddDeprecatedFlag(writer); + writer->WriteLine("public $0$ Get$1$(int index) {", type_name(), + property_name()); + writer->WriteLine(" return result.Get$0$(index);", property_name()); + writer->WriteLine("}"); + AddDeprecatedFlag(writer); + writer->WriteLine("public Builder Set$0$(int index, $1$ value) {", + property_name(), type_name()); + writer->WriteLine(" PrepareBuilder();"); + writer->WriteLine(" result.$0$_[index] = value;", name()); + writer->WriteLine(" return this;"); + writer->WriteLine("}"); + AddDeprecatedFlag(writer); + writer->WriteLine("public Builder Add$0$($1$ value) {", property_name(), + type_name()); + writer->WriteLine(" PrepareBuilder();"); + writer->WriteLine(" result.$0$_.Add(value);", name(), type_name()); + writer->WriteLine(" return this;"); + writer->WriteLine("}"); + AddDeprecatedFlag(writer); + writer->WriteLine( + "public Builder AddRange$0$(scg::IEnumerable<$1$> values) {", + property_name(), type_name()); + writer->WriteLine(" PrepareBuilder();"); + writer->WriteLine(" result.$0$_.Add(values);", name()); + writer->WriteLine(" return this;"); + writer->WriteLine("}"); + AddDeprecatedFlag(writer); + writer->WriteLine("public Builder Clear$0$() {", property_name()); + writer->WriteLine(" PrepareBuilder();"); + writer->WriteLine(" result.$0$_.Clear();", name()); + writer->WriteLine(" return this;"); + writer->WriteLine("}"); +} + +void RepeatedEnumFieldGenerator::GenerateMergingCode(Writer* writer) { + writer->WriteLine("if (other.$0$_.Count != 0) {", name()); + writer->WriteLine(" result.$0$_.Add(other.$0$_);", name()); + writer->WriteLine("}"); +} + +void RepeatedEnumFieldGenerator::GenerateBuildingCode(Writer* writer) { + writer->WriteLine("$0$_.MakeReadOnly();", name()); +} + +void RepeatedEnumFieldGenerator::GenerateParsingCode(Writer* writer) { + writer->WriteLine("scg::ICollection unknownItems;"); + writer->WriteLine( + "input.ReadEnumArray<$0$>(tag, field_name, result.$1$_, out unknownItems);", + type_name(), name()); + if (!use_lite_runtime()) { + writer->WriteLine("if (unknownItems != null) {"); + writer->WriteLine(" if (unknownFields == null) {"); + writer->WriteLine( + " unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);"); + writer->WriteLine(" }"); + writer->WriteLine(" foreach (object rawValue in unknownItems)"); + writer->WriteLine(" if (rawValue is int)"); + writer->WriteLine( + " unknownFields.MergeVarintField($0$, (ulong)(int)rawValue);", + number()); + writer->WriteLine("}"); + } +} + +void RepeatedEnumFieldGenerator::GenerateSerializationCode(Writer* writer) { + writer->WriteLine("if ($0$_.Count > 0) {", name()); + writer->Indent(); + if (descriptor_->is_packed()) { + writer->WriteLine( + "output.WritePackedEnumArray($0$, field_names[$2$], $1$MemoizedSerializedSize, $1$_);", + number(), name(), field_ordinal()); + } else { + writer->WriteLine("output.WriteEnumArray($0$, field_names[$2$], $1$_);", + number(), name(), field_ordinal()); + } + writer->Outdent(); + writer->WriteLine("}"); +} + +void RepeatedEnumFieldGenerator::GenerateSerializedSizeCode(Writer* writer) { + writer->WriteLine("{"); + writer->Indent(); + writer->WriteLine("int dataSize = 0;"); + writer->WriteLine("if ($0$_.Count > 0) {", name()); + writer->Indent(); + writer->WriteLine("foreach ($0$ element in $1$_) {", type_name(), name()); + writer->WriteLine( + " dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element);"); + writer->WriteLine("}"); + writer->WriteLine("size += dataSize;"); + int tagSize = internal::WireFormat::TagSize(descriptor_->number(), descriptor_->type()); + if (descriptor_->is_packed()) { + writer->WriteLine("size += $0$;", SimpleItoa(tagSize)); + writer->WriteLine( + "size += pb::CodedOutputStream.ComputeRawVarint32Size((uint) dataSize);"); + } else { + writer->WriteLine("size += $0$ * $1$_.Count;", SimpleItoa(tagSize), name()); + } + writer->Outdent(); + writer->WriteLine("}"); + // cache the data size for packed fields. + if (descriptor_->is_packed()) { + writer->WriteLine("$0$MemoizedSerializedSize = dataSize;", name()); + } + writer->Outdent(); + writer->WriteLine("}"); +} + +void RepeatedEnumFieldGenerator::WriteHash(Writer* writer) { + writer->WriteLine("foreach($0$ i in $1$_)", type_name(), name()); + writer->WriteLine(" hash ^= i.GetHashCode();"); +} + +void RepeatedEnumFieldGenerator::WriteEquals(Writer* writer) { + writer->WriteLine("if($0$_.Count != other.$0$_.Count) return false;", name()); + writer->WriteLine("for(int ix=0; ix < $0$_.Count; ix++)", name()); + writer->WriteLine(" if(!$0$_[ix].Equals(other.$0$_[ix])) return false;", + name()); +} + +void RepeatedEnumFieldGenerator::WriteToString(Writer* writer) { + writer->WriteLine("PrintField(\"$0$\", $1$_, writer);", descriptor_->name(), + name()); +} + +} // namespace csharp +} // namespace compiler +} // namespace protobuf +} // namespace google diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.h b/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.h new file mode 100644 index 00000000..c872131c --- /dev/null +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.h @@ -0,0 +1,73 @@ +// 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_REPEATED_ENUM_FIELD_H__ +#define GOOGLE_PROTOBUF_COMPILER_CSHARP_REPEATED_ENUM_FIELD_H__ + +#include + +#include +#include + +namespace google { +namespace protobuf { +namespace compiler { +namespace csharp { + +class Writer; + +class RepeatedEnumFieldGenerator : public FieldGeneratorBase { + public: + RepeatedEnumFieldGenerator(const FieldDescriptor* descriptor, int fieldOrdinal); + ~RepeatedEnumFieldGenerator(); + + virtual void GenerateMembers(Writer* writer); + virtual void GenerateBuilderMembers(Writer* writer); + virtual void GenerateMergingCode(Writer* writer); + virtual void GenerateBuildingCode(Writer* writer); + virtual void GenerateParsingCode(Writer* writer); + virtual void GenerateSerializationCode(Writer* writer); + virtual void GenerateSerializedSizeCode(Writer* writer); + + virtual void WriteHash(Writer* writer); + virtual void WriteEquals(Writer* writer); + virtual void WriteToString(Writer* writer); + + private: + GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedEnumFieldGenerator); +}; + +} // namespace csharp +} // namespace compiler +} // namespace protobuf +} // namespace google + +#endif // GOOGLE_PROTOBUF_COMPILER_CSHARP_REPEATED_ENUM_FIELD_H__ + diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc b/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc new file mode 100644 index 00000000..2dfcd402 --- /dev/null +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc @@ -0,0 +1,201 @@ +// 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 + +namespace google { +namespace protobuf { +namespace compiler { +namespace csharp { + +RepeatedMessageFieldGenerator::RepeatedMessageFieldGenerator( + const FieldDescriptor* descriptor, int fieldOrdinal) + : FieldGeneratorBase(descriptor, fieldOrdinal) { +} + +RepeatedMessageFieldGenerator::~RepeatedMessageFieldGenerator() { + +} + +void RepeatedMessageFieldGenerator::GenerateMembers(Writer* writer) { + writer->WriteLine( + "private pbc::PopsicleList<$0$> $1$_ = new pbc::PopsicleList<$0$>();", + type_name(), name()); + AddDeprecatedFlag(writer); + writer->WriteLine("public scg::IList<$0$> $1$List {", type_name(), + property_name()); + writer->WriteLine(" get { return $0$_; }", name()); + writer->WriteLine("}"); + + // TODO(jonskeet): Redundant API calls? Possibly - include for portability though. Maybe create an option. + AddDeprecatedFlag(writer); + writer->WriteLine("public int $0$Count {", property_name()); + writer->WriteLine(" get { return $0$_.Count; }", name()); + writer->WriteLine("}"); + + AddDeprecatedFlag(writer); + writer->WriteLine("public $0$ Get$1$(int index) {", type_name(), + property_name()); + writer->WriteLine(" return $0$_[index];", name()); + writer->WriteLine("}"); +} + +void RepeatedMessageFieldGenerator::GenerateBuilderMembers(Writer* writer) { + // 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(writer); + writer->WriteLine("public pbc::IPopsicleList<$0$> $1$List {", type_name(), + property_name()); + writer->WriteLine(" get { return PrepareBuilder().$0$_; }", name()); + writer->WriteLine("}"); + AddDeprecatedFlag(writer); + writer->WriteLine("public int $0$Count {", property_name()); + writer->WriteLine(" get { return result.$0$Count; }", property_name()); + writer->WriteLine("}"); + AddDeprecatedFlag(writer); + writer->WriteLine("public $0$ Get$1$(int index) {", type_name(), + property_name()); + writer->WriteLine(" return result.Get$0$(index);", property_name()); + writer->WriteLine("}"); + AddDeprecatedFlag(writer); + writer->WriteLine("public Builder Set$0$(int index, $1$ value) {", + property_name(), type_name()); + AddNullCheck(writer); + writer->WriteLine(" PrepareBuilder();"); + writer->WriteLine(" result.$0$_[index] = value;", name()); + writer->WriteLine(" return this;"); + writer->WriteLine("}"); + // Extra overload for builder (just on messages) + AddDeprecatedFlag(writer); + writer->WriteLine( + "public Builder Set$0$(int index, $1$.Builder builderForValue) {", + property_name(), type_name()); + AddNullCheck(writer, "builderForValue"); + writer->WriteLine(" PrepareBuilder();"); + writer->WriteLine(" result.$0$_[index] = builderForValue.Build();", name()); + writer->WriteLine(" return this;"); + writer->WriteLine("}"); + AddDeprecatedFlag(writer); + writer->WriteLine("public Builder Add$0$($1$ value) {", property_name(), + type_name()); + AddNullCheck(writer); + writer->WriteLine(" PrepareBuilder();"); + writer->WriteLine(" result.$0$_.Add(value);", name(), type_name()); + writer->WriteLine(" return this;"); + writer->WriteLine("}"); + // Extra overload for builder (just on messages) + AddDeprecatedFlag(writer); + writer->WriteLine("public Builder Add$0$($1$.Builder builderForValue) {", + property_name(), type_name()); + AddNullCheck(writer, "builderForValue"); + writer->WriteLine(" PrepareBuilder();"); + writer->WriteLine(" result.$0$_.Add(builderForValue.Build());", name()); + writer->WriteLine(" return this;"); + writer->WriteLine("}"); + AddDeprecatedFlag(writer); + writer->WriteLine( + "public Builder AddRange$0$(scg::IEnumerable<$1$> values) {", + property_name(), type_name()); + writer->WriteLine(" PrepareBuilder();"); + writer->WriteLine(" result.$0$_.Add(values);", name()); + writer->WriteLine(" return this;"); + writer->WriteLine("}"); + AddDeprecatedFlag(writer); + writer->WriteLine("public Builder Clear$0$() {", property_name()); + writer->WriteLine(" PrepareBuilder();"); + writer->WriteLine(" result.$0$_.Clear();", name()); + writer->WriteLine(" return this;"); + writer->WriteLine("}"); +} + +void RepeatedMessageFieldGenerator::GenerateMergingCode(Writer* writer) { + writer->WriteLine("if (other.$0$_.Count != 0) {", name()); + writer->WriteLine(" result.$0$_.Add(other.$0$_);", name()); + writer->WriteLine("}"); +} + +void RepeatedMessageFieldGenerator::GenerateBuildingCode(Writer* writer) { + writer->WriteLine("$0$_.MakeReadOnly();", name()); +} + +void RepeatedMessageFieldGenerator::GenerateParsingCode(Writer* writer) { + writer->WriteLine( + "input.Read$0$Array(tag, field_name, result.$1$_, $2$.DefaultInstance, extensionRegistry);", + message_or_group(), name(), type_name()); +} + +void RepeatedMessageFieldGenerator::GenerateSerializationCode(Writer* writer) { + writer->WriteLine("if ($0$_.Count > 0) {", name()); + writer->Indent(); + writer->WriteLine("output.Write$0$Array($1$, field_names[$3$], $2$_);", + message_or_group(), number(), name(), field_ordinal()); + writer->Outdent(); + writer->WriteLine("}"); +} + +void RepeatedMessageFieldGenerator::GenerateSerializedSizeCode(Writer* writer) { + writer->WriteLine("foreach ($0$ element in $1$List) {", type_name(), + property_name()); + writer->WriteLine( + " size += pb::CodedOutputStream.Compute$0$Size($1$, element);", + message_or_group(), number()); + writer->WriteLine("}"); +} + +void RepeatedMessageFieldGenerator::WriteHash(Writer* writer) { + writer->WriteLine("foreach($0$ i in $1$_)", type_name(), name()); + writer->WriteLine(" hash ^= i.GetHashCode();"); +} +void RepeatedMessageFieldGenerator::WriteEquals(Writer* writer) { + writer->WriteLine("if($0$_.Count != other.$0$_.Count) return false;", name()); + writer->WriteLine("for(int ix=0; ix < $0$_.Count; ix++)", name()); + writer->WriteLine(" if(!$0$_[ix].Equals(other.$0$_[ix])) return false;", + name()); +} +void RepeatedMessageFieldGenerator::WriteToString(Writer* writer) { + writer->WriteLine("PrintField(\"$0$\", $1$_, writer);", + GetFieldName(descriptor_), name()); +} + +} // namespace csharp +} // namespace compiler +} // namespace protobuf +} // namespace google diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.h b/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.h new file mode 100644 index 00000000..104274cb --- /dev/null +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.h @@ -0,0 +1,73 @@ +// 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_REPEATED_MESSAGE_FIELD_H__ +#define GOOGLE_PROTOBUF_COMPILER_CSHARP_REPEATED_MESSAGE_FIELD_H__ + +#include + +#include +#include + +namespace google { +namespace protobuf { +namespace compiler { +namespace csharp { + +class Writer; + +class RepeatedMessageFieldGenerator : public FieldGeneratorBase { + public: + RepeatedMessageFieldGenerator(const FieldDescriptor* descriptor, int fieldOrdinal); + ~RepeatedMessageFieldGenerator(); + + virtual void GenerateMembers(Writer* writer); + virtual void GenerateBuilderMembers(Writer* writer); + virtual void GenerateMergingCode(Writer* writer); + virtual void GenerateBuildingCode(Writer* writer); + virtual void GenerateParsingCode(Writer* writer); + virtual void GenerateSerializationCode(Writer* writer); + virtual void GenerateSerializedSizeCode(Writer* writer); + + virtual void WriteHash(Writer* writer); + virtual void WriteEquals(Writer* writer); + virtual void WriteToString(Writer* writer); + + private: + GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedMessageFieldGenerator); +}; + +} // namespace csharp +} // namespace compiler +} // namespace protobuf +} // namespace google + +#endif // GOOGLE_PROTOBUF_COMPILER_CSHARP_REPEATED_MESSAGE_FIELD_H__ + diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc b/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc new file mode 100644 index 00000000..8b285468 --- /dev/null +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc @@ -0,0 +1,219 @@ +// 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 +#include + +namespace google { +namespace protobuf { +namespace compiler { +namespace csharp { + +RepeatedPrimitiveFieldGenerator::RepeatedPrimitiveFieldGenerator( + const FieldDescriptor* descriptor, int fieldOrdinal) + : FieldGeneratorBase(descriptor, fieldOrdinal) { +} + +RepeatedPrimitiveFieldGenerator::~RepeatedPrimitiveFieldGenerator() { + +} + +void RepeatedPrimitiveFieldGenerator::GenerateMembers(Writer* writer) { + if (descriptor_->is_packed() && optimize_speed()) { + writer->WriteLine("private int $0$MemoizedSerializedSize;", name()); + } + writer->WriteLine( + "private pbc::PopsicleList<$0$> $1$_ = new pbc::PopsicleList<$0$>();", + type_name(), name()); + AddPublicMemberAttributes(writer); + writer->WriteLine("public scg::IList<$0$> $1$List {", type_name(), + property_name()); + writer->WriteLine(" get { return pbc::Lists.AsReadOnly($0$_); }", name()); + writer->WriteLine("}"); + + // TODO(jonskeet): Redundant API calls? Possibly - include for portability though. Maybe create an option. + AddDeprecatedFlag(writer); + writer->WriteLine("public int $0$Count {", property_name()); + writer->WriteLine(" get { return $0$_.Count; }", name()); + writer->WriteLine("}"); + + AddPublicMemberAttributes(writer); + writer->WriteLine("public $0$ Get$1$(int index) {", type_name(), + property_name()); + writer->WriteLine(" return $0$_[index];", name()); + writer->WriteLine("}"); +} + +void RepeatedPrimitiveFieldGenerator::GenerateBuilderMembers(Writer* writer) { + // 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(writer); + writer->WriteLine("public pbc::IPopsicleList<$0$> $1$List {", type_name(), + property_name()); + writer->WriteLine(" get { return PrepareBuilder().$0$_; }", name()); + writer->WriteLine("}"); + AddDeprecatedFlag(writer); + writer->WriteLine("public int $0$Count {", property_name()); + writer->WriteLine(" get { return result.$0$Count; }", property_name()); + writer->WriteLine("}"); + AddPublicMemberAttributes(writer); + writer->WriteLine("public $0$ Get$1$(int index) {", type_name(), + property_name()); + writer->WriteLine(" return result.Get$0$(index);", property_name()); + writer->WriteLine("}"); + AddPublicMemberAttributes(writer); + writer->WriteLine("public Builder Set$0$(int index, $1$ value) {", + property_name(), type_name()); + AddNullCheck(writer); + writer->WriteLine(" PrepareBuilder();"); + writer->WriteLine(" result.$0$_[index] = value;", name()); + writer->WriteLine(" return this;"); + writer->WriteLine("}"); + AddPublicMemberAttributes(writer); + writer->WriteLine("public Builder Add$0$($1$ value) {", property_name(), + type_name()); + AddNullCheck(writer); + writer->WriteLine(" PrepareBuilder();"); + writer->WriteLine(" result.$0$_.Add(value);", name(), type_name()); + writer->WriteLine(" return this;"); + writer->WriteLine("}"); + AddPublicMemberAttributes(writer); + writer->WriteLine( + "public Builder AddRange$0$(scg::IEnumerable<$1$> values) {", + property_name(), type_name()); + writer->WriteLine(" PrepareBuilder();"); + writer->WriteLine(" result.$0$_.Add(values);", name()); + writer->WriteLine(" return this;"); + writer->WriteLine("}"); + AddDeprecatedFlag(writer); + writer->WriteLine("public Builder Clear$0$() {", property_name()); + writer->WriteLine(" PrepareBuilder();"); + writer->WriteLine(" result.$0$_.Clear();", name()); + writer->WriteLine(" return this;"); + writer->WriteLine("}"); +} + +void RepeatedPrimitiveFieldGenerator::GenerateMergingCode(Writer* writer) { + writer->WriteLine("if (other.$0$_.Count != 0) {", name()); + writer->WriteLine(" result.$0$_.Add(other.$0$_);", name()); + writer->WriteLine("}"); +} + +void RepeatedPrimitiveFieldGenerator::GenerateBuildingCode(Writer* writer) { + writer->WriteLine("$0$_.MakeReadOnly();", name()); +} + +void RepeatedPrimitiveFieldGenerator::GenerateParsingCode(Writer* writer) { + writer->WriteLine("input.Read$0$Array(tag, field_name, result.$1$_);", + capitalized_type_name(), name()); +} + +void RepeatedPrimitiveFieldGenerator::GenerateSerializationCode( + Writer* writer) { + writer->WriteLine("if ($0$_.Count > 0) {", name()); + writer->Indent(); + if (descriptor_->is_packed()) { + writer->WriteLine( + "output.WritePacked$0$Array($1$, field_names[$3$], $2$MemoizedSerializedSize, $2$_);", + capitalized_type_name(), number(), name(), field_ordinal()); + } else { + writer->WriteLine("output.Write$0$Array($1$, field_names[$3$], $2$_);", + capitalized_type_name(), number(), name(), + field_ordinal()); + } + writer->Outdent(); + writer->WriteLine("}"); +} + +void RepeatedPrimitiveFieldGenerator::GenerateSerializedSizeCode( + Writer* writer) { + writer->WriteLine("{"); + writer->Indent(); + writer->WriteLine("int dataSize = 0;"); + int fixedSize = GetFixedSize(descriptor_->type()); + if (fixedSize == -1) { + writer->WriteLine("foreach ($0$ element in $1$List) {", type_name(), + property_name()); + writer->WriteLine( + " dataSize += pb::CodedOutputStream.Compute$0$SizeNoTag(element);", + capitalized_type_name(), number()); + writer->WriteLine("}"); + } else { + writer->WriteLine("dataSize = $0$ * $1$_.Count;", SimpleItoa(fixedSize), name()); + } + writer->WriteLine("size += dataSize;"); + int tagSize = internal::WireFormat::TagSize(descriptor_->number(), descriptor_->type()); + if (descriptor_->is_packed()) { + writer->WriteLine("if ($0$_.Count != 0) {", name()); + writer->WriteLine( + " size += $0$ + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize);", + SimpleItoa(tagSize)); + writer->WriteLine("}"); + } else { + writer->WriteLine("size += $0$ * $1$_.Count;", SimpleItoa(tagSize), name()); + } + // cache the data size for packed fields. + if (descriptor_->is_packed()) { + writer->WriteLine("$0$MemoizedSerializedSize = dataSize;", name()); + } + writer->Outdent(); + writer->WriteLine("}"); +} + +void RepeatedPrimitiveFieldGenerator::WriteHash(Writer* writer) { + writer->WriteLine("foreach($0$ i in $1$_)", type_name(), name()); + writer->WriteLine(" hash ^= i.GetHashCode();"); +} +void RepeatedPrimitiveFieldGenerator::WriteEquals(Writer* writer) { + writer->WriteLine("if($0$_.Count != other.$0$_.Count) return false;", name()); + writer->WriteLine("for(int ix=0; ix < $0$_.Count; ix++)", name()); + writer->WriteLine(" if(!$0$_[ix].Equals(other.$0$_[ix])) return false;", + name()); +} +void RepeatedPrimitiveFieldGenerator::WriteToString(Writer* writer) { + writer->WriteLine("PrintField(\"$0$\", $1$_, writer);", descriptor_->name(), + name()); +} + +} // namespace csharp +} // namespace compiler +} // namespace protobuf +} // namespace google diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h b/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h new file mode 100644 index 00000000..07b12015 --- /dev/null +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h @@ -0,0 +1,73 @@ +// 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_REPEATED_PRIMITIVE_FIELD_H__ +#define GOOGLE_PROTOBUF_COMPILER_CSHARP_REPEATED_PRIMITIVE_FIELD_H__ + +#include + +#include +#include + +namespace google { +namespace protobuf { +namespace compiler { +namespace csharp { + +class Writer; + +class RepeatedPrimitiveFieldGenerator : public FieldGeneratorBase { + public: + RepeatedPrimitiveFieldGenerator(const FieldDescriptor* descriptor, int fieldOrdinal); + ~RepeatedPrimitiveFieldGenerator(); + + virtual void GenerateMembers(Writer* writer); + virtual void GenerateBuilderMembers(Writer* writer); + virtual void GenerateMergingCode(Writer* writer); + virtual void GenerateBuildingCode(Writer* writer); + virtual void GenerateParsingCode(Writer* writer); + virtual void GenerateSerializationCode(Writer* writer); + virtual void GenerateSerializedSizeCode(Writer* writer); + + virtual void WriteHash(Writer* writer); + virtual void WriteEquals(Writer* writer); + virtual void WriteToString(Writer* writer); + + private: + GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedPrimitiveFieldGenerator); +}; + +} // namespace csharp +} // namespace compiler +} // namespace protobuf +} // namespace google + +#endif // GOOGLE_PROTOBUF_COMPILER_CSHARP_REPEATED_PRIMITIVE_FIELD_H__ + diff --git a/src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc b/src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc new file mode 100644 index 00000000..35c28141 --- /dev/null +++ b/src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc @@ -0,0 +1,82 @@ +// 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 + +namespace google { +namespace protobuf { +namespace compiler { +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() { +} + +void SourceGeneratorBase::WriteGeneratedCodeAttributes(Writer* writer) { + // TODO(jtattermusch): + //if (descriptor.File.CSharpOptions.GeneratedCodeAttributes) + // { + // writer.WriteLine("[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]"); + // writer.WriteLine("[global::System.CodeDom.Compiler.GeneratedCodeAttribute(\"{0}\", \"{1}\")]", + // GetType().Assembly.GetName().Name, GetType().Assembly.GetName().Version); + // } +} + +std::string SourceGeneratorBase::class_access_level() { + // TODO(jtattermusch): implement this + return "public"; +} + +} // namespace csharp +} // namespace compiler +} // namespace protobuf +} // namespace google diff --git a/src/google/protobuf/compiler/csharp/csharp_source_generator_base.h b/src/google/protobuf/compiler/csharp/csharp_source_generator_base.h new file mode 100644 index 00000000..1955394e --- /dev/null +++ b/src/google/protobuf/compiler/csharp/csharp_source_generator_base.h @@ -0,0 +1,83 @@ +// 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_SOURCE_GENERATOR_BASE_H__ +#define GOOGLE_PROTOBUF_COMPILER_CSHARP_SOURCE_GENERATOR_BASE_H__ + +#include + +#include + +namespace google { +namespace protobuf { +namespace compiler { +namespace csharp { + +class Writer; + +class SourceGeneratorBase { + protected: + SourceGeneratorBase(const FileDescriptor* descriptor); + virtual ~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(Writer* writer); + + private: + const FileDescriptor* descriptor_; + bool optimizeSize_; + bool optimizeSpeed_; + bool useLiteRuntime_; + std::string runtimeSuffix_; + + GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(SourceGeneratorBase); +}; + +} // namespace csharp +} // namespace compiler +} // namespace protobuf +} // namespace google + +#endif // GOOGLE_PROTOBUF_COMPILER_CSHARP_SOURCE_GENERATOR_BASE_H__ + diff --git a/src/google/protobuf/compiler/csharp/csharp_umbrella_class.cc b/src/google/protobuf/compiler/csharp/csharp_umbrella_class.cc new file mode 100644 index 00000000..ead6c1a9 --- /dev/null +++ b/src/google/protobuf/compiler/csharp/csharp_umbrella_class.cc @@ -0,0 +1,297 @@ +// 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 +#include +#include +#include + +namespace google { +namespace protobuf { +namespace compiler { +namespace csharp { + +UmbrellaClassGenerator::UmbrellaClassGenerator(const FileDescriptor* file) + : SourceGeneratorBase(file), + file_(file) { + namespace_ = GetFileNamespace(file); + umbrellaClassname_ = GetFileUmbrellaClassname(file); + umbrellaNamespace_ = GetFileUmbrellaNamespace(file); +} + +UmbrellaClassGenerator::~UmbrellaClassGenerator() { +} + +void UmbrellaClassGenerator::Generate(Writer* writer) { + WriteIntroduction(writer); + WriteExtensionRegistration(writer); + + // write children: Extensions + if (file_->extension_count() > 0) { + writer->WriteLine("#region Extensions"); + for (int i = 0; i < file_->extension_count(); i++) { + ExtensionGenerator extensionGenerator(file_->extension(i)); + extensionGenerator.Generate(writer); + } + writer->WriteLine("#endregion"); + writer->WriteLine(); + } + + writer->WriteLine("#region Static variables"); + for (int i = 0; i < file_->message_type_count(); i++) { + MessageGenerator messageGenerator(file_->message_type(i)); + messageGenerator.GenerateStaticVariables(writer); + } + writer->WriteLine("#endregion"); + if (!use_lite_runtime()) { + WriteDescriptor(writer); + } else { + WriteLiteExtensions(writer); + } + // The class declaration either gets closed before or after the children are written. + if (!file_->options().csharp_nest_classes()) { + writer->Outdent(); + writer->WriteLine("}"); + + // Close the namespace around the umbrella class if defined + if (!file_->options().csharp_nest_classes() + && !umbrellaNamespace_.empty()) { + writer->Outdent(); + writer->WriteLine("}"); + } + } + + // write children: Enums + if (file_->enum_type_count() > 0) { + writer->WriteLine("#region Enums"); + for (int i = 0; i < file_->enum_type_count(); i++) { + EnumGenerator enumGenerator(file_->enum_type(i)); + enumGenerator.Generate(writer); + } + writer->WriteLine("#endregion"); + writer->WriteLine(); + } + + // write children: Messages + if (file_->message_type_count() > 0) { + writer->WriteLine("#region Messages"); + for (int i = 0; i < file_->message_type_count(); i++) { + MessageGenerator messageGenerator(file_->message_type(i)); + messageGenerator.Generate(writer); + } + writer->WriteLine("#endregion"); + writer->WriteLine(); + } + + // TODO(jtattermusch): add support for generating services. + //WriteChildren(writer, "Services", Descriptor.Services); + if (file_->options().csharp_nest_classes()) { + writer->Outdent(); + writer->WriteLine("}"); + } + if (!namespace_.empty()) { + writer->Outdent(); + writer->WriteLine("}"); + } + writer->WriteLine(); + writer->WriteLine("#endregion Designer generated code"); +} + +void UmbrellaClassGenerator::WriteIntroduction(Writer* writer) { + writer->WriteLine( + "// Generated by the protocol buffer compiler. DO NOT EDIT!"); + writer->WriteLine("// source: $0$", file_->name()); + writer->WriteLine("#pragma warning disable 1591, 0612, 3021"); + writer->WriteLine("#region Designer generated code"); + + writer->WriteLine(); + writer->WriteLine("using pb = global::Google.ProtocolBuffers;"); + writer->WriteLine("using pbc = global::Google.ProtocolBuffers.Collections;"); + writer->WriteLine("using pbd = global::Google.ProtocolBuffers.Descriptors;"); + writer->WriteLine("using scg = global::System.Collections.Generic;"); + + if (!namespace_.empty()) { + writer->WriteLine("namespace $0$ {", namespace_); + writer->Indent(); + writer->WriteLine(); + } + + // Add the namespace around the umbrella class if defined + if (!file_->options().csharp_nest_classes() && !umbrellaNamespace_.empty()) { + writer->WriteLine("namespace $0$ {", umbrellaNamespace_); + writer->Indent(); + writer->WriteLine(); + } + + if (file_->options().csharp_code_contracts()) { + writer->WriteLine( + "[global::System.Diagnostics.Contracts.ContractVerificationAttribute(false)]"); + } + writer->WriteLine( + "[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]"); + WriteGeneratedCodeAttributes(writer); + writer->WriteLine("$0$ static partial class $1$ {", class_access_level(), + umbrellaClassname_); + writer->WriteLine(); + writer->Indent(); +} + +void UmbrellaClassGenerator::WriteExtensionRegistration(Writer* writer) { + writer->WriteLine("#region Extension registration"); + writer->WriteLine( + "public static void RegisterAllExtensions(pb::ExtensionRegistry registry) {"); + writer->Indent(); + for (int i = 0; i < file_->extension_count(); i++) { + ExtensionGenerator extensionGenerator(file_->extension(i)); + extensionGenerator.GenerateExtensionRegistrationCode(writer); + } + for (int i = 0; i < file_->message_type_count(); i++) { + MessageGenerator messageGenerator(file_->message_type(i)); + messageGenerator.GenerateExtensionRegistrationCode(writer); + } + writer->Outdent(); + writer->WriteLine("}"); + writer->WriteLine("#endregion"); +} + +void UmbrellaClassGenerator::WriteDescriptor(Writer* writer) { + writer->WriteLine("#region Descriptor"); + + writer->WriteLine("public static pbd::FileDescriptor Descriptor {"); + writer->WriteLine(" get { return descriptor; }"); + writer->WriteLine("}"); + writer->WriteLine("private static pbd::FileDescriptor descriptor;"); + writer->WriteLine(); + writer->WriteLine("static $0$() {", umbrellaClassname_); + writer->Indent(); + writer->WriteLine( + "byte[] descriptorData = global::System.Convert.FromBase64String("); + writer->Indent(); + writer->Indent(); + writer->WriteLine("string.Concat("); + writer->Indent(); + + // TODO(jonskeet): Consider a C#-escaping format here instead of just Base64. + std::string base64 = FileDescriptorToBase64(file_); + while (base64.size() > 60) { + writer->WriteLine("\"$0$\", ", base64.substr(0, 60)); + base64 = base64.substr(60); + } + writer->Outdent(); + writer->WriteLine("\"$0$\"));", base64); + writer->Outdent(); + writer->Outdent(); + writer->WriteLine( + "pbd::FileDescriptor.InternalDescriptorAssigner assigner = delegate(pbd::FileDescriptor root) {"); + writer->Indent(); + writer->WriteLine("descriptor = root;"); + for (int i = 0; i < file_->message_type_count(); i++) { + MessageGenerator messageGenerator(file_->message_type(i)); + messageGenerator.GenerateStaticVariableInitializers(writer); + } + for (int i = 0; i < file_->extension_count(); i++) { + ExtensionGenerator extensionGenerator(file_->extension(i)); + extensionGenerator.GenerateStaticVariableInitializers(writer); + } + + if (uses_extensions()) { + // Must construct an ExtensionRegistry containing all possible extensions + // and return it. + writer->WriteLine( + "pb::ExtensionRegistry registry = pb::ExtensionRegistry.CreateInstance();"); + writer->WriteLine("RegisterAllExtensions(registry);"); + for (int i = 0; i < file_->dependency_count(); i++) { + writer->WriteLine("$0$.RegisterAllExtensions(registry);", + GetFullUmbrellaClassName(file_->dependency(i))); + } + writer->WriteLine("return registry;"); + } else { + writer->WriteLine("return null;"); + } + writer->Outdent(); + writer->WriteLine("};"); + + // ----------------------------------------------------------------- + // Invoke internalBuildGeneratedFileFrom() to build the file. + writer->WriteLine( + "pbd::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData,"); + writer->WriteLine(" new pbd::FileDescriptor[] {"); + for (int i = 0; i < file_->dependency_count(); i++) { + writer->WriteLine(" $0$.Descriptor, ", + GetFullUmbrellaClassName(file_->dependency(i))); + } + writer->WriteLine(" }, assigner);"); + writer->Outdent(); + writer->WriteLine("}"); + writer->WriteLine("#endregion"); + writer->WriteLine(); +} + +void UmbrellaClassGenerator::WriteLiteExtensions(Writer* writer) { + writer->WriteLine("#region Extensions"); + writer->WriteLine("internal static readonly object Descriptor;"); + writer->WriteLine("static $0$() {", umbrellaClassname_); + writer->Indent(); + writer->WriteLine("Descriptor = null;"); + for (int i = 0; i < file_->message_type_count(); i++) { + MessageGenerator messageGenerator(file_->message_type(i)); + messageGenerator.GenerateStaticVariableInitializers(writer); + } + for (int i = 0; i < file_->extension_count(); i++) { + ExtensionGenerator extensionGenerator(file_->extension(i)); + extensionGenerator.GenerateStaticVariableInitializers(writer); + } + writer->Outdent(); + writer->WriteLine("}"); + writer->WriteLine("#endregion"); + writer->WriteLine(); +} + +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 +} // namespace google diff --git a/src/google/protobuf/compiler/csharp/csharp_umbrella_class.h b/src/google/protobuf/compiler/csharp/csharp_umbrella_class.h new file mode 100644 index 00000000..757f8f91 --- /dev/null +++ b/src/google/protobuf/compiler/csharp/csharp_umbrella_class.h @@ -0,0 +1,76 @@ +// 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_UMBRELLA_CLASS_H__ +#define GOOGLE_PROTOBUF_COMPILER_CSHARP_UMBRELLA_CLASS_H__ + +#include + +#include +#include + +namespace google { +namespace protobuf { +namespace compiler { +namespace csharp { + +class Writer; + +class UmbrellaClassGenerator : public SourceGeneratorBase { + public: + UmbrellaClassGenerator(const FileDescriptor* file); + ~UmbrellaClassGenerator(); + + void Generate(Writer* write); + + private: + const FileDescriptor* file_; + + std::string namespace_; + std::string umbrellaClassname_; + std::string umbrellaNamespace_; + + void WriteIntroduction(Writer* writer); + void WriteExtensionRegistration(Writer* writer); + void WriteDescriptor(Writer* writer); + void WriteLiteExtensions(Writer* write); + + bool uses_extensions(); + + GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(UmbrellaClassGenerator); +}; + +} // namespace csharp +} // namespace compiler +} // namespace protobuf +} // 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 new file mode 100644 index 00000000..2bcafde5 --- /dev/null +++ b/src/google/protobuf/compiler/csharp/csharp_writer.cc @@ -0,0 +1,136 @@ +// 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 new file mode 100644 index 00000000..26c59b31 --- /dev/null +++ b/src/google/protobuf/compiler/csharp/csharp_writer.h @@ -0,0 +1,93 @@ +// 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/src/google/protobuf/compiler/main.cc b/src/google/protobuf/compiler/main.cc index 931b8fa3..bc2da38e 100644 --- a/src/google/protobuf/compiler/main.cc +++ b/src/google/protobuf/compiler/main.cc @@ -36,6 +36,7 @@ #include #include #include +#include int main(int argc, char* argv[]) { @@ -68,5 +69,10 @@ int main(int argc, char* argv[]) { cli.RegisterGenerator("--ruby_out", &rb_generator, "Generate Ruby source file."); + // CSharp + google::protobuf::compiler::csharp::Generator csharp_generator; + cli.RegisterGenerator("--csharp_out", &csharp_generator, + "Generate C# source file."); + return cli.Run(argc, argv); } diff --git a/src/google/protobuf/descriptor.pb.cc b/src/google/protobuf/descriptor.pb.cc index 9556206c..3a67e5e0 100644 --- a/src/google/protobuf/descriptor.pb.cc +++ b/src/google/protobuf/descriptor.pb.cc @@ -289,7 +289,7 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, _internal_metadata_), -1); FileOptions_descriptor_ = file->message_type(9); - static const int FileOptions_offsets_[14] = { + static const int FileOptions_offsets_[27] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_package_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_outer_classname_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_multiple_files_), @@ -303,6 +303,19 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, deprecated_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, cc_enable_arenas_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, objc_class_prefix_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, csharp_namespace_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, csharp_umbrella_classname_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, csharp_public_classes_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, csharp_multiple_files_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, csharp_nest_classes_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, csharp_code_contracts_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, csharp_expand_namespace_directories_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, csharp_cls_compliance_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, csharp_add_serializable_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, csharp_generate_private_ctor_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, csharp_file_extension_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, csharp_umbrella_namespace_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, csharp_generated_code_attributes_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, uninterpreted_option_), }; FileOptions_reflection_ = @@ -574,6 +587,7 @@ void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto() { delete MethodDescriptorProto_reflection_; delete FileOptions::default_instance_; delete FileOptions_reflection_; + delete FileOptions::_default_csharp_file_extension_; delete MessageOptions::default_instance_; delete MessageOptions_reflection_; delete FieldOptions::default_instance_; @@ -663,7 +677,7 @@ void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto() { "t_type\030\003 \001(\t\022/\n\007options\030\004 \001(\0132\036.google.p" "rotobuf.MethodOptions\022\037\n\020client_streamin" "g\030\005 \001(\010:\005false\022\037\n\020server_streaming\030\006 \001(\010" - ":\005false\"\347\004\n\013FileOptions\022\024\n\014java_package\030" + ":\005false\"\302\010\n\013FileOptions\022\024\n\014java_package\030" "\001 \001(\t\022\034\n\024java_outer_classname\030\010 \001(\t\022\"\n\023j" "ava_multiple_files\030\n \001(\010:\005false\022,\n\035java_" "generate_equals_and_hash\030\024 \001(\010:\005false\022%\n" @@ -675,50 +689,62 @@ void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto() { "se\022\"\n\023py_generic_services\030\022 \001(\010:\005false\022\031" "\n\ndeprecated\030\027 \001(\010:\005false\022\037\n\020cc_enable_a" "renas\030\037 \001(\010:\005false\022\031\n\021objc_class_prefix\030" - "$ \001(\t\022C\n\024uninterpreted_option\030\347\007 \003(\0132$.g" - "oogle.protobuf.UninterpretedOption\":\n\014Op" - "timizeMode\022\t\n\005SPEED\020\001\022\r\n\tCODE_SIZE\020\002\022\020\n\014" - "LITE_RUNTIME\020\003*\t\010\350\007\020\200\200\200\200\002\"\346\001\n\016MessageOpt" - "ions\022&\n\027message_set_wire_format\030\001 \001(\010:\005f" - "alse\022.\n\037no_standard_descriptor_accessor\030" - "\002 \001(\010:\005false\022\031\n\ndeprecated\030\003 \001(\010:\005false\022" - "\021\n\tmap_entry\030\007 \001(\010\022C\n\024uninterpreted_opti" - "on\030\347\007 \003(\0132$.google.protobuf.Uninterprete" - "dOption*\t\010\350\007\020\200\200\200\200\002\"\240\002\n\014FieldOptions\022:\n\005c" - "type\030\001 \001(\0162#.google.protobuf.FieldOption" - "s.CType:\006STRING\022\016\n\006packed\030\002 \001(\010\022\023\n\004lazy\030" - "\005 \001(\010:\005false\022\031\n\ndeprecated\030\003 \001(\010:\005false\022" - "\023\n\004weak\030\n \001(\010:\005false\022C\n\024uninterpreted_op" - "tion\030\347\007 \003(\0132$.google.protobuf.Uninterpre" - "tedOption\"/\n\005CType\022\n\n\006STRING\020\000\022\010\n\004CORD\020\001" - "\022\020\n\014STRING_PIECE\020\002*\t\010\350\007\020\200\200\200\200\002\"\215\001\n\013EnumOp" - "tions\022\023\n\013allow_alias\030\002 \001(\010\022\031\n\ndeprecated" - "\030\003 \001(\010:\005false\022C\n\024uninterpreted_option\030\347\007" + "$ \001(\t\022\030\n\020csharp_namespace\030% \001(\t\022!\n\031cshar" + "p_umbrella_classname\030& \001(\t\022#\n\025csharp_pub" + "lic_classes\030\' \001(\010:\004true\022\035\n\025csharp_multip" + "le_files\030( \001(\010\022\033\n\023csharp_nest_classes\030) " + "\001(\010\022\035\n\025csharp_code_contracts\030* \001(\010\022+\n#cs" + "harp_expand_namespace_directories\030+ \001(\010\022" + "#\n\025csharp_cls_compliance\030, \001(\010:\004true\022&\n\027" + "csharp_add_serializable\030- \001(\010:\005false\022*\n\034" + "csharp_generate_private_ctor\030. \001(\010:\004true" + "\022\"\n\025csharp_file_extension\030/ \001(\t:\003.cs\022!\n\031" + "csharp_umbrella_namespace\0300 \001(\t\022/\n cshar" + "p_generated_code_attributes\0301 \001(\010:\005false" + "\022C\n\024uninterpreted_option\030\347\007 \003(\0132$.google" + ".protobuf.UninterpretedOption\":\n\014Optimiz" + "eMode\022\t\n\005SPEED\020\001\022\r\n\tCODE_SIZE\020\002\022\020\n\014LITE_" + "RUNTIME\020\003*\t\010\350\007\020\200\200\200\200\002\"\346\001\n\016MessageOptions\022" + "&\n\027message_set_wire_format\030\001 \001(\010:\005false\022" + ".\n\037no_standard_descriptor_accessor\030\002 \001(\010" + ":\005false\022\031\n\ndeprecated\030\003 \001(\010:\005false\022\021\n\tma" + "p_entry\030\007 \001(\010\022C\n\024uninterpreted_option\030\347\007" " \003(\0132$.google.protobuf.UninterpretedOpti" - "on*\t\010\350\007\020\200\200\200\200\002\"}\n\020EnumValueOptions\022\031\n\ndep" - "recated\030\001 \001(\010:\005false\022C\n\024uninterpreted_op" + "on*\t\010\350\007\020\200\200\200\200\002\"\240\002\n\014FieldOptions\022:\n\005ctype\030" + "\001 \001(\0162#.google.protobuf.FieldOptions.CTy" + "pe:\006STRING\022\016\n\006packed\030\002 \001(\010\022\023\n\004lazy\030\005 \001(\010" + ":\005false\022\031\n\ndeprecated\030\003 \001(\010:\005false\022\023\n\004we" + "ak\030\n \001(\010:\005false\022C\n\024uninterpreted_option\030" + "\347\007 \003(\0132$.google.protobuf.UninterpretedOp" + "tion\"/\n\005CType\022\n\n\006STRING\020\000\022\010\n\004CORD\020\001\022\020\n\014S" + "TRING_PIECE\020\002*\t\010\350\007\020\200\200\200\200\002\"\215\001\n\013EnumOptions" + "\022\023\n\013allow_alias\030\002 \001(\010\022\031\n\ndeprecated\030\003 \001(" + "\010:\005false\022C\n\024uninterpreted_option\030\347\007 \003(\0132" + "$.google.protobuf.UninterpretedOption*\t\010" + "\350\007\020\200\200\200\200\002\"}\n\020EnumValueOptions\022\031\n\ndeprecat" + "ed\030\001 \001(\010:\005false\022C\n\024uninterpreted_option\030" + "\347\007 \003(\0132$.google.protobuf.UninterpretedOp" + "tion*\t\010\350\007\020\200\200\200\200\002\"{\n\016ServiceOptions\022\031\n\ndep" + "recated\030! \001(\010:\005false\022C\n\024uninterpreted_op" "tion\030\347\007 \003(\0132$.google.protobuf.Uninterpre" - "tedOption*\t\010\350\007\020\200\200\200\200\002\"{\n\016ServiceOptions\022\031" - "\n\ndeprecated\030! \001(\010:\005false\022C\n\024uninterpret" - "ed_option\030\347\007 \003(\0132$.google.protobuf.Unint" - "erpretedOption*\t\010\350\007\020\200\200\200\200\002\"z\n\rMethodOptio" - "ns\022\031\n\ndeprecated\030! \001(\010:\005false\022C\n\024uninter" - "preted_option\030\347\007 \003(\0132$.google.protobuf.U" - "ninterpretedOption*\t\010\350\007\020\200\200\200\200\002\"\236\002\n\023Uninte" - "rpretedOption\022;\n\004name\030\002 \003(\0132-.google.pro" - "tobuf.UninterpretedOption.NamePart\022\030\n\020id" - "entifier_value\030\003 \001(\t\022\032\n\022positive_int_val" - "ue\030\004 \001(\004\022\032\n\022negative_int_value\030\005 \001(\003\022\024\n\014" - "double_value\030\006 \001(\001\022\024\n\014string_value\030\007 \001(\014" - "\022\027\n\017aggregate_value\030\010 \001(\t\0323\n\010NamePart\022\021\n" - "\tname_part\030\001 \002(\t\022\024\n\014is_extension\030\002 \002(\010\"\325" - "\001\n\016SourceCodeInfo\022:\n\010location\030\001 \003(\0132(.go" - "ogle.protobuf.SourceCodeInfo.Location\032\206\001" - "\n\010Location\022\020\n\004path\030\001 \003(\005B\002\020\001\022\020\n\004span\030\002 \003" - "(\005B\002\020\001\022\030\n\020leading_comments\030\003 \001(\t\022\031\n\021trai" - "ling_comments\030\004 \001(\t\022!\n\031leading_detached_" - "comments\030\006 \003(\tB)\n\023com.google.protobufB\020D" - "escriptorProtosH\001", 4617); + "tedOption*\t\010\350\007\020\200\200\200\200\002\"z\n\rMethodOptions\022\031\n" + "\ndeprecated\030! \001(\010:\005false\022C\n\024uninterprete" + "d_option\030\347\007 \003(\0132$.google.protobuf.Uninte" + "rpretedOption*\t\010\350\007\020\200\200\200\200\002\"\236\002\n\023Uninterpret" + "edOption\022;\n\004name\030\002 \003(\0132-.google.protobuf" + ".UninterpretedOption.NamePart\022\030\n\020identif" + "ier_value\030\003 \001(\t\022\032\n\022positive_int_value\030\004 " + "\001(\004\022\032\n\022negative_int_value\030\005 \001(\003\022\024\n\014doubl" + "e_value\030\006 \001(\001\022\024\n\014string_value\030\007 \001(\014\022\027\n\017a" + "ggregate_value\030\010 \001(\t\0323\n\010NamePart\022\021\n\tname" + "_part\030\001 \002(\t\022\024\n\014is_extension\030\002 \002(\010\"\325\001\n\016So" + "urceCodeInfo\022:\n\010location\030\001 \003(\0132(.google." + "protobuf.SourceCodeInfo.Location\032\206\001\n\010Loc" + "ation\022\020\n\004path\030\001 \003(\005B\002\020\001\022\020\n\004span\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_detached_comme" + "nts\030\006 \003(\tB)\n\023com.google.protobufB\020Descri" + "ptorProtosH\001", 5092); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/descriptor.proto", &protobuf_RegisterTypes); FileDescriptorSet::default_instance_ = new FileDescriptorSet(); @@ -731,6 +757,8 @@ void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto() { EnumValueDescriptorProto::default_instance_ = new EnumValueDescriptorProto(); ServiceDescriptorProto::default_instance_ = new ServiceDescriptorProto(); MethodDescriptorProto::default_instance_ = new MethodDescriptorProto(); + FileOptions::_default_csharp_file_extension_ = + new ::std::string(".cs", 3); FileOptions::default_instance_ = new FileOptions(); MessageOptions::default_instance_ = new MessageOptions(); FieldOptions::default_instance_ = new FieldOptions(); @@ -7002,6 +7030,7 @@ const FileOptions_OptimizeMode FileOptions::OptimizeMode_MIN; const FileOptions_OptimizeMode FileOptions::OptimizeMode_MAX; const int FileOptions::OptimizeMode_ARRAYSIZE; #endif // _MSC_VER +::std::string* FileOptions::_default_csharp_file_extension_ = NULL; #ifndef _MSC_VER const int FileOptions::kJavaPackageFieldNumber; const int FileOptions::kJavaOuterClassnameFieldNumber; @@ -7016,6 +7045,19 @@ const int FileOptions::kPyGenericServicesFieldNumber; const int FileOptions::kDeprecatedFieldNumber; const int FileOptions::kCcEnableArenasFieldNumber; const int FileOptions::kObjcClassPrefixFieldNumber; +const int FileOptions::kCsharpNamespaceFieldNumber; +const int FileOptions::kCsharpUmbrellaClassnameFieldNumber; +const int FileOptions::kCsharpPublicClassesFieldNumber; +const int FileOptions::kCsharpMultipleFilesFieldNumber; +const int FileOptions::kCsharpNestClassesFieldNumber; +const int FileOptions::kCsharpCodeContractsFieldNumber; +const int FileOptions::kCsharpExpandNamespaceDirectoriesFieldNumber; +const int FileOptions::kCsharpClsComplianceFieldNumber; +const int FileOptions::kCsharpAddSerializableFieldNumber; +const int FileOptions::kCsharpGeneratePrivateCtorFieldNumber; +const int FileOptions::kCsharpFileExtensionFieldNumber; +const int FileOptions::kCsharpUmbrellaNamespaceFieldNumber; +const int FileOptions::kCsharpGeneratedCodeAttributesFieldNumber; const int FileOptions::kUninterpretedOptionFieldNumber; #endif // !_MSC_VER @@ -7052,6 +7094,19 @@ void FileOptions::SharedCtor() { deprecated_ = false; cc_enable_arenas_ = false; objc_class_prefix_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + csharp_namespace_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + csharp_umbrella_classname_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + csharp_public_classes_ = true; + csharp_multiple_files_ = false; + csharp_nest_classes_ = false; + csharp_code_contracts_ = false; + csharp_expand_namespace_directories_ = false; + csharp_cls_compliance_ = true; + csharp_add_serializable_ = false; + csharp_generate_private_ctor_ = true; + csharp_file_extension_.UnsafeSetDefault(_default_csharp_file_extension_); + csharp_umbrella_namespace_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + csharp_generated_code_attributes_ = false; ::memset(_has_bits_, 0, sizeof(_has_bits_)); } @@ -7065,6 +7120,10 @@ void FileOptions::SharedDtor() { java_outer_classname_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); go_package_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); objc_class_prefix_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + csharp_namespace_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + csharp_umbrella_classname_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + csharp_file_extension_.DestroyNoArena(_default_csharp_file_extension_); + csharp_umbrella_namespace_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); if (this != default_instance_) { } } @@ -7117,11 +7176,34 @@ void FileOptions::Clear() { go_package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } } - if (_has_bits_[8 / 32] & 7936) { + if (_has_bits_[8 / 32] & 65280) { ZR_(java_generic_services_, cc_enable_arenas_); if (has_objc_class_prefix()) { objc_class_prefix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } + if (has_csharp_namespace()) { + csharp_namespace_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + if (has_csharp_umbrella_classname()) { + csharp_umbrella_classname_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + csharp_public_classes_ = true; + } + if (_has_bits_[16 / 32] & 16711680) { + ZR_(csharp_multiple_files_, csharp_code_contracts_); + csharp_expand_namespace_directories_ = false; + csharp_cls_compliance_ = true; + csharp_add_serializable_ = false; + csharp_generate_private_ctor_ = true; + if (has_csharp_file_extension()) { + csharp_file_extension_.ClearToDefaultNoArena(_default_csharp_file_extension_); + } + } + if (_has_bits_[24 / 32] & 50331648) { + if (has_csharp_umbrella_namespace()) { + csharp_umbrella_namespace_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + csharp_generated_code_attributes_ = false; } #undef ZR_HELPER_ @@ -7347,6 +7429,209 @@ bool FileOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } + if (input->ExpectTag(298)) goto parse_csharp_namespace; + break; + } + + // optional string csharp_namespace = 37; + case 37: { + if (tag == 298) { + parse_csharp_namespace: + DO_(::google::protobuf::internal::WireFormatLite::ReadString( + input, this->mutable_csharp_namespace())); + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->csharp_namespace().data(), this->csharp_namespace().length(), + ::google::protobuf::internal::WireFormat::PARSE, + "google.protobuf.FileOptions.csharp_namespace"); + } else { + goto handle_unusual; + } + if (input->ExpectTag(306)) goto parse_csharp_umbrella_classname; + break; + } + + // optional string csharp_umbrella_classname = 38; + case 38: { + if (tag == 306) { + parse_csharp_umbrella_classname: + DO_(::google::protobuf::internal::WireFormatLite::ReadString( + input, this->mutable_csharp_umbrella_classname())); + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->csharp_umbrella_classname().data(), this->csharp_umbrella_classname().length(), + ::google::protobuf::internal::WireFormat::PARSE, + "google.protobuf.FileOptions.csharp_umbrella_classname"); + } else { + goto handle_unusual; + } + if (input->ExpectTag(312)) goto parse_csharp_public_classes; + break; + } + + // optional bool csharp_public_classes = 39 [default = true]; + case 39: { + if (tag == 312) { + parse_csharp_public_classes: + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( + input, &csharp_public_classes_))); + set_has_csharp_public_classes(); + } else { + goto handle_unusual; + } + if (input->ExpectTag(320)) goto parse_csharp_multiple_files; + break; + } + + // optional bool csharp_multiple_files = 40; + case 40: { + if (tag == 320) { + parse_csharp_multiple_files: + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( + input, &csharp_multiple_files_))); + set_has_csharp_multiple_files(); + } else { + goto handle_unusual; + } + if (input->ExpectTag(328)) goto parse_csharp_nest_classes; + break; + } + + // optional bool csharp_nest_classes = 41; + case 41: { + if (tag == 328) { + parse_csharp_nest_classes: + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( + input, &csharp_nest_classes_))); + set_has_csharp_nest_classes(); + } else { + goto handle_unusual; + } + if (input->ExpectTag(336)) goto parse_csharp_code_contracts; + break; + } + + // optional bool csharp_code_contracts = 42; + case 42: { + if (tag == 336) { + parse_csharp_code_contracts: + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( + input, &csharp_code_contracts_))); + set_has_csharp_code_contracts(); + } else { + goto handle_unusual; + } + if (input->ExpectTag(344)) goto parse_csharp_expand_namespace_directories; + break; + } + + // optional bool csharp_expand_namespace_directories = 43; + case 43: { + if (tag == 344) { + parse_csharp_expand_namespace_directories: + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( + input, &csharp_expand_namespace_directories_))); + set_has_csharp_expand_namespace_directories(); + } else { + goto handle_unusual; + } + if (input->ExpectTag(352)) goto parse_csharp_cls_compliance; + break; + } + + // optional bool csharp_cls_compliance = 44 [default = true]; + case 44: { + if (tag == 352) { + parse_csharp_cls_compliance: + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( + input, &csharp_cls_compliance_))); + set_has_csharp_cls_compliance(); + } else { + goto handle_unusual; + } + if (input->ExpectTag(360)) goto parse_csharp_add_serializable; + break; + } + + // optional bool csharp_add_serializable = 45 [default = false]; + case 45: { + if (tag == 360) { + parse_csharp_add_serializable: + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( + input, &csharp_add_serializable_))); + set_has_csharp_add_serializable(); + } else { + goto handle_unusual; + } + if (input->ExpectTag(368)) goto parse_csharp_generate_private_ctor; + break; + } + + // optional bool csharp_generate_private_ctor = 46 [default = true]; + case 46: { + if (tag == 368) { + parse_csharp_generate_private_ctor: + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( + input, &csharp_generate_private_ctor_))); + set_has_csharp_generate_private_ctor(); + } else { + goto handle_unusual; + } + if (input->ExpectTag(378)) goto parse_csharp_file_extension; + break; + } + + // optional string csharp_file_extension = 47 [default = ".cs"]; + case 47: { + if (tag == 378) { + parse_csharp_file_extension: + DO_(::google::protobuf::internal::WireFormatLite::ReadString( + input, this->mutable_csharp_file_extension())); + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->csharp_file_extension().data(), this->csharp_file_extension().length(), + ::google::protobuf::internal::WireFormat::PARSE, + "google.protobuf.FileOptions.csharp_file_extension"); + } else { + goto handle_unusual; + } + if (input->ExpectTag(386)) goto parse_csharp_umbrella_namespace; + break; + } + + // optional string csharp_umbrella_namespace = 48; + case 48: { + if (tag == 386) { + parse_csharp_umbrella_namespace: + DO_(::google::protobuf::internal::WireFormatLite::ReadString( + input, this->mutable_csharp_umbrella_namespace())); + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->csharp_umbrella_namespace().data(), this->csharp_umbrella_namespace().length(), + ::google::protobuf::internal::WireFormat::PARSE, + "google.protobuf.FileOptions.csharp_umbrella_namespace"); + } else { + goto handle_unusual; + } + if (input->ExpectTag(392)) goto parse_csharp_generated_code_attributes; + break; + } + + // optional bool csharp_generated_code_attributes = 49 [default = false]; + case 49: { + if (tag == 392) { + parse_csharp_generated_code_attributes: + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( + input, &csharp_generated_code_attributes_))); + set_has_csharp_generated_code_attributes(); + } else { + goto handle_unusual; + } if (input->ExpectTag(7994)) goto parse_uninterpreted_option; break; } @@ -7481,6 +7766,91 @@ void FileOptions::SerializeWithCachedSizes( 36, this->objc_class_prefix(), output); } + // optional string csharp_namespace = 37; + if (has_csharp_namespace()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->csharp_namespace().data(), this->csharp_namespace().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "google.protobuf.FileOptions.csharp_namespace"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( + 37, this->csharp_namespace(), output); + } + + // optional string csharp_umbrella_classname = 38; + if (has_csharp_umbrella_classname()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->csharp_umbrella_classname().data(), this->csharp_umbrella_classname().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "google.protobuf.FileOptions.csharp_umbrella_classname"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( + 38, this->csharp_umbrella_classname(), output); + } + + // optional bool csharp_public_classes = 39 [default = true]; + if (has_csharp_public_classes()) { + ::google::protobuf::internal::WireFormatLite::WriteBool(39, this->csharp_public_classes(), output); + } + + // optional bool csharp_multiple_files = 40; + if (has_csharp_multiple_files()) { + ::google::protobuf::internal::WireFormatLite::WriteBool(40, this->csharp_multiple_files(), output); + } + + // optional bool csharp_nest_classes = 41; + if (has_csharp_nest_classes()) { + ::google::protobuf::internal::WireFormatLite::WriteBool(41, this->csharp_nest_classes(), output); + } + + // optional bool csharp_code_contracts = 42; + if (has_csharp_code_contracts()) { + ::google::protobuf::internal::WireFormatLite::WriteBool(42, this->csharp_code_contracts(), output); + } + + // optional bool csharp_expand_namespace_directories = 43; + if (has_csharp_expand_namespace_directories()) { + ::google::protobuf::internal::WireFormatLite::WriteBool(43, this->csharp_expand_namespace_directories(), output); + } + + // optional bool csharp_cls_compliance = 44 [default = true]; + if (has_csharp_cls_compliance()) { + ::google::protobuf::internal::WireFormatLite::WriteBool(44, this->csharp_cls_compliance(), output); + } + + // optional bool csharp_add_serializable = 45 [default = false]; + if (has_csharp_add_serializable()) { + ::google::protobuf::internal::WireFormatLite::WriteBool(45, this->csharp_add_serializable(), output); + } + + // optional bool csharp_generate_private_ctor = 46 [default = true]; + if (has_csharp_generate_private_ctor()) { + ::google::protobuf::internal::WireFormatLite::WriteBool(46, this->csharp_generate_private_ctor(), output); + } + + // optional string csharp_file_extension = 47 [default = ".cs"]; + if (has_csharp_file_extension()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->csharp_file_extension().data(), this->csharp_file_extension().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "google.protobuf.FileOptions.csharp_file_extension"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( + 47, this->csharp_file_extension(), output); + } + + // optional string csharp_umbrella_namespace = 48; + if (has_csharp_umbrella_namespace()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->csharp_umbrella_namespace().data(), this->csharp_umbrella_namespace().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "google.protobuf.FileOptions.csharp_umbrella_namespace"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( + 48, this->csharp_umbrella_namespace(), output); + } + + // optional bool csharp_generated_code_attributes = 49 [default = false]; + if (has_csharp_generated_code_attributes()) { + ::google::protobuf::internal::WireFormatLite::WriteBool(49, this->csharp_generated_code_attributes(), output); + } + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( @@ -7591,6 +7961,95 @@ void FileOptions::SerializeWithCachedSizes( 36, this->objc_class_prefix(), target); } + // optional string csharp_namespace = 37; + if (has_csharp_namespace()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->csharp_namespace().data(), this->csharp_namespace().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "google.protobuf.FileOptions.csharp_namespace"); + target = + ::google::protobuf::internal::WireFormatLite::WriteStringToArray( + 37, this->csharp_namespace(), target); + } + + // optional string csharp_umbrella_classname = 38; + if (has_csharp_umbrella_classname()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->csharp_umbrella_classname().data(), this->csharp_umbrella_classname().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "google.protobuf.FileOptions.csharp_umbrella_classname"); + target = + ::google::protobuf::internal::WireFormatLite::WriteStringToArray( + 38, this->csharp_umbrella_classname(), target); + } + + // optional bool csharp_public_classes = 39 [default = true]; + if (has_csharp_public_classes()) { + target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(39, this->csharp_public_classes(), target); + } + + // optional bool csharp_multiple_files = 40; + if (has_csharp_multiple_files()) { + target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(40, this->csharp_multiple_files(), target); + } + + // optional bool csharp_nest_classes = 41; + if (has_csharp_nest_classes()) { + target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(41, this->csharp_nest_classes(), target); + } + + // optional bool csharp_code_contracts = 42; + if (has_csharp_code_contracts()) { + target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(42, this->csharp_code_contracts(), target); + } + + // optional bool csharp_expand_namespace_directories = 43; + if (has_csharp_expand_namespace_directories()) { + target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(43, this->csharp_expand_namespace_directories(), target); + } + + // optional bool csharp_cls_compliance = 44 [default = true]; + if (has_csharp_cls_compliance()) { + target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(44, this->csharp_cls_compliance(), target); + } + + // optional bool csharp_add_serializable = 45 [default = false]; + if (has_csharp_add_serializable()) { + target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(45, this->csharp_add_serializable(), target); + } + + // optional bool csharp_generate_private_ctor = 46 [default = true]; + if (has_csharp_generate_private_ctor()) { + target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(46, this->csharp_generate_private_ctor(), target); + } + + // optional string csharp_file_extension = 47 [default = ".cs"]; + if (has_csharp_file_extension()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->csharp_file_extension().data(), this->csharp_file_extension().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "google.protobuf.FileOptions.csharp_file_extension"); + target = + ::google::protobuf::internal::WireFormatLite::WriteStringToArray( + 47, this->csharp_file_extension(), target); + } + + // optional string csharp_umbrella_namespace = 48; + if (has_csharp_umbrella_namespace()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->csharp_umbrella_namespace().data(), this->csharp_umbrella_namespace().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "google.protobuf.FileOptions.csharp_umbrella_namespace"); + target = + ::google::protobuf::internal::WireFormatLite::WriteStringToArray( + 48, this->csharp_umbrella_namespace(), target); + } + + // optional bool csharp_generated_code_attributes = 49 [default = false]; + if (has_csharp_generated_code_attributes()) { + target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(49, this->csharp_generated_code_attributes(), target); + } + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: @@ -7662,7 +8121,7 @@ int FileOptions::ByteSize() const { } } - if (_has_bits_[8 / 32] & 7936) { + if (_has_bits_[8 / 32] & 65280) { // optional bool java_generic_services = 17 [default = false]; if (has_java_generic_services()) { total_size += 2 + 1; @@ -7690,6 +8149,83 @@ int FileOptions::ByteSize() const { this->objc_class_prefix()); } + // optional string csharp_namespace = 37; + if (has_csharp_namespace()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->csharp_namespace()); + } + + // optional string csharp_umbrella_classname = 38; + if (has_csharp_umbrella_classname()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->csharp_umbrella_classname()); + } + + // optional bool csharp_public_classes = 39 [default = true]; + if (has_csharp_public_classes()) { + total_size += 2 + 1; + } + + } + if (_has_bits_[16 / 32] & 16711680) { + // optional bool csharp_multiple_files = 40; + if (has_csharp_multiple_files()) { + total_size += 2 + 1; + } + + // optional bool csharp_nest_classes = 41; + if (has_csharp_nest_classes()) { + total_size += 2 + 1; + } + + // optional bool csharp_code_contracts = 42; + if (has_csharp_code_contracts()) { + total_size += 2 + 1; + } + + // optional bool csharp_expand_namespace_directories = 43; + if (has_csharp_expand_namespace_directories()) { + total_size += 2 + 1; + } + + // optional bool csharp_cls_compliance = 44 [default = true]; + if (has_csharp_cls_compliance()) { + total_size += 2 + 1; + } + + // optional bool csharp_add_serializable = 45 [default = false]; + if (has_csharp_add_serializable()) { + total_size += 2 + 1; + } + + // optional bool csharp_generate_private_ctor = 46 [default = true]; + if (has_csharp_generate_private_ctor()) { + total_size += 2 + 1; + } + + // optional string csharp_file_extension = 47 [default = ".cs"]; + if (has_csharp_file_extension()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->csharp_file_extension()); + } + + } + if (_has_bits_[24 / 32] & 50331648) { + // optional string csharp_umbrella_namespace = 48; + if (has_csharp_umbrella_namespace()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->csharp_umbrella_namespace()); + } + + // optional bool csharp_generated_code_attributes = 49 [default = false]; + if (has_csharp_generated_code_attributes()) { + total_size += 2 + 1; + } + } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; total_size += 2 * this->uninterpreted_option_size(); @@ -7773,6 +8309,53 @@ void FileOptions::MergeFrom(const FileOptions& from) { set_has_objc_class_prefix(); objc_class_prefix_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.objc_class_prefix_); } + if (from.has_csharp_namespace()) { + set_has_csharp_namespace(); + csharp_namespace_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.csharp_namespace_); + } + if (from.has_csharp_umbrella_classname()) { + set_has_csharp_umbrella_classname(); + csharp_umbrella_classname_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.csharp_umbrella_classname_); + } + if (from.has_csharp_public_classes()) { + set_csharp_public_classes(from.csharp_public_classes()); + } + } + if (from._has_bits_[16 / 32] & (0xffu << (16 % 32))) { + if (from.has_csharp_multiple_files()) { + set_csharp_multiple_files(from.csharp_multiple_files()); + } + if (from.has_csharp_nest_classes()) { + set_csharp_nest_classes(from.csharp_nest_classes()); + } + if (from.has_csharp_code_contracts()) { + set_csharp_code_contracts(from.csharp_code_contracts()); + } + if (from.has_csharp_expand_namespace_directories()) { + set_csharp_expand_namespace_directories(from.csharp_expand_namespace_directories()); + } + if (from.has_csharp_cls_compliance()) { + set_csharp_cls_compliance(from.csharp_cls_compliance()); + } + if (from.has_csharp_add_serializable()) { + set_csharp_add_serializable(from.csharp_add_serializable()); + } + if (from.has_csharp_generate_private_ctor()) { + set_csharp_generate_private_ctor(from.csharp_generate_private_ctor()); + } + if (from.has_csharp_file_extension()) { + set_has_csharp_file_extension(); + csharp_file_extension_.AssignWithDefault(_default_csharp_file_extension_, from.csharp_file_extension_); + } + } + if (from._has_bits_[24 / 32] & (0xffu << (24 % 32))) { + if (from.has_csharp_umbrella_namespace()) { + set_has_csharp_umbrella_namespace(); + csharp_umbrella_namespace_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.csharp_umbrella_namespace_); + } + if (from.has_csharp_generated_code_attributes()) { + set_csharp_generated_code_attributes(from.csharp_generated_code_attributes()); + } } _extensions_.MergeFrom(from._extensions_); if (from._internal_metadata_.have_unknown_fields()) { @@ -7817,6 +8400,19 @@ void FileOptions::InternalSwap(FileOptions* other) { std::swap(deprecated_, other->deprecated_); std::swap(cc_enable_arenas_, other->cc_enable_arenas_); objc_class_prefix_.Swap(&other->objc_class_prefix_); + csharp_namespace_.Swap(&other->csharp_namespace_); + csharp_umbrella_classname_.Swap(&other->csharp_umbrella_classname_); + std::swap(csharp_public_classes_, other->csharp_public_classes_); + std::swap(csharp_multiple_files_, other->csharp_multiple_files_); + std::swap(csharp_nest_classes_, other->csharp_nest_classes_); + std::swap(csharp_code_contracts_, other->csharp_code_contracts_); + std::swap(csharp_expand_namespace_directories_, other->csharp_expand_namespace_directories_); + std::swap(csharp_cls_compliance_, other->csharp_cls_compliance_); + std::swap(csharp_add_serializable_, other->csharp_add_serializable_); + std::swap(csharp_generate_private_ctor_, other->csharp_generate_private_ctor_); + csharp_file_extension_.Swap(&other->csharp_file_extension_); + csharp_umbrella_namespace_.Swap(&other->csharp_umbrella_namespace_); + std::swap(csharp_generated_code_attributes_, other->csharp_generated_code_attributes_); uninterpreted_option_.UnsafeArenaSwap(&other->uninterpreted_option_); std::swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); @@ -8264,6 +8860,434 @@ void FileOptions::InternalSwap(FileOptions* other) { // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.objc_class_prefix) } +// optional string csharp_namespace = 37; + bool FileOptions::has_csharp_namespace() const { + return (_has_bits_[0] & 0x00002000u) != 0; +} + void FileOptions::set_has_csharp_namespace() { + _has_bits_[0] |= 0x00002000u; +} + void FileOptions::clear_has_csharp_namespace() { + _has_bits_[0] &= ~0x00002000u; +} + void FileOptions::clear_csharp_namespace() { + csharp_namespace_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_csharp_namespace(); +} + const ::std::string& FileOptions::csharp_namespace() const { + // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_namespace) + return csharp_namespace_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + void FileOptions::set_csharp_namespace(const ::std::string& value) { + set_has_csharp_namespace(); + csharp_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_namespace) +} + void FileOptions::set_csharp_namespace(const char* value) { + set_has_csharp_namespace(); + csharp_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.csharp_namespace) +} + void FileOptions::set_csharp_namespace(const char* value, size_t size) { + set_has_csharp_namespace(); + csharp_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.csharp_namespace) +} + ::std::string* FileOptions::mutable_csharp_namespace() { + set_has_csharp_namespace(); + // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.csharp_namespace) + return csharp_namespace_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + ::std::string* FileOptions::release_csharp_namespace() { + clear_has_csharp_namespace(); + return csharp_namespace_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + void FileOptions::set_allocated_csharp_namespace(::std::string* csharp_namespace) { + if (csharp_namespace != NULL) { + set_has_csharp_namespace(); + } else { + clear_has_csharp_namespace(); + } + csharp_namespace_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), csharp_namespace); + // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.csharp_namespace) +} + +// optional string csharp_umbrella_classname = 38; + bool FileOptions::has_csharp_umbrella_classname() const { + return (_has_bits_[0] & 0x00004000u) != 0; +} + void FileOptions::set_has_csharp_umbrella_classname() { + _has_bits_[0] |= 0x00004000u; +} + void FileOptions::clear_has_csharp_umbrella_classname() { + _has_bits_[0] &= ~0x00004000u; +} + void FileOptions::clear_csharp_umbrella_classname() { + csharp_umbrella_classname_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_csharp_umbrella_classname(); +} + const ::std::string& FileOptions::csharp_umbrella_classname() const { + // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_umbrella_classname) + return csharp_umbrella_classname_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + void FileOptions::set_csharp_umbrella_classname(const ::std::string& value) { + set_has_csharp_umbrella_classname(); + csharp_umbrella_classname_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_umbrella_classname) +} + void FileOptions::set_csharp_umbrella_classname(const char* value) { + set_has_csharp_umbrella_classname(); + csharp_umbrella_classname_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.csharp_umbrella_classname) +} + void FileOptions::set_csharp_umbrella_classname(const char* value, size_t size) { + set_has_csharp_umbrella_classname(); + csharp_umbrella_classname_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.csharp_umbrella_classname) +} + ::std::string* FileOptions::mutable_csharp_umbrella_classname() { + set_has_csharp_umbrella_classname(); + // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.csharp_umbrella_classname) + return csharp_umbrella_classname_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + ::std::string* FileOptions::release_csharp_umbrella_classname() { + clear_has_csharp_umbrella_classname(); + return csharp_umbrella_classname_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + void FileOptions::set_allocated_csharp_umbrella_classname(::std::string* csharp_umbrella_classname) { + if (csharp_umbrella_classname != NULL) { + set_has_csharp_umbrella_classname(); + } else { + clear_has_csharp_umbrella_classname(); + } + csharp_umbrella_classname_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), csharp_umbrella_classname); + // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.csharp_umbrella_classname) +} + +// optional bool csharp_public_classes = 39 [default = true]; + bool FileOptions::has_csharp_public_classes() const { + return (_has_bits_[0] & 0x00008000u) != 0; +} + void FileOptions::set_has_csharp_public_classes() { + _has_bits_[0] |= 0x00008000u; +} + void FileOptions::clear_has_csharp_public_classes() { + _has_bits_[0] &= ~0x00008000u; +} + void FileOptions::clear_csharp_public_classes() { + csharp_public_classes_ = true; + clear_has_csharp_public_classes(); +} + bool FileOptions::csharp_public_classes() const { + // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_public_classes) + return csharp_public_classes_; +} + void FileOptions::set_csharp_public_classes(bool value) { + set_has_csharp_public_classes(); + csharp_public_classes_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_public_classes) +} + +// optional bool csharp_multiple_files = 40; + bool FileOptions::has_csharp_multiple_files() const { + return (_has_bits_[0] & 0x00010000u) != 0; +} + void FileOptions::set_has_csharp_multiple_files() { + _has_bits_[0] |= 0x00010000u; +} + void FileOptions::clear_has_csharp_multiple_files() { + _has_bits_[0] &= ~0x00010000u; +} + void FileOptions::clear_csharp_multiple_files() { + csharp_multiple_files_ = false; + clear_has_csharp_multiple_files(); +} + bool FileOptions::csharp_multiple_files() const { + // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_multiple_files) + return csharp_multiple_files_; +} + void FileOptions::set_csharp_multiple_files(bool value) { + set_has_csharp_multiple_files(); + csharp_multiple_files_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_multiple_files) +} + +// optional bool csharp_nest_classes = 41; + bool FileOptions::has_csharp_nest_classes() const { + return (_has_bits_[0] & 0x00020000u) != 0; +} + void FileOptions::set_has_csharp_nest_classes() { + _has_bits_[0] |= 0x00020000u; +} + void FileOptions::clear_has_csharp_nest_classes() { + _has_bits_[0] &= ~0x00020000u; +} + void FileOptions::clear_csharp_nest_classes() { + csharp_nest_classes_ = false; + clear_has_csharp_nest_classes(); +} + bool FileOptions::csharp_nest_classes() const { + // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_nest_classes) + return csharp_nest_classes_; +} + void FileOptions::set_csharp_nest_classes(bool value) { + set_has_csharp_nest_classes(); + csharp_nest_classes_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_nest_classes) +} + +// optional bool csharp_code_contracts = 42; + bool FileOptions::has_csharp_code_contracts() const { + return (_has_bits_[0] & 0x00040000u) != 0; +} + void FileOptions::set_has_csharp_code_contracts() { + _has_bits_[0] |= 0x00040000u; +} + void FileOptions::clear_has_csharp_code_contracts() { + _has_bits_[0] &= ~0x00040000u; +} + void FileOptions::clear_csharp_code_contracts() { + csharp_code_contracts_ = false; + clear_has_csharp_code_contracts(); +} + bool FileOptions::csharp_code_contracts() const { + // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_code_contracts) + return csharp_code_contracts_; +} + void FileOptions::set_csharp_code_contracts(bool value) { + set_has_csharp_code_contracts(); + csharp_code_contracts_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_code_contracts) +} + +// optional bool csharp_expand_namespace_directories = 43; + bool FileOptions::has_csharp_expand_namespace_directories() const { + return (_has_bits_[0] & 0x00080000u) != 0; +} + void FileOptions::set_has_csharp_expand_namespace_directories() { + _has_bits_[0] |= 0x00080000u; +} + void FileOptions::clear_has_csharp_expand_namespace_directories() { + _has_bits_[0] &= ~0x00080000u; +} + void FileOptions::clear_csharp_expand_namespace_directories() { + csharp_expand_namespace_directories_ = false; + clear_has_csharp_expand_namespace_directories(); +} + bool FileOptions::csharp_expand_namespace_directories() const { + // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_expand_namespace_directories) + return csharp_expand_namespace_directories_; +} + void FileOptions::set_csharp_expand_namespace_directories(bool value) { + set_has_csharp_expand_namespace_directories(); + csharp_expand_namespace_directories_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_expand_namespace_directories) +} + +// optional bool csharp_cls_compliance = 44 [default = true]; + bool FileOptions::has_csharp_cls_compliance() const { + return (_has_bits_[0] & 0x00100000u) != 0; +} + void FileOptions::set_has_csharp_cls_compliance() { + _has_bits_[0] |= 0x00100000u; +} + void FileOptions::clear_has_csharp_cls_compliance() { + _has_bits_[0] &= ~0x00100000u; +} + void FileOptions::clear_csharp_cls_compliance() { + csharp_cls_compliance_ = true; + clear_has_csharp_cls_compliance(); +} + bool FileOptions::csharp_cls_compliance() const { + // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_cls_compliance) + return csharp_cls_compliance_; +} + void FileOptions::set_csharp_cls_compliance(bool value) { + set_has_csharp_cls_compliance(); + csharp_cls_compliance_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_cls_compliance) +} + +// optional bool csharp_add_serializable = 45 [default = false]; + bool FileOptions::has_csharp_add_serializable() const { + return (_has_bits_[0] & 0x00200000u) != 0; +} + void FileOptions::set_has_csharp_add_serializable() { + _has_bits_[0] |= 0x00200000u; +} + void FileOptions::clear_has_csharp_add_serializable() { + _has_bits_[0] &= ~0x00200000u; +} + void FileOptions::clear_csharp_add_serializable() { + csharp_add_serializable_ = false; + clear_has_csharp_add_serializable(); +} + bool FileOptions::csharp_add_serializable() const { + // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_add_serializable) + return csharp_add_serializable_; +} + void FileOptions::set_csharp_add_serializable(bool value) { + set_has_csharp_add_serializable(); + csharp_add_serializable_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_add_serializable) +} + +// optional bool csharp_generate_private_ctor = 46 [default = true]; + bool FileOptions::has_csharp_generate_private_ctor() const { + return (_has_bits_[0] & 0x00400000u) != 0; +} + void FileOptions::set_has_csharp_generate_private_ctor() { + _has_bits_[0] |= 0x00400000u; +} + void FileOptions::clear_has_csharp_generate_private_ctor() { + _has_bits_[0] &= ~0x00400000u; +} + void FileOptions::clear_csharp_generate_private_ctor() { + csharp_generate_private_ctor_ = true; + clear_has_csharp_generate_private_ctor(); +} + bool FileOptions::csharp_generate_private_ctor() const { + // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_generate_private_ctor) + return csharp_generate_private_ctor_; +} + void FileOptions::set_csharp_generate_private_ctor(bool value) { + set_has_csharp_generate_private_ctor(); + csharp_generate_private_ctor_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_generate_private_ctor) +} + +// optional string csharp_file_extension = 47 [default = ".cs"]; + bool FileOptions::has_csharp_file_extension() const { + return (_has_bits_[0] & 0x00800000u) != 0; +} + void FileOptions::set_has_csharp_file_extension() { + _has_bits_[0] |= 0x00800000u; +} + void FileOptions::clear_has_csharp_file_extension() { + _has_bits_[0] &= ~0x00800000u; +} + void FileOptions::clear_csharp_file_extension() { + csharp_file_extension_.ClearToDefaultNoArena(_default_csharp_file_extension_); + clear_has_csharp_file_extension(); +} + const ::std::string& FileOptions::csharp_file_extension() const { + // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_file_extension) + return csharp_file_extension_.GetNoArena(_default_csharp_file_extension_); +} + void FileOptions::set_csharp_file_extension(const ::std::string& value) { + set_has_csharp_file_extension(); + csharp_file_extension_.SetNoArena(_default_csharp_file_extension_, value); + // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_file_extension) +} + void FileOptions::set_csharp_file_extension(const char* value) { + set_has_csharp_file_extension(); + csharp_file_extension_.SetNoArena(_default_csharp_file_extension_, ::std::string(value)); + // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.csharp_file_extension) +} + void FileOptions::set_csharp_file_extension(const char* value, size_t size) { + set_has_csharp_file_extension(); + csharp_file_extension_.SetNoArena(_default_csharp_file_extension_, + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.csharp_file_extension) +} + ::std::string* FileOptions::mutable_csharp_file_extension() { + set_has_csharp_file_extension(); + // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.csharp_file_extension) + return csharp_file_extension_.MutableNoArena(_default_csharp_file_extension_); +} + ::std::string* FileOptions::release_csharp_file_extension() { + clear_has_csharp_file_extension(); + return csharp_file_extension_.ReleaseNoArena(_default_csharp_file_extension_); +} + void FileOptions::set_allocated_csharp_file_extension(::std::string* csharp_file_extension) { + if (csharp_file_extension != NULL) { + set_has_csharp_file_extension(); + } else { + clear_has_csharp_file_extension(); + } + csharp_file_extension_.SetAllocatedNoArena(_default_csharp_file_extension_, csharp_file_extension); + // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.csharp_file_extension) +} + +// optional string csharp_umbrella_namespace = 48; + bool FileOptions::has_csharp_umbrella_namespace() const { + return (_has_bits_[0] & 0x01000000u) != 0; +} + void FileOptions::set_has_csharp_umbrella_namespace() { + _has_bits_[0] |= 0x01000000u; +} + void FileOptions::clear_has_csharp_umbrella_namespace() { + _has_bits_[0] &= ~0x01000000u; +} + void FileOptions::clear_csharp_umbrella_namespace() { + csharp_umbrella_namespace_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_csharp_umbrella_namespace(); +} + const ::std::string& FileOptions::csharp_umbrella_namespace() const { + // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_umbrella_namespace) + return csharp_umbrella_namespace_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + void FileOptions::set_csharp_umbrella_namespace(const ::std::string& value) { + set_has_csharp_umbrella_namespace(); + csharp_umbrella_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_umbrella_namespace) +} + void FileOptions::set_csharp_umbrella_namespace(const char* value) { + set_has_csharp_umbrella_namespace(); + csharp_umbrella_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.csharp_umbrella_namespace) +} + void FileOptions::set_csharp_umbrella_namespace(const char* value, size_t size) { + set_has_csharp_umbrella_namespace(); + csharp_umbrella_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.csharp_umbrella_namespace) +} + ::std::string* FileOptions::mutable_csharp_umbrella_namespace() { + set_has_csharp_umbrella_namespace(); + // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.csharp_umbrella_namespace) + return csharp_umbrella_namespace_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + ::std::string* FileOptions::release_csharp_umbrella_namespace() { + clear_has_csharp_umbrella_namespace(); + return csharp_umbrella_namespace_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + void FileOptions::set_allocated_csharp_umbrella_namespace(::std::string* csharp_umbrella_namespace) { + if (csharp_umbrella_namespace != NULL) { + set_has_csharp_umbrella_namespace(); + } else { + clear_has_csharp_umbrella_namespace(); + } + csharp_umbrella_namespace_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), csharp_umbrella_namespace); + // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.csharp_umbrella_namespace) +} + +// optional bool csharp_generated_code_attributes = 49 [default = false]; + bool FileOptions::has_csharp_generated_code_attributes() const { + return (_has_bits_[0] & 0x02000000u) != 0; +} + void FileOptions::set_has_csharp_generated_code_attributes() { + _has_bits_[0] |= 0x02000000u; +} + void FileOptions::clear_has_csharp_generated_code_attributes() { + _has_bits_[0] &= ~0x02000000u; +} + void FileOptions::clear_csharp_generated_code_attributes() { + csharp_generated_code_attributes_ = false; + clear_has_csharp_generated_code_attributes(); +} + bool FileOptions::csharp_generated_code_attributes() const { + // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_generated_code_attributes) + return csharp_generated_code_attributes_; +} + void FileOptions::set_csharp_generated_code_attributes(bool value) { + set_has_csharp_generated_code_attributes(); + csharp_generated_code_attributes_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_generated_code_attributes) +} + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; int FileOptions::uninterpreted_option_size() const { return uninterpreted_option_.size(); diff --git a/src/google/protobuf/descriptor.pb.h b/src/google/protobuf/descriptor.pb.h index d8cba659..f51ab536 100644 --- a/src/google/protobuf/descriptor.pb.h +++ b/src/google/protobuf/descriptor.pb.h @@ -1837,6 +1837,117 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message { ::std::string* release_objc_class_prefix(); void set_allocated_objc_class_prefix(::std::string* objc_class_prefix); + // optional string csharp_namespace = 37; + bool has_csharp_namespace() const; + void clear_csharp_namespace(); + static const int kCsharpNamespaceFieldNumber = 37; + const ::std::string& csharp_namespace() const; + void set_csharp_namespace(const ::std::string& value); + void set_csharp_namespace(const char* value); + void set_csharp_namespace(const char* value, size_t size); + ::std::string* mutable_csharp_namespace(); + ::std::string* release_csharp_namespace(); + void set_allocated_csharp_namespace(::std::string* csharp_namespace); + + // optional string csharp_umbrella_classname = 38; + bool has_csharp_umbrella_classname() const; + void clear_csharp_umbrella_classname(); + static const int kCsharpUmbrellaClassnameFieldNumber = 38; + const ::std::string& csharp_umbrella_classname() const; + void set_csharp_umbrella_classname(const ::std::string& value); + void set_csharp_umbrella_classname(const char* value); + void set_csharp_umbrella_classname(const char* value, size_t size); + ::std::string* mutable_csharp_umbrella_classname(); + ::std::string* release_csharp_umbrella_classname(); + void set_allocated_csharp_umbrella_classname(::std::string* csharp_umbrella_classname); + + // optional bool csharp_public_classes = 39 [default = true]; + bool has_csharp_public_classes() const; + void clear_csharp_public_classes(); + static const int kCsharpPublicClassesFieldNumber = 39; + bool csharp_public_classes() const; + void set_csharp_public_classes(bool value); + + // optional bool csharp_multiple_files = 40; + bool has_csharp_multiple_files() const; + void clear_csharp_multiple_files(); + static const int kCsharpMultipleFilesFieldNumber = 40; + bool csharp_multiple_files() const; + void set_csharp_multiple_files(bool value); + + // optional bool csharp_nest_classes = 41; + bool has_csharp_nest_classes() const; + void clear_csharp_nest_classes(); + static const int kCsharpNestClassesFieldNumber = 41; + bool csharp_nest_classes() const; + void set_csharp_nest_classes(bool value); + + // optional bool csharp_code_contracts = 42; + bool has_csharp_code_contracts() const; + void clear_csharp_code_contracts(); + static const int kCsharpCodeContractsFieldNumber = 42; + bool csharp_code_contracts() const; + void set_csharp_code_contracts(bool value); + + // optional bool csharp_expand_namespace_directories = 43; + bool has_csharp_expand_namespace_directories() const; + void clear_csharp_expand_namespace_directories(); + static const int kCsharpExpandNamespaceDirectoriesFieldNumber = 43; + bool csharp_expand_namespace_directories() const; + void set_csharp_expand_namespace_directories(bool value); + + // optional bool csharp_cls_compliance = 44 [default = true]; + bool has_csharp_cls_compliance() const; + void clear_csharp_cls_compliance(); + static const int kCsharpClsComplianceFieldNumber = 44; + bool csharp_cls_compliance() const; + void set_csharp_cls_compliance(bool value); + + // optional bool csharp_add_serializable = 45 [default = false]; + bool has_csharp_add_serializable() const; + void clear_csharp_add_serializable(); + static const int kCsharpAddSerializableFieldNumber = 45; + bool csharp_add_serializable() const; + void set_csharp_add_serializable(bool value); + + // optional bool csharp_generate_private_ctor = 46 [default = true]; + bool has_csharp_generate_private_ctor() const; + void clear_csharp_generate_private_ctor(); + static const int kCsharpGeneratePrivateCtorFieldNumber = 46; + bool csharp_generate_private_ctor() const; + void set_csharp_generate_private_ctor(bool value); + + // optional string csharp_file_extension = 47 [default = ".cs"]; + bool has_csharp_file_extension() const; + void clear_csharp_file_extension(); + static const int kCsharpFileExtensionFieldNumber = 47; + const ::std::string& csharp_file_extension() const; + void set_csharp_file_extension(const ::std::string& value); + void set_csharp_file_extension(const char* value); + void set_csharp_file_extension(const char* value, size_t size); + ::std::string* mutable_csharp_file_extension(); + ::std::string* release_csharp_file_extension(); + void set_allocated_csharp_file_extension(::std::string* csharp_file_extension); + + // optional string csharp_umbrella_namespace = 48; + bool has_csharp_umbrella_namespace() const; + void clear_csharp_umbrella_namespace(); + static const int kCsharpUmbrellaNamespaceFieldNumber = 48; + const ::std::string& csharp_umbrella_namespace() const; + void set_csharp_umbrella_namespace(const ::std::string& value); + void set_csharp_umbrella_namespace(const char* value); + void set_csharp_umbrella_namespace(const char* value, size_t size); + ::std::string* mutable_csharp_umbrella_namespace(); + ::std::string* release_csharp_umbrella_namespace(); + void set_allocated_csharp_umbrella_namespace(::std::string* csharp_umbrella_namespace); + + // optional bool csharp_generated_code_attributes = 49 [default = false]; + bool has_csharp_generated_code_attributes() const; + void clear_csharp_generated_code_attributes(); + static const int kCsharpGeneratedCodeAttributesFieldNumber = 49; + bool csharp_generated_code_attributes() const; + void set_csharp_generated_code_attributes(bool value); + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; int uninterpreted_option_size() const; void clear_uninterpreted_option(); @@ -1878,6 +1989,32 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message { inline void clear_has_cc_enable_arenas(); inline void set_has_objc_class_prefix(); inline void clear_has_objc_class_prefix(); + inline void set_has_csharp_namespace(); + inline void clear_has_csharp_namespace(); + inline void set_has_csharp_umbrella_classname(); + inline void clear_has_csharp_umbrella_classname(); + inline void set_has_csharp_public_classes(); + inline void clear_has_csharp_public_classes(); + inline void set_has_csharp_multiple_files(); + inline void clear_has_csharp_multiple_files(); + inline void set_has_csharp_nest_classes(); + inline void clear_has_csharp_nest_classes(); + inline void set_has_csharp_code_contracts(); + inline void clear_has_csharp_code_contracts(); + inline void set_has_csharp_expand_namespace_directories(); + inline void clear_has_csharp_expand_namespace_directories(); + inline void set_has_csharp_cls_compliance(); + inline void clear_has_csharp_cls_compliance(); + inline void set_has_csharp_add_serializable(); + inline void clear_has_csharp_add_serializable(); + inline void set_has_csharp_generate_private_ctor(); + inline void clear_has_csharp_generate_private_ctor(); + inline void set_has_csharp_file_extension(); + inline void clear_has_csharp_file_extension(); + inline void set_has_csharp_umbrella_namespace(); + inline void clear_has_csharp_umbrella_namespace(); + inline void set_has_csharp_generated_code_attributes(); + inline void clear_has_csharp_generated_code_attributes(); ::google::protobuf::internal::ExtensionSet _extensions_; @@ -1893,11 +2030,25 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message { int optimize_for_; ::google::protobuf::internal::ArenaStringPtr go_package_; ::google::protobuf::internal::ArenaStringPtr objc_class_prefix_; - ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; + ::google::protobuf::internal::ArenaStringPtr csharp_namespace_; bool java_generic_services_; bool py_generic_services_; bool deprecated_; bool cc_enable_arenas_; + bool csharp_public_classes_; + bool csharp_multiple_files_; + bool csharp_nest_classes_; + bool csharp_code_contracts_; + ::google::protobuf::internal::ArenaStringPtr csharp_umbrella_classname_; + bool csharp_expand_namespace_directories_; + bool csharp_cls_compliance_; + bool csharp_add_serializable_; + bool csharp_generate_private_ctor_; + bool csharp_generated_code_attributes_; + static ::std::string* _default_csharp_file_extension_; + ::google::protobuf::internal::ArenaStringPtr csharp_file_extension_; + ::google::protobuf::internal::ArenaStringPtr csharp_umbrella_namespace_; + ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); @@ -5502,6 +5653,434 @@ inline void FileOptions::set_allocated_objc_class_prefix(::std::string* objc_cla // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.objc_class_prefix) } +// optional string csharp_namespace = 37; +inline bool FileOptions::has_csharp_namespace() const { + return (_has_bits_[0] & 0x00002000u) != 0; +} +inline void FileOptions::set_has_csharp_namespace() { + _has_bits_[0] |= 0x00002000u; +} +inline void FileOptions::clear_has_csharp_namespace() { + _has_bits_[0] &= ~0x00002000u; +} +inline void FileOptions::clear_csharp_namespace() { + csharp_namespace_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_csharp_namespace(); +} +inline const ::std::string& FileOptions::csharp_namespace() const { + // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_namespace) + return csharp_namespace_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline void FileOptions::set_csharp_namespace(const ::std::string& value) { + set_has_csharp_namespace(); + csharp_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_namespace) +} +inline void FileOptions::set_csharp_namespace(const char* value) { + set_has_csharp_namespace(); + csharp_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.csharp_namespace) +} +inline void FileOptions::set_csharp_namespace(const char* value, size_t size) { + set_has_csharp_namespace(); + csharp_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.csharp_namespace) +} +inline ::std::string* FileOptions::mutable_csharp_namespace() { + set_has_csharp_namespace(); + // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.csharp_namespace) + return csharp_namespace_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline ::std::string* FileOptions::release_csharp_namespace() { + clear_has_csharp_namespace(); + return csharp_namespace_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline void FileOptions::set_allocated_csharp_namespace(::std::string* csharp_namespace) { + if (csharp_namespace != NULL) { + set_has_csharp_namespace(); + } else { + clear_has_csharp_namespace(); + } + csharp_namespace_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), csharp_namespace); + // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.csharp_namespace) +} + +// optional string csharp_umbrella_classname = 38; +inline bool FileOptions::has_csharp_umbrella_classname() const { + return (_has_bits_[0] & 0x00004000u) != 0; +} +inline void FileOptions::set_has_csharp_umbrella_classname() { + _has_bits_[0] |= 0x00004000u; +} +inline void FileOptions::clear_has_csharp_umbrella_classname() { + _has_bits_[0] &= ~0x00004000u; +} +inline void FileOptions::clear_csharp_umbrella_classname() { + csharp_umbrella_classname_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_csharp_umbrella_classname(); +} +inline const ::std::string& FileOptions::csharp_umbrella_classname() const { + // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_umbrella_classname) + return csharp_umbrella_classname_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline void FileOptions::set_csharp_umbrella_classname(const ::std::string& value) { + set_has_csharp_umbrella_classname(); + csharp_umbrella_classname_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_umbrella_classname) +} +inline void FileOptions::set_csharp_umbrella_classname(const char* value) { + set_has_csharp_umbrella_classname(); + csharp_umbrella_classname_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.csharp_umbrella_classname) +} +inline void FileOptions::set_csharp_umbrella_classname(const char* value, size_t size) { + set_has_csharp_umbrella_classname(); + csharp_umbrella_classname_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.csharp_umbrella_classname) +} +inline ::std::string* FileOptions::mutable_csharp_umbrella_classname() { + set_has_csharp_umbrella_classname(); + // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.csharp_umbrella_classname) + return csharp_umbrella_classname_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline ::std::string* FileOptions::release_csharp_umbrella_classname() { + clear_has_csharp_umbrella_classname(); + return csharp_umbrella_classname_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline void FileOptions::set_allocated_csharp_umbrella_classname(::std::string* csharp_umbrella_classname) { + if (csharp_umbrella_classname != NULL) { + set_has_csharp_umbrella_classname(); + } else { + clear_has_csharp_umbrella_classname(); + } + csharp_umbrella_classname_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), csharp_umbrella_classname); + // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.csharp_umbrella_classname) +} + +// optional bool csharp_public_classes = 39 [default = true]; +inline bool FileOptions::has_csharp_public_classes() const { + return (_has_bits_[0] & 0x00008000u) != 0; +} +inline void FileOptions::set_has_csharp_public_classes() { + _has_bits_[0] |= 0x00008000u; +} +inline void FileOptions::clear_has_csharp_public_classes() { + _has_bits_[0] &= ~0x00008000u; +} +inline void FileOptions::clear_csharp_public_classes() { + csharp_public_classes_ = true; + clear_has_csharp_public_classes(); +} +inline bool FileOptions::csharp_public_classes() const { + // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_public_classes) + return csharp_public_classes_; +} +inline void FileOptions::set_csharp_public_classes(bool value) { + set_has_csharp_public_classes(); + csharp_public_classes_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_public_classes) +} + +// optional bool csharp_multiple_files = 40; +inline bool FileOptions::has_csharp_multiple_files() const { + return (_has_bits_[0] & 0x00010000u) != 0; +} +inline void FileOptions::set_has_csharp_multiple_files() { + _has_bits_[0] |= 0x00010000u; +} +inline void FileOptions::clear_has_csharp_multiple_files() { + _has_bits_[0] &= ~0x00010000u; +} +inline void FileOptions::clear_csharp_multiple_files() { + csharp_multiple_files_ = false; + clear_has_csharp_multiple_files(); +} +inline bool FileOptions::csharp_multiple_files() const { + // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_multiple_files) + return csharp_multiple_files_; +} +inline void FileOptions::set_csharp_multiple_files(bool value) { + set_has_csharp_multiple_files(); + csharp_multiple_files_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_multiple_files) +} + +// optional bool csharp_nest_classes = 41; +inline bool FileOptions::has_csharp_nest_classes() const { + return (_has_bits_[0] & 0x00020000u) != 0; +} +inline void FileOptions::set_has_csharp_nest_classes() { + _has_bits_[0] |= 0x00020000u; +} +inline void FileOptions::clear_has_csharp_nest_classes() { + _has_bits_[0] &= ~0x00020000u; +} +inline void FileOptions::clear_csharp_nest_classes() { + csharp_nest_classes_ = false; + clear_has_csharp_nest_classes(); +} +inline bool FileOptions::csharp_nest_classes() const { + // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_nest_classes) + return csharp_nest_classes_; +} +inline void FileOptions::set_csharp_nest_classes(bool value) { + set_has_csharp_nest_classes(); + csharp_nest_classes_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_nest_classes) +} + +// optional bool csharp_code_contracts = 42; +inline bool FileOptions::has_csharp_code_contracts() const { + return (_has_bits_[0] & 0x00040000u) != 0; +} +inline void FileOptions::set_has_csharp_code_contracts() { + _has_bits_[0] |= 0x00040000u; +} +inline void FileOptions::clear_has_csharp_code_contracts() { + _has_bits_[0] &= ~0x00040000u; +} +inline void FileOptions::clear_csharp_code_contracts() { + csharp_code_contracts_ = false; + clear_has_csharp_code_contracts(); +} +inline bool FileOptions::csharp_code_contracts() const { + // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_code_contracts) + return csharp_code_contracts_; +} +inline void FileOptions::set_csharp_code_contracts(bool value) { + set_has_csharp_code_contracts(); + csharp_code_contracts_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_code_contracts) +} + +// optional bool csharp_expand_namespace_directories = 43; +inline bool FileOptions::has_csharp_expand_namespace_directories() const { + return (_has_bits_[0] & 0x00080000u) != 0; +} +inline void FileOptions::set_has_csharp_expand_namespace_directories() { + _has_bits_[0] |= 0x00080000u; +} +inline void FileOptions::clear_has_csharp_expand_namespace_directories() { + _has_bits_[0] &= ~0x00080000u; +} +inline void FileOptions::clear_csharp_expand_namespace_directories() { + csharp_expand_namespace_directories_ = false; + clear_has_csharp_expand_namespace_directories(); +} +inline bool FileOptions::csharp_expand_namespace_directories() const { + // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_expand_namespace_directories) + return csharp_expand_namespace_directories_; +} +inline void FileOptions::set_csharp_expand_namespace_directories(bool value) { + set_has_csharp_expand_namespace_directories(); + csharp_expand_namespace_directories_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_expand_namespace_directories) +} + +// optional bool csharp_cls_compliance = 44 [default = true]; +inline bool FileOptions::has_csharp_cls_compliance() const { + return (_has_bits_[0] & 0x00100000u) != 0; +} +inline void FileOptions::set_has_csharp_cls_compliance() { + _has_bits_[0] |= 0x00100000u; +} +inline void FileOptions::clear_has_csharp_cls_compliance() { + _has_bits_[0] &= ~0x00100000u; +} +inline void FileOptions::clear_csharp_cls_compliance() { + csharp_cls_compliance_ = true; + clear_has_csharp_cls_compliance(); +} +inline bool FileOptions::csharp_cls_compliance() const { + // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_cls_compliance) + return csharp_cls_compliance_; +} +inline void FileOptions::set_csharp_cls_compliance(bool value) { + set_has_csharp_cls_compliance(); + csharp_cls_compliance_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_cls_compliance) +} + +// optional bool csharp_add_serializable = 45 [default = false]; +inline bool FileOptions::has_csharp_add_serializable() const { + return (_has_bits_[0] & 0x00200000u) != 0; +} +inline void FileOptions::set_has_csharp_add_serializable() { + _has_bits_[0] |= 0x00200000u; +} +inline void FileOptions::clear_has_csharp_add_serializable() { + _has_bits_[0] &= ~0x00200000u; +} +inline void FileOptions::clear_csharp_add_serializable() { + csharp_add_serializable_ = false; + clear_has_csharp_add_serializable(); +} +inline bool FileOptions::csharp_add_serializable() const { + // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_add_serializable) + return csharp_add_serializable_; +} +inline void FileOptions::set_csharp_add_serializable(bool value) { + set_has_csharp_add_serializable(); + csharp_add_serializable_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_add_serializable) +} + +// optional bool csharp_generate_private_ctor = 46 [default = true]; +inline bool FileOptions::has_csharp_generate_private_ctor() const { + return (_has_bits_[0] & 0x00400000u) != 0; +} +inline void FileOptions::set_has_csharp_generate_private_ctor() { + _has_bits_[0] |= 0x00400000u; +} +inline void FileOptions::clear_has_csharp_generate_private_ctor() { + _has_bits_[0] &= ~0x00400000u; +} +inline void FileOptions::clear_csharp_generate_private_ctor() { + csharp_generate_private_ctor_ = true; + clear_has_csharp_generate_private_ctor(); +} +inline bool FileOptions::csharp_generate_private_ctor() const { + // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_generate_private_ctor) + return csharp_generate_private_ctor_; +} +inline void FileOptions::set_csharp_generate_private_ctor(bool value) { + set_has_csharp_generate_private_ctor(); + csharp_generate_private_ctor_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_generate_private_ctor) +} + +// optional string csharp_file_extension = 47 [default = ".cs"]; +inline bool FileOptions::has_csharp_file_extension() const { + return (_has_bits_[0] & 0x00800000u) != 0; +} +inline void FileOptions::set_has_csharp_file_extension() { + _has_bits_[0] |= 0x00800000u; +} +inline void FileOptions::clear_has_csharp_file_extension() { + _has_bits_[0] &= ~0x00800000u; +} +inline void FileOptions::clear_csharp_file_extension() { + csharp_file_extension_.ClearToDefaultNoArena(_default_csharp_file_extension_); + clear_has_csharp_file_extension(); +} +inline const ::std::string& FileOptions::csharp_file_extension() const { + // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_file_extension) + return csharp_file_extension_.GetNoArena(_default_csharp_file_extension_); +} +inline void FileOptions::set_csharp_file_extension(const ::std::string& value) { + set_has_csharp_file_extension(); + csharp_file_extension_.SetNoArena(_default_csharp_file_extension_, value); + // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_file_extension) +} +inline void FileOptions::set_csharp_file_extension(const char* value) { + set_has_csharp_file_extension(); + csharp_file_extension_.SetNoArena(_default_csharp_file_extension_, ::std::string(value)); + // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.csharp_file_extension) +} +inline void FileOptions::set_csharp_file_extension(const char* value, size_t size) { + set_has_csharp_file_extension(); + csharp_file_extension_.SetNoArena(_default_csharp_file_extension_, + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.csharp_file_extension) +} +inline ::std::string* FileOptions::mutable_csharp_file_extension() { + set_has_csharp_file_extension(); + // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.csharp_file_extension) + return csharp_file_extension_.MutableNoArena(_default_csharp_file_extension_); +} +inline ::std::string* FileOptions::release_csharp_file_extension() { + clear_has_csharp_file_extension(); + return csharp_file_extension_.ReleaseNoArena(_default_csharp_file_extension_); +} +inline void FileOptions::set_allocated_csharp_file_extension(::std::string* csharp_file_extension) { + if (csharp_file_extension != NULL) { + set_has_csharp_file_extension(); + } else { + clear_has_csharp_file_extension(); + } + csharp_file_extension_.SetAllocatedNoArena(_default_csharp_file_extension_, csharp_file_extension); + // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.csharp_file_extension) +} + +// optional string csharp_umbrella_namespace = 48; +inline bool FileOptions::has_csharp_umbrella_namespace() const { + return (_has_bits_[0] & 0x01000000u) != 0; +} +inline void FileOptions::set_has_csharp_umbrella_namespace() { + _has_bits_[0] |= 0x01000000u; +} +inline void FileOptions::clear_has_csharp_umbrella_namespace() { + _has_bits_[0] &= ~0x01000000u; +} +inline void FileOptions::clear_csharp_umbrella_namespace() { + csharp_umbrella_namespace_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_csharp_umbrella_namespace(); +} +inline const ::std::string& FileOptions::csharp_umbrella_namespace() const { + // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_umbrella_namespace) + return csharp_umbrella_namespace_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline void FileOptions::set_csharp_umbrella_namespace(const ::std::string& value) { + set_has_csharp_umbrella_namespace(); + csharp_umbrella_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_umbrella_namespace) +} +inline void FileOptions::set_csharp_umbrella_namespace(const char* value) { + set_has_csharp_umbrella_namespace(); + csharp_umbrella_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.csharp_umbrella_namespace) +} +inline void FileOptions::set_csharp_umbrella_namespace(const char* value, size_t size) { + set_has_csharp_umbrella_namespace(); + csharp_umbrella_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.csharp_umbrella_namespace) +} +inline ::std::string* FileOptions::mutable_csharp_umbrella_namespace() { + set_has_csharp_umbrella_namespace(); + // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.csharp_umbrella_namespace) + return csharp_umbrella_namespace_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline ::std::string* FileOptions::release_csharp_umbrella_namespace() { + clear_has_csharp_umbrella_namespace(); + return csharp_umbrella_namespace_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline void FileOptions::set_allocated_csharp_umbrella_namespace(::std::string* csharp_umbrella_namespace) { + if (csharp_umbrella_namespace != NULL) { + set_has_csharp_umbrella_namespace(); + } else { + clear_has_csharp_umbrella_namespace(); + } + csharp_umbrella_namespace_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), csharp_umbrella_namespace); + // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.csharp_umbrella_namespace) +} + +// optional bool csharp_generated_code_attributes = 49 [default = false]; +inline bool FileOptions::has_csharp_generated_code_attributes() const { + return (_has_bits_[0] & 0x02000000u) != 0; +} +inline void FileOptions::set_has_csharp_generated_code_attributes() { + _has_bits_[0] |= 0x02000000u; +} +inline void FileOptions::clear_has_csharp_generated_code_attributes() { + _has_bits_[0] &= ~0x02000000u; +} +inline void FileOptions::clear_csharp_generated_code_attributes() { + csharp_generated_code_attributes_ = false; + clear_has_csharp_generated_code_attributes(); +} +inline bool FileOptions::csharp_generated_code_attributes() const { + // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_generated_code_attributes) + return csharp_generated_code_attributes_; +} +inline void FileOptions::set_csharp_generated_code_attributes(bool value) { + set_has_csharp_generated_code_attributes(); + csharp_generated_code_attributes_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_generated_code_attributes) +} + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; inline int FileOptions::uninterpreted_option_size() const { return uninterpreted_option_.size(); diff --git a/src/google/protobuf/descriptor.proto b/src/google/protobuf/descriptor.proto index 367b16e5..d3f7fae9 100644 --- a/src/google/protobuf/descriptor.proto +++ b/src/google/protobuf/descriptor.proto @@ -351,6 +351,58 @@ message FileOptions { // generated classes from this .proto. There is no default. optional string objc_class_prefix = 36; + // Namespace for generated classes; defaults to the package. + optional string csharp_namespace = 37; + + // Name of the "umbrella" class used for metadata about all + // the messages within this file. Default is based on the name + // of the file. + optional string csharp_umbrella_classname = 38; + + // Whether classes should be public (true) or internal (false) + optional bool csharp_public_classes = 39 [default = true]; + + // Whether to generate a single file for everything within the + // .proto file (false), or one file per message (true). + // This option is not currently honored; please log a feature + // request if you really want it. + optional bool csharp_multiple_files = 40; + + // Whether to nest messages within a single umbrella class (true) + // or create the umbrella class as a peer, with messages as + // top-level classes in the namespace (false) + optional bool csharp_nest_classes = 41; + + // Generate appropriate support for Code Contracts + // (Ongoing; support should improve over time) + optional bool csharp_code_contracts = 42; + + // Create subdirectories for namespaces, e.g. namespace "Foo.Bar" + // would generate files within [output directory]/Foo/Bar + optional bool csharp_expand_namespace_directories = 43; + + // Generate attributes indicating non-CLS-compliance + optional bool csharp_cls_compliance = 44 [default = true]; + + // Generate messages/builders with the [Serializable] attribute + optional bool csharp_add_serializable = 45 [default = false]; + + // Generates a private ctor for Message types + optional bool csharp_generate_private_ctor = 46 [default = true]; + + // The extension that should be appended to the umbrella_classname when creating files. + optional string csharp_file_extension = 47 [default = ".cs"]; + + // A nested namespace for the umbrella class. Helpful for name collisions caused by + // umbrella_classname conflicting with an existing type. This will be automatically + // set to 'Proto' if a collision is detected with types being generated. This value + // is ignored when nest_classes == true + optional string csharp_umbrella_namespace = 48; + + // Used to add the System.Runtime.CompilerServices.CompilerGeneratedAttribute and + // System.CodeDom.Compiler.GeneratedCodeAttribute attributes to generated code. + optional bool csharp_generated_code_attributes = 49 [default = false]; + // The parser stores options it doesn't recognize here. See above. repeated UninterpretedOption uninterpreted_option = 999; -- cgit v1.2.3 From b52cf04b3c4237bc8d2eee865d5a8f981a30d6bd Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 13 Apr 2015 10:59:24 -0700 Subject: restricted number of csharp options and regenerated descriptor.proto --- src/google/protobuf/descriptor.pb.cc | 1021 ++++++---------------------------- src/google/protobuf/descriptor.pb.h | 521 +++-------------- src/google/protobuf/descriptor.proto | 49 +- 3 files changed, 243 insertions(+), 1348 deletions(-) (limited to 'src') diff --git a/src/google/protobuf/descriptor.pb.cc b/src/google/protobuf/descriptor.pb.cc index 3a67e5e0..477fe1b7 100644 --- a/src/google/protobuf/descriptor.pb.cc +++ b/src/google/protobuf/descriptor.pb.cc @@ -289,7 +289,7 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, _internal_metadata_), -1); FileOptions_descriptor_ = file->message_type(9); - static const int FileOptions_offsets_[27] = { + static const int FileOptions_offsets_[16] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_package_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_outer_classname_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_multiple_files_), @@ -304,18 +304,7 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, cc_enable_arenas_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, objc_class_prefix_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, csharp_namespace_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, csharp_umbrella_classname_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, csharp_public_classes_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, csharp_multiple_files_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, csharp_nest_classes_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, csharp_code_contracts_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, csharp_expand_namespace_directories_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, csharp_cls_compliance_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, csharp_add_serializable_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, csharp_generate_private_ctor_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, csharp_file_extension_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, csharp_umbrella_namespace_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, csharp_generated_code_attributes_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, uninterpreted_option_), }; FileOptions_reflection_ = @@ -350,12 +339,13 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, _internal_metadata_), -1); FieldOptions_descriptor_ = file->message_type(11); - static const int FieldOptions_offsets_[6] = { + static const int FieldOptions_offsets_[7] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, ctype_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, packed_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, lazy_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, deprecated_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, weak_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, csharp_property_name_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, uninterpreted_option_), }; FieldOptions_reflection_ = @@ -587,7 +577,6 @@ void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto() { delete MethodDescriptorProto_reflection_; delete FileOptions::default_instance_; delete FileOptions_reflection_; - delete FileOptions::_default_csharp_file_extension_; delete MessageOptions::default_instance_; delete MessageOptions_reflection_; delete FieldOptions::default_instance_; @@ -677,7 +666,7 @@ void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto() { "t_type\030\003 \001(\t\022/\n\007options\030\004 \001(\0132\036.google.p" "rotobuf.MethodOptions\022\037\n\020client_streamin" "g\030\005 \001(\010:\005false\022\037\n\020server_streaming\030\006 \001(\010" - ":\005false\"\302\010\n\013FileOptions\022\024\n\014java_package\030" + ":\005false\"\244\005\n\013FileOptions\022\024\n\014java_package\030" "\001 \001(\t\022\034\n\024java_outer_classname\030\010 \001(\t\022\"\n\023j" "ava_multiple_files\030\n \001(\010:\005false\022,\n\035java_" "generate_equals_and_hash\030\024 \001(\010:\005false\022%\n" @@ -690,61 +679,51 @@ void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto() { "\n\ndeprecated\030\027 \001(\010:\005false\022\037\n\020cc_enable_a" "renas\030\037 \001(\010:\005false\022\031\n\021objc_class_prefix\030" "$ \001(\t\022\030\n\020csharp_namespace\030% \001(\t\022!\n\031cshar" - "p_umbrella_classname\030& \001(\t\022#\n\025csharp_pub" - "lic_classes\030\' \001(\010:\004true\022\035\n\025csharp_multip" - "le_files\030( \001(\010\022\033\n\023csharp_nest_classes\030) " - "\001(\010\022\035\n\025csharp_code_contracts\030* \001(\010\022+\n#cs" - "harp_expand_namespace_directories\030+ \001(\010\022" - "#\n\025csharp_cls_compliance\030, \001(\010:\004true\022&\n\027" - "csharp_add_serializable\030- \001(\010:\005false\022*\n\034" - "csharp_generate_private_ctor\030. \001(\010:\004true" - "\022\"\n\025csharp_file_extension\030/ \001(\t:\003.cs\022!\n\031" - "csharp_umbrella_namespace\0300 \001(\t\022/\n cshar" - "p_generated_code_attributes\0301 \001(\010:\005false" - "\022C\n\024uninterpreted_option\030\347\007 \003(\0132$.google" - ".protobuf.UninterpretedOption\":\n\014Optimiz" - "eMode\022\t\n\005SPEED\020\001\022\r\n\tCODE_SIZE\020\002\022\020\n\014LITE_" - "RUNTIME\020\003*\t\010\350\007\020\200\200\200\200\002\"\346\001\n\016MessageOptions\022" - "&\n\027message_set_wire_format\030\001 \001(\010:\005false\022" - ".\n\037no_standard_descriptor_accessor\030\002 \001(\010" - ":\005false\022\031\n\ndeprecated\030\003 \001(\010:\005false\022\021\n\tma" - "p_entry\030\007 \001(\010\022C\n\024uninterpreted_option\030\347\007" - " \003(\0132$.google.protobuf.UninterpretedOpti" - "on*\t\010\350\007\020\200\200\200\200\002\"\240\002\n\014FieldOptions\022:\n\005ctype\030" - "\001 \001(\0162#.google.protobuf.FieldOptions.CTy" - "pe:\006STRING\022\016\n\006packed\030\002 \001(\010\022\023\n\004lazy\030\005 \001(\010" - ":\005false\022\031\n\ndeprecated\030\003 \001(\010:\005false\022\023\n\004we" - "ak\030\n \001(\010:\005false\022C\n\024uninterpreted_option\030" - "\347\007 \003(\0132$.google.protobuf.UninterpretedOp" - "tion\"/\n\005CType\022\n\n\006STRING\020\000\022\010\n\004CORD\020\001\022\020\n\014S" - "TRING_PIECE\020\002*\t\010\350\007\020\200\200\200\200\002\"\215\001\n\013EnumOptions" - "\022\023\n\013allow_alias\030\002 \001(\010\022\031\n\ndeprecated\030\003 \001(" - "\010:\005false\022C\n\024uninterpreted_option\030\347\007 \003(\0132" - "$.google.protobuf.UninterpretedOption*\t\010" - "\350\007\020\200\200\200\200\002\"}\n\020EnumValueOptions\022\031\n\ndeprecat" - "ed\030\001 \001(\010:\005false\022C\n\024uninterpreted_option\030" - "\347\007 \003(\0132$.google.protobuf.UninterpretedOp" - "tion*\t\010\350\007\020\200\200\200\200\002\"{\n\016ServiceOptions\022\031\n\ndep" - "recated\030! \001(\010:\005false\022C\n\024uninterpreted_op" - "tion\030\347\007 \003(\0132$.google.protobuf.Uninterpre" - "tedOption*\t\010\350\007\020\200\200\200\200\002\"z\n\rMethodOptions\022\031\n" - "\ndeprecated\030! \001(\010:\005false\022C\n\024uninterprete" + "p_umbrella_namespace\0300 \001(\t\022C\n\024uninterpre" + "ted_option\030\347\007 \003(\0132$.google.protobuf.Unin" + "terpretedOption\":\n\014OptimizeMode\022\t\n\005SPEED" + "\020\001\022\r\n\tCODE_SIZE\020\002\022\020\n\014LITE_RUNTIME\020\003*\t\010\350\007" + "\020\200\200\200\200\002\"\346\001\n\016MessageOptions\022&\n\027message_set" + "_wire_format\030\001 \001(\010:\005false\022.\n\037no_standard" + "_descriptor_accessor\030\002 \001(\010:\005false\022\031\n\ndep" + "recated\030\003 \001(\010:\005false\022\021\n\tmap_entry\030\007 \001(\010\022" + "C\n\024uninterpreted_option\030\347\007 \003(\0132$.google." + "protobuf.UninterpretedOption*\t\010\350\007\020\200\200\200\200\002\"" + "\276\002\n\014FieldOptions\022:\n\005ctype\030\001 \001(\0162#.google" + ".protobuf.FieldOptions.CType:\006STRING\022\016\n\006" + "packed\030\002 \001(\010\022\023\n\004lazy\030\005 \001(\010:\005false\022\031\n\ndep" + "recated\030\003 \001(\010:\005false\022\023\n\004weak\030\n \001(\010:\005fals" + "e\022\034\n\024csharp_property_name\030\013 \001(\t\022C\n\024unint" + "erpreted_option\030\347\007 \003(\0132$.google.protobuf" + ".UninterpretedOption\"/\n\005CType\022\n\n\006STRING\020" + "\000\022\010\n\004CORD\020\001\022\020\n\014STRING_PIECE\020\002*\t\010\350\007\020\200\200\200\200\002" + "\"\215\001\n\013EnumOptions\022\023\n\013allow_alias\030\002 \001(\010\022\031\n" + "\ndeprecated\030\003 \001(\010:\005false\022C\n\024uninterprete" "d_option\030\347\007 \003(\0132$.google.protobuf.Uninte" - "rpretedOption*\t\010\350\007\020\200\200\200\200\002\"\236\002\n\023Uninterpret" - "edOption\022;\n\004name\030\002 \003(\0132-.google.protobuf" - ".UninterpretedOption.NamePart\022\030\n\020identif" - "ier_value\030\003 \001(\t\022\032\n\022positive_int_value\030\004 " - "\001(\004\022\032\n\022negative_int_value\030\005 \001(\003\022\024\n\014doubl" - "e_value\030\006 \001(\001\022\024\n\014string_value\030\007 \001(\014\022\027\n\017a" - "ggregate_value\030\010 \001(\t\0323\n\010NamePart\022\021\n\tname" - "_part\030\001 \002(\t\022\024\n\014is_extension\030\002 \002(\010\"\325\001\n\016So" - "urceCodeInfo\022:\n\010location\030\001 \003(\0132(.google." - "protobuf.SourceCodeInfo.Location\032\206\001\n\010Loc" - "ation\022\020\n\004path\030\001 \003(\005B\002\020\001\022\020\n\004span\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_detached_comme" - "nts\030\006 \003(\tB)\n\023com.google.protobufB\020Descri" - "ptorProtosH\001", 5092); + "rpretedOption*\t\010\350\007\020\200\200\200\200\002\"}\n\020EnumValueOpt" + "ions\022\031\n\ndeprecated\030\001 \001(\010:\005false\022C\n\024unint" + "erpreted_option\030\347\007 \003(\0132$.google.protobuf" + ".UninterpretedOption*\t\010\350\007\020\200\200\200\200\002\"{\n\016Servi" + "ceOptions\022\031\n\ndeprecated\030! \001(\010:\005false\022C\n\024" + "uninterpreted_option\030\347\007 \003(\0132$.google.pro" + "tobuf.UninterpretedOption*\t\010\350\007\020\200\200\200\200\002\"z\n\r" + "MethodOptions\022\031\n\ndeprecated\030! \001(\010:\005false" + "\022C\n\024uninterpreted_option\030\347\007 \003(\0132$.google" + ".protobuf.UninterpretedOption*\t\010\350\007\020\200\200\200\200\002" + "\"\236\002\n\023UninterpretedOption\022;\n\004name\030\002 \003(\0132-" + ".google.protobuf.UninterpretedOption.Nam" + "ePart\022\030\n\020identifier_value\030\003 \001(\t\022\032\n\022posit" + "ive_int_value\030\004 \001(\004\022\032\n\022negative_int_valu" + "e\030\005 \001(\003\022\024\n\014double_value\030\006 \001(\001\022\024\n\014string_" + "value\030\007 \001(\014\022\027\n\017aggregate_value\030\010 \001(\t\0323\n\010" + "NamePart\022\021\n\tname_part\030\001 \002(\t\022\024\n\014is_extens" + "ion\030\002 \002(\010\"\325\001\n\016SourceCodeInfo\022:\n\010location" + "\030\001 \003(\0132(.google.protobuf.SourceCodeInfo." + "Location\032\206\001\n\010Location\022\020\n\004path\030\001 \003(\005B\002\020\001\022" + "\020\n\004span\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\031leadin" + "g_detached_comments\030\006 \003(\tB)\n\023com.google." + "protobufB\020DescriptorProtosH\001", 4708); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/descriptor.proto", &protobuf_RegisterTypes); FileDescriptorSet::default_instance_ = new FileDescriptorSet(); @@ -757,8 +736,6 @@ void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto() { EnumValueDescriptorProto::default_instance_ = new EnumValueDescriptorProto(); ServiceDescriptorProto::default_instance_ = new ServiceDescriptorProto(); MethodDescriptorProto::default_instance_ = new MethodDescriptorProto(); - FileOptions::_default_csharp_file_extension_ = - new ::std::string(".cs", 3); FileOptions::default_instance_ = new FileOptions(); MessageOptions::default_instance_ = new MessageOptions(); FieldOptions::default_instance_ = new FieldOptions(); @@ -7030,7 +7007,6 @@ const FileOptions_OptimizeMode FileOptions::OptimizeMode_MIN; const FileOptions_OptimizeMode FileOptions::OptimizeMode_MAX; const int FileOptions::OptimizeMode_ARRAYSIZE; #endif // _MSC_VER -::std::string* FileOptions::_default_csharp_file_extension_ = NULL; #ifndef _MSC_VER const int FileOptions::kJavaPackageFieldNumber; const int FileOptions::kJavaOuterClassnameFieldNumber; @@ -7046,18 +7022,7 @@ const int FileOptions::kDeprecatedFieldNumber; const int FileOptions::kCcEnableArenasFieldNumber; const int FileOptions::kObjcClassPrefixFieldNumber; const int FileOptions::kCsharpNamespaceFieldNumber; -const int FileOptions::kCsharpUmbrellaClassnameFieldNumber; -const int FileOptions::kCsharpPublicClassesFieldNumber; -const int FileOptions::kCsharpMultipleFilesFieldNumber; -const int FileOptions::kCsharpNestClassesFieldNumber; -const int FileOptions::kCsharpCodeContractsFieldNumber; -const int FileOptions::kCsharpExpandNamespaceDirectoriesFieldNumber; -const int FileOptions::kCsharpClsComplianceFieldNumber; -const int FileOptions::kCsharpAddSerializableFieldNumber; -const int FileOptions::kCsharpGeneratePrivateCtorFieldNumber; -const int FileOptions::kCsharpFileExtensionFieldNumber; const int FileOptions::kCsharpUmbrellaNamespaceFieldNumber; -const int FileOptions::kCsharpGeneratedCodeAttributesFieldNumber; const int FileOptions::kUninterpretedOptionFieldNumber; #endif // !_MSC_VER @@ -7095,18 +7060,7 @@ void FileOptions::SharedCtor() { cc_enable_arenas_ = false; objc_class_prefix_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); csharp_namespace_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - csharp_umbrella_classname_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - csharp_public_classes_ = true; - csharp_multiple_files_ = false; - csharp_nest_classes_ = false; - csharp_code_contracts_ = false; - csharp_expand_namespace_directories_ = false; - csharp_cls_compliance_ = true; - csharp_add_serializable_ = false; - csharp_generate_private_ctor_ = true; - csharp_file_extension_.UnsafeSetDefault(_default_csharp_file_extension_); csharp_umbrella_namespace_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - csharp_generated_code_attributes_ = false; ::memset(_has_bits_, 0, sizeof(_has_bits_)); } @@ -7121,8 +7075,6 @@ void FileOptions::SharedDtor() { go_package_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); objc_class_prefix_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); csharp_namespace_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - csharp_umbrella_classname_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - csharp_file_extension_.DestroyNoArena(_default_csharp_file_extension_); csharp_umbrella_namespace_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); if (this != default_instance_) { } @@ -7176,7 +7128,7 @@ void FileOptions::Clear() { go_package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } } - if (_has_bits_[8 / 32] & 65280) { + if (_has_bits_[8 / 32] & 32512) { ZR_(java_generic_services_, cc_enable_arenas_); if (has_objc_class_prefix()) { objc_class_prefix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -7184,26 +7136,9 @@ void FileOptions::Clear() { if (has_csharp_namespace()) { csharp_namespace_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - if (has_csharp_umbrella_classname()) { - csharp_umbrella_classname_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - } - csharp_public_classes_ = true; - } - if (_has_bits_[16 / 32] & 16711680) { - ZR_(csharp_multiple_files_, csharp_code_contracts_); - csharp_expand_namespace_directories_ = false; - csharp_cls_compliance_ = true; - csharp_add_serializable_ = false; - csharp_generate_private_ctor_ = true; - if (has_csharp_file_extension()) { - csharp_file_extension_.ClearToDefaultNoArena(_default_csharp_file_extension_); - } - } - if (_has_bits_[24 / 32] & 50331648) { if (has_csharp_umbrella_namespace()) { csharp_umbrella_namespace_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - csharp_generated_code_attributes_ = false; } #undef ZR_HELPER_ @@ -7446,160 +7381,6 @@ bool FileOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(306)) goto parse_csharp_umbrella_classname; - break; - } - - // optional string csharp_umbrella_classname = 38; - case 38: { - if (tag == 306) { - parse_csharp_umbrella_classname: - DO_(::google::protobuf::internal::WireFormatLite::ReadString( - input, this->mutable_csharp_umbrella_classname())); - ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->csharp_umbrella_classname().data(), this->csharp_umbrella_classname().length(), - ::google::protobuf::internal::WireFormat::PARSE, - "google.protobuf.FileOptions.csharp_umbrella_classname"); - } else { - goto handle_unusual; - } - if (input->ExpectTag(312)) goto parse_csharp_public_classes; - break; - } - - // optional bool csharp_public_classes = 39 [default = true]; - case 39: { - if (tag == 312) { - parse_csharp_public_classes: - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( - input, &csharp_public_classes_))); - set_has_csharp_public_classes(); - } else { - goto handle_unusual; - } - if (input->ExpectTag(320)) goto parse_csharp_multiple_files; - break; - } - - // optional bool csharp_multiple_files = 40; - case 40: { - if (tag == 320) { - parse_csharp_multiple_files: - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( - input, &csharp_multiple_files_))); - set_has_csharp_multiple_files(); - } else { - goto handle_unusual; - } - if (input->ExpectTag(328)) goto parse_csharp_nest_classes; - break; - } - - // optional bool csharp_nest_classes = 41; - case 41: { - if (tag == 328) { - parse_csharp_nest_classes: - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( - input, &csharp_nest_classes_))); - set_has_csharp_nest_classes(); - } else { - goto handle_unusual; - } - if (input->ExpectTag(336)) goto parse_csharp_code_contracts; - break; - } - - // optional bool csharp_code_contracts = 42; - case 42: { - if (tag == 336) { - parse_csharp_code_contracts: - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( - input, &csharp_code_contracts_))); - set_has_csharp_code_contracts(); - } else { - goto handle_unusual; - } - if (input->ExpectTag(344)) goto parse_csharp_expand_namespace_directories; - break; - } - - // optional bool csharp_expand_namespace_directories = 43; - case 43: { - if (tag == 344) { - parse_csharp_expand_namespace_directories: - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( - input, &csharp_expand_namespace_directories_))); - set_has_csharp_expand_namespace_directories(); - } else { - goto handle_unusual; - } - if (input->ExpectTag(352)) goto parse_csharp_cls_compliance; - break; - } - - // optional bool csharp_cls_compliance = 44 [default = true]; - case 44: { - if (tag == 352) { - parse_csharp_cls_compliance: - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( - input, &csharp_cls_compliance_))); - set_has_csharp_cls_compliance(); - } else { - goto handle_unusual; - } - if (input->ExpectTag(360)) goto parse_csharp_add_serializable; - break; - } - - // optional bool csharp_add_serializable = 45 [default = false]; - case 45: { - if (tag == 360) { - parse_csharp_add_serializable: - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( - input, &csharp_add_serializable_))); - set_has_csharp_add_serializable(); - } else { - goto handle_unusual; - } - if (input->ExpectTag(368)) goto parse_csharp_generate_private_ctor; - break; - } - - // optional bool csharp_generate_private_ctor = 46 [default = true]; - case 46: { - if (tag == 368) { - parse_csharp_generate_private_ctor: - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( - input, &csharp_generate_private_ctor_))); - set_has_csharp_generate_private_ctor(); - } else { - goto handle_unusual; - } - if (input->ExpectTag(378)) goto parse_csharp_file_extension; - break; - } - - // optional string csharp_file_extension = 47 [default = ".cs"]; - case 47: { - if (tag == 378) { - parse_csharp_file_extension: - DO_(::google::protobuf::internal::WireFormatLite::ReadString( - input, this->mutable_csharp_file_extension())); - ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->csharp_file_extension().data(), this->csharp_file_extension().length(), - ::google::protobuf::internal::WireFormat::PARSE, - "google.protobuf.FileOptions.csharp_file_extension"); - } else { - goto handle_unusual; - } if (input->ExpectTag(386)) goto parse_csharp_umbrella_namespace; break; } @@ -7617,21 +7398,6 @@ bool FileOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(392)) goto parse_csharp_generated_code_attributes; - break; - } - - // optional bool csharp_generated_code_attributes = 49 [default = false]; - case 49: { - if (tag == 392) { - parse_csharp_generated_code_attributes: - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( - input, &csharp_generated_code_attributes_))); - set_has_csharp_generated_code_attributes(); - } else { - goto handle_unusual; - } if (input->ExpectTag(7994)) goto parse_uninterpreted_option; break; } @@ -7776,66 +7542,6 @@ void FileOptions::SerializeWithCachedSizes( 37, this->csharp_namespace(), output); } - // optional string csharp_umbrella_classname = 38; - if (has_csharp_umbrella_classname()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->csharp_umbrella_classname().data(), this->csharp_umbrella_classname().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE, - "google.protobuf.FileOptions.csharp_umbrella_classname"); - ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( - 38, this->csharp_umbrella_classname(), output); - } - - // optional bool csharp_public_classes = 39 [default = true]; - if (has_csharp_public_classes()) { - ::google::protobuf::internal::WireFormatLite::WriteBool(39, this->csharp_public_classes(), output); - } - - // optional bool csharp_multiple_files = 40; - if (has_csharp_multiple_files()) { - ::google::protobuf::internal::WireFormatLite::WriteBool(40, this->csharp_multiple_files(), output); - } - - // optional bool csharp_nest_classes = 41; - if (has_csharp_nest_classes()) { - ::google::protobuf::internal::WireFormatLite::WriteBool(41, this->csharp_nest_classes(), output); - } - - // optional bool csharp_code_contracts = 42; - if (has_csharp_code_contracts()) { - ::google::protobuf::internal::WireFormatLite::WriteBool(42, this->csharp_code_contracts(), output); - } - - // optional bool csharp_expand_namespace_directories = 43; - if (has_csharp_expand_namespace_directories()) { - ::google::protobuf::internal::WireFormatLite::WriteBool(43, this->csharp_expand_namespace_directories(), output); - } - - // optional bool csharp_cls_compliance = 44 [default = true]; - if (has_csharp_cls_compliance()) { - ::google::protobuf::internal::WireFormatLite::WriteBool(44, this->csharp_cls_compliance(), output); - } - - // optional bool csharp_add_serializable = 45 [default = false]; - if (has_csharp_add_serializable()) { - ::google::protobuf::internal::WireFormatLite::WriteBool(45, this->csharp_add_serializable(), output); - } - - // optional bool csharp_generate_private_ctor = 46 [default = true]; - if (has_csharp_generate_private_ctor()) { - ::google::protobuf::internal::WireFormatLite::WriteBool(46, this->csharp_generate_private_ctor(), output); - } - - // optional string csharp_file_extension = 47 [default = ".cs"]; - if (has_csharp_file_extension()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->csharp_file_extension().data(), this->csharp_file_extension().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE, - "google.protobuf.FileOptions.csharp_file_extension"); - ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( - 47, this->csharp_file_extension(), output); - } - // optional string csharp_umbrella_namespace = 48; if (has_csharp_umbrella_namespace()) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -7846,11 +7552,6 @@ void FileOptions::SerializeWithCachedSizes( 48, this->csharp_umbrella_namespace(), output); } - // optional bool csharp_generated_code_attributes = 49 [default = false]; - if (has_csharp_generated_code_attributes()) { - ::google::protobuf::internal::WireFormatLite::WriteBool(49, this->csharp_generated_code_attributes(), output); - } - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( @@ -7972,68 +7673,6 @@ void FileOptions::SerializeWithCachedSizes( 37, this->csharp_namespace(), target); } - // optional string csharp_umbrella_classname = 38; - if (has_csharp_umbrella_classname()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->csharp_umbrella_classname().data(), this->csharp_umbrella_classname().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE, - "google.protobuf.FileOptions.csharp_umbrella_classname"); - target = - ::google::protobuf::internal::WireFormatLite::WriteStringToArray( - 38, this->csharp_umbrella_classname(), target); - } - - // optional bool csharp_public_classes = 39 [default = true]; - if (has_csharp_public_classes()) { - target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(39, this->csharp_public_classes(), target); - } - - // optional bool csharp_multiple_files = 40; - if (has_csharp_multiple_files()) { - target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(40, this->csharp_multiple_files(), target); - } - - // optional bool csharp_nest_classes = 41; - if (has_csharp_nest_classes()) { - target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(41, this->csharp_nest_classes(), target); - } - - // optional bool csharp_code_contracts = 42; - if (has_csharp_code_contracts()) { - target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(42, this->csharp_code_contracts(), target); - } - - // optional bool csharp_expand_namespace_directories = 43; - if (has_csharp_expand_namespace_directories()) { - target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(43, this->csharp_expand_namespace_directories(), target); - } - - // optional bool csharp_cls_compliance = 44 [default = true]; - if (has_csharp_cls_compliance()) { - target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(44, this->csharp_cls_compliance(), target); - } - - // optional bool csharp_add_serializable = 45 [default = false]; - if (has_csharp_add_serializable()) { - target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(45, this->csharp_add_serializable(), target); - } - - // optional bool csharp_generate_private_ctor = 46 [default = true]; - if (has_csharp_generate_private_ctor()) { - target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(46, this->csharp_generate_private_ctor(), target); - } - - // optional string csharp_file_extension = 47 [default = ".cs"]; - if (has_csharp_file_extension()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->csharp_file_extension().data(), this->csharp_file_extension().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE, - "google.protobuf.FileOptions.csharp_file_extension"); - target = - ::google::protobuf::internal::WireFormatLite::WriteStringToArray( - 47, this->csharp_file_extension(), target); - } - // optional string csharp_umbrella_namespace = 48; if (has_csharp_umbrella_namespace()) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -8045,11 +7684,6 @@ void FileOptions::SerializeWithCachedSizes( 48, this->csharp_umbrella_namespace(), target); } - // optional bool csharp_generated_code_attributes = 49 [default = false]; - if (has_csharp_generated_code_attributes()) { - target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(49, this->csharp_generated_code_attributes(), target); - } - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: @@ -8121,7 +7755,7 @@ int FileOptions::ByteSize() const { } } - if (_has_bits_[8 / 32] & 65280) { + if (_has_bits_[8 / 32] & 32512) { // optional bool java_generic_services = 17 [default = false]; if (has_java_generic_services()) { total_size += 2 + 1; @@ -8156,64 +7790,6 @@ int FileOptions::ByteSize() const { this->csharp_namespace()); } - // optional string csharp_umbrella_classname = 38; - if (has_csharp_umbrella_classname()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->csharp_umbrella_classname()); - } - - // optional bool csharp_public_classes = 39 [default = true]; - if (has_csharp_public_classes()) { - total_size += 2 + 1; - } - - } - if (_has_bits_[16 / 32] & 16711680) { - // optional bool csharp_multiple_files = 40; - if (has_csharp_multiple_files()) { - total_size += 2 + 1; - } - - // optional bool csharp_nest_classes = 41; - if (has_csharp_nest_classes()) { - total_size += 2 + 1; - } - - // optional bool csharp_code_contracts = 42; - if (has_csharp_code_contracts()) { - total_size += 2 + 1; - } - - // optional bool csharp_expand_namespace_directories = 43; - if (has_csharp_expand_namespace_directories()) { - total_size += 2 + 1; - } - - // optional bool csharp_cls_compliance = 44 [default = true]; - if (has_csharp_cls_compliance()) { - total_size += 2 + 1; - } - - // optional bool csharp_add_serializable = 45 [default = false]; - if (has_csharp_add_serializable()) { - total_size += 2 + 1; - } - - // optional bool csharp_generate_private_ctor = 46 [default = true]; - if (has_csharp_generate_private_ctor()) { - total_size += 2 + 1; - } - - // optional string csharp_file_extension = 47 [default = ".cs"]; - if (has_csharp_file_extension()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->csharp_file_extension()); - } - - } - if (_has_bits_[24 / 32] & 50331648) { // optional string csharp_umbrella_namespace = 48; if (has_csharp_umbrella_namespace()) { total_size += 2 + @@ -8221,11 +7797,6 @@ int FileOptions::ByteSize() const { this->csharp_umbrella_namespace()); } - // optional bool csharp_generated_code_attributes = 49 [default = false]; - if (has_csharp_generated_code_attributes()) { - total_size += 2 + 1; - } - } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; total_size += 2 * this->uninterpreted_option_size(); @@ -8313,49 +7884,10 @@ void FileOptions::MergeFrom(const FileOptions& from) { set_has_csharp_namespace(); csharp_namespace_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.csharp_namespace_); } - if (from.has_csharp_umbrella_classname()) { - set_has_csharp_umbrella_classname(); - csharp_umbrella_classname_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.csharp_umbrella_classname_); - } - if (from.has_csharp_public_classes()) { - set_csharp_public_classes(from.csharp_public_classes()); - } - } - if (from._has_bits_[16 / 32] & (0xffu << (16 % 32))) { - if (from.has_csharp_multiple_files()) { - set_csharp_multiple_files(from.csharp_multiple_files()); - } - if (from.has_csharp_nest_classes()) { - set_csharp_nest_classes(from.csharp_nest_classes()); - } - if (from.has_csharp_code_contracts()) { - set_csharp_code_contracts(from.csharp_code_contracts()); - } - if (from.has_csharp_expand_namespace_directories()) { - set_csharp_expand_namespace_directories(from.csharp_expand_namespace_directories()); - } - if (from.has_csharp_cls_compliance()) { - set_csharp_cls_compliance(from.csharp_cls_compliance()); - } - if (from.has_csharp_add_serializable()) { - set_csharp_add_serializable(from.csharp_add_serializable()); - } - if (from.has_csharp_generate_private_ctor()) { - set_csharp_generate_private_ctor(from.csharp_generate_private_ctor()); - } - if (from.has_csharp_file_extension()) { - set_has_csharp_file_extension(); - csharp_file_extension_.AssignWithDefault(_default_csharp_file_extension_, from.csharp_file_extension_); - } - } - if (from._has_bits_[24 / 32] & (0xffu << (24 % 32))) { if (from.has_csharp_umbrella_namespace()) { set_has_csharp_umbrella_namespace(); csharp_umbrella_namespace_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.csharp_umbrella_namespace_); } - if (from.has_csharp_generated_code_attributes()) { - set_csharp_generated_code_attributes(from.csharp_generated_code_attributes()); - } } _extensions_.MergeFrom(from._extensions_); if (from._internal_metadata_.have_unknown_fields()) { @@ -8401,18 +7933,7 @@ void FileOptions::InternalSwap(FileOptions* other) { std::swap(cc_enable_arenas_, other->cc_enable_arenas_); objc_class_prefix_.Swap(&other->objc_class_prefix_); csharp_namespace_.Swap(&other->csharp_namespace_); - csharp_umbrella_classname_.Swap(&other->csharp_umbrella_classname_); - std::swap(csharp_public_classes_, other->csharp_public_classes_); - std::swap(csharp_multiple_files_, other->csharp_multiple_files_); - std::swap(csharp_nest_classes_, other->csharp_nest_classes_); - std::swap(csharp_code_contracts_, other->csharp_code_contracts_); - std::swap(csharp_expand_namespace_directories_, other->csharp_expand_namespace_directories_); - std::swap(csharp_cls_compliance_, other->csharp_cls_compliance_); - std::swap(csharp_add_serializable_, other->csharp_add_serializable_); - std::swap(csharp_generate_private_ctor_, other->csharp_generate_private_ctor_); - csharp_file_extension_.Swap(&other->csharp_file_extension_); csharp_umbrella_namespace_.Swap(&other->csharp_umbrella_namespace_); - std::swap(csharp_generated_code_attributes_, other->csharp_generated_code_attributes_); uninterpreted_option_.UnsafeArenaSwap(&other->uninterpreted_option_); std::swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); @@ -8913,313 +8434,15 @@ void FileOptions::InternalSwap(FileOptions* other) { // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.csharp_namespace) } -// optional string csharp_umbrella_classname = 38; - bool FileOptions::has_csharp_umbrella_classname() const { - return (_has_bits_[0] & 0x00004000u) != 0; -} - void FileOptions::set_has_csharp_umbrella_classname() { - _has_bits_[0] |= 0x00004000u; -} - void FileOptions::clear_has_csharp_umbrella_classname() { - _has_bits_[0] &= ~0x00004000u; -} - void FileOptions::clear_csharp_umbrella_classname() { - csharp_umbrella_classname_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - clear_has_csharp_umbrella_classname(); -} - const ::std::string& FileOptions::csharp_umbrella_classname() const { - // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_umbrella_classname) - return csharp_umbrella_classname_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} - void FileOptions::set_csharp_umbrella_classname(const ::std::string& value) { - set_has_csharp_umbrella_classname(); - csharp_umbrella_classname_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_umbrella_classname) -} - void FileOptions::set_csharp_umbrella_classname(const char* value) { - set_has_csharp_umbrella_classname(); - csharp_umbrella_classname_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); - // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.csharp_umbrella_classname) -} - void FileOptions::set_csharp_umbrella_classname(const char* value, size_t size) { - set_has_csharp_umbrella_classname(); - csharp_umbrella_classname_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.csharp_umbrella_classname) -} - ::std::string* FileOptions::mutable_csharp_umbrella_classname() { - set_has_csharp_umbrella_classname(); - // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.csharp_umbrella_classname) - return csharp_umbrella_classname_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} - ::std::string* FileOptions::release_csharp_umbrella_classname() { - clear_has_csharp_umbrella_classname(); - return csharp_umbrella_classname_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} - void FileOptions::set_allocated_csharp_umbrella_classname(::std::string* csharp_umbrella_classname) { - if (csharp_umbrella_classname != NULL) { - set_has_csharp_umbrella_classname(); - } else { - clear_has_csharp_umbrella_classname(); - } - csharp_umbrella_classname_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), csharp_umbrella_classname); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.csharp_umbrella_classname) -} - -// optional bool csharp_public_classes = 39 [default = true]; - bool FileOptions::has_csharp_public_classes() const { - return (_has_bits_[0] & 0x00008000u) != 0; -} - void FileOptions::set_has_csharp_public_classes() { - _has_bits_[0] |= 0x00008000u; -} - void FileOptions::clear_has_csharp_public_classes() { - _has_bits_[0] &= ~0x00008000u; -} - void FileOptions::clear_csharp_public_classes() { - csharp_public_classes_ = true; - clear_has_csharp_public_classes(); -} - bool FileOptions::csharp_public_classes() const { - // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_public_classes) - return csharp_public_classes_; -} - void FileOptions::set_csharp_public_classes(bool value) { - set_has_csharp_public_classes(); - csharp_public_classes_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_public_classes) -} - -// optional bool csharp_multiple_files = 40; - bool FileOptions::has_csharp_multiple_files() const { - return (_has_bits_[0] & 0x00010000u) != 0; -} - void FileOptions::set_has_csharp_multiple_files() { - _has_bits_[0] |= 0x00010000u; -} - void FileOptions::clear_has_csharp_multiple_files() { - _has_bits_[0] &= ~0x00010000u; -} - void FileOptions::clear_csharp_multiple_files() { - csharp_multiple_files_ = false; - clear_has_csharp_multiple_files(); -} - bool FileOptions::csharp_multiple_files() const { - // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_multiple_files) - return csharp_multiple_files_; -} - void FileOptions::set_csharp_multiple_files(bool value) { - set_has_csharp_multiple_files(); - csharp_multiple_files_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_multiple_files) -} - -// optional bool csharp_nest_classes = 41; - bool FileOptions::has_csharp_nest_classes() const { - return (_has_bits_[0] & 0x00020000u) != 0; -} - void FileOptions::set_has_csharp_nest_classes() { - _has_bits_[0] |= 0x00020000u; -} - void FileOptions::clear_has_csharp_nest_classes() { - _has_bits_[0] &= ~0x00020000u; -} - void FileOptions::clear_csharp_nest_classes() { - csharp_nest_classes_ = false; - clear_has_csharp_nest_classes(); -} - bool FileOptions::csharp_nest_classes() const { - // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_nest_classes) - return csharp_nest_classes_; -} - void FileOptions::set_csharp_nest_classes(bool value) { - set_has_csharp_nest_classes(); - csharp_nest_classes_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_nest_classes) -} - -// optional bool csharp_code_contracts = 42; - bool FileOptions::has_csharp_code_contracts() const { - return (_has_bits_[0] & 0x00040000u) != 0; -} - void FileOptions::set_has_csharp_code_contracts() { - _has_bits_[0] |= 0x00040000u; -} - void FileOptions::clear_has_csharp_code_contracts() { - _has_bits_[0] &= ~0x00040000u; -} - void FileOptions::clear_csharp_code_contracts() { - csharp_code_contracts_ = false; - clear_has_csharp_code_contracts(); -} - bool FileOptions::csharp_code_contracts() const { - // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_code_contracts) - return csharp_code_contracts_; -} - void FileOptions::set_csharp_code_contracts(bool value) { - set_has_csharp_code_contracts(); - csharp_code_contracts_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_code_contracts) -} - -// optional bool csharp_expand_namespace_directories = 43; - bool FileOptions::has_csharp_expand_namespace_directories() const { - return (_has_bits_[0] & 0x00080000u) != 0; -} - void FileOptions::set_has_csharp_expand_namespace_directories() { - _has_bits_[0] |= 0x00080000u; -} - void FileOptions::clear_has_csharp_expand_namespace_directories() { - _has_bits_[0] &= ~0x00080000u; -} - void FileOptions::clear_csharp_expand_namespace_directories() { - csharp_expand_namespace_directories_ = false; - clear_has_csharp_expand_namespace_directories(); -} - bool FileOptions::csharp_expand_namespace_directories() const { - // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_expand_namespace_directories) - return csharp_expand_namespace_directories_; -} - void FileOptions::set_csharp_expand_namespace_directories(bool value) { - set_has_csharp_expand_namespace_directories(); - csharp_expand_namespace_directories_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_expand_namespace_directories) -} - -// optional bool csharp_cls_compliance = 44 [default = true]; - bool FileOptions::has_csharp_cls_compliance() const { - return (_has_bits_[0] & 0x00100000u) != 0; -} - void FileOptions::set_has_csharp_cls_compliance() { - _has_bits_[0] |= 0x00100000u; -} - void FileOptions::clear_has_csharp_cls_compliance() { - _has_bits_[0] &= ~0x00100000u; -} - void FileOptions::clear_csharp_cls_compliance() { - csharp_cls_compliance_ = true; - clear_has_csharp_cls_compliance(); -} - bool FileOptions::csharp_cls_compliance() const { - // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_cls_compliance) - return csharp_cls_compliance_; -} - void FileOptions::set_csharp_cls_compliance(bool value) { - set_has_csharp_cls_compliance(); - csharp_cls_compliance_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_cls_compliance) -} - -// optional bool csharp_add_serializable = 45 [default = false]; - bool FileOptions::has_csharp_add_serializable() const { - return (_has_bits_[0] & 0x00200000u) != 0; -} - void FileOptions::set_has_csharp_add_serializable() { - _has_bits_[0] |= 0x00200000u; -} - void FileOptions::clear_has_csharp_add_serializable() { - _has_bits_[0] &= ~0x00200000u; -} - void FileOptions::clear_csharp_add_serializable() { - csharp_add_serializable_ = false; - clear_has_csharp_add_serializable(); -} - bool FileOptions::csharp_add_serializable() const { - // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_add_serializable) - return csharp_add_serializable_; -} - void FileOptions::set_csharp_add_serializable(bool value) { - set_has_csharp_add_serializable(); - csharp_add_serializable_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_add_serializable) -} - -// optional bool csharp_generate_private_ctor = 46 [default = true]; - bool FileOptions::has_csharp_generate_private_ctor() const { - return (_has_bits_[0] & 0x00400000u) != 0; -} - void FileOptions::set_has_csharp_generate_private_ctor() { - _has_bits_[0] |= 0x00400000u; -} - void FileOptions::clear_has_csharp_generate_private_ctor() { - _has_bits_[0] &= ~0x00400000u; -} - void FileOptions::clear_csharp_generate_private_ctor() { - csharp_generate_private_ctor_ = true; - clear_has_csharp_generate_private_ctor(); -} - bool FileOptions::csharp_generate_private_ctor() const { - // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_generate_private_ctor) - return csharp_generate_private_ctor_; -} - void FileOptions::set_csharp_generate_private_ctor(bool value) { - set_has_csharp_generate_private_ctor(); - csharp_generate_private_ctor_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_generate_private_ctor) -} - -// optional string csharp_file_extension = 47 [default = ".cs"]; - bool FileOptions::has_csharp_file_extension() const { - return (_has_bits_[0] & 0x00800000u) != 0; -} - void FileOptions::set_has_csharp_file_extension() { - _has_bits_[0] |= 0x00800000u; -} - void FileOptions::clear_has_csharp_file_extension() { - _has_bits_[0] &= ~0x00800000u; -} - void FileOptions::clear_csharp_file_extension() { - csharp_file_extension_.ClearToDefaultNoArena(_default_csharp_file_extension_); - clear_has_csharp_file_extension(); -} - const ::std::string& FileOptions::csharp_file_extension() const { - // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_file_extension) - return csharp_file_extension_.GetNoArena(_default_csharp_file_extension_); -} - void FileOptions::set_csharp_file_extension(const ::std::string& value) { - set_has_csharp_file_extension(); - csharp_file_extension_.SetNoArena(_default_csharp_file_extension_, value); - // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_file_extension) -} - void FileOptions::set_csharp_file_extension(const char* value) { - set_has_csharp_file_extension(); - csharp_file_extension_.SetNoArena(_default_csharp_file_extension_, ::std::string(value)); - // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.csharp_file_extension) -} - void FileOptions::set_csharp_file_extension(const char* value, size_t size) { - set_has_csharp_file_extension(); - csharp_file_extension_.SetNoArena(_default_csharp_file_extension_, - ::std::string(reinterpret_cast(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.csharp_file_extension) -} - ::std::string* FileOptions::mutable_csharp_file_extension() { - set_has_csharp_file_extension(); - // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.csharp_file_extension) - return csharp_file_extension_.MutableNoArena(_default_csharp_file_extension_); -} - ::std::string* FileOptions::release_csharp_file_extension() { - clear_has_csharp_file_extension(); - return csharp_file_extension_.ReleaseNoArena(_default_csharp_file_extension_); -} - void FileOptions::set_allocated_csharp_file_extension(::std::string* csharp_file_extension) { - if (csharp_file_extension != NULL) { - set_has_csharp_file_extension(); - } else { - clear_has_csharp_file_extension(); - } - csharp_file_extension_.SetAllocatedNoArena(_default_csharp_file_extension_, csharp_file_extension); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.csharp_file_extension) -} - // optional string csharp_umbrella_namespace = 48; bool FileOptions::has_csharp_umbrella_namespace() const { - return (_has_bits_[0] & 0x01000000u) != 0; + return (_has_bits_[0] & 0x00004000u) != 0; } void FileOptions::set_has_csharp_umbrella_namespace() { - _has_bits_[0] |= 0x01000000u; + _has_bits_[0] |= 0x00004000u; } void FileOptions::clear_has_csharp_umbrella_namespace() { - _has_bits_[0] &= ~0x01000000u; + _has_bits_[0] &= ~0x00004000u; } void FileOptions::clear_csharp_umbrella_namespace() { csharp_umbrella_namespace_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -9264,30 +8487,6 @@ void FileOptions::InternalSwap(FileOptions* other) { // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.csharp_umbrella_namespace) } -// optional bool csharp_generated_code_attributes = 49 [default = false]; - bool FileOptions::has_csharp_generated_code_attributes() const { - return (_has_bits_[0] & 0x02000000u) != 0; -} - void FileOptions::set_has_csharp_generated_code_attributes() { - _has_bits_[0] |= 0x02000000u; -} - void FileOptions::clear_has_csharp_generated_code_attributes() { - _has_bits_[0] &= ~0x02000000u; -} - void FileOptions::clear_csharp_generated_code_attributes() { - csharp_generated_code_attributes_ = false; - clear_has_csharp_generated_code_attributes(); -} - bool FileOptions::csharp_generated_code_attributes() const { - // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_generated_code_attributes) - return csharp_generated_code_attributes_; -} - void FileOptions::set_csharp_generated_code_attributes(bool value) { - set_has_csharp_generated_code_attributes(); - csharp_generated_code_attributes_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_generated_code_attributes) -} - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; int FileOptions::uninterpreted_option_size() const { return uninterpreted_option_.size(); @@ -9891,6 +9090,7 @@ const int FieldOptions::kPackedFieldNumber; const int FieldOptions::kLazyFieldNumber; const int FieldOptions::kDeprecatedFieldNumber; const int FieldOptions::kWeakFieldNumber; +const int FieldOptions::kCsharpPropertyNameFieldNumber; const int FieldOptions::kUninterpretedOptionFieldNumber; #endif // !_MSC_VER @@ -9912,12 +9112,14 @@ FieldOptions::FieldOptions(const FieldOptions& from) } void FieldOptions::SharedCtor() { + ::google::protobuf::internal::GetEmptyString(); _cached_size_ = 0; ctype_ = 0; packed_ = false; lazy_ = false; deprecated_ = false; weak_ = false; + csharp_property_name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); ::memset(_has_bits_, 0, sizeof(_has_bits_)); } @@ -9927,6 +9129,7 @@ FieldOptions::~FieldOptions() { } void FieldOptions::SharedDtor() { + csharp_property_name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); if (this != default_instance_) { } } @@ -9966,8 +9169,11 @@ void FieldOptions::Clear() { ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ } while (0) - if (_has_bits_[0 / 32] & 31) { + if (_has_bits_[0 / 32] & 63) { ZR_(ctype_, weak_); + if (has_csharp_property_name()) { + csharp_property_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } } #undef ZR_HELPER_ @@ -10065,6 +9271,23 @@ bool FieldOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } + if (input->ExpectTag(90)) goto parse_csharp_property_name; + break; + } + + // optional string csharp_property_name = 11; + case 11: { + if (tag == 90) { + parse_csharp_property_name: + DO_(::google::protobuf::internal::WireFormatLite::ReadString( + input, this->mutable_csharp_property_name())); + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->csharp_property_name().data(), this->csharp_property_name().length(), + ::google::protobuf::internal::WireFormat::PARSE, + "google.protobuf.FieldOptions.csharp_property_name"); + } else { + goto handle_unusual; + } if (input->ExpectTag(7994)) goto parse_uninterpreted_option; break; } @@ -10139,6 +9362,16 @@ void FieldOptions::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WriteBool(10, this->weak(), output); } + // optional string csharp_property_name = 11; + if (has_csharp_property_name()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->csharp_property_name().data(), this->csharp_property_name().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "google.protobuf.FieldOptions.csharp_property_name"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( + 11, this->csharp_property_name(), output); + } + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( @@ -10185,6 +9418,17 @@ void FieldOptions::SerializeWithCachedSizes( target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(10, this->weak(), target); } + // optional string csharp_property_name = 11; + if (has_csharp_property_name()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->csharp_property_name().data(), this->csharp_property_name().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "google.protobuf.FieldOptions.csharp_property_name"); + target = + ::google::protobuf::internal::WireFormatLite::WriteStringToArray( + 11, this->csharp_property_name(), target); + } + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: @@ -10207,7 +9451,7 @@ void FieldOptions::SerializeWithCachedSizes( int FieldOptions::ByteSize() const { int total_size = 0; - if (_has_bits_[0 / 32] & 31) { + if (_has_bits_[0 / 32] & 63) { // optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING]; if (has_ctype()) { total_size += 1 + @@ -10234,6 +9478,13 @@ int FieldOptions::ByteSize() const { total_size += 1 + 1; } + // optional string csharp_property_name = 11; + if (has_csharp_property_name()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->csharp_property_name()); + } + } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; total_size += 2 * this->uninterpreted_option_size(); @@ -10287,6 +9538,10 @@ void FieldOptions::MergeFrom(const FieldOptions& from) { if (from.has_weak()) { set_weak(from.weak()); } + if (from.has_csharp_property_name()) { + set_has_csharp_property_name(); + csharp_property_name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.csharp_property_name_); + } } _extensions_.MergeFrom(from._extensions_); if (from._internal_metadata_.have_unknown_fields()) { @@ -10323,6 +9578,7 @@ void FieldOptions::InternalSwap(FieldOptions* other) { std::swap(lazy_, other->lazy_); std::swap(deprecated_, other->deprecated_); std::swap(weak_, other->weak_); + csharp_property_name_.Swap(&other->csharp_property_name_); uninterpreted_option_.UnsafeArenaSwap(&other->uninterpreted_option_); std::swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); @@ -10462,6 +9718,59 @@ void FieldOptions::InternalSwap(FieldOptions* other) { // @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.weak) } +// optional string csharp_property_name = 11; + bool FieldOptions::has_csharp_property_name() const { + return (_has_bits_[0] & 0x00000020u) != 0; +} + void FieldOptions::set_has_csharp_property_name() { + _has_bits_[0] |= 0x00000020u; +} + void FieldOptions::clear_has_csharp_property_name() { + _has_bits_[0] &= ~0x00000020u; +} + void FieldOptions::clear_csharp_property_name() { + csharp_property_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_csharp_property_name(); +} + const ::std::string& FieldOptions::csharp_property_name() const { + // @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.csharp_property_name) + return csharp_property_name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + void FieldOptions::set_csharp_property_name(const ::std::string& value) { + set_has_csharp_property_name(); + csharp_property_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.csharp_property_name) +} + void FieldOptions::set_csharp_property_name(const char* value) { + set_has_csharp_property_name(); + csharp_property_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:google.protobuf.FieldOptions.csharp_property_name) +} + void FieldOptions::set_csharp_property_name(const char* value, size_t size) { + set_has_csharp_property_name(); + csharp_property_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldOptions.csharp_property_name) +} + ::std::string* FieldOptions::mutable_csharp_property_name() { + set_has_csharp_property_name(); + // @@protoc_insertion_point(field_mutable:google.protobuf.FieldOptions.csharp_property_name) + return csharp_property_name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + ::std::string* FieldOptions::release_csharp_property_name() { + clear_has_csharp_property_name(); + return csharp_property_name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + void FieldOptions::set_allocated_csharp_property_name(::std::string* csharp_property_name) { + if (csharp_property_name != NULL) { + set_has_csharp_property_name(); + } else { + clear_has_csharp_property_name(); + } + csharp_property_name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), csharp_property_name); + // @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldOptions.csharp_property_name) +} + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; int FieldOptions::uninterpreted_option_size() const { return uninterpreted_option_.size(); diff --git a/src/google/protobuf/descriptor.pb.h b/src/google/protobuf/descriptor.pb.h index f51ab536..6082d182 100644 --- a/src/google/protobuf/descriptor.pb.h +++ b/src/google/protobuf/descriptor.pb.h @@ -1849,86 +1849,6 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message { ::std::string* release_csharp_namespace(); void set_allocated_csharp_namespace(::std::string* csharp_namespace); - // optional string csharp_umbrella_classname = 38; - bool has_csharp_umbrella_classname() const; - void clear_csharp_umbrella_classname(); - static const int kCsharpUmbrellaClassnameFieldNumber = 38; - const ::std::string& csharp_umbrella_classname() const; - void set_csharp_umbrella_classname(const ::std::string& value); - void set_csharp_umbrella_classname(const char* value); - void set_csharp_umbrella_classname(const char* value, size_t size); - ::std::string* mutable_csharp_umbrella_classname(); - ::std::string* release_csharp_umbrella_classname(); - void set_allocated_csharp_umbrella_classname(::std::string* csharp_umbrella_classname); - - // optional bool csharp_public_classes = 39 [default = true]; - bool has_csharp_public_classes() const; - void clear_csharp_public_classes(); - static const int kCsharpPublicClassesFieldNumber = 39; - bool csharp_public_classes() const; - void set_csharp_public_classes(bool value); - - // optional bool csharp_multiple_files = 40; - bool has_csharp_multiple_files() const; - void clear_csharp_multiple_files(); - static const int kCsharpMultipleFilesFieldNumber = 40; - bool csharp_multiple_files() const; - void set_csharp_multiple_files(bool value); - - // optional bool csharp_nest_classes = 41; - bool has_csharp_nest_classes() const; - void clear_csharp_nest_classes(); - static const int kCsharpNestClassesFieldNumber = 41; - bool csharp_nest_classes() const; - void set_csharp_nest_classes(bool value); - - // optional bool csharp_code_contracts = 42; - bool has_csharp_code_contracts() const; - void clear_csharp_code_contracts(); - static const int kCsharpCodeContractsFieldNumber = 42; - bool csharp_code_contracts() const; - void set_csharp_code_contracts(bool value); - - // optional bool csharp_expand_namespace_directories = 43; - bool has_csharp_expand_namespace_directories() const; - void clear_csharp_expand_namespace_directories(); - static const int kCsharpExpandNamespaceDirectoriesFieldNumber = 43; - bool csharp_expand_namespace_directories() const; - void set_csharp_expand_namespace_directories(bool value); - - // optional bool csharp_cls_compliance = 44 [default = true]; - bool has_csharp_cls_compliance() const; - void clear_csharp_cls_compliance(); - static const int kCsharpClsComplianceFieldNumber = 44; - bool csharp_cls_compliance() const; - void set_csharp_cls_compliance(bool value); - - // optional bool csharp_add_serializable = 45 [default = false]; - bool has_csharp_add_serializable() const; - void clear_csharp_add_serializable(); - static const int kCsharpAddSerializableFieldNumber = 45; - bool csharp_add_serializable() const; - void set_csharp_add_serializable(bool value); - - // optional bool csharp_generate_private_ctor = 46 [default = true]; - bool has_csharp_generate_private_ctor() const; - void clear_csharp_generate_private_ctor(); - static const int kCsharpGeneratePrivateCtorFieldNumber = 46; - bool csharp_generate_private_ctor() const; - void set_csharp_generate_private_ctor(bool value); - - // optional string csharp_file_extension = 47 [default = ".cs"]; - bool has_csharp_file_extension() const; - void clear_csharp_file_extension(); - static const int kCsharpFileExtensionFieldNumber = 47; - const ::std::string& csharp_file_extension() const; - void set_csharp_file_extension(const ::std::string& value); - void set_csharp_file_extension(const char* value); - void set_csharp_file_extension(const char* value, size_t size); - ::std::string* mutable_csharp_file_extension(); - ::std::string* release_csharp_file_extension(); - void set_allocated_csharp_file_extension(::std::string* csharp_file_extension); - // optional string csharp_umbrella_namespace = 48; bool has_csharp_umbrella_namespace() const; void clear_csharp_umbrella_namespace(); @@ -1941,13 +1861,6 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message { ::std::string* release_csharp_umbrella_namespace(); void set_allocated_csharp_umbrella_namespace(::std::string* csharp_umbrella_namespace); - // optional bool csharp_generated_code_attributes = 49 [default = false]; - bool has_csharp_generated_code_attributes() const; - void clear_csharp_generated_code_attributes(); - static const int kCsharpGeneratedCodeAttributesFieldNumber = 49; - bool csharp_generated_code_attributes() const; - void set_csharp_generated_code_attributes(bool value); - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; int uninterpreted_option_size() const; void clear_uninterpreted_option(); @@ -1991,30 +1904,8 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message { inline void clear_has_objc_class_prefix(); inline void set_has_csharp_namespace(); inline void clear_has_csharp_namespace(); - inline void set_has_csharp_umbrella_classname(); - inline void clear_has_csharp_umbrella_classname(); - inline void set_has_csharp_public_classes(); - inline void clear_has_csharp_public_classes(); - inline void set_has_csharp_multiple_files(); - inline void clear_has_csharp_multiple_files(); - inline void set_has_csharp_nest_classes(); - inline void clear_has_csharp_nest_classes(); - inline void set_has_csharp_code_contracts(); - inline void clear_has_csharp_code_contracts(); - inline void set_has_csharp_expand_namespace_directories(); - inline void clear_has_csharp_expand_namespace_directories(); - inline void set_has_csharp_cls_compliance(); - inline void clear_has_csharp_cls_compliance(); - inline void set_has_csharp_add_serializable(); - inline void clear_has_csharp_add_serializable(); - inline void set_has_csharp_generate_private_ctor(); - inline void clear_has_csharp_generate_private_ctor(); - inline void set_has_csharp_file_extension(); - inline void clear_has_csharp_file_extension(); inline void set_has_csharp_umbrella_namespace(); inline void clear_has_csharp_umbrella_namespace(); - inline void set_has_csharp_generated_code_attributes(); - inline void clear_has_csharp_generated_code_attributes(); ::google::protobuf::internal::ExtensionSet _extensions_; @@ -2031,24 +1922,12 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message { ::google::protobuf::internal::ArenaStringPtr go_package_; ::google::protobuf::internal::ArenaStringPtr objc_class_prefix_; ::google::protobuf::internal::ArenaStringPtr csharp_namespace_; + ::google::protobuf::internal::ArenaStringPtr csharp_umbrella_namespace_; + ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; bool java_generic_services_; bool py_generic_services_; bool deprecated_; bool cc_enable_arenas_; - bool csharp_public_classes_; - bool csharp_multiple_files_; - bool csharp_nest_classes_; - bool csharp_code_contracts_; - ::google::protobuf::internal::ArenaStringPtr csharp_umbrella_classname_; - bool csharp_expand_namespace_directories_; - bool csharp_cls_compliance_; - bool csharp_add_serializable_; - bool csharp_generate_private_ctor_; - bool csharp_generated_code_attributes_; - static ::std::string* _default_csharp_file_extension_; - ::google::protobuf::internal::ArenaStringPtr csharp_file_extension_; - ::google::protobuf::internal::ArenaStringPtr csharp_umbrella_namespace_; - ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); @@ -2317,6 +2196,18 @@ class LIBPROTOBUF_EXPORT FieldOptions : public ::google::protobuf::Message { bool weak() const; void set_weak(bool value); + // optional string csharp_property_name = 11; + bool has_csharp_property_name() const; + void clear_csharp_property_name(); + static const int kCsharpPropertyNameFieldNumber = 11; + const ::std::string& csharp_property_name() const; + void set_csharp_property_name(const ::std::string& value); + void set_csharp_property_name(const char* value); + void set_csharp_property_name(const char* value, size_t size); + ::std::string* mutable_csharp_property_name(); + ::std::string* release_csharp_property_name(); + void set_allocated_csharp_property_name(::std::string* csharp_property_name); + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; int uninterpreted_option_size() const; void clear_uninterpreted_option(); @@ -2342,6 +2233,8 @@ class LIBPROTOBUF_EXPORT FieldOptions : public ::google::protobuf::Message { inline void clear_has_deprecated(); inline void set_has_weak(); inline void clear_has_weak(); + inline void set_has_csharp_property_name(); + inline void clear_has_csharp_property_name(); ::google::protobuf::internal::ExtensionSet _extensions_; @@ -2353,6 +2246,7 @@ class LIBPROTOBUF_EXPORT FieldOptions : public ::google::protobuf::Message { bool lazy_; bool deprecated_; bool weak_; + ::google::protobuf::internal::ArenaStringPtr csharp_property_name_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); @@ -5706,313 +5600,15 @@ inline void FileOptions::set_allocated_csharp_namespace(::std::string* csharp_na // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.csharp_namespace) } -// optional string csharp_umbrella_classname = 38; -inline bool FileOptions::has_csharp_umbrella_classname() const { - return (_has_bits_[0] & 0x00004000u) != 0; -} -inline void FileOptions::set_has_csharp_umbrella_classname() { - _has_bits_[0] |= 0x00004000u; -} -inline void FileOptions::clear_has_csharp_umbrella_classname() { - _has_bits_[0] &= ~0x00004000u; -} -inline void FileOptions::clear_csharp_umbrella_classname() { - csharp_umbrella_classname_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - clear_has_csharp_umbrella_classname(); -} -inline const ::std::string& FileOptions::csharp_umbrella_classname() const { - // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_umbrella_classname) - return csharp_umbrella_classname_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -inline void FileOptions::set_csharp_umbrella_classname(const ::std::string& value) { - set_has_csharp_umbrella_classname(); - csharp_umbrella_classname_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_umbrella_classname) -} -inline void FileOptions::set_csharp_umbrella_classname(const char* value) { - set_has_csharp_umbrella_classname(); - csharp_umbrella_classname_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); - // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.csharp_umbrella_classname) -} -inline void FileOptions::set_csharp_umbrella_classname(const char* value, size_t size) { - set_has_csharp_umbrella_classname(); - csharp_umbrella_classname_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.csharp_umbrella_classname) -} -inline ::std::string* FileOptions::mutable_csharp_umbrella_classname() { - set_has_csharp_umbrella_classname(); - // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.csharp_umbrella_classname) - return csharp_umbrella_classname_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -inline ::std::string* FileOptions::release_csharp_umbrella_classname() { - clear_has_csharp_umbrella_classname(); - return csharp_umbrella_classname_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -inline void FileOptions::set_allocated_csharp_umbrella_classname(::std::string* csharp_umbrella_classname) { - if (csharp_umbrella_classname != NULL) { - set_has_csharp_umbrella_classname(); - } else { - clear_has_csharp_umbrella_classname(); - } - csharp_umbrella_classname_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), csharp_umbrella_classname); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.csharp_umbrella_classname) -} - -// optional bool csharp_public_classes = 39 [default = true]; -inline bool FileOptions::has_csharp_public_classes() const { - return (_has_bits_[0] & 0x00008000u) != 0; -} -inline void FileOptions::set_has_csharp_public_classes() { - _has_bits_[0] |= 0x00008000u; -} -inline void FileOptions::clear_has_csharp_public_classes() { - _has_bits_[0] &= ~0x00008000u; -} -inline void FileOptions::clear_csharp_public_classes() { - csharp_public_classes_ = true; - clear_has_csharp_public_classes(); -} -inline bool FileOptions::csharp_public_classes() const { - // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_public_classes) - return csharp_public_classes_; -} -inline void FileOptions::set_csharp_public_classes(bool value) { - set_has_csharp_public_classes(); - csharp_public_classes_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_public_classes) -} - -// optional bool csharp_multiple_files = 40; -inline bool FileOptions::has_csharp_multiple_files() const { - return (_has_bits_[0] & 0x00010000u) != 0; -} -inline void FileOptions::set_has_csharp_multiple_files() { - _has_bits_[0] |= 0x00010000u; -} -inline void FileOptions::clear_has_csharp_multiple_files() { - _has_bits_[0] &= ~0x00010000u; -} -inline void FileOptions::clear_csharp_multiple_files() { - csharp_multiple_files_ = false; - clear_has_csharp_multiple_files(); -} -inline bool FileOptions::csharp_multiple_files() const { - // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_multiple_files) - return csharp_multiple_files_; -} -inline void FileOptions::set_csharp_multiple_files(bool value) { - set_has_csharp_multiple_files(); - csharp_multiple_files_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_multiple_files) -} - -// optional bool csharp_nest_classes = 41; -inline bool FileOptions::has_csharp_nest_classes() const { - return (_has_bits_[0] & 0x00020000u) != 0; -} -inline void FileOptions::set_has_csharp_nest_classes() { - _has_bits_[0] |= 0x00020000u; -} -inline void FileOptions::clear_has_csharp_nest_classes() { - _has_bits_[0] &= ~0x00020000u; -} -inline void FileOptions::clear_csharp_nest_classes() { - csharp_nest_classes_ = false; - clear_has_csharp_nest_classes(); -} -inline bool FileOptions::csharp_nest_classes() const { - // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_nest_classes) - return csharp_nest_classes_; -} -inline void FileOptions::set_csharp_nest_classes(bool value) { - set_has_csharp_nest_classes(); - csharp_nest_classes_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_nest_classes) -} - -// optional bool csharp_code_contracts = 42; -inline bool FileOptions::has_csharp_code_contracts() const { - return (_has_bits_[0] & 0x00040000u) != 0; -} -inline void FileOptions::set_has_csharp_code_contracts() { - _has_bits_[0] |= 0x00040000u; -} -inline void FileOptions::clear_has_csharp_code_contracts() { - _has_bits_[0] &= ~0x00040000u; -} -inline void FileOptions::clear_csharp_code_contracts() { - csharp_code_contracts_ = false; - clear_has_csharp_code_contracts(); -} -inline bool FileOptions::csharp_code_contracts() const { - // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_code_contracts) - return csharp_code_contracts_; -} -inline void FileOptions::set_csharp_code_contracts(bool value) { - set_has_csharp_code_contracts(); - csharp_code_contracts_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_code_contracts) -} - -// optional bool csharp_expand_namespace_directories = 43; -inline bool FileOptions::has_csharp_expand_namespace_directories() const { - return (_has_bits_[0] & 0x00080000u) != 0; -} -inline void FileOptions::set_has_csharp_expand_namespace_directories() { - _has_bits_[0] |= 0x00080000u; -} -inline void FileOptions::clear_has_csharp_expand_namespace_directories() { - _has_bits_[0] &= ~0x00080000u; -} -inline void FileOptions::clear_csharp_expand_namespace_directories() { - csharp_expand_namespace_directories_ = false; - clear_has_csharp_expand_namespace_directories(); -} -inline bool FileOptions::csharp_expand_namespace_directories() const { - // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_expand_namespace_directories) - return csharp_expand_namespace_directories_; -} -inline void FileOptions::set_csharp_expand_namespace_directories(bool value) { - set_has_csharp_expand_namespace_directories(); - csharp_expand_namespace_directories_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_expand_namespace_directories) -} - -// optional bool csharp_cls_compliance = 44 [default = true]; -inline bool FileOptions::has_csharp_cls_compliance() const { - return (_has_bits_[0] & 0x00100000u) != 0; -} -inline void FileOptions::set_has_csharp_cls_compliance() { - _has_bits_[0] |= 0x00100000u; -} -inline void FileOptions::clear_has_csharp_cls_compliance() { - _has_bits_[0] &= ~0x00100000u; -} -inline void FileOptions::clear_csharp_cls_compliance() { - csharp_cls_compliance_ = true; - clear_has_csharp_cls_compliance(); -} -inline bool FileOptions::csharp_cls_compliance() const { - // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_cls_compliance) - return csharp_cls_compliance_; -} -inline void FileOptions::set_csharp_cls_compliance(bool value) { - set_has_csharp_cls_compliance(); - csharp_cls_compliance_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_cls_compliance) -} - -// optional bool csharp_add_serializable = 45 [default = false]; -inline bool FileOptions::has_csharp_add_serializable() const { - return (_has_bits_[0] & 0x00200000u) != 0; -} -inline void FileOptions::set_has_csharp_add_serializable() { - _has_bits_[0] |= 0x00200000u; -} -inline void FileOptions::clear_has_csharp_add_serializable() { - _has_bits_[0] &= ~0x00200000u; -} -inline void FileOptions::clear_csharp_add_serializable() { - csharp_add_serializable_ = false; - clear_has_csharp_add_serializable(); -} -inline bool FileOptions::csharp_add_serializable() const { - // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_add_serializable) - return csharp_add_serializable_; -} -inline void FileOptions::set_csharp_add_serializable(bool value) { - set_has_csharp_add_serializable(); - csharp_add_serializable_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_add_serializable) -} - -// optional bool csharp_generate_private_ctor = 46 [default = true]; -inline bool FileOptions::has_csharp_generate_private_ctor() const { - return (_has_bits_[0] & 0x00400000u) != 0; -} -inline void FileOptions::set_has_csharp_generate_private_ctor() { - _has_bits_[0] |= 0x00400000u; -} -inline void FileOptions::clear_has_csharp_generate_private_ctor() { - _has_bits_[0] &= ~0x00400000u; -} -inline void FileOptions::clear_csharp_generate_private_ctor() { - csharp_generate_private_ctor_ = true; - clear_has_csharp_generate_private_ctor(); -} -inline bool FileOptions::csharp_generate_private_ctor() const { - // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_generate_private_ctor) - return csharp_generate_private_ctor_; -} -inline void FileOptions::set_csharp_generate_private_ctor(bool value) { - set_has_csharp_generate_private_ctor(); - csharp_generate_private_ctor_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_generate_private_ctor) -} - -// optional string csharp_file_extension = 47 [default = ".cs"]; -inline bool FileOptions::has_csharp_file_extension() const { - return (_has_bits_[0] & 0x00800000u) != 0; -} -inline void FileOptions::set_has_csharp_file_extension() { - _has_bits_[0] |= 0x00800000u; -} -inline void FileOptions::clear_has_csharp_file_extension() { - _has_bits_[0] &= ~0x00800000u; -} -inline void FileOptions::clear_csharp_file_extension() { - csharp_file_extension_.ClearToDefaultNoArena(_default_csharp_file_extension_); - clear_has_csharp_file_extension(); -} -inline const ::std::string& FileOptions::csharp_file_extension() const { - // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_file_extension) - return csharp_file_extension_.GetNoArena(_default_csharp_file_extension_); -} -inline void FileOptions::set_csharp_file_extension(const ::std::string& value) { - set_has_csharp_file_extension(); - csharp_file_extension_.SetNoArena(_default_csharp_file_extension_, value); - // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_file_extension) -} -inline void FileOptions::set_csharp_file_extension(const char* value) { - set_has_csharp_file_extension(); - csharp_file_extension_.SetNoArena(_default_csharp_file_extension_, ::std::string(value)); - // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.csharp_file_extension) -} -inline void FileOptions::set_csharp_file_extension(const char* value, size_t size) { - set_has_csharp_file_extension(); - csharp_file_extension_.SetNoArena(_default_csharp_file_extension_, - ::std::string(reinterpret_cast(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.csharp_file_extension) -} -inline ::std::string* FileOptions::mutable_csharp_file_extension() { - set_has_csharp_file_extension(); - // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.csharp_file_extension) - return csharp_file_extension_.MutableNoArena(_default_csharp_file_extension_); -} -inline ::std::string* FileOptions::release_csharp_file_extension() { - clear_has_csharp_file_extension(); - return csharp_file_extension_.ReleaseNoArena(_default_csharp_file_extension_); -} -inline void FileOptions::set_allocated_csharp_file_extension(::std::string* csharp_file_extension) { - if (csharp_file_extension != NULL) { - set_has_csharp_file_extension(); - } else { - clear_has_csharp_file_extension(); - } - csharp_file_extension_.SetAllocatedNoArena(_default_csharp_file_extension_, csharp_file_extension); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.csharp_file_extension) -} - // optional string csharp_umbrella_namespace = 48; inline bool FileOptions::has_csharp_umbrella_namespace() const { - return (_has_bits_[0] & 0x01000000u) != 0; + return (_has_bits_[0] & 0x00004000u) != 0; } inline void FileOptions::set_has_csharp_umbrella_namespace() { - _has_bits_[0] |= 0x01000000u; + _has_bits_[0] |= 0x00004000u; } inline void FileOptions::clear_has_csharp_umbrella_namespace() { - _has_bits_[0] &= ~0x01000000u; + _has_bits_[0] &= ~0x00004000u; } inline void FileOptions::clear_csharp_umbrella_namespace() { csharp_umbrella_namespace_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -6057,30 +5653,6 @@ inline void FileOptions::set_allocated_csharp_umbrella_namespace(::std::string* // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.csharp_umbrella_namespace) } -// optional bool csharp_generated_code_attributes = 49 [default = false]; -inline bool FileOptions::has_csharp_generated_code_attributes() const { - return (_has_bits_[0] & 0x02000000u) != 0; -} -inline void FileOptions::set_has_csharp_generated_code_attributes() { - _has_bits_[0] |= 0x02000000u; -} -inline void FileOptions::clear_has_csharp_generated_code_attributes() { - _has_bits_[0] &= ~0x02000000u; -} -inline void FileOptions::clear_csharp_generated_code_attributes() { - csharp_generated_code_attributes_ = false; - clear_has_csharp_generated_code_attributes(); -} -inline bool FileOptions::csharp_generated_code_attributes() const { - // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_generated_code_attributes) - return csharp_generated_code_attributes_; -} -inline void FileOptions::set_csharp_generated_code_attributes(bool value) { - set_has_csharp_generated_code_attributes(); - csharp_generated_code_attributes_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_generated_code_attributes) -} - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; inline int FileOptions::uninterpreted_option_size() const { return uninterpreted_option_.size(); @@ -6366,6 +5938,59 @@ inline void FieldOptions::set_weak(bool value) { // @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.weak) } +// optional string csharp_property_name = 11; +inline bool FieldOptions::has_csharp_property_name() const { + return (_has_bits_[0] & 0x00000020u) != 0; +} +inline void FieldOptions::set_has_csharp_property_name() { + _has_bits_[0] |= 0x00000020u; +} +inline void FieldOptions::clear_has_csharp_property_name() { + _has_bits_[0] &= ~0x00000020u; +} +inline void FieldOptions::clear_csharp_property_name() { + csharp_property_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_csharp_property_name(); +} +inline const ::std::string& FieldOptions::csharp_property_name() const { + // @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.csharp_property_name) + return csharp_property_name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline void FieldOptions::set_csharp_property_name(const ::std::string& value) { + set_has_csharp_property_name(); + csharp_property_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.csharp_property_name) +} +inline void FieldOptions::set_csharp_property_name(const char* value) { + set_has_csharp_property_name(); + csharp_property_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:google.protobuf.FieldOptions.csharp_property_name) +} +inline void FieldOptions::set_csharp_property_name(const char* value, size_t size) { + set_has_csharp_property_name(); + csharp_property_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldOptions.csharp_property_name) +} +inline ::std::string* FieldOptions::mutable_csharp_property_name() { + set_has_csharp_property_name(); + // @@protoc_insertion_point(field_mutable:google.protobuf.FieldOptions.csharp_property_name) + return csharp_property_name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline ::std::string* FieldOptions::release_csharp_property_name() { + clear_has_csharp_property_name(); + return csharp_property_name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline void FieldOptions::set_allocated_csharp_property_name(::std::string* csharp_property_name) { + if (csharp_property_name != NULL) { + set_has_csharp_property_name(); + } else { + clear_has_csharp_property_name(); + } + csharp_property_name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), csharp_property_name); + // @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldOptions.csharp_property_name) +} + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; inline int FieldOptions::uninterpreted_option_size() const { return uninterpreted_option_.size(); diff --git a/src/google/protobuf/descriptor.proto b/src/google/protobuf/descriptor.proto index d3f7fae9..5b719b63 100644 --- a/src/google/protobuf/descriptor.proto +++ b/src/google/protobuf/descriptor.proto @@ -354,55 +354,12 @@ message FileOptions { // Namespace for generated classes; defaults to the package. optional string csharp_namespace = 37; - // Name of the "umbrella" class used for metadata about all - // the messages within this file. Default is based on the name - // of the file. - optional string csharp_umbrella_classname = 38; - - // Whether classes should be public (true) or internal (false) - optional bool csharp_public_classes = 39 [default = true]; - - // Whether to generate a single file for everything within the - // .proto file (false), or one file per message (true). - // This option is not currently honored; please log a feature - // request if you really want it. - optional bool csharp_multiple_files = 40; - - // Whether to nest messages within a single umbrella class (true) - // or create the umbrella class as a peer, with messages as - // top-level classes in the namespace (false) - optional bool csharp_nest_classes = 41; - - // Generate appropriate support for Code Contracts - // (Ongoing; support should improve over time) - optional bool csharp_code_contracts = 42; - - // Create subdirectories for namespaces, e.g. namespace "Foo.Bar" - // would generate files within [output directory]/Foo/Bar - optional bool csharp_expand_namespace_directories = 43; - - // Generate attributes indicating non-CLS-compliance - optional bool csharp_cls_compliance = 44 [default = true]; - - // Generate messages/builders with the [Serializable] attribute - optional bool csharp_add_serializable = 45 [default = false]; - - // Generates a private ctor for Message types - optional bool csharp_generate_private_ctor = 46 [default = true]; - - // The extension that should be appended to the umbrella_classname when creating files. - optional string csharp_file_extension = 47 [default = ".cs"]; - // A nested namespace for the umbrella class. Helpful for name collisions caused by // umbrella_classname conflicting with an existing type. This will be automatically // set to 'Proto' if a collision is detected with types being generated. This value // is ignored when nest_classes == true optional string csharp_umbrella_namespace = 48; - // Used to add the System.Runtime.CompilerServices.CompilerGeneratedAttribute and - // System.CodeDom.Compiler.GeneratedCodeAttribute attributes to generated code. - optional bool csharp_generated_code_attributes = 49 [default = false]; - // The parser stores options it doesn't recognize here. See above. repeated UninterpretedOption uninterpreted_option = 999; @@ -533,7 +490,11 @@ message FieldOptions { // For Google-internal migration only. Do not use. optional bool weak = 10 [default=false]; - + // Provides the ability to override the name of the property + // generated for this field. This is applied to all properties + // and methods to do with this field, including HasFoo, FooCount, + // FooList etc. + optional string csharp_property_name = 11; // The parser stores options it doesn't recognize here. See above. repeated UninterpretedOption uninterpreted_option = 999; -- cgit v1.2.3 From 44664bb705fc704ac3cc5a745d200145a4897ed2 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 13 Apr 2015 12:40:48 -0700 Subject: updated C# codegen to use restricted set of csharp options from descriptor.proto --- .../protobuf/compiler/csharp/csharp_extension.cc | 2 +- .../protobuf/compiler/csharp/csharp_field_base.cc | 2 +- .../protobuf/compiler/csharp/csharp_generator.cc | 6 +++-- .../protobuf/compiler/csharp/csharp_helpers.cc | 19 +++----------- .../protobuf/compiler/csharp/csharp_message.cc | 15 ++--------- .../csharp/csharp_source_generator_base.cc | 5 ++++ .../compiler/csharp/csharp_source_generator_base.h | 1 + .../compiler/csharp/csharp_umbrella_class.cc | 29 +++++++--------------- 8 files changed, 27 insertions(+), 52 deletions(-) (limited to 'src') diff --git a/src/google/protobuf/compiler/csharp/csharp_extension.cc b/src/google/protobuf/compiler/csharp/csharp_extension.cc index f929f49f..b089aed1 100644 --- a/src/google/protobuf/compiler/csharp/csharp_extension.cc +++ b/src/google/protobuf/compiler/csharp/csharp_extension.cc @@ -63,7 +63,7 @@ ExtensionGenerator::~ExtensionGenerator() { } void ExtensionGenerator::Generate(Writer* writer) { - if (descriptor_->file()->options().csharp_cls_compliance() + if (cls_compliance() && (GetFieldConstantName(descriptor_).substr(0, 1) == "_")) { writer->WriteLine("[global::System.CLSCompliant(false)]"); } diff --git a/src/google/protobuf/compiler/csharp/csharp_field_base.cc b/src/google/protobuf/compiler/csharp/csharp_field_base.cc index 48af999c..d7eb5d34 100644 --- a/src/google/protobuf/compiler/csharp/csharp_field_base.cc +++ b/src/google/protobuf/compiler/csharp/csharp_field_base.cc @@ -84,7 +84,7 @@ void FieldGeneratorBase::AddPublicMemberAttributes(Writer* writer) { } void FieldGeneratorBase::AddClsComplianceCheck(Writer* writer) { - if (!is_cls_compliant() && descriptor_->file()->options().csharp_cls_compliance()) { + if (cls_compliance() && !is_cls_compliant()) { writer->WriteLine("[global::System.CLSCompliant(false)]"); } } diff --git a/src/google/protobuf/compiler/csharp/csharp_generator.cc b/src/google/protobuf/compiler/csharp/csharp_generator.cc index 0cac22df..deb3d205 100644 --- a/src/google/protobuf/compiler/csharp/csharp_generator.cc +++ b/src/google/protobuf/compiler/csharp/csharp_generator.cc @@ -61,9 +61,11 @@ bool Generator::Generate( GeneratorContext* generator_context, string* error) const { - // TODO: parse generator parameters... + // TODO(jtattermusch): parse generator parameters: + // cls_compliance + // file_extension - // TODO: file output file naming logic + // TODO(jtattermusch): rework output file naming logic std::string filename = StripDotProto(file->name()) + ".cs"; scoped_ptr output( diff --git a/src/google/protobuf/compiler/csharp/csharp_helpers.cc b/src/google/protobuf/compiler/csharp/csharp_helpers.cc index 49ae2c94..ac258f04 100644 --- a/src/google/protobuf/compiler/csharp/csharp_helpers.cc +++ b/src/google/protobuf/compiler/csharp/csharp_helpers.cc @@ -122,16 +122,12 @@ std::string GetUmbrellaClassNameInternal(const std::string& proto_file) { } std::string GetFileUmbrellaClassname(const FileDescriptor* descriptor) { - if (descriptor->options().has_csharp_umbrella_classname()) { - return descriptor->options().csharp_umbrella_namespace(); - } else { - return GetUmbrellaClassNameInternal(descriptor->name()); - } + // umbrella_classname can no longer be set using message option. + return GetUmbrellaClassNameInternal(descriptor->name()); } std::string GetFileUmbrellaNamespace(const FileDescriptor* descriptor) { - if (!descriptor->options().csharp_nest_classes() - && !descriptor->options().has_csharp_umbrella_namespace()) { + if (!descriptor->options().has_csharp_umbrella_namespace()) { bool collision = false; // TODO(jtattermusch): detect collisions! // foreach (IDescriptor d in MessageTypes) @@ -196,12 +192,6 @@ std::string UnderscoresToPascalCase(const std::string& input) { std::string ToCSharpName(const std::string& name, const FileDescriptor* file) { std::string result = GetFileNamespace(file); - if (file->options().csharp_nest_classes()) { - if (result != "") { - result += "."; - } - result += GetFileUmbrellaClassname(file); - } if (result != "") { result += '.'; } @@ -233,8 +223,7 @@ std::string GetQualifiedUmbrellaClassName(const FileDescriptor* descriptor) { std::string umbrellaClassname = GetFileUmbrellaClassname(descriptor); std::string fullName = umbrellaClassname; - if (!descriptor->options().csharp_nest_classes() - && !umbrellaNamespace.empty()) { + if (!umbrellaNamespace.empty()) { fullName = umbrellaNamespace + "." + umbrellaClassname; } return fullName; diff --git a/src/google/protobuf/compiler/csharp/csharp_message.cc b/src/google/protobuf/compiler/csharp/csharp_message.cc index 2df3bd2d..126ed22d 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message.cc @@ -118,9 +118,7 @@ void MessageGenerator::GenerateStaticVariables(Writer* writer) { if (!use_lite_runtime()) { // The descriptor for this type. - std::string access = - descriptor_->file()->options().csharp_nest_classes() ? - "private" : "internal"; + std::string access = "internal"; writer->WriteLine( "$0$ static pbd::MessageDescriptor internal__$1$__Descriptor;", access, identifier); @@ -175,9 +173,6 @@ void MessageGenerator::GenerateStaticVariableInitializers(Writer* writer) { } void MessageGenerator::Generate(Writer* writer) { - if (descriptor_->file()->options().csharp_add_serializable()) { - writer->WriteLine("[global::System.SerializableAttribute()]"); - } writer->WriteLine( "[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]"); WriteGeneratedCodeAttributes(writer); @@ -187,9 +182,6 @@ void MessageGenerator::Generate(Writer* writer) { descriptor_->extension_range_count() > 0 ? "Extendable" : "Generated", runtime_suffix()); writer->Indent(); - if (descriptor_->file()->options().csharp_generate_private_ctor()) { - writer->WriteLine("private $0$() { }", class_name()); - } // Must call MakeReadOnly() to make sure all lists are made read-only writer->WriteLine( "private static readonly $0$ defaultInstance = new $0$().MakeReadOnly();", @@ -271,7 +263,7 @@ void MessageGenerator::Generate(Writer* writer) { for (int i = 0; i < descriptor_->field_count(); i++) { const FieldDescriptor* fieldDescriptor = descriptor_->field(i); // TODO(jtattermusch): same code for cls compliance is in csharp_extension - if (descriptor_->file()->options().csharp_cls_compliance() + if (cls_compliance() && GetFieldConstantName(fieldDescriptor)[0] == '_') { writer->WriteLine("[global::System.CLSCompliant(false)]"); } @@ -557,9 +549,6 @@ void MessageGenerator::GenerateBuilder(Writer* writer) { writer->WriteLine(" return new Builder(prototype);"); writer->WriteLine("}"); writer->WriteLine(); - if (descriptor_->file()->options().csharp_add_serializable()) { - writer->WriteLine("[global::System.SerializableAttribute()]"); - } writer->WriteLine( "[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]"); WriteGeneratedCodeAttributes(writer); 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 35c28141..ed016b46 100644 --- a/src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc +++ b/src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc @@ -76,6 +76,11 @@ std::string SourceGeneratorBase::class_access_level() { return "public"; } +bool SourceGeneratorBase::cls_compliance() { + // TODO(jtattermusch): implement this based on "cls_compliance" cmdline param. + return true; +} + } // namespace csharp } // namespace compiler } // namespace protobuf 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 1955394e..dbc65d04 100644 --- a/src/google/protobuf/compiler/csharp/csharp_source_generator_base.h +++ b/src/google/protobuf/compiler/csharp/csharp_source_generator_base.h @@ -48,6 +48,7 @@ class SourceGeneratorBase { virtual ~SourceGeneratorBase(); std::string class_access_level(); + bool cls_compliance(); bool optimize_size() { return optimizeSize_; diff --git a/src/google/protobuf/compiler/csharp/csharp_umbrella_class.cc b/src/google/protobuf/compiler/csharp/csharp_umbrella_class.cc index ead6c1a9..358cfa4f 100644 --- a/src/google/protobuf/compiler/csharp/csharp_umbrella_class.cc +++ b/src/google/protobuf/compiler/csharp/csharp_umbrella_class.cc @@ -86,17 +86,14 @@ void UmbrellaClassGenerator::Generate(Writer* writer) { } else { WriteLiteExtensions(writer); } - // The class declaration either gets closed before or after the children are written. - if (!file_->options().csharp_nest_classes()) { + // Close the class declaration. + writer->Outdent(); + writer->WriteLine("}"); + + // Close the namespace around the umbrella class if defined + if (!umbrellaNamespace_.empty()) { writer->Outdent(); writer->WriteLine("}"); - - // Close the namespace around the umbrella class if defined - if (!file_->options().csharp_nest_classes() - && !umbrellaNamespace_.empty()) { - writer->Outdent(); - writer->WriteLine("}"); - } } // write children: Enums @@ -121,12 +118,8 @@ void UmbrellaClassGenerator::Generate(Writer* writer) { writer->WriteLine(); } - // TODO(jtattermusch): add support for generating services. - //WriteChildren(writer, "Services", Descriptor.Services); - if (file_->options().csharp_nest_classes()) { - writer->Outdent(); - writer->WriteLine("}"); - } + // TODO(jtattermusch): add insertion point for services. + if (!namespace_.empty()) { writer->Outdent(); writer->WriteLine("}"); @@ -155,16 +148,12 @@ void UmbrellaClassGenerator::WriteIntroduction(Writer* writer) { } // Add the namespace around the umbrella class if defined - if (!file_->options().csharp_nest_classes() && !umbrellaNamespace_.empty()) { + if (!umbrellaNamespace_.empty()) { writer->WriteLine("namespace $0$ {", umbrellaNamespace_); writer->Indent(); writer->WriteLine(); } - if (file_->options().csharp_code_contracts()) { - writer->WriteLine( - "[global::System.Diagnostics.Contracts.ContractVerificationAttribute(false)]"); - } writer->WriteLine( "[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]"); WriteGeneratedCodeAttributes(writer); -- cgit v1.2.3 From 16a3e2b91423c32680b3dc904c839853c9dc8cc8 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 13 Apr 2015 13:03:23 -0700 Subject: enable overriding of property name using csharp_property_name --- src/google/protobuf/compiler/csharp/csharp_helpers.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/google/protobuf/compiler/csharp/csharp_helpers.cc b/src/google/protobuf/compiler/csharp/csharp_helpers.cc index ac258f04..55ce3285 100644 --- a/src/google/protobuf/compiler/csharp/csharp_helpers.cc +++ b/src/google/protobuf/compiler/csharp/csharp_helpers.cc @@ -253,7 +253,9 @@ std::string GetFieldConstantName(const FieldDescriptor* field) { } std::string GetPropertyName(const FieldDescriptor* descriptor) { - // TODO: fix this. + if (descriptor->options().has_csharp_property_name()) { + return descriptor->options().csharp_property_name(); + } std::string property_name = UnderscoresToPascalCase(GetFieldName(descriptor)); if (property_name == descriptor->containing_type()->name()) { property_name += "_"; -- cgit v1.2.3 From 8cec65e761a90a6370e4f4439abd072f43834505 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 13 Apr 2015 14:21:33 -0700 Subject: added support for deprecated fields, reworded some todos --- src/google/protobuf/compiler/csharp/csharp_extension.cc | 4 ++-- src/google/protobuf/compiler/csharp/csharp_field_base.cc | 9 ++++----- src/google/protobuf/compiler/csharp/csharp_message.cc | 1 - 3 files changed, 6 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/google/protobuf/compiler/csharp/csharp_extension.cc b/src/google/protobuf/compiler/csharp/csharp_extension.cc index b089aed1..8a30144d 100644 --- a/src/google/protobuf/compiler/csharp/csharp_extension.cc +++ b/src/google/protobuf/compiler/csharp/csharp_extension.cc @@ -73,7 +73,7 @@ void ExtensionGenerator::Generate(Writer* writer) { SimpleItoa(descriptor_->number())); if (use_lite_runtime()) { - // TODO(jtattermusch): check the argument... + // TODO(jtattermusch): include the following check //if (Descriptor.MappedType == MappedType.Message && Descriptor.MessageType.Options.MessageSetWireFormat) //{ // throw new ArgumentException( @@ -122,7 +122,7 @@ void ExtensionGenerator::GenerateStaticVariableInitializers(Writer* writer) { } writer->WriteLine("$0$,", default_val); } - // TODO(jtattermusch): + // TODO(jtattermusch): include following snippet //writer.WriteLine("{0},", // (Descriptor.MappedType == MappedType.Message) ? type + ".DefaultInstance" : "null"); //writer.WriteLine("{0},", diff --git a/src/google/protobuf/compiler/csharp/csharp_field_base.cc b/src/google/protobuf/compiler/csharp/csharp_field_base.cc index d7eb5d34..ed4d55c4 100644 --- a/src/google/protobuf/compiler/csharp/csharp_field_base.cc +++ b/src/google/protobuf/compiler/csharp/csharp_field_base.cc @@ -61,11 +61,10 @@ FieldGeneratorBase::~FieldGeneratorBase() { } void FieldGeneratorBase::AddDeprecatedFlag(Writer* writer) { - // TODO(jtattermusch): - //if (IsObsolete) - //{ - // writer.WriteLine("[global::System.ObsoleteAttribute()]"); - //} + if (descriptor_->options().deprecated()) + { + writer->WriteLine("[global::System.ObsoleteAttribute()]"); + } } void FieldGeneratorBase::AddNullCheck(Writer* writer) { diff --git a/src/google/protobuf/compiler/csharp/csharp_message.cc b/src/google/protobuf/compiler/csharp/csharp_message.cc index 126ed22d..7156c9e5 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message.cc @@ -81,7 +81,6 @@ MessageGenerator::~MessageGenerator() { } std::string MessageGenerator::class_name() { - // TODO: check correctness. return descriptor_->name(); } -- cgit v1.2.3 From f61e1791c0df2a518103b5924ee76098d5b72fab Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 13 Apr 2015 15:10:07 -0700 Subject: output file naming logic, configurable file extension, comment rewording --- .../protobuf/compiler/csharp/csharp_generator.cc | 27 +++++++++++++++++----- .../protobuf/compiler/csharp/csharp_helpers.cc | 2 +- .../csharp/csharp_source_generator_base.cc | 11 ++------- 3 files changed, 24 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/google/protobuf/compiler/csharp/csharp_generator.cc b/src/google/protobuf/compiler/csharp/csharp_generator.cc index deb3d205..61ed37ad 100644 --- a/src/google/protobuf/compiler/csharp/csharp_generator.cc +++ b/src/google/protobuf/compiler/csharp/csharp_generator.cc @@ -49,6 +49,11 @@ namespace protobuf { namespace compiler { namespace csharp { +std::string GetOutputFile(const google::protobuf::FileDescriptor* file, const std::string file_extension) +{ + return GetFileUmbrellaClassname(file) + file_extension; +} + void GenerateFile(const google::protobuf::FileDescriptor* file, Writer* writer) { UmbrellaClassGenerator umbrellaGenerator(file); @@ -61,13 +66,23 @@ bool Generator::Generate( GeneratorContext* generator_context, string* error) const { - // TODO(jtattermusch): parse generator parameters: - // cls_compliance - // file_extension + vector > options; + ParseGeneratorParameter(parameter, &options); + + std::string file_extension = ".cs"; + for (int i = 0; i < options.size(); i++) { + if (options[i].first == "no_cls_compliance") { + *error = "Turning off CLS compliance is not implemented yet."; + return false; + } else if (options[i].first == "file_extension") { + file_extension = options[i].second; + } else { + *error = "Unknown generator option: " + options[i].first; + return false; + } + } - // TODO(jtattermusch): rework output file naming logic - std::string filename = - StripDotProto(file->name()) + ".cs"; + std::string filename = GetOutputFile(file, file_extension); scoped_ptr output( generator_context->Open(filename)); io::Printer printer(output.get(), '$'); diff --git a/src/google/protobuf/compiler/csharp/csharp_helpers.cc b/src/google/protobuf/compiler/csharp/csharp_helpers.cc index 55ce3285..5829c61e 100644 --- a/src/google/protobuf/compiler/csharp/csharp_helpers.cc +++ b/src/google/protobuf/compiler/csharp/csharp_helpers.cc @@ -364,7 +364,7 @@ FieldGeneratorBase* CreateFieldGenerator(const FieldDescriptor* descriptor, } bool HasRequiredFields(const Descriptor* descriptor) { - // TODO(jtattermusch): implement this. + // TODO(jtattermusch): implement HasRequiredFields logic. return true; } 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 ed016b46..e39911ee 100644 --- a/src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc +++ b/src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc @@ -62,18 +62,11 @@ SourceGeneratorBase::~SourceGeneratorBase() { } void SourceGeneratorBase::WriteGeneratedCodeAttributes(Writer* writer) { - // TODO(jtattermusch): - //if (descriptor.File.CSharpOptions.GeneratedCodeAttributes) - // { - // writer.WriteLine("[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]"); - // writer.WriteLine("[global::System.CodeDom.Compiler.GeneratedCodeAttribute(\"{0}\", \"{1}\")]", - // GetType().Assembly.GetName().Name, GetType().Assembly.GetName().Version); - // } + // This hook can be used to reintroduce generated code attributes in the future. } std::string SourceGeneratorBase::class_access_level() { - // TODO(jtattermusch): implement this - return "public"; + return "public"; // public_classes is always on. } bool SourceGeneratorBase::cls_compliance() { -- cgit v1.2.3 From d92de1742d2bbc77058637709140717e00f011da Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 13 Apr 2015 15:28:43 -0700 Subject: creating private ctor for builders is now the default (as it used to be for old codegen) --- src/google/protobuf/compiler/csharp/csharp_message.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/google/protobuf/compiler/csharp/csharp_message.cc b/src/google/protobuf/compiler/csharp/csharp_message.cc index 7156c9e5..66b8c2d5 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message.cc @@ -181,6 +181,7 @@ void MessageGenerator::Generate(Writer* writer) { descriptor_->extension_range_count() > 0 ? "Extendable" : "Generated", runtime_suffix()); writer->Indent(); + writer->WriteLine("private $0$() { }", class_name()); // Private ctor. // Must call MakeReadOnly() to make sure all lists are made read-only writer->WriteLine( "private static readonly $0$ defaultInstance = new $0$().MakeReadOnly();", -- cgit v1.2.3 From db9060dc61ce72f3747197644f31a57b9ddbf6a4 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 13 Apr 2015 15:48:40 -0700 Subject: addressed TODO for lite runtime --- .../protobuf/compiler/csharp/csharp_extension.cc | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/google/protobuf/compiler/csharp/csharp_extension.cc b/src/google/protobuf/compiler/csharp/csharp_extension.cc index 8a30144d..5d38f52e 100644 --- a/src/google/protobuf/compiler/csharp/csharp_extension.cc +++ b/src/google/protobuf/compiler/csharp/csharp_extension.cc @@ -122,13 +122,17 @@ void ExtensionGenerator::GenerateStaticVariableInitializers(Writer* writer) { } writer->WriteLine("$0$,", default_val); } - // TODO(jtattermusch): include following snippet - //writer.WriteLine("{0},", - // (Descriptor.MappedType == MappedType.Message) ? type + ".DefaultInstance" : "null"); - //writer.WriteLine("{0},", - // (Descriptor.MappedType == MappedType.Enum) ? "new EnumLiteMap<" + type + ">()" : "null"); - //writer.WriteLine("{0}.{1}FieldNumber,", scope, name); - //writer.Write("pbd::FieldType.{0}", Descriptor.FieldType); + writer->WriteLine( + "$0$,", + (GetCSharpType(descriptor_->type()) == CSHARPTYPE_MESSAGE) ? + type_name() + ".DefaultInstance" : "null"); + writer->WriteLine( + "$0$,", + (GetCSharpType(descriptor_->type()) == CSHARPTYPE_ENUM) ? + "new EnumLiteMap<" + type_name() + ">()" : "null"); + writer->WriteLine("$0$.$1$FieldNumber,", scope_, + GetPropertyName(descriptor_)); + writer->Write("pbd::FieldType.$0$", capitalized_type_name()); if (descriptor_->is_repeated()) { writer->WriteLine(","); writer->Write(descriptor_->is_packed() ? "true" : "false"); -- cgit v1.2.3 From 5ac8de5b46a7b2adb81f957dfb78c612137d9ffb Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 13 Apr 2015 16:12:29 -0700 Subject: implemented HasRequiredFields logic --- .../protobuf/compiler/csharp/csharp_helpers.cc | 39 ++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/google/protobuf/compiler/csharp/csharp_helpers.cc b/src/google/protobuf/compiler/csharp/csharp_helpers.cc index 5829c61e..fd6e3722 100644 --- a/src/google/protobuf/compiler/csharp/csharp_helpers.cc +++ b/src/google/protobuf/compiler/csharp/csharp_helpers.cc @@ -363,9 +363,44 @@ 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) { - // TODO(jtattermusch): implement HasRequiredFields logic. - return true; + std::set already_seen; + return HasRequiredFields(descriptor, &already_seen); } } // namespace java -- cgit v1.2.3 From 7cc05ecb3a6fecf97604ab89803e7cbb34838268 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 13 Apr 2015 16:32:54 -0700 Subject: fixing implementation of GetFileUmbrellaNamespace --- .../protobuf/compiler/csharp/csharp_helpers.cc | 40 ++++++++++++---------- 1 file changed, 22 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/google/protobuf/compiler/csharp/csharp_helpers.cc b/src/google/protobuf/compiler/csharp/csharp_helpers.cc index fd6e3722..c7e9e4cc 100644 --- a/src/google/protobuf/compiler/csharp/csharp_helpers.cc +++ b/src/google/protobuf/compiler/csharp/csharp_helpers.cc @@ -127,26 +127,30 @@ std::string GetFileUmbrellaClassname(const FileDescriptor* descriptor) { } std::string GetFileUmbrellaNamespace(const FileDescriptor* descriptor) { - if (!descriptor->options().has_csharp_umbrella_namespace()) { - bool collision = false; - // TODO(jtattermusch): detect collisions! -// foreach (IDescriptor d in MessageTypes) -// { -// collision |= d.Name == builder.UmbrellaClassname; -// } -// foreach (IDescriptor d in Services) -// { -// collision |= d.Name == builder.UmbrellaClassname; -// } -// foreach (IDescriptor d in EnumTypes) -// { -// collision |= d.Name == builder.UmbrellaClassname; -// } - if (collision) { - return "Proto"; + if (descriptor->options().has_csharp_umbrella_namespace()) { + return descriptor->options().csharp_umbrella_namespace(); + } + bool collision = false; + std::string umbrella_classname = GetFileUmbrellaClassname(descriptor); + for(int i = 0; i < descriptor->message_type_count(); i++) { + if (descriptor->message_type(i)->name() == umbrella_classname) { + collision = true; + break; + } + } + for (int i = 0; i < descriptor->service_count(); i++) { + if (descriptor->service(i)->name() == umbrella_classname) { + collision = true; + break; + } + } + for (int i = 0; i < descriptor->enum_type_count(); i++) { + if (descriptor->enum_type(i)->name() == umbrella_classname) { + collision = true; + break; } } - return ""; + return collision ? "Proto" : ""; } // TODO(jtattermusch): can we reuse a utility function? -- cgit v1.2.3 From 333d200a96b067dcc43f249d957cf1efd52bf592 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 13 Apr 2015 17:41:03 -0700 Subject: integrate CalcSerializedSize() fix from protobuf-csharp-port issue 84 --- src/google/protobuf/compiler/csharp/csharp_message.cc | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/google/protobuf/compiler/csharp/csharp_message.cc b/src/google/protobuf/compiler/csharp/csharp_message.cc index 66b8c2d5..f7c8ddfb 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message.cc @@ -378,7 +378,7 @@ void MessageGenerator::GenerateMessageSerializationMethods(Writer* writer) { "public override void WriteTo(pb::ICodedOutputStream output) {"); writer->Indent(); // Make sure we've computed the serialized length, so that packed fields are generated correctly. - writer->WriteLine("int size = SerializedSize;"); + writer->WriteLine("CalcSerializedSize();"); writer->WriteLine("string[] field_names = _$0$FieldNames;", UnderscoresToCamelCase(class_name(), false)); if (descriptor_->extension_range_count()) { @@ -421,6 +421,17 @@ void MessageGenerator::GenerateMessageSerializationMethods(Writer* writer) { writer->Indent(); writer->WriteLine("int size = memoizedSerializedSize;"); writer->WriteLine("if (size != -1) return size;"); + writer->WriteLine("return CalcSerializedSize();"); + writer->Outdent(); + writer->WriteLine("}"); + writer->Outdent(); + writer->WriteLine("}"); + writer->WriteLine(); + + writer->WriteLine("private int CalcSerializedSize() {"); + writer->Indent(); + writer->WriteLine("int size = memoizedSerializedSize;"); + writer->WriteLine("if (size != -1) return size;"); writer->WriteLine(); writer->WriteLine("size = 0;"); for (int i = 0; i < descriptor_->field_count(); i++) { @@ -443,9 +454,6 @@ void MessageGenerator::GenerateMessageSerializationMethods(Writer* writer) { writer->WriteLine("return size;"); writer->Outdent(); writer->WriteLine("}"); - writer->Outdent(); - writer->WriteLine("}"); - writer->WriteLine(); } void MessageGenerator::GenerateSerializeOneField( -- cgit v1.2.3 From 2c2f76c50f7122f2c3f4adbde021ad4f110cd066 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 16 Apr 2015 15:28:32 -0700 Subject: fixing field number of csharp_umbrella_namespace option --- src/google/protobuf/descriptor.pb.cc | 22 +++++++++++----------- src/google/protobuf/descriptor.pb.h | 6 +++--- src/google/protobuf/descriptor.proto | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/google/protobuf/descriptor.pb.cc b/src/google/protobuf/descriptor.pb.cc index 477fe1b7..2aac269b 100644 --- a/src/google/protobuf/descriptor.pb.cc +++ b/src/google/protobuf/descriptor.pb.cc @@ -679,7 +679,7 @@ void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto() { "\n\ndeprecated\030\027 \001(\010:\005false\022\037\n\020cc_enable_a" "renas\030\037 \001(\010:\005false\022\031\n\021objc_class_prefix\030" "$ \001(\t\022\030\n\020csharp_namespace\030% \001(\t\022!\n\031cshar" - "p_umbrella_namespace\0300 \001(\t\022C\n\024uninterpre" + "p_umbrella_namespace\030& \001(\t\022C\n\024uninterpre" "ted_option\030\347\007 \003(\0132$.google.protobuf.Unin" "terpretedOption\":\n\014OptimizeMode\022\t\n\005SPEED" "\020\001\022\r\n\tCODE_SIZE\020\002\022\020\n\014LITE_RUNTIME\020\003*\t\010\350\007" @@ -7381,13 +7381,13 @@ bool FileOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(386)) goto parse_csharp_umbrella_namespace; + if (input->ExpectTag(306)) goto parse_csharp_umbrella_namespace; break; } - // optional string csharp_umbrella_namespace = 48; - case 48: { - if (tag == 386) { + // optional string csharp_umbrella_namespace = 38; + case 38: { + if (tag == 306) { parse_csharp_umbrella_namespace: DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_csharp_umbrella_namespace())); @@ -7542,14 +7542,14 @@ void FileOptions::SerializeWithCachedSizes( 37, this->csharp_namespace(), output); } - // optional string csharp_umbrella_namespace = 48; + // optional string csharp_umbrella_namespace = 38; if (has_csharp_umbrella_namespace()) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->csharp_umbrella_namespace().data(), this->csharp_umbrella_namespace().length(), ::google::protobuf::internal::WireFormat::SERIALIZE, "google.protobuf.FileOptions.csharp_umbrella_namespace"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( - 48, this->csharp_umbrella_namespace(), output); + 38, this->csharp_umbrella_namespace(), output); } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; @@ -7673,7 +7673,7 @@ void FileOptions::SerializeWithCachedSizes( 37, this->csharp_namespace(), target); } - // optional string csharp_umbrella_namespace = 48; + // optional string csharp_umbrella_namespace = 38; if (has_csharp_umbrella_namespace()) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->csharp_umbrella_namespace().data(), this->csharp_umbrella_namespace().length(), @@ -7681,7 +7681,7 @@ void FileOptions::SerializeWithCachedSizes( "google.protobuf.FileOptions.csharp_umbrella_namespace"); target = ::google::protobuf::internal::WireFormatLite::WriteStringToArray( - 48, this->csharp_umbrella_namespace(), target); + 38, this->csharp_umbrella_namespace(), target); } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; @@ -7790,7 +7790,7 @@ int FileOptions::ByteSize() const { this->csharp_namespace()); } - // optional string csharp_umbrella_namespace = 48; + // optional string csharp_umbrella_namespace = 38; if (has_csharp_umbrella_namespace()) { total_size += 2 + ::google::protobuf::internal::WireFormatLite::StringSize( @@ -8434,7 +8434,7 @@ void FileOptions::InternalSwap(FileOptions* other) { // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.csharp_namespace) } -// optional string csharp_umbrella_namespace = 48; +// optional string csharp_umbrella_namespace = 38; bool FileOptions::has_csharp_umbrella_namespace() const { return (_has_bits_[0] & 0x00004000u) != 0; } diff --git a/src/google/protobuf/descriptor.pb.h b/src/google/protobuf/descriptor.pb.h index 6082d182..106fc0b3 100644 --- a/src/google/protobuf/descriptor.pb.h +++ b/src/google/protobuf/descriptor.pb.h @@ -1849,10 +1849,10 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message { ::std::string* release_csharp_namespace(); void set_allocated_csharp_namespace(::std::string* csharp_namespace); - // optional string csharp_umbrella_namespace = 48; + // optional string csharp_umbrella_namespace = 38; bool has_csharp_umbrella_namespace() const; void clear_csharp_umbrella_namespace(); - static const int kCsharpUmbrellaNamespaceFieldNumber = 48; + static const int kCsharpUmbrellaNamespaceFieldNumber = 38; const ::std::string& csharp_umbrella_namespace() const; void set_csharp_umbrella_namespace(const ::std::string& value); void set_csharp_umbrella_namespace(const char* value); @@ -5600,7 +5600,7 @@ inline void FileOptions::set_allocated_csharp_namespace(::std::string* csharp_na // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.csharp_namespace) } -// optional string csharp_umbrella_namespace = 48; +// optional string csharp_umbrella_namespace = 38; inline bool FileOptions::has_csharp_umbrella_namespace() const { return (_has_bits_[0] & 0x00004000u) != 0; } diff --git a/src/google/protobuf/descriptor.proto b/src/google/protobuf/descriptor.proto index 5b719b63..81c8d99f 100644 --- a/src/google/protobuf/descriptor.proto +++ b/src/google/protobuf/descriptor.proto @@ -358,7 +358,7 @@ message FileOptions { // umbrella_classname conflicting with an existing type. This will be automatically // set to 'Proto' if a collision is detected with types being generated. This value // is ignored when nest_classes == true - optional string csharp_umbrella_namespace = 48; + optional string csharp_umbrella_namespace = 38; // The parser stores options it doesn't recognize here. See above. repeated UninterpretedOption uninterpreted_option = 999; -- cgit v1.2.3 From abcde243fe613246aa3d7c0bec21569c0639c95d Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 16 Apr 2015 15:32:36 -0700 Subject: Fixed comment for csharp_umbrella_namespace (nest_classes has been removed) --- src/google/protobuf/descriptor.proto | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/google/protobuf/descriptor.proto b/src/google/protobuf/descriptor.proto index 81c8d99f..b16a1630 100644 --- a/src/google/protobuf/descriptor.proto +++ b/src/google/protobuf/descriptor.proto @@ -356,8 +356,7 @@ message FileOptions { // A nested namespace for the umbrella class. Helpful for name collisions caused by // umbrella_classname conflicting with an existing type. This will be automatically - // set to 'Proto' if a collision is detected with types being generated. This value - // is ignored when nest_classes == true + // set to 'Proto' if a collision is detected with types being generated. optional string csharp_umbrella_namespace = 38; // The parser stores options it doesn't recognize here. See above. -- cgit v1.2.3 From b6555b1da0cf3b00fcfd139f4465861268a44ed2 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 17 Apr 2015 10:00:38 -0700 Subject: fix: do not mention umbrella_classname in comment --- src/google/protobuf/descriptor.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/google/protobuf/descriptor.proto b/src/google/protobuf/descriptor.proto index b16a1630..e039e112 100644 --- a/src/google/protobuf/descriptor.proto +++ b/src/google/protobuf/descriptor.proto @@ -355,7 +355,7 @@ message FileOptions { optional string csharp_namespace = 37; // A nested namespace for the umbrella class. Helpful for name collisions caused by - // umbrella_classname conflicting with an existing type. This will be automatically + // its name conflicting with an existing type. This will be automatically // set to 'Proto' if a collision is detected with types being generated. optional string csharp_umbrella_namespace = 38; -- cgit v1.2.3 From b36420addb9e1453bd60b2379a4ecf106283b7c3 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 17 Apr 2015 10:20:35 -0700 Subject: one more fix to csharp_umbrella_namespace comment --- src/google/protobuf/descriptor.proto | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/google/protobuf/descriptor.proto b/src/google/protobuf/descriptor.proto index e039e112..33e8a322 100644 --- a/src/google/protobuf/descriptor.proto +++ b/src/google/protobuf/descriptor.proto @@ -354,9 +354,11 @@ message FileOptions { // Namespace for generated classes; defaults to the package. optional string csharp_namespace = 37; - // A nested namespace for the umbrella class. Helpful for name collisions caused by - // its name conflicting with an existing type. This will be automatically - // set to 'Proto' if a collision is detected with types being generated. + // A nested namespace for the umbrella class, which contains metadata about + // all the messages within the file. This option is helpful for name + // collisions between the umbrella class and an existing type. This will be + // automatically set to 'Proto' if a collision is detected with types being + // generated. optional string csharp_umbrella_namespace = 38; // The parser stores options it doesn't recognize here. See above. -- cgit v1.2.3 From 83a5991d12ecabc3388c99d121892a488ea8ee97 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 17 Apr 2015 10:53:06 -0700 Subject: removing csharp_property_name field option --- .../protobuf/compiler/csharp/csharp_helpers.cc | 4 +- src/google/protobuf/descriptor.pb.cc | 180 ++++----------------- src/google/protobuf/descriptor.pb.h | 68 -------- src/google/protobuf/descriptor.proto | 6 - 4 files changed, 35 insertions(+), 223 deletions(-) (limited to 'src') diff --git a/src/google/protobuf/compiler/csharp/csharp_helpers.cc b/src/google/protobuf/compiler/csharp/csharp_helpers.cc index c7e9e4cc..cae12e2e 100644 --- a/src/google/protobuf/compiler/csharp/csharp_helpers.cc +++ b/src/google/protobuf/compiler/csharp/csharp_helpers.cc @@ -257,9 +257,7 @@ std::string GetFieldConstantName(const FieldDescriptor* field) { } std::string GetPropertyName(const FieldDescriptor* descriptor) { - if (descriptor->options().has_csharp_property_name()) { - return descriptor->options().csharp_property_name(); - } + // TODO(jtattermusch): consider introducing csharp_property_name field option std::string property_name = UnderscoresToPascalCase(GetFieldName(descriptor)); if (property_name == descriptor->containing_type()->name()) { property_name += "_"; diff --git a/src/google/protobuf/descriptor.pb.cc b/src/google/protobuf/descriptor.pb.cc index 2aac269b..aa5952c7 100644 --- a/src/google/protobuf/descriptor.pb.cc +++ b/src/google/protobuf/descriptor.pb.cc @@ -339,13 +339,12 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, _internal_metadata_), -1); FieldOptions_descriptor_ = file->message_type(11); - static const int FieldOptions_offsets_[7] = { + static const int FieldOptions_offsets_[6] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, ctype_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, packed_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, lazy_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, deprecated_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, weak_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, csharp_property_name_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, uninterpreted_option_), }; FieldOptions_reflection_ = @@ -689,41 +688,40 @@ void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto() { "recated\030\003 \001(\010:\005false\022\021\n\tmap_entry\030\007 \001(\010\022" "C\n\024uninterpreted_option\030\347\007 \003(\0132$.google." "protobuf.UninterpretedOption*\t\010\350\007\020\200\200\200\200\002\"" - "\276\002\n\014FieldOptions\022:\n\005ctype\030\001 \001(\0162#.google" + "\240\002\n\014FieldOptions\022:\n\005ctype\030\001 \001(\0162#.google" ".protobuf.FieldOptions.CType:\006STRING\022\016\n\006" "packed\030\002 \001(\010\022\023\n\004lazy\030\005 \001(\010:\005false\022\031\n\ndep" "recated\030\003 \001(\010:\005false\022\023\n\004weak\030\n \001(\010:\005fals" - "e\022\034\n\024csharp_property_name\030\013 \001(\t\022C\n\024unint" - "erpreted_option\030\347\007 \003(\0132$.google.protobuf" - ".UninterpretedOption\"/\n\005CType\022\n\n\006STRING\020" - "\000\022\010\n\004CORD\020\001\022\020\n\014STRING_PIECE\020\002*\t\010\350\007\020\200\200\200\200\002" - "\"\215\001\n\013EnumOptions\022\023\n\013allow_alias\030\002 \001(\010\022\031\n" - "\ndeprecated\030\003 \001(\010:\005false\022C\n\024uninterprete" - "d_option\030\347\007 \003(\0132$.google.protobuf.Uninte" - "rpretedOption*\t\010\350\007\020\200\200\200\200\002\"}\n\020EnumValueOpt" - "ions\022\031\n\ndeprecated\030\001 \001(\010:\005false\022C\n\024unint" - "erpreted_option\030\347\007 \003(\0132$.google.protobuf" - ".UninterpretedOption*\t\010\350\007\020\200\200\200\200\002\"{\n\016Servi" - "ceOptions\022\031\n\ndeprecated\030! \001(\010:\005false\022C\n\024" - "uninterpreted_option\030\347\007 \003(\0132$.google.pro" - "tobuf.UninterpretedOption*\t\010\350\007\020\200\200\200\200\002\"z\n\r" - "MethodOptions\022\031\n\ndeprecated\030! \001(\010:\005false" - "\022C\n\024uninterpreted_option\030\347\007 \003(\0132$.google" - ".protobuf.UninterpretedOption*\t\010\350\007\020\200\200\200\200\002" - "\"\236\002\n\023UninterpretedOption\022;\n\004name\030\002 \003(\0132-" - ".google.protobuf.UninterpretedOption.Nam" - "ePart\022\030\n\020identifier_value\030\003 \001(\t\022\032\n\022posit" - "ive_int_value\030\004 \001(\004\022\032\n\022negative_int_valu" - "e\030\005 \001(\003\022\024\n\014double_value\030\006 \001(\001\022\024\n\014string_" - "value\030\007 \001(\014\022\027\n\017aggregate_value\030\010 \001(\t\0323\n\010" - "NamePart\022\021\n\tname_part\030\001 \002(\t\022\024\n\014is_extens" - "ion\030\002 \002(\010\"\325\001\n\016SourceCodeInfo\022:\n\010location" - "\030\001 \003(\0132(.google.protobuf.SourceCodeInfo." - "Location\032\206\001\n\010Location\022\020\n\004path\030\001 \003(\005B\002\020\001\022" - "\020\n\004span\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\031leadin" - "g_detached_comments\030\006 \003(\tB)\n\023com.google." - "protobufB\020DescriptorProtosH\001", 4708); + "e\022C\n\024uninterpreted_option\030\347\007 \003(\0132$.googl" + "e.protobuf.UninterpretedOption\"/\n\005CType\022" + "\n\n\006STRING\020\000\022\010\n\004CORD\020\001\022\020\n\014STRING_PIECE\020\002*" + "\t\010\350\007\020\200\200\200\200\002\"\215\001\n\013EnumOptions\022\023\n\013allow_alia" + "s\030\002 \001(\010\022\031\n\ndeprecated\030\003 \001(\010:\005false\022C\n\024un" + "interpreted_option\030\347\007 \003(\0132$.google.proto" + "buf.UninterpretedOption*\t\010\350\007\020\200\200\200\200\002\"}\n\020En" + "umValueOptions\022\031\n\ndeprecated\030\001 \001(\010:\005fals" + "e\022C\n\024uninterpreted_option\030\347\007 \003(\0132$.googl" + "e.protobuf.UninterpretedOption*\t\010\350\007\020\200\200\200\200" + "\002\"{\n\016ServiceOptions\022\031\n\ndeprecated\030! \001(\010:" + "\005false\022C\n\024uninterpreted_option\030\347\007 \003(\0132$." + "google.protobuf.UninterpretedOption*\t\010\350\007" + "\020\200\200\200\200\002\"z\n\rMethodOptions\022\031\n\ndeprecated\030! " + "\001(\010:\005false\022C\n\024uninterpreted_option\030\347\007 \003(" + "\0132$.google.protobuf.UninterpretedOption*" + "\t\010\350\007\020\200\200\200\200\002\"\236\002\n\023UninterpretedOption\022;\n\004na" + "me\030\002 \003(\0132-.google.protobuf.Uninterpreted" + "Option.NamePart\022\030\n\020identifier_value\030\003 \001(" + "\t\022\032\n\022positive_int_value\030\004 \001(\004\022\032\n\022negativ" + "e_int_value\030\005 \001(\003\022\024\n\014double_value\030\006 \001(\001\022" + "\024\n\014string_value\030\007 \001(\014\022\027\n\017aggregate_value" + "\030\010 \001(\t\0323\n\010NamePart\022\021\n\tname_part\030\001 \002(\t\022\024\n" + "\014is_extension\030\002 \002(\010\"\325\001\n\016SourceCodeInfo\022:" + "\n\010location\030\001 \003(\0132(.google.protobuf.Sourc" + "eCodeInfo.Location\032\206\001\n\010Location\022\020\n\004path\030" + "\001 \003(\005B\002\020\001\022\020\n\004span\030\002 \003(\005B\002\020\001\022\030\n\020leading_c" + "omments\030\003 \001(\t\022\031\n\021trailing_comments\030\004 \001(\t" + "\022!\n\031leading_detached_comments\030\006 \003(\tB)\n\023c" + "om.google.protobufB\020DescriptorProtosH\001", 4678); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/descriptor.proto", &protobuf_RegisterTypes); FileDescriptorSet::default_instance_ = new FileDescriptorSet(); @@ -9090,7 +9088,6 @@ const int FieldOptions::kPackedFieldNumber; const int FieldOptions::kLazyFieldNumber; const int FieldOptions::kDeprecatedFieldNumber; const int FieldOptions::kWeakFieldNumber; -const int FieldOptions::kCsharpPropertyNameFieldNumber; const int FieldOptions::kUninterpretedOptionFieldNumber; #endif // !_MSC_VER @@ -9112,14 +9109,12 @@ FieldOptions::FieldOptions(const FieldOptions& from) } void FieldOptions::SharedCtor() { - ::google::protobuf::internal::GetEmptyString(); _cached_size_ = 0; ctype_ = 0; packed_ = false; lazy_ = false; deprecated_ = false; weak_ = false; - csharp_property_name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); ::memset(_has_bits_, 0, sizeof(_has_bits_)); } @@ -9129,7 +9124,6 @@ FieldOptions::~FieldOptions() { } void FieldOptions::SharedDtor() { - csharp_property_name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); if (this != default_instance_) { } } @@ -9169,11 +9163,8 @@ void FieldOptions::Clear() { ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ } while (0) - if (_has_bits_[0 / 32] & 63) { + if (_has_bits_[0 / 32] & 31) { ZR_(ctype_, weak_); - if (has_csharp_property_name()) { - csharp_property_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - } } #undef ZR_HELPER_ @@ -9271,23 +9262,6 @@ bool FieldOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(90)) goto parse_csharp_property_name; - break; - } - - // optional string csharp_property_name = 11; - case 11: { - if (tag == 90) { - parse_csharp_property_name: - DO_(::google::protobuf::internal::WireFormatLite::ReadString( - input, this->mutable_csharp_property_name())); - ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->csharp_property_name().data(), this->csharp_property_name().length(), - ::google::protobuf::internal::WireFormat::PARSE, - "google.protobuf.FieldOptions.csharp_property_name"); - } else { - goto handle_unusual; - } if (input->ExpectTag(7994)) goto parse_uninterpreted_option; break; } @@ -9362,16 +9336,6 @@ void FieldOptions::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WriteBool(10, this->weak(), output); } - // optional string csharp_property_name = 11; - if (has_csharp_property_name()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->csharp_property_name().data(), this->csharp_property_name().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE, - "google.protobuf.FieldOptions.csharp_property_name"); - ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( - 11, this->csharp_property_name(), output); - } - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( @@ -9418,17 +9382,6 @@ void FieldOptions::SerializeWithCachedSizes( target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(10, this->weak(), target); } - // optional string csharp_property_name = 11; - if (has_csharp_property_name()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->csharp_property_name().data(), this->csharp_property_name().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE, - "google.protobuf.FieldOptions.csharp_property_name"); - target = - ::google::protobuf::internal::WireFormatLite::WriteStringToArray( - 11, this->csharp_property_name(), target); - } - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: @@ -9451,7 +9404,7 @@ void FieldOptions::SerializeWithCachedSizes( int FieldOptions::ByteSize() const { int total_size = 0; - if (_has_bits_[0 / 32] & 63) { + if (_has_bits_[0 / 32] & 31) { // optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING]; if (has_ctype()) { total_size += 1 + @@ -9478,13 +9431,6 @@ int FieldOptions::ByteSize() const { total_size += 1 + 1; } - // optional string csharp_property_name = 11; - if (has_csharp_property_name()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->csharp_property_name()); - } - } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; total_size += 2 * this->uninterpreted_option_size(); @@ -9538,10 +9484,6 @@ void FieldOptions::MergeFrom(const FieldOptions& from) { if (from.has_weak()) { set_weak(from.weak()); } - if (from.has_csharp_property_name()) { - set_has_csharp_property_name(); - csharp_property_name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.csharp_property_name_); - } } _extensions_.MergeFrom(from._extensions_); if (from._internal_metadata_.have_unknown_fields()) { @@ -9578,7 +9520,6 @@ void FieldOptions::InternalSwap(FieldOptions* other) { std::swap(lazy_, other->lazy_); std::swap(deprecated_, other->deprecated_); std::swap(weak_, other->weak_); - csharp_property_name_.Swap(&other->csharp_property_name_); uninterpreted_option_.UnsafeArenaSwap(&other->uninterpreted_option_); std::swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); @@ -9718,59 +9659,6 @@ void FieldOptions::InternalSwap(FieldOptions* other) { // @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.weak) } -// optional string csharp_property_name = 11; - bool FieldOptions::has_csharp_property_name() const { - return (_has_bits_[0] & 0x00000020u) != 0; -} - void FieldOptions::set_has_csharp_property_name() { - _has_bits_[0] |= 0x00000020u; -} - void FieldOptions::clear_has_csharp_property_name() { - _has_bits_[0] &= ~0x00000020u; -} - void FieldOptions::clear_csharp_property_name() { - csharp_property_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - clear_has_csharp_property_name(); -} - const ::std::string& FieldOptions::csharp_property_name() const { - // @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.csharp_property_name) - return csharp_property_name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} - void FieldOptions::set_csharp_property_name(const ::std::string& value) { - set_has_csharp_property_name(); - csharp_property_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.csharp_property_name) -} - void FieldOptions::set_csharp_property_name(const char* value) { - set_has_csharp_property_name(); - csharp_property_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); - // @@protoc_insertion_point(field_set_char:google.protobuf.FieldOptions.csharp_property_name) -} - void FieldOptions::set_csharp_property_name(const char* value, size_t size) { - set_has_csharp_property_name(); - csharp_property_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldOptions.csharp_property_name) -} - ::std::string* FieldOptions::mutable_csharp_property_name() { - set_has_csharp_property_name(); - // @@protoc_insertion_point(field_mutable:google.protobuf.FieldOptions.csharp_property_name) - return csharp_property_name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} - ::std::string* FieldOptions::release_csharp_property_name() { - clear_has_csharp_property_name(); - return csharp_property_name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} - void FieldOptions::set_allocated_csharp_property_name(::std::string* csharp_property_name) { - if (csharp_property_name != NULL) { - set_has_csharp_property_name(); - } else { - clear_has_csharp_property_name(); - } - csharp_property_name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), csharp_property_name); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldOptions.csharp_property_name) -} - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; int FieldOptions::uninterpreted_option_size() const { return uninterpreted_option_.size(); diff --git a/src/google/protobuf/descriptor.pb.h b/src/google/protobuf/descriptor.pb.h index 106fc0b3..0c564abd 100644 --- a/src/google/protobuf/descriptor.pb.h +++ b/src/google/protobuf/descriptor.pb.h @@ -2196,18 +2196,6 @@ class LIBPROTOBUF_EXPORT FieldOptions : public ::google::protobuf::Message { bool weak() const; void set_weak(bool value); - // optional string csharp_property_name = 11; - bool has_csharp_property_name() const; - void clear_csharp_property_name(); - static const int kCsharpPropertyNameFieldNumber = 11; - const ::std::string& csharp_property_name() const; - void set_csharp_property_name(const ::std::string& value); - void set_csharp_property_name(const char* value); - void set_csharp_property_name(const char* value, size_t size); - ::std::string* mutable_csharp_property_name(); - ::std::string* release_csharp_property_name(); - void set_allocated_csharp_property_name(::std::string* csharp_property_name); - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; int uninterpreted_option_size() const; void clear_uninterpreted_option(); @@ -2233,8 +2221,6 @@ class LIBPROTOBUF_EXPORT FieldOptions : public ::google::protobuf::Message { inline void clear_has_deprecated(); inline void set_has_weak(); inline void clear_has_weak(); - inline void set_has_csharp_property_name(); - inline void clear_has_csharp_property_name(); ::google::protobuf::internal::ExtensionSet _extensions_; @@ -2246,7 +2232,6 @@ class LIBPROTOBUF_EXPORT FieldOptions : public ::google::protobuf::Message { bool lazy_; bool deprecated_; bool weak_; - ::google::protobuf::internal::ArenaStringPtr csharp_property_name_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); @@ -5938,59 +5923,6 @@ inline void FieldOptions::set_weak(bool value) { // @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.weak) } -// optional string csharp_property_name = 11; -inline bool FieldOptions::has_csharp_property_name() const { - return (_has_bits_[0] & 0x00000020u) != 0; -} -inline void FieldOptions::set_has_csharp_property_name() { - _has_bits_[0] |= 0x00000020u; -} -inline void FieldOptions::clear_has_csharp_property_name() { - _has_bits_[0] &= ~0x00000020u; -} -inline void FieldOptions::clear_csharp_property_name() { - csharp_property_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - clear_has_csharp_property_name(); -} -inline const ::std::string& FieldOptions::csharp_property_name() const { - // @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.csharp_property_name) - return csharp_property_name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -inline void FieldOptions::set_csharp_property_name(const ::std::string& value) { - set_has_csharp_property_name(); - csharp_property_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.csharp_property_name) -} -inline void FieldOptions::set_csharp_property_name(const char* value) { - set_has_csharp_property_name(); - csharp_property_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); - // @@protoc_insertion_point(field_set_char:google.protobuf.FieldOptions.csharp_property_name) -} -inline void FieldOptions::set_csharp_property_name(const char* value, size_t size) { - set_has_csharp_property_name(); - csharp_property_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldOptions.csharp_property_name) -} -inline ::std::string* FieldOptions::mutable_csharp_property_name() { - set_has_csharp_property_name(); - // @@protoc_insertion_point(field_mutable:google.protobuf.FieldOptions.csharp_property_name) - return csharp_property_name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -inline ::std::string* FieldOptions::release_csharp_property_name() { - clear_has_csharp_property_name(); - return csharp_property_name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -inline void FieldOptions::set_allocated_csharp_property_name(::std::string* csharp_property_name) { - if (csharp_property_name != NULL) { - set_has_csharp_property_name(); - } else { - clear_has_csharp_property_name(); - } - csharp_property_name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), csharp_property_name); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldOptions.csharp_property_name) -} - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; inline int FieldOptions::uninterpreted_option_size() const { return uninterpreted_option_.size(); diff --git a/src/google/protobuf/descriptor.proto b/src/google/protobuf/descriptor.proto index 33e8a322..912e4301 100644 --- a/src/google/protobuf/descriptor.proto +++ b/src/google/protobuf/descriptor.proto @@ -491,12 +491,6 @@ message FieldOptions { // For Google-internal migration only. Do not use. optional bool weak = 10 [default=false]; - // Provides the ability to override the name of the property - // generated for this field. This is applied to all properties - // and methods to do with this field, including HasFoo, FooCount, - // FooList etc. - optional string csharp_property_name = 11; - // The parser stores options it doesn't recognize here. See above. repeated UninterpretedOption uninterpreted_option = 999; -- cgit v1.2.3 From 8e190d498c9e402c787e70cde4afc7124393bea6 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 17 Apr 2015 11:07:02 -0700 Subject: temporarily removing csharp_umbrella_namespace file option --- .../protobuf/compiler/csharp/csharp_helpers.cc | 4 +- src/google/protobuf/descriptor.pb.cc | 200 +++++---------------- src/google/protobuf/descriptor.pb.h | 68 ------- src/google/protobuf/descriptor.proto | 7 - 4 files changed, 46 insertions(+), 233 deletions(-) (limited to 'src') diff --git a/src/google/protobuf/compiler/csharp/csharp_helpers.cc b/src/google/protobuf/compiler/csharp/csharp_helpers.cc index cae12e2e..4580b7be 100644 --- a/src/google/protobuf/compiler/csharp/csharp_helpers.cc +++ b/src/google/protobuf/compiler/csharp/csharp_helpers.cc @@ -127,9 +127,7 @@ std::string GetFileUmbrellaClassname(const FileDescriptor* descriptor) { } std::string GetFileUmbrellaNamespace(const FileDescriptor* descriptor) { - if (descriptor->options().has_csharp_umbrella_namespace()) { - return descriptor->options().csharp_umbrella_namespace(); - } + // TODO(jtattermusch): reintroduce csharp_umbrella_namespace option bool collision = false; std::string umbrella_classname = GetFileUmbrellaClassname(descriptor); for(int i = 0; i < descriptor->message_type_count(); i++) { diff --git a/src/google/protobuf/descriptor.pb.cc b/src/google/protobuf/descriptor.pb.cc index aa5952c7..9e703d96 100644 --- a/src/google/protobuf/descriptor.pb.cc +++ b/src/google/protobuf/descriptor.pb.cc @@ -289,7 +289,7 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, _internal_metadata_), -1); FileOptions_descriptor_ = file->message_type(9); - static const int FileOptions_offsets_[16] = { + static const int FileOptions_offsets_[15] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_package_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_outer_classname_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_multiple_files_), @@ -304,7 +304,6 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, cc_enable_arenas_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, objc_class_prefix_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, csharp_namespace_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, csharp_umbrella_namespace_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, uninterpreted_option_), }; FileOptions_reflection_ = @@ -665,7 +664,7 @@ void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto() { "t_type\030\003 \001(\t\022/\n\007options\030\004 \001(\0132\036.google.p" "rotobuf.MethodOptions\022\037\n\020client_streamin" "g\030\005 \001(\010:\005false\022\037\n\020server_streaming\030\006 \001(\010" - ":\005false\"\244\005\n\013FileOptions\022\024\n\014java_package\030" + ":\005false\"\201\005\n\013FileOptions\022\024\n\014java_package\030" "\001 \001(\t\022\034\n\024java_outer_classname\030\010 \001(\t\022\"\n\023j" "ava_multiple_files\030\n \001(\010:\005false\022,\n\035java_" "generate_equals_and_hash\030\024 \001(\010:\005false\022%\n" @@ -677,51 +676,51 @@ void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto() { "se\022\"\n\023py_generic_services\030\022 \001(\010:\005false\022\031" "\n\ndeprecated\030\027 \001(\010:\005false\022\037\n\020cc_enable_a" "renas\030\037 \001(\010:\005false\022\031\n\021objc_class_prefix\030" - "$ \001(\t\022\030\n\020csharp_namespace\030% \001(\t\022!\n\031cshar" - "p_umbrella_namespace\030& \001(\t\022C\n\024uninterpre" - "ted_option\030\347\007 \003(\0132$.google.protobuf.Unin" - "terpretedOption\":\n\014OptimizeMode\022\t\n\005SPEED" - "\020\001\022\r\n\tCODE_SIZE\020\002\022\020\n\014LITE_RUNTIME\020\003*\t\010\350\007" - "\020\200\200\200\200\002\"\346\001\n\016MessageOptions\022&\n\027message_set" - "_wire_format\030\001 \001(\010:\005false\022.\n\037no_standard" - "_descriptor_accessor\030\002 \001(\010:\005false\022\031\n\ndep" - "recated\030\003 \001(\010:\005false\022\021\n\tmap_entry\030\007 \001(\010\022" + "$ \001(\t\022\030\n\020csharp_namespace\030% \001(\t\022C\n\024unint" + "erpreted_option\030\347\007 \003(\0132$.google.protobuf" + ".UninterpretedOption\":\n\014OptimizeMode\022\t\n\005" + "SPEED\020\001\022\r\n\tCODE_SIZE\020\002\022\020\n\014LITE_RUNTIME\020\003" + "*\t\010\350\007\020\200\200\200\200\002\"\346\001\n\016MessageOptions\022&\n\027messag" + "e_set_wire_format\030\001 \001(\010:\005false\022.\n\037no_sta" + "ndard_descriptor_accessor\030\002 \001(\010:\005false\022\031" + "\n\ndeprecated\030\003 \001(\010:\005false\022\021\n\tmap_entry\030\007" + " \001(\010\022C\n\024uninterpreted_option\030\347\007 \003(\0132$.go" + "ogle.protobuf.UninterpretedOption*\t\010\350\007\020\200" + "\200\200\200\002\"\240\002\n\014FieldOptions\022:\n\005ctype\030\001 \001(\0162#.g" + "oogle.protobuf.FieldOptions.CType:\006STRIN" + "G\022\016\n\006packed\030\002 \001(\010\022\023\n\004lazy\030\005 \001(\010:\005false\022\031" + "\n\ndeprecated\030\003 \001(\010:\005false\022\023\n\004weak\030\n \001(\010:" + "\005false\022C\n\024uninterpreted_option\030\347\007 \003(\0132$." + "google.protobuf.UninterpretedOption\"/\n\005C" + "Type\022\n\n\006STRING\020\000\022\010\n\004CORD\020\001\022\020\n\014STRING_PIE" + "CE\020\002*\t\010\350\007\020\200\200\200\200\002\"\215\001\n\013EnumOptions\022\023\n\013allow" + "_alias\030\002 \001(\010\022\031\n\ndeprecated\030\003 \001(\010:\005false\022" "C\n\024uninterpreted_option\030\347\007 \003(\0132$.google." "protobuf.UninterpretedOption*\t\010\350\007\020\200\200\200\200\002\"" - "\240\002\n\014FieldOptions\022:\n\005ctype\030\001 \001(\0162#.google" - ".protobuf.FieldOptions.CType:\006STRING\022\016\n\006" - "packed\030\002 \001(\010\022\023\n\004lazy\030\005 \001(\010:\005false\022\031\n\ndep" - "recated\030\003 \001(\010:\005false\022\023\n\004weak\030\n \001(\010:\005fals" - "e\022C\n\024uninterpreted_option\030\347\007 \003(\0132$.googl" - "e.protobuf.UninterpretedOption\"/\n\005CType\022" - "\n\n\006STRING\020\000\022\010\n\004CORD\020\001\022\020\n\014STRING_PIECE\020\002*" - "\t\010\350\007\020\200\200\200\200\002\"\215\001\n\013EnumOptions\022\023\n\013allow_alia" - "s\030\002 \001(\010\022\031\n\ndeprecated\030\003 \001(\010:\005false\022C\n\024un" - "interpreted_option\030\347\007 \003(\0132$.google.proto" - "buf.UninterpretedOption*\t\010\350\007\020\200\200\200\200\002\"}\n\020En" - "umValueOptions\022\031\n\ndeprecated\030\001 \001(\010:\005fals" - "e\022C\n\024uninterpreted_option\030\347\007 \003(\0132$.googl" - "e.protobuf.UninterpretedOption*\t\010\350\007\020\200\200\200\200" - "\002\"{\n\016ServiceOptions\022\031\n\ndeprecated\030! \001(\010:" + "}\n\020EnumValueOptions\022\031\n\ndeprecated\030\001 \001(\010:" "\005false\022C\n\024uninterpreted_option\030\347\007 \003(\0132$." "google.protobuf.UninterpretedOption*\t\010\350\007" - "\020\200\200\200\200\002\"z\n\rMethodOptions\022\031\n\ndeprecated\030! " - "\001(\010:\005false\022C\n\024uninterpreted_option\030\347\007 \003(" - "\0132$.google.protobuf.UninterpretedOption*" - "\t\010\350\007\020\200\200\200\200\002\"\236\002\n\023UninterpretedOption\022;\n\004na" - "me\030\002 \003(\0132-.google.protobuf.Uninterpreted" - "Option.NamePart\022\030\n\020identifier_value\030\003 \001(" - "\t\022\032\n\022positive_int_value\030\004 \001(\004\022\032\n\022negativ" - "e_int_value\030\005 \001(\003\022\024\n\014double_value\030\006 \001(\001\022" - "\024\n\014string_value\030\007 \001(\014\022\027\n\017aggregate_value" - "\030\010 \001(\t\0323\n\010NamePart\022\021\n\tname_part\030\001 \002(\t\022\024\n" - "\014is_extension\030\002 \002(\010\"\325\001\n\016SourceCodeInfo\022:" - "\n\010location\030\001 \003(\0132(.google.protobuf.Sourc" - "eCodeInfo.Location\032\206\001\n\010Location\022\020\n\004path\030" - "\001 \003(\005B\002\020\001\022\020\n\004span\030\002 \003(\005B\002\020\001\022\030\n\020leading_c" - "omments\030\003 \001(\t\022\031\n\021trailing_comments\030\004 \001(\t" - "\022!\n\031leading_detached_comments\030\006 \003(\tB)\n\023c" - "om.google.protobufB\020DescriptorProtosH\001", 4678); + "\020\200\200\200\200\002\"{\n\016ServiceOptions\022\031\n\ndeprecated\030!" + " \001(\010:\005false\022C\n\024uninterpreted_option\030\347\007 \003" + "(\0132$.google.protobuf.UninterpretedOption" + "*\t\010\350\007\020\200\200\200\200\002\"z\n\rMethodOptions\022\031\n\ndeprecat" + "ed\030! \001(\010:\005false\022C\n\024uninterpreted_option\030" + "\347\007 \003(\0132$.google.protobuf.UninterpretedOp" + "tion*\t\010\350\007\020\200\200\200\200\002\"\236\002\n\023UninterpretedOption\022" + ";\n\004name\030\002 \003(\0132-.google.protobuf.Uninterp" + "retedOption.NamePart\022\030\n\020identifier_value" + "\030\003 \001(\t\022\032\n\022positive_int_value\030\004 \001(\004\022\032\n\022ne" + "gative_int_value\030\005 \001(\003\022\024\n\014double_value\030\006" + " \001(\001\022\024\n\014string_value\030\007 \001(\014\022\027\n\017aggregate_" + "value\030\010 \001(\t\0323\n\010NamePart\022\021\n\tname_part\030\001 \002" + "(\t\022\024\n\014is_extension\030\002 \002(\010\"\325\001\n\016SourceCodeI" + "nfo\022:\n\010location\030\001 \003(\0132(.google.protobuf." + "SourceCodeInfo.Location\032\206\001\n\010Location\022\020\n\004" + "path\030\001 \003(\005B\002\020\001\022\020\n\004span\030\002 \003(\005B\002\020\001\022\030\n\020lead" + "ing_comments\030\003 \001(\t\022\031\n\021trailing_comments\030" + "\004 \001(\t\022!\n\031leading_detached_comments\030\006 \003(\t" + "B)\n\023com.google.protobufB\020DescriptorProto" + "sH\001", 4643); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/descriptor.proto", &protobuf_RegisterTypes); FileDescriptorSet::default_instance_ = new FileDescriptorSet(); @@ -7020,7 +7019,6 @@ const int FileOptions::kDeprecatedFieldNumber; const int FileOptions::kCcEnableArenasFieldNumber; const int FileOptions::kObjcClassPrefixFieldNumber; const int FileOptions::kCsharpNamespaceFieldNumber; -const int FileOptions::kCsharpUmbrellaNamespaceFieldNumber; const int FileOptions::kUninterpretedOptionFieldNumber; #endif // !_MSC_VER @@ -7058,7 +7056,6 @@ void FileOptions::SharedCtor() { cc_enable_arenas_ = false; objc_class_prefix_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); csharp_namespace_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - csharp_umbrella_namespace_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); ::memset(_has_bits_, 0, sizeof(_has_bits_)); } @@ -7073,7 +7070,6 @@ void FileOptions::SharedDtor() { go_package_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); objc_class_prefix_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); csharp_namespace_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - csharp_umbrella_namespace_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); if (this != default_instance_) { } } @@ -7126,7 +7122,7 @@ void FileOptions::Clear() { go_package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } } - if (_has_bits_[8 / 32] & 32512) { + if (_has_bits_[8 / 32] & 16128) { ZR_(java_generic_services_, cc_enable_arenas_); if (has_objc_class_prefix()) { objc_class_prefix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -7134,9 +7130,6 @@ void FileOptions::Clear() { if (has_csharp_namespace()) { csharp_namespace_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - if (has_csharp_umbrella_namespace()) { - csharp_umbrella_namespace_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - } } #undef ZR_HELPER_ @@ -7379,23 +7372,6 @@ bool FileOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(306)) goto parse_csharp_umbrella_namespace; - break; - } - - // optional string csharp_umbrella_namespace = 38; - case 38: { - if (tag == 306) { - parse_csharp_umbrella_namespace: - DO_(::google::protobuf::internal::WireFormatLite::ReadString( - input, this->mutable_csharp_umbrella_namespace())); - ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->csharp_umbrella_namespace().data(), this->csharp_umbrella_namespace().length(), - ::google::protobuf::internal::WireFormat::PARSE, - "google.protobuf.FileOptions.csharp_umbrella_namespace"); - } else { - goto handle_unusual; - } if (input->ExpectTag(7994)) goto parse_uninterpreted_option; break; } @@ -7540,16 +7516,6 @@ void FileOptions::SerializeWithCachedSizes( 37, this->csharp_namespace(), output); } - // optional string csharp_umbrella_namespace = 38; - if (has_csharp_umbrella_namespace()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->csharp_umbrella_namespace().data(), this->csharp_umbrella_namespace().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE, - "google.protobuf.FileOptions.csharp_umbrella_namespace"); - ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( - 38, this->csharp_umbrella_namespace(), output); - } - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( @@ -7671,17 +7637,6 @@ void FileOptions::SerializeWithCachedSizes( 37, this->csharp_namespace(), target); } - // optional string csharp_umbrella_namespace = 38; - if (has_csharp_umbrella_namespace()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->csharp_umbrella_namespace().data(), this->csharp_umbrella_namespace().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE, - "google.protobuf.FileOptions.csharp_umbrella_namespace"); - target = - ::google::protobuf::internal::WireFormatLite::WriteStringToArray( - 38, this->csharp_umbrella_namespace(), target); - } - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: @@ -7753,7 +7708,7 @@ int FileOptions::ByteSize() const { } } - if (_has_bits_[8 / 32] & 32512) { + if (_has_bits_[8 / 32] & 16128) { // optional bool java_generic_services = 17 [default = false]; if (has_java_generic_services()) { total_size += 2 + 1; @@ -7788,13 +7743,6 @@ int FileOptions::ByteSize() const { this->csharp_namespace()); } - // optional string csharp_umbrella_namespace = 38; - if (has_csharp_umbrella_namespace()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->csharp_umbrella_namespace()); - } - } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; total_size += 2 * this->uninterpreted_option_size(); @@ -7882,10 +7830,6 @@ void FileOptions::MergeFrom(const FileOptions& from) { set_has_csharp_namespace(); csharp_namespace_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.csharp_namespace_); } - if (from.has_csharp_umbrella_namespace()) { - set_has_csharp_umbrella_namespace(); - csharp_umbrella_namespace_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.csharp_umbrella_namespace_); - } } _extensions_.MergeFrom(from._extensions_); if (from._internal_metadata_.have_unknown_fields()) { @@ -7931,7 +7875,6 @@ void FileOptions::InternalSwap(FileOptions* other) { std::swap(cc_enable_arenas_, other->cc_enable_arenas_); objc_class_prefix_.Swap(&other->objc_class_prefix_); csharp_namespace_.Swap(&other->csharp_namespace_); - csharp_umbrella_namespace_.Swap(&other->csharp_umbrella_namespace_); uninterpreted_option_.UnsafeArenaSwap(&other->uninterpreted_option_); std::swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); @@ -8432,59 +8375,6 @@ void FileOptions::InternalSwap(FileOptions* other) { // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.csharp_namespace) } -// optional string csharp_umbrella_namespace = 38; - bool FileOptions::has_csharp_umbrella_namespace() const { - return (_has_bits_[0] & 0x00004000u) != 0; -} - void FileOptions::set_has_csharp_umbrella_namespace() { - _has_bits_[0] |= 0x00004000u; -} - void FileOptions::clear_has_csharp_umbrella_namespace() { - _has_bits_[0] &= ~0x00004000u; -} - void FileOptions::clear_csharp_umbrella_namespace() { - csharp_umbrella_namespace_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - clear_has_csharp_umbrella_namespace(); -} - const ::std::string& FileOptions::csharp_umbrella_namespace() const { - // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_umbrella_namespace) - return csharp_umbrella_namespace_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} - void FileOptions::set_csharp_umbrella_namespace(const ::std::string& value) { - set_has_csharp_umbrella_namespace(); - csharp_umbrella_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_umbrella_namespace) -} - void FileOptions::set_csharp_umbrella_namespace(const char* value) { - set_has_csharp_umbrella_namespace(); - csharp_umbrella_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); - // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.csharp_umbrella_namespace) -} - void FileOptions::set_csharp_umbrella_namespace(const char* value, size_t size) { - set_has_csharp_umbrella_namespace(); - csharp_umbrella_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.csharp_umbrella_namespace) -} - ::std::string* FileOptions::mutable_csharp_umbrella_namespace() { - set_has_csharp_umbrella_namespace(); - // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.csharp_umbrella_namespace) - return csharp_umbrella_namespace_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} - ::std::string* FileOptions::release_csharp_umbrella_namespace() { - clear_has_csharp_umbrella_namespace(); - return csharp_umbrella_namespace_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} - void FileOptions::set_allocated_csharp_umbrella_namespace(::std::string* csharp_umbrella_namespace) { - if (csharp_umbrella_namespace != NULL) { - set_has_csharp_umbrella_namespace(); - } else { - clear_has_csharp_umbrella_namespace(); - } - csharp_umbrella_namespace_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), csharp_umbrella_namespace); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.csharp_umbrella_namespace) -} - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; int FileOptions::uninterpreted_option_size() const { return uninterpreted_option_.size(); diff --git a/src/google/protobuf/descriptor.pb.h b/src/google/protobuf/descriptor.pb.h index 0c564abd..5bebf4fd 100644 --- a/src/google/protobuf/descriptor.pb.h +++ b/src/google/protobuf/descriptor.pb.h @@ -1849,18 +1849,6 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message { ::std::string* release_csharp_namespace(); void set_allocated_csharp_namespace(::std::string* csharp_namespace); - // optional string csharp_umbrella_namespace = 38; - bool has_csharp_umbrella_namespace() const; - void clear_csharp_umbrella_namespace(); - static const int kCsharpUmbrellaNamespaceFieldNumber = 38; - const ::std::string& csharp_umbrella_namespace() const; - void set_csharp_umbrella_namespace(const ::std::string& value); - void set_csharp_umbrella_namespace(const char* value); - void set_csharp_umbrella_namespace(const char* value, size_t size); - ::std::string* mutable_csharp_umbrella_namespace(); - ::std::string* release_csharp_umbrella_namespace(); - void set_allocated_csharp_umbrella_namespace(::std::string* csharp_umbrella_namespace); - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; int uninterpreted_option_size() const; void clear_uninterpreted_option(); @@ -1904,8 +1892,6 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message { inline void clear_has_objc_class_prefix(); inline void set_has_csharp_namespace(); inline void clear_has_csharp_namespace(); - inline void set_has_csharp_umbrella_namespace(); - inline void clear_has_csharp_umbrella_namespace(); ::google::protobuf::internal::ExtensionSet _extensions_; @@ -1922,7 +1908,6 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message { ::google::protobuf::internal::ArenaStringPtr go_package_; ::google::protobuf::internal::ArenaStringPtr objc_class_prefix_; ::google::protobuf::internal::ArenaStringPtr csharp_namespace_; - ::google::protobuf::internal::ArenaStringPtr csharp_umbrella_namespace_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; bool java_generic_services_; bool py_generic_services_; @@ -5585,59 +5570,6 @@ inline void FileOptions::set_allocated_csharp_namespace(::std::string* csharp_na // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.csharp_namespace) } -// optional string csharp_umbrella_namespace = 38; -inline bool FileOptions::has_csharp_umbrella_namespace() const { - return (_has_bits_[0] & 0x00004000u) != 0; -} -inline void FileOptions::set_has_csharp_umbrella_namespace() { - _has_bits_[0] |= 0x00004000u; -} -inline void FileOptions::clear_has_csharp_umbrella_namespace() { - _has_bits_[0] &= ~0x00004000u; -} -inline void FileOptions::clear_csharp_umbrella_namespace() { - csharp_umbrella_namespace_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - clear_has_csharp_umbrella_namespace(); -} -inline const ::std::string& FileOptions::csharp_umbrella_namespace() const { - // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_umbrella_namespace) - return csharp_umbrella_namespace_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -inline void FileOptions::set_csharp_umbrella_namespace(const ::std::string& value) { - set_has_csharp_umbrella_namespace(); - csharp_umbrella_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_umbrella_namespace) -} -inline void FileOptions::set_csharp_umbrella_namespace(const char* value) { - set_has_csharp_umbrella_namespace(); - csharp_umbrella_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); - // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.csharp_umbrella_namespace) -} -inline void FileOptions::set_csharp_umbrella_namespace(const char* value, size_t size) { - set_has_csharp_umbrella_namespace(); - csharp_umbrella_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.csharp_umbrella_namespace) -} -inline ::std::string* FileOptions::mutable_csharp_umbrella_namespace() { - set_has_csharp_umbrella_namespace(); - // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.csharp_umbrella_namespace) - return csharp_umbrella_namespace_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -inline ::std::string* FileOptions::release_csharp_umbrella_namespace() { - clear_has_csharp_umbrella_namespace(); - return csharp_umbrella_namespace_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -inline void FileOptions::set_allocated_csharp_umbrella_namespace(::std::string* csharp_umbrella_namespace) { - if (csharp_umbrella_namespace != NULL) { - set_has_csharp_umbrella_namespace(); - } else { - clear_has_csharp_umbrella_namespace(); - } - csharp_umbrella_namespace_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), csharp_umbrella_namespace); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.csharp_umbrella_namespace) -} - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; inline int FileOptions::uninterpreted_option_size() const { return uninterpreted_option_.size(); diff --git a/src/google/protobuf/descriptor.proto b/src/google/protobuf/descriptor.proto index 912e4301..a4b64f65 100644 --- a/src/google/protobuf/descriptor.proto +++ b/src/google/protobuf/descriptor.proto @@ -354,13 +354,6 @@ message FileOptions { // Namespace for generated classes; defaults to the package. optional string csharp_namespace = 37; - // A nested namespace for the umbrella class, which contains metadata about - // all the messages within the file. This option is helpful for name - // collisions between the umbrella class and an existing type. This will be - // automatically set to 'Proto' if a collision is detected with types being - // generated. - optional string csharp_umbrella_namespace = 38; - // The parser stores options it doesn't recognize here. See above. repeated UninterpretedOption uninterpreted_option = 999; -- cgit v1.2.3 From 7eaf4380315624ad34bd7751bfd04c068d2bdd39 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 17 Apr 2015 16:51:43 -0700 Subject: forgot to include header files into automake template --- src/Makefile.am | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 59f7eaa2..1a82448e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -291,20 +291,34 @@ libprotoc_la_SOURCES = \ google/protobuf/compiler/python/python_generator.cc \ google/protobuf/compiler/ruby/ruby_generator.cc \ google/protobuf/compiler/csharp/csharp_enum.cc \ + 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 \ google/protobuf/compiler/csharp/csharp_helpers.cc \ + google/protobuf/compiler/csharp/csharp_helpers.h \ google/protobuf/compiler/csharp/csharp_message.cc \ + google/protobuf/compiler/csharp/csharp_message.h \ google/protobuf/compiler/csharp/csharp_message_field.cc \ + google/protobuf/compiler/csharp/csharp_message_field.h \ google/protobuf/compiler/csharp/csharp_primitive_field.cc \ + google/protobuf/compiler/csharp/csharp_primitive_field.h \ google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc \ + google/protobuf/compiler/csharp/csharp_repeated_enum_field.h \ google/protobuf/compiler/csharp/csharp_repeated_message_field.cc \ + google/protobuf/compiler/csharp/csharp_repeated_message_field.h \ google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc \ + google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h \ 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_writer.cc + google/protobuf/compiler/csharp/csharp_umbrella_class.h \ + google/protobuf/compiler/csharp/csharp_writer.cc \ + google/protobuf/compiler/csharp/csharp_writer.h bin_PROGRAMS = protoc protoc_LDADD = $(PTHREAD_LIBS) libprotobuf.la libprotoc.la -- cgit v1.2.3 From 856ced5d767c7f4d0eb30eb28f5831c16871b149 Mon Sep 17 00:00:00 2001 From: Jie Luo Date: Mon, 27 Apr 2015 14:00:47 -0700 Subject: Field Presence: remove has methods for optional non-message fields in proto3 --- .../google/protobuf/field_presence_test.proto | 24 + .../TestProtos/FieldPresenceTestProtoFile.cs | 781 +++++++++++++++++++++ .../protobuf/compiler/csharp/csharp_enum_field.cc | 79 ++- .../protobuf/compiler/csharp/csharp_helpers.h | 4 + .../protobuf/compiler/csharp/csharp_message.cc | 4 +- .../compiler/csharp/csharp_primitive_field.cc | 84 ++- 6 files changed, 934 insertions(+), 42 deletions(-) create mode 100644 csharp/protos/google/protobuf/field_presence_test.proto create mode 100644 csharp/src/ProtocolBuffers.Test/TestProtos/FieldPresenceTestProtoFile.cs (limited to 'src') diff --git a/csharp/protos/google/protobuf/field_presence_test.proto b/csharp/protos/google/protobuf/field_presence_test.proto new file mode 100644 index 00000000..43b4f04b --- /dev/null +++ b/csharp/protos/google/protobuf/field_presence_test.proto @@ -0,0 +1,24 @@ +syntax = "proto3"; + +package field_presence_test; + +option java_package = "com.google.protobuf"; +option java_outer_classname = "FieldPresenceTestProto"; +option java_generate_equals_and_hash = true; + +message TestAllTypes { + enum NestedEnum { + FOO = 0; + BAR = 1; + BAZ = 2; + } + message NestedMessage { + optional int32 value = 1; + } + + optional int32 optional_int32 = 1; + optional string optional_string = 2; + optional bytes optional_bytes = 3; + optional NestedEnum optional_nested_enum = 4; + optional NestedMessage optional_nested_message = 5; +} diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/FieldPresenceTestProtoFile.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/FieldPresenceTestProtoFile.cs new file mode 100644 index 00000000..2ea69bc0 --- /dev/null +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/FieldPresenceTestProtoFile.cs @@ -0,0 +1,781 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: protos/google/protobuf/field_presence_test.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 field_presence_test { + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static partial class FieldPresenceTest { + + #region Extension registration + public static void RegisterAllExtensions(pb::ExtensionRegistry registry) { + } + #endregion + #region Static variables + internal static pbd::MessageDescriptor internal__static_field_presence_test_TestAllTypes__Descriptor; + internal static pb::FieldAccess.FieldAccessorTable internal__static_field_presence_test_TestAllTypes__FieldAccessorTable; + internal static pbd::MessageDescriptor internal__static_field_presence_test_TestAllTypes_NestedMessage__Descriptor; + internal static pb::FieldAccess.FieldAccessorTable internal__static_field_presence_test_TestAllTypes_NestedMessage__FieldAccessorTable; + #endregion + #region Descriptor + public static pbd::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbd::FileDescriptor descriptor; + + static FieldPresenceTest() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "CjBwcm90b3MvZ29vZ2xlL3Byb3RvYnVmL2ZpZWxkX3ByZXNlbmNlX3Rlc3Qu", + "cHJvdG8SE2ZpZWxkX3ByZXNlbmNlX3Rlc3QivgIKDFRlc3RBbGxUeXBlcxIW", + "Cg5vcHRpb25hbF9pbnQzMhgBIAEoBRIXCg9vcHRpb25hbF9zdHJpbmcYAiAB", + "KAkSFgoOb3B0aW9uYWxfYnl0ZXMYAyABKAwSSgoUb3B0aW9uYWxfbmVzdGVk", + "X2VudW0YBCABKA4yLC5maWVsZF9wcmVzZW5jZV90ZXN0LlRlc3RBbGxUeXBl", + "cy5OZXN0ZWRFbnVtElAKF29wdGlvbmFsX25lc3RlZF9tZXNzYWdlGAUgASgL", + "Mi8uZmllbGRfcHJlc2VuY2VfdGVzdC5UZXN0QWxsVHlwZXMuTmVzdGVkTWVz", + "c2FnZRoeCg1OZXN0ZWRNZXNzYWdlEg0KBXZhbHVlGAEgASgFIicKCk5lc3Rl", + "ZEVudW0SBwoDRk9PEAASBwoDQkFSEAESBwoDQkFaEAJCMAoTY29tLmdvb2ds", + "ZS5wcm90b2J1ZkIWRmllbGRQcmVzZW5jZVRlc3RQcm90b6ABAWIGcHJvdG8z")); + pbd::FileDescriptor.InternalDescriptorAssigner assigner = delegate(pbd::FileDescriptor root) { + descriptor = root; + internal__static_field_presence_test_TestAllTypes__Descriptor = Descriptor.MessageTypes[0]; + internal__static_field_presence_test_TestAllTypes__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(internal__static_field_presence_test_TestAllTypes__Descriptor, + new string[] { "OptionalInt32", "OptionalString", "OptionalBytes", "OptionalNestedEnum", "OptionalNestedMessage", }); + internal__static_field_presence_test_TestAllTypes_NestedMessage__Descriptor = internal__static_field_presence_test_TestAllTypes__Descriptor.NestedTypes[0]; + internal__static_field_presence_test_TestAllTypes_NestedMessage__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(internal__static_field_presence_test_TestAllTypes_NestedMessage__Descriptor, + new string[] { "Value", }); + 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 TestAllTypes : pb::GeneratedMessage { + private TestAllTypes() { } + private static readonly TestAllTypes defaultInstance = new TestAllTypes().MakeReadOnly(); + private static readonly string[] _testAllTypesFieldNames = new string[] { "optional_bytes", "optional_int32", "optional_nested_enum", "optional_nested_message", "optional_string" }; + private static readonly uint[] _testAllTypesFieldTags = new uint[] { 26, 8, 32, 42, 18 }; + 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::field_presence_test.FieldPresenceTest.internal__static_field_presence_test_TestAllTypes__Descriptor; } + } + + protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { + get { return global::field_presence_test.FieldPresenceTest.internal__static_field_presence_test_TestAllTypes__FieldAccessorTable; } + } + + #region Nested types + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static partial class Types { + public enum NestedEnum { + FOO = 0, + BAR = 1, + BAZ = 2, + } + + [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[] { "value" }; + 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::field_presence_test.FieldPresenceTest.internal__static_field_presence_test_TestAllTypes_NestedMessage__Descriptor; } + } + + protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { + get { return global::field_presence_test.FieldPresenceTest.internal__static_field_presence_test_TestAllTypes_NestedMessage__FieldAccessorTable; } + } + + public const int ValueFieldNumber = 1; + private int value_; + public int Value { + get { return value_; } + } + + public override void WriteTo(pb::ICodedOutputStream output) { + CalcSerializedSize(); + string[] field_names = _nestedMessageFieldNames; + if (Value != 0) { + output.WriteInt32(1, field_names[0], Value); + } + 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 (Value != 0) { + size += pb::CodedOutputStream.ComputeInt32Size(1, Value); + } + 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::field_presence_test.TestAllTypes.Types.NestedMessage.Descriptor; } + } + + public override NestedMessage DefaultInstanceForType { + get { return global::field_presence_test.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::field_presence_test.TestAllTypes.Types.NestedMessage.DefaultInstance) return this; + PrepareBuilder(); + if (other.Value != 0) { + Value = other.Value; + } + 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: { + input.ReadInt32(ref result.value_); + break; + } + } + } + + if (unknownFields != null) { + this.UnknownFields = unknownFields.Build(); + } + return this; + } + + + public int Value { + get { return result.Value; } + set { SetValue(value); } + } + public Builder SetValue(int value) { + PrepareBuilder(); + result.value_ = value; + return this; + } + public Builder ClearValue() { + PrepareBuilder(); + result.value_ = 0; + return this; + } + } + static NestedMessage() { + object.ReferenceEquals(global::field_presence_test.FieldPresenceTest.Descriptor, null); + } + } + + } + #endregion + + public const int OptionalInt32FieldNumber = 1; + private int optionalInt32_; + public int OptionalInt32 { + get { return optionalInt32_; } + } + + public const int OptionalStringFieldNumber = 2; + private string optionalString_ = ""; + public string OptionalString { + get { return optionalString_; } + } + + public const int OptionalBytesFieldNumber = 3; + private pb::ByteString optionalBytes_ = pb::ByteString.Empty; + public pb::ByteString OptionalBytes { + get { return optionalBytes_; } + } + + public const int OptionalNestedEnumFieldNumber = 4; + private global::field_presence_test.TestAllTypes.Types.NestedEnum optionalNestedEnum_ = global::field_presence_test.TestAllTypes.Types.NestedEnum.FOO; + public global::field_presence_test.TestAllTypes.Types.NestedEnum OptionalNestedEnum { + get { return optionalNestedEnum_; } + } + + public const int OptionalNestedMessageFieldNumber = 5; + private bool hasOptionalNestedMessage; + private global::field_presence_test.TestAllTypes.Types.NestedMessage optionalNestedMessage_; + public bool HasOptionalNestedMessage { + get { return hasOptionalNestedMessage; } + } + public global::field_presence_test.TestAllTypes.Types.NestedMessage OptionalNestedMessage { + get { return optionalNestedMessage_ ?? global::field_presence_test.TestAllTypes.Types.NestedMessage.DefaultInstance; } + } + + public override void WriteTo(pb::ICodedOutputStream output) { + CalcSerializedSize(); + string[] field_names = _testAllTypesFieldNames; + if (OptionalInt32 != 0) { + output.WriteInt32(1, field_names[1], OptionalInt32); + } + if (OptionalString != "") { + output.WriteString(2, field_names[4], OptionalString); + } + if (OptionalBytes != pb::ByteString.Empty) { + output.WriteBytes(3, field_names[0], OptionalBytes); + } + if (OptionalNestedEnum != global::field_presence_test.TestAllTypes.Types.NestedEnum.FOO) { + output.WriteEnum(4, field_names[2], (int) OptionalNestedEnum, OptionalNestedEnum); + } + if (hasOptionalNestedMessage) { + output.WriteMessage(5, 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 (OptionalInt32 != 0) { + size += pb::CodedOutputStream.ComputeInt32Size(1, OptionalInt32); + } + if (OptionalString != "") { + size += pb::CodedOutputStream.ComputeStringSize(2, OptionalString); + } + if (OptionalBytes != pb::ByteString.Empty) { + size += pb::CodedOutputStream.ComputeBytesSize(3, OptionalBytes); + } + if (OptionalNestedEnum != global::field_presence_test.TestAllTypes.Types.NestedEnum.FOO) { + size += pb::CodedOutputStream.ComputeEnumSize(4, (int) OptionalNestedEnum); + } + if (hasOptionalNestedMessage) { + size += pb::CodedOutputStream.ComputeMessageSize(5, OptionalNestedMessage); + } + 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() { + 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::field_presence_test.TestAllTypes.Descriptor; } + } + + public override TestAllTypes DefaultInstanceForType { + get { return global::field_presence_test.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::field_presence_test.TestAllTypes.DefaultInstance) return this; + PrepareBuilder(); + if (other.OptionalInt32 != 0) { + OptionalInt32 = other.OptionalInt32; + } + if (other.OptionalString != "") { + OptionalString = other.OptionalString; + } + if (other.OptionalBytes != pb::ByteString.Empty) { + OptionalBytes = other.OptionalBytes; + } + if (other.OptionalNestedEnum != global::field_presence_test.TestAllTypes.Types.NestedEnum.FOO) { + OptionalNestedEnum = other.OptionalNestedEnum; + } + 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(_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: { + input.ReadInt32(ref result.optionalInt32_); + break; + } + case 18: { + input.ReadString(ref result.optionalString_); + break; + } + case 26: { + input.ReadBytes(ref result.optionalBytes_); + break; + } + case 32: { + object unknown; + if(input.ReadEnum(ref result.optionalNestedEnum_, out unknown)) { + } else if(unknown is int) { + if (unknownFields == null) { + unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); + } + unknownFields.MergeVarintField(4, (ulong)(int)unknown); + } + break; + } + case 42: { + global::field_presence_test.TestAllTypes.Types.NestedMessage.Builder subBuilder = global::field_presence_test.TestAllTypes.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 int OptionalInt32 { + get { return result.OptionalInt32; } + set { SetOptionalInt32(value); } + } + public Builder SetOptionalInt32(int value) { + PrepareBuilder(); + result.optionalInt32_ = value; + return this; + } + public Builder ClearOptionalInt32() { + PrepareBuilder(); + result.optionalInt32_ = 0; + return this; + } + + public string OptionalString { + get { return result.OptionalString; } + set { SetOptionalString(value); } + } + public Builder SetOptionalString(string value) { + pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); + result.optionalString_ = value; + return this; + } + public Builder ClearOptionalString() { + PrepareBuilder(); + result.optionalString_ = ""; + return this; + } + + public pb::ByteString OptionalBytes { + get { return result.OptionalBytes; } + set { SetOptionalBytes(value); } + } + public Builder SetOptionalBytes(pb::ByteString value) { + pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); + result.optionalBytes_ = value; + return this; + } + public Builder ClearOptionalBytes() { + PrepareBuilder(); + result.optionalBytes_ = pb::ByteString.Empty; + return this; + } + + public global::field_presence_test.TestAllTypes.Types.NestedEnum OptionalNestedEnum { + get { return result.OptionalNestedEnum; } + set { SetOptionalNestedEnum(value); } + } + public Builder SetOptionalNestedEnum(global::field_presence_test.TestAllTypes.Types.NestedEnum value) { + PrepareBuilder(); + result.optionalNestedEnum_ = value; + return this; + } + public Builder ClearOptionalNestedEnum() { + PrepareBuilder(); + result.optionalNestedEnum_ = global::field_presence_test.TestAllTypes.Types.NestedEnum.FOO; + return this; + } + + public bool HasOptionalNestedMessage { + get { return result.hasOptionalNestedMessage; } + } + public global::field_presence_test.TestAllTypes.Types.NestedMessage OptionalNestedMessage { + get { return result.OptionalNestedMessage; } + set { SetOptionalNestedMessage(value); } + } + public Builder SetOptionalNestedMessage(global::field_presence_test.TestAllTypes.Types.NestedMessage value) { + pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); + result.hasOptionalNestedMessage = true; + result.optionalNestedMessage_ = value; + return this; + } + public Builder SetOptionalNestedMessage(global::field_presence_test.TestAllTypes.Types.NestedMessage.Builder builderForValue) { + pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); + result.hasOptionalNestedMessage = true; + result.optionalNestedMessage_ = builderForValue.Build(); + return this; + } + public Builder MergeOptionalNestedMessage(global::field_presence_test.TestAllTypes.Types.NestedMessage value) { + pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); + if (result.hasOptionalNestedMessage && + result.optionalNestedMessage_ != global::field_presence_test.TestAllTypes.Types.NestedMessage.DefaultInstance) { + result.optionalNestedMessage_ = global::field_presence_test.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; + } + } + static TestAllTypes() { + object.ReferenceEquals(global::field_presence_test.FieldPresenceTest.Descriptor, null); + } + } + + #endregion + +} + +#endregion Designer generated code diff --git a/src/google/protobuf/compiler/csharp/csharp_enum_field.cc b/src/google/protobuf/compiler/csharp/csharp_enum_field.cc index d5b1b477..1fbd1c6c 100644 --- a/src/google/protobuf/compiler/csharp/csharp_enum_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_enum_field.cc @@ -56,13 +56,17 @@ EnumFieldGenerator::~EnumFieldGenerator() { } void EnumFieldGenerator::GenerateMembers(Writer* writer) { - writer->WriteLine("private bool has$0$;", property_name()); + if (SupportFieldPresence(descriptor_->file())) { + writer->WriteLine("private bool has$0$;", property_name()); + } writer->WriteLine("private $0$ $1$_ = $2$;", type_name(), name(), default_value()); AddDeprecatedFlag(writer); - writer->WriteLine("public bool Has$0$ {", property_name()); - writer->WriteLine(" get { return has$0$; }", property_name()); - writer->WriteLine("}"); + if (SupportFieldPresence(descriptor_->file())) { + writer->WriteLine("public bool Has$0$ {", property_name()); + writer->WriteLine(" get { return has$0$; }", property_name()); + writer->WriteLine("}"); + } AddPublicMemberAttributes(writer); writer->WriteLine("public $0$ $1$ {", type_name(), property_name()); writer->WriteLine(" get { return $0$_; }", name()); @@ -71,9 +75,11 @@ void EnumFieldGenerator::GenerateMembers(Writer* writer) { void EnumFieldGenerator::GenerateBuilderMembers(Writer* writer) { AddDeprecatedFlag(writer); - writer->WriteLine("public bool Has$0$ {", property_name()); - writer->WriteLine(" get { return result.has$0$; }", property_name()); - writer->WriteLine("}"); + if (SupportFieldPresence(descriptor_->file())) { + writer->WriteLine("public bool Has$0$ {", property_name()); + writer->WriteLine(" get { return result.has$0$; }", property_name()); + writer->WriteLine("}"); + } AddPublicMemberAttributes(writer); writer->WriteLine("public $0$ $1$ {", type_name(), property_name()); writer->WriteLine(" get { return result.$0$; }", property_name()); @@ -83,21 +89,29 @@ void EnumFieldGenerator::GenerateBuilderMembers(Writer* writer) { writer->WriteLine("public Builder Set$0$($1$ value) {", property_name(), type_name()); writer->WriteLine(" PrepareBuilder();"); - writer->WriteLine(" result.has$0$ = true;", property_name()); + if (SupportFieldPresence(descriptor_->file())) { + writer->WriteLine(" result.has$0$ = true;", property_name()); + } writer->WriteLine(" result.$0$_ = value;", name()); writer->WriteLine(" return this;"); writer->WriteLine("}"); AddDeprecatedFlag(writer); writer->WriteLine("public Builder Clear$0$() {", property_name()); writer->WriteLine(" PrepareBuilder();"); - writer->WriteLine(" result.has$0$ = false;", property_name()); + if (SupportFieldPresence(descriptor_->file())) { + writer->WriteLine(" result.has$0$ = false;", property_name()); + } writer->WriteLine(" result.$0$_ = $1$;", name(), default_value()); writer->WriteLine(" return this;"); writer->WriteLine("}"); } void EnumFieldGenerator::GenerateMergingCode(Writer* writer) { - writer->WriteLine("if (other.Has$0$) {", property_name()); + if (SupportFieldPresence(descriptor_->file())) { + writer->WriteLine("if (other.Has$0$) {", property_name()); + } else { + writer->WriteLine("if (other.$0$ != $1$) {", property_name(), default_value()); + } writer->WriteLine(" $0$ = other.$0$;", property_name()); writer->WriteLine("}"); } @@ -110,7 +124,9 @@ void EnumFieldGenerator::GenerateParsingCode(Writer* writer) { writer->WriteLine("object unknown;"); writer->WriteLine("if(input.ReadEnum(ref result.$0$_, out unknown)) {", name()); - writer->WriteLine(" result.has$0$ = true;", property_name()); + if (SupportFieldPresence(descriptor_->file())) { + writer->WriteLine(" result.has$0$ = true;", property_name()); + } writer->WriteLine("} else if(unknown is int) {"); if (!use_lite_runtime()) { writer->WriteLine(" if (unknownFields == null) {"); // First unknown field - create builder now @@ -125,7 +141,11 @@ void EnumFieldGenerator::GenerateParsingCode(Writer* writer) { } void EnumFieldGenerator::GenerateSerializationCode(Writer* writer) { - writer->WriteLine("if (has$0$) {", property_name()); + if (SupportFieldPresence(descriptor_->file())) { + writer->WriteLine("if (has$0$) {", property_name()); + } else { + writer->WriteLine("if ($0$ != $1$) {", property_name(), default_value()); + } writer->WriteLine( " output.WriteEnum($0$, field_names[$2$], (int) $1$, $1$);", number(), property_name(), field_ordinal()); @@ -133,7 +153,11 @@ void EnumFieldGenerator::GenerateSerializationCode(Writer* writer) { } void EnumFieldGenerator::GenerateSerializedSizeCode(Writer* writer) { - writer->WriteLine("if (has$0$) {", property_name()); + if (SupportFieldPresence(descriptor_->file())) { + writer->WriteLine("if (has$0$) {", property_name()); + } else { + writer->WriteLine("if ($0$ != $1$) {", property_name(), default_value()); + } writer->WriteLine( " size += pb::CodedOutputStream.ComputeEnumSize($0$, (int) $1$);", number(), property_name()); @@ -141,17 +165,32 @@ void EnumFieldGenerator::GenerateSerializedSizeCode(Writer* writer) { } void EnumFieldGenerator::WriteHash(Writer* writer) { - writer->WriteLine("if (has$0$) hash ^= $1$_.GetHashCode();", property_name(), - name()); + if (SupportFieldPresence(descriptor_->file())) { + writer->WriteLine("if (has$0$) {", property_name()); + } else { + writer->WriteLine("if ($0$ != $1$) {", property_name(), default_value()); + } + writer->WriteLine(" hash ^= $1$_.GetHashCode();", name()); + writer->WriteLine("}"); } void EnumFieldGenerator::WriteEquals(Writer* writer) { - writer->WriteLine( - "if (has$0$ != other.has$0$ || (has$0$ && !$1$_.Equals(other.$1$_))) return false;", - property_name(), name()); + if (SupportFieldPresence(descriptor_->file())) { + writer->WriteLine( + "if (has$0$ != other.has$0$ || (has$0$ && !$1$_.Equals(other.$1$_))) return false;", + property_name(), name()); + } else { + writer->WriteLine( + "if (!$0$_.Equals(other.$0$_)) return false;", name()); + } } void EnumFieldGenerator::WriteToString(Writer* writer) { - writer->WriteLine("PrintField(\"$0$\", has$1$, $2$_, writer);", - descriptor_->name(), property_name(), name()); + if (SupportFieldPresence(descriptor_->file())) { + writer->WriteLine("PrintField(\"$0$\", has$1$, $2$_, writer);", + descriptor_->name(), property_name(), name()); + } else { + writer->WriteLine("PrintField(\"$0$\", $1$_, writer);", + descriptor_->name(), name()); + } } } // namespace csharp diff --git a/src/google/protobuf/compiler/csharp/csharp_helpers.h b/src/google/protobuf/compiler/csharp/csharp_helpers.h index 8fdd214e..bc77f43a 100644 --- a/src/google/protobuf/compiler/csharp/csharp_helpers.h +++ b/src/google/protobuf/compiler/csharp/csharp_helpers.h @@ -101,6 +101,10 @@ FieldGeneratorBase* CreateFieldGenerator(const FieldDescriptor* descriptor, int bool HasRequiredFields(const Descriptor* descriptor); +inline bool SupportFieldPresence(const FileDescriptor* file) { + return file->syntax() != FileDescriptor::SYNTAX_PROTO3; +} + } // namespace csharp } // namespace compiler } // namespace protobuf diff --git a/src/google/protobuf/compiler/csharp/csharp_message.cc b/src/google/protobuf/compiler/csharp/csharp_message.cc index f7c8ddfb..36f41c70 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message.cc @@ -279,7 +279,9 @@ void MessageGenerator::Generate(Writer* writer) { } if (optimize_speed()) { - GenerateIsInitialized(writer); + if (SupportFieldPresence(descriptor_->file())) { + GenerateIsInitialized(writer); + } GenerateMessageSerializationMethods(writer); } if (use_lite_runtime()) { diff --git a/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc b/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc index 54287b41..10e886eb 100644 --- a/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc @@ -57,13 +57,17 @@ PrimitiveFieldGenerator::~PrimitiveFieldGenerator() { } void PrimitiveFieldGenerator::GenerateMembers(Writer* writer) { - writer->WriteLine("private bool has$0$;", property_name()); + if (SupportFieldPresence(descriptor_->file())) { + writer->WriteLine("private bool has$0$;", property_name()); + } writer->WriteLine("private $0$ $1$_$2$;", type_name(), name(), has_default_value() ? " = " + default_value() : ""); AddDeprecatedFlag(writer); - writer->WriteLine("public bool Has$0$ {", property_name()); - writer->WriteLine(" get { return has$0$; }", property_name()); - writer->WriteLine("}"); + if (SupportFieldPresence(descriptor_->file())) { + writer->WriteLine("public bool Has$0$ {", property_name()); + writer->WriteLine(" get { return has$0$; }", property_name()); + writer->WriteLine("}"); + } AddPublicMemberAttributes(writer); writer->WriteLine("public $0$ $1$ {", type_name(), property_name()); writer->WriteLine(" get { return $0$_; }", name()); @@ -72,9 +76,11 @@ void PrimitiveFieldGenerator::GenerateMembers(Writer* writer) { void PrimitiveFieldGenerator::GenerateBuilderMembers(Writer* writer) { AddDeprecatedFlag(writer); - writer->WriteLine("public bool Has$0$ {", property_name()); - writer->WriteLine(" get { return result.has$0$; }", property_name()); - writer->WriteLine("}"); + if (SupportFieldPresence(descriptor_->file())) { + writer->WriteLine("public bool Has$0$ {", property_name()); + writer->WriteLine(" get { return result.has$0$; }", property_name()); + writer->WriteLine("}"); + } AddPublicMemberAttributes(writer); writer->WriteLine("public $0$ $1$ {", type_name(), property_name()); writer->WriteLine(" get { return result.$0$; }", property_name()); @@ -85,21 +91,29 @@ void PrimitiveFieldGenerator::GenerateBuilderMembers(Writer* writer) { type_name()); AddNullCheck(writer); writer->WriteLine(" PrepareBuilder();"); - writer->WriteLine(" result.has$0$ = true;", property_name()); + if (SupportFieldPresence(descriptor_->file())) { + writer->WriteLine(" result.has$0$ = true;", property_name()); + } writer->WriteLine(" result.$0$_ = value;", name()); writer->WriteLine(" return this;"); writer->WriteLine("}"); AddDeprecatedFlag(writer); writer->WriteLine("public Builder Clear$0$() {", property_name()); writer->WriteLine(" PrepareBuilder();"); - writer->WriteLine(" result.has$0$ = false;", property_name()); + if (SupportFieldPresence(descriptor_->file())) { + writer->WriteLine(" result.has$0$ = false;", property_name()); + } writer->WriteLine(" result.$0$_ = $1$;", name(), default_value()); writer->WriteLine(" return this;"); writer->WriteLine("}"); } void PrimitiveFieldGenerator::GenerateMergingCode(Writer* writer) { - writer->WriteLine("if (other.Has$0$) {", property_name()); + if (SupportFieldPresence(descriptor_->file())) { + writer->WriteLine("if (other.Has$0$) {", property_name()); + } else { + writer->WriteLine("if (other.$0$ != $1$) {", property_name(), default_value()); + } writer->WriteLine(" $0$ = other.$0$;", property_name()); writer->WriteLine("}"); } @@ -109,12 +123,21 @@ void PrimitiveFieldGenerator::GenerateBuildingCode(Writer* writer) { } void PrimitiveFieldGenerator::GenerateParsingCode(Writer* writer) { - writer->WriteLine("result.has$0$ = input.Read$1$(ref result.$2$_);", - property_name(), capitalized_type_name(), name()); + if (SupportFieldPresence(descriptor_->file())) { + writer->WriteLine("result.has$0$ = input.Read$1$(ref result.$2$_);", + property_name(), capitalized_type_name(), name()); + } else { + writer->WriteLine("input.Read$0$(ref result.$1$_);", + capitalized_type_name(), name()); + } } void PrimitiveFieldGenerator::GenerateSerializationCode(Writer* writer) { - writer->WriteLine("if (has$0$) {", property_name()); + if (SupportFieldPresence(descriptor_->file())) { + writer->WriteLine("if (has$0$) {", property_name()); + } else { + writer->WriteLine("if ($0$ != $1$) {", property_name(), default_value()); + } writer->WriteLine(" output.Write$0$($1$, field_names[$3$], $2$);", capitalized_type_name(), number(), property_name(), field_ordinal()); @@ -122,24 +145,43 @@ void PrimitiveFieldGenerator::GenerateSerializationCode(Writer* writer) { } void PrimitiveFieldGenerator::GenerateSerializedSizeCode(Writer* writer) { - writer->WriteLine("if (has$0$) {", property_name()); + if (SupportFieldPresence(descriptor_->file())) { + writer->WriteLine("if (has$0$) {", property_name()); + } else { + writer->WriteLine("if ($0$ != $1$) {", property_name(), default_value()); + } writer->WriteLine(" size += pb::CodedOutputStream.Compute$0$Size($1$, $2$);", capitalized_type_name(), number(), property_name()); writer->WriteLine("}"); } void PrimitiveFieldGenerator::WriteHash(Writer* writer) { - writer->WriteLine("if (has$0$) hash ^= $1$_.GetHashCode();", property_name(), - name()); + if (SupportFieldPresence(descriptor_->file())) { + writer->WriteLine("if (has$0$) {", property_name()); + } else { + writer->WriteLine("if ($0$ != $1$) {", property_name(), default_value()); + } + writer->WriteLine(" hash ^= $1$_.GetHashCode();", name()); + writer->WriteLine("}"); } void PrimitiveFieldGenerator::WriteEquals(Writer* writer) { - writer->WriteLine( - "if (has$0$ != other.has$0$ || (has$0$ && !$1$_.Equals(other.$1$_))) return false;", - property_name(), name()); + if (SupportFieldPresence(descriptor_->file())) { + writer->WriteLine( + "if (has$0$ != other.has$0$ || (has$0$ && !$1$_.Equals(other.$1$_))) return false;", + property_name(), name()); + } else { + writer->WriteLine( + "if (!$0$_.Equals(other.$0$_)) return false;", name()); + } } void PrimitiveFieldGenerator::WriteToString(Writer* writer) { - writer->WriteLine("PrintField(\"$0$\", has$1$, $2$_, writer);", - descriptor_->name(), property_name(), name()); + if (SupportFieldPresence(descriptor_->file())) { + writer->WriteLine("PrintField(\"$0$\", has$1$, $2$_, writer);", + descriptor_->name(), property_name(), name()); + } else { + writer->WriteLine("PrintField(\"$0$\", $1$_, writer);", + descriptor_->name(), name()); + } } } // namespace csharp -- cgit v1.2.3 From 5a811ac6f9d92a6875a7a1e0f1cdb8058640cc62 Mon Sep 17 00:00:00 2001 From: Jie Luo Date: Mon, 27 Apr 2015 14:27:21 -0700 Subject: fix bug for Field Presence --- src/google/protobuf/compiler/csharp/csharp_enum_field.cc | 2 +- src/google/protobuf/compiler/csharp/csharp_primitive_field.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/google/protobuf/compiler/csharp/csharp_enum_field.cc b/src/google/protobuf/compiler/csharp/csharp_enum_field.cc index 1fbd1c6c..34d1c5c6 100644 --- a/src/google/protobuf/compiler/csharp/csharp_enum_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_enum_field.cc @@ -170,7 +170,7 @@ void EnumFieldGenerator::WriteHash(Writer* writer) { } else { writer->WriteLine("if ($0$ != $1$) {", property_name(), default_value()); } - writer->WriteLine(" hash ^= $1$_.GetHashCode();", name()); + writer->WriteLine(" hash ^= $0$_.GetHashCode();", name()); writer->WriteLine("}"); } void EnumFieldGenerator::WriteEquals(Writer* writer) { diff --git a/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc b/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc index 10e886eb..a193afda 100644 --- a/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc @@ -161,7 +161,7 @@ void PrimitiveFieldGenerator::WriteHash(Writer* writer) { } else { writer->WriteLine("if ($0$ != $1$) {", property_name(), default_value()); } - writer->WriteLine(" hash ^= $1$_.GetHashCode();", name()); + writer->WriteLine(" hash ^= $0$_.GetHashCode();", name()); writer->WriteLine("}"); } void PrimitiveFieldGenerator::WriteEquals(Writer* writer) { -- cgit v1.2.3 From d9e3063eb054503a98f8ef74fe0484c0f12210ea Mon Sep 17 00:00:00 2001 From: Jie Luo Date: Fri, 1 May 2015 11:20:50 -0700 Subject: Remove ClsCompliant declarations from C# code --- src/google/protobuf/compiler/csharp/csharp_extension.cc | 8 -------- src/google/protobuf/compiler/csharp/csharp_field_base.cc | 13 ------------- src/google/protobuf/compiler/csharp/csharp_field_base.h | 2 -- src/google/protobuf/compiler/csharp/csharp_generator.cc | 5 +---- src/google/protobuf/compiler/csharp/csharp_message.cc | 5 ----- .../compiler/csharp/csharp_source_generator_base.cc | 5 ----- .../protobuf/compiler/csharp/csharp_source_generator_base.h | 1 - 7 files changed, 1 insertion(+), 38 deletions(-) (limited to 'src') diff --git a/src/google/protobuf/compiler/csharp/csharp_extension.cc b/src/google/protobuf/compiler/csharp/csharp_extension.cc index 5d38f52e..2bac320d 100644 --- a/src/google/protobuf/compiler/csharp/csharp_extension.cc +++ b/src/google/protobuf/compiler/csharp/csharp_extension.cc @@ -63,11 +63,6 @@ ExtensionGenerator::~ExtensionGenerator() { } void ExtensionGenerator::Generate(Writer* writer) { - if (cls_compliance() - && (GetFieldConstantName(descriptor_).substr(0, 1) == "_")) { - writer->WriteLine("[global::System.CLSCompliant(false)]"); - } - writer->WriteLine("public const int $0$ = $1$;", GetFieldConstantName(descriptor_), SimpleItoa(descriptor_->number())); @@ -80,7 +75,6 @@ void ExtensionGenerator::Generate(Writer* writer) { // "option message_set_wire_format = true; is not supported in Lite runtime extensions."); //} - AddClsComplianceCheck(writer); writer->Write("$0$ ", class_access_level()); writer->WriteLine( "static pb::$3$<$0$, $1$> $2$;", @@ -90,12 +84,10 @@ void ExtensionGenerator::Generate(Writer* writer) { descriptor_->is_repeated() ? "GeneratedRepeatExtensionLite" : "GeneratedExtensionLite"); } else if (descriptor_->is_repeated()) { - AddClsComplianceCheck(writer); writer->WriteLine( "$0$ static pb::GeneratedExtensionBase> $2$;", class_access_level(), type_name(), property_name()); } else { - AddClsComplianceCheck(writer); writer->WriteLine("$0$ static pb::GeneratedExtensionBase<$1$> $2$;", class_access_level(), type_name(), property_name()); } diff --git a/src/google/protobuf/compiler/csharp/csharp_field_base.cc b/src/google/protobuf/compiler/csharp/csharp_field_base.cc index ed4d55c4..145b6743 100644 --- a/src/google/protobuf/compiler/csharp/csharp_field_base.cc +++ b/src/google/protobuf/compiler/csharp/csharp_field_base.cc @@ -79,13 +79,6 @@ void FieldGeneratorBase::AddNullCheck(Writer* writer, const std::string& name) { void FieldGeneratorBase::AddPublicMemberAttributes(Writer* writer) { AddDeprecatedFlag(writer); - AddClsComplianceCheck(writer); -} - -void FieldGeneratorBase::AddClsComplianceCheck(Writer* writer) { - if (cls_compliance() && !is_cls_compliant()) { - writer->WriteLine("[global::System.CLSCompliant(false)]"); - } } std::string FieldGeneratorBase::property_name() { @@ -211,12 +204,6 @@ bool FieldGeneratorBase::is_nullable_type() { } } -bool FieldGeneratorBase::is_cls_compliant() { - CSharpType type = GetCSharpType(descriptor_->type()); - return (type != CSHARPTYPE_UINT32) && (type != CSHARPTYPE_UINT64) - && (UnderscoresToPascalCase(name()).substr(0, 1) != "_"); -} - inline bool IsNaN(double value) { // NaN is never equal to anything, even itself. return value != value; diff --git a/src/google/protobuf/compiler/csharp/csharp_field_base.h b/src/google/protobuf/compiler/csharp/csharp_field_base.h index 4f3a7658..311f7a6e 100644 --- a/src/google/protobuf/compiler/csharp/csharp_field_base.h +++ b/src/google/protobuf/compiler/csharp/csharp_field_base.h @@ -70,14 +70,12 @@ class FieldGeneratorBase : public SourceGeneratorBase { void AddNullCheck(Writer* writer, const std::string& name); void AddPublicMemberAttributes(Writer* writer); - void AddClsComplianceCheck(Writer* writer); std::string property_name(); std::string name(); std::string type_name(); bool has_default_value(); bool is_nullable_type(); - bool is_cls_compliant(); std::string default_value(); std::string number(); std::string message_or_group(); diff --git a/src/google/protobuf/compiler/csharp/csharp_generator.cc b/src/google/protobuf/compiler/csharp/csharp_generator.cc index 61ed37ad..64c4bd7d 100644 --- a/src/google/protobuf/compiler/csharp/csharp_generator.cc +++ b/src/google/protobuf/compiler/csharp/csharp_generator.cc @@ -71,10 +71,7 @@ bool Generator::Generate( std::string file_extension = ".cs"; for (int i = 0; i < options.size(); i++) { - if (options[i].first == "no_cls_compliance") { - *error = "Turning off CLS compliance is not implemented yet."; - return false; - } else if (options[i].first == "file_extension") { + if (options[i].first == "file_extension") { file_extension = options[i].second; } else { *error = "Unknown generator option: " + options[i].first; diff --git a/src/google/protobuf/compiler/csharp/csharp_message.cc b/src/google/protobuf/compiler/csharp/csharp_message.cc index 36f41c70..96f7c17c 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message.cc @@ -262,11 +262,6 @@ void MessageGenerator::Generate(Writer* writer) { for (int i = 0; i < descriptor_->field_count(); i++) { const FieldDescriptor* fieldDescriptor = descriptor_->field(i); - // TODO(jtattermusch): same code for cls compliance is in csharp_extension - if (cls_compliance() - && GetFieldConstantName(fieldDescriptor)[0] == '_') { - writer->WriteLine("[global::System.CLSCompliant(false)]"); - } // Rats: we lose the debug comment here :( writer->WriteLine("public const int $0$ = $1$;", 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 e39911ee..8dfb41d4 100644 --- a/src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc +++ b/src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc @@ -69,11 +69,6 @@ std::string SourceGeneratorBase::class_access_level() { return "public"; // public_classes is always on. } -bool SourceGeneratorBase::cls_compliance() { - // TODO(jtattermusch): implement this based on "cls_compliance" cmdline param. - return true; -} - } // namespace csharp } // namespace compiler } // namespace protobuf 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 dbc65d04..1955394e 100644 --- a/src/google/protobuf/compiler/csharp/csharp_source_generator_base.h +++ b/src/google/protobuf/compiler/csharp/csharp_source_generator_base.h @@ -48,7 +48,6 @@ class SourceGeneratorBase { virtual ~SourceGeneratorBase(); std::string class_access_level(); - bool cls_compliance(); bool optimize_size() { return optimizeSize_; -- cgit v1.2.3 From 7879f82ddceb76c2b6710e240a91f0eabf494c33 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Wed, 6 May 2015 15:25:03 +0100 Subject: Add C# namespace to .proto files (e.g. descriptors, unit tests) --- benchmarks/google_size.proto | 3 +++ benchmarks/google_speed.proto | 3 +++ src/google/protobuf/any.proto | 2 +- src/google/protobuf/descriptor.proto | 1 + 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 + src/google/protobuf/unittest_drop_unknown_fields.proto | 2 ++ src/google/protobuf/unittest_embed_optimize_for.proto | 2 ++ src/google/protobuf/unittest_enormous_descriptor.proto | 4 +++- src/google/protobuf/unittest_import.proto | 1 + src/google/protobuf/unittest_import_lite.proto | 1 + src/google/protobuf/unittest_import_public.proto | 1 + src/google/protobuf/unittest_import_public_lite.proto | 1 + src/google/protobuf/unittest_lite.proto | 1 + src/google/protobuf/unittest_lite_imports_nonlite.proto | 1 + src/google/protobuf/unittest_mset.proto | 1 + src/google/protobuf/unittest_no_field_presence.proto | 2 ++ src/google/protobuf/unittest_optimize_for.proto | 1 + src/google/protobuf/unittest_preserve_unknown_enum.proto | 2 ++ src/google/protobuf/unittest_preserve_unknown_enum2.proto | 2 ++ src/google/protobuf/unknown_enum_test.proto | 1 + src/google/protobuf/wrappers.proto | 2 +- 29 files changed, 41 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/benchmarks/google_size.proto b/benchmarks/google_size.proto index 3e6fbdbc..e0fcb2e0 100644 --- a/benchmarks/google_size.proto +++ b/benchmarks/google_size.proto @@ -1,7 +1,10 @@ +syntax = "proto2"; + 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 d6cd0321..3bc5fd2d 100644 --- a/benchmarks/google_speed.proto +++ b/benchmarks/google_speed.proto @@ -1,7 +1,10 @@ +syntax = "proto2"; + 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/src/google/protobuf/any.proto b/src/google/protobuf/any.proto index bf2aa0a9..5f29e01e 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"; // `Any` contains an arbitrary serialized message along with a URL // that describes the type of the serialized message. diff --git a/src/google/protobuf/descriptor.proto b/src/google/protobuf/descriptor.proto index a4b64f65..375814c9 100644 --- a/src/google/protobuf/descriptor.proto +++ b/src/google/protobuf/descriptor.proto @@ -42,6 +42,7 @@ syntax = "proto2"; package google.protobuf; option java_package = "com.google.protobuf"; option java_outer_classname = "DescriptorProtos"; +option csharp_namespace = "Google.ProtocolBuffers.DescriptorProtos"; // descriptor.proto must be optimized for speed because reflection-based // algorithms don't work during bootstrapping. diff --git a/src/google/protobuf/duration.proto b/src/google/protobuf/duration.proto index 868c732f..59420cc0 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"; // A Duration represents a signed, fixed-length span of time represented // as a count of seconds and fractions of seconds at nanosecond diff --git a/src/google/protobuf/field_mask.proto b/src/google/protobuf/field_mask.proto index 492d4b06..0b98411c 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"; // `FieldMask` represents a set of symbolic field paths, for example: // diff --git a/src/google/protobuf/map_lite_unittest.proto b/src/google/protobuf/map_lite_unittest.proto index c69e8d94..febfe5f6 100644 --- a/src/google/protobuf/map_lite_unittest.proto +++ b/src/google/protobuf/map_lite_unittest.proto @@ -32,6 +32,7 @@ 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 3d4af28e..04ca6170 100644 --- a/src/google/protobuf/map_proto2_unittest.proto +++ b/src/google/protobuf/map_proto2_unittest.proto @@ -36,6 +36,8 @@ 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 830f672b..b6a988b3 100644 --- a/src/google/protobuf/map_unittest.proto +++ b/src/google/protobuf/map_unittest.proto @@ -31,6 +31,7 @@ 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 9f27eb43..cfe010c2 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"; // `Struct` represents a structured data value, consisting of fields // which map to dynamically typed values. In some languages, `Struct` diff --git a/src/google/protobuf/timestamp.proto b/src/google/protobuf/timestamp.proto index ac8e009c..94386de1 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"; // A Timestamp represents a point in time independent of any time zone // or calendar, represented as seconds and fractions of seconds at diff --git a/src/google/protobuf/unittest.proto b/src/google/protobuf/unittest.proto index 745f77c5..a32291e0 100644 --- a/src/google/protobuf/unittest.proto +++ b/src/google/protobuf/unittest.proto @@ -42,6 +42,7 @@ 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 d4d6e869..8f9fb582 100644 --- a/src/google/protobuf/unittest_custom_options.proto +++ b/src/google/protobuf/unittest_custom_options.proto @@ -41,6 +41,7 @@ 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 66b31acf..1bb168f2 100644 --- a/src/google/protobuf/unittest_drop_unknown_fields.proto +++ b/src/google/protobuf/unittest_drop_unknown_fields.proto @@ -32,6 +32,8 @@ syntax = "proto3"; package unittest_drop_unknown_fields; +option csharp_namespace = "Google.ProtocolBuffers.TestProtos"; + message Foo { enum NestedEnum { FOO = 0; diff --git a/src/google/protobuf/unittest_embed_optimize_for.proto b/src/google/protobuf/unittest_embed_optimize_for.proto index d8b0f9b9..c4ccccb7 100644 --- a/src/google/protobuf/unittest_embed_optimize_for.proto +++ b/src/google/protobuf/unittest_embed_optimize_for.proto @@ -39,6 +39,8 @@ 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 2250261d..f8fcc9c0 100644 --- a/src/google/protobuf/unittest_enormous_descriptor.proto +++ b/src/google/protobuf/unittest_enormous_descriptor.proto @@ -33,12 +33,14 @@ // Sanjay Ghemawat, Jeff Dean, and others. // // A proto file that has an extremely large descriptor. Used to test that -// descriptors over 64k don't break the string literal length limit in Java. +// descriptors over 64k don't break language-specific limits in generated code, +// such as the string literal length limit in Java. 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 7e165220..ae2e90b8 100644 --- a/src/google/protobuf/unittest_import.proto +++ b/src/google/protobuf/unittest_import.proto @@ -47,6 +47,7 @@ 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 a7afa452..ca208582 100644 --- a/src/google/protobuf/unittest_import_lite.proto +++ b/src/google/protobuf/unittest_import_lite.proto @@ -38,6 +38,7 @@ 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 ffaf7736..0bc5d617 100644 --- a/src/google/protobuf/unittest_import_public.proto +++ b/src/google/protobuf/unittest_import_public.proto @@ -35,6 +35,7 @@ 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 33549c22..231ab9dd 100644 --- a/src/google/protobuf/unittest_import_public_lite.proto +++ b/src/google/protobuf/unittest_import_public_lite.proto @@ -37,6 +37,7 @@ 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 662c0e46..0040874b 100644 --- a/src/google/protobuf/unittest_lite.proto +++ b/src/google/protobuf/unittest_lite.proto @@ -40,6 +40,7 @@ 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 132d6a82..d955cc14 100644 --- a/src/google/protobuf/unittest_lite_imports_nonlite.proto +++ b/src/google/protobuf/unittest_lite_imports_nonlite.proto @@ -38,6 +38,7 @@ 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 3aa31fa9..425c9a5a 100644 --- a/src/google/protobuf/unittest_mset.proto +++ b/src/google/protobuf/unittest_mset.proto @@ -39,6 +39,7 @@ 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 e04da0ac..6e71517c 100644 --- a/src/google/protobuf/unittest_no_field_presence.proto +++ b/src/google/protobuf/unittest_no_field_presence.proto @@ -37,6 +37,8 @@ import "google/protobuf/unittest.proto"; package proto2_nofieldpresence_unittest; +option csharp_namespace = "Google.ProtocolBuffers.TestProtos"; + // 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 ee9cc7bd..2bcd16e4 100644 --- a/src/google/protobuf/unittest_optimize_for.proto +++ b/src/google/protobuf/unittest_optimize_for.proto @@ -40,6 +40,7 @@ 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 67e57499..5214247e 100644 --- a/src/google/protobuf/unittest_preserve_unknown_enum.proto +++ b/src/google/protobuf/unittest_preserve_unknown_enum.proto @@ -32,6 +32,8 @@ syntax = "proto3"; package proto3_preserve_unknown_enum_unittest; +option csharp_namespace = "Google.ProtocolBuffers.TestProtos"; + enum MyEnum { FOO = 0; BAR = 1; diff --git a/src/google/protobuf/unittest_preserve_unknown_enum2.proto b/src/google/protobuf/unittest_preserve_unknown_enum2.proto index adf42968..168b2407 100644 --- a/src/google/protobuf/unittest_preserve_unknown_enum2.proto +++ b/src/google/protobuf/unittest_preserve_unknown_enum2.proto @@ -32,6 +32,8 @@ 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 caafadcd..3c549cc7 100644 --- a/src/google/protobuf/unknown_enum_test.proto +++ b/src/google/protobuf/unknown_enum_test.proto @@ -36,6 +36,7 @@ syntax = "proto2"; package google.protobuf.util; +option csharp_namespace = "Google.ProtocolBuffers.TestProtos"; message DownRevision { enum Enum { diff --git a/src/google/protobuf/wrappers.proto b/src/google/protobuf/wrappers.proto index 5164c24c..28657fbf 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"; // Wrapper message for double. message DoubleValue { -- cgit v1.2.3 From 8172561995e177397c5726e9cb8c4de624527e53 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Thu, 7 May 2015 09:14:00 +0100 Subject: Regenerate descriptor.pb.cc after csharp_namespace change --- src/google/protobuf/descriptor.pb.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/google/protobuf/descriptor.pb.cc b/src/google/protobuf/descriptor.pb.cc index 9e703d96..d7100370 100644 --- a/src/google/protobuf/descriptor.pb.cc +++ b/src/google/protobuf/descriptor.pb.cc @@ -719,8 +719,9 @@ void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto() { "path\030\001 \003(\005B\002\020\001\022\020\n\004span\030\002 \003(\005B\002\020\001\022\030\n\020lead" "ing_comments\030\003 \001(\t\022\031\n\021trailing_comments\030" "\004 \001(\t\022!\n\031leading_detached_comments\030\006 \003(\t" - "B)\n\023com.google.protobufB\020DescriptorProto" - "sH\001", 4643); + "BS\n\023com.google.protobufB\020DescriptorProto" + "sH\001\252\002\'Google.ProtocolBuffers.DescriptorP" + "rotos", 4685); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/descriptor.proto", &protobuf_RegisterTypes); FileDescriptorSet::default_instance_ = new FileDescriptorSet(); -- cgit v1.2.3 From 998b5ba20d4bacb25c90f2afaddac3900a06d61b Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Wed, 13 May 2015 17:34:02 +0100 Subject: Remove the C#-specific field_presence_test.proto, using unittest_no_field_presence.proto instead. This is the start of establishing a C# namespace of "Google.ProtocolBuffers.TestProtos.Proto3" for proto3-syntax protos. We could optionally split the directory structure as well into Proto2 and Proto3 for clarity. --- .../google/protobuf/field_presence_test.proto | 21 - .../src/ProtocolBuffers.Test/FieldPresenceTest.cs | 4 +- .../ProtocolBuffers.Test.csproj | 2 +- .../TestProtos/FieldPresenceTest.cs | 782 ---- .../TestProtos/UnittestNoFieldPresence.cs | 3776 ++++++++++++++++++++ .../protobuf/unittest_no_field_presence.proto | 2 +- 6 files changed, 3780 insertions(+), 807 deletions(-) delete mode 100644 csharp/protos/google/protobuf/field_presence_test.proto delete mode 100644 csharp/src/ProtocolBuffers.Test/TestProtos/FieldPresenceTest.cs create mode 100644 csharp/src/ProtocolBuffers.Test/TestProtos/UnittestNoFieldPresence.cs (limited to 'src') diff --git a/csharp/protos/google/protobuf/field_presence_test.proto b/csharp/protos/google/protobuf/field_presence_test.proto deleted file mode 100644 index 14d91312..00000000 --- a/csharp/protos/google/protobuf/field_presence_test.proto +++ /dev/null @@ -1,21 +0,0 @@ -syntax = "proto3"; - -package Google.ProtocolBuffers.TestProtos.FieldPresence; - -// TODO(jieluo): Add repeated fields, oneof, maps to TestAllTypes -message TestAllTypes { - enum NestedEnum { - FOO = 0; - BAR = 1; - BAZ = 2; - } - message NestedMessage { - optional int32 value = 1; - } - - optional int32 optional_int32 = 1; - optional string optional_string = 2; - optional bytes optional_bytes = 3; - optional NestedEnum optional_nested_enum = 4; - optional NestedMessage optional_nested_message = 5; -} diff --git a/csharp/src/ProtocolBuffers.Test/FieldPresenceTest.cs b/csharp/src/ProtocolBuffers.Test/FieldPresenceTest.cs index 9c1fc6af..8f59334e 100644 --- a/csharp/src/ProtocolBuffers.Test/FieldPresenceTest.cs +++ b/csharp/src/ProtocolBuffers.Test/FieldPresenceTest.cs @@ -33,7 +33,7 @@ using System; using Google.ProtocolBuffers.Descriptors; -using Google.ProtocolBuffers.TestProtos.FieldPresence; +using Google.ProtocolBuffers.TestProtos.Proto3; using NUnit.Framework; namespace Google.ProtocolBuffers @@ -177,7 +177,7 @@ namespace Google.ProtocolBuffers Assert.AreEqual(ByteString.Empty, message.OptionalBytes); Assert.AreEqual(TestAllTypes.Types.NestedEnum.FOO, message.OptionalNestedEnum); Assert.IsTrue(message.HasOptionalNestedMessage); - Assert.AreEqual(0, message.OptionalNestedMessage.Value); + Assert.AreEqual(0, message.OptionalNestedMessage.Bb); } } } diff --git a/csharp/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj b/csharp/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj index dd28f34a..b4c562d1 100644 --- a/csharp/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj +++ b/csharp/src/ProtocolBuffers.Test/ProtocolBuffers.Test.csproj @@ -84,7 +84,6 @@ - @@ -96,6 +95,7 @@ + diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/FieldPresenceTest.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/FieldPresenceTest.cs deleted file mode 100644 index b4cb279d..00000000 --- a/csharp/src/ProtocolBuffers.Test/TestProtos/FieldPresenceTest.cs +++ /dev/null @@ -1,782 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: protos/google/protobuf/field_presence_test.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.FieldPresence { - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class FieldPresenceTest { - - #region Extension registration - public static void RegisterAllExtensions(pb::ExtensionRegistry registry) { - } - #endregion - #region Static variables - internal static pbd::MessageDescriptor internal__static_Google_ProtocolBuffers_TestProtos_FieldPresence_TestAllTypes__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_Google_ProtocolBuffers_TestProtos_FieldPresence_TestAllTypes__FieldAccessorTable; - internal static pbd::MessageDescriptor internal__static_Google_ProtocolBuffers_TestProtos_FieldPresence_TestAllTypes_NestedMessage__Descriptor; - internal static pb::FieldAccess.FieldAccessorTable internal__static_Google_ProtocolBuffers_TestProtos_FieldPresence_TestAllTypes_NestedMessage__FieldAccessorTable; - #endregion - #region Descriptor - public static pbd::FileDescriptor Descriptor { - get { return descriptor; } - } - private static pbd::FileDescriptor descriptor; - - static FieldPresenceTest() { - byte[] descriptorData = global::System.Convert.FromBase64String( - string.Concat( - "CjBwcm90b3MvZ29vZ2xlL3Byb3RvYnVmL2ZpZWxkX3ByZXNlbmNlX3Rlc3Qu", - "cHJvdG8SL0dvb2dsZS5Qcm90b2NvbEJ1ZmZlcnMuVGVzdFByb3Rvcy5GaWVs", - "ZFByZXNlbmNlIvYCCgxUZXN0QWxsVHlwZXMSFgoOb3B0aW9uYWxfaW50MzIY", - "ASABKAUSFwoPb3B0aW9uYWxfc3RyaW5nGAIgASgJEhYKDm9wdGlvbmFsX2J5", - "dGVzGAMgASgMEmYKFG9wdGlvbmFsX25lc3RlZF9lbnVtGAQgASgOMkguR29v", - "Z2xlLlByb3RvY29sQnVmZmVycy5UZXN0UHJvdG9zLkZpZWxkUHJlc2VuY2Uu", - "VGVzdEFsbFR5cGVzLk5lc3RlZEVudW0SbAoXb3B0aW9uYWxfbmVzdGVkX21l", - "c3NhZ2UYBSABKAsySy5Hb29nbGUuUHJvdG9jb2xCdWZmZXJzLlRlc3RQcm90", - "b3MuRmllbGRQcmVzZW5jZS5UZXN0QWxsVHlwZXMuTmVzdGVkTWVzc2FnZRoe", - "Cg1OZXN0ZWRNZXNzYWdlEg0KBXZhbHVlGAEgASgFIicKCk5lc3RlZEVudW0S", - "BwoDRk9PEAASBwoDQkFSEAESBwoDQkFaEAJiBnByb3RvMw==")); - pbd::FileDescriptor.InternalDescriptorAssigner assigner = delegate(pbd::FileDescriptor root) { - descriptor = root; - internal__static_Google_ProtocolBuffers_TestProtos_FieldPresence_TestAllTypes__Descriptor = Descriptor.MessageTypes[0]; - internal__static_Google_ProtocolBuffers_TestProtos_FieldPresence_TestAllTypes__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_Google_ProtocolBuffers_TestProtos_FieldPresence_TestAllTypes__Descriptor, - new string[] { "OptionalInt32", "OptionalString", "OptionalBytes", "OptionalNestedEnum", "OptionalNestedMessage", }); - internal__static_Google_ProtocolBuffers_TestProtos_FieldPresence_TestAllTypes_NestedMessage__Descriptor = internal__static_Google_ProtocolBuffers_TestProtos_FieldPresence_TestAllTypes__Descriptor.NestedTypes[0]; - internal__static_Google_ProtocolBuffers_TestProtos_FieldPresence_TestAllTypes_NestedMessage__FieldAccessorTable = - new pb::FieldAccess.FieldAccessorTable(internal__static_Google_ProtocolBuffers_TestProtos_FieldPresence_TestAllTypes_NestedMessage__Descriptor, - new string[] { "Value", }); - 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 TestAllTypes : pb::GeneratedMessage { - private TestAllTypes() { } - private static readonly TestAllTypes defaultInstance = new TestAllTypes().MakeReadOnly(); - private static readonly string[] _testAllTypesFieldNames = new string[] { "optional_bytes", "optional_int32", "optional_nested_enum", "optional_nested_message", "optional_string" }; - private static readonly uint[] _testAllTypesFieldTags = new uint[] { 26, 8, 32, 42, 18 }; - 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.FieldPresence.FieldPresenceTest.internal__static_Google_ProtocolBuffers_TestProtos_FieldPresence_TestAllTypes__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.FieldPresence.FieldPresenceTest.internal__static_Google_ProtocolBuffers_TestProtos_FieldPresence_TestAllTypes__FieldAccessorTable; } - } - - #region Nested types - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public static partial class Types { - public enum NestedEnum { - FOO = 0, - BAR = 1, - BAZ = 2, - } - - [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[] { "value" }; - 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.FieldPresence.FieldPresenceTest.internal__static_Google_ProtocolBuffers_TestProtos_FieldPresence_TestAllTypes_NestedMessage__Descriptor; } - } - - protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { - get { return global::Google.ProtocolBuffers.TestProtos.FieldPresence.FieldPresenceTest.internal__static_Google_ProtocolBuffers_TestProtos_FieldPresence_TestAllTypes_NestedMessage__FieldAccessorTable; } - } - - public const int ValueFieldNumber = 1; - private int value_; - public int Value { - get { return value_; } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _nestedMessageFieldNames; - if (Value != 0) { - output.WriteInt32(1, field_names[0], Value); - } - 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 (Value != 0) { - size += pb::CodedOutputStream.ComputeInt32Size(1, Value); - } - 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.FieldPresence.TestAllTypes.Types.NestedMessage.Descriptor; } - } - - public override NestedMessage DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.FieldPresence.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.FieldPresence.TestAllTypes.Types.NestedMessage.DefaultInstance) return this; - PrepareBuilder(); - if (other.Value != 0) { - Value = other.Value; - } - 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: { - input.ReadInt32(ref result.value_); - break; - } - } - } - - if (unknownFields != null) { - this.UnknownFields = unknownFields.Build(); - } - return this; - } - - - public int Value { - get { return result.Value; } - set { SetValue(value); } - } - public Builder SetValue(int value) { - PrepareBuilder(); - result.value_ = value; - return this; - } - public Builder ClearValue() { - PrepareBuilder(); - result.value_ = 0; - return this; - } - } - static NestedMessage() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.FieldPresence.FieldPresenceTest.Descriptor, null); - } - } - - } - #endregion - - public const int OptionalInt32FieldNumber = 1; - private int optionalInt32_; - public int OptionalInt32 { - get { return optionalInt32_; } - } - - public const int OptionalStringFieldNumber = 2; - private string optionalString_ = ""; - public string OptionalString { - get { return optionalString_; } - } - - public const int OptionalBytesFieldNumber = 3; - private pb::ByteString optionalBytes_ = pb::ByteString.Empty; - public pb::ByteString OptionalBytes { - get { return optionalBytes_; } - } - - public const int OptionalNestedEnumFieldNumber = 4; - private global::Google.ProtocolBuffers.TestProtos.FieldPresence.TestAllTypes.Types.NestedEnum optionalNestedEnum_ = global::Google.ProtocolBuffers.TestProtos.FieldPresence.TestAllTypes.Types.NestedEnum.FOO; - public global::Google.ProtocolBuffers.TestProtos.FieldPresence.TestAllTypes.Types.NestedEnum OptionalNestedEnum { - get { return optionalNestedEnum_; } - } - - public const int OptionalNestedMessageFieldNumber = 5; - private bool hasOptionalNestedMessage; - private global::Google.ProtocolBuffers.TestProtos.FieldPresence.TestAllTypes.Types.NestedMessage optionalNestedMessage_; - public bool HasOptionalNestedMessage { - get { return hasOptionalNestedMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.FieldPresence.TestAllTypes.Types.NestedMessage OptionalNestedMessage { - get { return optionalNestedMessage_ ?? global::Google.ProtocolBuffers.TestProtos.FieldPresence.TestAllTypes.Types.NestedMessage.DefaultInstance; } - } - - public override void WriteTo(pb::ICodedOutputStream output) { - CalcSerializedSize(); - string[] field_names = _testAllTypesFieldNames; - if (OptionalInt32 != 0) { - output.WriteInt32(1, field_names[1], OptionalInt32); - } - if (OptionalString != "") { - output.WriteString(2, field_names[4], OptionalString); - } - if (OptionalBytes != pb::ByteString.Empty) { - output.WriteBytes(3, field_names[0], OptionalBytes); - } - if (OptionalNestedEnum != global::Google.ProtocolBuffers.TestProtos.FieldPresence.TestAllTypes.Types.NestedEnum.FOO) { - output.WriteEnum(4, field_names[2], (int) OptionalNestedEnum, OptionalNestedEnum); - } - if (hasOptionalNestedMessage) { - output.WriteMessage(5, 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 (OptionalInt32 != 0) { - size += pb::CodedOutputStream.ComputeInt32Size(1, OptionalInt32); - } - if (OptionalString != "") { - size += pb::CodedOutputStream.ComputeStringSize(2, OptionalString); - } - if (OptionalBytes != pb::ByteString.Empty) { - size += pb::CodedOutputStream.ComputeBytesSize(3, OptionalBytes); - } - if (OptionalNestedEnum != global::Google.ProtocolBuffers.TestProtos.FieldPresence.TestAllTypes.Types.NestedEnum.FOO) { - size += pb::CodedOutputStream.ComputeEnumSize(4, (int) OptionalNestedEnum); - } - if (hasOptionalNestedMessage) { - size += pb::CodedOutputStream.ComputeMessageSize(5, OptionalNestedMessage); - } - 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() { - 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.FieldPresence.TestAllTypes.Descriptor; } - } - - public override TestAllTypes DefaultInstanceForType { - get { return global::Google.ProtocolBuffers.TestProtos.FieldPresence.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.FieldPresence.TestAllTypes.DefaultInstance) return this; - PrepareBuilder(); - if (other.OptionalInt32 != 0) { - OptionalInt32 = other.OptionalInt32; - } - if (other.OptionalString != "") { - OptionalString = other.OptionalString; - } - if (other.OptionalBytes != pb::ByteString.Empty) { - OptionalBytes = other.OptionalBytes; - } - if (other.OptionalNestedEnum != global::Google.ProtocolBuffers.TestProtos.FieldPresence.TestAllTypes.Types.NestedEnum.FOO) { - OptionalNestedEnum = other.OptionalNestedEnum; - } - 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(_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: { - input.ReadInt32(ref result.optionalInt32_); - break; - } - case 18: { - input.ReadString(ref result.optionalString_); - break; - } - case 26: { - input.ReadBytes(ref result.optionalBytes_); - break; - } - case 32: { - object unknown; - if(input.ReadEnum(ref result.optionalNestedEnum_, out unknown)) { - } else if(unknown is int) { - if (unknownFields == null) { - unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); - } - unknownFields.MergeVarintField(4, (ulong)(int)unknown); - } - break; - } - case 42: { - global::Google.ProtocolBuffers.TestProtos.FieldPresence.TestAllTypes.Types.NestedMessage.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.FieldPresence.TestAllTypes.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 int OptionalInt32 { - get { return result.OptionalInt32; } - set { SetOptionalInt32(value); } - } - public Builder SetOptionalInt32(int value) { - PrepareBuilder(); - result.optionalInt32_ = value; - return this; - } - public Builder ClearOptionalInt32() { - PrepareBuilder(); - result.optionalInt32_ = 0; - return this; - } - - public string OptionalString { - get { return result.OptionalString; } - set { SetOptionalString(value); } - } - public Builder SetOptionalString(string value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.optionalString_ = value; - return this; - } - public Builder ClearOptionalString() { - PrepareBuilder(); - result.optionalString_ = ""; - return this; - } - - public pb::ByteString OptionalBytes { - get { return result.OptionalBytes; } - set { SetOptionalBytes(value); } - } - public Builder SetOptionalBytes(pb::ByteString value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - result.optionalBytes_ = value; - return this; - } - public Builder ClearOptionalBytes() { - PrepareBuilder(); - result.optionalBytes_ = pb::ByteString.Empty; - return this; - } - - public global::Google.ProtocolBuffers.TestProtos.FieldPresence.TestAllTypes.Types.NestedEnum OptionalNestedEnum { - get { return result.OptionalNestedEnum; } - set { SetOptionalNestedEnum(value); } - } - public Builder SetOptionalNestedEnum(global::Google.ProtocolBuffers.TestProtos.FieldPresence.TestAllTypes.Types.NestedEnum value) { - PrepareBuilder(); - result.optionalNestedEnum_ = value; - return this; - } - public Builder ClearOptionalNestedEnum() { - PrepareBuilder(); - result.optionalNestedEnum_ = global::Google.ProtocolBuffers.TestProtos.FieldPresence.TestAllTypes.Types.NestedEnum.FOO; - return this; - } - - public bool HasOptionalNestedMessage { - get { return result.hasOptionalNestedMessage; } - } - public global::Google.ProtocolBuffers.TestProtos.FieldPresence.TestAllTypes.Types.NestedMessage OptionalNestedMessage { - get { return result.OptionalNestedMessage; } - set { SetOptionalNestedMessage(value); } - } - public Builder SetOptionalNestedMessage(global::Google.ProtocolBuffers.TestProtos.FieldPresence.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.FieldPresence.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.FieldPresence.TestAllTypes.Types.NestedMessage value) { - pb::ThrowHelper.ThrowIfNull(value, "value"); - PrepareBuilder(); - if (result.hasOptionalNestedMessage && - result.optionalNestedMessage_ != global::Google.ProtocolBuffers.TestProtos.FieldPresence.TestAllTypes.Types.NestedMessage.DefaultInstance) { - result.optionalNestedMessage_ = global::Google.ProtocolBuffers.TestProtos.FieldPresence.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; - } - } - static TestAllTypes() { - object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.FieldPresence.FieldPresenceTest.Descriptor, null); - } - } - - #endregion - -} - -#endregion Designer generated code diff --git a/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestNoFieldPresence.cs b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestNoFieldPresence.cs new file mode 100644 index 00000000..0d212b72 --- /dev/null +++ b/csharp/src/ProtocolBuffers.Test/TestProtos/UnittestNoFieldPresence.cs @@ -0,0 +1,3776 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/unittest_no_field_presence.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.Proto3 { + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static partial class UnittestNoFieldPresence { + + #region Extension registration + public static void RegisterAllExtensions(pb::ExtensionRegistry registry) { + } + #endregion + #region Static variables + internal static pbd::MessageDescriptor internal__static_proto2_nofieldpresence_unittest_TestAllTypes__Descriptor; + internal static pb::FieldAccess.FieldAccessorTable internal__static_proto2_nofieldpresence_unittest_TestAllTypes__FieldAccessorTable; + internal static pbd::MessageDescriptor internal__static_proto2_nofieldpresence_unittest_TestAllTypes_NestedMessage__Descriptor; + internal static pb::FieldAccess.FieldAccessorTable internal__static_proto2_nofieldpresence_unittest_TestAllTypes_NestedMessage__FieldAccessorTable; + internal static pbd::MessageDescriptor internal__static_proto2_nofieldpresence_unittest_TestProto2Required__Descriptor; + internal static pb::FieldAccess.FieldAccessorTable internal__static_proto2_nofieldpresence_unittest_TestProto2Required__FieldAccessorTable; + internal static pbd::MessageDescriptor internal__static_proto2_nofieldpresence_unittest_ForeignMessage__Descriptor; + internal static pb::FieldAccess.FieldAccessorTable internal__static_proto2_nofieldpresence_unittest_ForeignMessage__FieldAccessorTable; + #endregion + #region Descriptor + public static pbd::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbd::FileDescriptor descriptor; + + static UnittestNoFieldPresence() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "CjBnb29nbGUvcHJvdG9idWYvdW5pdHRlc3Rfbm9fZmllbGRfcHJlc2VuY2Uu", + "cHJvdG8SH3Byb3RvMl9ub2ZpZWxkcHJlc2VuY2VfdW5pdHRlc3QaHmdvb2ds", + "ZS9wcm90b2J1Zi91bml0dGVzdC5wcm90byKaEQoMVGVzdEFsbFR5cGVzEhYK", + "Dm9wdGlvbmFsX2ludDMyGAEgASgFEhYKDm9wdGlvbmFsX2ludDY0GAIgASgD", + "EhcKD29wdGlvbmFsX3VpbnQzMhgDIAEoDRIXCg9vcHRpb25hbF91aW50NjQY", + "BCABKAQSFwoPb3B0aW9uYWxfc2ludDMyGAUgASgREhcKD29wdGlvbmFsX3Np", + "bnQ2NBgGIAEoEhIYChBvcHRpb25hbF9maXhlZDMyGAcgASgHEhgKEG9wdGlv", + "bmFsX2ZpeGVkNjQYCCABKAYSGQoRb3B0aW9uYWxfc2ZpeGVkMzIYCSABKA8S", + "GQoRb3B0aW9uYWxfc2ZpeGVkNjQYCiABKBASFgoOb3B0aW9uYWxfZmxvYXQY", + "CyABKAISFwoPb3B0aW9uYWxfZG91YmxlGAwgASgBEhUKDW9wdGlvbmFsX2Jv", + "b2wYDSABKAgSFwoPb3B0aW9uYWxfc3RyaW5nGA4gASgJEhYKDm9wdGlvbmFs", + "X2J5dGVzGA8gASgMElwKF29wdGlvbmFsX25lc3RlZF9tZXNzYWdlGBIgASgL", + "MjsucHJvdG8yX25vZmllbGRwcmVzZW5jZV91bml0dGVzdC5UZXN0QWxsVHlw", + "ZXMuTmVzdGVkTWVzc2FnZRJRChhvcHRpb25hbF9mb3JlaWduX21lc3NhZ2UY", + "EyABKAsyLy5wcm90bzJfbm9maWVsZHByZXNlbmNlX3VuaXR0ZXN0LkZvcmVp", + "Z25NZXNzYWdlEkAKF29wdGlvbmFsX3Byb3RvMl9tZXNzYWdlGBQgASgLMh8u", + "cHJvdG9idWZfdW5pdHRlc3QuVGVzdEFsbFR5cGVzElYKFG9wdGlvbmFsX25l", + "c3RlZF9lbnVtGBUgASgOMjgucHJvdG8yX25vZmllbGRwcmVzZW5jZV91bml0", + "dGVzdC5UZXN0QWxsVHlwZXMuTmVzdGVkRW51bRJLChVvcHRpb25hbF9mb3Jl", + "aWduX2VudW0YFiABKA4yLC5wcm90bzJfbm9maWVsZHByZXNlbmNlX3VuaXR0", + "ZXN0LkZvcmVpZ25FbnVtEiEKFW9wdGlvbmFsX3N0cmluZ19waWVjZRgYIAEo", + "CUICCAISGQoNb3B0aW9uYWxfY29yZBgZIAEoCUICCAESXgoVb3B0aW9uYWxf", + "bGF6eV9tZXNzYWdlGB4gASgLMjsucHJvdG8yX25vZmllbGRwcmVzZW5jZV91", + "bml0dGVzdC5UZXN0QWxsVHlwZXMuTmVzdGVkTWVzc2FnZUICKAESFgoOcmVw", + "ZWF0ZWRfaW50MzIYHyADKAUSFgoOcmVwZWF0ZWRfaW50NjQYICADKAMSFwoP", + "cmVwZWF0ZWRfdWludDMyGCEgAygNEhcKD3JlcGVhdGVkX3VpbnQ2NBgiIAMo", + "BBIXCg9yZXBlYXRlZF9zaW50MzIYIyADKBESFwoPcmVwZWF0ZWRfc2ludDY0", + "GCQgAygSEhgKEHJlcGVhdGVkX2ZpeGVkMzIYJSADKAcSGAoQcmVwZWF0ZWRf", + "Zml4ZWQ2NBgmIAMoBhIZChFyZXBlYXRlZF9zZml4ZWQzMhgnIAMoDxIZChFy", + "ZXBlYXRlZF9zZml4ZWQ2NBgoIAMoEBIWCg5yZXBlYXRlZF9mbG9hdBgpIAMo", + "AhIXCg9yZXBlYXRlZF9kb3VibGUYKiADKAESFQoNcmVwZWF0ZWRfYm9vbBgr", + "IAMoCBIXCg9yZXBlYXRlZF9zdHJpbmcYLCADKAkSFgoOcmVwZWF0ZWRfYnl0", + "ZXMYLSADKAwSXAoXcmVwZWF0ZWRfbmVzdGVkX21lc3NhZ2UYMCADKAsyOy5w", + "cm90bzJfbm9maWVsZHByZXNlbmNlX3VuaXR0ZXN0LlRlc3RBbGxUeXBlcy5O", + "ZXN0ZWRNZXNzYWdlElEKGHJlcGVhdGVkX2ZvcmVpZ25fbWVzc2FnZRgxIAMo", + "CzIvLnByb3RvMl9ub2ZpZWxkcHJlc2VuY2VfdW5pdHRlc3QuRm9yZWlnbk1l", + "c3NhZ2USQAoXcmVwZWF0ZWRfcHJvdG8yX21lc3NhZ2UYMiADKAsyHy5wcm90", + "b2J1Zl91bml0dGVzdC5UZXN0QWxsVHlwZXMSVgoUcmVwZWF0ZWRfbmVzdGVk", + "X2VudW0YMyADKA4yOC5wcm90bzJfbm9maWVsZHByZXNlbmNlX3VuaXR0ZXN0", + "LlRlc3RBbGxUeXBlcy5OZXN0ZWRFbnVtEksKFXJlcGVhdGVkX2ZvcmVpZ25f", + "ZW51bRg0IAMoDjIsLnByb3RvMl9ub2ZpZWxkcHJlc2VuY2VfdW5pdHRlc3Qu", + "Rm9yZWlnbkVudW0SIQoVcmVwZWF0ZWRfc3RyaW5nX3BpZWNlGDYgAygJQgII", + "AhIZCg1yZXBlYXRlZF9jb3JkGDcgAygJQgIIARJeChVyZXBlYXRlZF9sYXp5", + "X21lc3NhZ2UYOSADKAsyOy5wcm90bzJfbm9maWVsZHByZXNlbmNlX3VuaXR0", + "ZXN0LlRlc3RBbGxUeXBlcy5OZXN0ZWRNZXNzYWdlQgIoARIWCgxvbmVvZl91", + "aW50MzIYbyABKA1IABJbChRvbmVvZl9uZXN0ZWRfbWVzc2FnZRhwIAEoCzI7", + "LnByb3RvMl9ub2ZpZWxkcHJlc2VuY2VfdW5pdHRlc3QuVGVzdEFsbFR5cGVz", + "Lk5lc3RlZE1lc3NhZ2VIABIWCgxvbmVvZl9zdHJpbmcYcSABKAlIABJOCgpv", + "bmVvZl9lbnVtGHIgASgOMjgucHJvdG8yX25vZmllbGRwcmVzZW5jZV91bml0", + "dGVzdC5UZXN0QWxsVHlwZXMuTmVzdGVkRW51bUgAGhsKDU5lc3RlZE1lc3Nh", + "Z2USCgoCYmIYASABKAUiJwoKTmVzdGVkRW51bRIHCgNGT08QABIHCgNCQVIQ", + "ARIHCgNCQVoQAkINCgtvbmVvZl9maWVsZCJFChJUZXN0UHJvdG8yUmVxdWly", + "ZWQSLwoGcHJvdG8yGAEgASgLMh8ucHJvdG9idWZfdW5pdHRlc3QuVGVzdFJl", + "cXVpcmVkIhsKDkZvcmVpZ25NZXNzYWdlEgkKAWMYASABKAUqQAoLRm9yZWln", + "bkVudW0SDwoLRk9SRUlHTl9GT08QABIPCgtGT1JFSUdOX0JBUhABEg8KC0ZP", + "UkVJR05fQkFaEAJCK6oCKEdvb2dsZS5Qcm90b2NvbEJ1ZmZlcnMuVGVzdFBy", + "b3Rvcy5Qcm90bzNiBnByb3RvMw==")); + pbd::FileDescriptor.InternalDescriptorAssigner assigner = delegate(pbd::FileDescriptor root) { + descriptor = root; + internal__static_proto2_nofieldpresence_unittest_TestAllTypes__Descriptor = Descriptor.MessageTypes[0]; + internal__static_proto2_nofieldpresence_unittest_TestAllTypes__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(internal__static_proto2_nofieldpresence_unittest_TestAllTypes__Descriptor, + new string[] { "OptionalInt32", "OptionalInt64", "OptionalUint32", "OptionalUint64", "OptionalSint32", "OptionalSint64", "OptionalFixed32", "OptionalFixed64", "OptionalSfixed32", "OptionalSfixed64", "OptionalFloat", "OptionalDouble", "OptionalBool", "OptionalString", "OptionalBytes", "OptionalNestedMessage", "OptionalForeignMessage", "OptionalProto2Message", "OptionalNestedEnum", "OptionalForeignEnum", "OptionalStringPiece", "OptionalCord", "OptionalLazyMessage", "RepeatedInt32", "RepeatedInt64", "RepeatedUint32", "RepeatedUint64", "RepeatedSint32", "RepeatedSint64", "RepeatedFixed32", "RepeatedFixed64", "RepeatedSfixed32", "RepeatedSfixed64", "RepeatedFloat", "RepeatedDouble", "RepeatedBool", "RepeatedString", "RepeatedBytes", "RepeatedNestedMessage", "RepeatedForeignMessage", "RepeatedProto2Message", "RepeatedNestedEnum", "RepeatedForeignEnum", "RepeatedStringPiece", "RepeatedCord", "RepeatedLazyMessage", "OneofUint32", "OneofNestedMessage", "OneofString", "OneofEnum", }); + internal__static_proto2_nofieldpresence_unittest_TestAllTypes_NestedMessage__Descriptor = internal__static_proto2_nofieldpresence_unittest_TestAllTypes__Descriptor.NestedTypes[0]; + internal__static_proto2_nofieldpresence_unittest_TestAllTypes_NestedMessage__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(internal__static_proto2_nofieldpresence_unittest_TestAllTypes_NestedMessage__Descriptor, + new string[] { "Bb", }); + internal__static_proto2_nofieldpresence_unittest_TestProto2Required__Descriptor = Descriptor.MessageTypes[1]; + internal__static_proto2_nofieldpresence_unittest_TestProto2Required__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(internal__static_proto2_nofieldpresence_unittest_TestProto2Required__Descriptor, + new string[] { "Proto2", }); + internal__static_proto2_nofieldpresence_unittest_ForeignMessage__Descriptor = Descriptor.MessageTypes[2]; + internal__static_proto2_nofieldpresence_unittest_ForeignMessage__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable(internal__static_proto2_nofieldpresence_unittest_ForeignMessage__Descriptor, + new string[] { "C", }); + pb::ExtensionRegistry registry = pb::ExtensionRegistry.CreateInstance(); + RegisterAllExtensions(registry); + global::Google.ProtocolBuffers.TestProtos.Unittest.RegisterAllExtensions(registry); + return registry; + }; + pbd::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, + new pbd::FileDescriptor[] { + global::Google.ProtocolBuffers.TestProtos.Unittest.Descriptor, + }, assigner); + } + #endregion + + } + #region Enums + public enum ForeignEnum { + FOREIGN_FOO = 0, + FOREIGN_BAR = 1, + FOREIGN_BAZ = 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[] { "oneof_enum", "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_int32", "optional_int64", "optional_lazy_message", "optional_nested_enum", "optional_nested_message", "optional_proto2_message", "optional_sfixed32", "optional_sfixed64", "optional_sint32", "optional_sint64", "optional_string", "optional_string_piece", "optional_uint32", "optional_uint64", "repeated_bool", "repeated_bytes", "repeated_cord", "repeated_double", "repeated_fixed32", "repeated_fixed64", "repeated_float", "repeated_foreign_enum", "repeated_foreign_message", "repeated_int32", "repeated_int64", "repeated_lazy_message", "repeated_nested_enum", "repeated_nested_message", "repeated_proto2_message", "repeated_sfixed32", "repeated_sfixed64", "repeated_sint32", "repeated_sint64", "repeated_string", "repeated_string_piece", "repeated_uint32", "repeated_uint64" }; + private static readonly uint[] _testAllTypesFieldTags = new uint[] { 912, 898, 906, 888, 104, 122, 202, 97, 61, 65, 93, 176, 154, 8, 16, 242, 168, 146, 162, 77, 81, 40, 48, 114, 194, 24, 32, 344, 362, 442, 337, 301, 305, 333, 416, 394, 248, 256, 458, 408, 386, 402, 317, 321, 280, 288, 354, 434, 264, 272 }; + 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.Proto3.UnittestNoFieldPresence.internal__static_proto2_nofieldpresence_unittest_TestAllTypes__Descriptor; } + } + + protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { + get { return global::Google.ProtocolBuffers.TestProtos.Proto3.UnittestNoFieldPresence.internal__static_proto2_nofieldpresence_unittest_TestAllTypes__FieldAccessorTable; } + } + + #region Nested types + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static partial class Types { + public enum NestedEnum { + FOO = 0, + BAR = 1, + BAZ = 2, + } + + [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.Proto3.UnittestNoFieldPresence.internal__static_proto2_nofieldpresence_unittest_TestAllTypes_NestedMessage__Descriptor; } + } + + protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { + get { return global::Google.ProtocolBuffers.TestProtos.Proto3.UnittestNoFieldPresence.internal__static_proto2_nofieldpresence_unittest_TestAllTypes_NestedMessage__FieldAccessorTable; } + } + + public const int BbFieldNumber = 1; + private int bb_; + public int Bb { + get { return bb_; } + } + + public override void WriteTo(pb::ICodedOutputStream output) { + CalcSerializedSize(); + string[] field_names = _nestedMessageFieldNames; + if (Bb != 0) { + 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 (Bb != 0) { + 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.Proto3.TestAllTypes.Types.NestedMessage.Descriptor; } + } + + public override NestedMessage DefaultInstanceForType { + get { return global::Google.ProtocolBuffers.TestProtos.Proto3.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.Proto3.TestAllTypes.Types.NestedMessage.DefaultInstance) return this; + PrepareBuilder(); + if (other.Bb != 0) { + 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: { + input.ReadInt32(ref result.bb_); + break; + } + } + } + + if (unknownFields != null) { + this.UnknownFields = unknownFields.Build(); + } + return this; + } + + + public int Bb { + get { return result.Bb; } + set { SetBb(value); } + } + public Builder SetBb(int value) { + PrepareBuilder(); + result.bb_ = value; + return this; + } + public Builder ClearBb() { + PrepareBuilder(); + result.bb_ = 0; + return this; + } + } + static NestedMessage() { + object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Proto3.UnittestNoFieldPresence.Descriptor, null); + } + } + + } + #endregion + + public const int OptionalInt32FieldNumber = 1; + private int optionalInt32_; + public int OptionalInt32 { + get { return optionalInt32_; } + } + + public const int OptionalInt64FieldNumber = 2; + private long optionalInt64_; + public long OptionalInt64 { + get { return optionalInt64_; } + } + + public const int OptionalUint32FieldNumber = 3; + private uint optionalUint32_; + public uint OptionalUint32 { + get { return optionalUint32_; } + } + + public const int OptionalUint64FieldNumber = 4; + private ulong optionalUint64_; + public ulong OptionalUint64 { + get { return optionalUint64_; } + } + + public const int OptionalSint32FieldNumber = 5; + private int optionalSint32_; + public int OptionalSint32 { + get { return optionalSint32_; } + } + + public const int OptionalSint64FieldNumber = 6; + private long optionalSint64_; + public long OptionalSint64 { + get { return optionalSint64_; } + } + + public const int OptionalFixed32FieldNumber = 7; + private uint optionalFixed32_; + public uint OptionalFixed32 { + get { return optionalFixed32_; } + } + + public const int OptionalFixed64FieldNumber = 8; + private ulong optionalFixed64_; + public ulong OptionalFixed64 { + get { return optionalFixed64_; } + } + + public const int OptionalSfixed32FieldNumber = 9; + private int optionalSfixed32_; + public int OptionalSfixed32 { + get { return optionalSfixed32_; } + } + + public const int OptionalSfixed64FieldNumber = 10; + private long optionalSfixed64_; + public long OptionalSfixed64 { + get { return optionalSfixed64_; } + } + + public const int OptionalFloatFieldNumber = 11; + private float optionalFloat_; + public float OptionalFloat { + get { return optionalFloat_; } + } + + public const int OptionalDoubleFieldNumber = 12; + private double optionalDouble_; + public double OptionalDouble { + get { return optionalDouble_; } + } + + public const int OptionalBoolFieldNumber = 13; + private bool optionalBool_; + public bool OptionalBool { + get { return optionalBool_; } + } + + public const int OptionalStringFieldNumber = 14; + private string optionalString_ = ""; + public string OptionalString { + get { return optionalString_; } + } + + public const int OptionalBytesFieldNumber = 15; + private pb::ByteString optionalBytes_ = pb::ByteString.Empty; + public pb::ByteString OptionalBytes { + get { return optionalBytes_; } + } + + public const int OptionalNestedMessageFieldNumber = 18; + private bool hasOptionalNestedMessage; + private global::Google.ProtocolBuffers.TestProtos.Proto3.TestAllTypes.Types.NestedMessage optionalNestedMessage_; + public bool HasOptionalNestedMessage { + get { return hasOptionalNestedMessage; } + } + public global::Google.ProtocolBuffers.TestProtos.Proto3.TestAllTypes.Types.NestedMessage OptionalNestedMessage { + get { return optionalNestedMessage_ ?? global::Google.ProtocolBuffers.TestProtos.Proto3.TestAllTypes.Types.NestedMessage.DefaultInstance; } + } + + public const int OptionalForeignMessageFieldNumber = 19; + private bool hasOptionalForeignMessage; + private global::Google.ProtocolBuffers.TestProtos.Proto3.ForeignMessage optionalForeignMessage_; + public bool HasOptionalForeignMessage { + get { return hasOptionalForeignMessage; } + } + public global::Google.ProtocolBuffers.TestProtos.Proto3.ForeignMessage OptionalForeignMessage { + get { return optionalForeignMessage_ ?? global::Google.ProtocolBuffers.TestProtos.Proto3.ForeignMessage.DefaultInstance; } + } + + public const int OptionalProto2MessageFieldNumber = 20; + private bool hasOptionalProto2Message; + private global::Google.ProtocolBuffers.TestProtos.TestAllTypes optionalProto2Message_; + public bool HasOptionalProto2Message { + get { return hasOptionalProto2Message; } + } + public global::Google.ProtocolBuffers.TestProtos.TestAllTypes OptionalProto2Message { + get { return optionalProto2Message_ ?? global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance; } + } + + public const int OptionalNestedEnumFieldNumber = 21; + private global::Google.ProtocolBuffers.TestProtos.Proto3.TestAllTypes.Types.NestedEnum optionalNestedEnum_ = global::Google.ProtocolBuffers.TestProtos.Proto3.TestAllTypes.Types.NestedEnum.FOO; + public global::Google.ProtocolBuffers.TestProtos.Proto3.TestAllTypes.Types.NestedEnum OptionalNestedEnum { + get { return optionalNestedEnum_; } + } + + public const int OptionalForeignEnumFieldNumber = 22; + private global::Google.ProtocolBuffers.TestProtos.Proto3.ForeignEnum optionalForeignEnum_ = global::Google.ProtocolBuffers.TestProtos.Proto3.ForeignEnum.FOREIGN_FOO; + public global::Google.ProtocolBuffers.TestProtos.Proto3.ForeignEnum OptionalForeignEnum { + get { return optionalForeignEnum_; } + } + + public const int OptionalStringPieceFieldNumber = 24; + private string optionalStringPiece_ = ""; + public string OptionalStringPiece { + get { return optionalStringPiece_; } + } + + public const int OptionalCordFieldNumber = 25; + private string optionalCord_ = ""; + public string OptionalCord { + get { return optionalCord_; } + } + + public const int OptionalLazyMessageFieldNumber = 30; + private bool hasOptionalLazyMessage; + private global::Google.ProtocolBuffers.TestProtos.Proto3.TestAllTypes.Types.NestedMessage optionalLazyMessage_; + public bool HasOptionalLazyMessage { + get { return hasOptionalLazyMessage; } + } + public global::Google.ProtocolBuffers.TestProtos.Proto3.TestAllTypes.Types.NestedMessage OptionalLazyMessage { + get { return optionalLazyMessage_ ?? global::Google.ProtocolBuffers.TestProtos.Proto3.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 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.Proto3.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.Proto3.ForeignMessage GetRepeatedForeignMessage(int index) { + return repeatedForeignMessage_[index]; + } + + public const int RepeatedProto2MessageFieldNumber = 50; + private pbc::PopsicleList repeatedProto2Message_ = new pbc::PopsicleList(); + public scg::IList RepeatedProto2MessageList { + get { return repeatedProto2Message_; } + } + public int RepeatedProto2MessageCount { + get { return repeatedProto2Message_.Count; } + } + public global::Google.ProtocolBuffers.TestProtos.TestAllTypes GetRepeatedProto2Message(int index) { + return repeatedProto2Message_[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.Proto3.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.Proto3.ForeignEnum GetRepeatedForeignEnum(int index) { + return repeatedForeignEnum_[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.Proto3.TestAllTypes.Types.NestedMessage GetRepeatedLazyMessage(int index) { + return repeatedLazyMessage_[index]; + } + + public const int OneofUint32FieldNumber = 111; + private uint oneofUint32_; + public uint OneofUint32 { + get { return oneofUint32_; } + } + + public const int OneofNestedMessageFieldNumber = 112; + private bool hasOneofNestedMessage; + private global::Google.ProtocolBuffers.TestProtos.Proto3.TestAllTypes.Types.NestedMessage oneofNestedMessage_; + public bool HasOneofNestedMessage { + get { return hasOneofNestedMessage; } + } + public global::Google.ProtocolBuffers.TestProtos.Proto3.TestAllTypes.Types.NestedMessage OneofNestedMessage { + get { return oneofNestedMessage_ ?? global::Google.ProtocolBuffers.TestProtos.Proto3.TestAllTypes.Types.NestedMessage.DefaultInstance; } + } + + public const int OneofStringFieldNumber = 113; + private string oneofString_ = ""; + public string OneofString { + get { return oneofString_; } + } + + public const int OneofEnumFieldNumber = 114; + private global::Google.ProtocolBuffers.TestProtos.Proto3.TestAllTypes.Types.NestedEnum oneofEnum_ = global::Google.ProtocolBuffers.TestProtos.Proto3.TestAllTypes.Types.NestedEnum.FOO; + public global::Google.ProtocolBuffers.TestProtos.Proto3.TestAllTypes.Types.NestedEnum OneofEnum { + get { return oneofEnum_; } + } + + public override void WriteTo(pb::ICodedOutputStream output) { + CalcSerializedSize(); + string[] field_names = _testAllTypesFieldNames; + if (OptionalInt32 != 0) { + output.WriteInt32(1, field_names[13], OptionalInt32); + } + if (OptionalInt64 != 0L) { + output.WriteInt64(2, field_names[14], OptionalInt64); + } + if (OptionalUint32 != 0) { + output.WriteUInt32(3, field_names[25], OptionalUint32); + } + if (OptionalUint64 != 0UL) { + output.WriteUInt64(4, field_names[26], OptionalUint64); + } + if (OptionalSint32 != 0) { + output.WriteSInt32(5, field_names[21], OptionalSint32); + } + if (OptionalSint64 != 0L) { + output.WriteSInt64(6, field_names[22], OptionalSint64); + } + if (OptionalFixed32 != 0) { + output.WriteFixed32(7, field_names[8], OptionalFixed32); + } + if (OptionalFixed64 != 0UL) { + output.WriteFixed64(8, field_names[9], OptionalFixed64); + } + if (OptionalSfixed32 != 0) { + output.WriteSFixed32(9, field_names[19], OptionalSfixed32); + } + if (OptionalSfixed64 != 0L) { + output.WriteSFixed64(10, field_names[20], OptionalSfixed64); + } + if (OptionalFloat != 0F) { + output.WriteFloat(11, field_names[10], OptionalFloat); + } + if (OptionalDouble != 0D) { + output.WriteDouble(12, field_names[7], OptionalDouble); + } + if (OptionalBool != false) { + output.WriteBool(13, field_names[4], OptionalBool); + } + if (OptionalString != "") { + output.WriteString(14, field_names[23], OptionalString); + } + if (OptionalBytes != pb::ByteString.Empty) { + output.WriteBytes(15, field_names[5], OptionalBytes); + } + if (hasOptionalNestedMessage) { + output.WriteMessage(18, field_names[17], OptionalNestedMessage); + } + if (hasOptionalForeignMessage) { + output.WriteMessage(19, field_names[12], OptionalForeignMessage); + } + if (hasOptionalProto2Message) { + output.WriteMessage(20, field_names[18], OptionalProto2Message); + } + if (OptionalNestedEnum != global::Google.ProtocolBuffers.TestProtos.Proto3.TestAllTypes.Types.NestedEnum.FOO) { + output.WriteEnum(21, field_names[16], (int) OptionalNestedEnum, OptionalNestedEnum); + } + if (OptionalForeignEnum != global::Google.ProtocolBuffers.TestProtos.Proto3.ForeignEnum.FOREIGN_FOO) { + output.WriteEnum(22, field_names[11], (int) OptionalForeignEnum, OptionalForeignEnum); + } + if (OptionalStringPiece != "") { + output.WriteString(24, field_names[24], OptionalStringPiece); + } + if (OptionalCord != "") { + output.WriteString(25, field_names[6], OptionalCord); + } + if (hasOptionalLazyMessage) { + output.WriteMessage(30, field_names[15], OptionalLazyMessage); + } + if (repeatedInt32_.Count > 0) { + output.WriteInt32Array(31, field_names[36], repeatedInt32_); + } + if (repeatedInt64_.Count > 0) { + output.WriteInt64Array(32, field_names[37], repeatedInt64_); + } + if (repeatedUint32_.Count > 0) { + output.WriteUInt32Array(33, field_names[48], repeatedUint32_); + } + if (repeatedUint64_.Count > 0) { + output.WriteUInt64Array(34, field_names[49], repeatedUint64_); + } + if (repeatedSint32_.Count > 0) { + output.WriteSInt32Array(35, field_names[44], repeatedSint32_); + } + if (repeatedSint64_.Count > 0) { + output.WriteSInt64Array(36, field_names[45], repeatedSint64_); + } + if (repeatedFixed32_.Count > 0) { + output.WriteFixed32Array(37, field_names[31], repeatedFixed32_); + } + if (repeatedFixed64_.Count > 0) { + output.WriteFixed64Array(38, field_names[32], repeatedFixed64_); + } + if (repeatedSfixed32_.Count > 0) { + output.WriteSFixed32Array(39, field_names[42], repeatedSfixed32_); + } + if (repeatedSfixed64_.Count > 0) { + output.WriteSFixed64Array(40, field_names[43], repeatedSfixed64_); + } + if (repeatedFloat_.Count > 0) { + output.WriteFloatArray(41, field_names[33], repeatedFloat_); + } + if (repeatedDouble_.Count > 0) { + output.WriteDoubleArray(42, field_names[30], repeatedDouble_); + } + if (repeatedBool_.Count > 0) { + output.WriteBoolArray(43, field_names[27], repeatedBool_); + } + if (repeatedString_.Count > 0) { + output.WriteStringArray(44, field_names[46], repeatedString_); + } + if (repeatedBytes_.Count > 0) { + output.WriteBytesArray(45, field_names[28], repeatedBytes_); + } + if (repeatedNestedMessage_.Count > 0) { + output.WriteMessageArray(48, field_names[40], repeatedNestedMessage_); + } + if (repeatedForeignMessage_.Count > 0) { + output.WriteMessageArray(49, field_names[35], repeatedForeignMessage_); + } + if (repeatedProto2Message_.Count > 0) { + output.WriteMessageArray(50, field_names[41], repeatedProto2Message_); + } + if (repeatedNestedEnum_.Count > 0) { + output.WriteEnumArray(51, field_names[39], repeatedNestedEnum_); + } + if (repeatedForeignEnum_.Count > 0) { + output.WriteEnumArray(52, field_names[34], repeatedForeignEnum_); + } + if (repeatedStringPiece_.Count > 0) { + output.WriteStringArray(54, field_names[47], repeatedStringPiece_); + } + if (repeatedCord_.Count > 0) { + output.WriteStringArray(55, field_names[29], repeatedCord_); + } + if (repeatedLazyMessage_.Count > 0) { + output.WriteMessageArray(57, field_names[38], repeatedLazyMessage_); + } + if (OneofUint32 != 0) { + output.WriteUInt32(111, field_names[3], OneofUint32); + } + if (hasOneofNestedMessage) { + output.WriteMessage(112, field_names[1], OneofNestedMessage); + } + if (OneofString != "") { + output.WriteString(113, field_names[2], OneofString); + } + if (OneofEnum != global::Google.ProtocolBuffers.TestProtos.Proto3.TestAllTypes.Types.NestedEnum.FOO) { + output.WriteEnum(114, field_names[0], (int) OneofEnum, OneofEnum); + } + 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 (OptionalInt32 != 0) { + size += pb::CodedOutputStream.ComputeInt32Size(1, OptionalInt32); + } + if (OptionalInt64 != 0L) { + size += pb::CodedOutputStream.ComputeInt64Size(2, OptionalInt64); + } + if (OptionalUint32 != 0) { + size += pb::CodedOutputStream.ComputeUInt32Size(3, OptionalUint32); + } + if (OptionalUint64 != 0UL) { + size += pb::CodedOutputStream.ComputeUInt64Size(4, OptionalUint64); + } + if (OptionalSint32 != 0) { + size += pb::CodedOutputStream.ComputeSInt32Size(5, OptionalSint32); + } + if (OptionalSint64 != 0L) { + size += pb::CodedOutputStream.ComputeSInt64Size(6, OptionalSint64); + } + if (OptionalFixed32 != 0) { + size += pb::CodedOutputStream.ComputeFixed32Size(7, OptionalFixed32); + } + if (OptionalFixed64 != 0UL) { + size += pb::CodedOutputStream.ComputeFixed64Size(8, OptionalFixed64); + } + if (OptionalSfixed32 != 0) { + size += pb::CodedOutputStream.ComputeSFixed32Size(9, OptionalSfixed32); + } + if (OptionalSfixed64 != 0L) { + size += pb::CodedOutputStream.ComputeSFixed64Size(10, OptionalSfixed64); + } + if (OptionalFloat != 0F) { + size += pb::CodedOutputStream.ComputeFloatSize(11, OptionalFloat); + } + if (OptionalDouble != 0D) { + size += pb::CodedOutputStream.ComputeDoubleSize(12, OptionalDouble); + } + if (OptionalBool != false) { + size += pb::CodedOutputStream.ComputeBoolSize(13, OptionalBool); + } + if (OptionalString != "") { + size += pb::CodedOutputStream.ComputeStringSize(14, OptionalString); + } + if (OptionalBytes != pb::ByteString.Empty) { + size += pb::CodedOutputStream.ComputeBytesSize(15, OptionalBytes); + } + if (hasOptionalNestedMessage) { + size += pb::CodedOutputStream.ComputeMessageSize(18, OptionalNestedMessage); + } + if (hasOptionalForeignMessage) { + size += pb::CodedOutputStream.ComputeMessageSize(19, OptionalForeignMessage); + } + if (hasOptionalProto2Message) { + size += pb::CodedOutputStream.ComputeMessageSize(20, OptionalProto2Message); + } + if (OptionalNestedEnum != global::Google.ProtocolBuffers.TestProtos.Proto3.TestAllTypes.Types.NestedEnum.FOO) { + size += pb::CodedOutputStream.ComputeEnumSize(21, (int) OptionalNestedEnum); + } + if (OptionalForeignEnum != global::Google.ProtocolBuffers.TestProtos.Proto3.ForeignEnum.FOREIGN_FOO) { + size += pb::CodedOutputStream.ComputeEnumSize(22, (int) OptionalForeignEnum); + } + if (OptionalStringPiece != "") { + size += pb::CodedOutputStream.ComputeStringSize(24, OptionalStringPiece); + } + if (OptionalCord != "") { + size += pb::CodedOutputStream.ComputeStringSize(25, OptionalCord); + } + if (hasOptionalLazyMessage) { + size += pb::CodedOutputStream.ComputeMessageSize(30, 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.Proto3.TestAllTypes.Types.NestedMessage element in RepeatedNestedMessageList) { + size += pb::CodedOutputStream.ComputeMessageSize(48, element); + } + foreach (global::Google.ProtocolBuffers.TestProtos.Proto3.ForeignMessage element in RepeatedForeignMessageList) { + size += pb::CodedOutputStream.ComputeMessageSize(49, element); + } + foreach (global::Google.ProtocolBuffers.TestProtos.TestAllTypes element in RepeatedProto2MessageList) { + size += pb::CodedOutputStream.ComputeMessageSize(50, element); + } + { + int dataSize = 0; + if (repeatedNestedEnum_.Count > 0) { + foreach (global::Google.ProtocolBuffers.TestProtos.Proto3.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.Proto3.ForeignEnum element in repeatedForeignEnum_) { + dataSize += pb::CodedOutputStream.ComputeEnumSizeNoTag((int) element); + } + size += dataSize; + size += 2 * repeatedForeignEnum_.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.Proto3.TestAllTypes.Types.NestedMessage element in RepeatedLazyMessageList) { + size += pb::CodedOutputStream.ComputeMessageSize(57, element); + } + if (OneofUint32 != 0) { + size += pb::CodedOutputStream.ComputeUInt32Size(111, OneofUint32); + } + if (hasOneofNestedMessage) { + size += pb::CodedOutputStream.ComputeMessageSize(112, OneofNestedMessage); + } + if (OneofString != "") { + size += pb::CodedOutputStream.ComputeStringSize(113, OneofString); + } + if (OneofEnum != global::Google.ProtocolBuffers.TestProtos.Proto3.TestAllTypes.Types.NestedEnum.FOO) { + size += pb::CodedOutputStream.ComputeEnumSize(114, (int) OneofEnum); + } + 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(); + repeatedNestedMessage_.MakeReadOnly(); + repeatedForeignMessage_.MakeReadOnly(); + repeatedProto2Message_.MakeReadOnly(); + repeatedNestedEnum_.MakeReadOnly(); + repeatedForeignEnum_.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.Proto3.TestAllTypes.Descriptor; } + } + + public override TestAllTypes DefaultInstanceForType { + get { return global::Google.ProtocolBuffers.TestProtos.Proto3.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.Proto3.TestAllTypes.DefaultInstance) return this; + PrepareBuilder(); + if (other.OptionalInt32 != 0) { + OptionalInt32 = other.OptionalInt32; + } + if (other.OptionalInt64 != 0L) { + OptionalInt64 = other.OptionalInt64; + } + if (other.OptionalUint32 != 0) { + OptionalUint32 = other.OptionalUint32; + } + if (other.OptionalUint64 != 0UL) { + OptionalUint64 = other.OptionalUint64; + } + if (other.OptionalSint32 != 0) { + OptionalSint32 = other.OptionalSint32; + } + if (other.OptionalSint64 != 0L) { + OptionalSint64 = other.OptionalSint64; + } + if (other.OptionalFixed32 != 0) { + OptionalFixed32 = other.OptionalFixed32; + } + if (other.OptionalFixed64 != 0UL) { + OptionalFixed64 = other.OptionalFixed64; + } + if (other.OptionalSfixed32 != 0) { + OptionalSfixed32 = other.OptionalSfixed32; + } + if (other.OptionalSfixed64 != 0L) { + OptionalSfixed64 = other.OptionalSfixed64; + } + if (other.OptionalFloat != 0F) { + OptionalFloat = other.OptionalFloat; + } + if (other.OptionalDouble != 0D) { + OptionalDouble = other.OptionalDouble; + } + if (other.OptionalBool != false) { + OptionalBool = other.OptionalBool; + } + if (other.OptionalString != "") { + OptionalString = other.OptionalString; + } + if (other.OptionalBytes != pb::ByteString.Empty) { + OptionalBytes = other.OptionalBytes; + } + if (other.HasOptionalNestedMessage) { + MergeOptionalNestedMessage(other.OptionalNestedMessage); + } + if (other.HasOptionalForeignMessage) { + MergeOptionalForeignMessage(other.OptionalForeignMessage); + } + if (other.HasOptionalProto2Message) { + MergeOptionalProto2Message(other.OptionalProto2Message); + } + if (other.OptionalNestedEnum != global::Google.ProtocolBuffers.TestProtos.Proto3.TestAllTypes.Types.NestedEnum.FOO) { + OptionalNestedEnum = other.OptionalNestedEnum; + } + if (other.OptionalForeignEnum != global::Google.ProtocolBuffers.TestProtos.Proto3.ForeignEnum.FOREIGN_FOO) { + OptionalForeignEnum = other.OptionalForeignEnum; + } + if (other.OptionalStringPiece != "") { + OptionalStringPiece = other.OptionalStringPiece; + } + if (other.OptionalCord != "") { + OptionalCord = other.OptionalCord; + } + 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.repeatedNestedMessage_.Count != 0) { + result.repeatedNestedMessage_.Add(other.repeatedNestedMessage_); + } + if (other.repeatedForeignMessage_.Count != 0) { + result.repeatedForeignMessage_.Add(other.repeatedForeignMessage_); + } + if (other.repeatedProto2Message_.Count != 0) { + result.repeatedProto2Message_.Add(other.repeatedProto2Message_); + } + if (other.repeatedNestedEnum_.Count != 0) { + result.repeatedNestedEnum_.Add(other.repeatedNestedEnum_); + } + if (other.repeatedForeignEnum_.Count != 0) { + result.repeatedForeignEnum_.Add(other.repeatedForeignEnum_); + } + 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.OneofUint32 != 0) { + OneofUint32 = other.OneofUint32; + } + if (other.HasOneofNestedMessage) { + MergeOneofNestedMessage(other.OneofNestedMessage); + } + if (other.OneofString != "") { + OneofString = other.OneofString; + } + if (other.OneofEnum != global::Google.ProtocolBuffers.TestProtos.Proto3.TestAllTypes.Types.NestedEnum.FOO) { + OneofEnum = other.OneofEnum; + } + 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: { + input.ReadInt32(ref result.optionalInt32_); + break; + } + case 16: { + input.ReadInt64(ref result.optionalInt64_); + break; + } + case 24: { + input.ReadUInt32(ref result.optionalUint32_); + break; + } + case 32: { + input.ReadUInt64(ref result.optionalUint64_); + break; + } + case 40: { + input.ReadSInt32(ref result.optionalSint32_); + break; + } + case 48: { + input.ReadSInt64(ref result.optionalSint64_); + break; + } + case 61: { + input.ReadFixed32(ref result.optionalFixed32_); + break; + } + case 65: { + input.ReadFixed64(ref result.optionalFixed64_); + break; + } + case 77: { + input.ReadSFixed32(ref result.optionalSfixed32_); + break; + } + case 81: { + input.ReadSFixed64(ref result.optionalSfixed64_); + break; + } + case 93: { + input.ReadFloat(ref result.optionalFloat_); + break; + } + case 97: { + input.ReadDouble(ref result.optionalDouble_); + break; + } + case 104: { + input.ReadBool(ref result.optionalBool_); + break; + } + case 114: { + input.ReadString(ref result.optionalString_); + break; + } + case 122: { + input.ReadBytes(ref result.optionalBytes_); + break; + } + case 146: { + global::Google.ProtocolBuffers.TestProtos.Proto3.TestAllTypes.Types.NestedMessage.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.Proto3.TestAllTypes.Types.NestedMessage.CreateBuilder(); + if (result.hasOptionalNestedMessage) { + subBuilder.MergeFrom(OptionalNestedMessage); + } + input.ReadMessage(subBuilder, extensionRegistry); + OptionalNestedMessage = subBuilder.BuildPartial(); + break; + } + case 154: { + global::Google.ProtocolBuffers.TestProtos.Proto3.ForeignMessage.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.Proto3.ForeignMessage.CreateBuilder(); + if (result.hasOptionalForeignMessage) { + subBuilder.MergeFrom(OptionalForeignMessage); + } + input.ReadMessage(subBuilder, extensionRegistry); + OptionalForeignMessage = subBuilder.BuildPartial(); + break; + } + case 162: { + global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.CreateBuilder(); + if (result.hasOptionalProto2Message) { + subBuilder.MergeFrom(OptionalProto2Message); + } + input.ReadMessage(subBuilder, extensionRegistry); + OptionalProto2Message = subBuilder.BuildPartial(); + break; + } + case 168: { + object unknown; + if(input.ReadEnum(ref result.optionalNestedEnum_, out unknown)) { + } 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)) { + } else if(unknown is int) { + if (unknownFields == null) { + unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); + } + unknownFields.MergeVarintField(22, (ulong)(int)unknown); + } + break; + } + case 194: { + input.ReadString(ref result.optionalStringPiece_); + break; + } + case 202: { + input.ReadString(ref result.optionalCord_); + break; + } + case 242: { + global::Google.ProtocolBuffers.TestProtos.Proto3.TestAllTypes.Types.NestedMessage.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.Proto3.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 386: { + input.ReadMessageArray(tag, field_name, result.repeatedNestedMessage_, global::Google.ProtocolBuffers.TestProtos.Proto3.TestAllTypes.Types.NestedMessage.DefaultInstance, extensionRegistry); + break; + } + case 394: { + input.ReadMessageArray(tag, field_name, result.repeatedForeignMessage_, global::Google.ProtocolBuffers.TestProtos.Proto3.ForeignMessage.DefaultInstance, extensionRegistry); + break; + } + case 402: { + input.ReadMessageArray(tag, field_name, result.repeatedProto2Message_, global::Google.ProtocolBuffers.TestProtos.TestAllTypes.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 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.Proto3.TestAllTypes.Types.NestedMessage.DefaultInstance, extensionRegistry); + break; + } + case 888: { + input.ReadUInt32(ref result.oneofUint32_); + break; + } + case 898: { + global::Google.ProtocolBuffers.TestProtos.Proto3.TestAllTypes.Types.NestedMessage.Builder subBuilder = global::Google.ProtocolBuffers.TestProtos.Proto3.TestAllTypes.Types.NestedMessage.CreateBuilder(); + if (result.hasOneofNestedMessage) { + subBuilder.MergeFrom(OneofNestedMessage); + } + input.ReadMessage(subBuilder, extensionRegistry); + OneofNestedMessage = subBuilder.BuildPartial(); + break; + } + case 906: { + input.ReadString(ref result.oneofString_); + break; + } + case 912: { + object unknown; + if(input.ReadEnum(ref result.oneofEnum_, out unknown)) { + } else if(unknown is int) { + if (unknownFields == null) { + unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields); + } + unknownFields.MergeVarintField(114, (ulong)(int)unknown); + } + break; + } + } + } + + if (unknownFields != null) { + this.UnknownFields = unknownFields.Build(); + } + return this; + } + + + public int OptionalInt32 { + get { return result.OptionalInt32; } + set { SetOptionalInt32(value); } + } + public Builder SetOptionalInt32(int value) { + PrepareBuilder(); + result.optionalInt32_ = value; + return this; + } + public Builder ClearOptionalInt32() { + PrepareBuilder(); + result.optionalInt32_ = 0; + return this; + } + + public long OptionalInt64 { + get { return result.OptionalInt64; } + set { SetOptionalInt64(value); } + } + public Builder SetOptionalInt64(long value) { + PrepareBuilder(); + result.optionalInt64_ = value; + return this; + } + public Builder ClearOptionalInt64() { + PrepareBuilder(); + result.optionalInt64_ = 0L; + return this; + } + + public uint OptionalUint32 { + get { return result.OptionalUint32; } + set { SetOptionalUint32(value); } + } + public Builder SetOptionalUint32(uint value) { + PrepareBuilder(); + result.optionalUint32_ = value; + return this; + } + public Builder ClearOptionalUint32() { + PrepareBuilder(); + result.optionalUint32_ = 0; + return this; + } + + public ulong OptionalUint64 { + get { return result.OptionalUint64; } + set { SetOptionalUint64(value); } + } + public Builder SetOptionalUint64(ulong value) { + PrepareBuilder(); + result.optionalUint64_ = value; + return this; + } + public Builder ClearOptionalUint64() { + PrepareBuilder(); + result.optionalUint64_ = 0UL; + return this; + } + + public int OptionalSint32 { + get { return result.OptionalSint32; } + set { SetOptionalSint32(value); } + } + public Builder SetOptionalSint32(int value) { + PrepareBuilder(); + result.optionalSint32_ = value; + return this; + } + public Builder ClearOptionalSint32() { + PrepareBuilder(); + result.optionalSint32_ = 0; + return this; + } + + public long OptionalSint64 { + get { return result.OptionalSint64; } + set { SetOptionalSint64(value); } + } + public Builder SetOptionalSint64(long value) { + PrepareBuilder(); + result.optionalSint64_ = value; + return this; + } + public Builder ClearOptionalSint64() { + PrepareBuilder(); + result.optionalSint64_ = 0L; + return this; + } + + public uint OptionalFixed32 { + get { return result.OptionalFixed32; } + set { SetOptionalFixed32(value); } + } + public Builder SetOptionalFixed32(uint value) { + PrepareBuilder(); + result.optionalFixed32_ = value; + return this; + } + public Builder ClearOptionalFixed32() { + PrepareBuilder(); + result.optionalFixed32_ = 0; + return this; + } + + public ulong OptionalFixed64 { + get { return result.OptionalFixed64; } + set { SetOptionalFixed64(value); } + } + public Builder SetOptionalFixed64(ulong value) { + PrepareBuilder(); + result.optionalFixed64_ = value; + return this; + } + public Builder ClearOptionalFixed64() { + PrepareBuilder(); + result.optionalFixed64_ = 0UL; + return this; + } + + public int OptionalSfixed32 { + get { return result.OptionalSfixed32; } + set { SetOptionalSfixed32(value); } + } + public Builder SetOptionalSfixed32(int value) { + PrepareBuilder(); + result.optionalSfixed32_ = value; + return this; + } + public Builder ClearOptionalSfixed32() { + PrepareBuilder(); + result.optionalSfixed32_ = 0; + return this; + } + + public long OptionalSfixed64 { + get { return result.OptionalSfixed64; } + set { SetOptionalSfixed64(value); } + } + public Builder SetOptionalSfixed64(long value) { + PrepareBuilder(); + result.optionalSfixed64_ = value; + return this; + } + public Builder ClearOptionalSfixed64() { + PrepareBuilder(); + result.optionalSfixed64_ = 0L; + return this; + } + + public float OptionalFloat { + get { return result.OptionalFloat; } + set { SetOptionalFloat(value); } + } + public Builder SetOptionalFloat(float value) { + PrepareBuilder(); + result.optionalFloat_ = value; + return this; + } + public Builder ClearOptionalFloat() { + PrepareBuilder(); + result.optionalFloat_ = 0F; + return this; + } + + public double OptionalDouble { + get { return result.OptionalDouble; } + set { SetOptionalDouble(value); } + } + public Builder SetOptionalDouble(double value) { + PrepareBuilder(); + result.optionalDouble_ = value; + return this; + } + public Builder ClearOptionalDouble() { + PrepareBuilder(); + result.optionalDouble_ = 0D; + return this; + } + + public bool OptionalBool { + get { return result.OptionalBool; } + set { SetOptionalBool(value); } + } + public Builder SetOptionalBool(bool value) { + PrepareBuilder(); + result.optionalBool_ = value; + return this; + } + public Builder ClearOptionalBool() { + PrepareBuilder(); + result.optionalBool_ = false; + return this; + } + + public string OptionalString { + get { return result.OptionalString; } + set { SetOptionalString(value); } + } + public Builder SetOptionalString(string value) { + pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); + result.optionalString_ = value; + return this; + } + public Builder ClearOptionalString() { + PrepareBuilder(); + result.optionalString_ = ""; + return this; + } + + public pb::ByteString OptionalBytes { + get { return result.OptionalBytes; } + set { SetOptionalBytes(value); } + } + public Builder SetOptionalBytes(pb::ByteString value) { + pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); + result.optionalBytes_ = value; + return this; + } + public Builder ClearOptionalBytes() { + PrepareBuilder(); + result.optionalBytes_ = pb::ByteString.Empty; + return this; + } + + public bool HasOptionalNestedMessage { + get { return result.hasOptionalNestedMessage; } + } + public global::Google.ProtocolBuffers.TestProtos.Proto3.TestAllTypes.Types.NestedMessage OptionalNestedMessage { + get { return result.OptionalNestedMessage; } + set { SetOptionalNestedMessage(value); } + } + public Builder SetOptionalNestedMessage(global::Google.ProtocolBuffers.TestProtos.Proto3.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.Proto3.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.Proto3.TestAllTypes.Types.NestedMessage value) { + pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); + if (result.hasOptionalNestedMessage && + result.optionalNestedMessage_ != global::Google.ProtocolBuffers.TestProtos.Proto3.TestAllTypes.Types.NestedMessage.DefaultInstance) { + result.optionalNestedMessage_ = global::Google.ProtocolBuffers.TestProtos.Proto3.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.Proto3.ForeignMessage OptionalForeignMessage { + get { return result.OptionalForeignMessage; } + set { SetOptionalForeignMessage(value); } + } + public Builder SetOptionalForeignMessage(global::Google.ProtocolBuffers.TestProtos.Proto3.ForeignMessage value) { + pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); + result.hasOptionalForeignMessage = true; + result.optionalForeignMessage_ = value; + return this; + } + public Builder SetOptionalForeignMessage(global::Google.ProtocolBuffers.TestProtos.Proto3.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.Proto3.ForeignMessage value) { + pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); + if (result.hasOptionalForeignMessage && + result.optionalForeignMessage_ != global::Google.ProtocolBuffers.TestProtos.Proto3.ForeignMessage.DefaultInstance) { + result.optionalForeignMessage_ = global::Google.ProtocolBuffers.TestProtos.Proto3.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 HasOptionalProto2Message { + get { return result.hasOptionalProto2Message; } + } + public global::Google.ProtocolBuffers.TestProtos.TestAllTypes OptionalProto2Message { + get { return result.OptionalProto2Message; } + set { SetOptionalProto2Message(value); } + } + public Builder SetOptionalProto2Message(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { + pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); + result.hasOptionalProto2Message = true; + result.optionalProto2Message_ = value; + return this; + } + public Builder SetOptionalProto2Message(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder builderForValue) { + pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); + result.hasOptionalProto2Message = true; + result.optionalProto2Message_ = builderForValue.Build(); + return this; + } + public Builder MergeOptionalProto2Message(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { + pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); + if (result.hasOptionalProto2Message && + result.optionalProto2Message_ != global::Google.ProtocolBuffers.TestProtos.TestAllTypes.DefaultInstance) { + result.optionalProto2Message_ = global::Google.ProtocolBuffers.TestProtos.TestAllTypes.CreateBuilder(result.optionalProto2Message_).MergeFrom(value).BuildPartial(); + } else { + result.optionalProto2Message_ = value; + } + result.hasOptionalProto2Message = true; + return this; + } + public Builder ClearOptionalProto2Message() { + PrepareBuilder(); + result.hasOptionalProto2Message = false; + result.optionalProto2Message_ = null; + return this; + } + + public global::Google.ProtocolBuffers.TestProtos.Proto3.TestAllTypes.Types.NestedEnum OptionalNestedEnum { + get { return result.OptionalNestedEnum; } + set { SetOptionalNestedEnum(value); } + } + public Builder SetOptionalNestedEnum(global::Google.ProtocolBuffers.TestProtos.Proto3.TestAllTypes.Types.NestedEnum value) { + PrepareBuilder(); + result.optionalNestedEnum_ = value; + return this; + } + public Builder ClearOptionalNestedEnum() { + PrepareBuilder(); + result.optionalNestedEnum_ = global::Google.ProtocolBuffers.TestProtos.Proto3.TestAllTypes.Types.NestedEnum.FOO; + return this; + } + + public global::Google.ProtocolBuffers.TestProtos.Proto3.ForeignEnum OptionalForeignEnum { + get { return result.OptionalForeignEnum; } + set { SetOptionalForeignEnum(value); } + } + public Builder SetOptionalForeignEnum(global::Google.ProtocolBuffers.TestProtos.Proto3.ForeignEnum value) { + PrepareBuilder(); + result.optionalForeignEnum_ = value; + return this; + } + public Builder ClearOptionalForeignEnum() { + PrepareBuilder(); + result.optionalForeignEnum_ = global::Google.ProtocolBuffers.TestProtos.Proto3.ForeignEnum.FOREIGN_FOO; + return this; + } + + public string OptionalStringPiece { + get { return result.OptionalStringPiece; } + set { SetOptionalStringPiece(value); } + } + public Builder SetOptionalStringPiece(string value) { + pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); + result.optionalStringPiece_ = value; + return this; + } + public Builder ClearOptionalStringPiece() { + PrepareBuilder(); + result.optionalStringPiece_ = ""; + return this; + } + + public string OptionalCord { + get { return result.OptionalCord; } + set { SetOptionalCord(value); } + } + public Builder SetOptionalCord(string value) { + pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); + result.optionalCord_ = value; + return this; + } + public Builder ClearOptionalCord() { + PrepareBuilder(); + result.optionalCord_ = ""; + return this; + } + + public bool HasOptionalLazyMessage { + get { return result.hasOptionalLazyMessage; } + } + public global::Google.ProtocolBuffers.TestProtos.Proto3.TestAllTypes.Types.NestedMessage OptionalLazyMessage { + get { return result.OptionalLazyMessage; } + set { SetOptionalLazyMessage(value); } + } + public Builder SetOptionalLazyMessage(global::Google.ProtocolBuffers.TestProtos.Proto3.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.Proto3.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.Proto3.TestAllTypes.Types.NestedMessage value) { + pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); + if (result.hasOptionalLazyMessage && + result.optionalLazyMessage_ != global::Google.ProtocolBuffers.TestProtos.Proto3.TestAllTypes.Types.NestedMessage.DefaultInstance) { + result.optionalLazyMessage_ = global::Google.ProtocolBuffers.TestProtos.Proto3.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 RepeatedNestedMessageList { + get { return PrepareBuilder().repeatedNestedMessage_; } + } + public int RepeatedNestedMessageCount { + get { return result.RepeatedNestedMessageCount; } + } + public global::Google.ProtocolBuffers.TestProtos.Proto3.TestAllTypes.Types.NestedMessage GetRepeatedNestedMessage(int index) { + return result.GetRepeatedNestedMessage(index); + } + public Builder SetRepeatedNestedMessage(int index, global::Google.ProtocolBuffers.TestProtos.Proto3.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.Proto3.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.Proto3.TestAllTypes.Types.NestedMessage value) { + pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); + result.repeatedNestedMessage_.Add(value); + return this; + } + public Builder AddRepeatedNestedMessage(global::Google.ProtocolBuffers.TestProtos.Proto3.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.Proto3.ForeignMessage GetRepeatedForeignMessage(int index) { + return result.GetRepeatedForeignMessage(index); + } + public Builder SetRepeatedForeignMessage(int index, global::Google.ProtocolBuffers.TestProtos.Proto3.ForeignMessage value) { + pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); + result.repeatedForeignMessage_[index] = value; + return this; + } + public Builder SetRepeatedForeignMessage(int index, global::Google.ProtocolBuffers.TestProtos.Proto3.ForeignMessage.Builder builderForValue) { + pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); + result.repeatedForeignMessage_[index] = builderForValue.Build(); + return this; + } + public Builder AddRepeatedForeignMessage(global::Google.ProtocolBuffers.TestProtos.Proto3.ForeignMessage value) { + pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); + result.repeatedForeignMessage_.Add(value); + return this; + } + public Builder AddRepeatedForeignMessage(global::Google.ProtocolBuffers.TestProtos.Proto3.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 RepeatedProto2MessageList { + get { return PrepareBuilder().repeatedProto2Message_; } + } + public int RepeatedProto2MessageCount { + get { return result.RepeatedProto2MessageCount; } + } + public global::Google.ProtocolBuffers.TestProtos.TestAllTypes GetRepeatedProto2Message(int index) { + return result.GetRepeatedProto2Message(index); + } + public Builder SetRepeatedProto2Message(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { + pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); + result.repeatedProto2Message_[index] = value; + return this; + } + public Builder SetRepeatedProto2Message(int index, global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder builderForValue) { + pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); + result.repeatedProto2Message_[index] = builderForValue.Build(); + return this; + } + public Builder AddRepeatedProto2Message(global::Google.ProtocolBuffers.TestProtos.TestAllTypes value) { + pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); + result.repeatedProto2Message_.Add(value); + return this; + } + public Builder AddRepeatedProto2Message(global::Google.ProtocolBuffers.TestProtos.TestAllTypes.Builder builderForValue) { + pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); + result.repeatedProto2Message_.Add(builderForValue.Build()); + return this; + } + public Builder AddRangeRepeatedProto2Message(scg::IEnumerable values) { + PrepareBuilder(); + result.repeatedProto2Message_.Add(values); + return this; + } + public Builder ClearRepeatedProto2Message() { + PrepareBuilder(); + result.repeatedProto2Message_.Clear(); + return this; + } + + public pbc::IPopsicleList RepeatedNestedEnumList { + get { return PrepareBuilder().repeatedNestedEnum_; } + } + public int RepeatedNestedEnumCount { + get { return result.RepeatedNestedEnumCount; } + } + public global::Google.ProtocolBuffers.TestProtos.Proto3.TestAllTypes.Types.NestedEnum GetRepeatedNestedEnum(int index) { + return result.GetRepeatedNestedEnum(index); + } + public Builder SetRepeatedNestedEnum(int index, global::Google.ProtocolBuffers.TestProtos.Proto3.TestAllTypes.Types.NestedEnum value) { + PrepareBuilder(); + result.repeatedNestedEnum_[index] = value; + return this; + } + public Builder AddRepeatedNestedEnum(global::Google.ProtocolBuffers.TestProtos.Proto3.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.Proto3.ForeignEnum GetRepeatedForeignEnum(int index) { + return result.GetRepeatedForeignEnum(index); + } + public Builder SetRepeatedForeignEnum(int index, global::Google.ProtocolBuffers.TestProtos.Proto3.ForeignEnum value) { + PrepareBuilder(); + result.repeatedForeignEnum_[index] = value; + return this; + } + public Builder AddRepeatedForeignEnum(global::Google.ProtocolBuffers.TestProtos.Proto3.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 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.Proto3.TestAllTypes.Types.NestedMessage GetRepeatedLazyMessage(int index) { + return result.GetRepeatedLazyMessage(index); + } + public Builder SetRepeatedLazyMessage(int index, global::Google.ProtocolBuffers.TestProtos.Proto3.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.Proto3.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.Proto3.TestAllTypes.Types.NestedMessage value) { + pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); + result.repeatedLazyMessage_.Add(value); + return this; + } + public Builder AddRepeatedLazyMessage(global::Google.ProtocolBuffers.TestProtos.Proto3.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 uint OneofUint32 { + get { return result.OneofUint32; } + set { SetOneofUint32(value); } + } + public Builder SetOneofUint32(uint value) { + PrepareBuilder(); + result.oneofUint32_ = value; + return this; + } + public Builder ClearOneofUint32() { + PrepareBuilder(); + result.oneofUint32_ = 0; + return this; + } + + public bool HasOneofNestedMessage { + get { return result.hasOneofNestedMessage; } + } + public global::Google.ProtocolBuffers.TestProtos.Proto3.TestAllTypes.Types.NestedMessage OneofNestedMessage { + get { return result.OneofNestedMessage; } + set { SetOneofNestedMessage(value); } + } + public Builder SetOneofNestedMessage(global::Google.ProtocolBuffers.TestProtos.Proto3.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.Proto3.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.Proto3.TestAllTypes.Types.NestedMessage value) { + pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); + if (result.hasOneofNestedMessage && + result.oneofNestedMessage_ != global::Google.ProtocolBuffers.TestProtos.Proto3.TestAllTypes.Types.NestedMessage.DefaultInstance) { + result.oneofNestedMessage_ = global::Google.ProtocolBuffers.TestProtos.Proto3.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 string OneofString { + get { return result.OneofString; } + set { SetOneofString(value); } + } + public Builder SetOneofString(string value) { + pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); + result.oneofString_ = value; + return this; + } + public Builder ClearOneofString() { + PrepareBuilder(); + result.oneofString_ = ""; + return this; + } + + public global::Google.ProtocolBuffers.TestProtos.Proto3.TestAllTypes.Types.NestedEnum OneofEnum { + get { return result.OneofEnum; } + set { SetOneofEnum(value); } + } + public Builder SetOneofEnum(global::Google.ProtocolBuffers.TestProtos.Proto3.TestAllTypes.Types.NestedEnum value) { + PrepareBuilder(); + result.oneofEnum_ = value; + return this; + } + public Builder ClearOneofEnum() { + PrepareBuilder(); + result.oneofEnum_ = global::Google.ProtocolBuffers.TestProtos.Proto3.TestAllTypes.Types.NestedEnum.FOO; + return this; + } + } + static TestAllTypes() { + object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Proto3.UnittestNoFieldPresence.Descriptor, null); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class TestProto2Required : pb::GeneratedMessage { + private TestProto2Required() { } + private static readonly TestProto2Required defaultInstance = new TestProto2Required().MakeReadOnly(); + private static readonly string[] _testProto2RequiredFieldNames = new string[] { "proto2" }; + private static readonly uint[] _testProto2RequiredFieldTags = new uint[] { 10 }; + public static TestProto2Required DefaultInstance { + get { return defaultInstance; } + } + + public override TestProto2Required DefaultInstanceForType { + get { return DefaultInstance; } + } + + protected override TestProto2Required ThisMessage { + get { return this; } + } + + public static pbd::MessageDescriptor Descriptor { + get { return global::Google.ProtocolBuffers.TestProtos.Proto3.UnittestNoFieldPresence.internal__static_proto2_nofieldpresence_unittest_TestProto2Required__Descriptor; } + } + + protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { + get { return global::Google.ProtocolBuffers.TestProtos.Proto3.UnittestNoFieldPresence.internal__static_proto2_nofieldpresence_unittest_TestProto2Required__FieldAccessorTable; } + } + + public const int Proto2FieldNumber = 1; + private bool hasProto2; + private global::Google.ProtocolBuffers.TestProtos.TestRequired proto2_; + public bool HasProto2 { + get { return hasProto2; } + } + public global::Google.ProtocolBuffers.TestProtos.TestRequired Proto2 { + get { return proto2_ ?? global::Google.ProtocolBuffers.TestProtos.TestRequired.DefaultInstance; } + } + + public override void WriteTo(pb::ICodedOutputStream output) { + CalcSerializedSize(); + string[] field_names = _testProto2RequiredFieldNames; + if (hasProto2) { + output.WriteMessage(1, field_names[0], Proto2); + } + 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 (hasProto2) { + size += pb::CodedOutputStream.ComputeMessageSize(1, Proto2); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } + public static TestProto2Required ParseFrom(pb::ByteString data) { + return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); + } + public static TestProto2Required ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { + return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); + } + public static TestProto2Required ParseFrom(byte[] data) { + return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); + } + public static TestProto2Required ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { + return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); + } + public static TestProto2Required ParseFrom(global::System.IO.Stream input) { + return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); + } + public static TestProto2Required ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { + return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); + } + public static TestProto2Required ParseDelimitedFrom(global::System.IO.Stream input) { + return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); + } + public static TestProto2Required ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { + return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); + } + public static TestProto2Required ParseFrom(pb::ICodedInputStream input) { + return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); + } + public static TestProto2Required ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { + return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); + } + private TestProto2Required 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(TestProto2Required 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(TestProto2Required cloneFrom) { + result = cloneFrom; + resultIsReadOnly = true; + } + + private bool resultIsReadOnly; + private TestProto2Required result; + + private TestProto2Required PrepareBuilder() { + if (resultIsReadOnly) { + TestProto2Required original = result; + result = new TestProto2Required(); + resultIsReadOnly = false; + MergeFrom(original); + } + return result; + } + + public override bool IsInitialized { + get { return result.IsInitialized; } + } + + protected override TestProto2Required 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.Proto3.TestProto2Required.Descriptor; } + } + + public override TestProto2Required DefaultInstanceForType { + get { return global::Google.ProtocolBuffers.TestProtos.Proto3.TestProto2Required.DefaultInstance; } + } + + public override TestProto2Required BuildPartial() { + if (resultIsReadOnly) { + return result; + } + resultIsReadOnly = true; + return result.MakeReadOnly(); + } + + public override Builder MergeFrom(pb::IMessage other) { + if (other is TestProto2Required) { + return MergeFrom((TestProto2Required) other); + } else { + base.MergeFrom(other); + return this; + } + } + + public override Builder MergeFrom(TestProto2Required other) { + if (other == global::Google.ProtocolBuffers.TestProtos.Proto3.TestProto2Required.DefaultInstance) return this; + PrepareBuilder(); + if (other.HasProto2) { + MergeProto2(other.Proto2); + } + 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(_testProto2RequiredFieldNames, field_name, global::System.StringComparer.Ordinal); + if(field_ordinal >= 0) + tag = _testProto2RequiredFieldTags[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.hasProto2) { + subBuilder.MergeFrom(Proto2); + } + input.ReadMessage(subBuilder, extensionRegistry); + Proto2 = subBuilder.BuildPartial(); + break; + } + } + } + + if (unknownFields != null) { + this.UnknownFields = unknownFields.Build(); + } + return this; + } + + + public bool HasProto2 { + get { return result.hasProto2; } + } + public global::Google.ProtocolBuffers.TestProtos.TestRequired Proto2 { + get { return result.Proto2; } + set { SetProto2(value); } + } + public Builder SetProto2(global::Google.ProtocolBuffers.TestProtos.TestRequired value) { + pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); + result.hasProto2 = true; + result.proto2_ = value; + return this; + } + public Builder SetProto2(global::Google.ProtocolBuffers.TestProtos.TestRequired.Builder builderForValue) { + pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue"); + PrepareBuilder(); + result.hasProto2 = true; + result.proto2_ = builderForValue.Build(); + return this; + } + public Builder MergeProto2(global::Google.ProtocolBuffers.TestProtos.TestRequired value) { + pb::ThrowHelper.ThrowIfNull(value, "value"); + PrepareBuilder(); + if (result.hasProto2 && + result.proto2_ != global::Google.ProtocolBuffers.TestProtos.TestRequired.DefaultInstance) { + result.proto2_ = global::Google.ProtocolBuffers.TestProtos.TestRequired.CreateBuilder(result.proto2_).MergeFrom(value).BuildPartial(); + } else { + result.proto2_ = value; + } + result.hasProto2 = true; + return this; + } + public Builder ClearProto2() { + PrepareBuilder(); + result.hasProto2 = false; + result.proto2_ = null; + return this; + } + } + static TestProto2Required() { + object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Proto3.UnittestNoFieldPresence.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.Proto3.UnittestNoFieldPresence.internal__static_proto2_nofieldpresence_unittest_ForeignMessage__Descriptor; } + } + + protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors { + get { return global::Google.ProtocolBuffers.TestProtos.Proto3.UnittestNoFieldPresence.internal__static_proto2_nofieldpresence_unittest_ForeignMessage__FieldAccessorTable; } + } + + public const int CFieldNumber = 1; + private int c_; + public int C { + get { return c_; } + } + + public override void WriteTo(pb::ICodedOutputStream output) { + CalcSerializedSize(); + string[] field_names = _foreignMessageFieldNames; + if (C != 0) { + 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 (C != 0) { + 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.Proto3.ForeignMessage.Descriptor; } + } + + public override ForeignMessage DefaultInstanceForType { + get { return global::Google.ProtocolBuffers.TestProtos.Proto3.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.Proto3.ForeignMessage.DefaultInstance) return this; + PrepareBuilder(); + if (other.C != 0) { + 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: { + input.ReadInt32(ref result.c_); + break; + } + } + } + + if (unknownFields != null) { + this.UnknownFields = unknownFields.Build(); + } + return this; + } + + + public int C { + get { return result.C; } + set { SetC(value); } + } + public Builder SetC(int value) { + PrepareBuilder(); + result.c_ = value; + return this; + } + public Builder ClearC() { + PrepareBuilder(); + result.c_ = 0; + return this; + } + } + static ForeignMessage() { + object.ReferenceEquals(global::Google.ProtocolBuffers.TestProtos.Proto3.UnittestNoFieldPresence.Descriptor, null); + } + } + + #endregion + +} + +#endregion Designer generated code diff --git a/src/google/protobuf/unittest_no_field_presence.proto b/src/google/protobuf/unittest_no_field_presence.proto index 6e71517c..f261b58e 100644 --- a/src/google/protobuf/unittest_no_field_presence.proto +++ b/src/google/protobuf/unittest_no_field_presence.proto @@ -37,7 +37,7 @@ import "google/protobuf/unittest.proto"; package proto2_nofieldpresence_unittest; -option csharp_namespace = "Google.ProtocolBuffers.TestProtos"; +option csharp_namespace = "Google.ProtocolBuffers.TestProtos.Proto3"; // This proto includes every type of field in both singular and repeated // forms. -- cgit v1.2.3